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

Unified Diff: test/filterClasses.js

Issue 29470687: Issue 5344 - Element hiding emulation exceptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 21, 2017, 6:50 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 | « lib/filterClasses.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
@@ -25,28 +25,30 @@
let ActiveFilter = null;
let RegExpFilter = null;
let BlockingFilter = null;
let WhitelistFilter = null;
let ElemHideBase = null;
let ElemHideFilter = null;
let ElemHideException = null;
let ElemHideEmulationFilter = null;
+let ElemHideEmulationException = null;
let t = null;
let defaultTypes = null;
exports.setUp = function(callback)
{
let sandboxedRequire = createSandbox();
(
{Filter, InvalidFilter, CommentFilter, ActiveFilter, RegExpFilter,
BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter,
ElemHideException,
- ElemHideEmulationFilter} = sandboxedRequire("../lib/filterClasses")
+ ElemHideEmulationFilter,
+ ElemHideEmulationException} = sandboxedRequire("../lib/filterClasses")
);
t = RegExpFilter.typeMap;
defaultTypes = 0x7FFFFFFF & ~(t.ELEMHIDE | t.DOCUMENT | t.POPUP |
t.GENERICHIDE | t.GENERICBLOCK);
callback();
};
@@ -100,16 +102,18 @@
else if (filter instanceof ElemHideBase)
{
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");
+ else if (filter instanceof ElemHideEmulationException)
+ result.push("type=elemhideemulationexception");
result.push("selectorDomain=" + (filter.selectorDomain || ""));
result.push("selector=" + filter.selector);
}
}
return result;
}
@@ -127,17 +131,18 @@
function addProperty(prop, value)
{
if (!(prop in hasProperty))
expected.push(prop + "=" + value);
}
if (type == "whitelist" || type == "filterlist" || type == "elemhide" ||
- type == "elemhideexception" || type == "elemhideemulation")
+ type == "elemhideexception" || type == "elemhideemulation" ||
+ type == "elemhideemulationexception")
{
addProperty("disabled", "false");
addProperty("lastHit", "0");
addProperty("hitCount", "0");
}
if (type == "whitelist" || type == "filterlist")
{
addProperty("contentType", 0x7FFFFFFF & ~(
@@ -199,16 +204,18 @@
test.equal(typeof RegExpFilter, "function", "typeof RegExpFilter");
test.equal(typeof BlockingFilter, "function", "typeof BlockingFilter");
test.equal(typeof WhitelistFilter, "function", "typeof WhitelistFilter");
test.equal(typeof ElemHideBase, "function", "typeof ElemHideBase");
test.equal(typeof ElemHideFilter, "function", "typeof ElemHideFilter");
test.equal(typeof ElemHideException, "function", "typeof ElemHideException");
test.equal(typeof ElemHideEmulationFilter, "function",
"typeof ElemHideEmulationFilter");
+ test.equal(typeof ElemHideEmulationException, "function",
+ "typeof ElemHideEmulationException");
test.done();
};
exports.testComments = function(test)
{
compareFilter(test, "!asdf", ["type=comment", "text=!asdf"]);
compareFilter(test, "!foo#bar", ["type=comment", "text=!foo#bar"]);
@@ -330,16 +337,21 @@
{
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"]);
+ // elemhideemulationexception
+ // invalid exception, elemehideemulation requires a domain
+ compareFilter(test, "#^#ddd", ["type=invalid", "reason=filter_elemhideemulation_nodomain", "text=#^#ddd"]);
+ compareFilter(test, "foo.bar#^#ddd", ["type=elemhideemulationexception", "text=foo.bar#^#ddd", "selectorDomain=foo.bar", "selector=ddd", "domains=FOO.BAR"]);
+
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"]);
« no previous file with comments | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld