mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1055750 - Mixed content tests for imageset r=tanvi
This commit is contained in:
parent
c6f8e09409
commit
8f5b9b410a
@ -27,6 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
websocket connections over https require an encrypted websocket protocol (wss:)
|
||||
|
||||
case nsIContentPolicy::TYPE_IMAGE:
|
||||
case nsIContentPolicy::TYPE_IMAGESET:
|
||||
case nsIContentPolicy::TYPE_MEDIA:
|
||||
case nsIContentPolicy::TYPE_PING:
|
||||
our ping implementation is off by default and does not comply with the current spec (bug 786347)
|
||||
@ -181,18 +182,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
|
||||
/* Part 2: Mixed Display tests */
|
||||
|
||||
// Shorthand for all image test variants
|
||||
function imgHandlers(img, test) {
|
||||
img.onload = function () {
|
||||
parent.postMessage({"test": test, "msg": "insecure image loaded"}, "http://mochi.test:8888");
|
||||
}
|
||||
img.onerror = function() {
|
||||
parent.postMessage({"test": test, "msg": "insecure image blocked"}, "http://mochi.test:8888");
|
||||
}
|
||||
}
|
||||
|
||||
// Test 2a: insecure image
|
||||
var img = document.createElement("img");
|
||||
img.src = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
img.onload = function() {
|
||||
parent.postMessage({"test": "image", "msg": "insecure image loaded"}, "http://mochi.test:8888");
|
||||
}
|
||||
img.onerror = function() {
|
||||
parent.postMessage({"test": "image", "msg": "insecure image blocked"}, "http://mochi.test:8888");
|
||||
}
|
||||
imgHandlers(img, "image");
|
||||
// We don't need to append the image to the document. Doing so causes the image test to run twice.
|
||||
|
||||
|
||||
// Test 2b: insecure media
|
||||
var media = document.createElement("video");
|
||||
media.src = "http://mochi.test:8888/tests/content/media/test/320x240.ogv?" + Math.floor((Math.random()*1000)+1);
|
||||
@ -207,6 +212,59 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
}
|
||||
// We don't need to append the video to the document. Doing so causes the image test to run twice.
|
||||
|
||||
/* Part 3: Mixed Active Tests for Image srcset */
|
||||
|
||||
// Test 3a: image with srcset
|
||||
var imgA = document.createElement("img");
|
||||
imgA.srcset = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
imgHandlers(imgA, "imageSrcset");
|
||||
|
||||
// Test 3b: image with srcset, using fallback from src, should still use imageset policy
|
||||
var imgB = document.createElement("img");
|
||||
imgB.srcset = " ";
|
||||
imgB.src = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
imgHandlers(imgB, "imageSrcsetFallback");
|
||||
|
||||
// Test 3c: image in <picture>
|
||||
var imgC = document.createElement("img");
|
||||
var pictureC = document.createElement("picture");
|
||||
var sourceC = document.createElement("source");
|
||||
sourceC.srcset = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
pictureC.appendChild(sourceC);
|
||||
pictureC.appendChild(imgC);
|
||||
imgHandlers(imgC, "imagePicture");
|
||||
|
||||
// Test 3d: Loaded basic image switching to a <picture>, loading
|
||||
// same source, should still redo the request with new
|
||||
// policy.
|
||||
var imgD = document.createElement("img");
|
||||
imgD.src = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
imgD.onload = imgD.onerror = function() {
|
||||
// Whether or not it loads, we want to now append it to a picture and observe
|
||||
var pictureD = document.createElement("picture");
|
||||
var sourceD = document.createElement("source");
|
||||
sourceD.srcset = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
pictureD.appendChild(sourceD);
|
||||
pictureD.appendChild(imgD);
|
||||
imgHandlers(imgD, "imageJoinPicture");
|
||||
}
|
||||
|
||||
// Test 3e: img load from <picture> source reverts to img.src as it
|
||||
// is removed -- the new request should revert to mixed
|
||||
// display policy
|
||||
var imgE = document.createElement("img");
|
||||
var pictureE = document.createElement("picture");
|
||||
var sourceE = document.createElement("source");
|
||||
sourceE.srcset = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
pictureE.appendChild(sourceE);
|
||||
pictureE.appendChild(imgE);
|
||||
imgE.src = "http://mochi.test:8888/tests/image/test/mochitest/blue.png";
|
||||
imgE.onload = imgE.onerror = function() {
|
||||
// Whether or not it loads, remove it from the picture and observe
|
||||
pictureE.removeChild(imgE)
|
||||
imgHandlers(imgE, "imageLeavePicture");
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -45,6 +45,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
var testsToRun = {
|
||||
iframe: false,
|
||||
image: false,
|
||||
imageSrcset: false,
|
||||
imageSrcsetFallback: false,
|
||||
imagePicture: false,
|
||||
imageJoinPicture: false,
|
||||
imageLeavePicture: false,
|
||||
script: false,
|
||||
stylesheet: false,
|
||||
object: false,
|
||||
@ -56,6 +61,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
document.getElementById("log").textContent += "\n" + msg;
|
||||
}
|
||||
|
||||
function reloadFrame() {
|
||||
document.getElementById('framediv').innerHTML = '<iframe id="testHarness" src="https://example.com/tests/content/base/test/file_mixed_content_main.html"></iframe>';
|
||||
}
|
||||
|
||||
function checkTestsCompleted() {
|
||||
for (var prop in testsToRun) {
|
||||
// some test hasn't run yet so we're not done
|
||||
@ -71,7 +80,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
changePrefs(counter);
|
||||
counter++;
|
||||
log("\nblockDisplay set to "+blockDisplay+", blockActive set to "+blockActive+".");
|
||||
document.getElementById('framediv').innerHTML = '<iframe id="testHarness" src="https://example.com/tests/content/base/test/file_mixed_content_main.html"></iframe>';
|
||||
reloadFrame();
|
||||
}
|
||||
else {
|
||||
//set the prefs back to what they were set to originally
|
||||
@ -125,7 +134,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
|
||||
/* Mixed Display tests */
|
||||
case "image":
|
||||
//test that the image load matches the pref for dipslay content
|
||||
//test that the image load matches the pref for display content
|
||||
ok(blockDisplay == (event.data.msg == "insecure image blocked"), "image did not follow block_display_content pref");
|
||||
testsToRun["image"] = true;
|
||||
break;
|
||||
@ -134,18 +143,53 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
|
||||
ok(blockDisplay == (event.data.msg == "insecure media blocked"), "media did not follow block_display_content pref");
|
||||
testsToRun["media"] = true;
|
||||
break;
|
||||
|
||||
/* Images using the "imageset" policy, from <img srcset> and <picture>, do not get the mixed display exception */
|
||||
case "imageSrcset":
|
||||
ok(blockActive == (event.data.msg == "insecure image blocked"), "imageSrcset did not follow block_active_content pref");
|
||||
testsToRun["imageSrcset"] = true;
|
||||
break;
|
||||
|
||||
case "imageSrcsetFallback":
|
||||
ok(blockActive == (event.data.msg == "insecure image blocked"), "imageSrcsetFallback did not follow block_active_content pref");
|
||||
testsToRun["imageSrcsetFallback"] = true;
|
||||
break;
|
||||
|
||||
case "imagePicture":
|
||||
ok(blockActive == (event.data.msg == "insecure image blocked"), "imagePicture did not follow block_active_content pref");
|
||||
testsToRun["imagePicture"] = true;
|
||||
break;
|
||||
|
||||
case "imageJoinPicture":
|
||||
ok(blockActive == (event.data.msg == "insecure image blocked"), "imageJoinPicture did not follow block_active_content pref");
|
||||
testsToRun["imageJoinPicture"] = true;
|
||||
break;
|
||||
|
||||
// Should return to mixed display mode
|
||||
case "imageLeavePicture":
|
||||
ok(blockDisplay == (event.data.msg == "insecure image blocked"), "imageLeavePicture did not follow block_display_content pref");
|
||||
testsToRun["imageLeavePicture"] = true;
|
||||
break;
|
||||
|
||||
}
|
||||
checkTestsCompleted();
|
||||
}
|
||||
|
||||
// Enable <picture> and <img srcset> for test
|
||||
SpecialPowers.pushPrefEnv({'set': [[ "dom.image.srcset.enabled", true ],
|
||||
[ "dom.image.picture.enabled", true ]] },
|
||||
function() {
|
||||
// Kick off test
|
||||
reloadFrame();
|
||||
});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="framediv">
|
||||
<iframe id="testHarness" src="https://example.com/tests/content/base/test/file_mixed_content_main.html"></iframe>
|
||||
</div>
|
||||
<div id="framediv"></div>
|
||||
<pre id="log"></pre>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user