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

Unified Diff: test/elemHideEmulation.js

Issue 29595633: Issue 5870 - Implement the new ElemHideEmulation filter type (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebased patch. Fix assertion. Created Nov. 27, 2017, 3:13 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
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | test/filterClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/elemHideEmulation.js
===================================================================
--- a/test/elemHideEmulation.js
+++ b/test/elemHideEmulation.js
@@ -112,16 +112,33 @@
filter3.delete();
selectors = ElemHide.getSelectorsForDomain("example.com", 0);
test.equal(selectors.selectorCount, 2);
selectors.delete();
test.done();
};
+exports.testSyntaxConversion = function(test)
+{
+ function checkConvertedFilter(old, converted)
+ {
+ let filter = Filter.fromText(old);
+
+ 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)
{
for (let text of filters)
{
let filter = Filter.fromText(text);
if (filter instanceof ElemHideEmulationFilter)
@@ -144,57 +161,57 @@
ElemHideEmulation.clear();
ElemHide.clear();
}
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)
{
function compareRules(description, domain, expectedMatches)
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld