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

Side by Side Diff: test/matcher.js

Issue 30018560: Issue 7312 - Ignore lone pure generic filters for specific-only queries (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 26, 2019, 11:48 a.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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 checkMatch(test, ["@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo.com", f alse, null, false, null, "@@||foo.com^"); 238 checkMatch(test, ["@@||foo.com^"], "http://foo.com/bar", "IMAGE", "foo.com", f alse, null, false, null, "@@||foo.com^");
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.
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,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
248 test.done(); 252 test.done();
249 }; 253 };
250 254
251 exports.testFilterSearch = function(test) 255 exports.testFilterSearch = function(test)
252 { 256 {
253 // Start with three filters: foo, bar, and @@foo 257 // Start with three filters: foo, bar, and @@foo
254 let filters = ["foo", "bar", "@@foo"]; 258 let filters = ["foo", "bar", "@@foo"];
255 259
256 checkSearch(test, filters, "http://example.com/foo", "IMAGE", "example.com", 260 checkSearch(test, filters, "http://example.com/foo", "IMAGE", "example.com",
257 false, null, false, "all", 261 false, null, false, "all",
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 matcher.remove(Filter.fromText("/example/*$~third-party")); 438 matcher.remove(Filter.fromText("/example/*$~third-party"));
435 439
436 test.equal(matcher._blacklist._filterDomainMapsByKeyword.size, 0); 440 test.equal(matcher._blacklist._filterDomainMapsByKeyword.size, 0);
437 441
438 test.ok(!matcher.matchesAny("https://example.com/example/image.jpg", 442 test.ok(!matcher.matchesAny("https://example.com/example/image.jpg",
439 RegExpFilter.typeMap.IMAGE, "example.com", 443 RegExpFilter.typeMap.IMAGE, "example.com",
440 false)); 444 false));
441 445
442 test.done(); 446 test.done();
443 }; 447 };
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