Bug 1914887 - Enable 'mailto:' links in .eml files. r=mkmelin

Differential Revision: https://phabricator.services.mozilla.com/D220121

--HG--
extra : rebase_source : 9d4dc7676155666d6496044b5a9748b1709985ac
extra : amend_source : 43d4938eac37d80511b314e44e23aab82bdc90b2
This commit is contained in:
welpy-cw 2024-08-26 20:23:31 +00:00
Родитель f65ad3ea20
Коммит 9503add3e2
3 изменённых файлов: 46 добавлений и 4 удалений

Просмотреть файл

@ -56,11 +56,13 @@ export class MailLinkParent extends JSWindowActorParent {
_handleMailToLink({ data, target }) {
let identity = null;
// If the document with the link is a message, try to get the identity
// from the message and use it when composing.
// If the document with the link is a message from a local database,
// try to get the identity from the message and use it when composing.
const documentURI = target.windowContext.documentURI;
if (documentURI instanceof Ci.nsIMsgMessageUrl) {
documentURI.QueryInterface(Ci.nsIMsgMessageUrl);
if (
documentURI instanceof Ci.nsIMsgMessageUrl &&
documentURI.messageHeader
) {
[identity] = lazy.MailUtils.getIdentityForHeader(
documentURI.messageHeader
);

Просмотреть файл

@ -10,6 +10,7 @@
var {
close_compose_window,
compose_window_ready,
get_compose_body,
open_compose_with_forward,
open_compose_with_reply,
@ -19,6 +20,7 @@ var {
);
var {
be_in_folder,
get_about_message,
get_special_folder,
open_message_from_file,
press_delete,
@ -31,6 +33,10 @@ var { MailServices } = ChromeUtils.importESModule(
"resource:///modules/MailServices.sys.mjs"
);
var { promise_new_window } = ChromeUtils.importESModule(
"resource://testing-common/mail/WindowHelpers.sys.mjs"
);
var gDrafts;
add_setup(async function () {
@ -195,3 +201,21 @@ add_task(async function test_forward_eml_catchall() {
await close_compose_window(replyWin); // close compose window
await BrowserTestUtils.closeWindow(msgc); // close base .eml message
});
/**
* Test that clicking on a 'mailto:' link in an .eml opens a compose window.
*/
add_task(async function test_mailto_link_in_eml() {
// Open an .eml file.
const file = new FileUtils.File(getTestFilePath("data/testmsg-html.eml"));
const msgc = await open_message_from_file(file);
const composePromise = promise_new_window("msgcompose");
await BrowserTestUtils.synthesizeMouseAtCenter(
"#mailtolink",
{},
get_about_message(msgc).getMessagePaneBrowser()
);
const cwc = await compose_window_ready(composePromise);
await close_compose_window(cwc);
await BrowserTestUtils.closeWindow(msgc); // close base .eml message
});

Просмотреть файл

@ -0,0 +1,16 @@
From: "Mailtomaton" <email@mailtomaton.invalid>
To: <user@example.com>
Subject: 'mailto:' link
Date: Mon, 26 Aug 2024 21:13:10 +0200
MIME-Version: 1.0
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
<!DOCTYPE html>
<html>
<body>
<a href="mailto:email@mailtomaton.invalid" id="mailtolink">Mailto Link</a>
</body>