summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/folder-display/browser_readMsgs.js
blob: 1f69bfbe5402641261da63a89152b7193bd21a51 (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
52
53
54
55
56
57
58
59
60
61
62
/* 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 various special messages.
 */

var { PromiseTestUtils } = ChromeUtils.import(
  "resource://testing-common/mailnews/PromiseTestUtils.jsm"
);
var { MailServices } = ChromeUtils.import(
  "resource:///modules/MailServices.jsm"
);
var {
  assert_selected_and_displayed,
  be_in_folder,
  create_folder,
  inboxFolder,
  press_delete,
  select_click_row,
  wait_for_message_display_completion,
} = ChromeUtils.import(
  "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);

/**
 * Tests that a message containing an invalid vcard can be displayed.
 */
add_task(async function testMarkedAsRead() {
  let folder = await create_folder("SpecialMsgs");
  Services.prefs.setBoolPref("mailnews.mark_message_read.auto", true);

  let file = new FileUtils.File(getTestFilePath("data/test-invalid-vcard.eml"));
  Assert.ok(file.exists(), "test data file should exist");
  let promiseCopyListener = new PromiseTestUtils.PromiseCopyListener();
  // Copy gIncomingMailFile into the Inbox.
  MailServices.copy.copyFileMessage(
    file,
    folder,
    null,
    false,
    0,
    "",
    promiseCopyListener,
    null
  );
  await promiseCopyListener.promise;
  await be_in_folder(folder);
  let msg = select_click_row(0);
  assert_selected_and_displayed(0);
  // Make sure it's the msg we want.
  Assert.equal(msg.subject, "this contains an invalid vcard");
  // The message should get marked as read.
  await BrowserTestUtils.waitForCondition(
    () => msg.isRead,
    "should get marked as read"
  );
  await be_in_folder(inboxFolder);
  folder.deleteSelf(null);
  Services.prefs.clearUserPref("mailnews.mark_message_read.auto");
});