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

Side by Side Diff: test/matcher.js

Issue 29933592: Issue 7089 - Match filters by type for non-default types (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 1, 2018, 11:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/matcher.js ('K') | « lib/matcher.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 checkMatch(test, ["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo .com|~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, false, null) ; 196 checkMatch(test, ["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo .com|~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, false, null) ;
197 checkMatch(test, ["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo .com|~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, null, false, "ccc$ domain=~foo.com|~bar.com"); 197 checkMatch(test, ["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo .com|~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, null, false, "ccc$ domain=~foo.com|~bar.com");
198 checkMatch(test, ["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "foo.com", false, "foo-publickey", false, "abc$sitekey =foo-publickey"); 198 checkMatch(test, ["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "foo.com", false, "foo-publickey", false, "abc$sitekey =foo-publickey");
199 checkMatch(test, ["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, "abc$sitekey =bar-publickey"); 199 checkMatch(test, ["abc$sitekey=foo-publickey", "abc$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, "abc$sitekey =bar-publickey");
200 checkMatch(test, ["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, null); 200 checkMatch(test, ["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "bar.com", false, "bar-publickey", false, null);
201 checkMatch(test, ["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "baz.com", false, null, false, null); 201 checkMatch(test, ["abc$sitekey=foo-publickey", "cba$sitekey=bar-publickey"], " http://abc/def", "IMAGE", "baz.com", false, null, false, null);
202 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "foo-p ublickey", false, "abc$sitekey=foo-publickey,domain=foo.com"); 202 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "foo-p ublickey", false, "abc$sitekey=foo-publickey,domain=foo.com");
203 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "bar-p ublickey", false, null); 203 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "bar-p ublickey", false, null);
204 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "foo-p ublickey", false, null); 204 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "foo-p ublickey", false, null);
205 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "bar-p ublickey", false, "abc$sitekey=bar-publickey,domain=bar.com"); 205 checkMatch(test, ["abc$sitekey=foo-publickey,domain=foo.com", "abc$sitekey=bar -publickey,domain=bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "bar-p ublickey", false, "abc$sitekey=bar-publickey,domain=bar.com");
206 checkMatch(test, ["@@foo.com$document"], "http://foo.com/bar", "DOCUMENT", "fo o.com", false, null, false, "@@foo.com$document");
Manish Jethani 2018/11/02 00:33:47 Tests for $document and $elemhide
207 checkMatch(test, ["@@foo.com$elemhide"], "http://foo.com/bar", "ELEMHIDE", "fo o.com", false, null, false, "@@foo.com$elemhide");
206 checkMatch(test, ["@@foo.com$generichide"], "http://foo.com/bar", "GENERICHIDE ", "foo.com", false, null, false, "@@foo.com$generichide"); 208 checkMatch(test, ["@@foo.com$generichide"], "http://foo.com/bar", "GENERICHIDE ", "foo.com", false, null, false, "@@foo.com$generichide");
207 checkMatch(test, ["@@foo.com$genericblock"], "http://foo.com/bar", "GENERICBLO CK", "foo.com", false, null, false, "@@foo.com$genericblock"); 209 checkMatch(test, ["@@foo.com$genericblock"], "http://foo.com/bar", "GENERICBLO CK", "foo.com", false, null, false, "@@foo.com$genericblock");
210 checkMatch(test, ["@@bar.com$document"], "http://foo.com/bar", "DOCUMENT", "fo o.com", false, null, false, null);
211 checkMatch(test, ["@@bar.com$elemhide"], "http://foo.com/bar", "ELEMHIDE", "fo o.com", false, null, false, null);
208 checkMatch(test, ["@@bar.com$generichide"], "http://foo.com/bar", "GENERICHIDE ", "foo.com", false, null, false, null); 212 checkMatch(test, ["@@bar.com$generichide"], "http://foo.com/bar", "GENERICHIDE ", "foo.com", false, null, false, null);
209 checkMatch(test, ["@@bar.com$genericblock"], "http://foo.com/bar", "GENERICBLO CK", "foo.com", false, null, false, null); 213 checkMatch(test, ["@@bar.com$genericblock"], "http://foo.com/bar", "GENERICBLO CK", "foo.com", false, null, false, null);
210 checkMatch(test, ["/bar"], "http://foo.com/bar", "IMAGE", "foo.com", false, nu ll, true, null); 214 checkMatch(test, ["/bar"], "http://foo.com/bar", "IMAGE", "foo.com", false, nu ll, true, null);
211 checkMatch(test, ["/bar$domain=foo.com"], "http://foo.com/bar", "IMAGE", "foo. com", false, null, true, "/bar$domain=foo.com"); 215 checkMatch(test, ["/bar$domain=foo.com"], "http://foo.com/bar", "IMAGE", "foo. com", false, null, true, "/bar$domain=foo.com");
212 checkMatch(test, ["@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo.com", f alse, null, false, null, "@@||foo.com^"); 216 checkMatch(test, ["@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo.com", f alse, null, false, null, "@@||foo.com^");
213 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo .com", false, null, false, "@@||foo.com^"); 217 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo .com", false, null, false, "@@||foo.com^");
214 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/foo", "IMAGE", "foo .com", false, null, false, null, "@@||foo.com^"); 218 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/foo", "IMAGE", "foo .com", false, null, false, null, "@@||foo.com^");
219 checkMatch(test, ["||foo.com^$popup"], "http://foo.com/bar", "POPUP", "foo.com ", false, null, false, "||foo.com^$popup");
Manish Jethani 2018/11/02 00:33:47 Tests for $popup and $csp
220 checkMatch(test, ["@@||foo.com^$popup"], "http://foo.com/bar", "POPUP", "foo.c om", false, null, false, null, "@@||foo.com^$popup");
221 checkMatch(test, ["||foo.com^$popup", "@@||foo.com^$popup"], "http://foo.com/b ar", "POPUP", "foo.com", false, null, false, "@@||foo.com^$popup", "||foo.com^$p opup");
222 checkMatch(test, ["||foo.com^$csp=script-src 'none'"], "http://foo.com/bar", " CSP", "foo.com", false, null, false, "||foo.com^$csp=script-src 'none'");
223 checkMatch(test, ["@@||foo.com^$csp"], "http://foo.com/bar", "CSP", "foo.com", false, null, false, null, "@@||foo.com^$csp");
224 checkMatch(test, ["||foo.com^$csp=script-src 'none'", "@@||foo.com^$csp"], "ht tp://foo.com/bar", "CSP", "foo.com", false, null, false, "@@||foo.com^$csp", "|| foo.com^$csp=script-src 'none'");
215 225
216 test.done(); 226 test.done();
217 }; 227 };
218 228
219 exports.testResultCacheChecks = function(test) 229 exports.testResultCacheChecks = function(test)
220 { 230 {
221 let matcher = new CombinedMatcher(); 231 let matcher = new CombinedMatcher();
222 matcher.add(Filter.fromText("abc$image")); 232 matcher.add(Filter.fromText("abc$image"));
223 matcher.add(Filter.fromText("abc$script")); 233 matcher.add(Filter.fromText("abc$script"));
224 matcher.add(Filter.fromText("abc$~image,~script,~media,~ping")); 234 matcher.add(Filter.fromText("abc$~image,~script,~media,~ping"));
(...skipping 17 matching lines...) Expand all
242 cacheCheck(test, matcher, "http://fed", "IMAGE", null, true, "http://fed$third -party"); 252 cacheCheck(test, matcher, "http://fed", "IMAGE", null, true, "http://fed$third -party");
243 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third- party,~script"); 253 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third- party,~script");
244 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-pa rty"); 254 cacheCheck(test, matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-pa rty");
245 cacheCheck(test, matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script "); 255 cacheCheck(test, matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script ");
246 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, false, "http ://fed$~third-party,~script"); 256 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, false, "http ://fed$~third-party,~script");
247 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, true, "http: //fed$third-party"); 257 cacheCheck(test, matcher, "http://def?http://fed", "MEDIA", null, true, "http: //fed$third-party");
248 cacheCheck(test, matcher, "http://def?http://fed", "SCRIPT", null, false, "htt p://def$script"); 258 cacheCheck(test, matcher, "http://def?http://fed", "SCRIPT", null, false, "htt p://def$script");
249 259
250 test.done(); 260 test.done();
251 }; 261 };
OLDNEW
« lib/matcher.js ('K') | « lib/matcher.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld