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

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

Issue 5745141503492096: Issue 1561 - Move unit tests out of the browser`s content area (Closed)
Patch Set: Rebased patch Created Jan. 10, 2015, 12:44 a.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/settings.xul ('k') | chrome/content/tests/policy.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/tests/elemhide.js
===================================================================
--- a/chrome/content/tests/elemhide.js
+++ b/chrome/content/tests/elemhide.js
@@ -9,23 +9,28 @@
prepareFilterComponents.call(this);
preparePrefs.call(this);
server = new nsHttpServer();
server.start(1234);
server.registerPathHandler("/test", function(metadata, response)
{
- let body = '<div id="test1" class="testClass">foo</div><p id="test2" class="testClass">bar</p>';
+ let body =
+ '<body onload="document.dispatchEvent(new CustomEvent(\'abp:frameready\', {bubbles: true}));">' +
+ '<div id="test1" class="testClass">foo</div>' +
+ '<p id="test2" class="testClass">bar</p>' +
+ '</body>';
response.setStatusLine("1.1", "200", "OK");
response.setHeader("Content-Type", "text/html; charset=utf-8");
response.bodyOutputStream.write(body, body.length);
});
- frame = document.createElement("iframe");
+ frame = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "iframe");
+ frame.setAttribute("type", "content");
frame.style.visibility = "collapse";
document.body.appendChild(frame);
},
teardown: function()
{
restoreFilterComponents.call(this);
restorePrefs.call(this);
@@ -116,28 +121,28 @@
else if (stage == 3)
defaultMatcher.add(Filter.fromText("@@||localhost^$~document"));
else if (stage == 4)
defaultMatcher.add(Filter.fromText("@@||localhost^$elemhide"));
if (stage == 2 || stage == 4)
expected = ["visible", "visible"]; // Second and forth runs are whitelisted, nothing should be hidden
- frame.onload = function()
+ frame.addEventListener("abp:frameready", function()
{
Utils.runAsync(function()
{
let doc = frame.contentDocument;
equal(doc.getElementById("test1").offsetHeight > 0 ? "visible" : "hidden", expected[0], "First element visible");
equal(doc.getElementById("test2").offsetHeight > 0 ? "visible" : "hidden", expected[1], "Second element visible");
start();
});
- };
- frame.contentWindow.location.href = "http://localhost:1234/test";
+ }, false, true);
+ frame.setAttribute("src", "http://localhost:1234/test");
}
FilterNotifier.addListener(listener);
for (let filter of filters)
ElemHide.add(Filter.fromText(filter));
ElemHide.isDirty = true;
ElemHide.apply();
}
« no previous file with comments | « chrome/content/settings.xul ('k') | chrome/content/tests/policy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld