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

Side by Side Diff: test/matcher.js

Issue 30011555: Issue 7303 - Deprecate the use of String.prototype.substr() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 19, 2019, 4:47 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/_common.js ('k') | test/signatures.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 result = result.text; 81 result = result.text;
82 82
83 test.equal(result, expected, "combinedMatch(" + location + ", " + contentTyp e + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-spe cificOnly") + ") with:\n" + filters.join("\n")); 83 test.equal(result, expected, "combinedMatch(" + location + ", " + contentTyp e + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-spe cificOnly") + ") with:\n" + filters.join("\n"));
84 84
85 // Generic whitelisting rules can match for specificOnly searches, so we 85 // Generic whitelisting rules can match for specificOnly searches, so we
86 // can't easily know which rule will match for these whitelisting tests 86 // can't easily know which rule will match for these whitelisting tests
87 if (specificOnly) 87 if (specificOnly)
88 continue; 88 continue;
89 89
90 // For next run: add whitelisting filters for filters that aren't already 90 // For next run: add whitelisting filters for filters that aren't already
91 filters = filters.map(text => text.substr(0, 2) == "@@" ? text : "@@" + text ); 91 filters = filters.map(text => text.substring(0, 2) == "@@" ? text : "@@" + t ext);
92 if (expected && expected.substr(0, 2) != "@@") 92 if (expected && expected.substring(0, 2) != "@@")
93 expected = "@@" + expected; 93 expected = "@@" + expected;
94 } 94 }
95 } 95 }
96 96
97 function checkSearch(test, filters, location, contentType, docDomain, 97 function checkSearch(test, filters, location, contentType, docDomain,
98 thirdParty, sitekey, specificOnly, filterType, 98 thirdParty, sitekey, specificOnly, filterType,
99 expected) 99 expected)
100 { 100 {
101 let matcher = new CombinedMatcher(); 101 let matcher = new CombinedMatcher();
102 for (let filter of filters) 102 for (let filter of filters)
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 matcher.remove(Filter.fromText("/example/*$~third-party")); 434 matcher.remove(Filter.fromText("/example/*$~third-party"));
435 435
436 test.equal(matcher._blacklist._filterDomainMapsByKeyword.size, 0); 436 test.equal(matcher._blacklist._filterDomainMapsByKeyword.size, 0);
437 437
438 test.ok(!matcher.matchesAny("https://example.com/example/image.jpg", 438 test.ok(!matcher.matchesAny("https://example.com/example/image.jpg",
439 RegExpFilter.typeMap.IMAGE, "example.com", 439 RegExpFilter.typeMap.IMAGE, "example.com",
440 false)); 440 false));
441 441
442 test.done(); 442 test.done();
443 }; 443 };
OLDNEW
« no previous file with comments | « test/_common.js ('k') | test/signatures.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld