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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29909555: Issue 7046 - Defer caching of domain maps (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Do not cache value for generic filters Created Oct. 14, 2018, 12:26 a.m.
Right Patch Set: Change shouldCacheDomain function to cacheDomain property Created Oct. 16, 2018, 6 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text= @@bla$~script,~other,donottrack", "reason=filter_unknown_option"]); 338 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text= @@bla$~script,~other,donottrack", "reason=filter_unknown_option"]);
339 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text =@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]); 339 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text =@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]);
340 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac k", "reason=filter_unknown_option"]); 340 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac k", "reason=filter_unknown_option"]);
341 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea son=filter_unknown_option"]); 341 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea son=filter_unknown_option"]);
342 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f oobar", "reason=filter_unknown_option"]); 342 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f oobar", "reason=filter_unknown_option"]);
343 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar, image", "reason=filter_unknown_option"]); 343 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar, image", "reason=filter_unknown_option"]);
344 344
345 compareFilter(test, "bla$csp", ["type=invalid", "text=bla$csp", "reason=filter _invalid_csp"]); 345 compareFilter(test, "bla$csp", ["type=invalid", "text=bla$csp", "reason=filter _invalid_csp"]);
346 compareFilter(test, "bla$csp=", ["type=invalid", "text=bla$csp=", "reason=filt er_invalid_csp"]); 346 compareFilter(test, "bla$csp=", ["type=invalid", "text=bla$csp=", "reason=filt er_invalid_csp"]);
347
348 // Blank CSP values are allowed for whitelist filters.
349 compareFilter(test, "@@bla$csp", ["type=whitelist", "text=@@bla$csp", "regexp= bla", "contentType=" + t.CSP]);
350 compareFilter(test, "@@bla$csp=", ["type=whitelist", "text=@@bla$csp=", "regex p=bla", "contentType=" + t.CSP]);
351
347 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor t-uri", "reason=filter_invalid_csp"]); 352 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor t-uri", "reason=filter_invalid_csp"]);
348 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs p=foo,csp=report-to", "reason=filter_invalid_csp"]); 353 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs p=foo,csp=report-to", "reason=filter_invalid_csp"]);
349 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]); 354 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]);
350 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]); 355 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]);
351 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]); 356 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]);
352 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); 357 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]);
353 358
354 test.done(); 359 test.done();
355 }; 360 };
356 361
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 test.equal( 603 test.equal(
599 filterStrip.rewriteUrl("http://example.com/?tag"), 604 filterStrip.rewriteUrl("http://example.com/?tag"),
600 "http://example.com/?" 605 "http://example.com/?"
601 ); 606 );
602 607
603 test.done(); 608 test.done();
604 }; 609 };
605 610
606 exports.testDomainMapDeduplication = function(test) 611 exports.testDomainMapDeduplication = function(test)
607 { 612 {
608 // Make sure the generated domain map is cached on first access. 613 let filter1 = Filter.fromText("foo$domain=blocking.example.com");
609 ActiveFilter.prototype._domainsAccessCacheThreshold = 0; 614 let filter2 = Filter.fromText("bar$domain=blocking.example.com");
610 615 let filter3 = Filter.fromText("elemhide.example.com##.foo");
611 let filter1 = Filter.fromText("example.com##.foo"); 616 let filter4 = Filter.fromText("elemhide.example.com##.bar");
612 let filter2 = Filter.fromText("example.com##.bar");
613 617
614 // This compares the references to make sure that both refer to the same 618 // This compares the references to make sure that both refer to the same
615 // object (#6815). 619 // object (#6815).
616 test.equal(filter1.domains, filter2.domains); 620 test.equal(filter1.domains, filter2.domains);
617 621
618 let filter3 = Filter.fromText("www.example.com##.bar"); 622 // For element hiding filters, the value of the property is cached internally
619 623 // only on second access.
620 test.notEqual(filter2.domains, filter3.domains); 624 test.notEqual(filter3.domains, filter4.domains);
621 625 test.equal(filter3.domains, filter4.domains);
622 test.done(); 626
623 }; 627 let filter5 = Filter.fromText("bar$domain=www.example.com");
628 let filter6 = Filter.fromText("www.example.com##.bar");
629
630 test.notEqual(filter2.domains, filter5.domains);
631
632 // Check twice for element hiding filters to make sure the internal cached
633 // values are also not equal.
634 test.notEqual(filter4.domains, filter6.domains);
635 test.notEqual(filter4.domains, filter6.domains);
636
637 test.done();
638 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld