Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / toolkit / profile / xpcshell / test_update_unknown_dedicated.js
blob1fd8c30fbf17ab824596282651216ac7a64d3961
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 any build
6  * doesn't get updated to a dedicated profile for this build and we don't set
7  * the flag to show the user info about dedicated profiles.
8  */
10 add_task(async () => {
11   let hash = xreDirProvider.getInstallHash();
12   let defaultProfile = makeRandomProfileDir("default");
14   writeProfilesIni({
15     profiles: [
16       {
17         name: PROFILE_DEFAULT,
18         path: defaultProfile.leafName,
19         default: true,
20       },
21     ],
22   });
24   let { profile: selectedProfile, didCreate } = selectStartupProfile();
25   checkStartupReason("firstrun-created-default");
27   let profileData = readProfilesIni();
29   Assert.ok(
30     profileData.options.startWithLastProfile,
31     "Should be set to start with the last profile."
32   );
33   Assert.equal(
34     profileData.profiles.length,
35     2,
36     "Should have the right number of profiles."
37   );
39   // Since there is already a profile with the desired name on dev-edition, a
40   // unique version will be used.
41   let expectedName = AppConstants.MOZ_DEV_EDITION
42     ? `${DEDICATED_NAME}-1`
43     : DEDICATED_NAME;
45   let profile = profileData.profiles[0];
46   Assert.equal(profile.name, PROFILE_DEFAULT, "Should have the right name.");
47   Assert.equal(
48     profile.path,
49     defaultProfile.leafName,
50     "Should be the original default profile."
51   );
52   Assert.ok(profile.default, "Should be marked as the old-style default.");
53   profile = profileData.profiles[1];
54   Assert.equal(profile.name, expectedName, "Should have the right name.");
55   Assert.notEqual(
56     profile.path,
57     defaultProfile.leafName,
58     "Should not be the original default profile."
59   );
60   Assert.ok(!profile.default, "Should not be marked as the old-style default.");
62   Assert.equal(
63     Object.keys(profileData.installs).length,
64     1,
65     "Should be a default for installs."
66   );
67   Assert.equal(
68     profileData.installs[hash].default,
69     profile.path,
70     "Should have the right default profile."
71   );
72   Assert.ok(
73     profileData.installs[hash].locked,
74     "Should have locked as we created this profile for this install."
75   );
77   checkProfileService(profileData);
79   Assert.ok(didCreate, "Should have created a new profile.");
80   Assert.ok(
81     !selectedProfile.rootDir.equals(defaultProfile),
82     "Should not be using the old directory."
83   );
84   Assert.equal(selectedProfile.name, expectedName);
85 });