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 don't snatch it if it is
7 * locked by another install.
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 and it is locked.
39 default: root.leafName,
45 writeProfilesIni(profileData);
46 checkProfileService(profileData);
48 Services.env.set("XRE_PROFILE_PATH", root.path);
49 Services.env.set("XRE_PROFILE_LOCAL_PATH", local.path);
51 let { rootDir, localDir, profile, didCreate } = selectStartupProfile();
52 checkStartupReason("restart-skipped-default");
54 // Since there is already a profile with the desired name on dev-edition, a
55 // unique version will be used.
56 let expectedName = AppConstants.MOZ_DEV_EDITION
57 ? `${DEDICATED_NAME}-1`
60 Assert.ok(didCreate, "Should have created a new profile.");
61 Assert.ok(!rootDir.equals(root), "Should have selected the right root dir.");
63 !localDir.equals(local),
64 "Should have selected the right local dir."
66 Assert.ok(profile, "A named profile was returned.");
67 Assert.equal(profile.name, expectedName, "The right profile name was used.");
69 let service = getProfileService();
71 service.defaultProfile,
73 "Should be the default profile."
76 service.currentProfile,
78 "Should be the current profile."
81 profileData = readProfilesIni();
84 profileData.profiles[0].name,
86 "Should be the right profile."
89 profileData.profiles[0].default,
90 "Should be the old default profile."
93 profileData.profiles[0].path,
95 "Should be the correct path."
98 profileData.profiles[1].name,
100 "Should be the right profile."
103 !profileData.profiles[1].default,
104 "Should not be the old default profile."
107 let hash = xreDirProvider.getInstallHash();
109 Object.keys(profileData.installs).length,
111 "Should be one known install."
114 profileData.installs[hash].default,
116 "Should have marked the original default profile as the default for this install."
119 profileData.installs[hash].locked,
120 "Should have locked as we created the profile for this install."
123 profileData.installs.otherinstall.default,
125 "Should have left the other profile as the default for the other install."
128 profileData.installs[hash].locked,
129 "Should still be locked to the other install."