OLD | NEW |
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 Loading... |
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 Loading... |
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 }; |
OLD | NEW |