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

Unified Diff: test/filterClasses.js

Issue 29383799: Issue 4988 - [emscripten] Adjust API for Element Hiding Emulation filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created March 14, 2017, 2:42 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
« compiled/RegExpFilter.cpp ('K') | « lib/filterClassesNew.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
@@ -24,26 +24,26 @@ let InvalidFilter = null;
let CommentFilter = null;
let ActiveFilter = null;
let RegExpFilter = null;
let BlockingFilter = null;
let WhitelistFilter = null;
let ElemHideBase = null;
let ElemHideFilter = null;
let ElemHideException = null;
-let CSSPropertyFilter = null;
+let ElemHideEmulationFilter = null;
exports.setUp = function(callback)
{
let sandboxedRequire = createSandbox();
(
{
Filter, InvalidFilter, CommentFilter, ActiveFilter, RegExpFilter,
BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter,
- ElemHideException, CSSPropertyFilter
+ ElemHideException, ElemHideEmulationFilter
} = sandboxedRequire("../lib/filterClassesNew")
);
callback();
};
exports.testFromText = function(test)
{
let tests = [
@@ -70,31 +70,31 @@ exports.testFromText = function(test)
["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", CSSPropertyFilter, "cssproperty"],
+ ["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", CSSPropertyFilter, "cssproperty"],
+ ["~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", CSSPropertyFilter, "cssproperty"],
+ ["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']", CSSPropertyFilter, "cssproperty"],
+ ["example.com##[-abp-properties='something']", ElemHideEmulationFilter, "elemhideemulation"],
["example.com#@#[-abp-properties='something']", ElemHideException, "elemhideexception"],
- ["example.com##[-abp-properties=\"something\"]", CSSPropertyFilter, "cssproperty"],
+ ["example.com##[-abp-properties=\"something\"]", ElemHideEmulationFilter, "elemhideemulation"],
["example.com#@#[-abp-properties=\"something\"]", ElemHideException, "elemhideexception"],
- ["example.com##[-abp-properties=(something)]", ElemHideFilter, "elemhide"],
+ ["example.com##[-abp-properties=(something)]", ElemHideEmulationFilter, "elemhideemulation"],
["example.com#@#[-abp-properties=(something)]", ElemHideException, "elemhideexception"],
];
for (let [text, type, typeName, location] 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);
@@ -105,25 +105,25 @@ exports.testFromText = function(test)
}
test.done();
};
exports.testClassHierarchy = function(test)
{
let allClasses = ["Filter", "InvalidFilter", "CommentFilter", "ActiveFilter",
"RegExpFilter", "BlockingFilter", "WhitelistFilter", "ElemHideBase",
- "ElemHideFilter", "ElemHideException", "CSSPropertyFilter"];
+ "ElemHideFilter", "ElemHideException", "ElemHideEmulationFilter"];
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", "CSSPropertyFilter"],
+ ["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 eval(cls),
@@ -255,17 +255,17 @@ exports.testSerialize = function(test)
test.done();
};
exports.testInvalidReasons = function(test)
{
let tests = [
["/??/", "filter_invalid_regexp"],
["asd$foobar", "filter_unknown_option"],
- ["~foo.com##[-abp-properties='abc']", "filter_cssproperty_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();
}
@@ -350,44 +350,22 @@ exports.testElemHideSelector = function(
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"],
// 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);
doTest(text.replace("##", "#@#"), selector, selectorDomain);
}
test.done();
};
-
-exports.testCSSRules = function(test)
-{
- let tests = [
- ["foo.com##[-abp-properties='abc']", "abc", "", ""],
- ["foo.com##[-abp-properties='a\"bc']", "a\\\"bc", "", ""],
- ["foo.com##[-abp-properties=\"abc\"]", "abc", "", ""],
- ["foo.com##[-abp-properties=\"a'bc\"]", "a\\'bc", "", ""],
- ["foo.com##aaa [-abp-properties='abc'] bbb", "abc", "aaa ", " bbb"],
- ["foo.com##[-abp-properties='|background-image: url(data:*)']", "^background\\-image\\:\\ url\\(data\\:.*\\)", "", ""],
- ];
-
- for (let [text, regexp, prefix, suffix] of tests)
- {
- let filter = Filter.fromText(text);
- test.equal(filter.regexpString, regexp, "Regular expression of " + text);
- test.equal(filter.selectorPrefix, prefix, "Selector prefix of " + text);
- test.equal(filter.selectorSuffix, suffix, "Selector suffix of " + text);
- filter.delete();
- }
-
- test.done();
-};
« compiled/RegExpFilter.cpp ('K') | « lib/filterClassesNew.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld