OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 let server = null; | 3 let server = null; |
4 let frame = null; | 4 let frame = null; |
5 | 5 |
6 module("Pop-up blocker", { | 6 module("Pop-up blocker", { |
7 setup: function() | 7 setup: function() |
8 { | 8 { |
9 prepareFilterComponents.call(this, true); | 9 prepareFilterComponents.call(this, true); |
10 preparePrefs.call(this); | 10 preparePrefs.call(this); |
11 | 11 |
12 server = new nsHttpServer(); | 12 server = new nsHttpServer(); |
13 server.start(1234); | 13 server.start(1234); |
14 | 14 |
15 server.registerPathHandler("/test", function(metadata, response) | 15 server.registerPathHandler("/test", function(metadata, response) |
16 { | 16 { |
17 response.setStatusLine("1.1", "200", "OK"); | 17 response.setStatusLine("1.1", "200", "OK"); |
18 response.setHeader("Content-Type", "text/html; charset=utf-8"); | 18 response.setHeader("Content-Type", "text/html; charset=utf-8"); |
19 | 19 |
20 let body = '<html><body><a id="link" href="/redirect" target="_blank">li
nk</a></body></html>'; | 20 let body = |
| 21 '<body onload="document.dispatchEvent(new CustomEvent(\'frameready\',
{bubbles: true}));">' + |
| 22 '<a id="link" href="/redirect" target="_blank">link</a>' + |
| 23 '</body>'; |
21 response.bodyOutputStream.write(body, body.length); | 24 response.bodyOutputStream.write(body, body.length); |
22 }); | 25 }); |
23 server.registerPathHandler("/redirect", function(metadata, response) | 26 server.registerPathHandler("/redirect", function(metadata, response) |
24 { | 27 { |
25 response.setStatusLine("1.1", "302", "Moved Temporarily"); | 28 response.setStatusLine("1.1", "302", "Moved Temporarily"); |
26 response.setHeader("Location", "http://127.0.0.1:1234/target"); | 29 response.setHeader("Location", "http://127.0.0.1:1234/target"); |
27 }); | 30 }); |
28 server.registerPathHandler("/target", function(metadata, response) | 31 server.registerPathHandler("/target", function(metadata, response) |
29 { | 32 { |
30 response.setStatusLine("1.1", "302", "Moved Temporarily"); | |
31 response.setHeader("Content-Type", "text/html; charset=utf-8"); | 33 response.setHeader("Content-Type", "text/html; charset=utf-8"); |
32 | 34 |
33 let body = '<html><body>OK</body></html>'; | 35 let body = '<html><body>OK</body></html>'; |
34 response.bodyOutputStream.write(body, body.length); | 36 response.bodyOutputStream.write(body, body.length); |
35 }); | 37 }); |
36 | 38 |
37 frame = document.createElement("iframe"); | 39 frame = document.createElementNS("http://www.mozilla.org/keymaster/gatekee
per/there.is.only.xul", "iframe"); |
| 40 frame.setAttribute("type", "content"); |
38 frame.setAttribute("src", "http://127.0.0.1:1234/test"); | 41 frame.setAttribute("src", "http://127.0.0.1:1234/test"); |
39 frame.style.visibility = "collapse"; | 42 frame.style.visibility = "collapse"; |
40 document.body.appendChild(frame); | 43 document.body.appendChild(frame); |
41 | 44 |
42 stop(); | 45 stop(); |
43 frame.addEventListener("load", function(event) | 46 frame.addEventListener("frameready", function(event) |
44 { | 47 { |
45 start(); | 48 start(); |
46 }, false); | 49 }, false, true); |
47 }, | 50 }, |
48 teardown: function() | 51 teardown: function() |
49 { | 52 { |
50 restoreFilterComponents.call(this); | 53 restoreFilterComponents.call(this); |
51 restorePrefs.call(this); | 54 restorePrefs.call(this); |
52 | 55 |
53 stop(); | 56 stop(); |
54 server.stop(function() | 57 server.stop(function() |
55 { | 58 { |
56 frame.parentElement.removeChild(frame); | 59 frame.parentElement.removeChild(frame); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 wnd.gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, false); | 118 wnd.gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, false); |
116 wnd.gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false); | 119 wnd.gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false); |
117 let timeout = window.setTimeout(onTabClose, 1000); // In case the tab isn
't opened | 120 let timeout = window.setTimeout(onTabClose, 1000); // In case the tab isn
't opened |
118 | 121 |
119 frame.contentDocument.getElementById("link").click(); | 122 frame.contentDocument.getElementById("link").click(); |
120 } | 123 } |
121 | 124 |
122 for (let [filter, result] of tests) | 125 for (let [filter, result] of tests) |
123 asyncTest(filter, runTest.bind(null, Filter.fromText(filter), result)); | 126 asyncTest(filter, runTest.bind(null, Filter.fromText(filter), result)); |
124 })(); | 127 })(); |
OLD | NEW |