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
10 add_task(async () => {
11 let root = makeRandomProfileDir("foo");
12 let local = gDataHomeLocal.clone();
15 writeCompatibilityIni(root);
19 startWithLastProfile: true,
23 name: PROFILE_DEFAULT,
36 // Another install is using the profile but it isn't locked.
39 default: root.leafName,
44 writeProfilesIni(profileData);
45 checkProfileService(profileData);
47 Services.env.set("XRE_PROFILE_PATH", root.path);
48 Services.env.set("XRE_PROFILE_LOCAL_PATH", local.path);
50 let { rootDir, localDir, profile, didCreate } = selectStartupProfile();
51 checkStartupReason("restart-claimed-default");
53 Assert.ok(!didCreate, "Should not have created a new profile.");
54 Assert.ok(rootDir.equals(root), "Should have selected the right root dir.");
56 localDir.equals(local),
57 "Should have selected the right local dir."
59 Assert.ok(profile, "A named profile matches this.");
60 Assert.equal(profile.name, PROFILE_DEFAULT, "The right profile was matched.");
62 let service = getProfileService();
64 service.defaultProfile,
66 "Should be the default profile."
69 service.currentProfile,
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 not have locked as we're not the default app."