summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/attachment/browser_attachmentInPlainMsg.js
blob: fb8ff5eb6c411de8b514acb9ed032b52ce3c6187 (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
49
50
51
/* 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/. */

"use strict";

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

/**
 * Bug 1358565
 * Check that a non-empty image is shown as attachment and is detected as non-empty
 * when message is viewed as plain text.
 */
add_task(async function test_attachment_not_empty() {
  Services.prefs.setBoolPref("mailnews.display.prefer_plaintext", true);

  let file = new FileUtils.File(getTestFilePath("data/bug1358565.eml"));

  let msgc = await open_message_from_file(file);
  let aboutMessage = get_about_message(msgc.window);

  EventUtils.synthesizeMouseAtCenter(
    aboutMessage.document.getElementById("attachmentToggle"),
    {},
    aboutMessage
  );
  Assert.equal(
    aboutMessage.document.getElementById("attachmentList").itemCount,
    1
  );

  let attachmentElem = aboutMessage.document
    .getElementById("attachmentList")
    .getItemAtIndex(0);
  Assert.equal(attachmentElem.attachment.contentType, "image/jpeg");
  Assert.equal(attachmentElem.attachment.name, "bug.png");
  Assert.ok(attachmentElem.attachment.hasFile);
  Assert.ok(
    !(await attachmentElem.attachment.isEmpty()),
    "Attachment incorrectly determined empty"
  );

  close_window(msgc);

  Services.prefs.clearUserPref("mailnews.display.prefer_plaintext");
});