1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
5 * Tests that the environment variables are used to select a profile and that
6 * on the first run of a dedicated profile build we snatch it if it was the
7 * default profile and lock it when we're the default app.
10 add_task(async () => {
13 let root = makeRandomProfileDir("foo");
14 let local = gDataHomeLocal.clone();
17 writeCompatibilityIni(root);
21 startWithLastProfile: true,
25 name: PROFILE_DEFAULT,
38 // Another install is using the profile but it isn't locked.
41 default: root.leafName,
46 writeProfilesIni(profileData);
47 checkProfileService(profileData);
49 Services.env.set("XRE_PROFILE_PATH", root.path);
50 Services.env.set("XRE_PROFILE_LOCAL_PATH", local.path);
52 let { rootDir, localDir, profile, didCreate } = selectStartupProfile();
53 checkStartupReason("restart-claimed-default");
55 Assert.ok(!didCreate, "Should not have created a new profile.");
56 Assert.ok(rootDir.equals(root), "Should have selected the right root dir.");
58 localDir.equals(local),
59 "Should have selected the right local dir."
61 Assert.ok(!!profile, "A named profile matches this.");
62 Assert.equal(profile.name, PROFILE_DEFAULT, "The right profile was matched.");
64 let service = getProfileService();
66 service.defaultProfile === profile,
67 "Should be the default profile."
70 service.currentProfile === profile,
71 "Should be the current profile."
74 profileData = readProfilesIni();
76 profileData.profiles[0].name,
78 "Should be the right profile."
81 profileData.profiles[0].default,
82 "Should still be the old default profile."
85 let hash = xreDirProvider.getInstallHash();
86 // The info about the other install will have been removed so it goes through first run on next startup.
88 Object.keys(profileData.installs).length,
90 "Should be one known install."
93 profileData.installs[hash].default,
95 "Should have marked the original default profile as the default for this install."
98 profileData.installs[hash].locked,
99 "Should have locked as we're the default app."