| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return 1; | 103 return 1; |
| 104 return 0; | 104 return 0; |
| 105 }); | 105 }); |
| 106 return sections.map( | 106 return sections.map( |
| 107 section => [section.header].concat(section.data).join("\n") | 107 section => [section.header].concat(section.data).join("\n") |
| 108 ).join("\n"); | 108 ).join("\n"); |
| 109 } | 109 } |
| 110 | 110 |
| 111 function testReadWrite(test, withExternal) | 111 function testReadWrite(test, withExternal) |
| 112 { | 112 { |
| 113 test.ok(!FilterStorage.initialized, "Uninitialized before the first load"); |
| 114 |
| 113 return testData.then(data => | 115 return testData.then(data => |
| 114 { | 116 { |
| 115 dataFile.contents = data; | 117 dataFile.contents = data; |
| 116 return loadFilters(); | 118 return loadFilters(); |
| 117 }).then(() => | 119 }).then(() => |
| 118 { | 120 { |
| 121 test.ok(FilterStorage.initialized, "Initialize after the first load"); |
| 119 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion
, "File format version"); | 122 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion
, "File format version"); |
| 120 | 123 |
| 121 if (withExternal) | 124 if (withExternal) |
| 122 { | 125 { |
| 123 { | 126 { |
| 124 let subscription = new ExternalSubscription("~external~external subscrip
tion ID", "External subscription"); | 127 let subscription = new ExternalSubscription("~external~external subscrip
tion ID", "External subscription"); |
| 125 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")]; | 128 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")]; |
| 126 FilterStorage.addSubscription(subscription); | 129 FilterStorage.addSubscription(subscription); |
| 127 } | 130 } |
| 128 | 131 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return FilterStorage.restoreBackup(1); | 324 return FilterStorage.restoreBackup(1); |
| 322 }).then(() => | 325 }).then(() => |
| 323 { | 326 { |
| 324 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
restoring backup"); | 327 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
restoring backup"); |
| 325 return loadFilters(); | 328 return loadFilters(); |
| 326 }).then(() => | 329 }).then(() => |
| 327 { | 330 { |
| 328 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
reloading"); | 331 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
reloading"); |
| 329 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 332 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
| 330 }; | 333 }; |
| OLD | NEW |