Bug 1153543 - properly initialize SMTP server menulist for new identities. r=IanN, r=mkmelin. a=rkent
authoraceman <acelists@atlas.sk>
Fri, 17 Apr 2015 00:26:13 +0200
changeset 25858 73b80ca7e276844113d857f78fcd8edcce745f8f
parent 25857 ec4c11836db9aa3729b82dba62ebd65571f2d589
child 25859 98df258b09d07238b0733c1fb41bb0dd37c8ee60
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)
reviewersIanN, mkmelin, rkent
bugs1153543
Bug 1153543 - properly initialize SMTP server menulist for new identities. r=IanN, r=mkmelin. a=rkent
mailnews/base/prefs/content/am-identity-edit.js
--- a/mailnews/base/prefs/content/am-identity-edit.js
+++ b/mailnews/base/prefs/content/am-identity-edit.js
@@ -20,40 +20,45 @@ function onLoadIdentityProperties()
   initIdentityValues(gIdentity);
   initCopiesAndFolder(gIdentity);
   initCompositionAndAddressing(gIdentity);
 }
 
 // based on the values of gIdentity, initialize the identity fields we expose to the user
 function initIdentityValues(identity)
 {
+  function initSmtpServer(aServerKey) {
+    // Select a server in the SMTP server menulist by its key.
+    // The value of the identity.smtpServerKey is null when the
+    // "use default server" option is used so, if we get that passed in, select
+    // the useDefaultItem representing this option by using the value of "".
+    document.getElementById("identity.smtpServerKey").value = aServerKey || "";
+  }
+
   if (identity)
   {
     document.getElementById('identity.fullName').value = identity.fullName;
     document.getElementById('identity.email').value = identity.email;
     document.getElementById('identity.replyTo').value = identity.replyTo;
     document.getElementById('identity.organization').value = identity.organization;
     document.getElementById('identity.attachSignature').checked = identity.attachSignature;
     document.getElementById('identity.htmlSigText').value = identity.htmlSigText;
     document.getElementById('identity.htmlSigFormat').checked = identity.htmlSigFormat;
 
     if (identity.signature)
       document.getElementById('identity.signature').value = identity.signature.path;
 
     document.getElementById('identity.attachVCard').checked = identity.attachVCard;
     document.getElementById('identity.escapedVCard').value = identity.escapedVCard;
-
-    document.getElementById('identity.smtpServerKey').value =
-      identity.smtpServerKey || ""; // useDefaultItem.value is ""
+    initSmtpServer(identity.smtpServerKey);
   }
   else
   {
     // We're adding an identity, use the best default we have.
-    document.getElementById('identity.smtpServerKey').value =
-      gAccount.defaultIdentity.smtpServerKey;
+    initSmtpServer(gAccount.defaultIdentity.smtpServerKey);
   }
 
   setupSignatureItems();
 }
 
 function initCopiesAndFolder(identity)
 {
   // if we are editing an existing identity, use it...otherwise copy our values from the default identity
@@ -339,17 +344,17 @@ function getAccountForFolderPickerState(
  * Build the SMTP server list for display.
  */
 function loadSMTPServerList()
 {
   var smtpServerList = document.getElementById("identity.smtpServerKey");
   let servers = MailServices.smtp.servers;
   let defaultServer = MailServices.smtp.defaultServer;
 
-  var smtpPopup = document.getElementById("smtpPopup");
+  var smtpPopup = smtpServerList.menupopup;
   while (smtpPopup.lastChild.nodeName != "menuseparator")
     smtpPopup.lastChild.remove();
 
   while (servers.hasMoreElements())
   {
     var server = servers.getNext();
 
     if (server instanceof Components.interfaces.nsISmtpServer)