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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29800595: Issue 6735 - Store domains in lower case (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebase Created June 7, 2018, 10:17 a.m.
Right Patch Set: Disallow missing values in domain, sitekey, and rewrite Created June 8, 2018, 2:16 p.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
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 compareFilter(test, "@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d /", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); 284 compareFilter(test, "@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d /", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]);
285 compareFilter(test, "@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*" , "regexp=asdf.*d.*dd", "contentType=" + defaultTypes]); 285 compareFilter(test, "@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*" , "regexp=asdf.*d.*dd", "contentType=" + defaultTypes]);
286 compareFilter(test, "@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d* *dd*|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]); 286 compareFilter(test, "@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d* *dd*|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]);
287 compareFilter(test, "@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>& ()d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTyp es]); 287 compareFilter(test, "@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>& ()d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTyp es]);
288 288
289 test.done(); 289 test.done();
290 }; 290 };
291 291
292 exports.testFilterOptions = function(test) 292 exports.testFilterOptions = function(test)
293 { 293 {
294 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"]); 294 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"]);
295 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"]); 295 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"]);
296 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"]); 296 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"]);
297 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"]); 297 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"]);
298 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))]); 298 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))]);
299 299
300 // background and image should be the same for backwards compatibility 300 // background and image should be the same for backwards compatibility
301 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp =bla", "contentType=" + (t.IMAGE)]); 301 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp =bla", "contentType=" + (t.IMAGE)]);
302 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background ", "regexp=bla", "contentType=" + (t.IMAGE)]); 302 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background ", "regexp=bla", "contentType=" + (t.IMAGE)]);
303 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "rege xp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); 303 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "rege xp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]);
304 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou nd", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); 304 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou nd", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]);
305 305
306 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc ript,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE R))]); 306 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc ript,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE R))]);
(...skipping 20 matching lines...) Expand all
327 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]); 327 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp "]);
328 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); 328 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp =foo,csp=ReFeRReR", "reason=filter_invalid_csp"]);
329 329
330 test.done(); 330 test.done();
331 }; 331 };
332 332
333 exports.testElementHidingRules = function(test) 333 exports.testElementHidingRules = function(test)
334 { 334 {
335 compareFilter(test, "##ddd", ["type=elemhide", "text=##ddd", "selector=ddd"]); 335 compareFilter(test, "##ddd", ["type=elemhide", "text=##ddd", "selector=ddd"]);
336 compareFilter(test, "##body > div:first-child", ["type=elemhide", "text=##body > div:first-child", "selector=body > div:first-child"]); 336 compareFilter(test, "##body > div:first-child", ["type=elemhide", "text=##body > div:first-child", "selector=body > div:first-child"]);
337 compareFilter(test, "foo##ddd", ["type=elemhide", "text=foo##ddd", "selectorDo mains=foo", "selector=ddd", "domains=foo"]); 337 compareFilter(test, "fOO##ddd", ["type=elemhide", "text=fOO##ddd", "selectorDo mains=foo", "selector=ddd", "domains=foo"]);
338 compareFilter(test, "foo,bar##ddd", ["type=elemhide", "text=foo,bar##ddd", "se lectorDomains=foo,bar", "selector=ddd", "domains=bar|foo"]); 338 compareFilter(test, "Foo,bAr##ddd", ["type=elemhide", "text=Foo,bAr##ddd", "se lectorDomains=foo,bar", "selector=ddd", "domains=bar|foo"]);
339 compareFilter(test, "foo,~bar##ddd", ["type=elemhide", "text=foo,~bar##ddd", " selectorDomains=foo", "selector=ddd", "domains=foo|~bar"]); 339 compareFilter(test, "foo,~baR##ddd", ["type=elemhide", "text=foo,~baR##ddd", " selectorDomains=foo", "selector=ddd", "domains=foo|~bar"]);
340 compareFilter(test, "foo,~baz,bar##ddd", ["type=elemhide", "text=foo,~baz,bar# #ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo|~baz"]); 340 compareFilter(test, "foo,~baz,bar##ddd", ["type=elemhide", "text=foo,~baz,bar# #ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo|~baz"]);
341 341
342 test.done(); 342 test.done();
343 }; 343 };
344 344
345 exports.testElementHidingExceptions = function(test) 345 exports.testElementHidingExceptions = function(test)
346 { 346 {
347 compareFilter(test, "#@#ddd", ["type=elemhideexception", "text=#@#ddd", "selec tor=ddd"]); 347 compareFilter(test, "#@#ddd", ["type=elemhideexception", "text=#@#ddd", "selec tor=ddd"]);
348 compareFilter(test, "#@#body > div:first-child", ["type=elemhideexception", "t ext=#@#body > div:first-child", "selector=body > div:first-child"]); 348 compareFilter(test, "#@#body > div:first-child", ["type=elemhideexception", "t ext=#@#body > div:first-child", "selector=body > div:first-child"]);
349 compareFilter(test, "foo#@#ddd", ["type=elemhideexception", "text=foo#@#ddd", "selectorDomains=foo", "selector=ddd", "domains=foo"]); 349 compareFilter(test, "fOO#@#ddd", ["type=elemhideexception", "text=fOO#@#ddd", "selectorDomains=foo", "selector=ddd", "domains=foo"]);
350 compareFilter(test, "foo,bar#@#ddd", ["type=elemhideexception", "text=foo,bar# @#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo"]); 350 compareFilter(test, "Foo,bAr#@#ddd", ["type=elemhideexception", "text=Foo,bAr# @#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo"]);
351 compareFilter(test, "foo,~bar#@#ddd", ["type=elemhideexception", "text=foo,~ba r#@#ddd", "selectorDomains=foo", "selector=ddd", "domains=foo|~bar"]); 351 compareFilter(test, "foo,~baR#@#ddd", ["type=elemhideexception", "text=foo,~ba R#@#ddd", "selectorDomains=foo", "selector=ddd", "domains=foo|~bar"]);
352 compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo ,~baz,bar#@#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo|~b az"]); 352 compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo ,~baz,bar#@#ddd", "selectorDomains=foo,bar", "selector=ddd", "domains=bar|foo|~b az"]);
353 353
354 test.done(); 354 test.done();
355 }; 355 };
356 356
357 exports.testElemHideEmulationFilters = function(test) 357 exports.testElemHideEmulationFilters = function(test)
358 { 358 {
359 // Check valid domain combinations 359 // Check valid domain combinations
360 compareFilter(test, "foo.com#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=foo.com#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector =:-abp-properties(abc)", "domains=foo.com"]); 360 compareFilter(test, "fOO.cOm#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=fOO.cOm#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector =:-abp-properties(abc)", "domains=foo.com"]);
361 compareFilter(test, "foo.com,~bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=foo.com,~bar.com#?#:-abp-properties(abc)", "selectorDomains=f oo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar.com"]); 361 compareFilter(test, "Foo.com,~bAr.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=Foo.com,~bAr.com#?#:-abp-properties(abc)", "selectorDomains=f oo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar.com"]);
362 compareFilter(test, "foo.com,~bar#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~bar#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar"]); 362 compareFilter(test, "foo.com,~baR#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~baR#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selector=:-abp-properties(abc)", "domains=foo.com|~bar"]);
363 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "selectorDomains=b ar.com", "selector=:-abp-properties(abc)", "domains=bar.com|~foo.com"]); 363 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "selectorDomains=b ar.com", "selector=:-abp-properties(abc)", "domains=bar.com|~foo.com"]);
364 364
365 // Check some special cases 365 // Check some special cases
366 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]); 366 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]);
367 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomains=foo.com", "selector=abc", "domains=foo.com"]); 367 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomains=foo.com", "selector=abc", "domains=foo.com"]);
368 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomains=foo.com", "selector=:-abp-f oobar(abc)", "domains=foo.com"]); 368 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomains=foo.com", "selector=:-abp-f oobar(abc)", "domains=foo.com"]);
369 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomains=foo .com", "selector=aaa :-abp-properties(abc) bbb", "domains=foo.com"]); 369 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomains=foo .com", "selector=aaa :-abp-properties(abc) bbb", "domains=foo.com"]);
370 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "selectorDomains=foo.com", "selector=:-abp-properties(|backgro und-image: url(data:*))", "domains=foo.com"]); 370 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "selectorDomains=foo.com", "selector=:-abp-properties(|backgro und-image: url(data:*))", "domains=foo.com"]);
371 371
372 // Check conversion of legacy filters 372 // Check conversion of legacy filters
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 filterRelative.rewriteUrl("http://content.server/file/foo.txt?bar"), 541 filterRelative.rewriteUrl("http://content.server/file/foo.txt?bar"),
542 "http://content.server/file/foo.txt/disable" 542 "http://content.server/file/foo.txt/disable"
543 ); 543 );
544 test.equal( 544 test.equal(
545 filterRelative.rewriteUrl("http://example.com/file/foo.txt?bar"), 545 filterRelative.rewriteUrl("http://example.com/file/foo.txt?bar"),
546 "http://example.com/file/foo.txt/disable" 546 "http://example.com/file/foo.txt/disable"
547 ); 547 );
548 548
549 test.done(); 549 test.done();
550 }; 550 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld