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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/* 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/. */
/* globals openAddonsTab, openChatTab, openNewCalendarEventTab,
* openNewCalendarTaskTab, openPreferencesTab, openTasksTab,
* selectCalendarEventTab, selectCalendarTaskTab, selectFolderTab,
* toAddressBook */
// Test that today pane is visible/collapsed correctly for various tab types.
// In all cases today pane should not be visible in preferences or addons tab.
// Also test that the today pane button is visible/hidden for various tab types.
add_task(async () => {
let calendar = CalendarTestUtils.createCalendar();
registerCleanupFunction(() => {
CalendarTestUtils.removeCalendar(calendar);
});
const todayPane = document.getElementById("today-pane-panel");
const todayPaneButton = document.getElementById("calendar-status-todaypane-button");
let eventTabPanelId, taskTabPanelId;
async function clickTodayPaneButton() {
// The today pane button will be hidden for certain tabs (e.g. preferences), and then
// the user won't be able to click it, so we shouldn't be able to here either.
if (BrowserTestUtils.is_visible(todayPaneButton)) {
EventUtils.synthesizeMouseAtCenter(todayPaneButton, { clickCount: 1 });
}
await new Promise(resolve => setTimeout(resolve));
}
/**
* Tests whether the today pane is only open in certain tabs.
*
* @param {string[]} tabsWhereVisible - Array of tab mode names for tabs where
* the today pane should be visible.
*/
async function checkTodayPaneVisibility(tabsWhereVisible) {
function check(tabModeName) {
let shouldBeVisible = tabsWhereVisible.includes(tabModeName);
is(
BrowserTestUtils.is_visible(todayPane),
shouldBeVisible,
`today pane is ${shouldBeVisible ? "visible" : "collapsed"} in ${tabModeName} tab`
);
}
await selectFolderTab();
check("folder");
await CalendarTestUtils.openCalendarTab(window);
check("calendar");
await openTasksTab();
check("tasks");
await openChatTab();
check("chat");
await selectCalendarEventTab(eventTabPanelId);
check("calendarEvent");
await selectCalendarTaskTab(taskTabPanelId);
check("calendarTask");
await toAddressBook();
check("addressBookTab");
await openPreferencesTab();
check("preferencesTab");
await openAddonsTab();
check("contentTab");
}
// Show today pane in folder (mail) tab, but not in other tabs.
await selectFolderTab();
if (!BrowserTestUtils.is_visible(todayPane)) {
await clickTodayPaneButton();
}
await CalendarTestUtils.openCalendarTab(window);
if (BrowserTestUtils.is_visible(todayPane)) {
await clickTodayPaneButton();
}
await openTasksTab();
if (BrowserTestUtils.is_visible(todayPane)) {
await clickTodayPaneButton();
}
await openChatTab();
if (BrowserTestUtils.is_visible(todayPane)) {
await clickTodayPaneButton();
}
eventTabPanelId = await openNewCalendarEventTab();
if (BrowserTestUtils.is_visible(todayPane)) {
await clickTodayPaneButton();
}
taskTabPanelId = await openNewCalendarTaskTab();
if (BrowserTestUtils.is_visible(todayPane)) {
await clickTodayPaneButton();
}
await checkTodayPaneVisibility(["folder"]);
// Show today pane in calendar tab, but not in other tabs.
// Hide it in folder tab.
await selectFolderTab();
await clickTodayPaneButton();
// Show it in calendar tab.
await CalendarTestUtils.openCalendarTab(window);
await clickTodayPaneButton();
await checkTodayPaneVisibility(["calendar"]);
// Show today pane in tasks tab, but not in other tabs.
// Hide it in calendar tab.
await CalendarTestUtils.openCalendarTab(window);
await clickTodayPaneButton();
// Show it in tasks tab.
await openTasksTab();
await clickTodayPaneButton();
await checkTodayPaneVisibility(["tasks"]);
// Show today pane in chat tab, but not in other tabs.
// Hide it in tasks tab.
await openTasksTab();
await clickTodayPaneButton();
// Show it in chat tab.
await openChatTab();
await clickTodayPaneButton();
await checkTodayPaneVisibility(["chat"]);
// Show today pane in calendar event tab, but not in other tabs.
// Hide it in chat tab.
await openChatTab();
await clickTodayPaneButton();
// Show it in calendar event tab.
await selectCalendarEventTab(eventTabPanelId);
await clickTodayPaneButton();
await checkTodayPaneVisibility(["calendarEvent"]);
// Show today pane in calendar task tab, but not in other tabs.
// Hide it in calendar event tab.
await selectCalendarEventTab(eventTabPanelId);
await clickTodayPaneButton();
// Show it in calendar task tab.
await selectCalendarTaskTab(taskTabPanelId);
await clickTodayPaneButton();
await checkTodayPaneVisibility(["calendarTask"]);
// Check the visibility of the today pane button.
const button = document.getElementById("calendar-status-todaypane-button");
await selectFolderTab();
ok(BrowserTestUtils.is_visible(button), "today pane button is visible in folder tab");
await CalendarTestUtils.openCalendarTab(window);
ok(BrowserTestUtils.is_visible(button), "today pane button is visible in calendar tab");
await openTasksTab();
ok(BrowserTestUtils.is_visible(button), "today pane button is visible in tasks tab");
await openChatTab();
ok(BrowserTestUtils.is_visible(button), "today pane button is visible in chat tab");
await selectCalendarEventTab(eventTabPanelId);
ok(BrowserTestUtils.is_visible(button), "today pane button is visible in event tab");
await selectCalendarTaskTab(taskTabPanelId);
ok(BrowserTestUtils.is_visible(button), "today pane button is visible in task tab");
await toAddressBook();
is(BrowserTestUtils.is_visible(button), false, "today pane button is hidden in address book tab");
await openPreferencesTab();
is(BrowserTestUtils.is_visible(button), false, "today pane button is hidden in preferences tab");
await openAddonsTab();
is(BrowserTestUtils.is_visible(button), false, "today pane button is hidden in addons tab");
});
|