| 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  | 
|  171 exports.testDomainRestrictions = function(test) |  187 exports.testDomainRestrictions = function(test) | 
|  172 { |  188 { | 
|  173   function testSelectorMatches(description, filters, domain, expectedMatches) |  189   function testSelectorMatches(description, filters, domain, expectedMatches) | 
|  174   { |  190   { | 
|  175     withNAD([0, 1], (elemHide, elemHideEmulation) => |  191     withNAD([0, 1], (elemHide, elemHideEmulation) => | 
|  176     { |  192     { | 
|  177       let addFilter = withNAD(0, filter => |  193       let addFilter = withNAD(0, filter => | 
|  178       { |  194       { | 
|  179         if (filter instanceof ElemHideEmulationFilter) |  195         if (filter instanceof ElemHideEmulationFilter) | 
|  180           elemHideEmulation.add(filter); |  196           elemHideEmulation.add(filter); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  196         test.deepEqual(matches.sort(), expectedMatches.sort(), description); |  212         test.deepEqual(matches.sort(), expectedMatches.sort(), description); | 
|  197       })(elemHideEmulation.getRulesForDomain(elemHide, domain)); |  213       })(elemHideEmulation.getRulesForDomain(elemHide, domain)); | 
|  198  |  214  | 
|  199       elemHideEmulation.clear(); |  215       elemHideEmulation.clear(); | 
|  200     })(ElemHide.create(), ElemHideEmulation.create()); |  216     })(ElemHide.create(), ElemHideEmulation.create()); | 
|  201   } |  217   } | 
|  202  |  218  | 
|  203   testSelectorMatches( |  219   testSelectorMatches( | 
|  204     "Ignore generic filters", |  220     "Ignore generic filters", | 
|  205     [ |  221     [ | 
|  206       "##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", |  222       "#?#:-abp-properties(foo)", "example.com#?#:-abp-properties(foo)", | 
|  207       "~example.com##[-abp-properties='foo']" |  223       "~example.com##:-abp-properties(foo)" | 
|  208     ], |  224     ], | 
|  209     "example.com", |  225     "example.com", | 
|  210     ["example.com##[-abp-properties='foo']"] |  226     ["example.com#?#:-abp-properties(foo)"] | 
|  211   ); |  227   ); | 
|  212   testSelectorMatches( |  228   testSelectorMatches( | 
|  213     "Ignore selectors with exceptions", |  229     "Ignore selectors with exceptions", | 
|  214     [ |  230     [ | 
|  215       "example.com##[-abp-properties='foo']", |  231       "example.com#?#:-abp-properties(foo)", | 
|  216       "example.com##[-abp-properties='bar']", |  232       "example.com#?#:-abp-properties(bar)", | 
|  217       "example.com#@#[-abp-properties='foo']" |  233       "example.com#@#:-abp-properties(foo)" | 
|  218     ], |  234     ], | 
|  219     "example.com", |  235     "example.com", | 
|  220     ["example.com##[-abp-properties='bar']"] |  236     ["example.com#?#:-abp-properties(bar)"] | 
|  221   ); |  237   ); | 
|  222   testSelectorMatches( |  238   testSelectorMatches( | 
|  223     "Ignore filters that include parent domain but exclude subdomain", |  239     "Ignore filters that include parent domain but exclude subdomain", | 
|  224     [ |  240     [ | 
|  225       "~www.example.com,example.com##[-abp-properties='foo']" |  241       "~www.example.com,example.com#?#:-abp-properties(foo)" | 
|  226     ], |  242     ], | 
|  227     "www.example.com", |  243     "www.example.com", | 
|  228     [] |  244     [] | 
|  229   ); |  245   ); | 
|  230   testSelectorMatches( |  246   testSelectorMatches( | 
|  231     "Ignore filters with parent domain if exception matches subdomain", |  247     "Ignore filters with parent domain if exception matches subdomain", | 
|  232     [ |  248     [ | 
|  233       "www.example.com#@#[-abp-properties='foo']", |  249       "www.example.com#@#:-abp-properties(foo)", | 
|  234       "example.com##[-abp-properties='foo']" |  250       "example.com#?#:-abp-properties(foo)" | 
|  235     ], |  251     ], | 
|  236     "www.example.com", |  252     "www.example.com", | 
|  237     [] |  253     [] | 
|  238   ); |  254   ); | 
|  239   testSelectorMatches( |  255   testSelectorMatches( | 
|  240     "Ignore filters for other subdomain", |  256     "Ignore filters for other subdomain", | 
|  241     [ |  257     [ | 
|  242       "www.example.com##[-abp-properties='foo']", |  258       "www.example.com#?#:-abp-properties(foo)", | 
|  243       "other.example.com##[-abp-properties='foo']" |  259       "other.example.com#?#:-abp-properties(foo)" | 
|  244     ], |  260     ], | 
|  245     "other.example.com", |  261     "other.example.com", | 
|  246     ["other.example.com##[-abp-properties='foo']"] |  262     ["other.example.com#?#:-abp-properties(foo)"] | 
|  247   ); |  263   ); | 
|  248  |  264  | 
|  249   test.done(); |  265   test.done(); | 
|  250 }; |  266 }; | 
|  251  |  267  | 
|  252 exports.testElemHideEmulationFiltersContainer = function(test) |  268 exports.testElemHideEmulationFiltersContainer = function(test) | 
|  253 { |  269 { | 
|  254   withNAD([0, 1], (elemHide, elemHideEmulation) => |  270   withNAD([0, 1], (elemHide, elemHideEmulation) => | 
|  255   { |  271   { | 
|  256     function compareRules(description, domain, expectedMatches) |  272     function compareRules(description, domain, expectedMatches) | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  290         "www.example.com", |  306         "www.example.com", | 
|  291         [] |  307         [] | 
|  292       ); |  308       ); | 
|  293     })(Filter.fromText("example.com##filter1"), |  309     })(Filter.fromText("example.com##filter1"), | 
|  294        Filter.fromText("www.example.com##filter2"), |  310        Filter.fromText("www.example.com##filter2"), | 
|  295        Filter.fromText("other.example.com##filter3")); |  311        Filter.fromText("other.example.com##filter3")); | 
|  296   })(ElemHide.create(), ElemHideEmulation.create()); |  312   })(ElemHide.create(), ElemHideEmulation.create()); | 
|  297  |  313  | 
|  298   test.done(); |  314   test.done(); | 
|  299 }; |  315 }; | 
| OLD | NEW |