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

Side by Side Diff: chrome/content/tests/matcher.js

Issue 6612283790721024: Issue 698 - Added tests for $sitekey option (Closed)
Patch Set: Created Sept. 2, 2014, 2:03 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
OLDNEW
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 let publickeys = {
6 /*
7 -----BEGIN RSA PRIVATE KEY-----
8 MIIBOgIBAAJBANLNgMGCl6kc3QE/73/ESBsuhzCNQWApqWS1nKVWf+RjDTiF80LD
9 2TiTdQhlW9mlWsDDbttsDlEcCmPVz6H3OUMCAwEAAQJBALo/ZSYTqsl4ve7vvTwG
10 gKq7ZihIdV1wEcDwELGoBiESo87zl//7q2q9/7VE3dB3Qp6uZMLtxVvXzF8bh074
11 OuECIQDzzenwgPVMtg6OjMtZBAB95oKaTzd+x/8JienKW4edEQIhAN1Y+vlB/waB
12 miRjGMrsOQDHhUbxyL6NXaPfxYlosYETAiBg0M9qgztl+BH1x7FkqvMrC+OnNXf7
13 L552gj7F7ez/kQIgOBNhyaHxlNlijpNYZZhAvLTPS/DXFYdE0M5RAgW26mcCIDrR
14 fi2xaM2NqJQCmyshtNmDxW2FCrtrQn1n0211WCEe
15 -----END RSA PRIVATE KEY-----
16 */
17 foo: "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANLNgMGCl6kc3QE/73/ESBsuhzCNQWApqWS1nK VWf+RjDTiF80LD2TiTdQhlW9mlWsDDbttsDlEcCmPVz6H3OUMCAwEAAQ",
18 /*
19 -----BEGIN RSA PRIVATE KEY-----
20 MIIBOgIBAAJBALlKJGIBHYU3rIWyGmiwUgK1BUUomSBgLzSngoE7gBc7mqgCsEbj
21 f9EJ5AvQIM1x7MhVsD5djpqHLcjiQlZFXfECAwEAAQJABEK7MXG7HwwXsH9W8h9T
22 03IcK+nyE3eCvmA3tQcMO/x93imcBdNiz7ev09wGIPDN3Kmauf70/QnjebuDSV9A
23 XQIhAN57+YUwDdGccxqZyj+wRuU5pA1rltIDBQByBLRGd6YjAiEA1TPE2PdWrSsp
24 S6VZoRPWIEebfH/ufWZEFfYKDwP9qtsCIEk3JSr2YGXNhXeIiq0g1oPSzzD3af+c
25 rMWzv+aPlgpfAiAvtSLiTg6GN3dJJxn0UmUC2iMv68ypIN4xb9n2XDVCKwIhAJkd
26 evN4qUcg1kCeQ4LZ5F4WUus+4kd2+Y1nnYQbOrE9
27 -----END RSA PRIVATE KEY-----
28 */
29 bar: "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALlKJGIBHYU3rIWyGmiwUgK1BUUomSBgLzSngo E7gBc7mqgCsEbjf9EJ5AvQIM1x7MhVsD5djpqHLcjiQlZFXfECAwEAAQ"
30 };
Wladimir Palant 2014/09/10 21:55:06 Given that no signatures are being verified here a
Thomas Greiner 2014/12/11 14:33:55 Done. That was a leftover from my previous approac
31
32 function beautifyKeys(str)
33 {
34 if (typeof str != "string")
35 return str;
36
37 return str.replace(publickeys.foo, "foo-publickey", "g")
38 .replace(publickeys.bar, "bar-publickey", "g");
39 }
40
5 function compareKeywords(text, expected) 41 function compareKeywords(text, expected)
6 { 42 {
7 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)]) 43 for (let filter of [Filter.fromText(text), Filter.fromText("@@" + text)])
8 { 44 {
9 let matcher = new Matcher(); 45 let matcher = new Matcher();
10 let result = []; 46 let result = [];
11 for (let dummy of expected) 47 for (let dummy of expected)
12 { 48 {
13 keyword = matcher.findKeyword(filter); 49 keyword = matcher.findKeyword(filter);
14 result.push(keyword); 50 result.push(keyword);
15 if (keyword) 51 if (keyword)
16 { 52 {
17 let dummyFilter = Filter.fromText('^' + keyword + '^'); 53 let dummyFilter = Filter.fromText('^' + keyword + '^');
18 dummyFilter.filterCount = Infinity; 54 dummyFilter.filterCount = Infinity;
19 matcher.add(dummyFilter); 55 matcher.add(dummyFilter);
20 } 56 }
21 } 57 }
22 58
23 equal(result.join(", "), expected.join(", "), "Keyword candidates for " + filter.text); 59 equal(result.join(", "), expected.join(", "), "Keyword candidates for " + filter.text);
24 } 60 }
25 } 61 }
26 62
27 function checkMatch(filters, location, contentType, docDomain, thirdParty, exp ected) 63 function checkMatch(filters, location, contentType, docDomain, thirdParty, sit ekey, expected)
28 { 64 {
29 let matcher = new Matcher(); 65 let matcher = new Matcher();
30 for (let filter of filters) 66 for (let filter of filters)
31 matcher.add(Filter.fromText(filter)); 67 matcher.add(Filter.fromText(filter));
32 68
33 let result = matcher.matchesAny(location, contentType, docDomain, thirdParty ); 69 let result = matcher.matchesAny(location, contentType, docDomain, thirdParty , sitekey);
34 if (result) 70 if (result)
35 result = result.text; 71 result = result.text;
36 72
37 equal(result, expected, "match(" + location + ", " + contentType + ", " + do cDomain + ", " + (thirdParty ? "third-party" : "first-party") + ") with:\n" + fi lters.join("\n")); 73 equal(beautifyKeys(result), beautifyKeys(expected), "match(" + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "firs t-party") + ", " + (sitekey ? beautifyKeys(sitekey) : "no-sitekey") + ") with:\n " + beautifyKeys(filters.join("\n")));
38 74
39 let combinedMatcher = new CombinedMatcher(); 75 let combinedMatcher = new CombinedMatcher();
40 for (let i = 0; i < 2; i++) 76 for (let i = 0; i < 2; i++)
41 { 77 {
42 for (let filter of filters) 78 for (let filter of filters)
43 combinedMatcher.add(Filter.fromText(filter)); 79 combinedMatcher.add(Filter.fromText(filter));
44 80
45 let result = combinedMatcher.matchesAny(location, contentType, docDomain, thirdParty); 81 let result = combinedMatcher.matchesAny(location, contentType, docDomain, thirdParty, sitekey);
46 if (result) 82 if (result)
47 result = result.text; 83 result = result.text;
48 84
49 equal(result, expected, "combinedMatch(" + location + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-party" : "first-party") + ") wit h:\n" + filters.join("\n")); 85 equal(beautifyKeys(result), beautifyKeys(expected), "combinedMatch(" + loc ation + ", " + contentType + ", " + docDomain + ", " + (thirdParty ? "third-part y" : "first-party") + ", " + (sitekey ? beautifyKeys(sitekey) : "no-sitekey") + ") with:\n" + beautifyKeys(filters.join("\n")));
50 86
51 // For next run: add whitelisting filters 87 // For next run: add whitelisting filters
52 filters = filters.map((text) => "@@" + text); 88 filters = filters.map((text) => "@@" + text);
53 if (expected) 89 if (expected)
54 expected = "@@" + expected; 90 expected = "@@" + expected;
55 } 91 }
56 } 92 }
57 93
58 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp ected) 94 function cacheCheck(matcher, location, contentType, docDomain, thirdParty, exp ected)
59 { 95 {
(...skipping 29 matching lines...) Expand all
89 compareKeywords("^foo%2Ebar^", ["foo%2ebar"]); 125 compareKeywords("^foo%2Ebar^", ["foo%2ebar"]);
90 compareKeywords("^aSdF^1234", ["asdf"]); 126 compareKeywords("^aSdF^1234", ["asdf"]);
91 compareKeywords("_asdf_1234_", ["asdf", "1234"]); 127 compareKeywords("_asdf_1234_", ["asdf", "1234"]);
92 compareKeywords("+asdf-1234=", ["asdf", "1234"]); 128 compareKeywords("+asdf-1234=", ["asdf", "1234"]);
93 compareKeywords("/123^ad2&ad&", ["123", "ad2"]); 129 compareKeywords("/123^ad2&ad&", ["123", "ad2"]);
94 compareKeywords("/123^ad2&ad$script,domain=example.com", ["123", "ad2"]); 130 compareKeywords("/123^ad2&ad$script,domain=example.com", ["123", "ad2"]);
95 }); 131 });
96 132
97 test("Filter matching", function() 133 test("Filter matching", function()
98 { 134 {
99 checkMatch([], "http://abc/def", "IMAGE", null, false, null); 135 checkMatch([], "http://abc/def", "IMAGE", null, false, null, null);
100 checkMatch(["abc"], "http://abc/def", "IMAGE", null, false, "abc"); 136 checkMatch(["abc"], "http://abc/def", "IMAGE", null, false, null, "abc");
101 checkMatch(["abc", "ddd"], "http://abc/def", "IMAGE", null, false, "abc"); 137 checkMatch(["abc", "ddd"], "http://abc/def", "IMAGE", null, false, null, "ab c");
102 checkMatch(["ddd", "abc"], "http://abc/def", "IMAGE", null, false, "abc"); 138 checkMatch(["ddd", "abc"], "http://abc/def", "IMAGE", null, false, null, "ab c");
103 checkMatch(["ddd", "abd"], "http://abc/def", "IMAGE", null, false, null); 139 checkMatch(["ddd", "abd"], "http://abc/def", "IMAGE", null, false, null, nul l);
104 checkMatch(["abc", "://abc/d"], "http://abc/def", "IMAGE", null, false, ":// abc/d"); 140 checkMatch(["abc", "://abc/d"], "http://abc/def", "IMAGE", null, false, null , "://abc/d");
105 checkMatch(["://abc/d", "abc"], "http://abc/def", "IMAGE", null, false, ":// abc/d"); 141 checkMatch(["://abc/d", "abc"], "http://abc/def", "IMAGE", null, false, null , "://abc/d");
106 checkMatch(["|http://"], "http://abc/def", "IMAGE", null, false, "|http://") ; 142 checkMatch(["|http://"], "http://abc/def", "IMAGE", null, false, null, "|htt p://");
107 checkMatch(["|http://abc"], "http://abc/def", "IMAGE", null, false, "|http:/ /abc"); 143 checkMatch(["|http://abc"], "http://abc/def", "IMAGE", null, false, null, "| http://abc");
108 checkMatch(["|abc"], "http://abc/def", "IMAGE", null, false, null); 144 checkMatch(["|abc"], "http://abc/def", "IMAGE", null, false, null, null);
109 checkMatch(["|/abc/def"], "http://abc/def", "IMAGE", null, false, null); 145 checkMatch(["|/abc/def"], "http://abc/def", "IMAGE", null, false, null, null );
110 checkMatch(["/def|"], "http://abc/def", "IMAGE", null, false, "/def|"); 146 checkMatch(["/def|"], "http://abc/def", "IMAGE", null, false, null, "/def|") ;
111 checkMatch(["/abc/def|"], "http://abc/def", "IMAGE", null, false, "/abc/def| "); 147 checkMatch(["/abc/def|"], "http://abc/def", "IMAGE", null, false, null, "/ab c/def|");
112 checkMatch(["/abc/|"], "http://abc/def", "IMAGE", null, false, null); 148 checkMatch(["/abc/|"], "http://abc/def", "IMAGE", null, false, null, null);
113 checkMatch(["http://abc/|"], "http://abc/def", "IMAGE", null, false, null); 149 checkMatch(["http://abc/|"], "http://abc/def", "IMAGE", null, false, null, n ull);
114 checkMatch(["|http://abc/def|"], "http://abc/def", "IMAGE", null, false, "|h ttp://abc/def|"); 150 checkMatch(["|http://abc/def|"], "http://abc/def", "IMAGE", null, false, nul l, "|http://abc/def|");
115 checkMatch(["|/abc/def|"], "http://abc/def", "IMAGE", null, false, null); 151 checkMatch(["|/abc/def|"], "http://abc/def", "IMAGE", null, false, null, nul l);
116 checkMatch(["|http://abc/|"], "http://abc/def", "IMAGE", null, false, null); 152 checkMatch(["|http://abc/|"], "http://abc/def", "IMAGE", null, false, null, null);
117 checkMatch(["|/abc/|"], "http://abc/def", "IMAGE", null, false, null); 153 checkMatch(["|/abc/|"], "http://abc/def", "IMAGE", null, false, null, null);
118 checkMatch(["||example.com/abc"], "http://example.com/abc/def", "IMAGE", nul l, false, "||example.com/abc"); 154 checkMatch(["||example.com/abc"], "http://example.com/abc/def", "IMAGE", nul l, false, null, "||example.com/abc");
119 checkMatch(["||com/abc/def"], "http://example.com/abc/def", "IMAGE", null, f alse, "||com/abc/def"); 155 checkMatch(["||com/abc/def"], "http://example.com/abc/def", "IMAGE", null, f alse, null, "||com/abc/def");
120 checkMatch(["||com/abc"], "http://example.com/abc/def", "IMAGE", null, false , "||com/abc"); 156 checkMatch(["||com/abc"], "http://example.com/abc/def", "IMAGE", null, false , null, "||com/abc");
121 checkMatch(["||mple.com/abc"], "http://example.com/abc/def", "IMAGE", null, false, null); 157 checkMatch(["||mple.com/abc"], "http://example.com/abc/def", "IMAGE", null, false, null, null);
122 checkMatch(["||.com/abc/def"], "http://example.com/abc/def", "IMAGE", null, false, null); 158 checkMatch(["||.com/abc/def"], "http://example.com/abc/def", "IMAGE", null, false, null, null);
123 checkMatch(["||http://example.com/"], "http://example.com/abc/def", "IMAGE", null, false, null); 159 checkMatch(["||http://example.com/"], "http://example.com/abc/def", "IMAGE", null, false, null, null);
124 checkMatch(["||example.com/abc/def|"], "http://example.com/abc/def", "IMAGE" , null, false, "||example.com/abc/def|"); 160 checkMatch(["||example.com/abc/def|"], "http://example.com/abc/def", "IMAGE" , null, false, null, "||example.com/abc/def|");
125 checkMatch(["||com/abc/def|"], "http://example.com/abc/def", "IMAGE", null, false, "||com/abc/def|"); 161 checkMatch(["||com/abc/def|"], "http://example.com/abc/def", "IMAGE", null, false, null, "||com/abc/def|");
126 checkMatch(["||example.com/abc|"], "http://example.com/abc/def", "IMAGE", nu ll, false, null); 162 checkMatch(["||example.com/abc|"], "http://example.com/abc/def", "IMAGE", nu ll, false, null, null);
127 checkMatch(["abc", "://abc/d", "asdf1234"], "http://abc/def", "IMAGE", null, false, "://abc/d"); 163 checkMatch(["abc", "://abc/d", "asdf1234"], "http://abc/def", "IMAGE", null, false, null, "://abc/d");
128 checkMatch(["foo*://abc/d", "foo*//abc/de", "://abc/de", "asdf1234"], "http: //abc/def", "IMAGE", null, false, "://abc/de"); 164 checkMatch(["foo*://abc/d", "foo*//abc/de", "://abc/de", "asdf1234"], "http: //abc/def", "IMAGE", null, false, null, "://abc/de");
129 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, false, "abc$~third-party"); 165 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, false, null, "abc$~third-party");
130 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, true, "abc$third-party"); 166 checkMatch(["abc$third-party", "abc$~third-party", "ddd"], "http://abc/def", "IMAGE", null, true, null, "abc$third-party");
131 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, false, "//abc/def$~third-party"); 167 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, false, null, "//abc/def$~third-party");
132 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, true, "//abc/def$third-party"); 168 checkMatch(["//abc/def$third-party", "//abc/def$~third-party", "//abc_def"], "http://abc/def", "IMAGE", null, true, null, "//abc/def$third-party");
133 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def"], "http://abc /def", "IMAGE", null, true, "//abc/def"); 169 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def"], "http://abc /def", "IMAGE", null, true, null, "//abc/def");
134 checkMatch(["//abc/def", "abc$third-party", "abc$~third-party"], "http://abc /def", "IMAGE", null, true, "//abc/def"); 170 checkMatch(["//abc/def", "abc$third-party", "abc$~third-party"], "http://abc /def", "IMAGE", null, true, null, "//abc/def");
135 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, true, "//abc/def$third-party"); 171 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, true, null, "//abc/def$third-party");
136 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, false, "abc$~third-party"); 172 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$third-party"], "http://abc/def", "IMAGE", null, false, null, "abc$~third-party");
137 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$~third-party"] , "http://abc/def", "IMAGE", null, true, "abc$third-party"); 173 checkMatch(["abc$third-party", "abc$~third-party", "//abc/def$~third-party"] , "http://abc/def", "IMAGE", null, true, null, "abc$third-party");
138 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "IMA GE", null, false, "abc$image"); 174 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "IMA GE", null, false, null, "abc$image");
139 checkMatch(["abc$image", "abc$script", "abc$~script"], "http://abc/def", "SC RIPT", null, false, "abc$script"); 175 checkMatch(["abc$image", "abc$script", "abc$~script"], "http://abc/def", "SC RIPT", null, false, null, "abc$script");
140 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "OTH ER", null, false, "abc$~image"); 176 checkMatch(["abc$image", "abc$script", "abc$~image"], "http://abc/def", "OTH ER", null, false, null, "abc$~image");
141 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "IMAGE", null, false, "//abc/def$image"); 177 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "IMAGE", null, false, null, "//abc/def$image");
142 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~script"], "ht tp://abc/def", "SCRIPT", null, false, "//abc/def$script"); 178 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~script"], "ht tp://abc/def", "SCRIPT", null, false, null, "//abc/def$script");
143 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "OTHER", null, false, "//abc/def$~image"); 179 checkMatch(["//abc/def$image", "//abc/def$script", "//abc/def$~image"], "htt p://abc/def", "OTHER", null, false, null, "//abc/def$~image");
144 checkMatch(["abc$image", "abc$~image", "//abc/def"], "http://abc/def", "IMAG E", null, false, "//abc/def"); 180 checkMatch(["abc$image", "abc$~image", "//abc/def"], "http://abc/def", "IMAG E", null, false, null, "//abc/def");
145 checkMatch(["//abc/def", "abc$image", "abc$~image"], "http://abc/def", "IMAG E", null, false, "//abc/def"); 181 checkMatch(["//abc/def", "abc$image", "abc$~image"], "http://abc/def", "IMAG E", null, false, null, "//abc/def");
146 checkMatch(["abc$image", "abc$~image", "//abc/def$image"], "http://abc/def", "IMAGE", null, false, "//abc/def$image"); 182 checkMatch(["abc$image", "abc$~image", "//abc/def$image"], "http://abc/def", "IMAGE", null, false, null, "//abc/def$image");
147 checkMatch(["abc$image", "abc$~image", "//abc/def$script"], "http://abc/def" , "IMAGE", null, false, "abc$image"); 183 checkMatch(["abc$image", "abc$~image", "//abc/def$script"], "http://abc/def" , "IMAGE", null, false, null, "abc$image");
148 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "abc$domain=foo.com"); 184 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, "abc$domain=foo. com");
149 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, "abc$domain=bar.com"); 185 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, "abc$domain=bar. com");
150 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, "abc$domain=~foo.com|~ bar.com"); 186 checkMatch(["abc$domain=foo.com", "abc$domain=bar.com", "abc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, "abc$domain=~foo .com|~bar.com");
151 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, "abc$domain=foo.com"); 187 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "foo.com", false, null, "abc$domain=foo. com");
152 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null); 188 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "bar.com", false, null, null);
153 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null); 189 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://abc/def", "IMAGE", "baz.com", false, null, null);
154 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, "ccc$domain=~foo.com|~ bar.com"); 190 checkMatch(["abc$domain=foo.com", "cba$domain=bar.com", "ccc$domain=~foo.com |~bar.com"], "http://ccc/def", "IMAGE", "baz.com", false, null, "ccc$domain=~foo .com|~bar.com");
191 checkMatch(["abc$sitekey=" + publickeys.foo, "abc$sitekey=" + publickeys.bar ], "http://abc/def", "IMAGE", "foo.com", false, publickeys.foo, "abc$sitekey=" + publickeys.foo);
192 checkMatch(["abc$sitekey=" + publickeys.foo, "abc$sitekey=" + publickeys.bar ], "http://abc/def", "IMAGE", "bar.com", false, publickeys.bar, "abc$sitekey=" + publickeys.bar);
193 checkMatch(["abc$sitekey=" + publickeys.foo, "cba$sitekey=" + publickeys.bar ], "http://abc/def", "IMAGE", "bar.com", false, publickeys.bar, null);
194 checkMatch(["abc$sitekey=" + publickeys.foo, "cba$sitekey=" + publickeys.bar ], "http://abc/def", "IMAGE", "baz.com", false, null, null);
Wladimir Palant 2014/09/10 21:55:06 Please test the scenarios where the filter combine
Thomas Greiner 2014/12/11 14:33:55 Done.
155 }); 195 });
156 196
157 test("Result cache checks", function() 197 test("Result cache checks", function()
158 { 198 {
159 let matcher = new CombinedMatcher(); 199 let matcher = new CombinedMatcher();
160 matcher.add(Filter.fromText("abc$image")); 200 matcher.add(Filter.fromText("abc$image"));
161 matcher.add(Filter.fromText("abc$script")); 201 matcher.add(Filter.fromText("abc$script"));
162 matcher.add(Filter.fromText("abc$~image,~script,~document")); 202 matcher.add(Filter.fromText("abc$~image,~script,~document"));
163 matcher.add(Filter.fromText("cba$third-party")); 203 matcher.add(Filter.fromText("cba$third-party"));
164 matcher.add(Filter.fromText("cba$~third-party,~script")); 204 matcher.add(Filter.fromText("cba$~third-party,~script"));
(...skipping 14 matching lines...) Expand all
179 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p arty,~script"); 219 cacheCheck(matcher, "http://fed", "IMAGE", null, false, "http://fed$~third-p arty,~script");
180 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par ty"); 220 cacheCheck(matcher, "http://fed", "IMAGE", null, true, "http://fed$third-par ty");
181 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, false, "cba$~third-p arty,~script"); 221 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, false, "cba$~third-p arty,~script");
182 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, true, "cba$third-par ty"); 222 cacheCheck(matcher, "http://abc_cba", "DOCUMENT", null, true, "cba$third-par ty");
183 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script"); 223 cacheCheck(matcher, "http://abc_cba", "SCRIPT", null, false, "abc$script");
184 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, false, "http: //fed$~third-party,~script"); 224 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, false, "http: //fed$~third-party,~script");
185 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, true, "http:/ /fed$third-party"); 225 cacheCheck(matcher, "http://def?http://fed", "DOCUMENT", null, true, "http:/ /fed$third-party");
186 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http:// def$script"); 226 cacheCheck(matcher, "http://def?http://fed", "SCRIPT", null, false, "http:// def$script");
187 }); 227 });
188 })(); 228 })();
OLDNEW

Powered by Google App Engine
This is Rietveld