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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 const {createSandbox, unexpectedError} = require("./_common"); | 20 const {createSandbox, unexpectedError} = require("./_common"); |
21 | 21 |
22 let Filter = null; | 22 let Filter = null; |
23 let FilterNotifier = null; | 23 let FilterNotifier = null; |
24 let FilterStorage = null; | 24 let FilterStorage = null; |
25 let IO = null; | 25 let IO = null; |
26 let Prefs = null; | 26 let Prefs = null; |
27 let Subscription = null; | |
28 let ExternalSubscription = null; | 27 let ExternalSubscription = null; |
29 let dataFile = null; | 28 let dataFile = null; |
30 | 29 |
31 exports.setUp = function(callback) | 30 exports.setUp = function(callback) |
32 { | 31 { |
33 let sandboxedRequire = createSandbox(); | 32 let sandboxedRequire = createSandbox(); |
34 ( | 33 ( |
35 {Filter} = sandboxedRequire("../lib/filterClasses"), | 34 {Filter} = sandboxedRequire("../lib/filterClasses"), |
36 {FilterNotifier} = sandboxedRequire("../lib/filterNotifier"), | 35 {FilterNotifier} = sandboxedRequire("../lib/filterNotifier"), |
37 {FilterStorage} = sandboxedRequire("../lib/filterStorage"), | 36 {FilterStorage} = sandboxedRequire("../lib/filterStorage"), |
38 {IO} = sandboxedRequire("./stub-modules/io"), | 37 {IO} = sandboxedRequire("./stub-modules/io"), |
39 {Prefs} = sandboxedRequire("./stub-modules/prefs"), | 38 {Prefs} = sandboxedRequire("./stub-modules/prefs"), |
40 {Subscription, ExternalSubscription} = sandboxedRequire("../lib/subscription
Classes") | 39 {ExternalSubscription} = sandboxedRequire("../lib/subscriptionClasses") |
41 ); | 40 ); |
42 | 41 |
43 Prefs.patternsfile = "patterns.ini"; | 42 Prefs.patternsfile = "patterns.ini"; |
44 dataFile = IO.resolveFilePath(Prefs.patternsfile); | 43 dataFile = IO.resolveFilePath(Prefs.patternsfile); |
45 | 44 |
46 FilterStorage.addFilter(Filter.fromText("foobar")); | 45 FilterStorage.addFilter(Filter.fromText("foobar")); |
47 callback(); | 46 callback(); |
48 }; | 47 }; |
49 | 48 |
50 let testData = new Promise((resolve, reject) => | 49 let testData = new Promise((resolve, reject) => |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 return FilterStorage.restoreBackup(1); | 323 return FilterStorage.restoreBackup(1); |
325 }).then(() => | 324 }).then(() => |
326 { | 325 { |
327 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
restoring backup"); | 326 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
restoring backup"); |
328 return loadFilters(); | 327 return loadFilters(); |
329 }).then(() => | 328 }).then(() => |
330 { | 329 { |
331 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
reloading"); | 330 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after
reloading"); |
332 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 331 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
333 }; | 332 }; |
OLD | NEW |