Bug 734966 - Fix "snooze all" button on Mac; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 31 Dec 2018 12:15:55 +1300
changeset 34083 9bc477f5f7d396d1d3d6be9e813759501e70a473
parent 34082 da68367e23e51f72ccd8e1aec01b76eee6732fbd
child 34084 3375b11b89fa06fcafed9f2fc2b3082b1fa67314
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersFallen
bugs734966
Bug 734966 - Fix "snooze all" button on Mac; r=Fallen
calendar/base/content/dialogs/calendar-alarm-dialog.xul
calendar/base/content/widgets/calendar-alarm-widget.xml
calendar/base/themes/linux/dialogs/calendar-alarm-dialog.css
calendar/base/themes/windows/dialogs/calendar-alarm-dialog.css
calendar/test/mozmill/eventDialog/testAlarmDialog.js
calendar/test/mozmill/eventDialog/testEventDialog.js
calendar/test/mozmill/shared-modules/test-calendar-utils.js
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.xul
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.xul
@@ -32,19 +32,21 @@
 
   <notificationbox id="readonly-notification" notificationside="top"/>
   <richlistbox id="alarm-richlist" flex="1" onselect="onSelectAlarm(event)"/>
 
   <hbox pack="end" id="alarm-actionbar" align="center">
     <button id="alarm-snooze-all-button"
             type="menu"
             label="&calendar.alarm.snoozeallfor.label;">
-      <menupopup type="snooze-menupopup"
+      <menupopup id="alarm-snooze-all-popup"
+                 type="snooze-menupopup"
                  ignorekeys="true"
                  onsnooze="snoozeAllItems(event.detail)"/>
     </button>
-    <button label="&calendar.alarm.dismissall.label;"
+    <button id="alarm-dismiss-all-button"
+            label="&calendar.alarm.dismissall.label;"
             oncommand="onDismissAllAlarms();"/>
   </hbox>
   <hbox pack="end" class="resizer-box">
     <resizer dir="bottomright"/>
   </hbox>
 </window>
