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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29863644: Issue 6870 - Remove support for legacy :-abp-properties() syntax (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Add check for legacy syntax and return of InvalidFilter Created Aug. 25, 2018, 5:29 a.m.
Right Patch Set: Put filter return back Created Aug. 27, 2018, 9:48 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text =@@bla$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]); 332 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text =@@bla$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
333 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide" , "regexp=bla", "contentType=" + t.ELEMHIDE]); 333 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide" , "regexp=bla", "contentType=" + t.ELEMHIDE]);
334 334
335 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text= @@bla$~script,~other,donottrack", "reason=filter_unknown_option"]); 335 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text= @@bla$~script,~other,donottrack", "reason=filter_unknown_option"]);
336 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text =@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]); 336 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text =@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]);
337 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac k", "reason=filter_unknown_option"]); 337 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac k", "reason=filter_unknown_option"]);
338 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea son=filter_unknown_option"]); 338 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea son=filter_unknown_option"]);
339 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f oobar", "reason=filter_unknown_option"]); 339 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f oobar", "reason=filter_unknown_option"]);
340 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar, image", "reason=filter_unknown_option"]); 340 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar, image", "reason=filter_unknown_option"]);
341 341
342 compareFilter(test, "bla$csp", ["type=invalid", "text=bla$csp", "reason=filter _invalid_csp"]);
343 compareFilter(test, "bla$csp=", ["type=invalid", "text=bla$csp=", "reason=filt er_invalid_csp"]);
342 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor t-uri", "reason=filter_invalid_csp"]); 344 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor t-uri", "reason=filter_invalid_csp"]);
343 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs p=foo,csp=report-to", "reason=filter_invalid_csp"]); 345 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs p=foo,csp=report-to", "reason=filter_invalid_csp"]);
344 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]); 346 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]);
345 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]); 347 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]);
346 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]); 348 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]);
347 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); 349 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]);
348 350
349 test.done(); 351 test.done();
350 }; 352 };
351 353
(...skipping 28 matching lines...) Expand all
380 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"]); 382 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"]);
381 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"]); 383 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"]);
382 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"]); 384 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"]);
383 385
384 // Check some special cases 386 // Check some special cases
385 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]); 387 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]);
386 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomains=foo.com", "selector=abc", "domains=foo.com"]); 388 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomains=foo.com", "selector=abc", "domains=foo.com"]);
387 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"]); 389 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"]);
388 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"]); 390 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"]);
389 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"]); 391 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"]);
390
391 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) .
392 compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide" , "text=foo.com##[-abp-properties-bogus='abc']", "selectorDomains=foo.com", "sel ector=[-abp-properties-bogus='abc']", "domains=foo.com"]);
393 392
394 test.done(); 393 test.done();
395 }; 394 };
396 395
397 exports.testEmptyElemHideDomains = function(test) 396 exports.testEmptyElemHideDomains = function(test)
398 { 397 {
399 let emptyDomainFilters = [ 398 let emptyDomainFilters = [
400 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector", 399 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector",
401 ",foo.com##selector", "foo.com,~##selector", 400 ",foo.com##selector", "foo.com,~##selector",
402 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector" 401 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 // This compares the references to make sure that both refer to the same 603 // This compares the references to make sure that both refer to the same
605 // object (#6815). 604 // object (#6815).
606 test.equal(filter1.domains, filter2.domains); 605 test.equal(filter1.domains, filter2.domains);
607 606
608 let filter3 = Filter.fromText("www.example.com##.bar"); 607 let filter3 = Filter.fromText("www.example.com##.bar");
609 608
610 test.notEqual(filter2.domains, filter3.domains); 609 test.notEqual(filter2.domains, filter3.domains);
611 610
612 test.done(); 611 test.done();
613 }; 612 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld