OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 module("Matching of blocking filters", {setup: prepareFilterComponents, teardo
wn: restoreFilterComponents}); | 3 module("Matching of blocking filters", {setup: prepareFilterComponents, teardo
wn: restoreFilterComponents}); |
4 | 4 |
5 function testMatch(text, location, contentType, docDomain, thirdParty, sitekey
, expected) | 5 function testMatch(text, location, contentType, docDomain, thirdParty, sitekey
, expected) |
6 { | 6 { |
7 function testMatch_internal(text, location, contentType, docDomain, thirdPar
ty, sitekey, expected) | 7 function testMatch_internal(text, location, contentType, docDomain, thirdPar
ty, sitekey, expected) |
8 { | 8 { |
9 let filter = Filter.fromText(text); | 9 let filter = Filter.fromText(text); |
10 let result = filter.matches(location, contentType, docDomain, thirdParty,
sitekey); | 10 let result = filter.matches(location, RegExpFilter.typeMap[contentType], d
ocDomain, thirdParty, sitekey); |
11 equal(!!result, expected, '"' + text + '".matches(' + location + ", " + co
ntentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party
") + ", " + (sitekey || "no-sitekey") + ")"); | 11 equal(!!result, expected, '"' + text + '".matches(' + location + ", " + co
ntentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party
") + ", " + (sitekey || "no-sitekey") + ")"); |
12 } | 12 } |
13 testMatch_internal(text, location, contentType, docDomain, thirdParty, sitek
ey, expected); | 13 testMatch_internal(text, location, contentType, docDomain, thirdParty, sitek
ey, expected); |
14 if (!/^@@/.test(text)) | 14 if (!/^@@/.test(text)) |
15 testMatch_internal("@@" + text, location, contentType, docDomain, thirdPar
ty, sitekey, expected); | 15 testMatch_internal("@@" + text, location, contentType, docDomain, thirdPar
ty, sitekey, expected); |
16 } | 16 } |
17 | 17 |
18 test("Basic filters", function() | 18 test("Basic filters", function() |
19 { | 19 { |
20 testMatch("abc", "http://abc/adf", "IMAGE", null, false, null, true); | 20 testMatch("abc", "http://abc/adf", "IMAGE", null, false, null, true); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 testMatch("@@test$~image,document", "http://test/", "DOCUMENT", null, false,
null, true); | 301 testMatch("@@test$~image,document", "http://test/", "DOCUMENT", null, false,
null, true); |
302 testMatch("@@test$document,~image", "http://test/", "DOCUMENT", null, false,
null, true); | 302 testMatch("@@test$document,~image", "http://test/", "DOCUMENT", null, false,
null, true); |
303 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo
.com", false, null, true); | 303 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "foo
.com", false, null, true); |
304 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar
.com", false, null, false); | 304 testMatch("@@test$document,domain=foo.com", "http://test/", "DOCUMENT", "bar
.com", false, null, false); |
305 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "fo
o.com", false, null, false); | 305 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "fo
o.com", false, null, false); |
306 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "ba
r.com", false, null, true); | 306 testMatch("@@test$document,domain=~foo.com", "http://test/", "DOCUMENT", "ba
r.com", false, null, true); |
307 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT
", "foo.com", false, "foo-publickey", true); | 307 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT
", "foo.com", false, "foo-publickey", true); |
308 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT
", "foo.com", false, null, false); | 308 testMatch("@@test$document,sitekey=foo-publickey", "http://test/", "DOCUMENT
", "foo.com", false, null, false); |
309 }); | 309 }); |
310 })(); | 310 })(); |
OLD | NEW |