Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
const { MailServices } = ChromeUtils.importESModule(
);
const { MessageGenerator } = ChromeUtils.importESModule(
);
const { ServerTestUtils } = ChromeUtils.importESModule(
);
const generator = new MessageGenerator();
async function newComposeWindow() {
const composeWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
const params = Cc[
"@mozilla.org/messengercompose/composeparams;1"
].createInstance(Ci.nsIMsgComposeParams);
params.composeFields = Cc[
"@mozilla.org/messengercompose/composefields;1"
].createInstance(Ci.nsIMsgCompFields);
const [name, address] = generator.makeNameAndAddress();
const subject = generator.makeSubject();
params.composeFields.to = `"${name}" <${address}>`;
params.composeFields.subject = subject;
params.composeFields.body = `Hello ${name}!`;
MailServices.compose.OpenComposeWindowWithParams(null, params);
const composeWindow = await composeWindowPromise;
if (!composeWindow.composeEditorReady) {
await BrowserTestUtils.waitForEvent(composeWindow, "compose-editor-ready");
}
await SimpleTest.promiseFocus(composeWindow);
return { composeWindow, subject };
}