Bug 1495247 [mozmill] close any remaining EventDialogs on teardownTest; r=darktrojan
authorMarkus Adrario <mozilla@adrario.de>
Mon, 05 Nov 2018 23:19:25 +1300
changeset 33656 c4332b0133ce425e0cf321a45558572940e6fc6b
parent 33655 21d5b4404cab343a645c49dbb8db102561955914
child 33657 99087a5cc9378a68bdf4207289081b5bf5f70f5d
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersdarktrojan
bugs1495247
Bug 1495247 [mozmill] close any remaining EventDialogs on teardownTest; r=darktrojan
calendar/test/mozmill/cal-recurrence/testAnnualRecurrence.js
calendar/test/mozmill/cal-recurrence/testBiweeklyRecurrence.js
calendar/test/mozmill/cal-recurrence/testDailyRecurrence.js
calendar/test/mozmill/cal-recurrence/testLastDayOfMonthRecurrence.js
calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
calendar/test/mozmill/eventDialog/testEventDialog.js
calendar/test/mozmill/eventDialog/testEventDialogModificationPrompt.js
calendar/test/mozmill/eventDialog/testEventDialogSize.js
calendar/test/mozmill/eventDialog/testUTF8.js
calendar/test/mozmill/recurrenceRotated/testAnnualRecurrence.js
calendar/test/mozmill/recurrenceRotated/testBiweeklyRecurrence.js
calendar/test/mozmill/recurrenceRotated/testDailyRecurrence.js
calendar/test/mozmill/recurrenceRotated/testLastDayOfMonthRecurrence.js
calendar/test/mozmill/recurrenceRotated/testWeeklyNRecurrence.js
calendar/test/mozmill/recurrenceRotated/testWeeklyUntilRecurrence.js
calendar/test/mozmill/recurrenceRotated/testWeeklyWithExceptionRecurrence.js
calendar/test/mozmill/shared-modules/test-calendar-utils.js
calendar/test/mozmill/views/testDayView.js
calendar/test/mozmill/views/testMonthView.js
calendar/test/mozmill/views/testMultiweekView.js
calendar/test/mozmill/views/testTaskView.js
calendar/test/mozmill/views/testWeekView.js
--- a/calendar/test/mozmill/cal-recurrence/testAnnualRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testAnnualRecurrence.js
@@ -2,33 +2,34 @@
  * 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 = "testAnnualRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
 var CALENDARNAME, EVENTPATH, ALLDAY;
-var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, deleteCalendars, createCalendar, menulistSelect;
+var helpersForController, handleOccurrencePrompt, switchToView, goToDate, invokeEventDialog;
+var closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 
 const STARTYEAR = 1950;
 const EPOCH = 1970;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         CALENDARNAME,
         EVENTPATH,
         ALLDAY,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     createCalendar(controller, CALENDARNAME);
@@ -75,9 +76,10 @@ function testAnnualRecurrence() {
     let box = getEventBoxPath("day", ALLDAY, null, 1, null) + EVENTPATH;
     controller.click(lookup(box));
     handleOccurrencePrompt(controller, eid("day-view"), "delete", true);
     controller.waitForElementNotPresent(lookup(box));
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/cal-recurrence/testBiweeklyRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testBiweeklyRecurrence.js
@@ -2,34 +2,35 @@
  * 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 = "testBiweeklyRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
 var CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
-var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, createCalendar, deleteCalendars, menulistSelect;
+var helpersForController, handleOccurrencePrompt, switchToView, goToDate, invokeEventDialog;
+var viewForward, closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         CALENDARNAME,
         EVENTPATH,
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     createCalendar(controller, CALENDARNAME);
@@ -98,9 +99,10 @@ function testBiweeklyRecurrence() {
     let box = lookupEventBox("month", EVENT_BOX, 4, 7, null, EVENTPATH);
     controller.click(box);
     handleOccurrencePrompt(controller, eid("month-view"), "delete", true);
     controller.waitForElementNotPresent(box);
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/cal-recurrence/testDailyRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testDailyRecurrence.js
@@ -2,19 +2,18 @@
  * 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 = "testDailyRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers"];
 
 var CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
-var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
-var switchToView, goToDate, viewForward, viewBack, handleOccurrencePrompt;
-var menulistSelect;
+var helpersForController, handleOccurrencePrompt, invokeEventDialog, switchToView, goToDate;
+var viewForward, viewBack, closeAllEventDialogs, createCalendar, deleteCalendars, menulistSelect;
 var setData;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         CALENDARNAME,
@@ -23,16 +22,17 @@ function setupModule(module) {
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
         viewBack,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({ setData } = collector.getModule("item-editing-helpers"));
@@ -187,9 +187,10 @@ function testDailyRecurrence() {
     day = lookupEventBox("month", EVENT_BOX, 1, 5, null, EVENTPATH);
     controller.click(day);
     handleOccurrencePrompt(controller, eid("month-view"), "delete", true);
     controller.waitForElementNotPresent(day);
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/cal-recurrence/testLastDayOfMonthRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testLastDayOfMonthRecurrence.js
@@ -3,37 +3,38 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var MODULE_NAME = "testLastDayOfMonthRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, deleteCalendars, createCalendar, menulistSelect;
+var invokeEventDialog, closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 var REC_DLG_ACCEPT;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         TIMEOUT_MODAL_DIALOG,
         CALENDARNAME,
         EVENTPATH,
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
-        invokeEventDialog,
-        createCalendar,
-        deleteCalendars,
+        handleOccurrencePrompt,
         switchToView,
         goToDate,
-        handleOccurrencePrompt,
+        invokeEventDialog,
+        closeAllEventDialogs,
+        deleteCalendars,
+        createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({ REC_DLG_ACCEPT } = collector.getModule("item-editing-helpers"));
     collector.getModule("item-editing-helpers").setupModule(module);
 
@@ -130,9 +131,10 @@ function setRecurrence(recurrence) {
     recsleep();
 
     // Close dialog.
     recurrence.click(reclookup(REC_DLG_ACCEPT));
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
@@ -4,18 +4,18 @@
 
 var MODULE_NAME = "testWeeklyNRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
-var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, deleteCalendars, createCalendar, menulistSelect;
+var helpersForController, handleOccurrencePrompt, switchToView, goToDate, invokeEventDialog;
+var viewForward, deleteCalendars, closeAllEventDialogs, createCalendar, menulistSelect;
 var REC_DLG_ACCEPT, REC_DLG_DAYS;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
@@ -26,16 +26,17 @@ function setupModule(module) {
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
         deleteCalendars,
+        closeAllEventDialogs,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
         REC_DLG_ACCEPT,
@@ -151,9 +152,10 @@ function checkMultiWeekView(view) {
     }
 
     // Saturday
     controller.assertNodeNotExist(lookupEventBox(view, EVENT_BOX, week, 7, null, EVENTPATH));
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
@@ -4,18 +4,18 @@
 
 var MODULE_NAME = "testWeeklyUntilRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var SHORT_SLEEP, TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
-var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, deleteCalendars, createCalendar, menulistSelect;
+var helpersForController, handleOccurrencePrompt, switchToView, goToDate, invokeEventDialog;
+var viewForward, closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 var REC_DLG_DAYS, REC_DLG_ACCEPT, REC_DLG_UNTIL_INPUT;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const ENDDATE = new Date(2009, 0, 26); // Last Monday in month.
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
@@ -27,16 +27,17 @@ function setupModule(module) {
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -195,9 +196,10 @@ function checkMultiWeekView(view) {
     // Wednesday
     controller.assertNodeNotExist(
         lookupEventBox(view, EVENT_BOX, startWeek + 3, 4, null, EVENTPATH)
     );
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
@@ -4,17 +4,17 @@
 
 var MODULE_NAME = "testWeeklyWithExceptionRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENT_BOX, CANVAS_BOX;
 var DAY_VIEW, WEEK_VIEW, EVENTPATH;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, deleteCalendars, createCalendar;
+var invokeEventDialog, viewForward, closeAllEventDialogs, deleteCalendars, createCalendar;
 var menulistSelect;
 var REPEAT_DETAILS, REC_DLG_ACCEPT, REC_DLG_DAYS;
 var helpersForEditUI, setData;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 const HOUR = 8;
@@ -31,16 +31,17 @@ function setupModule(module) {
         DAY_VIEW,
         WEEK_VIEW,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -277,9 +278,10 @@ function checkMultiWeekView(view) {
     assertNodeLookup(view, EVENT_BOX, startWeek + 1, 4, null, EVENTPATH);
     assertNodeNotExistLookup(view, EVENT_BOX, startWeek + 1, 5, null, EVENTPATH);
     assertNodeLookup(view, EVENT_BOX, startWeek + 1, 6, null, EVENTPATH);
     assertNodeNotExistLookup(view, EVENT_BOX, startWeek + 1, 7, null, EVENTPATH);
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/eventDialog/testEventDialog.js
+++ b/calendar/test/mozmill/eventDialog/testEventDialog.js
@@ -6,17 +6,17 @@ var MODULE_NAME = "testEventDialog";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX;
 var helpersForController, handleOccurrencePrompt, goToDate, lookupEventBox;
-var invokeEventDialog, checkAlarmIcon, deleteCalendars, createCalendar;
+var invokeEventDialog, checkAlarmIcon, closeAllEventDialogs, deleteCalendars, createCalendar;
 var EVENT_TABPANELS, ATTENDEES_ROW;
 var helpersForEditUI, setData;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const EVENTTITLE = "Event";
 const EVENTLOCATION = "Location";
 const EVENTDESCRIPTION = "Event Description";
 const EVENTATTENDEE = "foo@bar.com";
@@ -32,16 +32,17 @@ function setupModule(module) {
         EVENTPATH,
         EVENT_BOX,
         helpersForController,
         handleOccurrencePrompt,
         goToDate,
         lookupEventBox,
         invokeEventDialog,
         checkAlarmIcon,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
         EVENT_TABPANELS,
@@ -228,9 +229,10 @@ function checkTooltip(row, col, date, st
     });
 
     // This could be on the next day if it is 00:00.
     controller.assert(() => dateTime.getNode().textContent.endsWith(endTime));
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/eventDialog/testEventDialogModificationPrompt.js
+++ b/calendar/test/mozmill/eventDialog/testEventDialogModificationPrompt.js
@@ -5,17 +5,18 @@
 var MODULE_NAME = "testEventDialogModificationPrompt";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers",
     "window-helpers", "folder-display-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var CALENDARNAME, EVENT_BOX, CANVAS_BOX, EVENTPATH;
-var helpersForController, invokeEventDialog, createCalendar, deleteCalendars, goToDate;
+var helpersForController, invokeEventDialog, createCalendar, closeAllEventDialogs, deleteCalendars;
+var goToDate;
 var setData;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 var mark_failure;
 
 const TIMEOUT_COMMON_DIALOG = 3000;
 var savePromptAppeared = false;
 var failPoints = {
     first: "no change",
@@ -30,16 +31,17 @@ function setupModule(module) {
     ({
         CALENDARNAME,
         EVENT_BOX,
         CANVAS_BOX,
         EVENTPATH,
         helpersForController,
         invokeEventDialog,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars,
         goToDate
     } = 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);
@@ -142,16 +144,17 @@ function testEventDialogModificationProm
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     if (savePromptAppeared) {
         mark_failure(["Save Prompt unexpectedly appeared on: ", failPoints.first,
             failPoints.second, failPoints.third]);
     }
+    closeAllEventDialogs();
 }
 
 function handleSavePrompt(controller) {
     let { lookup: cdlglookup } = helpersForController(controller);
     // Unexpected prompt, thus the test has already failed.
     // Can't trigger a failure though, because the following click wouldn't
     // be executed. So remembering it.
     savePromptAppeared = true;
--- a/calendar/test/mozmill/eventDialog/testEventDialogSize.js
+++ b/calendar/test/mozmill/eventDialog/testEventDialogSize.js
@@ -1,30 +1,31 @@
 /* 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 = "testEventDialogSize";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "window-helpers"];
 
-var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
+var helpersForController, invokeEventDialog, createCalendar, closeAllEventDialogs, deleteCalendars;
 var CALENDARNAME;
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const SMALL_TOLERANCE = 5;
 const LARGE_TOLERANCE = 10;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         helpersForController,
         invokeEventDialog,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars,
         CALENDARNAME,
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     createCalendar(controller, CALENDARNAME);
 }
@@ -124,16 +125,17 @@ function testTaskDialog() {
         checkWithinTolerance(task.window.outerWidth, 650);
         checkWithinTolerance(task.window.outerHeight, 700);
         task.keypress(null, "VK_ESCAPE", {});
     });
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
 
 // Check the dialog is resized large enough to hold the iframe.
 function checkLargeEnough(outer, inner) {
     let { eid: outerId } = helpersForController(outer);
 
     let iframeNode = outerId("lightning-item-panel-iframe").getNode();
     let { scrollWidth, scrollHeight } = inner.window.document.documentElement;
--- a/calendar/test/mozmill/eventDialog/testUTF8.js
+++ b/calendar/test/mozmill/eventDialog/testUTF8.js
@@ -4,28 +4,29 @@
 
 var MODULE_NAME = "testUTF8";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers"];
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 var EVENT_BOX, CANVAS_BOX;
-var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
+var helpersForController, invokeEventDialog, closeAllEventDialogs, createCalendar, deleteCalendars;
 var setData;
 
 var UTF8STRING = " 💣 💥  ☣  ";
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
         invokeEventDialog,
+        closeAllEventDialogs,
         createCalendar,
         deleteCalendars
     } = 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);
@@ -69,9 +70,10 @@ function testUTF8() {
         // Escape the event window.
         event.keypress(null, "VK_ESCAPE", {});
     });
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, UTF8STRING);
     Preferences.reset("calendar.categories.names");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/recurrenceRotated/testAnnualRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testAnnualRecurrence.js
@@ -3,32 +3,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var MODULE_NAME = "testAnnualRecurrenceRotated";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
 var CALENDARNAME, EVENTPATH, ALLDAY;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, deleteCalendars, createCalendar, menulistSelect;
+var invokeEventDialog, closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 
 const STARTYEAR = 1950;
 const EPOCH = 1970;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         CALENDARNAME,
         EVENTPATH,
         ALLDAY,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     createCalendar(controller, CALENDARNAME);
@@ -83,9 +84,10 @@ function testAnnualRecurrence() {
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     // Reset view.
     if (eid("day-view").getNode().orient == "horizontal") {
         controller.mainMenu.click("#ltnViewRotated");
     }
     controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/recurrenceRotated/testBiweeklyRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testBiweeklyRecurrence.js
@@ -3,33 +3,34 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var MODULE_NAME = "testBiweeklyRecurrenceRotated";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
 var CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, createCalendar, deleteCalendars, menulistSelect;
+var invokeEventDialog, viewForward, createCalendar, closeAllEventDialogs, deleteCalendars, menulistSelect;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         CALENDARNAME,
         EVENTPATH,
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     createCalendar(controller, CALENDARNAME);
@@ -107,9 +108,10 @@ function testBiweeklyRecurrence() {
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     // Reset view.
     switchToView(controller, "day");
     if (eid("day-view").getNode().orient == "horizontal") {
         controller.mainMenu.click("#ltnViewRotated");
     }
     controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/recurrenceRotated/testDailyRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testDailyRecurrence.js
@@ -2,17 +2,17 @@
  * 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 = "testDailyRecurrenceRotated";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers"];
 
 var CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
-var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
+var helpersForController, invokeEventDialog, createCalendar, closeAllEventDialogs, deleteCalendars;
 var switchToView, goToDate, viewForward, viewBack, handleOccurrencePrompt;
 var menulistSelect;
 var setData;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
@@ -23,16 +23,17 @@ function setupModule(module) {
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
         viewBack,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({ setData } = collector.getModule("item-editing-helpers"));
@@ -196,9 +197,10 @@ function testDailyRecurrence() {
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     // Reset view.
     switchToView(controller, "day");
     if (eid("day-view").getNode().orient == "horizontal") {
         controller.mainMenu.click("#ltnViewRotated");
     }
     controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/recurrenceRotated/testLastDayOfMonthRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testLastDayOfMonthRecurrence.js
@@ -3,33 +3,34 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var MODULE_NAME = "testLastDayOfMonthRecurrenceRotated";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, deleteCalendars, createCalendar, menulistSelect;
+var invokeEventDialog, closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 var REC_DLG_ACCEPT;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         TIMEOUT_MODAL_DIALOG,
         CALENDARNAME,
         EVENTPATH,
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
         invokeEventDialog,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars,
         switchToView,
         goToDate,
         handleOccurrencePrompt,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
@@ -138,9 +139,10 @@ function setRecurrence(recurrence) {
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     // Reset view.
     if (eid("day-view").getNode().orient == "horizontal") {
         controller.mainMenu.click("#ltnViewRotated");
     }
     controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/recurrenceRotated/testWeeklyNRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testWeeklyNRecurrence.js
@@ -5,17 +5,17 @@
 var MODULE_NAME = "testWeeklyNRecurrenceRotated";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, deleteCalendars, createCalendar, menulistSelect;
+var invokeEventDialog, viewForward, closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 var REC_DLG_ACCEPT, REC_DLG_DAYS;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
@@ -25,16 +25,17 @@ function setupModule(module) {
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -160,9 +161,10 @@ function checkMultiWeekView(view) {
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     // Reset view.
     switchToView(controller, "day");
     if (eid("day-view").getNode().orient == "horizontal") {
         controller.mainMenu.click("#ltnViewRotated");
     }
     controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/recurrenceRotated/testWeeklyUntilRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testWeeklyUntilRecurrence.js
@@ -5,17 +5,17 @@
 var MODULE_NAME = "testWeeklyUntilRecurrenceRotated";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var SHORT_SLEEP, TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, deleteCalendars, createCalendar, menulistSelect;
+var invokeEventDialog, viewForward, closeAllEventDialogs, deleteCalendars, createCalendar, menulistSelect;
 var REC_DLG_DAYS, REC_DLG_ACCEPT, REC_DLG_UNTIL_INPUT;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const ENDDATE = new Date(2009, 0, 26); // last Monday in month
 const HOUR = 8;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
@@ -27,16 +27,17 @@ function setupModule(module) {
         EVENT_BOX,
         CANVAS_BOX,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -204,9 +205,10 @@ function checkMultiWeekView(view) {
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     // Reset view.
     switchToView(controller, "day");
     if (eid("day-view").getNode().orient == "horizontal") {
         controller.mainMenu.click("#ltnViewRotated");
     }
     controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/recurrenceRotated/testWeeklyWithExceptionRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testWeeklyWithExceptionRecurrence.js
@@ -4,17 +4,17 @@
 
 var MODULE_NAME = "testWeeklyWithExceptionRecurrenceRotated";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers", "window-helpers"];
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENT_BOX, CANVAS_BOX;
 var DAY_VIEW, WEEK_VIEW, EVENTPATH;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
-var invokeEventDialog, viewForward, deleteCalendars, createCalendar;
+var invokeEventDialog, viewForward, closeAllEventDialogs, deleteCalendars, createCalendar;
 var menulistSelect;
 var REPEAT_DETAILS, REC_DLG_ACCEPT, REC_DLG_DAYS;
 var helpersForEditUI, setData;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 const HOUR = 8;
@@ -31,16 +31,17 @@ function setupModule(module) {
         DAY_VIEW,
         WEEK_VIEW,
         helpersForController,
         handleOccurrencePrompt,
         switchToView,
         goToDate,
         invokeEventDialog,
         viewForward,
+        closeAllEventDialogs,
         deleteCalendars,
         createCalendar,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -286,9 +287,10 @@ function checkMultiWeekView(view) {
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
 
     // Reset view.
     if (eid("day-view").getNode().orient == "horizontal") {
         controller.mainMenu.click("#ltnViewRotated");
     }
     controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/shared-modules/test-calendar-utils.js
+++ b/calendar/test/mozmill/shared-modules/test-calendar-utils.js
@@ -71,20 +71,20 @@ var EVENTPATH = `
     /{"tooltip":"itemTooltip","calendar":"${CALENDARNAME.toLowerCase()}"}
 `;
 // Used after "${EVENTPATH}/${getEventDetials([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, open_pref_tab;
+var plan_for_modal_dialog, wait_for_modal_dialog, close_window, open_pref_tab;
 
 function setupModule(controller) {
-    ({ plan_for_modal_dialog, wait_for_modal_dialog } =
+    ({ plan_for_modal_dialog, wait_for_modal_dialog, close_window } =
         collector.getModule("window-helpers"));
 
     // This setup is needed for pref-win-helpers. For some reason, the automatic
     // loading of modules in shared modules does not setup the module correctly.
     collector.getModule("folder-display-helpers").setupModule();
 
     ({ open_pref_tab } = collector.getModule("pref-window-helpers"));
     collector.getModule("pref-window-helpers").setupModule();
@@ -131,16 +131,17 @@ function installInto(module) {
     module.switchToView = switchToView;
     module.goToDate = goToDate;
     module.invokeEventDialog = invokeEventDialog;
     module.getEventBoxPath = getEventBoxPath;
     module.getEventDetails = getEventDetails;
     module.checkAlarmIcon = checkAlarmIcon;
     module.viewForward = viewForward;
     module.viewBack = viewBack;
+    module.closeAllEventDialogs = closeAllEventDialogs;
     module.deleteCalendars = deleteCalendars;
     module.createCalendar = createCalendar;
     module.handleNewCalendarWizard = handleNewCalendarWizard;
     module.findEventsInNode = findEventsInNode;
     module.openLightningPrefs = openLightningPrefs;
     module.menulistSelect = menulistSelect;
 }
 
@@ -457,16 +458,25 @@ function viewBack(controller, n) {
     for (let i = 0; i < n; i++) {
         controller.click(eid("previous-view-button"));
         sleep(SHORT_SLEEP);
     }
     ensureViewLoaded(controller);
 }
 
 /**
+ * Closes all EventDialogs that may remain open after a failed test
+ */
+function closeAllEventDialogs() {
+    for (let win of mozmill.utils.getWindows("Calendar:EventDialog")) {
+        close_window(win);
+    }
+}
+
+/**
  * Deletes all calendars with given name.
  *
  * @param controller    Mozmill window controller
  * @param name          calendar name
  */
 function deleteCalendars(controller, name) {
     let { eid } = helpersForController(controller);
 
--- a/calendar/test/mozmill/views/testDayView.js
+++ b/calendar/test/mozmill/views/testDayView.js
@@ -5,17 +5,17 @@
 var MODULE_NAME = "testDayView";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var CALENDARNAME, CANVAS_BOX, EVENT_BOX, DAY_VIEW, LABELDAYBOX, EVENTPATH;
 var helpersForController, invokeEventDialog, getEventDetails, createCalendar;
-var deleteCalendars, goToDate, lookupEventBox;
+var closeAllEventDialogs, deleteCalendars, goToDate, lookupEventBox;
 var helpersForEditUI, setData;
 
 const TITLE1 = "Day View Event";
 const TITLE2 = "Day View Event Changed";
 const DESC = "Day View Event Description";
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
@@ -25,16 +25,17 @@ function setupModule(module) {
         EVENT_BOX,
         DAY_VIEW,
         LABELDAYBOX,
         EVENTPATH,
         helpersForController,
         invokeEventDialog,
         getEventDetails,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars,
         goToDate,
         lookupEventBox
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -102,9 +103,10 @@ function testDayView() {
     // Delete event
     controller.click(eventBox);
     controller.keypress(eid("day-view"), "VK_DELETE", {});
     controller.waitForElementNotPresent(eventBox);
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/views/testMonthView.js
+++ b/calendar/test/mozmill/views/testMonthView.js
@@ -5,17 +5,17 @@
 var MODULE_NAME = "testMonthView";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var CALENDARNAME, EVENT_BOX, CANVAS_BOX, MONTH_VIEW, EVENTPATH;
 var helpersForController, switchToView, invokeEventDialog, getEventDetails, createCalendar;
-var deleteCalendars, goToDate, lookupEventBox;
+var closeAllEventDialogs, deleteCalendars, goToDate, lookupEventBox;
 var helpersForEditUI, setData;
 
 const TITLE1 = "Month View Event";
 const TITLE2 = "Month View Event Changed";
 const DESC = "Month View Event Description";
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
@@ -25,16 +25,17 @@ function setupModule(module) {
         CANVAS_BOX,
         MONTH_VIEW,
         EVENTPATH,
         helpersForController,
         switchToView,
         invokeEventDialog,
         getEventDetails,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars,
         goToDate,
         lookupEventBox
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -111,9 +112,10 @@ function testMonthView() {
     // Delete event.
     controller.click(eventBox);
     controller.keypress(eid("month-view"), "VK_DELETE", {});
     controller.waitForElementNotPresent(eventBox);
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/views/testMultiweekView.js
+++ b/calendar/test/mozmill/views/testMultiweekView.js
@@ -5,17 +5,17 @@
 var MODULE_NAME = "testMultiweekView";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var CALENDARNAME, EVENT_BOX, CANVAS_BOX, MULTIWEEK_VIEW, EVENTPATH;
 var helpersForController, switchToView, invokeEventDialog, getEventDetails, createCalendar;
-var deleteCalendars, goToDate, lookupEventBox;
+var closeAllEventDialogs, deleteCalendars, goToDate, lookupEventBox;
 var helpersForEditUI, setData;
 
 const TITLE1 = "Multiweek View Event";
 const TITLE2 = "Multiweek View Event Changed";
 const DESC = "Multiweek View Event Description";
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
@@ -25,16 +25,17 @@ function setupModule(module) {
         CANVAS_BOX,
         MULTIWEEK_VIEW,
         EVENTPATH,
         helpersForController,
         switchToView,
         invokeEventDialog,
         getEventDetails,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars,
         goToDate,
         lookupEventBox
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -112,9 +113,10 @@ function testMultiWeekView() {
     // Delete event.
     controller.click(eventBox);
     controller.keypress(eid("multiweek-view"), "VK_DELETE", {});
     controller.waitForElementNotPresent(eventBox);
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/views/testTaskView.js
+++ b/calendar/test/mozmill/views/testTaskView.js
@@ -2,32 +2,33 @@
  * 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 = "testTaskView";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
 var CALENDARNAME, CALENDAR_PANEL, TASK_VIEW;
-var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
+var helpersForController, invokeEventDialog, createCalendar, closeAllEventDialogs, deleteCalendars;
 var setData;
 
 const TITLE = "Task";
 const DESCRIPTION = "1. Do A\n2. Do B";
 const PERCENTCOMPLETE = "50";
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         CALENDARNAME,
         CALENDAR_PANEL,
         TASK_VIEW,
         helpersForController,
         invokeEventDialog,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars
     } = 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);
 
@@ -160,9 +161,10 @@ function testTaskView() {
     controller.waitFor(() => {
         countAfterDelete = taskTreeNode.mTaskArray.length;
         return countAfter - 1 == countAfterDelete;
     });
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }
--- a/calendar/test/mozmill/views/testWeekView.js
+++ b/calendar/test/mozmill/views/testWeekView.js
@@ -5,17 +5,17 @@
 var MODULE_NAME = "testWeekView";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "item-editing-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var CALENDARNAME, CANVAS_BOX, EVENT_BOX, WEEK_VIEW, EVENTPATH;
 var helpersForController, switchToView, invokeEventDialog, getEventDetails, createCalendar;
-var deleteCalendars, goToDate, lookupEventBox;
+var closeAllEventDialogs, deleteCalendars, goToDate, lookupEventBox;
 var helpersForEditUI, setData;
 
 var TITLE1 = "Week View Event";
 var TITLE2 = "Week View Event Changed";
 var DESC = "Week View Event Description";
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
@@ -25,16 +25,17 @@ function setupModule(module) {
         EVENT_BOX,
         WEEK_VIEW,
         EVENTPATH,
         helpersForController,
         switchToView,
         invokeEventDialog,
         getEventDetails,
         createCalendar,
+        closeAllEventDialogs,
         deleteCalendars,
         goToDate,
         lookupEventBox
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
     Object.assign(module, helpersForController(controller));
 
     ({
@@ -107,9 +108,10 @@ function testWeekView() {
     // Delete event.
     controller.click(eventBox);
     controller.keypress(eid("week-view"), "VK_DELETE", {});
     controller.waitForElementNotPresent(eventBox);
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
+    closeAllEventDialogs();
 }