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

Side by Side Diff: test/filterClasses.js

Issue 29464708: Issue 5314 - Allow hide emulation filters to be with a plain selector (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Updated the logic Created June 19, 2017, 1:36 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
« 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 exports.testElemHideEmulationFilters = function(test) 341 exports.testElemHideEmulationFilters = function(test)
342 { 342 {
343 // Check valid domain combinations 343 // Check valid domain combinations
344 compareFilter(test, "foo.com#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=foo.com#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector= :-abp-properties(abc)", "domains=FOO.COM"]); 344 compareFilter(test, "foo.com#?#:-abp-properties(abc)", ["type=elemhideemulatio n", "text=foo.com#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector= :-abp-properties(abc)", "domains=FOO.COM"]);
345 compareFilter(test, "foo.com,~bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=foo.com,~bar.com#?#:-abp-properties(abc)", "selectorDomain=fo o.com", "selector=:-abp-properties(abc)", "domains=FOO.COM|~BAR.COM"]); 345 compareFilter(test, "foo.com,~bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=foo.com,~bar.com#?#:-abp-properties(abc)", "selectorDomain=fo o.com", "selector=:-abp-properties(abc)", "domains=FOO.COM|~BAR.COM"]);
346 compareFilter(test, "foo.com,~bar#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~bar#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector=:-abp-properties(abc)", "domains=FOO.COM|~BAR"]); 346 compareFilter(test, "foo.com,~bar#?#:-abp-properties(abc)", ["type=elemhideemu lation", "text=foo.com,~bar#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector=:-abp-properties(abc)", "domains=FOO.COM|~BAR"]);
347 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "selectorDomain=ba r.com", "selector=:-abp-properties(abc)", "domains=BAR.COM|~FOO.COM"]); 347 compareFilter(test, "~foo.com,bar.com#?#:-abp-properties(abc)", ["type=elemhid eemulation", "text=~foo.com,bar.com#?#:-abp-properties(abc)", "selectorDomain=ba r.com", "selector=:-abp-properties(abc)", "domains=BAR.COM|~FOO.COM"]);
348 348
349 // Check some special cases 349 // Check some special cases
350 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]); 350 compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-ab p-properties(abc)", "reason=filter_elemhideemulation_nodomain"]);
351 compareFilter(test, "foo.com#?#abc", ["type=invalid", "text=foo.com#?#abc", "r eason=filter_elemhideemulation_plainselector"]); 351 compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com# ?#abc", "selectorDomain=foo.com", "selector=abc", "domains=FOO.COM"]);
352 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomain=foo.com", "selector=:-abp-fo obar(abc)", "domains=FOO.COM"]); 352 compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomain=foo.com", "selector=:-abp-fo obar(abc)", "domains=FOO.COM"]);
353 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomain=foo. com", "selector=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]); 353 compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhide emulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomain=foo. com", "selector=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]);
354 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "selectorDomain=foo.com", "selector=:-abp-properties(|backgrou nd-image: url(data:*))", "domains=FOO.COM"]); 354 compareFilter(test, "foo.com#?#:-abp-properties(|background-image: url(data:*) )", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(|background-imag e: url(data:*))", "selectorDomain=foo.com", "selector=:-abp-properties(|backgrou nd-image: url(data:*))", "domains=FOO.COM"]);
355 355
356 // Check conversion of legacy filters 356 // Check conversion of legacy filters
357 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector =:-abp-properties(abc)", "domains=FOO.COM"]); 357 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com#?#:-abp-properties(abc)", "selectorDomain=foo.com", "selector =:-abp-properties(abc)", "domains=FOO.COM"]);
358 test.equal(Filter.fromText("foo.com##[-abp-properties='abc']"), Filter.fromTex t("foo.com#?#:-abp-properties(abc)")); 358 test.equal(Filter.fromText("foo.com##[-abp-properties='abc']"), Filter.fromTex t("foo.com#?#:-abp-properties(abc)"));
359 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept ion", "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selec tor=[-abp-properties='abc']", "domains=FOO.COM"]); 359 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept ion", "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selec tor=[-abp-properties='abc']", "domains=FOO.COM"]);
360 compareFilter(test, "foo.com#?#[-abp-properties='abc']", ["type=invalid", "tex t=foo.com#?#[-abp-properties='abc']", "reason=filter_elemhideemulation_plainsele ctor"]); 360 compareFilter(test, "foo.com#?#[-abp-properties='abc']", ["type=elemhideemulat ion", "text=foo.com#?#[-abp-properties='abc']", "selectorDomain=foo.com", "selec tor=[-abp-properties='abc']", "domains=FOO.COM"]);
361 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomain=foo .com", "selector=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]); 361 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "selectorDomain=foo .com", "selector=aaa :-abp-properties(abc) bbb", "domains=FOO.COM"]);
362 362
363 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) . 363 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) .
364 compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide" , "text=foo.com##[-abp-properties-bogus='abc']", "selectorDomain=foo.com", "sele ctor=[-abp-properties-bogus='abc']", "domains=FOO.COM"]); 364 compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide" , "text=foo.com##[-abp-properties-bogus='abc']", "selectorDomain=foo.com", "sele ctor=[-abp-properties-bogus='abc']", "domains=FOO.COM"]);
365 365
366 test.done(); 366 test.done();
367 }; 367 };
368 368
369 exports.testEmptyElemHideDomains = function(test) 369 exports.testEmptyElemHideDomains = function(test)
370 { 370 {
(...skipping 28 matching lines...) Expand all
399 test, "foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", [ 399 test, "foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", [
400 "type=elemhideemulation", 400 "type=elemhideemulation",
401 "text=foo.com#?#:-abp-properties(/margin: [3-4]{2}/)", 401 "text=foo.com#?#:-abp-properties(/margin: [3-4]{2}/)",
402 "selectorDomain=foo.com", 402 "selectorDomain=foo.com",
403 "selector=:-abp-properties(/margin: [3-4]\\x7B 2\\x7D /)", 403 "selector=:-abp-properties(/margin: [3-4]\\x7B 2\\x7D /)",
404 "domains=FOO.COM" 404 "domains=FOO.COM"
405 ] 405 ]
406 ); 406 );
407 test.done(); 407 test.done();
408 }; 408 };
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