| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 { | 112 { |
| 113 for (let text of filters) | 113 for (let text of filters) |
| 114 { | 114 { |
| 115 let filter = Filter.fromText(text); | 115 let filter = Filter.fromText(text); |
| 116 if (filter instanceof ElemHideEmulationFilter) | 116 if (filter instanceof ElemHideEmulationFilter) |
| 117 ElemHideEmulation.add(filter); | 117 ElemHideEmulation.add(filter); |
| 118 else | 118 else |
| 119 ElemHide.add(filter); | 119 ElemHide.add(filter); |
| 120 filter.delete(); | 120 filter.delete(); |
| 121 } | 121 } |
| 122 let matches = ElemHideEmulation.getRulesForDomain(domain) | 122 |
| 123 .map(filter => filter.text); | 123 let rules = ElemHideEmulation.getRulesForDomain(domain); |
| 124 let matches = []; |
| 125 for (let i = 0; i < rules.filterCount; i++) |
| 126 { |
| 127 let filter = rules.filterAt(i); |
| 128 matches.push(filter.text); |
| 129 filter.delete(); |
| 130 } |
| 124 test.deepEqual(matches.sort(), expectedMatches.sort(), description); | 131 test.deepEqual(matches.sort(), expectedMatches.sort(), description); |
| 132 rules.delete(); |
| 125 | 133 |
| 126 ElemHideEmulation.clear(); | 134 ElemHideEmulation.clear(); |
| 127 ElemHide.clear(); | 135 ElemHide.clear(); |
| 128 } | 136 } |
| 129 | 137 |
| 130 testSelectorMatches( | 138 testSelectorMatches( |
| 131 "Ignore generic filters", | 139 "Ignore generic filters", |
| 132 [ | 140 [ |
| 133 "##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", | 141 "##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", |
| 134 "~example.com##[-abp-properties='foo']" | 142 "~example.com##[-abp-properties='foo']" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ["other.example.com##[-abp-properties='foo']"] | 181 ["other.example.com##[-abp-properties='foo']"] |
| 174 ); | 182 ); |
| 175 | 183 |
| 176 test.done(); | 184 test.done(); |
| 177 }; | 185 }; |
| 178 | 186 |
| 179 exports.testElemHideEmulationFiltersContainer = function(test) | 187 exports.testElemHideEmulationFiltersContainer = function(test) |
| 180 { | 188 { |
| 181 function compareRules(description, domain, expectedMatches) | 189 function compareRules(description, domain, expectedMatches) |
| 182 { | 190 { |
| 183 let result = ElemHideEmulation.getRulesForDomain(domain) | 191 let rules = ElemHideEmulation.getRulesForDomain(domain); |
| 184 .map(filter => filter.text); | 192 let result = []; |
| 193 for (let i = 0; i < rules.filterCount; i++) |
| 194 { |
| 195 let filter = rules.filterAt(i); |
| 196 result.push(filter.text); |
| 197 filter.delete(); |
| 198 } |
| 185 expectedMatches = expectedMatches.map(filter => filter.text); | 199 expectedMatches = expectedMatches.map(filter => filter.text); |
| 186 test.deepEqual(result.sort(), expectedMatches.sort(), description); | 200 test.deepEqual(result.sort(), expectedMatches.sort(), description); |
| 201 |
| 202 rules.delete(); |
| 187 } | 203 } |
| 188 | 204 |
| 189 let domainFilter = Filter.fromText("example.com##filter1"); | 205 let domainFilter = Filter.fromText("example.com##filter1"); |
| 190 let subdomainFilter = Filter.fromText("www.example.com##filter2"); | 206 let subdomainFilter = Filter.fromText("www.example.com##filter2"); |
| 191 let otherDomainFilter = Filter.fromText("other.example.com##filter3"); | 207 let otherDomainFilter = Filter.fromText("other.example.com##filter3"); |
| 192 | 208 |
| 193 ElemHideEmulation.add(domainFilter); | 209 ElemHideEmulation.add(domainFilter); |
| 194 ElemHideEmulation.add(subdomainFilter); | 210 ElemHideEmulation.add(subdomainFilter); |
| 195 ElemHideEmulation.add(otherDomainFilter); | 211 ElemHideEmulation.add(otherDomainFilter); |
| 196 compareRules( | 212 compareRules( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 208 | 224 |
| 209 ElemHideEmulation.clear(); | 225 ElemHideEmulation.clear(); |
| 210 compareRules( | 226 compareRules( |
| 211 "Return no filters after clearing", | 227 "Return no filters after clearing", |
| 212 "www.example.com", | 228 "www.example.com", |
| 213 [] | 229 [] |
| 214 ); | 230 ); |
| 215 | 231 |
| 216 test.done(); | 232 test.done(); |
| 217 }; | 233 }; |
| OLD | NEW |