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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 let matches = ElemHideEmulation.getRulesForDomain(domain) | 53 let matches = ElemHideEmulation.getRulesForDomain(domain) |
54 .map(filter => filter.text); | 54 .map(filter => filter.text); |
55 test.deepEqual(matches.sort(), expectedMatches.sort(), description); | 55 test.deepEqual(matches.sort(), expectedMatches.sort(), description); |
56 | 56 |
57 ElemHideEmulation.clear(); | 57 ElemHideEmulation.clear(); |
58 ElemHide.clear(); | 58 ElemHide.clear(); |
59 } | 59 } |
60 | 60 |
61 testSelectorMatches( | 61 testSelectorMatches( |
62 "Ignore generic filters", | 62 "Ignore generic filters", |
63 ["##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", | 63 [ |
64 "~example.com##[-abp-properties='foo']"], | 64 "##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", |
| 65 "~example.com##[-abp-properties='foo']" |
| 66 ], |
65 "example.com", | 67 "example.com", |
66 ["example.com##[-abp-properties='foo']"] | 68 ["example.com##[-abp-properties='foo']"] |
67 ); | 69 ); |
68 testSelectorMatches( | 70 testSelectorMatches( |
69 "Ignore selectors with exceptions", | 71 "Ignore selectors with exceptions", |
70 ["example.com##[-abp-properties='foo']", | 72 [ |
71 "example.com##[-abp-properties='bar']", | 73 "example.com##[-abp-properties='foo']", |
72 "example.com#@#[-abp-properties='foo']"], | 74 "example.com##[-abp-properties='bar']", |
73 "example.com", | 75 "example.com#@#[-abp-properties='foo']" |
| 76 ], |
| 77 "example.com", |
74 ["example.com##[-abp-properties='bar']"] | 78 ["example.com##[-abp-properties='bar']"] |
75 ); | 79 ); |
76 testSelectorMatches( | 80 testSelectorMatches( |
77 "Ignore filters that include parent domain but exclude subdomain", | 81 "Ignore filters that include parent domain but exclude subdomain", |
78 ["~www.example.com,example.com##[-abp-properties='foo']"], | 82 [ |
79 "www.example.com", | 83 "~www.example.com,example.com##[-abp-properties='foo']" |
| 84 ], |
| 85 "www.example.com", |
80 [] | 86 [] |
81 ); | 87 ); |
82 testSelectorMatches( | 88 testSelectorMatches( |
83 "Ignore filters with parent domain if exception matches subdomain", | 89 "Ignore filters with parent domain if exception matches subdomain", |
84 ["www.example.com#@#[-abp-properties='foo']", | 90 [ |
85 "example.com##[-abp-properties='foo']"], | 91 "www.example.com#@#[-abp-properties='foo']", |
| 92 "example.com##[-abp-properties='foo']" |
| 93 ], |
86 "www.example.com", | 94 "www.example.com", |
87 [] | 95 [] |
88 ); | 96 ); |
89 testSelectorMatches( | 97 testSelectorMatches( |
90 "Ignore filters for other subdomain", | 98 "Ignore filters for other subdomain", |
91 ["www.example.com##[-abp-properties='foo']", | 99 [ |
92 "other.example.com##[-abp-properties='foo']"], | 100 "www.example.com##[-abp-properties='foo']", |
93 "other.example.com", | 101 "other.example.com##[-abp-properties='foo']" |
| 102 ], |
| 103 "other.example.com", |
94 ["other.example.com##[-abp-properties='foo']"] | 104 ["other.example.com##[-abp-properties='foo']"] |
95 ); | 105 ); |
96 | 106 |
97 test.done(); | 107 test.done(); |
98 }; | 108 }; |
99 | 109 |
100 exports.testElemHideEmulationFiltersContainer = function(test) | 110 exports.testElemHideEmulationFiltersContainer = function(test) |
101 { | 111 { |
102 function compareRules(description, domain, expectedMatches) | 112 function compareRules(description, domain, expectedMatches) |
103 { | 113 { |
104 let result = ElemHideEmulation.getRulesForDomain(domain) | 114 let result = ElemHideEmulation.getRulesForDomain(domain) |
105 .map((filter) => filter.text); | 115 .map(filter => filter.text); |
106 expectedMatches = expectedMatches.map(filter => filter.text); | 116 expectedMatches = expectedMatches.map(filter => filter.text); |
107 test.deepEqual(result.sort(), expectedMatches.sort(), description); | 117 test.deepEqual(result.sort(), expectedMatches.sort(), description); |
108 } | 118 } |
109 | 119 |
110 let domainFilter = Filter.fromText("example.com##filter1"); | 120 let domainFilter = Filter.fromText("example.com##filter1"); |
111 let subdomainFilter = Filter.fromText("www.example.com##filter2"); | 121 let subdomainFilter = Filter.fromText("www.example.com##filter2"); |
112 let otherDomainFilter = Filter.fromText("other.example.com##filter3"); | 122 let otherDomainFilter = Filter.fromText("other.example.com##filter3"); |
113 | 123 |
114 ElemHideEmulation.add(domainFilter); | 124 ElemHideEmulation.add(domainFilter); |
115 ElemHideEmulation.add(subdomainFilter); | 125 ElemHideEmulation.add(subdomainFilter); |
(...skipping 13 matching lines...) Expand all Loading... |
129 | 139 |
130 ElemHideEmulation.clear(); | 140 ElemHideEmulation.clear(); |
131 compareRules( | 141 compareRules( |
132 "Return no filters after clearing", | 142 "Return no filters after clearing", |
133 "www.example.com", | 143 "www.example.com", |
134 [] | 144 [] |
135 ); | 145 ); |
136 | 146 |
137 test.done(); | 147 test.done(); |
138 }; | 148 }; |
LEFT | RIGHT |