1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
5 * Tests from a clean state.
6 * Then does some testing that creating new profiles and marking them as
10 add_task(async () => {
11 let service = getProfileService();
13 let target = gDataHome.clone();
14 target.append("profiles.ini");
15 Assert.ok(!target.exists(), "profiles.ini should not exist yet.");
16 target.leafName = "installs.ini";
17 Assert.ok(!target.exists(), "installs.ini should not exist yet.");
19 // Create a new profile to use.
20 let newProfile = service.createProfile(null, "dedicated");
23 let profileData = readProfilesIni();
26 profileData.profiles.length,
28 "Should have the right number of profiles."
31 let profile = profileData.profiles[0];
32 Assert.equal(profile.name, "dedicated", "Should have the right name.");
33 Assert.ok(!profile.default, "Should not be marked as the old-style default.");
35 // The new profile hasn't been marked as the default yet!
37 Object.keys(profileData.installs).length,
39 "Should be no defaults for installs yet."
42 checkProfileService(profileData);
45 service.startWithLastProfile,
46 "Should be set to start with the last profile."
48 service.startWithLastProfile = false;
50 !service.startWithLastProfile,
51 "Should be set to not start with the last profile."
54 service.defaultProfile = newProfile;
57 profileData = readProfilesIni();
60 profileData.profiles.length,
62 "Should have the right number of profiles."
65 profile = profileData.profiles[0];
66 Assert.equal(profile.name, "dedicated", "Should have the right name.");
67 Assert.ok(!profile.default, "Should not be marked as the old-style default.");
69 let hash = xreDirProvider.getInstallHash();
71 Object.keys(profileData.installs).length,
73 "Should be only one known install."
76 profileData.installs[hash].default,
77 profileData.profiles[0].path,
78 "Should have marked the new profile as the default for this install."
81 checkProfileService(profileData);
83 let otherProfile = service.createProfile(null, "another");
84 service.defaultProfile = otherProfile;
88 profileData = readProfilesIni();
91 profileData.profiles.length,
93 "Should have the right number of profiles."
96 profile = profileData.profiles[0];
97 Assert.equal(profile.name, "another", "Should have the right name.");
98 Assert.ok(!profile.default, "Should not be marked as the old-style default.");
100 profile = profileData.profiles[1];
101 Assert.equal(profile.name, "dedicated", "Should have the right name.");
102 Assert.ok(!profile.default, "Should not be marked as the old-style default.");
105 Object.keys(profileData.installs).length,
107 "Should be only one known install."
110 profileData.installs[hash].default,
111 profileData.profiles[0].path,
112 "Should have marked the new profile as the default for this install."
115 checkProfileService(profileData);
117 newProfile.remove(true);
120 profileData = readProfilesIni();
123 profileData.profiles.length,
125 "Should have the right number of profiles."
128 profile = profileData.profiles[0];
129 Assert.equal(profile.name, "another", "Should have the right name.");
130 Assert.ok(!profile.default, "Should not be marked as the old-style default.");
133 Object.keys(profileData.installs).length,
135 "Should be only one known install."
138 profileData.installs[hash].default,
139 profileData.profiles[0].path,
140 "Should have marked the new profile as the default for this install."
143 checkProfileService(profileData);
145 otherProfile.remove(true);
148 profileData = readProfilesIni();
151 profileData.profiles.length,
153 "Should have the right number of profiles."
156 // We leave a reference to the missing profile to stop us trying to steal the
157 // old-style default profile on next startup.
159 Object.keys(profileData.installs).length,
161 "Should be only one known install."
164 checkProfileService(profileData);