summaryrefslogtreecommitdiffstats
path: root/toolkit/profile/xpcshell/test_claim_locked.js
blob: bffdea39dcf05233bd1e946e1755d680f2b6b56c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/*
 * Tests that an old-style default profile already locked to a different install
 * isn't claimed by this install.
 */

add_task(async () => {
  let defaultProfile = makeRandomProfileDir("default");

  writeCompatibilityIni(defaultProfile);

  writeProfilesIni({
    profiles: [
      {
        name: "Foo",
        path: defaultProfile.leafName,
        default: true,
      },
    ],
    installs: {
      other: {
        default: defaultProfile.leafName,
        locked: true,
      },
    },
  });

  let { profile: selectedProfile, didCreate } = selectStartupProfile();

  let profileData = readProfilesIni();

  Assert.ok(
    profileData.options.startWithLastProfile,
    "Should be set to start with the last profile."
  );
  Assert.equal(
    profileData.profiles.length,
    2,
    "Should have the right number of profiles."
  );

  let hash = xreDirProvider.getInstallHash();
  Assert.equal(
    Object.keys(profileData.installs).length,
    2,
    "Should be two known installs."
  );
  Assert.notEqual(
    profileData.installs[hash].default,
    defaultProfile.leafName,
    "Should not have marked the original default profile as the default for this install."
  );
  Assert.ok(
    profileData.installs[hash].locked,
    "Should have locked as we created this profile for this install."
  );

  checkProfileService(profileData);

  Assert.ok(didCreate, "Should have created a new profile.");
  Assert.ok(
    !selectedProfile.rootDir.equals(defaultProfile),
    "Should be using a different directory."
  );
  Assert.equal(selectedProfile.name, DEDICATED_NAME);
});