blob: df51fa9abfbe149a6df510db4c270322e9284cd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
"use strict";
AddonTestUtils.init(this);
AddonTestUtils.overrideCertDB();
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1"
);
// Tests that startupData is persisted and is available at startup
add_task(async function test_startupData() {
await AddonTestUtils.promiseStartupManager();
let wrapper = ExtensionTestUtils.loadExtension({
useAddonManager: "permanent",
});
await wrapper.startup();
let { extension } = wrapper;
deepEqual(
extension.startupData,
{},
"startupData for a new extension defaults to empty object"
);
const DATA = { test: "i am some startup data" };
extension.startupData = DATA;
extension.saveStartupData();
await AddonTestUtils.promiseRestartManager();
await wrapper.startupPromise;
({ extension } = wrapper);
deepEqual(extension.startupData, DATA, "startupData is present on restart");
const DATA2 = { other: "this is different data" };
extension.startupData = DATA2;
extension.saveStartupData();
await AddonTestUtils.promiseRestartManager();
await wrapper.startupPromise;
({ extension } = wrapper);
deepEqual(
extension.startupData,
DATA2,
"updated startupData is present on restart"
);
await wrapper.unload();
await AddonTestUtils.promiseShutdownManager();
});
|