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

Side by Side Diff: test/filterClasses.js

Issue 29800595: Issue 6735 - Store domains in lower case (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase Created June 7, 2018, 10:17 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
« no previous file with comments | « 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 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))]);
307 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@ http://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (default Types & ~(t.SCRIPT | t.OTHER))]); 307 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@ http://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (default Types & ~(t.SCRIPT | t.OTHER))]);
(...skipping 19 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
373 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selecto r=:-abp-properties(abc)", "domains=FOO.COM"]); 373 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com#?#:-abp-properties(abc)", "selectorDomains=foo.com", "selecto r=:-abp-properties(abc)", "domains=foo.com"]);
374 test.equal(Filter.fromText("foo.com##[-abp-properties='abc']"), Filter.fromTex t("foo.com#?#:-abp-properties(abc)")); 374 test.equal(Filter.fromText("foo.com##[-abp-properties='abc']"), Filter.fromTex t("foo.com#?#:-abp-properties(abc)"));
375 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept ion", "text=foo.com#@#[-abp-properties='abc']", "selectorDomains=foo.com", "sele ctor=[-abp-properties='abc']", "domains=FOO.COM"]); 375 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept ion", "text=foo.com#@#[-abp-properties='abc']", "selectorDomains=foo.com", "sele ctor=[-abp-properties='abc']", "domains=foo.com"]);
376 compareFilter(test, "foo.com#?#[-abp-properties='abc']", ["type=elemhideemulat ion", "text=foo.com#?#[-abp-properties='abc']", "selectorDomains=foo.com", "sele ctor=[-abp-properties='abc']", "domains=FOO.COM"]); 376 compareFilter(test, "foo.com#?#[-abp-properties='abc']", ["type=elemhideemulat ion", "text=foo.com#?#[-abp-properties='abc']", "selectorDomains=foo.com", "sele ctor=[-abp-properties='abc']", "domains=foo.com"]);
377 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomains=fo o.com", "selector=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]); 377 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomains=fo o.com", "selector=aaa :-abp-properties(abc) bbb", "domains=foo.com"]);
378 378
379 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) . 379 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) .
380 compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide" , "text=foo.com##[-abp-properties-bogus='abc']", "selectorDomains=foo.com", "sel ector=[-abp-properties-bogus='abc']", "domains=FOO.COM"]); 380 compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide" , "text=foo.com##[-abp-properties-bogus='abc']", "selectorDomains=foo.com", "sel ector=[-abp-properties-bogus='abc']", "domains=foo.com"]);
381 381
382 test.done(); 382 test.done();
383 }; 383 };
384 384
385 exports.testEmptyElemHideDomains = function(test) 385 exports.testEmptyElemHideDomains = function(test)
386 { 386 {
387 let emptyDomainFilters = [ 387 let emptyDomainFilters = [
388 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector", 388 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector",
389 ",foo.com##selector", "foo.com,~##selector", 389 ",foo.com##selector", "foo.com,~##selector",
390 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector" 390 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector"
(...skipping 19 matching lines...) Expand all
410 "selector=#foo\\7B color: red\\7D ", 410 "selector=#foo\\7B color: red\\7D ",
411 "domains=" 411 "domains="
412 ] 412 ]
413 ); 413 );
414 compareFilter( 414 compareFilter(
415 test, "foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", [ 415 test, "foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", [
416 "type=elemhideemulation", 416 "type=elemhideemulation",
417 "text=foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", 417 "text=foo.com#?#:-abp-properties(/margin: [3-4]{2}/)",
418 "selectorDomains=foo.com", 418 "selectorDomains=foo.com",
419 "selector=:-abp-properties(/margin: [3-4]\\7B 2\\7D /)", 419 "selector=:-abp-properties(/margin: [3-4]\\7B 2\\7D /)",
420 "domains=FOO.COM" 420 "domains=foo.com"
421 ] 421 ]
422 ); 422 );
423 test.done(); 423 test.done();
424 }; 424 };
425 425
426 exports.testFilterNormalization = function(test) 426 exports.testFilterNormalization = function(test)
427 { 427 {
428 // Line breaks etc 428 // Line breaks etc
429 test.equal(Filter.normalize("\n\t\nad\ns"), 429 test.equal(Filter.normalize("\n\t\nad\ns"),
430 "ads"); 430 "ads");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 ); 468 );
469 test.equal( 469 test.equal(
470 normalized, 470 normalized,
471 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p" 471 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p"
472 ); 472 );
473 compareFilter( 473 compareFilter(
474 test, normalized, [ 474 test, normalized, [
475 "type=filterlist", 475 "type=filterlist",
476 "text=" + normalized, 476 "text=" + normalized,
477 "csp=c s p", 477 "csp=c s p",
478 "domains=DOMAIN.COM|FOO.COM", 478 "domains=domain.com|foo.com",
479 "sitekeys=FOO", 479 "sitekeys=FOO",
480 "regexp=b\\$la", 480 "regexp=b\\$la",
481 "contentType=" + t.CSP 481 "contentType=" + t.CSP
482 ] 482 ]
483 ); 483 );
484 484
485 // Some $csp edge cases 485 // Some $csp edge cases
486 test.equal(Filter.normalize("$csp= c s p"), 486 test.equal(Filter.normalize("$csp= c s p"),
487 "$csp=c s p"); 487 "$csp=c s p");
488 test.equal(Filter.normalize("$$csp= c s p"), 488 test.equal(Filter.normalize("$$csp= c s p"),
(...skipping 52 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 };
OLDNEW
« no previous file with comments | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld