summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell/test_systemaddomstartupprefs.js
blob: fb45d60ff8816a756086f9ae82db74bd4d15cb2b (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

// This verifies that system addon about:config prefs
// are honored during startup/restarts/upgrades.
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2");

let distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "empty"], true);
registerDirectory("XREAppFeat", distroDir);

AddonTestUtils.usePrivilegedSignatures = "system";

add_task(initSystemAddonDirs);

BootstrapMonitor.init();

add_task(async function setup() {
  let xpi = await getSystemAddonXPI(1, "1.0");
  await AddonTestUtils.manuallyInstall(xpi, distroDir);
});

add_task(async function systemAddonPreffedOff() {
  const id = "system1@tests.mozilla.org";
  Services.prefs.setBoolPref("extensions.system1.enabled", false);

  await overrideBuiltIns({ system: [id] });

  await promiseStartupManager();

  BootstrapMonitor.checkInstalled(id);
  BootstrapMonitor.checkNotStarted(id);

  await promiseRestartManager();

  BootstrapMonitor.checkNotStarted(id);

  await promiseShutdownManager({ clearOverrides: false });
});

add_task(async function systemAddonPreffedOn() {
  const id = "system1@tests.mozilla.org";
  Services.prefs.setBoolPref("extensions.system1.enabled", true);

  await promiseStartupManager("2.0");

  BootstrapMonitor.checkInstalled(id);
  BootstrapMonitor.checkStarted(id);

  await promiseRestartManager();

  BootstrapMonitor.checkStarted(id);

  await promiseShutdownManager();
});