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

Unified Diff: test/filterClasses.js

Issue 29680689: [$csp2 adblockpluscore] Issue 6329 - Add the CSP filter type (Closed)
Patch Set: Created Jan. 26, 2018, 5:41 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
« lib/filterClasses.js ('K') | « 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
diff --git a/test/filterClasses.js b/test/filterClasses.js
index 9ca831741b625e69d9337d245494e222fc62d84b..401a9f33f7e1d1191a2b15d4fe4ecfcc56bfccf4 100644
--- a/test/filterClasses.js
+++ b/test/filterClasses.js
@@ -44,7 +44,7 @@ exports.setUp = function(callback)
ElemHideEmulationFilter} = sandboxedRequire("../lib/filterClasses")
);
t = RegExpFilter.typeMap;
- defaultTypes = 0x7FFFFFFF & ~(t.ELEMHIDE | t.DOCUMENT | t.POPUP |
+ defaultTypes = 0x7FFFFFFF & ~(t.CSP | t.ELEMHIDE | t.DOCUMENT | t.POPUP |
t.GENERICHIDE | t.GENERICBLOCK);
callback();
@@ -93,6 +93,7 @@ function serializeFilter(filter)
{
result.push("type=filterlist");
result.push("collapse=" + filter.collapse);
+ result.push("csp=" + filter.csp);
}
else if (filter instanceof WhitelistFilter)
result.push("type=whitelist");
@@ -141,9 +142,9 @@ function addDefaults(expected)
if (type == "whitelist" || type == "filterlist")
{
addProperty("contentType", 0x7FFFFFFF & ~(
- RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE |
- RegExpFilter.typeMap.POPUP | RegExpFilter.typeMap.GENERICHIDE |
- RegExpFilter.typeMap.GENERICBLOCK
+ RegExpFilter.typeMap.CSP | RegExpFilter.typeMap.DOCUMENT |
+ RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP |
+ RegExpFilter.typeMap.GENERICHIDE | RegExpFilter.typeMap.GENERICBLOCK
));
addProperty("matchCase", "false");
addProperty("thirdParty", "null");
@@ -151,7 +152,10 @@ function addDefaults(expected)
addProperty("sitekeys", "");
}
if (type == "filterlist")
+ {
addProperty("collapse", "null");
+ addProperty("csp", "null");
+ }
if (type == "elemhide" || type == "elemhideexception" ||
type == "elemhideemulation")
{
@@ -284,9 +288,9 @@ exports.testSpecialCharacters = function(test)
exports.testFilterOptions = function(test)
{
- compareFilter(test, "bla$match-case,script,other,third-party,domain=foo.com,sitekey=foo", ["type=filterlist", "text=bla$match-case,script,other,third-party,domain=foo.com,sitekey=foo", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER), "thirdParty=true", "domains=FOO.COM", "sitekeys=FOO"]);
+ compareFilter(test, "bla$match-case,script,other,third-party,domain=foo.com,sitekey=foo,csp= c s p ", ["type=filterlist", "text=bla$match-case,script,other,third-party,domain=foo.com,sitekey=foo,csp=c s p", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=FOO.COM", "sitekeys=FOO", "csp=c s p"]);
compareFilter(test, "bla$~match-case,~script,~other,~third-party,domain=~bar.com", ["type=filterlist", "text=bla$~match-case,~script,~other,~third-party,domain=~bar.com", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER)), "thirdParty=false", "domains=~BAR.COM"]);
- compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", ["type=whitelist", "text=@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER), "thirdParty=true", "domains=BAR.COM|FOO.COM|~BAR.FOO.COM|~FOO.BAR.COM", "sitekeys=BAR|FOO"]);
+ compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.bar.com,csp= c s p ,sitekey=foo|bar", ["type=whitelist", "text=@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.bar.com,csp=c s p,sitekey=foo|bar", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=BAR.COM|FOO.COM|~BAR.FOO.COM|~FOO.BAR.COM", "sitekeys=BAR|FOO"]);
// background and image should be the same for backwards compatibility
compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp=bla", "contentType=" + (t.IMAGE)]);
@@ -311,6 +315,8 @@ exports.testFilterOptions = function(test)
compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,foobar", "reason=filter_unknown_option"]);
compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar,image", "reason=filter_unknown_option"]);
+ compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=report-uri", "reason=filter_invalid_csp"]);
+
test.done();
};
@@ -426,9 +432,23 @@ exports.testFilterNormalisation = function(test)
"sitekeys=FOO",
"domains=DOMAIN.COM|FOO.COM"
]);
- compareFilter(test, Filter.stripJunk(" @@bl a$foo= bar ,domain= ab cd "), [
+ compareFilter(test, Filter.stripJunk(" @@bl a$foo= bar ,domain= ab cd ,foo"), [
+ "type=invalid",
+ "text=@@bla$foo=bar,domain=abcd,foo",
+ "reason=filter_unknown_option"
+ ]);
+
+ compareFilter(test, "bla$domain= a b ,csp= the c s p ", [
+ "type=filterlist",
+ "contentType=" + t.CSP,
+ "regexp=bla",
+ "text=bla$domain=ab,csp=the c s p",
+ "csp=the c s p",
+ "domains=AB"
+ ]);
+ compareFilter(test, Filter.stripJunk("bla$csp= the c s p ,invalid= f o o "), [
"type=invalid",
- "text=@@bla$invalid=foo,domain=abcd",
+ "text=bla$csp=the c s p,invalid=foo",
"reason=filter_unknown_option"
]);
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld