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

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

Issue 29329806: Issue 3227 - Adjust unit tests for e10s-related element hiding changes (Closed)
Patch Set: Created Nov. 6, 2015, 11:56 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 | « no previous file | metadata.gecko » ('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
@@ -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);
« no previous file with comments | « no previous file | metadata.gecko » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld