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

Unified Diff: test/filterClasses.js

Issue 29595633: Issue 5870 - Implement the new ElemHideEmulation filter type (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: properly handle exception filters. some test fixes. Created Nov. 3, 2017, 5:02 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 | « test/elemHideEmulation.js ('k') | test/subscriptionClasses.js » ('j') | 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
@@ -70,34 +70,32 @@
["foobar##asdf{asdf}", BlockingFilter, "blocking"],
["foobar##", BlockingFilter, "blocking"],
["foobar#@#", BlockingFilter, "blocking"],
["asdf$foobar", InvalidFilter, "invalid"],
["asdf$image,foobar", InvalidFilter, "invalid"],
["asdf$image=foobar", BlockingFilter, "blocking"],
["asdf$image=foobar=xyz,~collapse", BlockingFilter, "blocking"],
- ["##foo[-abp-properties='something']bar", InvalidFilter, "invalid"],
- ["#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexception"],
- ["example.com##foo[-abp-properties='something']bar", ElemHideEmulationFilter, "elemhideemulation"],
- ["example.com#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexception"],
- ["~example.com##foo[-abp-properties='something']bar", InvalidFilter, "invalid"],
- ["~example.com#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexception"],
- ["~example.com,~example.info##foo[-abp-properties='something']bar", InvalidFilter, "invalid"],
- ["~example.com,~example.info#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexception"],
- ["~sub.example.com,example.com##foo[-abp-properties='something']bar", ElemHideEmulationFilter, "elemhideemulation"],
- ["~sub.example.com,example.com#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexception"],
- ["example.com,~sub.example.com##foo[-abp-properties='something']bar", ElemHideEmulationFilter, "elemhideemulation"],
- ["example.com,~sub.example.com#@#foo[-abp-properties='something']bar", ElemHideException, "elemhideexception"],
- ["example.com##[-abp-properties='something']", ElemHideEmulationFilter, "elemhideemulation"],
- ["example.com#@#[-abp-properties='something']", ElemHideException, "elemhideexception"],
- ["example.com##[-abp-properties=\"something\"]", ElemHideEmulationFilter, "elemhideemulation"],
- ["example.com#@#[-abp-properties=\"something\"]", ElemHideException, "elemhideexception"],
- ["example.com##[-abp-properties=(something)]", ElemHideEmulationFilter, "elemhideemulation"],
- ["example.com#@#[-abp-properties=(something)]", ElemHideException, "elemhideexception"]
+ ["#?#foo:-abp-properties(something)bar", InvalidFilter, "invalid"],
+ ["#@#foo:-abp-properties(something)bar", ElemHideException, "elemhideexception"],
+ ["example.com#?#foo:-abp-properties(something)bar", ElemHideEmulationFilter, "elemhideemulation"],
+ ["example.com#@#foo:-abp-properties(something)bar", ElemHideException, "elemhideexception"],
+ ["~example.com#?#foo:-abp-properties(something)bar", InvalidFilter, "invalid"],
+ ["~example.com#@#foo:-abp-properties(something)bar", ElemHideException, "elemhideexception"],
+ ["~example.com,~example.info#?#foo:-abp-properties(something)bar", InvalidFilter, "invalid"],
+ ["~example.com,~example.info#@#foo:-abp-properties(something)bar", ElemHideException, "elemhideexception"],
+ ["~sub.example.com,example.com#?#foo:-abp-properties(something)bar", ElemHideEmulationFilter, "elemhideemulation"],
+ ["~sub.example.com,example.com#@#foo:-abp-properties(something)bar", ElemHideException, "elemhideexception"],
+ ["example.com,~sub.example.com#?#foo:-abp-properties(something)bar", ElemHideEmulationFilter, "elemhideemulation"],
+ ["example.com,~sub.example.com#@#foo:-abp-properties(something)bar", ElemHideException, "elemhideexception"],
+ ["example.com#?#:-abp-properties(something)", ElemHideEmulationFilter, "elemhideemulation"],
+ ["example.com#@#:-abp-properties(something)", ElemHideException, "elemhideexception"],
+ ["example.com#?#:-abp-properties((something))", ElemHideEmulationFilter, "elemhideemulation"],
+ ["example.com#@#:-abp-properties((something))", ElemHideException, "elemhideexception"]
];
for (let [text, type, typeName] of tests)
{
let filter = Filter.fromText(text);
test.ok(filter instanceof Filter, "Got filter for " + text);
test.equal(filter.text, text, "Correct filter text for " + text);
test.ok(filter instanceof type, "Correct filter type for " + text);
test.equal(filter.type, typeName, "Type name for " + text + " is " + typeName);
@@ -117,17 +115,17 @@
];
let tests = [
["/asdf??+/", Filter, InvalidFilter],
["!asdf", Filter, CommentFilter],
["asdf", Filter, ActiveFilter, RegExpFilter, BlockingFilter],
["@@asdf", Filter, ActiveFilter, RegExpFilter, WhitelistFilter],
["##asdf", Filter, ActiveFilter, ElemHideBase, ElemHideFilter],
["#@#asdf", Filter, ActiveFilter, ElemHideBase, ElemHideException],
- ["example.com##[-abp-properties='something']", Filter, ActiveFilter, ElemHideBase, ElemHideEmulationFilter]
+ ["example.com#?#:-abp-properties(something)", Filter, ActiveFilter, ElemHideBase, ElemHideEmulationFilter]
];
for (let list of tests)
{
let filter = Filter.fromText(list.shift());
for (let cls of list)
{
test.ok(filter instanceof cls,
@@ -264,17 +262,17 @@
test.done();
};
exports.testInvalidReasons = function(test)
{
let tests = [
["/??/", "filter_invalid_regexp"],
["asd$foobar", "filter_unknown_option"],
- ["~foo.com##[-abp-properties='abc']", "filter_elemhideemulation_nodomain"]
+ ["~foo.com#?#:-abp-properties(abc)", "filter_elemhideemulation_nodomain"]
];
for (let [text, reason] of tests)
{
let filter = Filter.fromText(text);
test.equals(filter.reason, reason, "Reason why filter " + text + " is invalid");
filter.delete();
}
@@ -359,17 +357,17 @@
let tests = [
["##foobar", "foobar", ""],
["~example.com##foobar", "foobar", ""],
["example.com##body > div:first-child", "body > div:first-child", "example.com"],
["xYz,~example.com##foobar:not(whatever)", "foobar:not(whatever)", "xyz"],
["~xyz,com,~abc.com,example.info##foobar", "foobar", "com,example.info"],
["foo,bar,bas,bam##foobar", "foobar", "foo,bar,bas,bam"],
- ["foo.com##x[-abp-properties='abc']y", "x[-abp-properties='abc']y", "foo.com"],
+ ["foo.com##x:-abp-properties(abc)y", "x:-abp-properties(abc)y", "foo.com"],
// Good idea to test this? Maybe consider behavior undefined in this case.
["foo,bar,bas,~bar##foobar", "foobar", "foo,bas"]
];
for (let [text, selector, selectorDomain] of tests)
{
doTest(text, selector, selectorDomain);
« no previous file with comments | « test/elemHideEmulation.js ('k') | test/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld