blob: 71425bec4aa96334d8027343163cad12336b40a2 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test startup and restart when no add-ons are installed
// bug 944006
// Load XPI Provider to get schema version ID
const {
XPIInternal: { DB_SCHEMA },
} = ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm");
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// Test for a preference to either exist with a specified value, or not exist at all
function checkPending() {
try {
Assert.ok(!Services.prefs.getBoolPref("extensions.pendingOperations"));
} catch (e) {
// OK
}
}
// Make sure all our extension state is empty/nonexistent
function check_empty_state() {
Assert.equal(
Services.prefs.getIntPref("extensions.databaseSchema"),
DB_SCHEMA
);
checkPending();
}
// After first run with no add-ons, we expect:
// no extensions.json is created
// no extensions.ini
// database schema version preference is set
// bootstrap add-ons preference is not found
// add-on directory state preference is an empty array
// no pending operations
add_task(async function first_run() {
await promiseStartupManager();
check_empty_state();
await true;
});
// Now do something that causes a DB load, and re-check
async function trigger_db_load() {
let addonList = await AddonManager.getAddonsByTypes(["extension"]);
Assert.equal(addonList.length, 0);
check_empty_state();
await true;
}
add_task(trigger_db_load);
// Now restart the manager and check again
add_task(async function restart_and_recheck() {
await promiseRestartManager();
check_empty_state();
await true;
});
// and reload the DB again
add_task(trigger_db_load);
// When we start up with no DB and an old database schema, we should update the
// schema number but not create a database
add_task(async function upgrade_schema_version() {
await promiseShutdownManager();
Services.prefs.setIntPref("extensions.databaseSchema", 1);
await promiseStartupManager();
Assert.equal(
Services.prefs.getIntPref("extensions.databaseSchema"),
DB_SCHEMA
);
check_empty_state();
});
|