OLD | NEW |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 withNAD( | 162 withNAD( |
163 0, selectors => | 163 0, selectors => |
164 test.equal(selectors.selectorCount, 2))( | 164 test.equal(selectors.selectorCount, 2))( |
165 elemHide.getSelectorsForDomain("example.com", 0)); | 165 elemHide.getSelectorsForDomain("example.com", 0)); |
166 })(ElemHide.create()); | 166 })(ElemHide.create()); |
167 | 167 |
168 test.done(); | 168 test.done(); |
169 }; | 169 }; |
170 | 170 |
171 exports.testSyntaxConversion = function(test) | |
172 { | |
173 function checkConvertedFilter(old, converted) | |
174 { | |
175 withNAD( | |
176 0, filter => test.equal(filter.text, converted))(Filter.fromText(old)); | |
177 } | |
178 | |
179 checkConvertedFilter("example.com##foo[-abp-properties='something']bar", "exam
ple.com#?#foo:-abp-properties(something)bar"); | |
180 checkConvertedFilter("example.com#@#foo[-abp-properties='something']bar", "exa
mple.com#@#foo:-abp-properties(something)bar"); | |
181 checkConvertedFilter("example.com##[-abp-properties=\"something\"]", "example.
com#?#:-abp-properties(something)"); | |
182 checkConvertedFilter("example.com##[-abp-properties='(something)']", "example.
com#?#:-abp-properties((something))"); | |
183 | |
184 test.done(); | |
185 }; | |
186 | |
187 exports.testDomainRestrictions = function(test) | 171 exports.testDomainRestrictions = function(test) |
188 { | 172 { |
189 function testSelectorMatches(description, filters, domain, expectedMatches) | 173 function testSelectorMatches(description, filters, domain, expectedMatches) |
190 { | 174 { |
191 withNAD([0, 1], (elemHide, elemHideEmulation) => | 175 withNAD([0, 1], (elemHide, elemHideEmulation) => |
192 { | 176 { |
193 let addFilter = withNAD(0, filter => | 177 let addFilter = withNAD(0, filter => |
194 { | 178 { |
195 if (filter instanceof ElemHideEmulationFilter) | 179 if (filter instanceof ElemHideEmulationFilter) |
196 elemHideEmulation.add(filter); | 180 elemHideEmulation.add(filter); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 "www.example.com", | 290 "www.example.com", |
307 [] | 291 [] |
308 ); | 292 ); |
309 })(Filter.fromText("example.com##filter1"), | 293 })(Filter.fromText("example.com##filter1"), |
310 Filter.fromText("www.example.com##filter2"), | 294 Filter.fromText("www.example.com##filter2"), |
311 Filter.fromText("other.example.com##filter3")); | 295 Filter.fromText("other.example.com##filter3")); |
312 })(ElemHide.create(), ElemHideEmulation.create()); | 296 })(ElemHide.create(), ElemHideEmulation.create()); |
313 | 297 |
314 test.done(); | 298 test.done(); |
315 }; | 299 }; |
OLD | NEW |