Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / toolkit / profile / xpcshell / test_use_dedicated.js
blobd6bbdca4d8380461c7603dd05f547669e92b9533
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5  * Tests that if installs.ini lists a profile we use it as the default.
6  */
8 add_task(async () => {
9   let hash = xreDirProvider.getInstallHash();
10   let defaultProfile = makeRandomProfileDir("default");
11   let dedicatedProfile = makeRandomProfileDir("dedicated");
12   let devProfile = makeRandomProfileDir("devedition");
14   // Make sure we don't steal the old-style default.
15   writeCompatibilityIni(defaultProfile);
17   writeProfilesIni({
18     profiles: [
19       {
20         name: "default",
21         path: defaultProfile.leafName,
22         default: true,
23       },
24       {
25         name: "dedicated",
26         path: dedicatedProfile.leafName,
27       },
28       {
29         name: "dev-edition-default",
30         path: devProfile.leafName,
31       },
32     ],
33     installs: {
34       [hash]: {
35         default: dedicatedProfile.leafName,
36       },
37       otherhash: {
38         default: "foobar",
39       },
40     },
41   });
43   let { profile: selectedProfile, didCreate } = selectStartupProfile();
44   checkStartupReason("default");
46   let profileData = readProfilesIni();
48   Assert.ok(
49     profileData.options.startWithLastProfile,
50     "Should be set to start with the last profile."
51   );
52   Assert.equal(
53     profileData.profiles.length,
54     3,
55     "Should have the right number of profiles."
56   );
58   let profile = profileData.profiles[0];
59   Assert.equal(profile.name, `dedicated`, "Should have the right name.");
60   Assert.equal(
61     profile.path,
62     dedicatedProfile.leafName,
63     "Should be the expected dedicated profile."
64   );
65   Assert.ok(!profile.default, "Should not be marked as the old-style default.");
67   profile = profileData.profiles[1];
68   Assert.equal(profile.name, "default", "Should have the right name.");
69   Assert.equal(
70     profile.path,
71     defaultProfile.leafName,
72     "Should be the original default profile."
73   );
74   Assert.ok(profile.default, "Should be marked as the old-style default.");
76   Assert.equal(
77     Object.keys(profileData.installs).length,
78     2,
79     "Should be two known installs."
80   );
81   Assert.equal(
82     profileData.installs[hash].default,
83     dedicatedProfile.leafName,
84     "Should have kept the default for this install."
85   );
86   Assert.equal(
87     profileData.installs.otherhash.default,
88     "foobar",
89     "Should have kept the default for the other install."
90   );
92   checkProfileService(profileData);
94   Assert.ok(!didCreate, "Should not have created a new profile.");
95   Assert.ok(
96     selectedProfile.rootDir.equals(dedicatedProfile),
97     "Should be using the right directory."
98   );
99   Assert.equal(selectedProfile.name, "dedicated");