| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 postInit(filter) | 155 postInit(filter) |
| 156 let result = serializeFilter(filter); | 156 let result = serializeFilter(filter); |
| 157 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text); | 157 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text); |
| 158 | 158 |
| 159 // Test round-trip | 159 // Test round-trip |
| 160 let filter2; | 160 let filter2; |
| 161 let buffer = []; | 161 let buffer = []; |
| 162 filter.serialize(buffer); | 162 filter.serialize(buffer); |
| 163 if (buffer.length) | 163 if (buffer.length) |
| 164 { | 164 { |
| 165 let map = {__proto__: null}; | 165 let map = Object.create(null); |
| 166 for (let line of buffer.slice(1)) | 166 for (let line of buffer.slice(1)) |
| 167 { | 167 { |
| 168 if (/(.*?)=(.*)/.test(line)) | 168 if (/(.*?)=(.*)/.test(line)) |
| 169 map[RegExp.$1] = RegExp.$2; | 169 map[RegExp.$1] = RegExp.$2; |
| 170 } | 170 } |
| 171 filter2 = Filter.fromObject(map); | 171 filter2 = Filter.fromObject(map); |
| 172 } | 172 } |
| 173 else | 173 else |
| 174 { | 174 { |
| 175 filter2 = Filter.fromText(filter.text); | 175 filter2 = Filter.fromText(filter.text); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 compareFilter(test, "foo.com,~bar##[-abp-properties='abc']", ["type=cssrule",
"text=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com", "selecto
r=[-abp-properties='abc']", "domains=FOO.COM|~BAR", "regexp=abc"]); | 336 compareFilter(test, "foo.com,~bar##[-abp-properties='abc']", ["type=cssrule",
"text=foo.com,~bar##[-abp-properties='abc']", "selectorDomain=foo.com", "selecto
r=[-abp-properties='abc']", "domains=FOO.COM|~BAR", "regexp=abc"]); |
| 337 compareFilter(test, "~foo.com,bar.com##[-abp-properties='abc']", ["type=cssrul
e", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain=bar.com",
"selector=[-abp-properties='abc']", "domains=BAR.COM|~FOO.COM", "regexp=abc"]); | 337 compareFilter(test, "~foo.com,bar.com##[-abp-properties='abc']", ["type=cssrul
e", "text=~foo.com,bar.com##[-abp-properties='abc']", "selectorDomain=bar.com",
"selector=[-abp-properties='abc']", "domains=BAR.COM|~FOO.COM", "regexp=abc"]); |
| 338 | 338 |
| 339 compareFilter(test, "##[-abp-properties='']", ["type=elemhide", "text=##[-abp-
properties='']", "selector=[-abp-properties='']"]); | 339 compareFilter(test, "##[-abp-properties='']", ["type=elemhide", "text=##[-abp-
properties='']", "selector=[-abp-properties='']"]); |
| 340 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept
ion", "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selec
tor=[-abp-properties='abc']", "domains=FOO.COM"]); | 340 compareFilter(test, "foo.com#@#[-abp-properties='abc']", ["type=elemhideexcept
ion", "text=foo.com#@#[-abp-properties='abc']", "selectorDomain=foo.com", "selec
tor=[-abp-properties='abc']", "domains=FOO.COM"]); |
| 341 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=cssrule
", "text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=foo.com", "s
elector=aaa [-abp-properties='abc'] bbb", "domains=FOO.COM", "prefix=aaa ", "reg
exp=abc", "suffix= bbb"]); | 341 compareFilter(test, "foo.com##aaa [-abp-properties='abc'] bbb", ["type=cssrule
", "text=foo.com##aaa [-abp-properties='abc'] bbb", "selectorDomain=foo.com", "s
elector=aaa [-abp-properties='abc'] bbb", "domains=FOO.COM", "prefix=aaa ", "reg
exp=abc", "suffix= bbb"]); |
| 342 compareFilter(test, "foo.com##[-abp-properties='|background-image: url(data:*)
']", ["type=cssrule", "text=foo.com##[-abp-properties='|background-image: url(da
ta:*)']", "selectorDomain=foo.com", "selector=[-abp-properties='|background-imag
e: url(data:*)']", "domains=FOO.COM", "regexp=^background\\-image\\:\\ url\\(dat
a\\:.*\\)"]); | 342 compareFilter(test, "foo.com##[-abp-properties='|background-image: url(data:*)
']", ["type=cssrule", "text=foo.com##[-abp-properties='|background-image: url(da
ta:*)']", "selectorDomain=foo.com", "selector=[-abp-properties='|background-imag
e: url(data:*)']", "domains=FOO.COM", "regexp=^background\\-image\\:\\ url\\(dat
a\\:.*\\)"]); |
| 343 | 343 |
| 344 test.done(); | 344 test.done(); |
| 345 }; | 345 }; |
| OLD | NEW |