Bug 1839316: part 5) Guard the "fetchpriority" attribute behind a pref. r=kershaw...
[gecko.git] / docshell / test / chrome / test_allowContentRetargeting.html
blobb6b830138f23a9d580494399a8b6e37d0e7c933d
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
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();
16 if (!test) {
17 SimpleTest.finish();
18 return;
20 test();
23 var tests = [
25 // Set allowContentRetargeting = false, load a downloadable URL, verify the
26 // downloadable stops loading.
27 function basic() {
28 var iframe = insertIframe();
29 iframe.contentWindow.docShell.allowContentRetargeting = false;
30 loadIframe(iframe);
33 // Set allowContentRetargeting = false on parent docshell, load a downloadable
34 // URL, verify the downloadable stops loading.
35 function inherit() {
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);
45 return 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))
60 return;
61 is(Components.isSuccessCode(status), false,
62 "Downloadable should have failed to load");
63 document.querySelector("iframe").remove();
64 runNextTest();
67 QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener", "nsISupportsWeakReference"]),
70 </script>
71 </head>
72 <body>
73 <p id="display">
74 </p>
75 </body>
76 </html>