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

Unified 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: Clear map Created Dec. 20, 2018, 10:57 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/matcher.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/matcher.js
===================================================================
--- a/test/matcher.js
+++ b/test/matcher.js
@@ -286,8 +286,30 @@
RegExpFilter.typeMap.IMAGE));
test.ok(!matcher.isWhitelisted("https://example.com/bar",
RegExpFilter.typeMap.IMAGE));
test.ok(!matcher.isWhitelisted("https://example.com/foo",
RegExpFilter.typeMap.SUBDOCUMENT));
test.done();
};
+
+exports.testAddRemoveByKeyword = function(test)
+{
+ let matcher = new CombinedMatcher();
+
+ matcher.add(Filter.fromText("||example.com/foo/bar/image.jpg"));
+
+ // Add the same filter a second time to make sure it doesn't get added again
+ // by a different keyword.
+ matcher.add(Filter.fromText("||example.com/foo/bar/image.jpg"));
+
+ test.ok(!!matcher.matchesAny("https://example.com/foo/bar/image.jpg",
+ RegExpFilter.typeMap.IMAGE));
+
+ matcher.remove(Filter.fromText("||example.com/foo/bar/image.jpg"));
+
+ // Make sure the filter got removed so there is no match.
+ test.ok(!matcher.matchesAny("https://example.com/foo/bar/image.jpg",
+ RegExpFilter.typeMap.IMAGE));
+
+ test.done();
+};
« 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