/* 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 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ /** * Tests that an element with the id used by Thunderbird 2 feed messages to * show a web page doesn't make the message pane load the Content-Base page, * since the message content can't be trusted. */ const tabmail = document.getElementById("tabmail"); const about3Pane = tabmail.currentAbout3Pane; const WEB_PAGE_URL = "https://example.org/browser/comm/mail/base/test/browser/files/sampleContent.html"; let testFolder; add_setup(async function () { const account = MailServices.accounts.createLocalMailAccount(); const rootFolder = account.incomingServer.rootFolder.QueryInterface( Ci.nsIMsgLocalMailFolder ); testFolder = rootFolder .createLocalSubfolder("feedLegacyWebPageMarker") .QueryInterface(Ci.nsIMsgLocalMailFolder); testFolder.addMessage( [ "From - Mon Jan 01 00:00:00 2024", "From: sender@example.invalid", "To: recipient@example.invalid", "Subject: Legacy feed marker", "Date: Mon, 01 Jan 2024 00:00:00 +0000", "Message-ID: ", "MIME-Version: 1.0", `Content-Base: ${WEB_PAGE_URL}`, "Content-Type: text/html; charset=UTF-8", "", '
Summary
', "", ].join("\r\n") ); const message = [...testFolder.messages][0]; message.orFlags(Ci.nsMsgMessageFlags.FeedMsg); registerCleanupFunction(() => { MailServices.accounts.removeAccount(account, false); }); }); add_task(async function test_legacyWebPageMarker() { Assert.equal( Services.prefs.getIntPref("rss.show.summary"), 1, "the feed body display pref should default to summary" ); about3Pane.restoreState({ folderURI: testFolder.URI, messagePaneVisible: true, }); about3Pane.threadTree.selectedIndex = 0; await messageLoadedIn(about3Pane.messageBrowser); const aboutMessage = about3Pane.messageBrowser.contentWindow; const browser = aboutMessage.getMessagePaneBrowser(); const message = aboutMessage.gMessage; Assert.ok( browser.contentDocument.getElementById("_mailrssiframe"), "the displayed message should contain the legacy feed marker" ); Assert.ok( aboutMessage.FeedMessageHandler.shouldShowSummary(message, false), "the summary should be shown despite the legacy feed marker" ); about3Pane.threadTree.selectedIndex = -1; });