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

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

Issue 6439460933730304: Issue 616 - Add tests for $generichide and $genericblock (Closed)
Patch Set: Slight improvement Created Oct. 1, 2015, 12:11 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
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.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP)); 95 addProperty("contentType", 0x7FFFFFFF & ~(RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP |
Thomas Greiner 2015/10/01 16:12:04 Detail: If you think that the 80 characters rule s
kzar 2015/10/02 10:19:28 Most of these test files are pretty bad when it co
Thomas Greiner 2015/10/02 13:55:47 Thanks, I appreciate that.
96 RegExpFilter.typeMap.GENERICHIDE | RegExpFilter.typeMap.GENERICBLOCK));
96 addProperty("matchCase", "false"); 97 addProperty("matchCase", "false");
97 addProperty("thirdParty", "null"); 98 addProperty("thirdParty", "null");
98 addProperty("domains", ""); 99 addProperty("domains", "");
99 addProperty("sitekeys", ""); 100 addProperty("sitekeys", "");
100 } 101 }
101 if (type == "filterlist") 102 if (type == "filterlist")
102 { 103 {
103 addProperty("collapse", "null"); 104 addProperty("collapse", "null");
104 } 105 }
105 if (type == "elemhide" || type == "elemhideexception") 106 if (type == "elemhide" || type == "elemhideexception")
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 }); 191 });
191 compareFilter("blabla_non_default", ["type=filterlist", "text=blabla_non_def ault", "regexp=blabla_non_default", "disabled=true", "hitCount=12", "lastHit=20" ], function(filter) 192 compareFilter("blabla_non_default", ["type=filterlist", "text=blabla_non_def ault", "regexp=blabla_non_default", "disabled=true", "hitCount=12", "lastHit=20" ], function(filter)
192 { 193 {
193 filter.disabled = true; 194 filter.disabled = true;
194 filter.hitCount = 12; 195 filter.hitCount = 12;
195 filter.lastHit = 20; 196 filter.lastHit = 20;
196 }); 197 });
197 }); 198 });
198 199
199 let t = RegExpFilter.typeMap; 200 let t = RegExpFilter.typeMap;
200 let defaultTypes = 0x7FFFFFFF & ~(t.ELEMHIDE | t.DOCUMENT | t.POPUP); 201 let defaultTypes = 0x7FFFFFFF & ~(t.ELEMHIDE | t.DOCUMENT | t.POPUP | t.GENERI CHIDE | t.GENERICBLOCK);
201 202
202 test("Special characters", function() 203 test("Special characters", function()
203 { 204 {
204 compareFilter("/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/", "re gexp=ddd|f?a[s]d"]); 205 compareFilter("/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/", "re gexp=ddd|f?a[s]d"]);
205 compareFilter("*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", "rege xp=asdf.*d.*dd"]); 206 compareFilter("*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", "rege xp=asdf.*d.*dd"]);
206 compareFilter("|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd*|", "regexp=^.*asd\\|f.*d.*dd.*$"]); 207 compareFilter("|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd*|", "regexp=^.*asd\\|f.*d.*dd.*$"]);
207 compareFilter("dd[]{}$%<>&()d", ["type=filterlist", "text=dd[]{}$%<>&()d", " regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d"]); 208 compareFilter("dd[]{}$%<>&()d", ["type=filterlist", "text=dd[]{}$%<>&()d", " regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d"]);
208 209
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("@@/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]); 211 compareFilter("@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*", "r egexp=asdf.*d.*dd", "contentType=" + defaultTypes]);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 compareFilter("#@ddd(fff)(foo=bar)", ["type=elemhideexception", "text=#@ddd( fff)(foo=bar)", 'selector=ddd.fff[foo="bar"],ddd#fff[foo="bar"]']); 266 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"]); 267 compareFilter("#@*(fff)", ["type=elemhideexception", "text=#@*(fff)", "selec tor=.fff,#fff"]);
267 compareFilter("#@*(foo=bar)", ["type=elemhideexception", "text=#@*(foo=bar)" , 'selector=[foo="bar"]']); 268 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"]); 269 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"]); 270 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"]); 271 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"]); 272 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"]); 273 compareFilter("foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo,~baz ,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]);
273 }); 274 });
274 })(); 275 })();
OLDNEW

Powered by Google App Engine
This is Rietveld