5 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"/>
7 <script type=
"application/javascript">
9 SimpleTest.waitForExplicitFinish();
10 addLoadEvent(runNextTest);
12 var TEST_URL =
"http://mochi.test:8888/tests/docshell/test/chrome/allowContentRetargeting.sjs";
14 function runNextTest() {
15 var test = tests.shift();
25 // Set allowContentRetargeting = false, load a downloadable URL, verify the
26 // downloadable stops loading.
28 var iframe = insertIframe();
29 iframe.contentWindow.docShell.allowContentRetargeting = false;
33 // Set allowContentRetargeting = false on parent docshell, load a downloadable
34 // URL, verify the downloadable stops loading.
36 var docshell = window.docShell;
37 docshell.allowContentRetargeting = false;
38 loadIframe(insertIframe());
42 function insertIframe() {
43 var iframe = document.createElement(
"iframe");
44 document.body.appendChild(iframe);
48 function loadIframe(iframe) {
49 iframe.setAttribute(
"src", TEST_URL);
50 iframe.contentWindow.docShell.
51 QueryInterface(Ci.nsIInterfaceRequestor).
52 getInterface(Ci.nsIWebProgress).
53 addProgressListener(progressListener,
54 Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
57 var progressListener = {
58 onStateChange(webProgress, req, flags, status) {
59 if (!(flags & Ci.nsIWebProgressListener.STATE_STOP))
61 is(Components.isSuccessCode(status), false,
62 "Downloadable should have failed to load");
63 document.querySelector(
"iframe").remove();
67 QueryInterface: ChromeUtils.generateQI([
"nsIWebProgressListener",
"nsISupportsWeakReference"]),