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

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

Issue 29350387: Issue 4353 - Remove deprecated __proto__ syntax (Closed)
Patch Set: Created Sept. 1, 2016, 11:44 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 | « chrome/content/common.js ('k') | chrome/content/tests/performance/filter_fromText.html » ('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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 postInit(filter) 135 postInit(filter)
136 let result = serializeFilter(filter); 136 let result = serializeFilter(filter);
137 equal(result.sort().join("\n"), expected.sort().join("\n"), text); 137 equal(result.sort().join("\n"), expected.sort().join("\n"), text);
138 138
139 // Test round-trip 139 // Test round-trip
140 let filter2; 140 let filter2;
141 let buffer = []; 141 let buffer = [];
142 filter.serialize(buffer); 142 filter.serialize(buffer);
143 if (buffer.length) 143 if (buffer.length)
144 { 144 {
145 let map = {__proto__: null}; 145 let map = Object.create(null);
146 for (let line of buffer.slice(1)) 146 for (let line of buffer.slice(1))
147 { 147 {
148 if (/(.*?)=(.*)/.test(line)) 148 if (/(.*?)=(.*)/.test(line))
149 map[RegExp.$1] = RegExp.$2; 149 map[RegExp.$1] = RegExp.$2;
150 } 150 }
151 filter2 = Filter.fromObject(map); 151 filter2 = Filter.fromObject(map);
152 } 152 }
153 else 153 else
154 { 154 {
155 filter2 = Filter.fromText(filter.text); 155 filter2 = Filter.fromText(filter.text);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 compareFilter("foo.com,~bar.com##[-abp-properties='abc']", ["type=cssrule", "text=foo.com,~bar.com##[-abp-properties='abc']", "selectorDomain=foo.com", "sel ector=[-abp-properties='abc']", "domains=FOO.COM|~BAR.COM", "regexp=abc"]); 310 compareFilter("foo.com,~bar.com##[-abp-properties='abc']", ["type=cssrule", "text=foo.com,~bar.com##[-abp-properties='abc']", "selectorDomain=foo.com", "sel ector=[-abp-properties='abc']", "domains=FOO.COM|~BAR.COM", "regexp=abc"]);
311 compareFilter("foo.com,~bar##[-abp-properties='abc']", ["type=cssrule", "tex t=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=[- abp-properties='abc']", "domains=FOO.COM|~BAR", "regexp=abc"]); 311 compareFilter("foo.com,~bar##[-abp-properties='abc']", ["type=cssrule", "tex t=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com", "selector=[- abp-properties='abc']", "domains=FOO.COM|~BAR", "regexp=abc"]);
312 compareFilter("~foo.com,bar.com##[-abp-properties='abc']", ["type=cssrule", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain=bar.com", "sel ector=[-abp-properties='abc']", "domains=BAR.COM|~FOO.COM", "regexp=abc"]); 312 compareFilter("~foo.com,bar.com##[-abp-properties='abc']", ["type=cssrule", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain=bar.com", "sel ector=[-abp-properties='abc']", "domains=BAR.COM|~FOO.COM", "regexp=abc"]);
313 313
314 compareFilter("##[-abp-properties='']", ["type=elemhide", "text=##[-abp-prop erties='']", "selector=[-abp-properties='']"]); 314 compareFilter("##[-abp-properties='']", ["type=elemhide", "text=##[-abp-prop erties='']", "selector=[-abp-properties='']"]);
315 compareFilter("foo.com#@#[-abp-properties='abc']", ["type=elemhideexception" , "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selector= [-abp-properties='abc']", "domains=FOO.COM"]); 315 compareFilter("foo.com#@#[-abp-properties='abc']", ["type=elemhideexception" , "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selector= [-abp-properties='abc']", "domains=FOO.COM"]);
316 compareFilter("foo.com##aaa [-abp-properties='abc'] bbb", ["type=cssrule", " text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=foo.com", "selec tor=aaa [-abp-properties='abc'] bbb", "domains=FOO.COM", "prefix=aaa ", "regexp= abc", "suffix= bbb"]); 316 compareFilter("foo.com##aaa [-abp-properties='abc'] bbb", ["type=cssrule", " text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=foo.com", "selec tor=aaa [-abp-properties='abc'] bbb", "domains=FOO.COM", "prefix=aaa ", "regexp= abc", "suffix= bbb"]);
317 compareFilter("foo.com##[-abp-properties='|background-image: url(data:*)']", ["type=cssrule", "text=foo.com##[-abp-properties='|background-image: url(data:* )']", "selectorDomain=foo.com", "selector=[-abp-properties='|background-image: u rl(data:*)']", "domains=FOO.COM", "regexp=^background\\-image\\:\\ url\\(data\\: .*\\)"]); 317 compareFilter("foo.com##[-abp-properties='|background-image: url(data:*)']", ["type=cssrule", "text=foo.com##[-abp-properties='|background-image: url(data:* )']", "selectorDomain=foo.com", "selector=[-abp-properties='|background-image: u rl(data:*)']", "domains=FOO.COM", "regexp=^background\\-image\\:\\ url\\(data\\: .*\\)"]);
318 }); 318 });
319 })(); 319 })();
OLDNEW
« no previous file with comments | « chrome/content/common.js ('k') | chrome/content/tests/performance/filter_fromText.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld