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: Final patch Created Nov. 15, 2014, 11:53 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
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(\'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("frameready", function()
tschuster 2014/11/16 12:53:54 When I first saw this I didn't immediately think t
Wladimir Palant 2014/11/17 18:58:44 Done.
{
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();
}

Powered by Google App Engine
This is Rietveld