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

Unified Diff: chrome/content/tests/popupBlocker.js

Issue 5745141503492096: Issue 1561 - Move unit tests out of the browser`s content area (Closed)
Patch Set: Addressed comment Created Nov. 17, 2014, 6:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/content/tests/policy.js ('k') | chrome/content/tests/ui/icon_position.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/tests/popupBlocker.js
===================================================================
--- a/chrome/content/tests/popupBlocker.js
+++ b/chrome/content/tests/popupBlocker.js
@@ -1,64 +1,65 @@
(function()
{
let server = null;
- let frame = null;
+ let wnd = null;
+ let tab = null;
module("Pop-up blocker", {
setup: function()
{
prepareFilterComponents.call(this, true);
preparePrefs.call(this);
server = new nsHttpServer();
server.start(1234);
server.registerPathHandler("/test", function(metadata, response)
{
response.setStatusLine("1.1", "200", "OK");
response.setHeader("Content-Type", "text/html; charset=utf-8");
- let body = '<html><body><a id="link" href="/redirect" target="_blank">link</a></body></html>';
+ let body =
+ '<body onload="document.dispatchEvent(new CustomEvent(\'abp:frameready\', {bubbles: true}));">' +
+ '<a id="link" href="/redirect" target="_blank">link</a>' +
+ '</body>';
response.bodyOutputStream.write(body, body.length);
});
server.registerPathHandler("/redirect", function(metadata, response)
{
response.setStatusLine("1.1", "302", "Moved Temporarily");
response.setHeader("Location", "http://127.0.0.1:1234/target");
});
server.registerPathHandler("/target", function(metadata, response)
{
- response.setStatusLine("1.1", "302", "Moved Temporarily");
response.setHeader("Content-Type", "text/html; charset=utf-8");
let body = '<html><body>OK</body></html>';
response.bodyOutputStream.write(body, body.length);
});
- frame = document.createElement("iframe");
- frame.setAttribute("src", "http://127.0.0.1:1234/test");
- frame.style.visibility = "collapse";
- document.body.appendChild(frame);
+ wnd = UI.currentWindow;
+ tab = wnd.gBrowser.loadOneTab("http://127.0.0.1:1234/test", {inBackground: false});
+ wnd.gBrowser.getBrowserForTab(tab).addEventListener("abp:frameready", function(event)
+ {
+ start();
+ }, false, true);
stop();
- frame.addEventListener("load", function(event)
- {
- start();
- }, false);
},
teardown: function()
{
restoreFilterComponents.call(this);
restorePrefs.call(this);
stop();
server.stop(function()
{
- frame.parentElement.removeChild(frame);
+ wnd.gBrowser.removeTab(tab);
server = null;
frame = null;
start();
});
}
});
@@ -74,17 +75,16 @@
["||127.0.0.1:1234/redirect$popup,domain=128.0.0.1", true],
];
function runTest(filter, result)
{
FilterStorage.addFilter(filter);
let successful = false;
- let wnd = Utils.getChromeWindow(window);
function onTabOpen(event)
{
window.clearTimeout(timeout);
wnd.gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, false);
let tab = event.target;
let browser = wnd.gBrowser.getBrowserForTab(tab);
@@ -111,14 +111,14 @@
FilterStorage.removeFilter(filter);
start();
}
wnd.gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, false);
wnd.gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false);
let timeout = window.setTimeout(onTabClose, 1000); // In case the tab isn't opened
- frame.contentDocument.getElementById("link").click();
+ wnd.gBrowser.getBrowserForTab(tab).contentDocument.getElementById("link").click();
}
for (let [filter, result] of tests)
asyncTest(filter, runTest.bind(null, Filter.fromText(filter), result));
})();
« no previous file with comments | « chrome/content/tests/policy.js ('k') | chrome/content/tests/ui/icon_position.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld