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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | metadata.gecko » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (function() 1 (function()
2 { 2 {
3 let server = null; 3 let server = null;
4 let frame = null; 4 let frame = null;
5 5
6 module("Element hiding", { 6 module("Element hiding", {
7 setup: function() 7 setup: function()
8 { 8 {
9 prepareFilterComponents.call(this); 9 prepareFilterComponents.call(this);
10 preparePrefs.call(this); 10 preparePrefs.call(this);
11 11
12 server = new nsHttpServer(); 12 server = new nsHttpServer();
13 server.start(1234); 13 server.start(1234);
14 14
15 server.registerPathHandler("/test", function(metadata, response) 15 server.registerPathHandler("/test", function(metadata, response)
16 { 16 {
17 let body = 17 let body =
18 '<body onload="document.dispatchEvent(new CustomEvent(\'abp:frameready \', {bubbles: true}));">' + 18 '<body onload="document.dispatchEvent(new CustomEvent(\'abp:frameready \', {bubbles: true}));">' +
19 '<div id="test1" class="testClass">foo</div>' + 19 '<div id="test1" class="testClass">foo</div>' +
20 '<p id="test2" class="testClass">bar</p>' + 20 '<p id="test2" class="testClass">bar</p>' +
21 '</body>'; 21 '</body>';
22 response.setStatusLine("1.1", "200", "OK"); 22 response.setStatusLine("1.1", "200", "OK");
23 response.setHeader("Content-Type", "text/html; charset=utf-8"); 23 response.setHeader("Content-Type", "text/html; charset=utf-8");
24 response.bodyOutputStream.write(body, body.length); 24 response.bodyOutputStream.write(body, body.length);
25 }); 25 });
26 26
27 frame = document.createElementNS("http://www.mozilla.org/keymaster/gatekee per/there.is.only.xul", "iframe"); 27 frame = document.createElementNS("http://www.mozilla.org/keymaster/gatekee per/there.is.only.xul", "browser");
28 frame.setAttribute("type", "content"); 28 frame.setAttribute("type", "content");
29 frame.setAttribute("disablehistory", "true");
29 frame.style.visibility = "collapse"; 30 frame.style.visibility = "collapse";
30 document.body.appendChild(frame); 31 document.body.appendChild(frame);
31 }, 32 },
32 teardown: function() 33 teardown: function()
33 { 34 {
34 restoreFilterComponents.call(this); 35 restoreFilterComponents.call(this);
35 restorePrefs.call(this); 36 restorePrefs.call(this);
36 37
37 stop(); 38 stop();
38 server.stop(function() 39 server.stop(function()
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 else if (stage == 3) 129 else if (stage == 3)
129 defaultMatcher.add(Filter.fromText("@@||localhost^$~document")); 130 defaultMatcher.add(Filter.fromText("@@||localhost^$~document"));
130 else if (stage == 4) 131 else if (stage == 4)
131 defaultMatcher.add(Filter.fromText("@@||localhost^$elemhide")); 132 defaultMatcher.add(Filter.fromText("@@||localhost^$elemhide"));
132 133
133 if (stage == 2 || stage == 4) 134 if (stage == 2 || stage == 4)
134 expected = ["visible", "visible"]; // Second and forth runs are whitel isted, nothing should be hidden 135 expected = ["visible", "visible"]; // Second and forth runs are whitel isted, nothing should be hidden
135 136
136 frame.addEventListener("abp:frameready", function() 137 frame.addEventListener("abp:frameready", function()
137 { 138 {
138 Utils.runAsync(function() 139 let frameScript = `
140 // The "load" event doesn't mean XBL bindings are done, these will
141 // take longer to load (async messaging). Only check visibility after
142 // sending a message to parent and receiving response.
143 addMessageListener("pong", function()
144 {
145 let visibility = [
146 content.document.getElementById("test1").offsetHeight > 0 ? "visib le" : "hidden",
147 content.document.getElementById("test2").offsetHeight > 0 ? "visib le" : "hidden"
148 ];
149 sendAsyncMessage("visibility", visibility);
150 });
151 sendAsyncMessage("ping");
152 `;
153 frame.messageManager.addMessageListener("ping", () => frame.messageManag er.sendAsyncMessage("pong"));
154 frame.messageManager.addMessageListener("visibility", (message) =>
139 { 155 {
140 let doc = frame.contentDocument; 156 let visibility = message.data;
141 equal(doc.getElementById("test1").offsetHeight > 0 ? "visible" : "hidd en", expected[0], "First element visible"); 157 equal(visibility[0], expected[0], "First element visible");
142 equal(doc.getElementById("test2").offsetHeight > 0 ? "visible" : "hidd en", expected[1], "Second element visible"); 158 equal(visibility[1], expected[1], "Second element visible");
143 159
144 start(); 160 start();
145 }); 161 });
162 frame.messageManager.loadFrameScript("data:text/javascript," + encodeURI Component(frameScript), false);
146 }, false, true); 163 }, false, true);
147 frame.setAttribute("src", "http://localhost:1234/test"); 164 frame.setAttribute("src", "http://localhost:1234/test");
148 }; 165 };
149 FilterNotifier.addListener(listener); 166 FilterNotifier.addListener(listener);
150 167
151 for (let filter_text of filters) 168 for (let filter_text of filters)
152 { 169 {
153 let filter = Filter.fromText(filter_text); 170 let filter = Filter.fromText(filter_text);
154 if (filter instanceof WhitelistFilter) 171 if (filter instanceof WhitelistFilter)
155 defaultMatcher.add(filter); 172 defaultMatcher.add(filter);
(...skipping 12 matching lines...) Expand all
168 4: "running with element hiding exception", 185 4: "running with element hiding exception",
169 }; 186 };
170 187
171 for (let test = 0; test < tests.length; test++) 188 for (let test = 0; test < tests.length; test++)
172 { 189 {
173 let [filters, expected] = tests[test]; 190 let [filters, expected] = tests[test];
174 for (let stage = 1; stage in stageDescriptions; stage++) 191 for (let stage = 1; stage in stageDescriptions; stage++)
175 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage)); 192 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage));
176 } 193 }
177 })(); 194 })();
OLDNEW
« no previous file with comments | « no previous file | metadata.gecko » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld