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

Side by Side Diff: chrome/content/tests/filterClasses.js

Issue 5971196453584896: Issue 2503 - Inconsistent behavior: $document flag implied for exception rules with protocol includ… (Closed)
Patch Set: Created May 18, 2015, 5:51 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/content/tests/matcher.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (function() 1 (function()
2 { 2 {
3 module("Filter classes", {setup: prepareFilterComponents, teardown: restoreFil terComponents}); 3 module("Filter classes", {setup: prepareFilterComponents, teardown: restoreFil terComponents});
4 4
5 function serializeFilter(filter) 5 function serializeFilter(filter)
6 { 6 {
7 // Filter serialization only writes out essential properties, need to do a f ull serialization here 7 // Filter serialization only writes out essential properties, need to do a f ull serialization here
8 let result = []; 8 let result = [];
9 result.push("text=" + filter.text); 9 result.push("text=" + filter.text);
10 if (filter instanceof InvalidFilter) 10 if (filter instanceof InvalidFilter)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 if (type == "whitelist" || type == "filterlist" || type == "elemhide" || typ e == "elemhideexception") 87 if (type == "whitelist" || type == "filterlist" || type == "elemhide" || typ e == "elemhideexception")
88 { 88 {
89 addProperty("disabled", "false"); 89 addProperty("disabled", "false");
90 addProperty("lastHit", "0"); 90 addProperty("lastHit", "0");
91 addProperty("hitCount", "0"); 91 addProperty("hitCount", "0");
92 } 92 }
93 if (type == "whitelist" || type == "filterlist") 93 if (type == "whitelist" || type == "filterlist")
94 { 94 {
95 addProperty("contentType", 0x7FFFFFFF & ~(RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP)); 95 addProperty("contentType", 0x7FFFFFFF & ~(RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP));
96 addProperty("matchCase", "false"); 96 addProperty("matchCase", "false");
97 addProperty("thirdParty", "null"); 97 addProperty("thirdParty", "null");
98 addProperty("domains", ""); 98 addProperty("domains", "");
99 addProperty("sitekeys", ""); 99 addProperty("sitekeys", "");
100 } 100 }
101 if (type == "filterlist") 101 if (type == "filterlist")
102 { 102 {
103 addProperty("collapse", "null"); 103 addProperty("collapse", "null");
104 } 104 }
105 if (type == "elemhide" || type == "elemhideexception") 105 if (type == "elemhide" || type == "elemhideexception")
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 compareFilter("@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d/", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); 209 compareFilter("@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d/", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]);
210 compareFilter("@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*", "r egexp=asdf.*d.*dd", "contentType=" + defaultTypes]); 210 compareFilter("@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*", "r egexp=asdf.*d.*dd", "contentType=" + defaultTypes]);
211 compareFilter("@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d**dd* |", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]); 211 compareFilter("@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d**dd* |", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]);
212 compareFilter("@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>&()d" , "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTypes]) ; 212 compareFilter("@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>&()d" , "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTypes]) ;
213 }); 213 });
214 214
215 test("Filter options", function() 215 test("Filter options", function()
216 { 216 {
217 compareFilter("bla$match-case,script,other,third-party,domain=foo.com,siteke y=foo", ["type=filterlist", "text=bla$match-case,script,other,third-party,domain =foo.com,sitekey=foo", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIP T | t.OTHER), "thirdParty=true", "domains=FOO.COM", "sitekeys=FOO"]); 217 compareFilter("bla$match-case,script,other,third-party,domain=foo.com,siteke y=foo", ["type=filterlist", "text=bla$match-case,script,other,third-party,domain =foo.com,sitekey=foo", "regexp=bla", "matchCase=true", "contentType=" + (t.SCRIP T | t.OTHER), "thirdParty=true", "domains=FOO.COM", "sitekeys=FOO"]);
218 compareFilter("bla$~match-case,~script,~other,~third-party,domain=~bar.com", ["type=filterlist", "text=bla$~match-case,~script,~other,~third-party,domain=~b ar.com", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER) | t.DOCUMENT), "thirdParty=false", "domains=~BAR.COM"]); 218 compareFilter("bla$~match-case,~script,~other,~third-party,domain=~bar.com", ["type=filterlist", "text=bla$~match-case,~script,~other,~third-party,domain=~b ar.com", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER)), "thirdParty=false", "domains=~BAR.COM"]);
219 compareFilter("@@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$m atch-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.C OM", "sitekeys=BAR|FOO"]); 219 compareFilter("@@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$m atch-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.C OM", "sitekeys=BAR|FOO"]);
220 220
221 // background and image should be the same for backwards compatibility 221 // background and image should be the same for backwards compatibility
222 compareFilter("bla$image", ["type=filterlist", "text=bla$image", "regexp=bla ", "contentType=" + (t.IMAGE)]); 222 compareFilter("bla$image", ["type=filterlist", "text=bla$image", "regexp=bla ", "contentType=" + (t.IMAGE)]);
223 compareFilter("bla$background", ["type=filterlist", "text=bla$background", " regexp=bla", "contentType=" + (t.IMAGE)]); 223 compareFilter("bla$background", ["type=filterlist", "text=bla$background", " regexp=bla", "contentType=" + (t.IMAGE)]);
224 compareFilter("bla$~image", ["type=filterlist", "text=bla$~image", "regexp=b la", "contentType=" + (defaultTypes & ~t.IMAGE | t.DOCUMENT)]); 224 compareFilter("bla$~image", ["type=filterlist", "text=bla$~image", "regexp=b la", "contentType=" + (defaultTypes & ~t.IMAGE)]);
225 compareFilter("bla$~background", ["type=filterlist", "text=bla$~background", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE | t.DOCUMENT)]); 225 compareFilter("bla$~background", ["type=filterlist", "text=bla$~background", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]);
226 226
227 compareFilter("@@bla$~script,~other", ["type=whitelist", "text=@@bla$~script ,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))] ); 227 compareFilter("@@bla$~script,~other", ["type=whitelist", "text=@@bla$~script ,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))] );
228 compareFilter("@@http://bla$~script,~other", ["type=whitelist", "text=@@http ://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (defaultType s & ~(t.SCRIPT | t.OTHER) | t.DOCUMENT)]); 228 compareFilter("@@http://bla$~script,~other", ["type=whitelist", "text=@@http ://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (defaultType s & ~(t.SCRIPT | t.OTHER))]);
229 compareFilter("@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@|ftp ://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (defaultType s & ~(t.SCRIPT | t.OTHER) | t.DOCUMENT)]); 229 compareFilter("@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@|ftp ://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (defaultType s & ~(t.SCRIPT | t.OTHER))]);
230 compareFilter("@@bla$~script,~other,document", ["type=whitelist", "text=@@bl a$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~(t. SCRIPT | t.OTHER) | t.DOCUMENT)]); 230 compareFilter("@@bla$~script,~other,document", ["type=whitelist", "text=@@bl a$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~(t. SCRIPT | t.OTHER) | t.DOCUMENT)]);
231 compareFilter("@@bla$~script,~other,~document", ["type=whitelist", "text=@@b la$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes & ~(t .SCRIPT | t.OTHER))]); 231 compareFilter("@@bla$~script,~other,~document", ["type=whitelist", "text=@@b la$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes & ~(t .SCRIPT | t.OTHER))]);
232 compareFilter("@@bla$document", ["type=whitelist", "text=@@bla$document", "r egexp=bla", "contentType=" + t.DOCUMENT]); 232 compareFilter("@@bla$document", ["type=whitelist", "text=@@bla$document", "r egexp=bla", "contentType=" + t.DOCUMENT]);
233 compareFilter("@@bla$~script,~other,elemhide", ["type=whitelist", "text=@@bl a$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t. SCRIPT | t.OTHER) | t.ELEMHIDE)]); 233 compareFilter("@@bla$~script,~other,elemhide", ["type=whitelist", "text=@@bl a$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t. SCRIPT | t.OTHER) | t.ELEMHIDE)]);
234 compareFilter("@@bla$~script,~other,~elemhide", ["type=whitelist", "text=@@b la$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t .SCRIPT | t.OTHER))]); 234 compareFilter("@@bla$~script,~other,~elemhide", ["type=whitelist", "text=@@b la$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~(t .SCRIPT | t.OTHER))]);
235 compareFilter("@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide", "r egexp=bla", "contentType=" + t.ELEMHIDE]); 235 compareFilter("@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide", "r egexp=bla", "contentType=" + t.ELEMHIDE]);
236 236
237 compareFilter("@@bla$~script,~other,donottrack", ["type=invalid", "text=@@bl a$~script,~other,donottrack", "hasReason"]); 237 compareFilter("@@bla$~script,~other,donottrack", ["type=invalid", "text=@@bl a$~script,~other,donottrack", "hasReason"]);
238 compareFilter("@@bla$~script,~other,~donottrack", ["type=invalid", "text=@@b la$~script,~other,~donottrack", "hasReason"]); 238 compareFilter("@@bla$~script,~other,~donottrack", ["type=invalid", "text=@@b la$~script,~other,~donottrack", "hasReason"]);
239 compareFilter("@@bla$donottrack", ["type=invalid", "text=@@bla$donottrack", "hasReason"]); 239 compareFilter("@@bla$donottrack", ["type=invalid", "text=@@bla$donottrack", "hasReason"]);
(...skipping 25 matching lines...) Expand all
265 compareFilter("#@ddd(fff)(foo=bar)", ["type=elemhideexception", "text=#@ddd( fff)(foo=bar)", 'selector=ddd.fff[foo="bar"],ddd#fff[foo="bar"]']); 265 compareFilter("#@ddd(fff)(foo=bar)", ["type=elemhideexception", "text=#@ddd( fff)(foo=bar)", 'selector=ddd.fff[foo="bar"],ddd#fff[foo="bar"]']);
266 compareFilter("#@*(fff)", ["type=elemhideexception", "text=#@*(fff)", "selec tor=.fff,#fff"]); 266 compareFilter("#@*(fff)", ["type=elemhideexception", "text=#@*(fff)", "selec tor=.fff,#fff"]);
267 compareFilter("#@*(foo=bar)", ["type=elemhideexception", "text=#@*(foo=bar)" , 'selector=[foo="bar"]']); 267 compareFilter("#@*(foo=bar)", ["type=elemhideexception", "text=#@*(foo=bar)" , 'selector=[foo="bar"]']);
268 compareFilter("#@#body > div:first-child", ["type=elemhideexception", "text= #@#body > div:first-child", "selector=body > div:first-child"]); 268 compareFilter("#@#body > div:first-child", ["type=elemhideexception", "text= #@#body > div:first-child", "selector=body > div:first-child"]);
269 compareFilter("foo#@ddd", ["type=elemhideexception", "text=foo#@ddd", "selec torDomain=foo", "selector=ddd", "domains=FOO"]); 269 compareFilter("foo#@ddd", ["type=elemhideexception", "text=foo#@ddd", "selec torDomain=foo", "selector=ddd", "domains=FOO"]);
270 compareFilter("foo,bar#@ddd", ["type=elemhideexception", "text=foo,bar#@ddd" , "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]); 270 compareFilter("foo,bar#@ddd", ["type=elemhideexception", "text=foo,bar#@ddd" , "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO"]);
271 compareFilter("foo,~bar#@ddd", ["type=elemhideexception", "text=foo,~bar#@dd d", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]); 271 compareFilter("foo,~bar#@ddd", ["type=elemhideexception", "text=foo,~bar#@dd d", "selectorDomain=foo", "selector=ddd", "domains=FOO|~BAR"]);
272 compareFilter("foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo,~baz ,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]); 272 compareFilter("foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo,~baz ,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]);
273 }); 273 });
274 })(); 274 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/content/tests/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld