| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 addDefaults(expected); | 189 addDefaults(expected); |
| 190 | 190 |
| 191 let filter = Filter.fromText(text); | 191 let filter = Filter.fromText(text); |
| 192 if (postInit) | 192 if (postInit) |
| 193 postInit(filter); | 193 postInit(filter); |
| 194 let result = serializeFilter(filter); | 194 let result = serializeFilter(filter); |
| 195 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text); | 195 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text); |
| 196 | 196 |
| 197 // Test round-trip | 197 // Test round-trip |
| 198 let filter2; | 198 let filter2; |
| 199 let buffer = []; | 199 let buffer = [...filter.serialize()]; |
| 200 filter.serialize(buffer); | |
| 201 if (buffer.length) | 200 if (buffer.length) |
| 202 { | 201 { |
| 203 let map = Object.create(null); | 202 let map = Object.create(null); |
| 204 for (let line of buffer.slice(1)) | 203 for (let line of buffer.slice(1)) |
| 205 { | 204 { |
| 206 if (/(.*?)=(.*)/.test(line)) | 205 if (/(.*?)=(.*)/.test(line)) |
| 207 map[RegExp.$1] = RegExp.$2; | 206 map[RegExp.$1] = RegExp.$2; |
| 208 } | 207 } |
| 209 filter2 = Filter.fromObject(map); | 208 filter2 = Filter.fromObject(map); |
| 210 } | 209 } |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 628 |
| 630 test.notEqual(filter2.domains, filter5.domains); | 629 test.notEqual(filter2.domains, filter5.domains); |
| 631 | 630 |
| 632 // Check twice for element hiding filters to make sure the internal cached | 631 // Check twice for element hiding filters to make sure the internal cached |
| 633 // values are also not equal. | 632 // values are also not equal. |
| 634 test.notEqual(filter4.domains, filter6.domains); | 633 test.notEqual(filter4.domains, filter6.domains); |
| 635 test.notEqual(filter4.domains, filter6.domains); | 634 test.notEqual(filter4.domains, filter6.domains); |
| 636 | 635 |
| 637 test.done(); | 636 test.done(); |
| 638 }; | 637 }; |
| OLD | NEW |