LEFT | RIGHT |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 { | 53 { |
54 if (error) | 54 if (error) |
55 reject(error); | 55 reject(error); |
56 else | 56 else |
57 resolve(data); | 57 resolve(data); |
58 }); | 58 }); |
59 }); | 59 }); |
60 | 60 |
61 function loadFilters(file) | 61 function loadFilters(file) |
62 { | 62 { |
63 return Promise.resolve().then(() => | 63 FilterStorage.loadFromDisk(file); |
64 { | 64 return FilterNotifier.once("load"); |
65 FilterStorage.loadFromDisk(file); | |
66 return FilterNotifier.once("load"); | |
67 }); | |
68 } | 65 } |
69 | 66 |
70 function saveFilters(file) | 67 function saveFilters(file) |
71 { | 68 { |
72 return Promise.resolve().then(() => | 69 FilterStorage.saveToDisk(file); |
73 { | 70 return FilterNotifier.once("save"); |
74 FilterStorage.saveToDisk(file); | |
75 return FilterNotifier.once("save"); | |
76 }); | |
77 } | 71 } |
78 | 72 |
79 function testReadWrite(test, withExternal) | 73 function testReadWrite(test, withExternal) |
80 { | 74 { |
81 let tempFile = IO.resolveFilePath("temp_patterns1.ini"); | 75 let tempFile = IO.resolveFilePath("temp_patterns1.ini"); |
82 let tempFile2 = IO.resolveFilePath("temp_patterns2.ini"); | 76 let tempFile2 = IO.resolveFilePath("temp_patterns2.ini"); |
83 | 77 |
84 function canonize(data) | 78 function canonize(data) |
85 { | 79 { |
86 let curSection = null; | 80 let curSection = null; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 backupFile.lastModifiedTime -= 25*60*60*1000; | 282 backupFile.lastModifiedTime -= 25*60*60*1000; |
289 oldModifiedTime = backupFile2.lastModifiedTime; | 283 oldModifiedTime = backupFile2.lastModifiedTime; |
290 return saveFilters(null); | 284 return saveFilters(null); |
291 }).then(() => | 285 }).then(() => |
292 { | 286 { |
293 test.notEqual(backupFile2.lastModifiedTime, oldModifiedTime, "Second backup
overwritten if first one is 25 hours old"); | 287 test.notEqual(backupFile2.lastModifiedTime, oldModifiedTime, "Second backup
overwritten if first one is 25 hours old"); |
294 | 288 |
295 test.ok(!backupFile3.exists(), "Third backup not created with patternsbackup
s = 2"); | 289 test.ok(!backupFile3.exists(), "Third backup not created with patternsbackup
s = 2"); |
296 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 290 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
297 }; | 291 }; |
LEFT | RIGHT |