Index: chrome/content/tests/elemhide.js |
=================================================================== |
--- a/chrome/content/tests/elemhide.js |
+++ b/chrome/content/tests/elemhide.js |
@@ -19,18 +19,19 @@ |
'<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.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "iframe"); |
+ frame = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser"); |
frame.setAttribute("type", "content"); |
+ frame.setAttribute("disablehistory", "true"); |
frame.style.visibility = "collapse"; |
document.body.appendChild(frame); |
}, |
teardown: function() |
{ |
restoreFilterComponents.call(this); |
restorePrefs.call(this); |
@@ -130,24 +131,40 @@ |
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.addEventListener("abp:frameready", function() |
{ |
- Utils.runAsync(function() |
+ let frameScript = ` |
+ // The "load" event doesn't mean XBL bindings are done, these will |
+ // take longer to load (async messaging). Only check visibility after |
+ // sending a message to parent and receiving response. |
+ addMessageListener("pong", function() |
+ { |
+ let visibility = [ |
+ content.document.getElementById("test1").offsetHeight > 0 ? "visible" : "hidden", |
+ content.document.getElementById("test2").offsetHeight > 0 ? "visible" : "hidden" |
+ ]; |
+ sendAsyncMessage("visibility", visibility); |
+ }); |
+ sendAsyncMessage("ping"); |
+ `; |
+ frame.messageManager.addMessageListener("ping", () => frame.messageManager.sendAsyncMessage("pong")); |
+ frame.messageManager.addMessageListener("visibility", (message) => |
{ |
- 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"); |
+ let visibility = message.data; |
+ equal(visibility[0], expected[0], "First element visible"); |
+ equal(visibility[1], expected[1], "Second element visible"); |
start(); |
}); |
+ frame.messageManager.loadFrameScript("data:text/javascript," + encodeURIComponent(frameScript), false); |
}, false, true); |
frame.setAttribute("src", "http://localhost:1234/test"); |
}; |
FilterNotifier.addListener(listener); |
for (let filter_text of filters) |
{ |
let filter = Filter.fromText(filter_text); |