Bug 1470307 - Replace open_pref_window() with open_pref_tab() in test-calendar-utils.js; r=philipp
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 17 Jul 2018 23:30:23 +1200
changeset 24281 630c57d2b41283e904a7bf62dea5b20b24efa3dc
parent 24280 ca94a7325ca9bf00111ad2f0b95cae6a829a760b
child 24282 1e7bb39d56f31b05be87943821a5112531c9b8d3
push id14626
push usergeoff@darktrojan.net
push dateTue, 17 Jul 2018 11:31:32 +0000
treeherdercomm-central@630c57d2b412 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs1470307
Bug 1470307 - Replace open_pref_window() with open_pref_tab() in test-calendar-utils.js; r=philipp
calendar/test/mozmill/mozmilltests.list
calendar/test/mozmill/shared-modules/test-calendar-utils.js
calendar/test/mozmill/testAlarmDefaultValue.js
--- a/calendar/test/mozmill/mozmilltests.list
+++ b/calendar/test/mozmill/mozmilltests.list
@@ -1,5 +1,6 @@
 cal-recurrence
 invitations
+testAlarmDefaultValue.js
 testBasicFunctionality.js
 testLocalICS.js
 testTodayPane.js
--- a/calendar/test/mozmill/shared-modules/test-calendar-utils.js
+++ b/calendar/test/mozmill/shared-modules/test-calendar-utils.js
@@ -7,16 +7,18 @@ var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["window-helpers", "folder-display-helpers", "pref-window-helpers"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var os = {};
 ChromeUtils.import("chrome://mozmill/content/stdlib/os.js", os);
 var frame = {};
 ChromeUtils.import("chrome://mozmill/content/modules/frame.js", frame);
+var utils = {};
+ChromeUtils.import("chrome://mozmill/content/modules/utils.js", utils);
 
 var SHORT_SLEEP = 100;
 var MID_SLEEP = 500;
 var TIMEOUT_MODAL_DIALOG = 30000;
 var TIMEOUT_MONTHCHANGE = 10000;
 var CALENDARNAME = "Mozmill";
 
 // these are used in EventBox lookup.
@@ -41,27 +43,27 @@ var REC_DLG_UNTIL_INPUT = `
         /id("calendar-event-dialog-recurrence")/id("recurrence-range-groupbox")/[1]/
         id("recurrence-duration")/id("recurrence-range-until-box")/
         id("repeat-until-date")/anon({"class":"datepicker-box-class"})/
         {"class":"datepicker-text-class"}/
         anon({"class":"menulist-editable-box textbox-input-box"})/
         anon({"anonid":"input"})
 `;
 
-var plan_for_modal_dialog, wait_for_modal_dialog, open_pref_window;
+var plan_for_modal_dialog, wait_for_modal_dialog, open_pref_tab;
 
 function setupModule() {
     ({ plan_for_modal_dialog, wait_for_modal_dialog } =
         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_window } = collector.getModule("pref-window-helpers"));
+    ({ open_pref_tab } = collector.getModule("pref-window-helpers"));
     collector.getModule("pref-window-helpers").setupModule();
 }
 
 function installInto(module) {
     // copy constants into module
     module.SHORT_SLEEP = SHORT_SLEEP;
     module.MID_SLEEP = MID_SLEEP;
     module.TIMEOUT_MODAL_DIALOG = TIMEOUT_MODAL_DIALOG;
@@ -828,19 +830,22 @@ function setData(dialog, iframe, data) {
             dialog.keypress(iframeId("attachment-link"), "VK_DELETE", {});
         }
     }
     dialog.click(iframeId("item-title"));
     sleep();
 }
 
 function openLightningPrefs(aCallback, aParentController) {
-    open_pref_window("paneLightning", aCallback);
-
-    aParentController.waitFor(() => mozmill.utils.getWindows("Mail:Preferences").length == 0, "Error closing preferences window", 2000);
+    // Since the Lightning pane is added after load, asking for it with open_pref_tab won't work. Cheat instead.
+    let tab = open_pref_tab("paneGeneral");
+    tab.browser.contentDocument.querySelector('#category-box radio[pane="paneLightning"]').click();
+    utils.waitFor(() => tab.browser.contentDocument.documentElement.currentPane.id == "paneLightning",
+                  "Timed out waiting for prefpane paneLightning to load.");
+    aCallback(tab);
 }
 
 /**
  * Helper to work around a mac bug in Thunderbird's mozmill version. This can
  * likely be removed with Mozmill 2.0's new Element Object.
  *
  * @param aMenuList     The XUL menulist to select in
  * @param aValue        The value assigned to the desired menuitem
--- a/calendar/test/mozmill/testAlarmDefaultValue.js
+++ b/calendar/test/mozmill/testAlarmDefaultValue.js
@@ -22,16 +22,17 @@ function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         helpersForController,
         invokeEventDialog,
         openLightningPrefs,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule();
+    collector.getModule("content-tab-helpers").installInto(module);
     Object.assign(module, helpersForController(controller));
 }
 
 function testDefaultAlarms() {
     let localeUnitString = cal.l10n.getCalString("unitDays");
     let unitString = PluralForm.get(DEFVALUE, localeUnitString).replace("#1", DEFVALUE);
     let alarmString = (...args) => cal.l10n.getString("calendar-alarms", ...args);
     let originStringEvent = alarmString("reminderCustomOriginBeginBeforeEvent");
@@ -74,39 +75,35 @@ function testDefaultAlarms() {
         `);
         task.assertDOMProperty(reminderDetailsVisible, "value", expectedTaskReminder);
 
         // Close the task dialog
         task.window.close();
     });
 }
 
-function handlePrefDialog(prefs) {
-    let { eid: prefsid } = helpersForController(prefs);
-
+function handlePrefDialog(tab) {
     // Click on the alarms tab
-    prefs.click(prefsid("calPreferencesTabAlarms"));
+    content_tab_e(tab, "calPreferencesTabAlarms").click();
 
     // Turn on alarms for events and tasks
-    prefs.waitForElement(prefsid("eventdefalarm"));
-    menulistSelect(prefsid("eventdefalarm"), "1", prefs);
-    menulistSelect(prefsid("tododefalarm"), "1", prefs);
+    menulistSelect(content_tab_eid(tab, "eventdefalarm"), "1", controller);
+    menulistSelect(content_tab_eid(tab, "tododefalarm"), "1", controller);
 
     // Selects "days" as a unit
-    menulistSelect(prefsid("tododefalarmunit"), "days", prefs);
-    menulistSelect(prefsid("eventdefalarmunit"), "days", prefs);
+    menulistSelect(content_tab_eid(tab, "tododefalarmunit"), "days", controller);
+    menulistSelect(content_tab_eid(tab, "eventdefalarmunit"), "days", controller);
 
     // Sets default alarm length for events to DEFVALUE
-    let eventdefalarmlen = prefsid("eventdefalarmlen");
-    prefs.click(eventdefalarmlen);
-    prefs.keypress(eventdefalarmlen, "a", { accelKey: true });
-    prefs.type(eventdefalarmlen, DEFVALUE.toString());
+    let eventdefalarmlen = content_tab_eid(tab, "eventdefalarmlen");
+    controller.click(eventdefalarmlen);
+    controller.keypress(eventdefalarmlen, "a", { accelKey: true });
+    controller.type(eventdefalarmlen, DEFVALUE.toString());
 
-    let tododefalarmlen = prefsid("tododefalarmlen");
-    prefs.click(tododefalarmlen);
-    prefs.keypress(tododefalarmlen, "a", { accelKey: true });
-    prefs.type(tododefalarmlen, DEFVALUE.toString());
-    prefs.window.document.documentElement.acceptDialog();
+    let tododefalarmlen = content_tab_eid(tab, "tododefalarmlen");
+    controller.click(tododefalarmlen);
+    controller.keypress(tododefalarmlen, "a", { accelKey: true });
+    controller.type(tododefalarmlen, DEFVALUE.toString());
 }
 
 function teardownTest(module) {
     Preferences.resetBranch("calendar.alarms");
 }