summaryrefslogtreecommitdiffstats
path: root/comm/mail/base/test/browser/browser_toolsMenu.js
blob: 8dbf5911c84cd68109451adbae1ee81e2af74320 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* 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/. */

const { MessageGenerator } = ChromeUtils.import(
  "resource://testing-common/mailnews/MessageGenerator.jsm"
);

/** @type MenuData */
const toolsMenuData = {
  tasksMenuMail: { hidden: true },
  addressBook: {},
  menu_openSavedFilesWnd: {},
  addonsManager: {},
  activityManager: {},
  imAccountsStatus: { disabled: true },
  imStatusAvailable: {},
  imStatusUnavailable: {},
  imStatusOffline: {},
  imStatusShowAccounts: {},
  joinChatMenuItem: { disabled: true },
  filtersCmd: {},
  applyFilters: { disabled: ["mail3PaneTab", "contentTab"] },
  applyFiltersToSelection: { disabled: ["mail3PaneTab", "contentTab"] },
  runJunkControls: { disabled: true },
  deleteJunk: { disabled: true },
  menu_import: {},
  menu_export: {},
  manageKeysOpenPGP: {},
  devtoolsMenu: {},
  devtoolsToolbox: {},
  addonDebugging: {},
  javascriptConsole: {},
  sanitizeHistory: {},
};
if (AppConstants.platform == "win") {
  toolsMenuData.menu_preferences = {};
  toolsMenuData.menu_accountmgr = {};
}
let helper = new MenuTestHelper("tasksMenu", toolsMenuData);

let tabmail = document.getElementById("tabmail");
let rootFolder, testFolder, testMessages;

add_setup(async function () {
  document.getElementById("toolbar-menubar").removeAttribute("autohide");

  let generator = new MessageGenerator();

  MailServices.accounts.createLocalMailAccount();
  let account = MailServices.accounts.accounts[0];
  account.addIdentity(MailServices.accounts.createIdentity());
  rootFolder = account.incomingServer.rootFolder;

  rootFolder.createSubfolder("tools menu", null);
  testFolder = rootFolder
    .getChildNamed("tools menu")
    .QueryInterface(Ci.nsIMsgLocalMailFolder);
  testFolder.addMessageBatch(
    generator.makeMessages({ count: 5 }).map(message => message.toMboxString())
  );
  testMessages = [...testFolder.messages];

  window.OpenMessageInNewTab(testMessages[0], { background: true });
  await BrowserTestUtils.waitForEvent(
    tabmail.tabInfo[1].chromeBrowser,
    "MsgLoaded"
  );

  window.openTab("contentTab", {
    url: "https://example.com/",
    background: true,
  });

  registerCleanupFunction(() => {
    tabmail.closeOtherTabs(0);
    MailServices.accounts.removeAccount(account, false);
  });
});

add_task(async function test3PaneTab() {
  tabmail.currentAbout3Pane.displayFolder(rootFolder);
  await helper.testAllItems("mail3PaneTab");

  tabmail.currentAbout3Pane.displayFolder(testFolder);
  await helper.testItems({
    applyFilters: {},
    runJunkControls: {},
    deleteJunk: {},
  });

  tabmail.currentAbout3Pane.threadTree.selectedIndex = 1;
  await helper.testItems({
    applyFilters: {},
    applyFiltersToSelection: {},
    runJunkControls: {},
    deleteJunk: {},
  });
});

add_task(async function testMessageTab() {
  tabmail.switchToTab(1);
  await helper.testAllItems("mailMessageTab");
});

add_task(async function testContentTab() {
  tabmail.switchToTab(2);
  await helper.testAllItems("contentTab");
});