LEFT | RIGHT |
1 /* globals preparePrefs, restorePrefs */ | |
2 | |
3 "use strict"; | 1 "use strict"; |
4 | 2 |
5 (function() | 3 (function() |
6 { | 4 { |
7 const {Prefs} = require("prefs"); | 5 const {Prefs} = require("prefs"); |
8 | 6 |
9 module("Preferences", { | 7 module("Preferences", { |
10 setup() | 8 setup() |
11 { | 9 { |
12 preparePrefs.call(this); | 10 this._pbackup = Object.create(null); |
| 11 for (let pref in Prefs) |
| 12 { |
| 13 let value = Prefs[pref]; |
| 14 this._pbackup[pref] = value; |
| 15 } |
| 16 Prefs.enabled = true; |
13 }, | 17 }, |
14 | 18 |
15 teardown() | 19 teardown() |
16 { | 20 { |
17 restorePrefs.call(this); | 21 for (let pref in this._pbackup) |
| 22 Prefs[pref] = this._pbackup[pref]; |
18 } | 23 } |
19 }); | 24 }); |
20 | 25 |
21 function checkPrefExists(name, expectedValue, description, assert) | 26 function checkPrefExists(name, expectedValue, description, assert) |
22 { | 27 { |
23 let done = assert.async(); | 28 let done = assert.async(); |
24 let key = "pref:" + name; | 29 let key = "pref:" + name; |
25 chrome.storage.local.get(key, items => | 30 chrome.storage.local.get(key, items => |
26 { | 31 { |
27 equal(key in items, expectedValue, description); | 32 equal(key in items, expectedValue, description); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 delete Prefs.notificationdata.foo; | 154 delete Prefs.notificationdata.foo; |
150 delete Prefs.notificationdata.bar; | 155 delete Prefs.notificationdata.bar; |
151 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); | 156 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); |
152 deepEqual( | 157 deepEqual( |
153 Prefs.notificationdata, {}, | 158 Prefs.notificationdata, {}, |
154 "Prefs object returns the correct value after setting pref to " + | 159 "Prefs object returns the correct value after setting pref to " + |
155 "default value" | 160 "default value" |
156 ); | 161 ); |
157 }); | 162 }); |
158 }()); | 163 }()); |
LEFT | RIGHT |