Bug 542817 - [mozmill] Remove attendees not working in Event modification test. r=darktrojan
authorMarkus Adrario <mozilla@adrario.de>
Fri, 22 Mar 2019 10:46:23 +0100
changeset 26144 fc995375f444
parent 26143 fd6b3628b5bc
child 26145 83230ef727a3
push id15694
push userMozilla@Adrario.de
push dateFri, 22 Mar 2019 09:52:01 +0000
treeherdercomm-central@fc995375f444 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs542817
Bug 542817 - [mozmill] Remove attendees not working in Event modification test. r=darktrojan
calendar/lightning/content/lightning-item-iframe.js
calendar/lightning/content/lightning-item-iframe.xul
calendar/test/mozmill/eventDialog/testEventDialogModificationPrompt.js
calendar/test/mozmill/shared-modules/test-item-editing-helpers.js
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -4,17 +4,17 @@
 
 /* exported onEventDialogUnload, changeUndiscloseCheckboxStatus,
  *          categoryPopupHiding, categoryTextboxKeypress,
  *          toggleKeepDuration, dateTimeControls2State, onUpdateAllDay,
  *          openNewEvent, openNewTask, openNewMessage, openNewCardDialog,
  *          deleteAllAttachments, copyAttachment, attachmentLinkKeyPress,
  *          attachmentDblClick, attachmentClick, notifyUser,
  *          removeNotification, chooseRecentTimezone, showTimezonePopup,
- *          attendeeDblClick, attendeeClick, removeAttendee,
+ *          attendeeDblClick, setAttendeeContext, removeAttendee,
  *          removeAllAttendees, sendMailToUndecidedAttendees, checkUntilDate,
  *          applyValues
  */
 
 /* import-globals-from ../../base/content/calendar-ui-utils.js */
 /* import-globals-from ../../base/content/dialogs/calendar-dialog-utils.js */
 /* import-globals-from html-item-editing/react-code.js */
 /* globals gTimezonesEnabled, gShowLink */// Set by lightning-item-panel.js.
@@ -3878,22 +3878,17 @@ function attendeeDblClick(aEvent) {
     }
 }
 
 /**
  * Event handler to set up the attendee-popup. This builds the popup menuitems.
  *
  * @param aEvent         The popupshowing event
  */
