OLD | NEW |
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 Loading... |
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 Loading... |
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 })(); |
OLD | NEW |