--- a/calendar/base/content/widgets/calendar-alarm-widget.xml
+++ b/calendar/base/content/widgets/calendar-alarm-widget.xml
@@ -286,20 +286,17 @@
 
       <method name="snoozeAlarm">
         <parameter name="minutes"/>
         <body><![CDATA[
             let snoozeEvent = document.createEvent("Events");
             snoozeEvent.initEvent("snooze", true, false);
             snoozeEvent.detail = minutes;
 
-            // The onsnooze attribute is set on the menupopup, this binding is
-            // instanciated on the menupopup's arrowscrollbox. Therefore we need
-            // to go up one node.
-            let handler = this.parentNode.getAttribute("onsnooze");
+            let handler = this.getAttribute("onsnooze");
             let cancel = false;
             if (handler) {
                 let func = new Function("event", handler);
                 cancel = (func.call(this, snoozeEvent) === false);
             }
 
             if (!cancel) {
                 this.dispatchEvent(snoozeEvent);
@@ -321,17 +318,17 @@
 
             let minutes = (unitList.value || 1) * unitValue.value;
             this.snoozeAlarm(minutes);
         ]]></body>
       </method>
 
       <method name="snoozeCancel">
         <body><![CDATA[
-            this.parentNode.hidePopup();
+            this.hidePopup();
         ]]></body>
       </method>
 
       <method name="updateAccessibleName">
         <body><![CDATA[
             let unitList = document.getAnonymousElementByAttribute(this, "anonid", "snooze-unit-menulist");
             let unitPopup = document.getAnonymousElementByAttribute(this, "anonid", "snooze-unit-menupopup");
             let unitValue = document.getAnonymousElementByAttribute(this, "anonid", "snooze-value-textbox");
--- a/calendar/base/themes/linux/dialogs/calendar-alarm-dialog.css
+++ b/calendar/base/themes/linux/dialogs/calendar-alarm-dialog.css
@@ -1,15 +1,15 @@
 /* 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/. */
 
 @import url(chrome://calendar-common/skin/dialogs/calendar-alarm-dialog.css);
 
-menupopup[type="snooze-menupopup"] > arrowscrollbox {
+menupopup[type="snooze-menupopup"] {
     -moz-binding: url(chrome://calendar/content/widgets/calendar-alarm-widget.xml#calendar-snooze-popup);
 }
 
 .snooze-popup-ok-button:hover {
     background-color: -moz-menuhover;
 }
 
 .snooze-popup-cancel-button:hover {
--- a/calendar/base/themes/windows/dialogs/calendar-alarm-dialog.css
+++ b/calendar/base/themes/windows/dialogs/calendar-alarm-dialog.css
@@ -1,15 +1,15 @@
 /* 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/. */
 
 @import url(chrome://calendar-common/skin/dialogs/calendar-alarm-dialog.css);
 
-menupopup[type="snooze-menupopup"] > arrowscrollbox {
+menupopup[type="snooze-menupopup"] {
     -moz-binding: url(chrome://calendar/content/widgets/calendar-alarm-widget.xml#calendar-snooze-popup);
 }
 
 .snooze-popup-ok-button:hover {
     background-color: -moz-menuhover;
 }
 
 .snooze-popup-cancel-button:hover {
new file mode 100644
--- /dev/null
+++ b/calendar/test/mozmill/eventDialog/testAlarmDialog.js
@@ -0,0 +1,99 @@
+/* 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/. */
+
+var MODULE_NAME = "testAlarmDialog";
+var RELATIVE_ROOT = "../shared-modules";
+var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
+
+var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, ALLDAY;
+var helpersForController, switchToView, goToDate, lookupEventBox;
+var invokeEventDialog, viewForward, closeAllEventDialogs, deleteCalendars;
+var createCalendar;
+var setData;
+var plan_for_modal_dialog, wait_for_modal_dialog;
+
+function setupModule(module) {
+    controller = mozmill.getMail3PaneController();
+    ({ plan_for_modal_dialog, wait_for_modal_dialog } =
+        collector.getModule("window-helpers"));
+    ({
+        TIMEOUT_MODAL_DIALOG,
+        CALENDARNAME,
+        EVENTPATH,
+        ALLDAY,
+        helpersForController,
+        switchToView,
+        goToDate,
+        lookupEventBox,
+        invokeEventDialog,
+        viewForward,
+        closeAllEventDialogs,
+        deleteCalendars,
+        createCalendar,
+    } = collector.getModule("calendar-utils"));
+    collector.getModule("calendar-utils").setupModule(controller);
+    Object.assign(module, helpersForController(controller));
+
+    ({ setData } = collector.getModule("item-editing-helpers"));
+    collector.getModule("item-editing-helpers").setupModule(module);
+
+    createCalendar(controller, CALENDARNAME);
+}
+
+function testAlarmDialog() {
+    let now = new Date();
+
+    switchToView(controller, "day");
+    goToDate(controller, now.getFullYear(), now.getMonth() + 1, now.getDate());
+    viewForward(controller, 1);
+
+    controller.click(lookupEventBox("day", ALLDAY, undefined, 1));
+    controller.mainMenu.click("#ltnNewEvent");
+
+    // Create a new all-day event tomorrow.
+    invokeEventDialog(controller, null, (event, iframe) => {
+        let { eid: eventid } = helpersForController(event);
+
+        setData(event, iframe, {
+            allday: true,
+            reminder: "1day",
+        });
+
+        event.click(eventid("button-saveandclose"));
+    });
+
+    // Dismiss the alarm.
+    plan_for_modal_dialog("Calendar:AlarmWindow", alarm => {
+        let { eid: alarmid } = helpersForController(alarm);
+        alarm.waitThenClick(alarmid("alarm-dismiss-all-button"));
+    });
+    wait_for_modal_dialog("Calendar:AlarmWindow", TIMEOUT_MODAL_DIALOG);
+
+    // Change the reminder duration, this resets the alarm.
+    let eventBox = lookupEventBox("day", ALLDAY, undefined, 1, undefined, EVENTPATH);
+    invokeEventDialog(controller, eventBox, (event, iframe) => {
+        let { eid: eventid } = helpersForController(event);
+
+        setData(event, iframe, { reminder: "2days" });
+
+        event.click(eventid("button-saveandclose"));
+    });
+
+    // Snooze the alarm.
+    plan_for_modal_dialog("Calendar:AlarmWindow", alarm => {
+        let { eid: alarmid } = helpersForController(alarm);
+        let snoozeAllButton = alarmid("alarm-snooze-all-button");
+        let popup = alarmid("alarm-snooze-all-popup").getNode();
+        let menuitems = alarm.window.document.getAnonymousNodes(popup);
+
+        alarm.waitThenClick(snoozeAllButton);
+        menuitems[5].click();
+    });
+    wait_for_modal_dialog("Calendar:AlarmWindow", TIMEOUT_MODAL_DIALOG);
+}
+
+function teardownTest(module) {
+    deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
+}
--- a/calendar/test/mozmill/eventDialog/testEventDialog.js
+++ b/calendar/test/mozmill/eventDialog/testEventDialog.js
@@ -162,20 +162,18 @@ function testEventDialog() {
         `));
 
         // save
         event.click(eventid("button-saveandclose"));
     });
 
     // Catch and dismiss alarm.
     plan_for_modal_dialog("Calendar:AlarmWindow", alarm => {
-        let { lookup: alarmlookup } = helpersForController(alarm);
-        alarm.waitThenClick(alarmlookup(`
-            /id("calendar-alarm-dialog")/id("alarm-actionbar")/[1]`
-        ));
+        let { eid: alarmid } = helpersForController(alarm);
+        alarm.waitThenClick(alarmid("alarm-dismiss-all-button"));
     });
     wait_for_modal_dialog("Calendar:AlarmWindow", TIMEOUT_MODAL_DIALOG);
 
     // Verify event and alarm icon visible until endDate (3 full rows) and check tooltip.
     for (let row = 1; row <= 3; row++) {
         for (col = 1; col <= 7; col++) {
             controller.waitForElement(lookupEventBox("month", EVENT_BOX, row, col, null, EVENTPATH));
             checkAlarmIcon(controller, "month", row, col);
--- a/calendar/test/mozmill/shared-modules/test-calendar-utils.js
+++ b/calendar/test/mozmill/shared-modules/test-calendar-utils.js
@@ -65,17 +65,17 @@ var TODAY_PANE = `
 `;
 var AGENDA_LISTBOX = `
     ${TODAY_PANE}/{"flex":"1"}/id("agenda-panel")/{"flex":"1"}/id("agenda-listbox")
 `;
 
 var EVENTPATH = `
     /{"tooltip":"itemTooltip","calendar":"${CALENDARNAME.toLowerCase()}"}
 `;
-// Used after "${EVENTPATH}/${getEventDetials([view])}/".
+// Used after "${EVENTPATH}/${getEventDetails([view])}/".
 var ALARM_ICON_PATH = `
     anon({"anonid":"category-box-stack"})/anon({"align":"center"})/
     anon({"anonid":"alarm-icons-box"})/anon({"class":"reminder-icon"})
 `;
 
 var plan_for_modal_dialog, wait_for_modal_dialog, close_window, open_pref_tab;
 
 function setupModule(controller) {