Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/content/tests/popupBlocker.js

Issue 5745141503492096: Issue 1561 - Move unit tests out of the browser`s content area (Closed)
Left Patch Set: Final patch Created Nov. 15, 2014, 11:53 p.m.
Right Patch Set: Rebased patch Created Jan. 10, 2015, 12:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/content/tests/policy.js ('k') | chrome/content/tests/ui/icon_position.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 (function() 1 (function()
2 { 2 {
3 let server = null; 3 let server = null;
4 let wnd = null; 4 let wnd = null;
5 let tab = null; 5 let tab = null;
6 6
7 module("Pop-up blocker", { 7 module("Pop-up blocker", {
8 setup: function() 8 setup: function()
9 { 9 {
10 prepareFilterComponents.call(this, true); 10 prepareFilterComponents.call(this, true);
11 preparePrefs.call(this); 11 preparePrefs.call(this);
12 12
13 server = new nsHttpServer(); 13 server = new nsHttpServer();
14 server.start(1234); 14 server.start(1234);
15 15
16 server.registerPathHandler("/test", function(metadata, response) 16 server.registerPathHandler("/test", function(metadata, response)
17 { 17 {
18 response.setStatusLine("1.1", "200", "OK"); 18 response.setStatusLine("1.1", "200", "OK");
19 response.setHeader("Content-Type", "text/html; charset=utf-8"); 19 response.setHeader("Content-Type", "text/html; charset=utf-8");
20 20
21 let body = 21 let body =
22 '<body onload="document.dispatchEvent(new CustomEvent(\'frameready\', {bubbles: true}));">' + 22 '<body onload="document.dispatchEvent(new CustomEvent(\'abp:frameready \', {bubbles: true}));">' +
23 '<a id="link" href="/redirect" target="_blank">link</a>' + 23 '<a id="link" href="/redirect" target="_blank">link</a>' +
24 '</body>'; 24 '</body>';
25 response.bodyOutputStream.write(body, body.length); 25 response.bodyOutputStream.write(body, body.length);
26 }); 26 });
27 server.registerPathHandler("/redirect", function(metadata, response) 27 server.registerPathHandler("/redirect", function(metadata, response)
28 { 28 {
29 response.setStatusLine("1.1", "302", "Moved Temporarily"); 29 response.setStatusLine("1.1", "302", "Moved Temporarily");
30 response.setHeader("Location", "http://127.0.0.1:1234/target"); 30 response.setHeader("Location", "http://127.0.0.1:1234/target");
31 }); 31 });
32 server.registerPathHandler("/target", function(metadata, response) 32 server.registerPathHandler("/target", function(metadata, response)
33 { 33 {
34 response.setHeader("Content-Type", "text/html; charset=utf-8"); 34 response.setHeader("Content-Type", "text/html; charset=utf-8");
35 35
36 let body = '<html><body>OK</body></html>'; 36 let body = '<html><body>OK</body></html>';
37 response.bodyOutputStream.write(body, body.length); 37 response.bodyOutputStream.write(body, body.length);
38 }); 38 });
39 39
40 wnd = UI.currentWindow; 40 wnd = UI.currentWindow;
41 tab = wnd.gBrowser.loadOneTab("http://127.0.0.1:1234/test", {inBackground: false}); 41 tab = wnd.gBrowser.loadOneTab("http://127.0.0.1:1234/test", {inBackground: false});
42 wnd.gBrowser.getBrowserForTab(tab).addEventListener("frameready", function (event) 42 wnd.gBrowser.getBrowserForTab(tab).addEventListener("abp:frameready", func tion(event)
43 { 43 {
44 start(); 44 start();
45 }, false, true); 45 }, false, true);
46 46
47 stop(); 47 stop();
48 }, 48 },
49 teardown: function() 49 teardown: function()
50 { 50 {
51 restoreFilterComponents.call(this); 51 restoreFilterComponents.call(this);
52 restorePrefs.call(this); 52 restorePrefs.call(this);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 wnd.gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, false); 115 wnd.gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, false);
116 wnd.gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false); 116 wnd.gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false);
117 let timeout = window.setTimeout(onTabClose, 1000); // In case the tab isn 't opened 117 let timeout = window.setTimeout(onTabClose, 1000); // In case the tab isn 't opened
118 118
119 wnd.gBrowser.getBrowserForTab(tab).contentDocument.getElementById("link").cl ick(); 119 wnd.gBrowser.getBrowserForTab(tab).contentDocument.getElementById("link").cl ick();
120 } 120 }
121 121
122 for (let [filter, result] of tests) 122 for (let [filter, result] of tests)
123 asyncTest(filter, runTest.bind(null, Filter.fromText(filter), result)); 123 asyncTest(filter, runTest.bind(null, Filter.fromText(filter), result));
124 })(); 124 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld