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

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

Issue 29356283: Issue 4500 - Fix element hiding integration tests (Closed) Base URL: https://hg.adblockplus.org/adblockplustests
Left Patch Set: Created Oct. 7, 2016, 8:29 a.m.
Right Patch Set: Addressed one more nit Created Oct. 7, 2016, 10:40 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 | « no previous file | no next file » | 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);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 [["##div#test1", "@@localhost$generichide"], ["visible", "visible"]], 111 [["##div#test1", "@@localhost$generichide"], ["visible", "visible"]],
112 [["##div#test1", "@@localhost$genericblock"], ["hidden", "visible"]], 112 [["##div#test1", "@@localhost$genericblock"], ["hidden", "visible"]],
113 [["localhost##div#test1", "@@localhost$generichide"], ["hidden", "visible"]] , 113 [["localhost##div#test1", "@@localhost$generichide"], ["hidden", "visible"]] ,
114 [["~example.com##div#test1", "@@localhost$generichide"], ["visible", "visibl e"]], 114 [["~example.com##div#test1", "@@localhost$generichide"], ["visible", "visibl e"]],
115 [["~example.com##div#test1", "@@localhost$genericblock"], ["hidden", "visibl e"]], 115 [["~example.com##div#test1", "@@localhost$genericblock"], ["hidden", "visibl e"]],
116 [["~example.com,localhost##div#test1", "@@localhost$generichide"], ["hidden" , "visible"]], 116 [["~example.com,localhost##div#test1", "@@localhost$generichide"], ["hidden" , "visible"]],
117 ]; 117 ];
118 118
119 function runTest([filters, expected], stage) 119 function runTest([filters, expected], stage)
120 { 120 {
121 for (let filter_text of filters) 121 for (let filterText of filters)
kzar 2016/10/07 09:42:08 Nit: We usually use camelCase for variable names i
Wladimir Palant 2016/10/07 10:41:21 Done.
122 FilterStorage.addFilter(Filter.fromText(filter_text)); 122 FilterStorage.addFilter(Filter.fromText(filterText));
Wladimir Palant 2016/10/07 08:35:50 Rietveld doesn't show it because of whitespace cha
kzar 2016/10/07 09:42:08 Sounds good to me, in fact I wonder why didn't do
Wladimir Palant 2016/10/07 10:16:05 Because element hiding was applying in an async fa
kzar 2016/10/07 10:19:54 Acknowledged.
123 123
124 if (stage == 2) 124 if (stage == 2)
125 FilterStorage.addFilter(Filter.fromText("@@||localhost^$document")); 125 FilterStorage.addFilter(Filter.fromText("@@||localhost^$document"));
126 else if (stage == 3) 126 else if (stage == 3)
127 FilterStorage.addFilter(Filter.fromText("@@||localhost^$~document")); 127 FilterStorage.addFilter(Filter.fromText("@@||localhost^$~document"));
128 else if (stage == 4) 128 else if (stage == 4)
129 FilterStorage.addFilter(Filter.fromText("@@||localhost^$elemhide")); 129 FilterStorage.addFilter(Filter.fromText("@@||localhost^$elemhide"));
130 130
131 // Second and forth runs are whitelisted, nothing should be hidden
131 if (stage == 2 || stage == 4) 132 if (stage == 2 || stage == 4)
132 expected = ["visible", "visible"]; // Second and forth runs are whitelis ted, nothing should be hidden 133 expected = ["visible", "visible"];
kzar 2016/10/07 09:42:08 Nit: Mind moving the comment above the if statemen
Wladimir Palant 2016/10/07 10:16:05 Done.
133 134
134 frame.addEventListener("abp:frameready", function() 135 frame.addEventListener("abp:frameready", function()
135 { 136 {
136 let frameScript = ` 137 let frameScript = `
137 // The "load" event doesn't mean that our styles are applied - these 138 // The "load" event doesn't mean that our styles are applied - these
138 // are only applied after a message roundtrip to parent determining 139 // are only applied after a message roundtrip to parent determining
139 // whether element hiding is enabled. Do the same roundtrip here before 140 // whether element hiding is enabled. Do the same roundtrip here before
140 // checking visibility to make sure timing is right. 141 // checking visibility to make sure timing is right.
Wladimir Palant 2016/10/07 08:35:50 This comment changed - the reason why we need to p
kzar 2016/10/07 09:42:08 Acknowledged.
141 addMessageListener("pong", function() 142 addMessageListener("pong", function()
142 { 143 {
143 let visibility = [ 144 let visibility = [
144 content.document.getElementById("test1").offsetHeight > 0 ? "visible " : "hidden", 145 content.document.getElementById("test1").offsetHeight > 0 ? "visible " : "hidden",
145 content.document.getElementById("test2").offsetHeight > 0 ? "visible " : "hidden" 146 content.document.getElementById("test2").offsetHeight > 0 ? "visible " : "hidden"
146 ]; 147 ];
147 sendAsyncMessage("visibility", visibility); 148 sendAsyncMessage("visibility", visibility);
148 }); 149 });
149 sendAsyncMessage("ping"); 150 sendAsyncMessage("ping");
150 `; 151 `;
(...skipping 18 matching lines...) Expand all
169 4: "running with element hiding exception", 170 4: "running with element hiding exception",
170 }; 171 };
171 172
172 for (let test = 0; test < tests.length; test++) 173 for (let test = 0; test < tests.length; test++)
173 { 174 {
174 let [filters, expected] = tests[test]; 175 let [filters, expected] = tests[test];
175 for (let stage = 1; stage in stageDescriptions; stage++) 176 for (let stage = 1; stage in stageDescriptions; stage++)
176 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage)); 177 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage));
177 } 178 }
178 })(); 179 })();
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld