| LEFT | RIGHT |
| (no file at all) | |
| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 const {createSandbox} = require("./_common"); | 20 const {createSandbox} = require("./_common"); |
| 21 | 21 |
| 22 let ElemHide = null; | 22 let ElemHide = null; |
| 23 let ElemHideExceptions = null; | 23 let ElemHideExceptions = null; |
| 24 let Filter = null; | 24 let Filter = null; |
| 25 let filtersByDomain = null; |
| 25 | 26 |
| 26 exports.setUp = function(callback) | 27 exports.setUp = function(callback) |
| 27 { | 28 { |
| 28 let sandboxedRequire = createSandbox(); | 29 let sandboxedRequire = createSandbox({ |
| 30 extraExports: { |
| 31 elemHide: ["filtersByDomain"] |
| 32 } |
| 33 }); |
| 29 ( | 34 ( |
| 30 {ElemHide} = sandboxedRequire("../lib/elemHide"), | 35 {ElemHide, filtersByDomain} = sandboxedRequire("../lib/elemHide"), |
| 31 {ElemHideExceptions} = sandboxedRequire("../lib/elemHideExceptions"), | 36 {ElemHideExceptions} = sandboxedRequire("../lib/elemHideExceptions"), |
| 32 {Filter} = sandboxedRequire("../lib/filterClasses") | 37 {Filter} = sandboxedRequire("../lib/filterClasses") |
| 33 ); | 38 ); |
| 34 | 39 |
| 35 callback(); | 40 callback(); |
| 36 }; | 41 }; |
| 37 | 42 |
| 38 function normalizeSelectors(selectors) | 43 function normalizeSelectors(selectors) |
| 39 { | 44 { |
| 40 // getSelectorsForDomain is currently allowed to return duplicate selectors | 45 // getSelectorsForDomain is currently allowed to return duplicate selectors |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 }; | 244 }; |
| 240 | 245 |
| 241 exports.testZeroFilterKey = function(test) | 246 exports.testZeroFilterKey = function(test) |
| 242 { | 247 { |
| 243 ElemHide.add(Filter.fromText("##test")); | 248 ElemHide.add(Filter.fromText("##test")); |
| 244 ElemHideExceptions.add(Filter.fromText("foo.com#@#test")); | 249 ElemHideExceptions.add(Filter.fromText("foo.com#@#test")); |
| 245 testResult(test, "foo.com", []); | 250 testResult(test, "foo.com", []); |
| 246 testResult(test, "bar.com", ["test"]); | 251 testResult(test, "bar.com", ["test"]); |
| 247 test.done(); | 252 test.done(); |
| 248 }; | 253 }; |
| 254 |
| 255 exports.testFiltersByDomain = function(test) |
| 256 { |
| 257 test.equal(filtersByDomain.size, 0); |
| 258 |
| 259 ElemHide.add(Filter.fromText("##test")); |
| 260 test.equal(filtersByDomain.size, 0); |
| 261 |
| 262 ElemHide.add(Filter.fromText("example.com##test")); |
| 263 test.equal(filtersByDomain.size, 1); |
| 264 |
| 265 ElemHide.add(Filter.fromText("example.com,~www.example.com##test")); |
| 266 test.equal(filtersByDomain.size, 2); |
| 267 |
| 268 ElemHide.remove(Filter.fromText("example.com##test")); |
| 269 test.equal(filtersByDomain.size, 2); |
| 270 |
| 271 ElemHide.remove(Filter.fromText("example.com,~www.example.com##test")); |
| 272 test.equal(filtersByDomain.size, 0); |
| 273 |
| 274 test.done(); |
| 275 }; |
| LEFT | RIGHT |