-function attendeeClick(aEvent) {
-    // we need to handle right clicks only to display the context menu
-    if (aEvent.button != 2) {
-        return;
-    }
-
+function setAttendeeContext(aEvent) {
     if (window.attendees.length == 0) {
         // we just need the option to open the attendee dialog in this case
         let popup = document.getElementById("attendee-popup");
         let invite = document.getElementById("attendee-popup-invite-menuitem");
         for (let node of popup.childNodes) {
             if (node == invite) {
                 showElement(node);
             } else {
old mode 100644
new mode 100755
--- a/calendar/lightning/content/lightning-item-iframe.xul
+++ b/calendar/lightning/content/lightning-item-iframe.xul
@@ -613,17 +613,17 @@
                          crop="right"/>
                 </hbox>
               </hbox>
               <hbox flex="1">
                 <vbox id="item-attendees-box"
                       dialog-type="event"
                       flex="1"
                       context="attendee-popup"
-                      onclick="attendeeClick(event)"
+                      oncontextmenu="setAttendeeContext(event)"
                       disable-on-readonly="true"/>
               </hbox>
             </vbox>
           </tabpanel>
         </tabpanels>
         <hbox id="notify-options"
               dialog-type="event"
               align="center"
@@ -731,17 +731,17 @@
   <vbox id="item-attendees-box-template"
         hidden="true">
     <hbox flex="1" class="item-attendees-row" equalsize="always" hidden="true">
       <box class="item-attendees-cell"
            hidden="true"
            flex="1"
            context="attendee-popup"
            ondblclick="attendeeDblClick(event)"
-           onclick="attendeeClick(event)">
+           oncontextmenu="setAttendeeContext(event)">
         <img class="itip-icon"/>
         <label class="item-attendees-cell-label"
                crop="end"
                flex="1"/>
       </box>
       <box hidden="true" flex="1"/>
     </hbox>
   </vbox>
--- a/calendar/test/mozmill/eventDialog/testEventDialogModificationPrompt.js
+++ b/calendar/test/mozmill/eventDialog/testEventDialogModificationPrompt.js
@@ -184,18 +184,17 @@ function setupData() {
             repeat: "none",
             reminder: "none",
             priority: "normal",
             privacy: "public",
             status: "confirmed",
             freebusy: "busy",
             timezonedisplay: true,
             attachment: { add: "http://mozilla.org" },
-            // Test fails when changing attendees, therefore leaving out for now.
-            // attendees: { add: "foo@bar.de,foo@bar.com" }
+            attendees: { add: "foo@bar.de,foo@bar.com" }
         }, {
             title: "title2",
             location: "location2",
             description: "description2",
             categories: [],
             allday: true,
             startdate: date2,
             starttime: date2,
@@ -204,17 +203,17 @@ function setupData() {
             repeat: "daily",
             reminder: "5minutes",
             priority: "high",
             privacy: "private",
             status: "tentative",
             freebusy: "free",
             timezonedisplay: false,
             attachment: { remove: "mozilla.org" },
-            // attendees: { remove: "foo@bar.de,foo@bar.com" }
+            attendees: { remove: "foo@bar.de,foo@bar.com" }
         }],
         newlines: [
             { title: "title", description: "  test spaces  " },
             { title: "title", description: "\ntest newline\n" },
             { title: "title", description: "\rtest \\r\r" },
             { title: "title", description: "\r\ntest \\r\\n\r\n" },
             { title: "title", description: "\ttest \\t\t" }
         ]
--- a/calendar/test/mozmill/shared-modules/test-item-editing-helpers.js
+++ b/calendar/test/mozmill/shared-modules/test-item-editing-helpers.js
@@ -5,30 +5,30 @@
 var MODULE_NAME = "item-editing-helpers";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "window-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var SHORT_SLEEP, TIMEOUT_MODAL_DIALOG;
 var helpersForController, menulistSelect;
-var plan_for_modal_dialog, wait_for_modal_dialog;
+var plan_for_modal_dialog, wait_for_modal_dialog, augment_controller;
 var mark_failure;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         SHORT_SLEEP,
         TIMEOUT_MODAL_DIALOG,
         helpersForController,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     Object.assign(module, helpersForController(controller));
 
-    ({ plan_for_modal_dialog, wait_for_modal_dialog } =
+    ({ plan_for_modal_dialog, wait_for_modal_dialog, augment_controller } =
         collector.getModule("window-helpers"));
 
     ({ mark_failure } =
         collector.getModule("folder-display-helpers"));
 }
 // Lookup paths and path-snippets.
 // These 5 have to be used with itemEditLookup().
 var CATEGORY_LIST = `
@@ -512,27 +512,28 @@ function addAttendees(dialog, innerFrame
     let attendees = attendeesString.split(",");
     for (let attendee of attendees) {
         let calAttendee = innerFrame.window.attendees.find(
             aAtt => aAtt.id == `mailto:${attendee}`
         );
         // Only add if not already present.
         if (!calAttendee) {
             plan_for_modal_dialog("Calendar:EventDialog:Attendees", (attDialog) => {
-                let { lookup: attlookup } = helpersForController(attDialog);
+                let { lookup: attlookup, eid: attid } = helpersForController(attDialog);
 
-                let input = attlookup(`
-                    /id("calendar-event-dialog-attendees-v2")/
-                    anon({"class":"box-inherit dialog-content-box"})
-                `);
+                let input = attid("attendees-list");
                 // As starting point is always the last entered Attendee, we have
                 // to advance to not overwrite it.
+                attDialog.waitFor(() =>
+                    attDialog.window.document.activeElement.getAttribute("class") == "textbox-input"
+                );
                 attDialog.keypress(input, "VK_TAB", {});
                 attDialog.waitFor(() =>
-                    attDialog.window.document.activeElement.getAttribute("class") == "textbox-input"
+                    attDialog.window.document.activeElement.getAttribute("class") == "textbox-input" &&
+                    attDialog.window.document.activeElement.getAttribute("value") == null
                 );
                 attDialog.type(input, attendee);
                 attDialog.click(attlookup(`
                     /id("calendar-event-dialog-attendees-v2")/anon({"anonid":"buttons"})/
                     {"dlgtype":"accept"}
                 `));
             });
             dialog.click(dlgid("button-attendees"));
@@ -544,27 +545,29 @@ function addAttendees(dialog, innerFrame
 /**
  * Delete attendees from the event.
  *
  * @param dialog            The controller of the Edit Dialog.
  * @param innerFrame        The controller of the item iframe.
  * @param attendeesString   Comma separated list of eMail-Addresses to delete.
  */
 function deleteAttendees(event, innerFrame, attendeesString) {
+    let { eid: iframeid } = helpersForController(innerFrame);
     let { iframeLookup } = helpersForEditUI(innerFrame);
 
     // Now delete the attendees.
     let attendees = attendeesString.split(",");
     for (let attendee of attendees) {
         let attendeeToDelete = iframeLookup(`${ATTENDEES_ROW}/{"attendeeid":"mailto:${attendee}"}`);
-        // Unfortunately the context menu of the attendees is not working in
-        // Mozmill tests. Thus we have to use the JS-functions.
-        let calAttendee = innerFrame.window.attendees.find(aAtt => aAtt.id == `mailto:${attendee}`);
-        if (calAttendee) {
-            innerFrame.window.removeAttendee(calAttendee);
+        if (attendeeToDelete) {
+            augment_controller(event);
+            event.rightClick(attendeeToDelete);
+            event.click_menus_in_sequence(iframeid("attendee-popup").getNode(),
+                [{ id: "attendee-popup-removeattendee-menuitem" }]
+            );
         }
         event.waitForElementNotPresent(attendeeToDelete);
     }
 }
 
 /**
  * Set the timezone for the item
  *