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

Side by Side Diff: test/filterClasses.js

Issue 29912636: Issue 7052 - Use string-based matching for literal patterns (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add comments Created Oct. 17, 2018, 8:58 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 for (let [domain, isIncluded] of filter.domains) 76 for (let [domain, isIncluded] of filter.domains)
77 { 77 {
78 if (domain != "") 78 if (domain != "")
79 domains.push(isIncluded ? domain : "~" + domain); 79 domains.push(isIncluded ? domain : "~" + domain);
80 } 80 }
81 } 81 }
82 result.push("domains=" + domains.sort().join("|")); 82 result.push("domains=" + domains.sort().join("|"));
83 83
84 if (filter instanceof RegExpFilter) 84 if (filter instanceof RegExpFilter)
85 { 85 {
86 result.push("regexp=" + filter.regexp.source); 86 result.push("regexp=" + (filter.regexp ? filter.regexp.source : null));
87 result.push("contentType=" + filter.contentType); 87 result.push("contentType=" + filter.contentType);
88 result.push("matchCase=" + filter.matchCase); 88 result.push("matchCase=" + filter.matchCase);
89 89
90 let sitekeys = filter.sitekeys || []; 90 let sitekeys = filter.sitekeys || [];
91 result.push("sitekeys=" + sitekeys.slice().sort().join("|")); 91 result.push("sitekeys=" + sitekeys.slice().sort().join("|"));
92 92
93 result.push("thirdParty=" + filter.thirdParty); 93 result.push("thirdParty=" + filter.thirdParty);
94 if (filter instanceof BlockingFilter) 94 if (filter instanceof BlockingFilter)
95 { 95 {
96 result.push("type=filterlist"); 96 result.push("type=filterlist");
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 { 153 {
154 addProperty("disabled", "false"); 154 addProperty("disabled", "false");
155 addProperty("lastHit", "0"); 155 addProperty("lastHit", "0");
156 addProperty("hitCount", "0"); 156 addProperty("hitCount", "0");
157 } 157 }
158 if (type == "whitelist" || type == "filterlist") 158 if (type == "whitelist" || type == "filterlist")
159 { 159 {
160 addProperty("contentType", 0x7FFFFFFF & ~( 160 addProperty("contentType", 0x7FFFFFFF & ~(
161 t.CSP | t.DOCUMENT | t.ELEMHIDE | t.POPUP | t.GENERICHIDE | t.GENERICBLOCK 161 t.CSP | t.DOCUMENT | t.ELEMHIDE | t.POPUP | t.GENERICHIDE | t.GENERICBLOCK
162 )); 162 ));
163 addProperty("regexp", "null");
163 addProperty("matchCase", "false"); 164 addProperty("matchCase", "false");
164 addProperty("thirdParty", "null"); 165 addProperty("thirdParty", "null");
165 addProperty("domains", ""); 166 addProperty("domains", "");
166 addProperty("sitekeys", ""); 167 addProperty("sitekeys", "");
167 } 168 }
168 if (type == "filterlist") 169 if (type == "filterlist")
169 { 170 {
170 addProperty("collapse", "null"); 171 addProperty("collapse", "null");
171 addProperty("csp", "null"); 172 addProperty("csp", "null");
172 addProperty("rewrite", "null"); 173 addProperty("rewrite", "null");
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 checkElemHideEmulationFilterInvalid("~foo.com"); 263 checkElemHideEmulationFilterInvalid("~foo.com");
263 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com"); 264 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com");
264 checkElemHideEmulationFilterInvalid("foo"); 265 checkElemHideEmulationFilterInvalid("foo");
265 checkElemHideEmulationFilterInvalid("~foo.com,bar"); 266 checkElemHideEmulationFilterInvalid("~foo.com,bar");
266 267
267 test.done(); 268 test.done();
268 }; 269 };
269 270
270 exports.testFiltersWithState = function(test) 271 exports.testFiltersWithState = function(test)
271 { 272 {
272 compareFilter(test, "blabla", ["type=filterlist", "text=blabla", "regexp=blabl a"]); 273 compareFilter(test, "blabla", ["type=filterlist", "text=blabla"]);
273 compareFilter( 274 compareFilter(
274 test, "blabla_default", ["type=filterlist", "text=blabla_default", "regexp=b labla_default"], 275 test, "blabla_default", ["type=filterlist", "text=blabla_default"],
275 filter => 276 filter =>
276 { 277 {
277 filter.disabled = false; 278 filter.disabled = false;
278 filter.hitCount = 0; 279 filter.hitCount = 0;
279 filter.lastHit = 0; 280 filter.lastHit = 0;
280 } 281 }
281 ); 282 );
282 compareFilter( 283 compareFilter(
283 test, "blabla_non_default", 284 test, "blabla_non_default",
284 ["type=filterlist", "text=blabla_non_default", "regexp=blabla_non_default", "disabled=true", "hitCount=12", "lastHit=20"], 285 ["type=filterlist", "text=blabla_non_default", "disabled=true", "hitCount=12 ", "lastHit=20"],
285 filter => 286 filter =>
286 { 287 {
287 filter.disabled = true; 288 filter.disabled = true;
288 filter.hitCount = 12; 289 filter.hitCount = 12;
289 filter.lastHit = 20; 290 filter.lastHit = 20;
290 } 291 }
291 ); 292 );
292 293
293 test.done(); 294 test.done();
294 }; 295 };
295 296
296 exports.testSpecialCharacters = function(test) 297 exports.testSpecialCharacters = function(test)
297 { 298 {
298 compareFilter(test, "/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/", "regexp=ddd|f?a[s]d"]); 299 compareFilter(test, "/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/", "regexp=ddd|f?a[s]d"]);
299 compareFilter(test, "*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", " regexp=asdf.*d.*dd"]); 300 compareFilter(test, "*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", " regexp=asdf.*d.*dd"]);
300 compareFilter(test, "|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd *|", "regexp=^.*asd\\|f.*d.*dd.*$"]); 301 compareFilter(test, "|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd *|", "regexp=^.*asd\\|f.*d.*dd.*$"]);
301 compareFilter(test, "dd[]{}$%<>&()d", ["type=filterlist", "text=dd[]{}$%<>&()d ", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d"]); 302 compareFilter(test, "dd[]{}$%<>&()*d", ["type=filterlist", "text=dd[]{}$%<>&() *d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\).*d"]);
Manish Jethani 2018/10/17 09:05:04 Line 302 and line 310 are the only cases where I d
302 303
303 // Leading and trailing wildcards should be left in for rewrite filters (#6868 ). 304 // Leading and trailing wildcards should be left in for rewrite filters (#6868 ).
304 compareFilter(test, "*asdf*d**dd*$rewrite=", ["type=filterlist", "text=*asdf*d **dd*$rewrite=", "regexp=.*asdf.*d.*dd.*", "rewrite=", "contentType=" + (default Types & ~(t.SCRIPT | t.SUBDOCUMENT | t.OBJECT | t.OBJECT_SUBREQUEST))]); 305 compareFilter(test, "*asdf*d**dd*$rewrite=", ["type=filterlist", "text=*asdf*d **dd*$rewrite=", "regexp=.*asdf.*d.*dd.*", "rewrite=", "contentType=" + (default Types & ~(t.SCRIPT | t.SUBDOCUMENT | t.OBJECT | t.OBJECT_SUBREQUEST))]);
305 306
306 compareFilter(test, "@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d /", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); 307 compareFilter(test, "@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d /", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]);
307 compareFilter(test, "@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*" , "regexp=asdf.*d.*dd", "contentType=" + defaultTypes]); 308 compareFilter(test, "@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*" , "regexp=asdf.*d.*dd", "contentType=" + defaultTypes]);
308 compareFilter(test, "@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d* *dd*|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]); 309 compareFilter(test, "@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d* *dd*|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]);
309 compareFilter(test, "@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>& ()d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTyp es]); 310 compareFilter(test, "@@dd[]{}$%<>&()*d", ["type=whitelist", "text=@@dd[]{}$%<> &()*d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\).*d", "contentType=" + defaul tTypes]);
310 311
311 test.done(); 312 test.done();
312 }; 313 };
313 314
314 exports.testFilterOptions = function(test) 315 exports.testFilterOptions = function(test)
315 { 316 {
316 compareFilter(test, "bla$match-case,csp=first csp,script,other,third-party,dom ain=FOO.cOm,sitekey=foo", ["type=filterlist", "text=bla$match-case,csp=first csp ,script,other,third-party,domain=FOO.cOm,sitekey=foo", "regexp=bla", "matchCase= true", "contentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domain s=foo.com", "sitekeys=FOO", "csp=first csp"]); 317 compareFilter(test, "bla$match-case,csp=first csp,script,other,third-party,dom ain=FOO.cOm,sitekey=foo", ["type=filterlist", "text=bla$match-case,csp=first csp ,script,other,third-party,domain=FOO.cOm,sitekey=foo", "matchCase=true", "conten tType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=foo.com", "s itekeys=FOO", "csp=first csp"]);
317 compareFilter(test, "bla$~match-case,~csp=csp,~script,~other,~third-party,doma in=~bAr.coM", ["type=filterlist", "text=bla$~match-case,~csp=csp,~script,~other, ~third-party,domain=~bAr.coM", "regexp=bla", "contentType=" + (defaultTypes & ~( t.SCRIPT | t.OTHER)), "thirdParty=false", "domains=~bar.com"]); 318 compareFilter(test, "bla$~match-case,~csp=csp,~script,~other,~third-party,doma in=~bAr.coM", ["type=filterlist", "text=bla$~match-case,~csp=csp,~script,~other, ~third-party,domain=~bAr.coM", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.O THER)), "thirdParty=false", "domains=~bar.com"]);
318 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com| bar.com|~bAR.foO.Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", ["type=whitelist", "text=@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bAR.foO .Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", "regexp=bla", "matchCase=true", "c ontentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=bar.com |foo.com|~bar.foo.com|~foo.bar.com", "sitekeys=BAR|FOO"]); 319 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com| bar.com|~bAR.foO.Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", ["type=whitelist", "text=@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bAR.foO .Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=bar.com|foo.com|~bar. foo.com|~foo.bar.com", "sitekeys=BAR|FOO"]);
319 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com| bar.com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", ["type=whitelist", "text=@@b la$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo. bar.com,sitekey=foo|bar", "regexp=bla", "matchCase=true", "contentType=" + (t.SC RIPT | t.OTHER), "thirdParty=true", "domains=bar.com|foo.com|~bar.foo.com|~foo.b ar.com", "sitekeys=BAR|FOO"]); 320 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com| bar.com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", ["type=whitelist", "text=@@b la$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo. bar.com,sitekey=foo|bar", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER ), "thirdParty=true", "domains=bar.com|foo.com|~bar.foo.com|~foo.bar.com", "site keys=BAR|FOO"]);
320 compareFilter(test, "||content.server.com/files/*.php$rewrite=$1", ["type=filt erlist", "text=||content.server.com/files/*.php$rewrite=$1", "regexp=^[\\w\\-]+: \\/+(?!\\/)(?:[^\\/]+\\.)?content\\.server\\.com\\/files\\/.*\\.php", "matchCase =false", "rewrite=$1", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.SUBDOCUME NT | t.OBJECT | t.OBJECT_SUBREQUEST))]); 321 compareFilter(test, "||content.server.com/files/*.php$rewrite=$1", ["type=filt erlist", "text=||content.server.com/files/*.php$rewrite=$1", "regexp=^[\\w\\-]+: \\/+(?!\\/)(?:[^\\/]+\\.)?content\\.server\\.com\\/files\\/.*\\.php", "matchCase =false", "rewrite=$1", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.SUBDOCUME NT | t.OBJECT | t.OBJECT_SUBREQUEST))]);
321 322
322 // background and image should be the same for backwards compatibility 323 // background and image should be the same for backwards compatibility
323 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp =bla", "contentType=" + (t.IMAGE)]); 324 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "conten tType=" + (t.IMAGE)]);
324 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background ", "regexp=bla", "contentType=" + (t.IMAGE)]); 325 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background ", "contentType=" + (t.IMAGE)]);
325 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "rege xp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); 326 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "cont entType=" + (defaultTypes & ~t.IMAGE)]);
326 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou nd", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); 327 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou nd", "contentType=" + (defaultTypes & ~t.IMAGE)]);
327 328
328 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc ript,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE R))]); 329 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc ript,~other", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
329 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@ http://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (default Types & ~(t.SCRIPT | t.OTHER))]); 330 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@ http://bla$~script,~other", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE R))]);
330 compareFilter(test, "@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@ |ftp://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (default Types & ~(t.SCRIPT | t.OTHER))]); 331 compareFilter(test, "@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@ |ftp://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (default Types & ~(t.SCRIPT | t.OTHER))]);
331 compareFilter(test, "@@bla$~script,~other,document", ["type=whitelist", "text= @@bla$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~ (t.SCRIPT | t.OTHER) | t.DOCUMENT)]); 332 compareFilter(test, "@@bla$~script,~other,document", ["type=whitelist", "text= @@bla$~script,~other,document", "contentType=" + (defaultTypes & ~(t.SCRIPT | t. OTHER) | t.DOCUMENT)]);
332 compareFilter(test, "@@bla$~script,~other,~document", ["type=whitelist", "text =@@bla$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]); 333 compareFilter(test, "@@bla$~script,~other,~document", ["type=whitelist", "text =@@bla$~script,~other,~document", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
333 compareFilter(test, "@@bla$document", ["type=whitelist", "text=@@bla$document" , "regexp=bla", "contentType=" + t.DOCUMENT]); 334 compareFilter(test, "@@bla$document", ["type=whitelist", "text=@@bla$document" , "contentType=" + t.DOCUMENT]);
334 compareFilter(test, "@@bla$~script,~other,elemhide", ["type=whitelist", "text= @@bla$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~ (t.SCRIPT | t.OTHER) | t.ELEMHIDE)]); 335 compareFilter(test, "@@bla$~script,~other,elemhide", ["type=whitelist", "text= @@bla$~script,~other,elemhide", "contentType=" + (defaultTypes & ~(t.SCRIPT | t. OTHER) | t.ELEMHIDE)]);
335 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text =@@bla$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]); 336 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text =@@bla$~script,~other,~elemhide", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
336 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide" , "regexp=bla", "contentType=" + t.ELEMHIDE]); 337 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide" , "contentType=" + t.ELEMHIDE]);
337 338
338 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text= @@bla$~script,~other,donottrack", "reason=filter_unknown_option"]); 339 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text= @@bla$~script,~other,donottrack", "reason=filter_unknown_option"]);
339 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text =@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]); 340 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text =@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]);
340 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac k", "reason=filter_unknown_option"]); 341 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac k", "reason=filter_unknown_option"]);
341 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea son=filter_unknown_option"]); 342 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea son=filter_unknown_option"]);
342 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f oobar", "reason=filter_unknown_option"]); 343 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f oobar", "reason=filter_unknown_option"]);
343 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar, image", "reason=filter_unknown_option"]); 344 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar, image", "reason=filter_unknown_option"]);
344 345
345 compareFilter(test, "bla$csp", ["type=invalid", "text=bla$csp", "reason=filter _invalid_csp"]); 346 compareFilter(test, "bla$csp", ["type=invalid", "text=bla$csp", "reason=filter _invalid_csp"]);
346 compareFilter(test, "bla$csp=", ["type=invalid", "text=bla$csp=", "reason=filt er_invalid_csp"]); 347 compareFilter(test, "bla$csp=", ["type=invalid", "text=bla$csp=", "reason=filt er_invalid_csp"]);
347 348
348 // Blank CSP values are allowed for whitelist filters. 349 // Blank CSP values are allowed for whitelist filters.
349 compareFilter(test, "@@bla$csp", ["type=whitelist", "text=@@bla$csp", "regexp= bla", "contentType=" + t.CSP]); 350 compareFilter(test, "@@bla$csp", ["type=whitelist", "text=@@bla$csp", "content Type=" + t.CSP]);
350 compareFilter(test, "@@bla$csp=", ["type=whitelist", "text=@@bla$csp=", "regex p=bla", "contentType=" + t.CSP]); 351 compareFilter(test, "@@bla$csp=", ["type=whitelist", "text=@@bla$csp=", "conte ntType=" + t.CSP]);
351 352
352 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor t-uri", "reason=filter_invalid_csp"]); 353 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor t-uri", "reason=filter_invalid_csp"]);
353 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs p=foo,csp=report-to", "reason=filter_invalid_csp"]); 354 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs p=foo,csp=report-to", "reason=filter_invalid_csp"]);
354 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]); 355 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla $csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]);
355 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]); 356 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp =foo,csp=base-uri", "reason=filter_invalid_csp"]);
356 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]); 357 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]);
357 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); 358 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]);
358 359
359 test.done(); 360 test.done();
360 }; 361 };
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 normalized, 509 normalized,
509 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p" 510 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p"
510 ); 511 );
511 compareFilter( 512 compareFilter(
512 test, normalized, [ 513 test, normalized, [
513 "type=filterlist", 514 "type=filterlist",
514 "text=" + normalized, 515 "text=" + normalized,
515 "csp=c s p", 516 "csp=c s p",
516 "domains=domain.com|foo.com", 517 "domains=domain.com|foo.com",
517 "sitekeys=FOO", 518 "sitekeys=FOO",
518 "regexp=b\\$la",
519 "contentType=" + t.CSP 519 "contentType=" + t.CSP
520 ] 520 ]
521 ); 521 );
522 522
523 // Some $csp edge cases 523 // Some $csp edge cases
524 test.equal(Filter.normalize("$csp= "), 524 test.equal(Filter.normalize("$csp= "),
525 "$csp="); 525 "$csp=");
526 test.equal(Filter.normalize("$csp= c s p"), 526 test.equal(Filter.normalize("$csp= c s p"),
527 "$csp=c s p"); 527 "$csp=c s p");
528 test.equal(Filter.normalize("$$csp= c s p"), 528 test.equal(Filter.normalize("$$csp= c s p"),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 test.notEqual(filter2.domains, filter5.domains); 630 test.notEqual(filter2.domains, filter5.domains);
631 631
632 // Check twice for element hiding filters to make sure the internal cached 632 // Check twice for element hiding filters to make sure the internal cached
633 // values are also not equal. 633 // values are also not equal.
634 test.notEqual(filter4.domains, filter6.domains); 634 test.notEqual(filter4.domains, filter6.domains);
635 test.notEqual(filter4.domains, filter6.domains); 635 test.notEqual(filter4.domains, filter6.domains);
636 636
637 test.done(); 637 test.done();
638 }; 638 };
OLDNEW
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld