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

Delta Between Two Patch Sets: test/browser/elemHideEmulation.js

Issue 29367181: Issue 4726 - Add tests for the element hiding emulation content script (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Left Patch Set: Addressed remaining comments Created Jan. 17, 2017, 7:39 p.m.
Right Patch Set: Wrap and indent QUnit.test invocations consistently Created Jan. 19, 2017, 9:55 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 | « test/browser/elemHideEmulation.html ('k') | test_runner.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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 Eyeo GmbH 3 * Copyright (C) 2006-2017 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 ); 114 );
115 115
116 elemHideEmulation.load(function() 116 elemHideEmulation.load(function()
117 { 117 {
118 elemHideEmulation.apply(); 118 elemHideEmulation.apply();
119 callback(); 119 callback();
120 }); 120 });
121 } 121 }
122 122
123 QUnit.test("Verbatim property selector", function(assert) 123 QUnit.test(
124 { 124 "Verbatim property selector",
125 var done = assert.async(); 125 function(assert)
126 var toHide = createElementWithStyle("{background-color: #000}"); 126 {
127 applyElemHideEmulation(["[-abp-properties='background-color: rgb(0, 0, 0)']"], 127 var done = assert.async();
kzar 2017/01/18 04:17:15 Mind also moving the first argument of the applyEl
Felix Dahlke 2017/01/19 09:56:51 I think there's a range of how we generally do thi
Sebastian Noack 2017/01/19 10:13:00 I agree with Dave. As I explained in my previous c
128 function() 128 var toHide = createElementWithStyle("{background-color: #000}");
129 { 129 applyElemHideEmulation(
130 assert.hidden(toHide); 130 ["[-abp-properties='background-color: rgb(0, 0, 0)']"],
131 done(); 131 function()
132 } 132 {
133 ); 133 assert.hidden(toHide);
134 }); 134 done();
135 135 }
136 QUnit.test("Property selector with wildcard", function(assert) 136 );
kzar 2017/01/18 04:17:15 Mind bringing the function call and test descripti
Felix Dahlke 2017/01/19 09:56:51 There's no need for the wrapping in these cases, a
Sebastian Noack 2017/01/19 10:13:00 FWIW, if all arguments fit on the same line as the
137 { 137 }
138 var done = assert.async(); 138 );
139 var toHide = createElementWithStyle("{background-color: #000}"); 139
140 applyElemHideEmulation(["[-abp-properties='*color: rgb(0, 0, 0)']"], 140 QUnit.test(
141 function() 141 "Property selector with wildcard",
142 { 142 function(assert)
143 assert.hidden(toHide); 143 {
144 done(); 144 var done = assert.async();
145 } 145 var toHide = createElementWithStyle("{background-color: #000}");
146 ); 146 applyElemHideEmulation(
147 }); 147 ["[-abp-properties='*color: rgb(0, 0, 0)']"],
148 148 function()
149 QUnit.test("Property selector with regular expression", function(assert) 149 {
150 { 150 assert.hidden(toHide);
151 var done = assert.async(); 151 done();
152 var toHide = createElementWithStyle("{background-color: #000}"); 152 }
153 applyElemHideEmulation(["[-abp-properties='/.*color: rgb\\(0, 0, 0\\)/']"], 153 );
154 function() 154 }
155 { 155 );
156 assert.hidden(toHide); 156
157 done(); 157 QUnit.test(
158 } 158 "Property selector with regular expression",
159 ); 159 function(assert)
160 }); 160 {
161 161 var done = assert.async();
162 QUnit.test("Property selector with regular expression containing escaped brace", 162 var toHide = createElementWithStyle("{background-color: #000}");
163 applyElemHideEmulation(
164 ["[-abp-properties='/.*color: rgb\\(0, 0, 0\\)/']"],
165 function()
166 {
167 assert.hidden(toHide);
168 done();
169 }
170 );
171 }
172 );
173
174 QUnit.test(
175 "Property selector with regular expression containing escaped brace",
163 function(assert) 176 function(assert)
164 { 177 {
165 var done = assert.async(); 178 var done = assert.async();
166 var toHide = createElementWithStyle("{background-color: #000}"); 179 var toHide = createElementWithStyle("{background-color: #000}");
167 applyElemHideEmulation( 180 applyElemHideEmulation(
168 ["[-abp-properties='/background.\\x7B 0,6\\x7D : rgb\\(0, 0, 0\\)/']"], 181 ["[-abp-properties='/background.\\x7B 0,6\\x7D : rgb\\(0, 0, 0\\)/']"],
169 function() 182 function()
170 { 183 {
171 assert.hidden(toHide); 184 assert.hidden(toHide);
172 done(); 185 done();
173 } 186 }
174 ); 187 );
175 } 188 }
176 ); 189 );
177 190
178 QUnit.test("Property selector with regular expression containing improperly \ 191 QUnit.test(
179 escaped brace", 192 "Property selector with regular expression containing improperly escaped \
193 brace",
180 function(assert) 194 function(assert)
181 { 195 {
182 var done = assert.async(); 196 var done = assert.async();
183 var toHide = createElementWithStyle("{background-color: #000}"); 197 var toHide = createElementWithStyle("{background-color: #000}");
184 applyElemHideEmulation( 198 applyElemHideEmulation(
185 ["[-abp-properties='/background.\\x7B0,6\\x7D: rgb\\(0, 0, 0\\)/']"], 199 ["[-abp-properties='/background.\\x7B0,6\\x7D: rgb\\(0, 0, 0\\)/']"],
186 function() 200 function()
187 { 201 {
188 assert.visible(toHide); 202 assert.visible(toHide);
189 done(); 203 done();
190 } 204 }
191 ); 205 );
192 } 206 }
193 ); 207 );
194 208
195 QUnit.test("Property selector works for dynamically changed property", 209 QUnit.test(
210 "Property selector works for dynamically changed property",
196 function(assert) 211 function(assert)
197 { 212 {
198 var done = assert.async(); 213 var done = assert.async();
199 var toHide = createElementWithStyle("{}"); 214 var toHide = createElementWithStyle("{}");
200 applyElemHideEmulation( 215 applyElemHideEmulation(
201 ["[-abp-properties='background-color: rgb(0, 0, 0)']"], 216 ["[-abp-properties='background-color: rgb(0, 0, 0)']"],
202 function() 217 function()
203 { 218 {
204 assert.visible(toHide); 219 assert.visible(toHide);
205 insertStyleRule("#" + toHide.id + " {background-color: #000}"); 220 insertStyleRule("#" + toHide.id + " {background-color: #000}");
206 setTimeout(function() 221 setTimeout(function()
207 { 222 {
208 assert.hidden(toHide); 223 assert.hidden(toHide);
209 done(); 224 done();
210 }); 225 });
211 } 226 }
212 ); 227 );
213 } 228 }
214 ); 229 );
LEFTRIGHT

Powered by Google App Engine
This is Rietveld