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
|
/* 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 EXPORTED_SYMBOLS = [
"SHORT_SLEEP",
"MID_SLEEP",
"TIMEOUT_MODAL_DIALOG",
"handleDeleteOccurrencePrompt",
"execEventDialogCallback",
"checkMonthAlarmIcon",
"closeAllEventDialogs",
];
var { Assert } = ChromeUtils.importESModule("resource://testing-common/Assert.sys.mjs");
var { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
var EventUtils = ChromeUtils.import("resource://testing-common/mozmill/EventUtils.jsm");
var { TestUtils } = ChromeUtils.importESModule("resource://testing-common/TestUtils.sys.mjs");
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"CalendarTestUtils",
"resource://testing-common/calendar/CalendarTestUtils.jsm"
);
var SHORT_SLEEP = 100;
var MID_SLEEP = 500;
var TIMEOUT_MODAL_DIALOG = 30000;
var EVENT_DIALOG_NAME = "Calendar:EventDialog";
/**
* Delete one or all occurrences using the prompt.
*
* @param {Window} window - Main window.
* @param {Element} element - Element which will open the dialog.
* @param {boolean} selectParent - true if all occurrences should be deleted.
*/
async function handleDeleteOccurrencePrompt(window, element, selectParent) {
let dialogPromise = BrowserTestUtils.promiseAlertDialog(
undefined,
"chrome://calendar/content/calendar-occurrence-prompt.xhtml",
{
callback(dialogWindow) {
let buttonId;
if (selectParent) {
buttonId = "accept-parent-button";
} else {
buttonId = "accept-occurrence-button";
}
let acceptButton = dialogWindow.document.getElementById(buttonId);
EventUtils.synthesizeMouseAtCenter(acceptButton, {}, dialogWindow);
},
}
);
EventUtils.synthesizeKey("VK_DELETE", {}, window);
await dialogPromise;
}
async function execEventDialogCallback(callback) {
let eventWindow = Services.wm.getMostRecentWindow(EVENT_DIALOG_NAME);
if (!eventWindow) {
eventWindow = await lazy.CalendarTestUtils.waitForEventDialog("edit");
}
let iframe = eventWindow.document.getElementById("calendar-item-panel-iframe");
await TestUtils.waitForCondition(() => iframe.contentWindow.onLoad?.hasLoaded);
await callback(eventWindow, iframe.contentWindow);
}
/**
* Checks if Alarm-Icon is shown on a given Event-Box.
*
* @param {Window} window - Main window.
* @param {number} week - Week to check between 1-6.
* @param {number} day - Day to check between 1-7.
*/
function checkMonthAlarmIcon(window, week, day) {
let dayBox = lazy.CalendarTestUtils.monthView.getItemAt(window, week, day, 1);
Assert.ok(dayBox.querySelector(".alarm-icons-box > .reminder-icon"));
}
|