Backout a4907013150f for test failures (bug 87987). rs=jorgk
authorJorg K
Thu, 07 Jan 2016 21:50:01 +0100
changeset 26611 aadc5f56de797842edf850360fc91e3431f9ed96
parent 26610 88c0fae98fa12263933495384fe7fc8c56dc5dfa
child 26612 833446bffdd9fb3177091cab815d3eb65b2c6304
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs87987
backs outa4907013150f036732f87103504d35717fa9624b
Backout a4907013150f for test failures (bug 87987). rs=jorgk
mail/test/mozmill/composition/test-newmsg-compose-identity.js
--- a/mail/test/mozmill/composition/test-newmsg-compose-identity.js
+++ b/mail/test/mozmill/composition/test-newmsg-compose-identity.js
@@ -6,164 +6,82 @@
  * Tests that compose new message chooses the correct initial identity when
  * called from the context of an open composer.
  */
 
 var MODULE_NAME = "test-newmsg-compose-identity";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers",
-                       "window-helpers", "compose-helpers"];
+                         "window-helpers", "compose-helpers"];
+
+var account;
+
+var identity1Email = "x@example.com";
+var identity2Email = "y@example.com";
 
 Components.utils.import("resource:///modules/mailServices.js");
 
-var gInbox;
-var gDrafts;
-var account;
-
-var identityKey1;
-var identity1Email = "x@example.invalid";
-var identityKey2;
-var identity2Email = "y@example.invalid";
-var identity2Name = "User Y";
-var identity2From = identity2Name + " <" + identity2Email + ">";
-
 function setupModule(module) {
-  for (let lib of MODULE_REQUIRES) {
-    collector.getModule(lib).installInto(module);
-  }
+  collector.getModule("folder-display-helpers").installInto(module);
+  collector.getModule("window-helpers").installInto(module);
+  collector.getModule("compose-helpers").installInto(module);
 
   // Now set up an account with some identities.
   let acctMgr = MailServices.accounts;
   account = acctMgr.createAccount();
   account.incomingServer = acctMgr.createIncomingServer(
     "nobody", "New Msg Compose Identity Testing", "pop3");
 
   let identity1 = acctMgr.createIdentity();
   identity1.email = identity1Email;
   account.addIdentity(identity1);
-  identityKey1 = identity1.key;
 
   let identity2 = acctMgr.createIdentity();
   identity2.email = identity2Email;
-  identity2.fullName = identity2Name;
   account.addIdentity(identity2);
-  identityKey2 = identity2.key;
-
-  gInbox = account.incomingServer.rootFolder
-                  .getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox);
 }
 
 /**
  * Helper to check that a suitable From identity was set up in the given
  * composer window.
- *
- * @param cwc             Compose window controller.
- * @param aIdentityKey    The key of the expected identity.
- * @param aIdentityAlias  The displayed label of the expected identity.
- * @param aIdentityValue  The value of the expected identity
- *                        (the sender address to be sent out).
  */
-function checkCompIdentity(cwc, aIdentityKey, aIdentityAlias, aIdentityValue) {
-  let identityList = cwc.e("msgIdentity");
-
-  assert_equals(cwc.window.getCurrentIdentityKey(), aIdentityKey,
-                "The From identity is not correctly selected");
-
-  if (aIdentityAlias) {
-    assert_equals(identityList.label, aIdentityAlias,
-                  "The From address does not have the correct label");
-  }
-
-  if (aIdentityValue) {
-    assert_equals(identityList.value, aIdentityValue,
-                  "The From address does not have the correct value");
-  }
+function checkCompIdentity(composeWin, expectedFromEmail) {
+  let identityList = composeWin.e("msgIdentity");
+  assert_equals(identityList.selectedItem.label, " <" + expectedFromEmail + ">",
+                "The From address is not correctly selected");
 }
 
 /**
  * Test that starting a new message from an open compose window gets the
  * expected initial identity.
  */
 function test_compose_from_composer() {
-  be_in_folder(gInbox);
+  be_in_folder(account.incomingServer
+                      .rootFolder
+                      .getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox));
 
   let mainCompWin = open_compose_new_mail();
-  checkCompIdentity(mainCompWin, account.defaultIdentity.key);
+  checkCompIdentity(mainCompWin, account.defaultIdentity.email);
 
   // Compose a new message from the compose window.
   plan_for_new_window("msgcompose");
   mainCompWin.keypress(null, "n", {shiftKey: false, accelKey: true});
   let newCompWin = wait_for_compose_window();
-  checkCompIdentity(newCompWin, account.defaultIdentity.key);
+  checkCompIdentity(newCompWin, account.defaultIdentity.email);
   close_compose_window(newCompWin);
 
   // Switch to identity2 in the main compose window, new compose windows
-  // starting from here should use the same identiy as its "parent".
+  // starting from here should use the same identiy as it's "parent".
   let identityList = mainCompWin.e("msgIdentity");
   identityList.selectedIndex++;
-  mainCompWin.click_menus_in_sequence(mainCompWin.e("msgIdentityPopup"),
-                                      [ { identitykey: identityKey2 } ]);
-  checkCompIdentity(mainCompWin, identityKey2);
+  checkCompIdentity(mainCompWin, identity2Email);
 
   // Compose a second new message from the compose window.
   plan_for_new_window("msgcompose");
   mainCompWin.keypress(null, "n", {shiftKey: false, accelKey: true});
   let newCompWin2 = wait_for_compose_window();
-  checkCompIdentity(newCompWin2, identityKey2);
-
+  checkCompIdentity(newCompWin2, identity2Email);
   close_compose_window(newCompWin2);
 
   close_compose_window(mainCompWin);
 }
 
-/**
- * Bug 87987
- * Test editing the identity email/name for the current composition.
- */
-function test_editing_identity() {
-  Services.prefs.setBoolPref("mail.compose.warned_about_customize_from", true);
-  be_in_folder(gInbox);
-
-  let compWin = open_compose_new_mail();
-  checkCompIdentity(compWin, account.defaultIdentity.key, " <" + identity1Email + ">");
-
-  // Input custom identity data into the From field.
-  let customName = "custom";
-  let customEmail = "custom@edited.invalid";
-  let identityCustom = customName + " <" + customEmail + ">";
-
-  compWin.click_menus_in_sequence(compWin.e("msgIdentityPopup"),
-                                  [ { command: "cmd_customizeFromAddress" } ]);
-
-  compWin.type(compWin.e("msgIdentityPopup").value, identityCustom);
-
-  // Save message with this changed identity.
-  compWin.window.SaveAsDraft();
-
-  // Switch to another identity to see if editable field still obeys predefined
-  // identity values.
-  compWin.click_menus_in_sequence(compWin.e("msgIdentityPopup"),
-                                  [ { identitykey: identityKey2 } ]);
-  checkCompIdentity(compWin, identityKey2, identity2From, identity2From);
-
-  // This should not save the identity2 to the draft message.
-  close_compose_window(compWin);
-
-  gDrafts = MailServices.accounts.localFoldersServer.rootFolder
-                                 .getFolderWithFlags(Ci.nsMsgFolderFlags.Drafts);
-  be_in_folder(gDrafts);
-  let curMessage = select_click_row(0);
-  assert_equals(curMessage.author, identityCustom);
-  // Remove the saved draft.
-  press_delete(mc);
-  Services.prefs.setBoolPref("mail.compose.warned_about_customize_from", false);
-}
-
-function teardownModule(module) {
-  account.removeIdentity(MailServices.accounts.getIdentity(identityKey1));
-  // The last identity of an account can't be removed so clear all its prefs
-  // which effectively destroys it.
-  MailServices.accounts.getIdentity(identityKey2).clearAllValues();
-  MailServices.accounts.removeAccount(account);
-  MailServices.accounts.localFoldersServer.rootFolder
-              .propagateDelete(gDrafts, true, null);
-}