summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/xpcshell/test_firstStartup.js
blob: 73570ae37e191dbed15dae9b59c56442308888b7 (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
"use strict";

const { AppConstants } = ChromeUtils.importESModule(
  "resource://gre/modules/AppConstants.sys.mjs"
);
const { FirstStartup } = ChromeUtils.importESModule(
  "resource://gre/modules/FirstStartup.sys.mjs"
);
const { updateAppInfo } = ChromeUtils.importESModule(
  "resource://testing-common/AppInfo.sys.mjs"
);

const PREF_TIMEOUT = "first-startup.timeout";

add_task(async function test_success() {
  updateAppInfo();
  FirstStartup.init();
  if (AppConstants.MOZ_NORMANDY || AppConstants.MOZ_UPDATE_AGENT) {
    equal(FirstStartup.state, FirstStartup.SUCCESS);
  } else {
    equal(FirstStartup.state, FirstStartup.UNSUPPORTED);
  }
});

add_task(async function test_timeout() {
  updateAppInfo();
  Services.prefs.setIntPref(PREF_TIMEOUT, 0);
  FirstStartup.init();

  if (AppConstants.MOZ_NORMANDY || AppConstants.MOZ_UPDATE_AGENT) {
    equal(FirstStartup.state, FirstStartup.TIMED_OUT);
  } else {
    equal(FirstStartup.state, FirstStartup.UNSUPPORTED);
  }
});