| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 | 2 |
| 3 (function() | 3 (function() |
| 4 { | 4 { |
| 5 const {Prefs} = require("prefs"); | 5 const {Prefs} = require("prefs"); |
| 6 | 6 |
| 7 module("Preferences", { | 7 module("Preferences", { |
| 8 setup() | 8 setup() |
| 9 { | 9 { |
| 10 this._pbackup = Object.create(null); | 10 this._pbackup = Object.create(null); |
| 11 for (let pref in Prefs) | 11 for (let pref in Prefs) |
| 12 { | 12 { |
| 13 let value = Prefs[pref]; | 13 let value = Prefs[pref]; |
| 14 this._pbackup[pref] = value; | 14 this._pbackup[pref] = value; |
| 15 } | 15 } |
| 16 Prefs.enabled = true; | 16 Prefs.enabled = true; |
| 17 }, | 17 }, |
| 18 | 18 |
| 19 teardown() | 19 teardown() |
| 20 { | 20 { |
| 21 for (let pref in this._pbackup) | 21 for (let pref in this._pbackup) |
| 22 Prefs[pref] = this._pbackup[pref]; | 22 Prefs[pref] = this._pbackup[pref]; |
| 23 } | 23 } |
| 24 }); | 24 }); |
| 25 | 25 |
| 26 function checkPrefExists(name, expectedValue, description, assert) | 26 function checkPrefExists(name, expectedValue, description, assert) |
| 27 { | 27 { |
| 28 let done = assert.async(); | 28 let done = assert.async(); |
| 29 let key = "pref:" + name; | 29 let key = "pref:" + name; |
| 30 chrome.storage.local.get(key, items => | 30 browser.storage.local.get(key, items => |
| 31 { | 31 { |
| 32 equal(key in items, expectedValue, description); | 32 equal(key in items, expectedValue, description); |
| 33 done(); | 33 done(); |
| 34 }); | 34 }); |
| 35 } | 35 } |
| 36 | 36 |
| 37 function checkPref(name, expectedValue, description, assert) | 37 function checkPref(name, expectedValue, description, assert) |
| 38 { | 38 { |
| 39 let done = assert.async(); | 39 let done = assert.async(); |
| 40 let key = "pref:" + name; | 40 let key = "pref:" + name; |
| 41 chrome.storage.local.get(key, items => | 41 browser.storage.local.get(key, items => |
| 42 { | 42 { |
| 43 deepEqual(items[key], expectedValue, description); | 43 deepEqual(items[key], expectedValue, description); |
| 44 done(); | 44 done(); |
| 45 }); | 45 }); |
| 46 } | 46 } |
| 47 | 47 |
| 48 test("Numerical pref", assert => | 48 test("Numerical pref", assert => |
| 49 { | 49 { |
| 50 Prefs.patternsbackups = 0; | 50 Prefs.patternsbackups = 0; |
| 51 equal( | 51 equal( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 delete Prefs.notificationdata.foo; | 154 delete Prefs.notificationdata.foo; |
| 155 delete Prefs.notificationdata.bar; | 155 delete Prefs.notificationdata.bar; |
| 156 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); | 156 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); |
| 157 deepEqual( | 157 deepEqual( |
| 158 Prefs.notificationdata, {}, | 158 Prefs.notificationdata, {}, |
| 159 "Prefs object returns the correct value after setting pref to " + | 159 "Prefs object returns the correct value after setting pref to " + |
| 160 "default value" | 160 "default value" |
| 161 ); | 161 ); |
| 162 }); | 162 }); |
| 163 }()); | 163 }()); |
| OLD | NEW |