Bug 1885565 - Part 2: Fix up parameter ordering and kDoc descriptions in NavigationBa...
[gecko.git] / toolkit / profile / xpcshell / test_select_environment.js
blobf7e3138191ceedf92c533806bf8a84d6c290ed27
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 /*
5  * Tests that the environment variables are used to select a profile.
6  */
8 add_task(async () => {
9   let dir = makeRandomProfileDir("foo");
11   let profileData = {
12     options: {
13       startWithLastProfile: true,
14     },
15     profiles: [
16       {
17         name: "Profile1",
18         path: dir.leafName,
19       },
20       {
21         name: "Profile2",
22         path: "Path2",
23         default: true,
24       },
25       {
26         name: "Profile3",
27         path: "Path3",
28       },
29     ],
30   };
32   writeProfilesIni(profileData);
33   checkProfileService(profileData);
35   Services.env.set("XRE_PROFILE_PATH", dir.path);
36   Services.env.set("XRE_PROFILE_LOCAL_PATH", dir.path);
38   let { rootDir, localDir, profile, didCreate } = selectStartupProfile();
39   checkStartupReason("restart");
41   Assert.ok(!didCreate, "Should not have created a new profile.");
42   Assert.ok(rootDir.equals(dir), "Should have selected the right root dir.");
43   Assert.ok(localDir.equals(dir), "Should have selected the right local dir.");
44   Assert.ok(!profile, "No named profile matches this.");
45 });