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

Unified Diff: test/filterClasses.js

Issue 29383960: Issue 3143 - Filter elements with :-abp-has() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Added validate of element id, and fixed an infinite recursion in parsing. Created May 15, 2017, 6:10 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/filterClasses.js ('K') | « test/browser/elemHideEmulation.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/filterClasses.js
===================================================================
--- a/test/filterClasses.js
+++ b/test/filterClasses.js
@@ -348,29 +348,33 @@
compareFilter(test, "foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo,~baz,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]);
test.done();
};
exports.testElemHideEmulationFilters = function(test)
{
// Check valid domain combinations
- compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=[-abp-properties='abc']", "domains=FOO.COM"]);
- compareFilter(test, "foo.com,~bar.com##[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com,~bar.com##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=[-abp-properties='abc']", "domains=FOO.COM|~BAR.COM"]);
- compareFilter(test, "foo.com,~bar##[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=[-abp-properties='abc']", "domains=FOO.COM|~BAR"]);
- compareFilter(test, "~foo.com,bar.com##[-abp-properties='abc']", ["type=elemhideemulation", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain=bar.com", "selector=[-abp-properties='abc']", "domains=BAR.COM|~FOO.COM"]);
+ compareFilter(test, "foo.com##[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=:-abp-properties('abc')", "domains=FOO.COM"]);
+ compareFilter(test, "foo.com,~bar.com##[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com,~bar.com##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=:-abp-properties('abc')", "domains=FOO.COM|~BAR.COM"]);
+ compareFilter(test, "foo.com,~bar##[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=:-abp-properties('abc')", "domains=FOO.COM|~BAR"]);
+ compareFilter(test, "~foo.com,bar.com##[-abp-properties='abc']", ["type=elemhideemulation", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain=bar.com", "selector=:-abp-properties('abc')", "domains=BAR.COM|~FOO.COM"]);
compareFilter(test, "##[-abp-properties='']", ["type=invalid", "text=##[-abp-properties='']", "reason=filter_elemhideemulation_nodomain"]);
- compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexception", "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selector=[-abp-properties='abc']", "domains=FOO.COM"]);
- compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhideemulation", "text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=foo.com", "selector=aaa [-abp-properties='abc'] bbb", "domains=FOO.COM"]);
- compareFilter(test, "foo.com##[-abp-properties='|background-image: url(data:*)']", ["type=elemhideemulation", "text=foo.com##[-abp-properties='|background-image: url(data:*)']", "selectorDomain=foo.com", "selector=[-abp-properties='|background-image: url(data:*)']", "domains=FOO.COM"]);
+ compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexception", "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selector=:-abp-properties('abc')", "domains=FOO.COM"]);
+ compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=elemhideemulation", "text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=foo.com", "selector=aaa :-abp-properties('abc') bbb", "domains=FOO.COM"]);
+ compareFilter(test, "foo.com##[-abp-properties='|background-image: url(data:*)']", ["type=elemhideemulation", "text=foo.com##[-abp-properties='|background-image: url(data:*)']", "selectorDomain=foo.com", "selector=:-abp-properties('|background-image: url(data:*)')", "domains=FOO.COM"]);
// test matching -abp-properties= (https://issues.adblockplus.org/ticket/5037).
compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide", "text=foo.com##[-abp-properties-bogus='abc']", "selectorDomain=foo.com", "selector=[-abp-properties-bogus='abc']", "domains=FOO.COM"]);
+ // Check extended CSS filter
+ 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)", "domains=BAR.COM|~FOO.COM"]);
+ compareFilter(test, "##[-abp-selector=':-abp-has(div > span)']", ["type=invalid", "text=##[-abp-selector=':-abp-has(div > span)']", "reason=filter_elemhideemulation_nodomain"]);
+
test.done();
};
exports.testEmptyElemHideDomains = function(test)
{
let emptyDomainFilters = [
",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector",
",foo.com##selector", "foo.com,~##selector",
@@ -398,14 +402,14 @@
"domains="
]
);
compareFilter(
test, "foo.com##[-abp-properties='/margin: [3-4]{2}/']", [
"type=elemhideemulation",
"text=foo.com##[-abp-properties='/margin: [3-4]{2}/']",
"selectorDomain=foo.com",
- "selector=[-abp-properties='/margin: [3-4]\\x7B 2\\x7D /']",
+ "selector=:-abp-properties('/margin: [3-4]\\x7B 2\\x7D /')",
"domains=FOO.COM"
]
);
test.done();
};
« lib/filterClasses.js ('K') | « test/browser/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld