Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / toolkit / profile / xpcshell / test_update_unselected_dedicated.js
blob4aa56eaaac3ab8258e9272e4d8a65f2df80d8b3d
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 /*
5  * Tests that an old-style default profile not previously used by this build gets
6  * ignored.
7  */
9 add_task(async () => {
10   let hash = xreDirProvider.getInstallHash();
11   let defaultProfile = makeRandomProfileDir("default");
13   // Just pretend this profile was last used by something in the profile dir.
14   let greDir = gProfD.clone();
15   greDir.append("app");
16   writeCompatibilityIni(defaultProfile, greDir, greDir);
18   writeProfilesIni({
19     profiles: [
20       {
21         name: PROFILE_DEFAULT,
22         path: defaultProfile.leafName,
23         default: true,
24       },
25     ],
26   });
28   let { profile: selectedProfile, didCreate } = selectStartupProfile();
29   checkStartupReason("firstrun-skipped-default");
31   let profileData = readProfilesIni();
33   Assert.ok(
34     profileData.options.startWithLastProfile,
35     "Should be set to start with the last profile."
36   );
37   Assert.equal(
38     profileData.profiles.length,
39     2,
40     "Should have the right number of profiles."
41   );
43   // Since there is already a profile with the desired name on dev-edition, a
44   // unique version will be used.
45   let expectedName = AppConstants.MOZ_DEV_EDITION
46     ? `${DEDICATED_NAME}-1`
47     : DEDICATED_NAME;
49   let profile = profileData.profiles[0];
50   Assert.equal(profile.name, PROFILE_DEFAULT, "Should have the right name.");
51   Assert.equal(
52     profile.path,
53     defaultProfile.leafName,
54     "Should be the original default profile."
55   );
56   Assert.ok(profile.default, "Should be marked as the old-style default.");
57   profile = profileData.profiles[1];
58   Assert.equal(profile.name, expectedName, "Should have the right name.");
59   Assert.notEqual(
60     profile.path,
61     defaultProfile.leafName,
62     "Should not be the original default profile."
63   );
64   Assert.ok(!profile.default, "Should not be marked as the old-style default.");
66   Assert.equal(
67     Object.keys(profileData.installs).length,
68     1,
69     "Should be a default for this install."
70   );
71   Assert.equal(
72     profileData.installs[hash].default,
73     profile.path,
74     "Should have marked the new profile as the default for this install."
75   );
76   Assert.ok(
77     profileData.installs[hash].locked,
78     "Should have locked as we created this profile for this install."
79   );
81   checkProfileService(profileData);
83   Assert.ok(didCreate, "Should have created a new profile.");
84   Assert.ok(
85     !selectedProfile.rootDir.equals(defaultProfile),
86     "Should be using the right directory."
87   );
88   Assert.equal(selectedProfile.name, expectedName);
89 });