OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil
terComponents}); | 3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil
terComponents}); |
4 | 4 |
5 function compareKeywords(text, expected) | 5 function compareKeywords(text, expected) |
6 { | 6 { |
7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) | 7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) |
8 { | 8 { |
9 let matcher = new Matcher(); | 9 let matcher = new Matcher(); |
10 let result = []; | 10 let result = []; |
11 for (let dummy of expected) | 11 for (let dummy of expected) |
12 { | 12 { |
13 let keyword = matcher.findKeyword(filter); | 13 let keyword = matcher.findKeyword(filter); |
14 result.push(keyword); | 14 result.push(keyword); |
15 if (keyword) | 15 if (keyword) |
16 { | 16 { |
17 let dummyFilter = Filter.fromText('^' + keyword + '^'); | 17 let dummyFilter = Filter.fromText('^' + keyword + '^'); |
18 dummyFilter.filterCount = Infinity; | 18 dummyFilter.filterCount = Infinity; |
19 matcher.add(dummyFilter); | 19 matcher.add(dummyFilter); |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 equal(result.join(", "), expected.join(", "), "Keyword candidates for " +
filter.text); | 23 equal(result.join(", "), expected.join(", "), "Keyword candidates for " +
filter.text); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 function checkMatch(filters, location, contentType, docDomain, thirdParty, sit
ekey, expected) | 27 function checkMatch(filters, location, contentType, docDomain, thirdParty, sit
ekey, specificOnly, expected) |
28 { | 28 { |
29 let matcher = new Matcher(); | 29 let matcher = new Matcher(); |
30 for (let filter of filters) | 30 for (let filter of filters) |
31 matcher.add(Filter.fromText(filter)); | 31 matcher.add(Filter.fromText(filter)); |
32 | 32 |
33 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType],
docDomain, thirdParty, sitekey); | 33 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType],
docDomain, thirdParty, sitekey, specificOnly); |
34 if (result) | 34 if (result) |
35 result = result.text; | 35 result = result.text; |
36 | 36 |
37 equal(result, expected, "match(" + location + ", " + contentType + ", " + do
cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey
|| "no-sitekey") + ") with:\n" + filters.join("\n")); | 37 equal(result, expected, "match(" + location + ", " + contentType + ", " + do
cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey
|| "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-specificOnly") +
") with:\n" + filters.join("\n")); |
38 | 38 |
39 let combinedMatcher = new CombinedMatcher(); | 39 let combinedMatcher = new CombinedMatcher(); |
40 for (let i = 0; i < 2; i++) | 40 for (let i = 0; i < 2; i++) |
41 { | 41 { |
42 for (let filter of filters) | 42 for (let filter of filters) |
43 combinedMatcher.add(Filter.fromText(filter)); | 43 combinedMatcher.add(Filter.fromText(filter)); |
44 | 44 |
45 let result = combinedMatcher.matchesAny(location, RegExpFilter.typeMap[con
tentType], docDomain, thirdParty, sitekey); | 45 let result = combinedMatcher.matchesAny(location, RegExpFilter.typeMap[con
tentType], docDomain, thirdParty, sitekey, specificOnly); |
46 if (result) | 46 if (result) |
47 result = result.text; | 47 result = result.text; |
48 | 48 |
49 equal(result, expected, "combinedMatch(" + location + ", " + contentType +
", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " +
(sitekey || "no-sitekey") + ") with:\n" + filters.join("\n")); | 49 equal(result, expected, "combinedMatch(" + location + ", " + contentType +
", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " +
(sitekey || "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-specif
icOnly") + ") with:\n" + filters.join("\n")); |
50 | 50 |
51 // For next run: add whitelisting filters | 51 // Generic whitelisting rules can match for specificOnly searches, so we |
52 filters = filters.map((text) => "@@" + text); | 52 // can't easily know which rule will match for these whitelisting tests |
53 if (expected) | 53 if (specificOnly) |
| 54 continue; |
| 55 |
| 56 // For next run: add whitelisting filters for filters that aren't already |
| 57 filters = filters.map((text) => text.substr(0, 2) == "@@" ? text : "@@" +
text); |
| 58 if (expected && expected.substr(0, 2) != "@@") |
54 expected = "@@" + expected; | 59 expected = "@@" + expected; |
55 } | 60 } |
56 } | 61 } |
57 | 62 |
58 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp
ected) | 63 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp
ected) |
59 { | 64 { |
60 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType],
docDomain, thirdParty); | 65 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType],
docDomain, thirdParty); |
61 if (result) | 66 if (result) |
62 result = result.text; | 67 result = result.text; |
63 | 68 |
(...skipping 25 matching lines...) Expand all Loading... |
89 compareKeywords("^foo%2Ebar^", ["foo%2ebar"]); | 94 compareKeywords("^foo%2Ebar^", ["foo%2ebar"]); |
90 compareKeywords("^aSdF^1234", ["asdf"]); | 95 compareKeywords("^aSdF^1234", ["asdf"]); |
91 compareKeywords("_asdf_1234_", ["asdf", "1234"]); | 96 compareKeywords("_asdf_1234_", ["asdf", "1234"]); |
92 compareKeywords("+asdf-1234=", ["asdf", "1234"]); | 97 compareKeywords("+asdf-1234=", ["asdf", "1234"]); |
93 compareKeywords("/123^ad2&ad&", ["123", "ad2"]); | 98 compareKeywords("/123^ad2&ad&", ["123", "ad2"]); |
94 compareKeywords("/123^ad2&ad$script,domain=example.com", ["123", "ad2"]); | 99 compareKeywords("/123^ad2&ad$script,domain=example.com", ["123", "ad2"]); |
95 }); | 100 }); |
96 | 101 |
97 test("Filter matching", function() | 102 test("Filter matching", function() |
98 { | 103 { |
99 checkMatch([], "http://abc/def", "IMAGE", null, false, null, null); | 104 checkMatch([], "http://abc/def", "IMAGE", null, false, null, false, null); |
100 checkMatch(["abc"], "http://abc/def", "IMAGE", null, false, null, "abc"); | 105 checkMatch(["abc"], "http://abc/def", "IMAGE", null, false, null, false, "ab
c"); |
101 checkMatch(["abc", "ddd"], "http://abc/def", "IMAGE", null, false, null, "ab
c"); | 106 checkMatch(["abc", "ddd"], "http://abc/def", "IMAGE", null, false, null, fal
se, "abc"); |
102 checkMatch(["ddd", "abc"], "http://abc/def", "IMAGE", null, false, null, "ab
c"); | 107 checkMatch(["ddd", "abc"], "http://abc/def", "IMAGE", null, false, null, fal
se, "abc"); |
103 checkMatch(["ddd", "abd"], "http://abc/def", "IMAGE", null, false, null, nul
l); | 108 checkMatch(["ddd", "abd"], "http://abc/def", "IMAGE", null, false, null, fal
se, null); |
104 checkMatch(["abc", "://abc/d"], "http://abc/def", "IMAGE", null, false, null
, "://abc/d"); | 109 checkMatch(["abc", "://abc/d"], "http://abc/def", "IMAGE", null, false, null
, false, "://abc/d"); |
105 checkMatch(["://abc/d", "abc"], "http://abc/def", "IMAGE", null, false, null
, "://abc/d"); | 110 checkMatch(["://abc/d", "abc"], "http://abc/def", "IMAGE", null, false, null
, false, "://abc/d"); |
106 checkMatch(["|http://"], "http://abc/def", "IMAGE", null, false, null, "|htt
p://"); | 111 checkMatch(["|http://"], "http://abc/def", "IMAGE", null, false, null, false
, "|http://"); |
107 checkMatch(["|http://abc"], "http://abc/def", "IMAGE", null, false, null, "|
http://abc"); | 112 checkMatch(["|http://abc"], "http://abc/def", "IMAGE", null, false, null, fa
lse, "|http://abc"); |
108 checkMatch(["|abc"], "http://abc/def", "IMAGE", null, false, null, null); | 113 checkMatch(["|abc"], "http://abc/def", "IMAGE", null, false, null, false, nu
ll); |
109 checkMatch(["|/abc/def"], "http://abc/def", "IMAGE", null, false, null, null
); | 114 checkMatch(["|/abc/def"], "http://abc/def", "IMAGE", null, false, null, fals
e, null); |
110 checkMatch(["/def|"], "http://abc/def", "IMAGE", null, false, null, "/def|")
; | 115 checkMatch(["/def|"], "http://abc/def", "IMAGE", null, false, null, false, "
/def|"); |
111 checkMatch(["/abc/def|"], "http://abc/def", "IMAGE", null, false, null, "/ab
c/def|"); | 116 checkMatch(["/abc/def|"], "http://abc/def", "IMAGE", null, false, null, fals
e, "/abc/def|"); |
112 checkMatch(["/abc/|"], "http://abc/def", "IMAGE", null, false, null, null); | 117 checkMatch(["/abc/|"], "http://abc/def", "IMAGE", null, false, null, false,
null); |
113 checkMatch(["http://abc/|"], "http://abc/def", "IMAGE", null, false, null, n
ull); | 118 checkMatch(["http://abc/|"], "http://abc/def", "IMAGE", null, false, null, f
alse, null); |
114 checkMatch(["|http://abc/def|"], "http://abc/def", "IMAGE", null, false, nul
l, "|http://abc/def|"); | 119 checkMatch(["|http://abc/def|"], "http://abc/def", "IMAGE", null, false, nul
l, false, "|http://abc/def|"); |
115 checkMatch(["|/abc/def|"], "http://abc/def", "IMAGE", null, false, null, nul
l); | 120 checkMatch(["|/abc/def|"], "http://abc/def", "IMAGE", null, false, null, fal
se, null); |
116 checkMatch(["|http://abc/|"], "http://abc/def", "IMAGE", null, false, null,
null); | 121 checkMatch(["|http://abc/|"], "http://abc/def", "IMAGE", null, false, null,
false, null); |
117 checkMatch(["|/abc/|"], "http://abc/def", "IMAGE", null, false, null, null); | 122 checkMatch(["|/abc/|"], "http://abc/def", "IMAGE", null, false, null, false,
null); |
118 checkMatch(["||example.com/abc"], "http://example.com/abc/def", "IMAGE", nul
l, false, null, "||example.com/abc"); | 123 checkMatch(["||example.com/abc"], "http://example.com/abc/def", "IMAGE", nul
l, false, null, false, "||example.com/abc"); |
119 checkMatch(["||com/abc/def"], "http://example.com/abc/def", "IMAGE", null, f
alse, null, "||com/abc/def"); | 124 checkMatch(["||com/abc/def"], "http://example.com/abc/def", "IMAGE", null, f
alse, null, false, "||com/abc/def"); |
120 checkMatch(["||com/abc"], "http://example.com/abc/def", "IMAGE", null, false
, null, "||com/abc"); | 125 checkMatch(["||com/abc"], "http://example.com/abc/def", "IMAGE", null, false
, null, false, "||com/abc"); |
121 checkMatch(["||mple.com/abc"], "http://example.com/abc/def", "IMAGE", null,
false, null, null); | 126 checkMatch(["||mple.com/abc"], "http://example.com/abc/def", "IMAGE", null,
false, null, false, null); |
122 checkMatch(["||.com/abc/def"], "http://example.com/abc/def", "IMAGE", null,
false, null, null); | 127 checkMatch(["||.com/abc/def"], "http://example.com/abc/def", "IMAGE", null,
false, null, false, null); |
123 checkMatch(["||http://example.com/"], "http://example.com/abc/def", "IMAGE",
null, false, null, null); | 128 checkMatch(["||http://example.com/"], "http://example.com/abc/def", "IMAGE",
null, false, null, false, null); |
124 checkMatch(["||example.com/abc/def|"], "http://example.com/abc/def", "IMAGE"
, null, false, null, "||example.com/abc/def|"); | 129 checkMatch(["||example.com/abc/def|"], "http://example.com/abc/def", "IMAGE"
, null, false, null, false, "||example.com/abc/def|"); |
125 checkMatch(["||com/abc/def|"], "http://example.com/abc/def", "IMAGE", null,
false, null, "||com/abc/def|"); | 130 checkMatch(["||com/abc/def|"], "http://example.com/abc/def", "IMAGE", null,
false, null, false, "||com/abc/def|"); |
126 checkMatch(["||example.com/abc|"], "http://example.com/abc/def", "IMAGE", nu
ll, false, null, null); | 131 checkMatch(["||example.com/abc|"], "http://example.com/abc/def", "IMAGE", nu
ll, false, null, false, null); |
127 checkMatch(["abc", "://abc/d", "asdf1234"], "http://abc/def", "IMAGE", null,
false, null, "://abc/d"); | 132 checkMatch(["abc", "://abc/d", "asdf1234"], "http://abc/def", "IMAGE", null,
false, null, false, "://abc/d"); |
128 checkMatch(["foo*://abc/d", "foo*//abc/de", "://abc/de", "asdf1234"], "http:
//abc/def", "IMAGE", null, false, null, "://abc/de"); | 133 checkMatch(["foo*://abc/d", "foo*//abc/de", "://abc/de", "asdf1234"], "http:
//abc/def", "IMAGE", null, false, null, false, "://abc/de"); |
129 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def",
"IMAGE", null, false, null, "abc$~third-party"); | 134 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def",
"IMAGE", null, false, null, false, "abc$~third-party"); |
130 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def",
"IMAGE", null, true, null, "abc$third-party"); | 135 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def",
"IMAGE", null, true, null, false, "abc$third-party"); |
131 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"],
"http://abc/def", "IMAGE", null, false, null, "//abc/def$~third-party"); | 136 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"],
"http://abc/def", "IMAGE", null, false, null, false, "//abc/def$~third-party"); |
132 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"],
"http://abc/def", "IMAGE", null, true, null, "//abc/def$third-party"); | 137 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"],
"http://abc/def", "IMAGE", null, true, null, false, "//abc/def$third-party"); |
133 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def"], "http://abc
/def", "IMAGE", null, true, null, "//abc/def"); | 138 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def"], "http://abc
/def", "IMAGE", null, true, null, false, "//abc/def"); |
134 checkMatch(["//abc/def", "abc$third-party", "abc$~third-party"], "http://abc
/def", "IMAGE", null, true, null, "//abc/def"); | 139 checkMatch(["//abc/def", "abc$third-party", "abc$~third-party"], "http://abc
/def", "IMAGE", null, true, null, false, "//abc/def"); |
135 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"],
"http://abc/def", "IMAGE", null, true, null, "//abc/def$third-party"); | 140 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"],
"http://abc/def", "IMAGE", null, true, null, false, "//abc/def$third-party"); |
136 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"],
"http://abc/def", "IMAGE", null, false, null, "abc$~third-party"); | 141 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"],
"http://abc/def", "IMAGE", null, false, null, false, "abc$~third-party"); |
137 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$~third-party"]
, "http://abc/def", "IMAGE", null, true, null, "abc$third-party"); | 142 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$~third-party"]
, "http://abc/def", "IMAGE", null, true, null, false, "abc$third-party"); |
138 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "IMA
GE", null, false, null, "abc$image"); | 143 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "IMA
GE", null, false, null, false, "abc$image"); |
139 checkMatch(["abc$image", "abc$script", "abc$~script"], "http://abc/def", "SC
RIPT", null, false, null, "abc$script"); | 144 checkMatch(["abc$image", "abc$script", "abc$~script"], "http://abc/def", "SC
RIPT", null, false, null, false, "abc$script"); |
140 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "OTH
ER", null, false, null, "abc$~image"); | 145 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "OTH
ER", null, false, null, false, "abc$~image"); |
141 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt
p://abc/def", "IMAGE", null, false, null, "//abc/def$image"); | 146 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt
p://abc/def", "IMAGE", null, false, null, false, "//abc/def$image"); |
142 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~script"], "ht
tp://abc/def", "SCRIPT", null, false, null, "//abc/def$script"); | 147 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~script"], "ht
tp://abc/def", "SCRIPT", null, false, null, false, "//abc/def$script"); |
143 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt
p://abc/def", "OTHER", null, false, null, "//abc/def$~image"); | 148 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt
p://abc/def", "OTHER", null, false, null, false, "//abc/def$~image"); |
144 checkMatch(["abc$image", "abc$~image", "//abc/def"], "http://abc/def", "IMAG
E", null, false, null, "//abc/def"); | 149 checkMatch(["abc$image", "abc$~image", "//abc/def"], "http://abc/def", "IMAG
E", null, false, null, false, "//abc/def"); |
145 checkMatch(["//abc/def", "abc$image", "abc$~image"], "http://abc/def", "IMAG
E", null, false, null, "//abc/def"); | 150 checkMatch(["//abc/def", "abc$image", "abc$~image"], "http://abc/def", "IMAG
E", null, false, null, false, "//abc/def"); |
146 checkMatch(["abc$image", "abc$~image", "//abc/def$image"], "http://abc/def",
"IMAGE", null, false, null, "//abc/def$image"); | 151 checkMatch(["abc$image", "abc$~image", "//abc/def$image"], "http://abc/def",
"IMAGE", null, false, null, false, "//abc/def$image"); |
147 checkMatch(["abc$image", "abc$~image", "//abc/def$script"], "http://abc/def"
, "IMAGE", null, false, null, "abc$image"); | 152 checkMatch(["abc$image", "abc$~image", "//abc/def$script"], "http://abc/def"
, "IMAGE", null, false, null, false, "abc$image"); |
148 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, "abc$domain=foo.
com"); | 153 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, false, "abc$doma
in=foo.com"); |
149 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, "abc$domain=bar.
com"); | 154 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, false, "abc$doma
in=bar.com"); |
150 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, "abc$domain=~foo
.com|~bar.com"); | 155 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, false, "abc$doma
in=~foo.com|~bar.com"); |
151 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, "abc$domain=foo.
com"); | 156 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, false, "abc$doma
in=foo.com"); |
152 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, null); | 157 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, false, null); |
153 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, null); | 158 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, false, null); |
154 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, null, "ccc$domain=~foo
.com|~bar.com"); | 159 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com
|~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, null, false, "ccc$doma
in=~foo.com|~bar.com"); |
155 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "foo.com", false, "foo-publickey", "abc$sitekey=foo-public
key"); | 160 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "foo.com", false, "foo-publickey", false, "abc$sitekey=foo
-publickey"); |
156 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "bar.com", false, "bar-publickey", "abc$sitekey=bar-public
key"); | 161 checkMatch(["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, "abc$sitekey=bar
-publickey"); |
157 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "bar.com", false, "bar-publickey", null); | 162 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, null); |
158 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "baz.com", false, null, null); | 163 checkMatch(["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], "http
://abc/def", "IMAGE", "baz.com", false, null, false, null); |
159 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "foo-publi
ckey", "abc$sitekey=foo-publickey,domain=foo.com"); | 164 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "foo-publi
ckey", false, "abc$sitekey=foo-publickey,domain=foo.com"); |
160 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "bar-publi
ckey", null); | 165 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "bar-publi
ckey", false, null); |
161 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "foo-publi
ckey", null); | 166 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "foo-publi
ckey", false, null); |
162 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "bar-publi
ckey", "abc$sitekey=bar-publickey,domain=bar.com"); | 167 checkMatch(["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar-pub
lickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "bar-publi
ckey", false, "abc$sitekey=bar-publickey,domain=bar.com"); |
| 168 checkMatch(["@@foo.com$generichide"], "http://foo.com/bar", "GENERICHIDE", "
foo.com", false, null, false, "@@foo.com$generichide"); |
| 169 checkMatch(["@@foo.com$genericblock"], "http://foo.com/bar", "GENERICBLOCK",
"foo.com", false, null, false, "@@foo.com$genericblock"); |
| 170 checkMatch(["@@bar.com$generichide"], "http://foo.com/bar", "GENERICHIDE", "
foo.com", false, null, false, null); |
| 171 checkMatch(["@@bar.com$genericblock"], "http://foo.com/bar", "GENERICBLOCK",
"foo.com", false, null, false, null); |
| 172 checkMatch(["/bar"], "http://foo.com/bar", "IMAGE", "foo.com", false, null,
true, null); |
| 173 checkMatch(["/bar$domain=foo.com"], "http://foo.com/bar", "IMAGE", "foo.com"
, false, null, true, "/bar$domain=foo.com"); |
163 }); | 174 }); |
164 | 175 |
165 test("Result cache checks", function() | 176 test("Result cache checks", function() |
166 { | 177 { |
167 let matcher = new CombinedMatcher(); | 178 let matcher = new CombinedMatcher(); |
168 matcher.add(Filter.fromText("abc$image")); | 179 matcher.add(Filter.fromText("abc$image")); |
169 matcher.add(Filter.fromText("abc$script")); | 180 matcher.add(Filter.fromText("abc$script")); |
170 matcher.add(Filter.fromText("abc$~image,~script,~media")); | 181 matcher.add(Filter.fromText("abc$~image,~script,~media")); |
171 matcher.add(Filter.fromText("cba$third-party")); | 182 matcher.add(Filter.fromText("cba$third-party")); |
172 matcher.add(Filter.fromText("cba$~third-party,~script")); | 183 matcher.add(Filter.fromText("cba$~third-party,~script")); |
(...skipping 14 matching lines...) Expand all Loading... |
187 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p
arty,~script"); | 198 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p
arty,~script"); |
188 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par
ty"); | 199 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par
ty"); |
189 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-part
y,~script"); | 200 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-part
y,~script"); |
190 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party"
); | 201 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party"
); |
191 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); | 202 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); |
192 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, false, "http://f
ed$~third-party,~script"); | 203 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, false, "http://f
ed$~third-party,~script"); |
193 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, true, "http://fe
d$third-party"); | 204 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, true, "http://fe
d$third-party"); |
194 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http://
def$script"); | 205 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http://
def$script"); |
195 }); | 206 }); |
196 })(); | 207 })(); |
OLD | NEW |