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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29841558: Issue 6815 - Avoid multiple copies of domain maps (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebase Created July 30, 2018, 4:35 p.m.
Right Patch Set: Add tests Created July 30, 2018, 5:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
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
(no file at all)
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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 "foo$bar$csp=ba r"); 536 "foo$bar$csp=ba r");
537 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "), 537 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "),
538 "f$o$o$csp=f o o"); 538 "f$o$o$csp=f o o");
539 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1= 1&$2=2&$3=3"), 539 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1= 1&$2=2&$3=3"),
540 "/foo$/$csp=script-src http://example.com/?$1=1&$2=2&$3=3"); 540 "/foo$/$csp=script-src http://example.com/?$1=1&$2=2&$3=3");
541 test.equal(Filter.normalize("||content.server.com/files/*.php$rewrite= $1"), 541 test.equal(Filter.normalize("||content.server.com/files/*.php$rewrite= $1"),
542 "||content.server.com/files/*.php$rewrite=$1"); 542 "||content.server.com/files/*.php$rewrite=$1");
543 test.done(); 543 test.done();
544 }; 544 };
545 545
546
547 exports.testFilterRewriteOption = function(test) 546 exports.testFilterRewriteOption = function(test)
548 { 547 {
549 let text = "/(content\\.server\\/file\\/.*\\.txt)\\?.*$/$rewrite=$1"; 548 let text = "/(content\\.server\\/file\\/.*\\.txt)\\?.*$/$rewrite=$1";
550 549
551 let filter = Filter.fromText(text); 550 let filter = Filter.fromText(text);
552 551
553 test.equal(filter.rewrite, "$1"); 552 test.equal(filter.rewrite, "$1");
554 // no rewrite occured: didn't match. 553 // no rewrite occured: didn't match.
555 test.equal(filter.rewriteUrl("foo"), "foo"); 554 test.equal(filter.rewriteUrl("foo"), "foo");
556 // rewrite occured: matched. 555 // rewrite occured: matched.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 let filterStrip = Filter.fromText(rewriteStrip); 595 let filterStrip = Filter.fromText(rewriteStrip);
597 596
598 test.equal(filterStrip.rewrite, ""); 597 test.equal(filterStrip.rewrite, "");
599 test.equal( 598 test.equal(
600 filterStrip.rewriteUrl("http://example.com/?tag"), 599 filterStrip.rewriteUrl("http://example.com/?tag"),
601 "http://example.com/?" 600 "http://example.com/?"
602 ); 601 );
603 602
604 test.done(); 603 test.done();
605 }; 604 };
605
606 exports.testDomainMapDeduplication = function(test)
607 {
608 let filter1 = Filter.fromText("example.com##.foo");
609 let filter2 = Filter.fromText("example.com##.bar");
610
611 // This compares the references to make sure that both refer to the same
612 // object (#6815).
613 test.equal(filter1.domains, filter2.domains);
614
615 let filter3 = Filter.fromText("www.example.com##.bar");
616
617 test.notEqual(filter2.domains, filter3.domains);
618
619 test.done();
620 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld