Bug 1586638 - Fix MODIFICATION_FAILED error in tests when dismissing alarm dialog. r=pmorris
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 07 Oct 2019 16:04:47 +1300
changeset 27891 f6d43522feaca6cc1e9d37e5c7085ec6873c7b61
parent 27890 1318ff6834a0a96292bf9769a1efe96a8362d4e2
child 27892 55f15b85ce9b7532b09d56840457304e79aa9406
push id16537
push usermozilla@jorgk.com
push dateThu, 10 Oct 2019 07:04:18 +0000
treeherdercomm-central@55f15b85ce9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspmorris
bugs1586638
Bug 1586638 - Fix MODIFICATION_FAILED error in tests when dismissing alarm dialog. r=pmorris
calendar/test/browser/eventDialog/browser_alarmDialog.js
calendar/test/browser/eventDialog/browser_eventDialog.js
--- a/calendar/test/browser/eventDialog/browser_alarmDialog.js
+++ b/calendar/test/browser/eventDialog/browser_alarmDialog.js
@@ -14,17 +14,17 @@ var {
   deleteCalendars,
   goToDate,
   helpersForController,
   invokeEventDialog,
   switchToView,
   viewForward,
 } = ChromeUtils.import("resource://testing-common/mozmill/CalendarUtils.jsm");
 var { setData } = ChromeUtils.import("resource://testing-common/mozmill/ItemEditingHelpers.jsm");
-var { close_window, plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
+var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
   "resource://testing-common/mozmill/WindowHelpers.jsm"
 );
 
 var controller = mozmill.getMail3PaneController();
 var { lookupEventBox } = helpersForController(controller);
 
 add_task(function testAlarmDialog() {
   let now = new Date();
@@ -45,16 +45,18 @@ add_task(function testAlarmDialog() {
       allday: true,
       reminder: "1day",
     });
 
     // Prepare to dismiss the alarm.
     plan_for_modal_dialog("Calendar:AlarmWindow", alarm => {
       let { eid: alarmid } = helpersForController(alarm);
       alarm.waitThenClick(alarmid("alarm-dismiss-all-button"));
+      // The dialog will close itself if we wait long enough.
+      alarm.sleep(500);
     });
 
     event.click(eventid("button-saveandclose"));
   });
   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);
@@ -67,26 +69,23 @@ add_task(function testAlarmDialog() {
     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 = popup.querySelectorAll(":scope > menuitem");
 
       alarm.waitThenClick(snoozeAllButton);
       menuitems[5].click();
+      // The dialog will close itself if we wait long enough.
+      alarm.sleep(500);
     });
 
     event.click(eventid("button-saveandclose"));
   });
   wait_for_modal_dialog("Calendar:AlarmWindow", TIMEOUT_MODAL_DIALOG);
 
   Assert.ok(true, "Test ran to completion");
 });
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   closeAllEventDialogs();
-
-  // TODO: fix this error message.
-  for (let win of mozmill.utils.getWindows("Calendar:ErrorPrompt")) {
-    close_window(win);
-  }
 });
--- a/calendar/test/browser/eventDialog/browser_eventDialog.js
+++ b/calendar/test/browser/eventDialog/browser_eventDialog.js
@@ -19,17 +19,17 @@ var {
   helpersForController,
   invokeEventDialog,
   switchToView,
   viewBack,
 } = ChromeUtils.import("resource://testing-common/mozmill/CalendarUtils.jsm");
 var { ATTENDEES_ROW, EVENT_TABPANELS, helpersForEditUI, setData } = ChromeUtils.import(
   "resource://testing-common/mozmill/ItemEditingHelpers.jsm"
 );
-var { close_window, plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
+var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
   "resource://testing-common/mozmill/WindowHelpers.jsm"
 );
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var controller = mozmill.getMail3PaneController();
 var { eid, lookup, lookupEventBox } = helpersForController(controller);
 
@@ -148,32 +148,21 @@ add_task(function testEventDialog() {
         `)
     );
 
     // save
     event.click(eventid("button-saveandclose"));
   });
 
   // Catch and dismiss alarm.
-  //
-  // NOTE: dismissing the alarms here can cause an "error has occurred" dialog to appear:
-  //   An error occurred when when writing to the calendar Mozmill!
-  //   Error code: MODIFICATION_FAILED
-  //   If you're seeing this message after snoozing or dismissing a reminder and this is for a
-  //   calendar you do not want to add or edit events for, you can mark this calendar as read-only
-  //   to avoid such experience in future. To do so, get to the calendar properties by
-  //   right-clicking on this calendar in the list in the calendar or task view.
-  // And in the console:
-  //   console.warn: Lightning: There has been an error reading data for calendar: Mozmill.
-  //   However, this error is believed to be minor, so the program will attempt to continue.
-  //   Error code: 0x80004005. Description: generation too old for for modifyItem
-  // These errors do not appear to have any real impact on the rest of the test.
   plan_for_modal_dialog("Calendar:AlarmWindow", alarm => {
     let { eid: alarmid } = helpersForController(alarm);
     alarm.waitThenClick(alarmid("alarm-dismiss-all-button"));
+    // The dialog will close itself if we wait long enough.
+    alarm.sleep(500);
   });
   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 (let col = 1; col <= 7; col++) {
       controller.waitForElement(lookupEventBox("month", CANVAS_BOX, row, col, null, EVENTPATH));
       checkAlarmIcon(controller, "month", row, col);
@@ -248,14 +237,9 @@ function checkTooltip(row, col, startTim
 
   // This could be on the next day if it is 00:00.
   controller.assert(() => dateTime.getNode().textContent.endsWith(endTime));
 }
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   closeAllEventDialogs();
-
-  // TODO: fix this error message.
-  for (let win of mozmill.utils.getWindows("Calendar:ErrorPrompt")) {
-    close_window(win);
-  }
 });