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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29760704: Issue 6592 - Implement $rewrite filter option (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Some comment adjustments. Created May 7, 2018, 8:11 p.m.
Right Patch Set: Just inject URL into the sandbox globals. Created May 17, 2018, 12:50 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
« lib/filterClasses.js ('K') | « test/_common.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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 let filter = Filter.fromText(text); 513 let filter = Filter.fromText(text);
514 514
515 test.equal(filter.rewrite, "$1"); 515 test.equal(filter.rewrite, "$1");
516 // no rewrite occured: didn't match. 516 // no rewrite occured: didn't match.
517 test.equal(filter.rewriteUrl("foo"), "foo"); 517 test.equal(filter.rewriteUrl("foo"), "foo");
518 // rewrite occured: matched. 518 // rewrite occured: matched.
519 test.equal(filter.rewriteUrl("http://content.server/file/foo.txt?bar"), 519 test.equal(filter.rewriteUrl("http://content.server/file/foo.txt?bar"),
520 "http://content.server/file/foo.txt"); 520 "http://content.server/file/foo.txt");
521 521
522 // checking for same origin. 522 // checking for same origin.
523 let rewriteDiffOrigin = "/content\\.server(\\/file\\/.*\\.txt)\\?.*$/$rewrite= foo.com$1"; 523 let rewriteDiffOrigin =
524 "/content\\.server(\\/file\\/.*\\.txt)\\?.*$/$rewrite=foo.com$1";
524 let filterDiffOrigin = Filter.fromText(rewriteDiffOrigin); 525 let filterDiffOrigin = Filter.fromText(rewriteDiffOrigin);
525 526
526 // no rewrite occured because of a different origin. 527 // no rewrite occured because of a different origin.
527 test.equal( 528 test.equal(
528 filterDiffOrigin.rewriteUrl("http://content.server/file/foo.txt?bar"), 529 filterDiffOrigin.rewriteUrl("http://content.server/file/foo.txt?bar"),
529 "http://content.server/file/foo.txt?bar"); 530 "http://content.server/file/foo.txt?bar"
530 531 );
531 test.done(); 532
532 }; 533 // relative path.
534 let rewriteRelative = "/(\\/file\\/.*\\.txt)\\?.*$/$rewrite=$1/disable";
535 let filterRelative = Filter.fromText(rewriteRelative);
536
537 test.equal(
538 filterRelative.rewriteUrl("http://content.server/file/foo.txt?bar"),
539 "http://content.server/file/foo.txt/disable"
540 );
541 test.equal(
542 filterRelative.rewriteUrl("http://example.com/file/foo.txt?bar"),
543 "http://example.com/file/foo.txt/disable"
544 );
545
546 test.done();
547 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld