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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 test.ok(!matcher.isWhitelisted("https://example.com/foo", | 285 test.ok(!matcher.isWhitelisted("https://example.com/foo", |
286 RegExpFilter.typeMap.IMAGE)); | 286 RegExpFilter.typeMap.IMAGE)); |
287 test.ok(!matcher.isWhitelisted("https://example.com/bar", | 287 test.ok(!matcher.isWhitelisted("https://example.com/bar", |
288 RegExpFilter.typeMap.IMAGE)); | 288 RegExpFilter.typeMap.IMAGE)); |
289 test.ok(!matcher.isWhitelisted("https://example.com/foo", | 289 test.ok(!matcher.isWhitelisted("https://example.com/foo", |
290 RegExpFilter.typeMap.SUBDOCUMENT)); | 290 RegExpFilter.typeMap.SUBDOCUMENT)); |
291 | 291 |
292 test.done(); | 292 test.done(); |
293 }; | 293 }; |
| 294 |
| 295 exports.testAddRemoveByKeyword = function(test) |
| 296 { |
| 297 let matcher = new CombinedMatcher(); |
| 298 |
| 299 matcher.add(Filter.fromText("||example.com/foo/bar/image.jpg")); |
| 300 |
| 301 // Add the same filter a second time to make sure it doesn't get added again |
| 302 // by a different keyword. |
| 303 matcher.add(Filter.fromText("||example.com/foo/bar/image.jpg")); |
| 304 |
| 305 test.ok(!!matcher.matchesAny("https://example.com/foo/bar/image.jpg", |
| 306 RegExpFilter.typeMap.IMAGE)); |
| 307 |
| 308 matcher.remove(Filter.fromText("||example.com/foo/bar/image.jpg")); |
| 309 |
| 310 // Make sure the filter got removed so there is no match. |
| 311 test.ok(!matcher.matchesAny("https://example.com/foo/bar/image.jpg", |
| 312 RegExpFilter.typeMap.IMAGE)); |
| 313 |
| 314 test.done(); |
| 315 }; |
OLD | NEW |