Bug 1796551 [wpt PR 36570] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / toolkit / profile / xpcshell / test_snap.js
bloba9bf4ed08a61e42e5bd7a05c46c2442cf1ca3c75
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  * used in a snap environment.
7  */
9 add_task(async () => {
10   let defaultProfile = makeRandomProfileDir("default");
12   // Just pretend this profile was last used by something in the profile dir.
13   let greDir = gProfD.clone();
14   greDir.append("app");
15   writeCompatibilityIni(defaultProfile, greDir, greDir);
17   writeProfilesIni({
18     profiles: [
19       {
20         name: PROFILE_DEFAULT,
21         path: defaultProfile.leafName,
22         default: true,
23       },
24     ],
25   });
27   simulateSnapEnvironment();
29   let { profile: selectedProfile, didCreate } = selectStartupProfile();
30   checkStartupReason("default");
32   let profileData = readProfilesIni();
33   let installsINI = gDataHome.clone();
34   installsINI.append("installs.ini");
35   Assert.ok(
36     !installsINI.exists(),
37     "Installs database should not have been created."
38   );
40   Assert.ok(
41     profileData.options.startWithLastProfile,
42     "Should be set to start with the last profile."
43   );
44   Assert.equal(
45     profileData.profiles.length,
46     1,
47     "Should have the right number of profiles."
48   );
50   let profile = profileData.profiles[0];
51   Assert.equal(profile.name, PROFILE_DEFAULT, "Should have the right name.");
52   Assert.equal(
53     profile.path,
54     defaultProfile.leafName,
55     "Should be the original default profile."
56   );
57   Assert.ok(profile.default, "Should be marked as the old-style default.");
59   checkProfileService(profileData);
61   Assert.ok(!didCreate, "Should not have created a new profile.");
62   Assert.ok(
63     selectedProfile.rootDir.equals(defaultProfile),
64     "Should be using the right directory."
65   );
66   Assert.equal(selectedProfile.name, PROFILE_DEFAULT);
67 });