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 = []; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | 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); |
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); | 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); |
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"); | 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"); |
163 }); | 163 }); |
164 | 164 |
165 test("Result cache checks", function() | 165 test("Result cache checks", function() |
166 { | 166 { |
167 let matcher = new CombinedMatcher(); | 167 let matcher = new CombinedMatcher(); |
168 matcher.add(Filter.fromText("abc$image")); | 168 matcher.add(Filter.fromText("abc$image")); |
169 matcher.add(Filter.fromText("abc$script")); | 169 matcher.add(Filter.fromText("abc$script")); |
170 matcher.add(Filter.fromText("abc$~image,~script,~document")); | 170 matcher.add(Filter.fromText("abc$~image,~script,~media")); |
171 matcher.add(Filter.fromText("cba$third-party")); | 171 matcher.add(Filter.fromText("cba$third-party")); |
172 matcher.add(Filter.fromText("cba$~third-party,~script")); | 172 matcher.add(Filter.fromText("cba$~third-party,~script")); |
173 matcher.add(Filter.fromText("http://def$image")); | 173 matcher.add(Filter.fromText("http://def$image")); |
174 matcher.add(Filter.fromText("http://def$script")); | 174 matcher.add(Filter.fromText("http://def$script")); |
175 matcher.add(Filter.fromText("http://def$~image,~script,~document")); | 175 matcher.add(Filter.fromText("http://def$~image,~script,~media")); |
176 matcher.add(Filter.fromText("http://fed$third-party")); | 176 matcher.add(Filter.fromText("http://fed$third-party")); |
177 matcher.add(Filter.fromText("http://fed$~third-party,~script")); | 177 matcher.add(Filter.fromText("http://fed$~third-party,~script")); |
178 | 178 |
179 cacheCheck(matcher, "http://abc", "IMAGE", null, false, "abc$image"); | 179 cacheCheck(matcher, "http://abc", "IMAGE", null, false, "abc$image"); |
180 cacheCheck(matcher, "http://abc", "SCRIPT", null, false, "abc$script"); | 180 cacheCheck(matcher, "http://abc", "SCRIPT", null, false, "abc$script"); |
181 cacheCheck(matcher, "http://abc", "OTHER", null, false, "abc$~image,~script,
~document"); | 181 cacheCheck(matcher, "http://abc", "OTHER", null, false, "abc$~image,~script,
~media"); |
182 cacheCheck(matcher, "http://cba", "IMAGE", null, false, "cba$~third-party,~s
cript"); | 182 cacheCheck(matcher, "http://cba", "IMAGE", null, false, "cba$~third-party,~s
cript"); |
183 cacheCheck(matcher, "http://cba", "IMAGE", null, true, "cba$third-party"); | 183 cacheCheck(matcher, "http://cba", "IMAGE", null, true, "cba$third-party"); |
184 cacheCheck(matcher, "http://def", "IMAGE", null, false, "http://def$image"); | 184 cacheCheck(matcher, "http://def", "IMAGE", null, false, "http://def$image"); |
185 cacheCheck(matcher, "http://def", "SCRIPT", null, false, "http://def$script"
); | 185 cacheCheck(matcher, "http://def", "SCRIPT", null, false, "http://def$script"
); |
186 cacheCheck(matcher, "http://def", "OTHER", null, false, "http://def$~image,~
script,~document"); | 186 cacheCheck(matcher, "http://def", "OTHER", null, false, "http://def$~image,~
script,~media"); |
187 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p
arty,~script"); | 187 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"); | 188 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par
ty"); |
189 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, false, "cba$~third-p
arty,~script"); | 189 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-part
y,~script"); |
190 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, true, "cba$third-par
ty"); | 190 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party"
); |
191 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); | 191 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); |
192 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, false, "http:
//fed$~third-party,~script"); | 192 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, false, "http://f
ed$~third-party,~script"); |
193 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, true, "http:/
/fed$third-party"); | 193 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"); | 194 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http://
def$script"); |
195 }); | 195 }); |
196 })(); | 196 })(); |
OLD | NEW |