summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/composition/browser_xUnsent.js
blob: dd3be862944952c0982b819a5474126884ede4fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* 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 X-Unsent .eml messages are correctly opened for composition.
 */

"use strict";

var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");

function waitForComposeWindow() {
  return BrowserTestUtils.domWindowOpened(null, async win => {
    await BrowserTestUtils.waitForEvent(win, "load");
    await BrowserTestUtils.waitForEvent(win, "focus", true);
    return (
      win.document.documentURI ===
      "chrome://messenger/content/messengercompose/messengercompose.xhtml"
    );
  });
}

/**
 * Tests that opening an .eml with X-Unsent: 1 opens composition correctly.
 */
add_task(async function openXUnsent() {
  let compWinReady = waitForComposeWindow();
  let file = new FileUtils.File(getTestFilePath(`data/xunsent.eml`));
  let fileURL = Services.io
    .newFileURI(file)
    .QueryInterface(Ci.nsIFileURL)
    .mutate()
    .setQuery("type=application/x-message-display")
    .finalize();
  MailUtils.openEMLFile(window, file, fileURL);
  let compWin = await compWinReady;

  Assert.equal(
    compWin.document.getElementById("msgSubject").value,
    "xx unsent",
    "Should open as draft with correct subject"
  );
  compWin.close();
});