summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/message-window/browser_emlSubject.js
blob: f8fc12c4dea6fec8689408e3cea8d9e77cd330d6 (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
46
47
48
/* 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 opening an .eml file with empty subject works.
 */

"use strict";

var { open_message_from_file } = ChromeUtils.import(
  "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var { close_window } = ChromeUtils.import(
  "resource://testing-common/mozmill/WindowHelpers.jsm"
);

async function check_eml_window_title(subject, eml) {
  let file = new FileUtils.File(getTestFilePath(`data/${eml}`));
  let msgc = await open_message_from_file(file);

  let brandBundle = Services.strings.createBundle(
    "chrome://branding/locale/brand.properties"
  );
  let productName = brandBundle.GetStringFromName("brandFullName");
  let expectedTitle = subject;
  if (expectedTitle && AppConstants.platform != "macosx") {
    expectedTitle += " - ";
  }

  if (!expectedTitle || AppConstants.platform != "macosx") {
    expectedTitle += productName;
  }

  await TestUtils.waitForCondition(
    () => msgc.window.document.title == expectedTitle
  );
  Assert.equal(msgc.window.document.title, expectedTitle);
  close_window(msgc);
}

add_task(async function test_eml_empty_subject() {
  await check_eml_window_title("", "./emptySubject.eml");
});

add_task(async function test_eml_normal_subject() {
  await check_eml_window_title("An email", "./evil.eml");
});