Bug 1885565 - Part 2: Fix up parameter ordering and kDoc descriptions in NavigationBa...
[gecko.git] / toolkit / profile / xpcshell / test_select_environment_named.js
blob348ce0ff0a71fb8c4eed5e453c87f09941f72d08
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 root = makeRandomProfileDir("foo");
10   let local = gDataHomeLocal.clone();
11   local.append("foo");
13   let profileData = {
14     options: {
15       startWithLastProfile: true,
16     },
17     profiles: [
18       {
19         name: "Profile1",
20         path: root.leafName,
21       },
22       {
23         name: "Profile2",
24         path: "Path2",
25         default: true,
26       },
27       {
28         name: "Profile3",
29         path: "Path3",
30       },
31     ],
32   };
34   writeProfilesIni(profileData);
35   checkProfileService(profileData);
37   Services.env.set("XRE_PROFILE_PATH", root.path);
38   Services.env.set("XRE_PROFILE_LOCAL_PATH", local.path);
40   let { rootDir, localDir, profile, didCreate } = selectStartupProfile([
41     "-P",
42     "Profile3",
43   ]);
44   checkStartupReason("restart");
46   Assert.ok(!didCreate, "Should not have created a new profile.");
47   Assert.ok(rootDir.equals(root), "Should have selected the right root dir.");
48   Assert.ok(
49     localDir.equals(local),
50     "Should have selected the right local dir."
51   );
52   Assert.ok(profile, "A named profile matches this.");
53   Assert.equal(profile.name, "Profile1", "The right profile was matched.");
55   let service = getProfileService();
56   Assert.notEqual(
57     service.defaultProfile,
58     profile,
59     "Should not be the default profile."
60   );
61 });