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

Delta Between Two Patch Sets: chrome/content/tests/elemhide.js

Issue 5745141503492096: Issue 1561 - Move unit tests out of the browser`s content area (Closed)
Left Patch Set: Created Nov. 14, 2014, 11:11 p.m.
Right Patch Set: Rebased patch Created Jan. 10, 2015, 12:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/content/settings.xul ('k') | chrome/content/tests/policy.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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(\'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", "iframe");
28 frame.setAttribute("type", "content"); 28 frame.setAttribute("type", "content");
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (stage == 2) 119 if (stage == 2)
120 defaultMatcher.add(Filter.fromText("@@||localhost^$document")); 120 defaultMatcher.add(Filter.fromText("@@||localhost^$document"));
121 else if (stage == 3) 121 else if (stage == 3)
122 defaultMatcher.add(Filter.fromText("@@||localhost^$~document")); 122 defaultMatcher.add(Filter.fromText("@@||localhost^$~document"));
123 else if (stage == 4) 123 else if (stage == 4)
124 defaultMatcher.add(Filter.fromText("@@||localhost^$elemhide")); 124 defaultMatcher.add(Filter.fromText("@@||localhost^$elemhide"));
125 125
126 if (stage == 2 || stage == 4) 126 if (stage == 2 || stage == 4)
127 expected = ["visible", "visible"]; // Second and forth runs are whitel isted, nothing should be hidden 127 expected = ["visible", "visible"]; // Second and forth runs are whitel isted, nothing should be hidden
128 128
129 frame.addEventListener("frameready", function() 129 frame.addEventListener("abp:frameready", function()
130 { 130 {
131 Utils.runAsync(function() 131 Utils.runAsync(function()
132 { 132 {
133 let doc = frame.contentDocument; 133 let doc = frame.contentDocument;
134 equal(doc.getElementById("test1").offsetHeight > 0 ? "visible" : "hidd en", expected[0], "First element visible"); 134 equal(doc.getElementById("test1").offsetHeight > 0 ? "visible" : "hidd en", expected[0], "First element visible");
135 equal(doc.getElementById("test2").offsetHeight > 0 ? "visible" : "hidd en", expected[1], "Second element visible"); 135 equal(doc.getElementById("test2").offsetHeight > 0 ? "visible" : "hidd en", expected[1], "Second element visible");
136 136
137 start(); 137 start();
138 }); 138 });
139 }, false, true); 139 }, false, true);
(...skipping 14 matching lines...) Expand all
154 4: "running with element hiding exception", 154 4: "running with element hiding exception",
155 }; 155 };
156 156
157 for (let test = 0; test < tests.length; test++) 157 for (let test = 0; test < tests.length; test++)
158 { 158 {
159 let [filters, expected] = tests[test]; 159 let [filters, expected] = tests[test];
160 for (let stage = 1; stage in stageDescriptions; stage++) 160 for (let stage = 1; stage in stageDescriptions; stage++)
161 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage)); 161 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage));
162 } 162 }
163 })(); 163 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld