| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 let ElemHideEmulationFilter = null; | 22 let ElemHideEmulationFilter = null; |
| 23 let ElemHideEmulation = null; | 23 let ElemHideEmulation = null; |
| 24 let ElemHide = null; | 24 let ElemHide = null; |
| 25 let Filter = null; | 25 let Filter = null; |
| 26 | 26 |
| 27 exports.setUp = function(callback) | 27 exports.setUp = function(callback) |
| 28 { | 28 { |
| 29 let sandboxedRequire = createSandbox(); | 29 let sandboxedRequire = createSandbox(); |
| 30 ( | 30 ( |
| 31 {Filter, ElemHideEmulationFilter} = sandboxedRequire("../lib/filterClasses") , | 31 {Filter, |
|
kzar
2016/11/04 15:45:56
Nit: Mind fixing the few long lines here?
Felix Dahlke
2016/11/04 16:43:35
It bothered me too, but I don't see an obvious way
kzar
2016/11/07 17:19:26
Well this line is not the worst, but none the less
Felix Dahlke
2016/11/08 17:45:35
Yeah, that's nice actually.
Felix Dahlke
2016/11/11 11:51:42
Done.
| |
| 32 ElemHideEmulationFilter} = sandboxedRequire("../lib/filterClasses"), | |
| 32 {ElemHideEmulation} = sandboxedRequire("../lib/elemHideEmulation"), | 33 {ElemHideEmulation} = sandboxedRequire("../lib/elemHideEmulation"), |
| 33 {ElemHide} = sandboxedRequire("../lib/elemHide") | 34 {ElemHide} = sandboxedRequire("../lib/elemHide") |
| 34 ); | 35 ); |
| 35 | 36 |
| 36 callback(); | 37 callback(); |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 exports.testDomainRestrictions = function(test) | 40 exports.testDomainRestrictions = function(test) |
| 40 { | 41 { |
| 41 function testSelectorMatches(description, filters, domain, expectedMatches) | 42 function testSelectorMatches(description, filters, domain, expectedMatches) |
| 42 { | 43 { |
| 43 for (let filter of filters) | 44 for (let filter of filters) |
| 44 { | 45 { |
| 45 filter = Filter.fromText(filter); | 46 filter = Filter.fromText(filter); |
| 46 if (filter instanceof ElemHideEmulationFilter) | 47 if (filter instanceof ElemHideEmulationFilter) |
| 47 ElemHideEmulation.add(filter); | 48 ElemHideEmulation.add(filter); |
| 48 else | 49 else |
| 49 ElemHide.add(filter); | 50 ElemHide.add(filter); |
| 50 } | 51 } |
| 51 | 52 |
| 52 let matches = ElemHideEmulation.getRulesForDomain(domain).map(filter => filt er.text); | 53 let matches = ElemHideEmulation.getRulesForDomain(domain) |
| 54 .map(filter => filter.text); | |
| 53 test.deepEqual(matches.sort(), expectedMatches.sort(), description); | 55 test.deepEqual(matches.sort(), expectedMatches.sort(), description); |
| 54 | 56 |
| 55 ElemHideEmulation.clear(); | 57 ElemHideEmulation.clear(); |
| 56 ElemHide.clear(); | 58 ElemHide.clear(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 testSelectorMatches( | 61 testSelectorMatches( |
| 60 "Ignore generic filters", | 62 "Ignore generic filters", |
| 61 ["##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", | 63 ["##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", |
| 62 "~example.com##[-abp-properties='foo']"], | 64 "~example.com##[-abp-properties='foo']"], |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 129 |
| 128 ElemHideEmulation.clear(); | 130 ElemHideEmulation.clear(); |
| 129 compareRules( | 131 compareRules( |
| 130 "Return no filters after clearing", | 132 "Return no filters after clearing", |
| 131 "www.example.com", | 133 "www.example.com", |
| 132 [] | 134 [] |
| 133 ); | 135 ); |
| 134 | 136 |
| 135 test.done(); | 137 test.done(); |
| 136 }; | 138 }; |
| LEFT | RIGHT |