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: Addressed The Professor's feedback! Created Oct. 2, 2015, 10:17 a.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 | « chrome/content/tests/elemhide.js ('k') | 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.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP)); 95 addProperty("contentType", 0x7FFFFFFF & ~(
96 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE |
97 RegExpFilter.typeMap.POPUP | RegExpFilter.typeMap.GENERICHIDE |
98 RegExpFilter.typeMap.GENERICBLOCK
99 ));
96 addProperty("matchCase", "false"); 100 addProperty("matchCase", "false");
97 addProperty("thirdParty", "null"); 101 addProperty("thirdParty", "null");
98 addProperty("domains", ""); 102 addProperty("domains", "");
99 addProperty("sitekeys", ""); 103 addProperty("sitekeys", "");
100 } 104 }
101 if (type == "filterlist") 105 if (type == "filterlist")
102 { 106 {
103 addProperty("collapse", "null"); 107 addProperty("collapse", "null");
104 } 108 }
105 if (type == "elemhide" || type == "elemhideexception") 109 if (type == "elemhide" || type == "elemhideexception")
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 }); 194 });
191 compareFilter("blabla_non_default", ["type=filterlist", "text=blabla_non_def ault", "regexp=blabla_non_default", "disabled=true", "hitCount=12", "lastHit=20" ], function(filter) 195 compareFilter("blabla_non_default", ["type=filterlist", "text=blabla_non_def ault", "regexp=blabla_non_default", "disabled=true", "hitCount=12", "lastHit=20" ], function(filter)
192 { 196 {
193 filter.disabled = true; 197 filter.disabled = true;
194 filter.hitCount = 12; 198 filter.hitCount = 12;
195 filter.lastHit = 20; 199 filter.lastHit = 20;
196 }); 200 });
197 }); 201 });
198 202
199 let t = RegExpFilter.typeMap; 203 let t = RegExpFilter.typeMap;
200 let defaultTypes = 0x7FFFFFFF & ~(t.ELEMHIDE | t.DOCUMENT | t.POPUP); 204 let defaultTypes = 0x7FFFFFFF & ~(t.ELEMHIDE | t.DOCUMENT | t.POPUP | t.GENERI CHIDE | t.GENERICBLOCK);
201 205
202 test("Special characters", function() 206 test("Special characters", function()
203 { 207 {
204 compareFilter("/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/", "re gexp=ddd|f?a[s]d"]); 208 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"]); 209 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.*$"]); 210 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"]); 211 compareFilter("dd[]{}$%<>&()d", ["type=filterlist", "text=dd[]{}$%<>&()d", " regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d"]);
208 212
209 compareFilter("@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d/", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); 213 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]); 214 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"]']); 269 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"]); 270 compareFilter("#@*(fff)", ["type=elemhideexception", "text=#@*(fff)", "selec tor=.fff,#fff"]);
267 compareFilter("#@*(foo=bar)", ["type=elemhideexception", "text=#@*(foo=bar)" , 'selector=[foo="bar"]']); 271 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"]); 272 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"]); 273 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"]); 274 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"]); 275 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"]); 276 compareFilter("foo,~baz,bar#@ddd", ["type=elemhideexception", "text=foo,~baz ,bar#@ddd", "selectorDomain=foo,bar", "selector=ddd", "domains=BAR|FOO|~BAZ"]);
273 }); 277 });
274 })(); 278 })();
OLDNEW
« no previous file with comments | « chrome/content/tests/elemhide.js ('k') | chrome/content/tests/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld