Bug 1885565 - Part 2: Fix up parameter ordering and kDoc descriptions in NavigationBa...
[gecko.git] / toolkit / profile / xpcshell / test_check_backup.js
blob2f5a9dbf181e770ec32e9a5275cb8c5a9e3ea10e
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 /*
5  * Tests that when the profiles DB is missing the install data we reload it.
6  */
8 add_task(async () => {
9   let hash = xreDirProvider.getInstallHash();
11   let profileData = {
12     options: {
13       startWithLastProfile: true,
14     },
15     profiles: [
16       {
17         name: "Profile1",
18         path: "Path1",
19       },
20       {
21         name: "Profile2",
22         path: "Path2",
23       },
24     ],
25   };
27   let installs = {
28     [hash]: {
29       default: "Path2",
30     },
31   };
33   writeProfilesIni(profileData);
34   writeInstallsIni({ installs });
36   let { profile, didCreate } = selectStartupProfile();
37   checkStartupReason("default");
38   let { databaseVersion, profileCount } = getTelemetryScalars();
39   Assert.equal(
40     databaseVersion,
41     "1",
42     "Old database file was present at startup."
43   );
44   Assert.equal(profileCount, 2, "Should be two profiles.");
46   // Should have added the backup data to the service, check that is true.
47   profileData.installs = installs;
48   checkProfileService(profileData);
50   Assert.ok(!didCreate, "Should not have created a new profile.");
51   Assert.equal(
52     profile.name,
53     "Profile2",
54     "Should have selected the right profile"
55   );
56 });