Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/matcher.js

Issue 29965589: Issue 7181 - Keep a keyword-by-filter map after all (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rename to _keywordByFilter Created Dec. 20, 2018, 11 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/matcher.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 };
OLDNEW
« no previous file with comments | « lib/matcher.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld