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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 cacheCheck(test, matcher, "http://fed", "IMAGE", null, true, "http://fed$third
-party"); | 242 cacheCheck(test, matcher, "http://fed", "IMAGE", null, true, "http://fed$third
-party"); |
243 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-
party,~script"); | 243 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-
party,~script"); |
244 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-pa
rty"); | 244 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-pa
rty"); |
245 cacheCheck(test, matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script
"); | 245 cacheCheck(test, matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script
"); |
246 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, false, "http
://fed$~third-party,~script"); | 246 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, false, "http
://fed$~third-party,~script"); |
247 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, true, "http:
//fed$third-party"); | 247 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, true, "http:
//fed$third-party"); |
248 cacheCheck(test, matcher, "http://def?http://fed", "SCRIPT", null, false, "htt
p://def$script"); | 248 cacheCheck(test, matcher, "http://def?http://fed", "SCRIPT", null, false, "htt
p://def$script"); |
249 | 249 |
250 test.done(); | 250 test.done(); |
251 }; | 251 }; |
| 252 |
| 253 exports.testWhitelisted = function(test) |
| 254 { |
| 255 let matcher = new CombinedMatcher(); |
| 256 |
| 257 test.ok(!matcher.isWhitelisted("https://example.com/foo", |
| 258 RegExpFilter.typeMap.IMAGE)); |
| 259 test.ok(!matcher.isWhitelisted("https://example.com/bar", |
| 260 RegExpFilter.typeMap.IMAGE)); |
| 261 test.ok(!matcher.isWhitelisted("https://example.com/foo", |
| 262 RegExpFilter.typeMap.SUBDOCUMENT)); |
| 263 |
| 264 matcher.add(Filter.fromText("@@/foo^$image")); |
| 265 |
| 266 test.ok(matcher.isWhitelisted("https://example.com/foo", |
| 267 RegExpFilter.typeMap.IMAGE)); |
| 268 test.ok(!matcher.isWhitelisted("https://example.com/bar", |
| 269 RegExpFilter.typeMap.IMAGE)); |
| 270 test.ok(!matcher.isWhitelisted("https://example.com/foo", |
| 271 RegExpFilter.typeMap.SUBDOCUMENT)); |
| 272 |
| 273 matcher.remove(Filter.fromText("@@/foo^$image")); |
| 274 |
| 275 test.ok(!matcher.isWhitelisted("https://example.com/foo", |
| 276 RegExpFilter.typeMap.IMAGE)); |
| 277 test.ok(!matcher.isWhitelisted("https://example.com/bar", |
| 278 RegExpFilter.typeMap.IMAGE)); |
| 279 test.ok(!matcher.isWhitelisted("https://example.com/foo", |
| 280 RegExpFilter.typeMap.SUBDOCUMENT)); |
| 281 |
| 282 test.done(); |
| 283 }; |
OLD | NEW |