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() |
{ |
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(); |
} |