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

Delta Between Two Patch Sets: test/matcher.js

Issue 30018560: Issue 7312 - Ignore lone pure generic filters for specific-only queries (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Feb. 26, 2019, 11:48 a.m.
Right Patch Set: Add more tests Created Feb. 26, 2019, noon
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/matcher.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo .com", false, null, false, "@@||foo.com^"); 239 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo .com", false, null, false, "@@||foo.com^");
240 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/foo", "IMAGE", "foo .com", false, null, false, null, "@@||foo.com^"); 240 checkMatch(test, ["/bar", "@@||foo.com^"], "http://foo.com/foo", "IMAGE", "foo .com", false, null, false, null, "@@||foo.com^");
241 checkMatch(test, ["||foo.com^$popup"], "http://foo.com/bar", "POPUP", "foo.com ", false, null, false, "||foo.com^$popup"); 241 checkMatch(test, ["||foo.com^$popup"], "http://foo.com/bar", "POPUP", "foo.com ", false, null, false, "||foo.com^$popup");
242 checkMatch(test, ["@@||foo.com^$popup"], "http://foo.com/bar", "POPUP", "foo.c om", false, null, false, null, "@@||foo.com^$popup"); 242 checkMatch(test, ["@@||foo.com^$popup"], "http://foo.com/bar", "POPUP", "foo.c om", false, null, false, null, "@@||foo.com^$popup");
243 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"); 243 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");
244 checkMatch(test, ["||foo.com^$csp=script-src 'none'"], "http://foo.com/bar", " CSP", "foo.com", false, null, false, "||foo.com^$csp=script-src 'none'"); 244 checkMatch(test, ["||foo.com^$csp=script-src 'none'"], "http://foo.com/bar", " CSP", "foo.com", false, null, false, "||foo.com^$csp=script-src 'none'");
245 checkMatch(test, ["@@||foo.com^$csp"], "http://foo.com/bar", "CSP", "foo.com", false, null, false, null, "@@||foo.com^$csp"); 245 checkMatch(test, ["@@||foo.com^$csp"], "http://foo.com/bar", "CSP", "foo.com", false, null, false, null, "@@||foo.com^$csp");
246 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'"); 246 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'");
247 247
248 // See #7312. 248 // See #7312.
249 checkMatch(test, ["^foo/bar/$script"], "http://foo/bar/", "SCRIPT", "example.c om", true, null, true, null); 249 checkMatch(test, ["^foo/bar/$script"], "http://foo/bar/", "SCRIPT", "example.c om", true, null, true, null);
Manish Jethani 2019/02/26 11:54:24 There's a domain-specific blocking filter and a ge
250 checkMatch(test, ["^foo/bar/$script"], "http://foo/bar/", "SCRIPT", "example.c om", true, null, false, "^foo/bar/$script");
250 checkMatch(test, ["^foo/bar/$script,domain=example.com", "@@^foo/bar/$script"] , "http://foo/bar/", "SCRIPT", "example.com", true, null, true, "@@^foo/bar/$scr ipt", "^foo/bar/$script,domain=example.com"); 251 checkMatch(test, ["^foo/bar/$script,domain=example.com", "@@^foo/bar/$script"] , "http://foo/bar/", "SCRIPT", "example.com", true, null, true, "@@^foo/bar/$scr ipt", "^foo/bar/$script,domain=example.com");
252 checkMatch(test, ["@@^foo/bar/$script", "^foo/bar/$script,domain=example.com"] , "http://foo/bar/", "SCRIPT", "example.com", true, null, true, "@@^foo/bar/$scr ipt", "^foo/bar/$script,domain=example.com");
253 checkMatch(test, ["@@^foo/bar/$script", "^foo/bar/$script,domain=example.com"] , "http://foo/bar/", "SCRIPT", "example.com", true, null, false, "@@^foo/bar/$sc ript");
251 254
252 test.done(); 255 test.done();
253 }; 256 };
254 257
255 exports.testFilterSearch = function(test) 258 exports.testFilterSearch = function(test)
256 { 259 {
257 // Start with three filters: foo, bar, and @@foo 260 // Start with three filters: foo, bar, and @@foo
258 let filters = ["foo", "bar", "@@foo"]; 261 let filters = ["foo", "bar", "@@foo"];
259 262
260 checkSearch(test, filters, "http://example.com/foo", "IMAGE", "example.com", 263 checkSearch(test, filters, "http://example.com/foo", "IMAGE", "example.com",
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 matcher.remove(Filter.fromText("/example/*$~third-party")); 441 matcher.remove(Filter.fromText("/example/*$~third-party"));
439 442
440 test.equal(matcher._blacklist._filterDomainMapsByKeyword.size, 0); 443 test.equal(matcher._blacklist._filterDomainMapsByKeyword.size, 0);
441 444
442 test.ok(!matcher.matchesAny("https://example.com/example/image.jpg", 445 test.ok(!matcher.matchesAny("https://example.com/example/image.jpg",
443 RegExpFilter.typeMap.IMAGE, "example.com", 446 RegExpFilter.typeMap.IMAGE, "example.com",
444 false)); 447 false));
445 448
446 test.done(); 449 test.done();
447 }; 450 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld