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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29876561: Issue 6931 - Allow content filters for localhost (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Sept. 6, 2018, 10:26 a.m.
Right Patch Set: Use includes Created Sept. 10, 2018, 5:56 p.m.
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/filterClasses.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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 compareFilter( 254 compareFilter(
255 test, filterText, [ 255 test, filterText, [
256 "type=invalid", "text=" + filterText, 256 "type=invalid", "text=" + filterText,
257 "reason=filter_elemhideemulation_nodomain" 257 "reason=filter_elemhideemulation_nodomain"
258 ] 258 ]
259 ); 259 );
260 } 260 }
261 checkElemHideEmulationFilterInvalid(""); 261 checkElemHideEmulationFilterInvalid("");
262 checkElemHideEmulationFilterInvalid("~foo.com"); 262 checkElemHideEmulationFilterInvalid("~foo.com");
263 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com"); 263 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com");
264 checkElemHideEmulationFilterInvalid("foo");
265 checkElemHideEmulationFilterInvalid("~foo.com,bar");
264 266
265 test.done(); 267 test.done();
266 }; 268 };
267 269
268 exports.testFiltersWithState = function(test) 270 exports.testFiltersWithState = function(test)
269 { 271 {
270 compareFilter(test, "blabla", ["type=filterlist", "text=blabla", "regexp=blabl a"]); 272 compareFilter(test, "blabla", ["type=filterlist", "text=blabla", "regexp=blabl a"]);
271 compareFilter( 273 compareFilter(
272 test, "blabla_default", ["type=filterlist", "text=blabla_default", "regexp=b labla_default"], 274 test, "blabla_default", ["type=filterlist", "text=blabla_default", "regexp=b labla_default"],
273 filter => 275 filter =>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 compareFilter(test, "Foo,bAr#@#ddd", ["type=elemhideexception", "text=Foo,bAr# @#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo"]); 374 compareFilter(test, "Foo,bAr#@#ddd", ["type=elemhideexception", "text=Foo,bAr# @#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo"]);
373 compareFilter(test, "foo,~baR#@#ddd", ["type=elemhideexception", "text=foo,~ba R#@#ddd", "selectorDomains=foo", "selector=ddd", "domains=foo|~bar"]); 375 compareFilter(test, "foo,~baR#@#ddd", ["type=elemhideexception", "text=foo,~ba R#@#ddd", "selectorDomains=foo", "selector=ddd", "domains=foo|~bar"]);
374 compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo ,~baz,bar#@#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo|~b az"]); 376 compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo ,~baz,bar#@#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo|~b az"]);
375 377
376 test.done(); 378 test.done();
377 }; 379 };
378 380
379 exports.testElemHideEmulationFilters = function(test) 381 exports.testElemHideEmulationFilters = function(test)
380 { 382 {
381 // Check valid domain combinations 383 // Check valid domain combinations
382 compareFilter(test, "foo#?#:-abp-properties(abc)", ["type=elemhideemulation", "text=foo#?#:-abp-properties(abc)", "selectorDomains=foo", "selector=:-abp-prope rties(abc)", "domains=foo"]);
383 compareFilter(test, "foo,~bar#?#:-abp-properties(abc)", ["type=elemhideemulati on", "text=foo,~bar#?#:-abp-properties(abc)", "selectorDomains=foo", "selector=: -abp-properties(abc)", "domains=foo|~bar"]);
384 compareFilter(test, "~foo,bar#?#:-abp-properties(abc)", ["type=elemhideemulati on", "text=~foo,bar#?#:-abp-properties(abc)", "selectorDomains=bar", "selector=: -abp-properties(abc)", "domains=bar|~foo"]);
385 compareFilter(test, "fOO.cOm#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=fOO.cOm#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector =:-abp-properties(abc)", "domains=foo.com"]); 384 compareFilter(test, "fOO.cOm#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=fOO.cOm#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector =:-abp-properties(abc)", "domains=foo.com"]);
386 compareFilter(test, "Foo.com,~bAr.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=Foo.com,~bAr.com#?#:-abp-properties(abc)", "selectorDomains=f oo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar.com"]); 385 compareFilter(test, "Foo.com,~bAr.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=Foo.com,~bAr.com#?#:-abp-properties(abc)", "selectorDomains=f oo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar.com"]);
387 compareFilter(test, "foo.com,~baR#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~baR#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar"]); 386 compareFilter(test, "foo.com,~baR#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~baR#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar"]);
388 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "selectorDomains=b ar.com", "selector=:-abp-properties(abc)", "domains=bar.com|~foo.com"]); 387 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "selectorDomains=b ar.com", "selector=:-abp-properties(abc)", "domains=bar.com|~foo.com"]);
389 388
390 // Check some special cases 389 // Check some special cases
391 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]); 390 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]);
392 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomains=foo.com", "selector=abc", "domains=foo.com"]); 391 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomains=foo.com", "selector=abc", "domains=foo.com"]);
393 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomains=foo.com", "selector=:-abp-f oobar(abc)", "domains=foo.com"]); 392 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomains=foo.com", "selector=:-abp-f oobar(abc)", "domains=foo.com"]);
394 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomains=foo .com", "selector=aaa :-abp-properties(abc) bbb", "domains=foo.com"]); 393 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomains=foo .com", "selector=aaa :-abp-properties(abc) bbb", "domains=foo.com"]);
395 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "selectorDomains=foo.com", "selector=:-abp-properties(|backgro und-image: url(data:*))", "domains=foo.com"]); 394 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "selectorDomains=foo.com", "selector=:-abp-properties(|backgro und-image: url(data:*))", "domains=foo.com"]);
395
396 // Support element hiding emulation filters for localhost (#6931).
397 compareFilter(test, "localhost#?#:-abp-properties(abc)", ["type=elemhideemulat ion", "text=localhost#?#:-abp-properties(abc)", "selectorDomains=localhost", "se lector=:-abp-properties(abc)", "domains=localhost"]);
398 compareFilter(test, "localhost,~www.localhost#?#:-abp-properties(abc)", ["type =elemhideemulation", "text=localhost,~www.localhost#?#:-abp-properties(abc)", "s electorDomains=localhost", "selector=:-abp-properties(abc)", "domains=localhost| ~www.localhost"]);
399 compareFilter(test, "~www.localhost,localhost#?#:-abp-properties(abc)", ["type =elemhideemulation", "text=~www.localhost,localhost#?#:-abp-properties(abc)", "s electorDomains=localhost", "selector=:-abp-properties(abc)", "domains=localhost| ~www.localhost"]);
396 400
397 test.done(); 401 test.done();
398 }; 402 };
399 403
400 exports.testEmptyElemHideDomains = function(test) 404 exports.testEmptyElemHideDomains = function(test)
401 { 405 {
402 let emptyDomainFilters = [ 406 let emptyDomainFilters = [
403 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector", 407 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector",
404 ",foo.com##selector", "foo.com,~##selector", 408 ",foo.com##selector", "foo.com,~##selector",
405 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector" 409 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // This compares the references to make sure that both refer to the same 611 // This compares the references to make sure that both refer to the same
608 // object (#6815). 612 // object (#6815).
609 test.equal(filter1.domains, filter2.domains); 613 test.equal(filter1.domains, filter2.domains);
610 614
611 let filter3 = Filter.fromText("www.example.com##.bar"); 615 let filter3 = Filter.fromText("www.example.com##.bar");
612 616
613 test.notEqual(filter2.domains, filter3.domains); 617 test.notEqual(filter2.domains, filter3.domains);
614 618
615 test.done(); 619 test.done();
616 }; 620 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld