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

Delta Between Two Patch Sets: chrome/content/tests/matcher.js

Issue 6439460933730304: Issue 616 - Add tests for $generichide and $genericblock (Closed)
Left Patch Set: Addressed The Professor's feedback! Created Oct. 2, 2015, 10:17 a.m.
Right Patch Set: Couple more tweaks Created Oct. 2, 2015, 10:37 a.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 | « chrome/content/tests/filterClasses.js ('k') | chrome/content/tests/policy.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 (function() 1 (function()
2 { 2 {
3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil terComponents}); 3 module("Filter matcher", {setup: prepareFilterComponents, teardown: restoreFil terComponents});
4 4
5 function compareKeywords(text, expected) 5 function compareKeywords(text, expected)
6 { 6 {
7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) 7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)])
8 { 8 {
9 let matcher = new Matcher(); 9 let matcher = new Matcher();
10 let result = []; 10 let result = [];
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 equal(result, expected, "combinedMatch(" + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-specif icOnly") + ") with:\n" + filters.join("\n")); 49 equal(result, expected, "combinedMatch(" + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ", " + (sitekey || "no-sitekey") + ", " + (specificOnly ? "specificOnly" : "not-specif icOnly") + ") with:\n" + filters.join("\n"));
50 50
51 // Generic whitelisting rules can match for specificOnly searches, so we 51 // Generic whitelisting rules can match for specificOnly searches, so we
52 // can't easily know which rule will match for these whitelisting tests 52 // can't easily know which rule will match for these whitelisting tests
53 if (specificOnly) 53 if (specificOnly)
54 continue; 54 continue;
55 55
56 // For next run: add whitelisting filters for filters that aren't already 56 // For next run: add whitelisting filters for filters that aren't already
57 filters = filters.map((text) => text.substr(0, 2) == "@@" ? text : "@@" + text); 57 filters = filters.map((text) => text.substr(0, 2) == "@@" ? text : "@@" + text);
58 if (expected && expected.substr(0, 2) != "@@") 58 if (expected && expected.substr(0, 2) != "@@")
59 expected = "@@" + expected; 59 expected = "@@" + expected;
60 } 60 }
61 } 61 }
62 62
63 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp ected) 63 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp ected)
64 { 64 {
65 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType], docDomain, thirdParty); 65 let result = matcher.matchesAny(location, RegExpFilter.typeMap[contentType], docDomain, thirdParty);
66 if (result) 66 if (result)
67 result = result.text; 67 result = result.text;
68 68
69 equal(result, expected, "match(" + location + ", " + contentType + ", " + do cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ") with static f ilters"); 69 equal(result, expected, "match(" + location + ", " + contentType + ", " + do cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ") with static f ilters");
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p arty,~script"); 198 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p arty,~script");
199 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par ty"); 199 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par ty");
200 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-part y,~script"); 200 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, false, "cba$~third-part y,~script");
201 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party" ); 201 cacheCheck(matcher, "http://abc_cba", "MEDIA", null, true, "cba$third-party" );
202 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); 202 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script");
203 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, false, "http://f ed$~third-party,~script"); 203 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, false, "http://f ed$~third-party,~script");
204 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, true, "http://fe d$third-party"); 204 cacheCheck(matcher, "http://def?http://fed", "MEDIA", null, true, "http://fe d$third-party");
205 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http:// def$script"); 205 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http:// def$script");
206 }); 206 });
207 })(); 207 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld