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

Unified Diff: test/matcher.js

Issue 29961555: Issue 7162 - Add isWhitelisted method to CombinedMatcher (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Dec. 9, 2018, 11:54 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
« lib/matcher.js ('K') | « 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
@@ -244,8 +244,40 @@
cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party");
cacheCheck(test, matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script");
cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, false, "http://fed$~third-party,~script");
cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, true, "http://fed$third-party");
cacheCheck(test, matcher, "http://def?http://fed", "SCRIPT", null, false, "http://def$script");
test.done();
};
+
+exports.testWhitelisted = function(test)
+{
+ let matcher = new CombinedMatcher();
+
+ test.ok(!matcher.isWhitelisted("https://example.com/foo",
+ 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));
+
+ matcher.add(Filter.fromText("@@/foo^$image"));
+
+ test.ok(matcher.isWhitelisted("https://example.com/foo",
+ 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));
+
+ matcher.remove(Filter.fromText("@@/foo^$image"));
+
+ test.ok(!matcher.isWhitelisted("https://example.com/foo",
+ 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();
+};
« lib/matcher.js ('K') | « lib/matcher.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld