Index: test/filterClasses.js |
=================================================================== |
--- a/test/filterClasses.js |
+++ b/test/filterClasses.js |
@@ -102,18 +102,18 @@ |
{ |
if (filter instanceof ElemHideFilter) |
result.push("type=elemhide"); |
else if (filter instanceof ElemHideException) |
result.push("type=elemhideexception"); |
else if (filter instanceof ElemHideEmulationFilter) |
result.push("type=elemhideemulation"); |
- result.push("selectorDomain=" + (filter.selectorDomain || "")); |
- result.push("selector=" + filter.selector); |
+ result.push("injectionDomain=" + (filter.injectionDomain || "")); |
+ result.push("code=" + filter.code); |
} |
} |
return result; |
} |
function addDefaults(expected) |
{ |
let type = null; |
@@ -152,17 +152,17 @@ |
if (type == "filterlist") |
{ |
addProperty("collapse", "null"); |
addProperty("csp", "null"); |
} |
if (type == "elemhide" || type == "elemhideexception" || |
type == "elemhideemulation") |
{ |
- addProperty("selectorDomain", ""); |
+ addProperty("injectionDomain", ""); |
addProperty("domains", ""); |
} |
} |
function compareFilter(test, text, expected, postInit) |
{ |
addDefaults(expected); |
@@ -321,62 +321,62 @@ |
compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invalid", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp"]); |
compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp=foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); |
test.done(); |
}; |
exports.testElementHidingRules = function(test) |
{ |
- compareFilter(test, "##ddd", ["type=elemhide", "text=##ddd", "selector=ddd"]); |
- compareFilter(test, "##body > div:first-child", ["type=elemhide", "text=##body > div:first-child", "selector=body > div:first-child"]); |
- compareFilter(test, "foo##ddd", ["type=elemhide", "text=foo##ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO"]); |
- compareFilter(test, "foo,bar##ddd", ["type=elemhide", "text=foo,bar##ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); |
- compareFilter(test, "foo,~bar##ddd", ["type=elemhide", "text=foo,~bar##ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); |
- compareFilter(test, "foo,~baz,bar##ddd", ["type=elemhide", "text=foo,~baz,bar##ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]); |
+ compareFilter(test, "##ddd", ["type=elemhide", "text=##ddd", "code=ddd"]); |
+ compareFilter(test, "##body > div:first-child", ["type=elemhide", "text=##body > div:first-child", "code=body > div:first-child"]); |
+ compareFilter(test, "foo##ddd", ["type=elemhide", "text=foo##ddd", "injectionDomain=foo", "code=ddd", "domains=FOO"]); |
+ compareFilter(test, "foo,bar##ddd", ["type=elemhide", "text=foo,bar##ddd", "injectionDomain=foo,bar", "code=ddd", "domains=BAR|FOO"]); |
+ compareFilter(test, "foo,~bar##ddd", ["type=elemhide", "text=foo,~bar##ddd", "injectionDomain=foo", "code=ddd", "domains=FOO|~BAR"]); |
+ compareFilter(test, "foo,~baz,bar##ddd", ["type=elemhide", "text=foo,~baz,bar##ddd", "injectionDomain=foo,bar", "code=ddd", "domains=BAR|FOO|~BAZ"]); |
test.done(); |
}; |
exports.testElementHidingExceptions = function(test) |
{ |
- compareFilter(test, "#@#ddd", ["type=elemhideexception", "text=#@#ddd", "selector=ddd"]); |
- compareFilter(test, "#@#body > div:first-child", ["type=elemhideexception", "text=#@#body > div:first-child", "selector=body > div:first-child"]); |
- compareFilter(test, "foo#@#ddd", ["type=elemhideexception", "text=foo#@#ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO"]); |
- compareFilter(test, "foo,bar#@#ddd", ["type=elemhideexception", "text=foo,bar#@#ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); |
- compareFilter(test, "foo,~bar#@#ddd", ["type=elemhideexception", "text=foo,~bar#@#ddd", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); |
- compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo,~baz,bar#@#ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]); |
+ compareFilter(test, "#@#ddd", ["type=elemhideexception", "text=#@#ddd", "code=ddd"]); |
+ compareFilter(test, "#@#body > div:first-child", ["type=elemhideexception", "text=#@#body > div:first-child", "code=body > div:first-child"]); |
+ compareFilter(test, "foo#@#ddd", ["type=elemhideexception", "text=foo#@#ddd", "injectionDomain=foo", "code=ddd", "domains=FOO"]); |
+ compareFilter(test, "foo,bar#@#ddd", ["type=elemhideexception", "text=foo,bar#@#ddd", "injectionDomain=foo,bar", "code=ddd", "domains=BAR|FOO"]); |
+ compareFilter(test, "foo,~bar#@#ddd", ["type=elemhideexception", "text=foo,~bar#@#ddd", "injectionDomain=foo", "code=ddd", "domains=FOO|~BAR"]); |
+ compareFilter(test, "foo,~baz,bar#@#ddd", ["type=elemhideexception", "text=foo,~baz,bar#@#ddd", "injectionDomain=foo,bar", "code=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)", "injectionDomain=foo.com", "code=:-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)", "injectionDomain=foo.com", "code=:-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)", "injectionDomain=foo.com", "code=:-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)", "injectionDomain=bar.com", "code=:-abp-properties(abc)", "domains=BAR.COM|~FOO.COM"]); |
// Check some special cases |
compareFilter(test, "#?#:-abp-properties(abc)", ["type=invalid", "text=#?#:-abp-properties(abc)", "reason=filter_elemhideemulation_nodomain"]); |
- compareFilter(test, "foo.com#?#abc", ["type=elemhideemulation", "text=foo.com#?#abc", "selectorDomain=foo.com", "selector=abc", "domains=FOO.COM"]); |
- compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "selectorDomain=foo.com", "selector=:-abp-foobar(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#?#abc", ["type=elemhideemulation", "text=foo.com#?#abc", "injectionDomain=foo.com", "code=abc", "domains=FOO.COM"]); |
+ compareFilter(test, "foo.com#?#:-abp-foobar(abc)", ["type=elemhideemulation", "text=foo.com#?#:-abp-foobar(abc)", "injectionDomain=foo.com", "code=:-abp-foobar(abc)", "domains=FOO.COM"]); |
+ compareFilter(test, "foo.com#?#aaa :-abp-properties(abc) bbb", ["type=elemhideemulation", "text=foo.com#?#aaa :-abp-properties(abc) bbb", "injectionDomain=foo.com", "code=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:*))", "injectionDomain=foo.com", "code=:-abp-properties(|background-image: url(data:*))", "domains=FOO.COM"]); |
// Check conversion of legacy filters |
- 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##[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com#?#:-abp-properties(abc)", "injectionDomain=foo.com", "code=:-abp-properties(abc)", "domains=FOO.COM"]); |
test.equal(Filter.fromText("foo.com##[-abp-properties='abc']"), Filter.fromText("foo.com#?#:-abp-properties(abc)")); |
- 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#?#[-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##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='abc']", ["type=elemhideexception", "text=foo.com#@#[-abp-properties='abc']", "injectionDomain=foo.com", "code=[-abp-properties='abc']", "domains=FOO.COM"]); |
+ compareFilter(test, "foo.com#?#[-abp-properties='abc']", ["type=elemhideemulation", "text=foo.com#?#[-abp-properties='abc']", "injectionDomain=foo.com", "code=[-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", "injectionDomain=foo.com", "code=aaa :-abp-properties(abc) bbb", "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"]); |
+ compareFilter(test, "foo.com##[-abp-properties-bogus='abc']", ["type=elemhide", "text=foo.com##[-abp-properties-bogus='abc']", "injectionDomain=foo.com", "code=[-abp-properties-bogus='abc']", "domains=FOO.COM"]); |
test.done(); |
}; |
exports.testEmptyElemHideDomains = function(test) |
{ |
let emptyDomainFilters = [ |
",##selector", ",,,##selector", "~,foo.com##selector", "foo.com,##selector", |
@@ -395,27 +395,27 @@ |
}; |
exports.testElemHideRulesWithBraces = function(test) |
{ |
compareFilter( |
test, "###foo{color: red}", [ |
"type=elemhide", |
"text=###foo{color: red}", |
- "selectorDomain=", |
- "selector=#foo\\7B color: red\\7D ", |
+ "injectionDomain=", |
+ "code=#foo\\7B color: red\\7D ", |
"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]\\7B 2\\7D /)", |
+ "injectionDomain=foo.com", |
+ "code=:-abp-properties(/margin: [3-4]\\7B 2\\7D /)", |
"domains=FOO.COM" |
] |
); |
test.done(); |
}; |
exports.testFilterNormalization = function(test) |
{ |