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

Unified Diff: test/filterClasses.js

Issue 29760704: Issue 6592 - Implement $rewrite filter option (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Use the replace syntax directly Created May 1, 2018, 6:30 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
===================================================================
--- a/test/filterClasses.js
+++ b/test/filterClasses.js
@@ -89,16 +89,17 @@
result.push("sitekeys=" + sitekeys.slice().sort().join("|"));
result.push("thirdParty=" + filter.thirdParty);
if (filter instanceof BlockingFilter)
{
result.push("type=filterlist");
result.push("collapse=" + filter.collapse);
result.push("csp=" + filter.csp);
+ result.push("rewrite=" + filter.rewrite);
}
else if (filter instanceof WhitelistFilter)
result.push("type=whitelist");
}
else if (filter instanceof ElemHideBase)
{
if (filter instanceof ElemHideFilter)
result.push("type=elemhide");
@@ -148,16 +149,17 @@
addProperty("thirdParty", "null");
addProperty("domains", "");
addProperty("sitekeys", "");
}
if (type == "filterlist")
{
addProperty("collapse", "null");
addProperty("csp", "null");
+ addProperty("rewrite", "null");
}
if (type == "elemhide" || type == "elemhideexception" ||
type == "elemhideemulation")
{
addProperty("selectorDomain", "");
addProperty("domains", "");
}
}
@@ -285,16 +287,17 @@
};
exports.testFilterOptions = function(test)
{
compareFilter(test, "bla$match-case,csp=first csp,script,other,third-party,domain=foo.com,sitekey=foo", ["type=filterlist", "text=bla$match-case,csp=first csp,script,other,third-party,domain=foo.com,sitekey=foo", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=FOO.COM", "sitekeys=FOO", "csp=first csp"]);
compareFilter(test, "bla$~match-case,~csp=csp,~script,~other,~third-party,domain=~bar.com", ["type=filterlist", "text=bla$~match-case,~csp=csp,~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,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"]);
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, "||content.server.com/files/*.php$rewrite=$1", ["type=filterlist", "text=||content.server.com/files/*.php$rewrite=$1", "regexp=^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?content\\.server\\.com\\/files\\/.*\\.php", "matchCase=false", "rewrite=$1"]);
// background and image should be the same for backwards compatibility
compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp=bla", "contentType=" + (t.IMAGE)]);
compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background", "regexp=bla", "contentType=" + (t.IMAGE)]);
compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]);
compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~background", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]);
compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~script,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]);
@@ -492,11 +495,12 @@
test.equal(Filter.normalize("foo$csp=bar,$c sp=c s p"),
"foo$csp=bar,$csp=c s p");
test.equal(Filter.normalize(" f o o $ bar $csp=ba r"),
"foo$bar$csp=ba r");
test.equal(Filter.normalize("f $ o $ o $ csp=f o o "),
"f$o$o$csp=f o o");
test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1=1&$2=2&$3=3"),
"/foo$/$csp=script-src http://example.com/?$1=1&$2=2&$3=3");
-
+ test.equal(Filter.normalize("||content.server.com/files/*.php$rewrite= $1"),
+ "||content.server.com/files/*.php$rewrite=$1");
test.done();
};
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld