Bug 1527547 - fix test-send-button.js on Mac. r=jorgk
authoraceman <acelists@atlas.sk>
Mon, 11 Mar 2019 16:20:00 +0100
changeset 32307 e915e56ae4360435030adfa96b8c9eb9758b783f
parent 32306 f79b60fb833f19ca091c9f209f40ad453c991546
child 32308 c54405f0225808eaf60565c7b898a03a0380acba
push idunknown
push userunknown
push dateunknown
reviewersjorgk
bugs1527547
Bug 1527547 - fix test-send-button.js on Mac. r=jorgk
mail/test/mozmill/composition/test-send-button.js
--- a/mail/test/mozmill/composition/test-send-button.js
+++ b/mail/test/mozmill/composition/test-send-button.js
@@ -9,16 +9,18 @@
 "use strict";
 
 var MODULE_NAME = "test-send-button";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers", "compose-helpers",
                          "window-helpers", "address-book-helpers"];
 
+var {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+
 var elib = ChromeUtils.import("chrome://mozmill/content/modules/elementslib.jsm");
 
 var account = null;
 
 var setupModule = function (module) {
   collector.getModule("folder-display-helpers").installInto(module);
   collector.getModule("compose-helpers").installInto(module);
   collector.getModule("window-helpers").installInto(module);
@@ -52,17 +54,16 @@ function check_send_commands_state(aCwc,
 }
 
 /**
  * Bug 431217
  * Test that the Send buttons are properly enabled if an addressee is input
  * by the user.
  */
 function test_send_enabled_manual_address() {
-  let {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
   let isMac = AppConstants.platform == "macosx";
   let cwc = open_compose_new_mail(); // compose controller
   // On an empty window, Send must be disabled.
   check_send_commands_state(cwc, false);
 
   // On valid "To:" addressee input, Send must be enabled.
   toggle_recipient_type(cwc, "addr_to");
   setup_msg_contents(cwc, " recipient@fake.invalid ", "", "");
@@ -82,25 +83,30 @@ function test_send_enabled_manual_addres
   check_send_commands_state(cwc, false);
 
   toggle_recipient_type(cwc, "addr_cc");
   check_send_commands_state(cwc, false);
 
   // We change focus from recipient type box to recipient input box.
   // One click on the recipient input box selects the whole typed string (bug 1527547).
   cwc.click(cwc.eid("addressCol2#1"), 200, 5);
-  if (!isMac)  // Skip tests on Mac for now since they fail.
-    assert_equals(cwc.e("addressCol2#1").selectionStart, 0);
-  // End of selection is counts length of the " recipient@" string from above.
-  if (!isMac)
-    assert_equals(cwc.e("addressCol2#1").selectionEnd, 11);
+  // On macOS the focus is automatically returned to the input box after operating
+  // the type box and no focus event is fired. So the recipient is not selected
+  // and the caret is after the last typed character (where we left off).
+  if (AppConstants.platform == "macosx") {
+    // Click subject and then back to recipient input to see that it gets selected.
+    cwc.click(cwc.eid("msgSubject"));
+    cwc.click(cwc.eid("addressCol2#1"));
+  }
+  assert_equals(cwc.e("addressCol2#1").selectionStart, 0);
+  // End of selection counts the length of the " recipient@" string from above.
+  assert_equals(cwc.e("addressCol2#1").selectionEnd, 11);
   // Another click after the recipient deselects it to allow typing.
   cwc.click(cwc.eid("addressCol2#1"), 200, 5);
-  if (!isMac)
-    assert_equals(cwc.e("addressCol2#1").selectionStart, 11);
+  assert_equals(cwc.e("addressCol2#1").selectionStart, 11);
   // This types additional characters into the recipient.
   setup_msg_contents(cwc, "domain.invalid", "", "");
   check_send_commands_state(cwc, true);
 
   clear_recipient(cwc);
   check_send_commands_state(cwc, false);
 
   // - a mailinglist in addressbook