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

Side by Side Diff: test/filterClasses.js

Issue 29383960: Issue 3143 - Filter elements with :-abp-has() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Reworked patch following the feedback Created May 25, 2017, 12:58 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 | « test/browser/elemHideEmulation.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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 compareFilter(test, "foo,bar#@ddd", ["type=elemhideexception", "text=foo,bar#@ ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); 346 compareFilter(test, "foo,bar#@ddd", ["type=elemhideexception", "text=foo,bar#@ ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]);
347 compareFilter(test, "foo,~bar#@ddd", ["type=elemhideexception", "text=foo,~bar #@ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); 347 compareFilter(test, "foo,~bar#@ddd", ["type=elemhideexception", "text=foo,~bar #@ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]);
348 compareFilter(test, "foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo, ~baz,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ" ]); 348 compareFilter(test, "foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo, ~baz,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ" ]);
349 349
350 test.done(); 350 test.done();
351 }; 351 };
352 352
353 exports.testElemHideEmulationFilters = function(test) 353 exports.testElemHideEmulationFilters = function(test)
354 { 354 {
355 // Check valid domain combinations 355 // Check valid domain combinations
356 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com##[-abp-properties='abc']", "selectorDomain=foo.com", "selecto r=[-abp-properties='abc']", "domains=FOO.COM"]); 356 compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulati on", "text=foo.com##[-abp-properties='abc']", "selectorDomain=foo.com", "selecto r=:-abp-properties('abc')", "domains=FOO.COM"]);
357 compareFilter(test, "foo.com,~bar.com##[-abp-properties='abc']", ["type=elemhi deemulation", "text=foo.com,~bar.com##[-abp-properties='abc']", "selectorDomain= foo.com", "selector=[-abp-properties='abc']", "domains=FOO.COM|~BAR.COM"]); 357 compareFilter(test, "foo.com,~bar.com##[-abp-properties='abc']", ["type=elemhi deemulation", "text=foo.com,~bar.com##[-abp-properties='abc']", "selectorDomain= foo.com", "selector=:-abp-properties('abc')", "domains=FOO.COM|~BAR.COM"]);
358 compareFilter(test, "foo.com,~bar##[-abp-properties='abc']", ["type=elemhideem ulation", "text=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com" , "selector=[-abp-properties='abc']", "domains=FOO.COM|~BAR"]); 358 compareFilter(test, "foo.com,~bar##[-abp-properties='abc']", ["type=elemhideem ulation", "text=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com" , "selector=:-abp-properties('abc')", "domains=FOO.COM|~BAR"]);
359 compareFilter(test, "~foo.com,bar.com##[-abp-properties='abc']", ["type=elemhi deemulation", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain= bar.com", "selector=[-abp-properties='abc']", "domains=BAR.COM|~FOO.COM"]); 359 compareFilter(test, "~foo.com,bar.com##[-abp-properties='abc']", ["type=elemhi deemulation", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain= bar.com", "selector=:-abp-properties('abc')", "domains=BAR.COM|~FOO.COM"]);
360 360
361 compareFilter(test, "##[-abp-properties='']", ["type=invalid", "text=##[-abp-p roperties='']", "reason=filter_elemhideemulation_nodomain"]); 361 compareFilter(test, "##[-abp-properties='']", ["type=invalid", "text=##[-abp-p roperties='']", "reason=filter_elemhideemulation_nodomain"]);
362 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"]); 362 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"]);
363 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=fo o.com", "selector=aaa [-abp-properties='abc'] bbb", "domains=FOO.COM"]); 363 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhid eemulation", "text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=fo o.com", "selector=aaa :-abp-properties('abc') bbb", "domains=FOO.COM"]);
364 compareFilter(test, "foo.com##[-abp-properties='|background-image: url(data:*) ']", ["type=elemhideemulation", "text=foo.com##[-abp-properties='|background-ima ge: url(data:*)']", "selectorDomain=foo.com", "selector=[-abp-properties='|backg round-image: url(data:*)']", "domains=FOO.COM"]); 364 compareFilter(test, "foo.com##[-abp-properties='|background-image: url(data:*) ']", ["type=elemhideemulation", "text=foo.com##[-abp-properties='|background-ima ge: url(data:*)']", "selectorDomain=foo.com", "selector=:-abp-properties('|backg round-image: url(data:*)')", "domains=FOO.COM"]);
365 365
366 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) . 366 // test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037) .
367 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"]); 367 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"]);
368 368
369 // Check extended CSS filter
370 compareFilter(test, "~foo.com,bar.com##[-abp-selector=':-abp-has(div > span)'] ", ["type=elemhideemulation", "text=~foo.com,bar.com##[-abp-selector=':-abp-has( div > span)']", "selectorDomain=bar.com", "selector=:-abp-has(div > span)", "dom ains=BAR.COM|~FOO.COM"]);
371 compareFilter(test, "##[-abp-selector=':-abp-has(div > span)']", ["type=invali d", "text=##[-abp-selector=':-abp-has(div > span)']", "reason=filter_elemhideemu lation_nodomain"]);
372
369 test.done(); 373 test.done();
370 }; 374 };
371 375
372 exports.testEmptyElemHideDomains = function(test) 376 exports.testEmptyElemHideDomains = function(test)
373 { 377 {
374 let emptyDomainFilters = [ 378 let emptyDomainFilters = [
375 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector", 379 ",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector",
376 ",foo.com##selector", "foo.com,~##selector", 380 ",foo.com##selector", "foo.com,~##selector",
377 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector" 381 "foo.com,,bar.com##selector", "foo.com,~,bar.com##selector"
378 ]; 382 ];
(...skipping 17 matching lines...) Expand all
396 "selectorDomain=", 400 "selectorDomain=",
397 "selector=#foo\\x7B color: red\\x7D ", 401 "selector=#foo\\x7B color: red\\x7D ",
398 "domains=" 402 "domains="
399 ] 403 ]
400 ); 404 );
401 compareFilter( 405 compareFilter(
402 test, "foo.com##[-abp-properties='/margin: [3-4]{2}/']", [ 406 test, "foo.com##[-abp-properties='/margin: [3-4]{2}/']", [
403 "type=elemhideemulation", 407 "type=elemhideemulation",
404 "text=foo.com##[-abp-properties='/margin: [3-4]{2}/']", 408 "text=foo.com##[-abp-properties='/margin: [3-4]{2}/']",
405 "selectorDomain=foo.com", 409 "selectorDomain=foo.com",
406 "selector=[-abp-properties='/margin: [3-4]\\x7B 2\\x7D /']", 410 "selector=:-abp-properties('/margin: [3-4]\\x7B 2\\x7D /')",
407 "domains=FOO.COM" 411 "domains=FOO.COM"
408 ] 412 ]
409 ); 413 );
410 test.done(); 414 test.done();
411 }; 415 };
OLDNEW
« no previous file with comments | « test/browser/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld