Created
June 6, 2017 08:48
-
-
Save allstarschh/cbb89503500f4a50359d87d98b505714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<!-- | |
https://bugzilla.mozilla.org/show_bug.cgi?id=1267075 | |
--> | |
<title>Test for Bug 1267075</title> | |
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> | |
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> | |
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> | |
</head> | |
<body onload="onLoad()"> | |
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1267075">Mozilla Bug 1267075</a> | |
<pre id="test"> | |
<script class="testbody" type="text/javascript"> | |
const { classes: Cc, interfaces: Ci } = Components; | |
SimpleTest.waitForExplicitFinish(); | |
function onLoad() { | |
var iframe = document.createElement("iframe"); | |
iframe.onload = function () { | |
info("iframe loaded"); | |
var winUtils = iframe.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor) | |
.getInterface(Ci.nsIDOMWindowUtils); | |
// load some styles at the agent level | |
var css = ` | |
img:-moz-suppressed { | |
display: none !important; | |
visibility: hidden !important; | |
}`; | |
var sheetURL = "data:text/css," + encodeURIComponent(css); | |
winUtils.loadSheetUsingURIString(sheetURL, winUtils.AGENT_SHEET); | |
var doc = iframe.contentDocument; | |
var img = doc.createElement("img"); | |
img.addEventListener("error", function() { | |
info("image error"); | |
is(img.matches(":-moz-suppressed"), "should match moz-suppressed selector."); | |
SimpleTest.finish(); | |
}); | |
// image from HTTP should be blocked. | |
img.src = "http://example.com/tests/image/test/mochitest/shaver.png"; | |
doc.body.appendChild(img); | |
}; | |
// file_blocking_image.html contains meta tag for CSP, which will block images from | |
// http. | |
iframe.src = "http://mochi.test:8888/chrome/dom/base/test/file_blocking_image.html"; | |
document.getElementById("content").appendChild(iframe); | |
} | |
</script> | |
</pre> | |
<p id="display"></p> | |
<div id="content"> | |
</div> | |
</body> </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment