Index: test/elemHideEmulation.js |
=================================================================== |
--- a/test/elemHideEmulation.js |
+++ b/test/elemHideEmulation.js |
@@ -133,16 +133,33 @@ |
0, selectors => |
test.equal(selectors.selectorCount, 2))( |
elemHide.getSelectorsForDomain("example.com", 0)); |
})(ElemHide.create()); |
test.done(); |
}; |
+exports.testSyntaxConversion = function(test) |
+{ |
+ function checkConvertedFilter(old, converted) |
+ { |
+ let filter = Filter.fromText(old); |
sergei
2018/01/30 19:02:40
`filter` should be released.
hub
2018/01/30 22:53:13
Done.
|
+ |
+ test.equal(filter.text, converted); |
+ } |
+ |
+ checkConvertedFilter("example.com#?#foo[-abp-properties='something']bar", "example.com#?#foo:-abp-properties(something)bar"); |
+ checkConvertedFilter("example.com#@#foo[-abp-properties='something']bar", "example.com#@#foo:-abp-properties(something)bar"); |
+ checkConvertedFilter("example.com#?#[-abp-properties=\"something\"]", "example.com#?#:-abp-properties(something)"); |
+ checkConvertedFilter("example.com#?#[-abp-properties=(something)]", "example.com#?#:-abp-properties((something))"); |
+ |
+ test.done(); |
+}; |
+ |
exports.testDomainRestrictions = function(test) |
{ |
function testSelectorMatches(description, filters, domain, expectedMatches) |
{ |
withNAD([0, 1], (elemHide, elemHideEmulation) => |
{ |
let addFilter = withNAD(0, filter => |
{ |
@@ -168,57 +185,57 @@ |
elemHideEmulation.clear(); |
})(ElemHide.create(), ElemHideEmulation.create()); |
} |
testSelectorMatches( |
"Ignore generic filters", |
[ |
- "##[-abp-properties='foo']", "example.com##[-abp-properties='foo']", |
- "~example.com##[-abp-properties='foo']" |
+ "#?#:-abp-properties(foo)", "example.com#?#:-abp-properties(foo)", |
+ "~example.com##:-abp-properties(foo)" |
], |
"example.com", |
- ["example.com##[-abp-properties='foo']"] |
+ ["example.com#?#:-abp-properties(foo)"] |
); |
testSelectorMatches( |
"Ignore selectors with exceptions", |
[ |
- "example.com##[-abp-properties='foo']", |
- "example.com##[-abp-properties='bar']", |
- "example.com#@#[-abp-properties='foo']" |
+ "example.com#?#:-abp-properties(foo)", |
+ "example.com#?#:-abp-properties(bar)", |
+ "example.com#@#:-abp-properties(foo)" |
], |
"example.com", |
- ["example.com##[-abp-properties='bar']"] |
+ ["example.com#?#:-abp-properties(bar)"] |
); |
testSelectorMatches( |
"Ignore filters that include parent domain but exclude subdomain", |
[ |
- "~www.example.com,example.com##[-abp-properties='foo']" |
+ "~www.example.com,example.com#?#:-abp-properties(foo)" |
], |
"www.example.com", |
[] |
); |
testSelectorMatches( |
"Ignore filters with parent domain if exception matches subdomain", |
[ |
- "www.example.com#@#[-abp-properties='foo']", |
- "example.com##[-abp-properties='foo']" |
+ "www.example.com#@#:-abp-properties(foo)", |
+ "example.com#?#:-abp-properties(foo)" |
], |
"www.example.com", |
[] |
); |
testSelectorMatches( |
"Ignore filters for other subdomain", |
[ |
- "www.example.com##[-abp-properties='foo']", |
- "other.example.com##[-abp-properties='foo']" |
+ "www.example.com#?#:-abp-properties(foo)", |
+ "other.example.com#?#:-abp-properties(foo)" |
], |
"other.example.com", |
- ["other.example.com##[-abp-properties='foo']"] |
+ ["other.example.com#?#:-abp-properties(foo)"] |
); |
test.done(); |
}; |
exports.testElemHideEmulationFiltersContainer = function(test) |
{ |
withNAD([0, 1], (elemHide, elemHideEmulation) => |