Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

/* Any copyright is dedicated to the Public Domain.
"use strict";
const { MockRegistrar } = ChromeUtils.importESModule(
);
let gLaunches = [];
add_setup(() => {
let mockCID = MockRegistrar.register("@mozilla.org/widget/macdocksupport;1", {
QueryInterface: ChromeUtils.generateQI(["nsIMacDockSupport"]),
launchAppBundle(appBundle, args) {
gLaunches.push({ path: appBundle.path, args });
},
});
registerCleanupFunction(() => MockRegistrar.unregister(mockCID));
});
function expectedBundlePath() {
return Services.dirsvc.get("XREExeF", Ci.nsIFile).parent.parent.parent.path;
}
add_task(async function test_createInstanceWithProfile() {
gLaunches = [];
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"].getService(
Ci.nsIToolkitProfileService
);
let profileDir = await IOUtils.createUniqueDirectory(
PathUtils.tempDir,
"createInstanceWithProfile"
);
let profile = profileService.createProfile(
await IOUtils.getDirectory(profileDir),
"Other Profile",
"test"
);
registerCleanupFunction(async () => {
profile.remove(false);
await IOUtils.remove(profileDir, { recursive: true });
});
Services.startup.createInstanceWithProfile(profile, ["-new-tab", "about:"]);
Assert.deepEqual(
gLaunches,
[
{
path: expectedBundlePath(),
args: ["-P", "Other Profile", "-new-tab", "about:"],
},
],
"The new instance is launched once through the app bundle"
);
});
add_task(function test_launchNewInstance() {
gLaunches = [];
Services.startup.launchNewInstance(["--profile", "/tmp/some-profile"]);
Assert.deepEqual(
gLaunches,
[
{
path: expectedBundlePath(),
args: ["--profile", "/tmp/some-profile"],
},
],
"The new instance is launched once through the app bundle"
);
});