summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/tabmail/browser_customize.js
blob: d9a0fc777d1d21f1986b6ff1b0418cf04a79d3f4 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* 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 customization features of the tabs toolbar.
 */

"use strict";

const { close_popup, mc, wait_for_popup_to_open } = ChromeUtils.import(
  "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);

const { drag_n_drop_element } = ChromeUtils.import(
  "resource://testing-common/mozmill/MouseEventHelpers.jsm"
);

const { click_through_appmenu } = ChromeUtils.import(
  "resource://testing-common/mozmill/WindowHelpers.jsm"
);

const { wait_for_element_visible, wait_for_element_invisible } =
  ChromeUtils.import("resource://testing-common/mozmill/DOMHelpers.jsm");

add_setup(function () {
  Services.prefs.setBoolPref("mail.tabs.autoHide", false);
});

registerCleanupFunction(function () {
  // Let's reset any and all of our changes to the toolbar
  Services.prefs.clearUserPref("mail.tabs.autoHide");
});

/**
 * Test that we can access the unified toolbar by clicking
 * customize on the toolbar context menu
 */
add_task(async function test_open_unified_by_context() {
  // First, ensure that the context menu is closed.
  let contextPopup = mc.window.document.getElementById("toolbar-context-menu");
  Assert.notEqual(
    contextPopup.state,
    "open",
    "Context menu is currently open!"
  );

  // Right click on the tab bar.
  EventUtils.synthesizeMouseAtCenter(
    mc.window.document.getElementById("tabmail-tabs"),
    { type: "contextmenu" },
    window
  );

  // Ensure that the popup opened.
  await wait_for_popup_to_open(contextPopup);
  Assert.equal(contextPopup.state, "open", "Context menu was not opened!");

  const customizeButton = document.getElementById("CustomizeMailToolbar");
  // Click customize.
  contextPopup.activateItem(customizeButton);

  // Wait for hidden css attribute on unified toolbar
  // customization to be removed.
  await wait_for_element_visible(
    window,
    "unifiedToolbarCustomizationContainer"
  );

  // Ensure messengerWindow (HTML element) has customizingUnifiedToolbar class,
  // which means unified toolbar customization should be open.
  Assert.ok(
    document
      .getElementById("messengerWindow")
      .classList.contains("customizingUnifiedToolbar"),
    "customizingUnifiedToolbar class not found on messengerWindow element"
  );

  // Click cancel.
  const cancelButton = document.getElementById(
    "unifiedToolbarCustomizationCancel"
  );
  cancelButton.click();

  // Wait for hidden css attribute on Unified Toolbar
  // customization to be added.
  await wait_for_element_invisible(
    window,
    "unifiedToolbarCustomizationContainer"
  );

  await close_popup(mc, contextPopup);
});

/**
 * Test that we can access the unified toolbar customization by clicking
 * the toolbar layout menu option
 */
add_task(async function test_open_unified_by_menu() {
  // First, ensure that the menu is closed.
  let appMenu = mc.window.document.getElementById("appMenu-popup");
  Assert.notEqual(
    appMenu.getAttribute("panelopen"),
    "true",
    "appMenu-popup is currently open!"
  );

  // Click through app menu to view unified toolbar.
  click_through_appmenu(
    [{ id: "appmenu_View" }, { id: "appmenu_Toolbars" }],
    { id: "appmenu_toolbarLayout" },
    window
  );

  // Wait for hidden css attribute on unified toolbar
  // customization to be removed.
  await wait_for_element_visible(
    window,
    "unifiedToolbarCustomizationContainer"
  );

  // Ensure messengerWindow (HTML element) has customizingUnifiedToolbar class,
  // which means unified toolbar customization should be open.
  Assert.ok(
    document
      .getElementById("messengerWindow")
      .classList.contains("customizingUnifiedToolbar"),
    "customizingUnifiedToolbar class not found on messengerWindow element"
  );

  // Click cancel.
  const cancelButton = document.getElementById(
    "unifiedToolbarCustomizationCancel"
  );
  cancelButton.click();

  // Wait for hidden css attribute on unified toolbar
  // customization to be added.
  await wait_for_element_invisible(
    window,
    "unifiedToolbarCustomizationContainer"
  );

  await close_popup(mc, appMenu);
});