Bug 1607526 - Hide To: field if the Newsgroups filed is in use. r=mkmelin
authorAlessandro Castellani <alessandro@thunderbird.net>
Thu, 23 Jan 2020 15:55:49 -0800
changeset 38001 04d95196247e3a348898c8fcff0ea5bccd7bd76c
parent 38000 237a41008a61db0eaa252f3c0bea04c89c455fb7
child 38002 bfcc947899e561eb23756dba6841cb17f758d2e3
push id398
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:10:28 +0000
reviewersmkmelin
bugs1607526
Bug 1607526 - Hide To: field if the Newsgroups filed is in use. r=mkmelin
mail/base/content/mailWidgets.js
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/addressingWidgetOverlay.js
mail/components/compose/content/messengercompose.xhtml
mail/test/browser/composition/browser_addressWidgets.js
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -1826,16 +1826,18 @@
       return document.importNode(this.constructor._fragment, true);
     }
 
     _setupEmailInput() {
       this.appendChild(this.fragment);
 
       this.emailInput = this.querySelector(`input[is="autocomplete-input"]`);
       this.emailInput.value = this.fullAddress;
+      this.emailInput.classList.remove("mail-primary-input");
+      this.emailInput.classList.remove("news-primary-input");
 
       let params = JSON.parse(
         this.emailInput.getAttribute("autocompletesearchparam")
       );
       params.type = this.originalInput.getAttribute("recipienttype");
       this.emailInput.setAttribute(
         "autocompletesearchparam",
         JSON.stringify(params)
@@ -1943,17 +1945,17 @@
       let isValid = this.isValidAddress(this.emailAddress);
       let listNames = MimeParser.parseHeaderField(
         this.fullAddress,
         MimeParser.HEADER_ADDRESS
       );
       let isMailingList =
         listNames.length > 0 &&
         MailServices.ab.mailListNameExists(listNames[0].name);
-      let isNewsgroup = this.originalInput.classList.contains("nntp-input");
+      let isNewsgroup = this.originalInput.classList.contains("news-input");
 
       this.classList.toggle(
         "error",
         !isValid && !isMailingList && !isNewsgroup
       );
 
       let emailCard = DisplayNameUtils.getCardForEmail(this.emailAddress);
       this.classList.toggle(
@@ -1991,17 +1993,17 @@
         return;
       }
       this.hasConnected = true;
 
       this.highlightNonMatches = Services.prefs.getBoolPref(
         "mail.autoComplete.highlightNonMatches"
       );
 
-      for (let input of this.querySelectorAll(".pop-imap-input,.nntp-input")) {
+      for (let input of this.querySelectorAll(".mail-input,.news-input")) {
         setupAutocompleteInput(input, this.highlightNonMatches);
       }
     }
 
     /**
      * Create a new recipient row container with the input autocomplete.
      *
      * @param {Array} recipient - The unique identifier of the email header.
@@ -2127,17 +2129,17 @@
 
       let listNames = MimeParser.parseHeaderField(
         address.toString(),
         MimeParser.HEADER_ADDRESS
       );
       let isMailingList =
         listNames.length > 0 &&
         MailServices.ab.mailListNameExists(listNames[0].name);
-      let isNewsgroup = element.classList.contains("nntp-input");
+      let isNewsgroup = element.classList.contains("news-input");
 
       pill.classList.toggle(
         "error",
         !isValidAddress(address.email) && !isMailingList && !isNewsgroup
       );
 
       let emailCard = DisplayNameUtils.getCardForEmail(address.email);
       pill.classList.toggle(
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -7,17 +7,18 @@
 /* import-globals-from ../../../../mailnews/addrbook/content/abDragDrop.js */
 /* import-globals-from ../../../base/content/mailCore.js */
 /* import-globals-from ../../../base/content/utilityOverlay.js */
 /* import-globals-from addressingWidgetOverlay.js */
 /* import-globals-from ComposerCommands.js */
 /* import-globals-from editor.js */
 /* import-globals-from editorUtilities.js */
 
-/* global updateRecipientsPanelVisibility */
+/* global updateRecipientsPanelVisibility, updateUIforNNTPAccount
+          updateUIforIMAPAccount */
 
 /**
  * Commands for the message composition window.
  */
 
 // Ensure the activity modules are loaded for this window.
 ChromeUtils.import("resource:///modules/activity/activityModules.jsm");
 var { AttachmentChecker } = ChromeUtils.import(
@@ -3418,17 +3419,17 @@ function ComposeLoad() {
 
       for (let header of otherHeaders.split(",")) {
         let recipient = {
           id: `${header}AddrInput`,
           row: `addressRow${header}`,
           label: `${header}AddrLabel`,
           labelId: header,
           container: `${header}AddrContainer`,
-          class: "nntp-input",
+          class: "news-input",
           type: "addr_other",
         };
 
         extraRecipientsPanel.appendChild(createRecipientLabel(header));
         recipientsContainer.appendChild(
           recipientsContainer.buildRecipientRows(recipient)
         );
       }
@@ -3955,17 +3956,17 @@ function updateSendLock() {
       );
       let isMailingList =
         listNames.length > 0 &&
         MailServices.ab.mailListNameExists(listNames[0].name);
 
       if (
         isValidAddress(address.emailAddress) ||
         isMailingList ||
-        address.originalInput.classList.contains("nntp-input")
+        address.originalInput.classList.contains("news-input")
       ) {
         gSendLocked = false;
         break;
       }
     }
   }
 }
 
@@ -4684,30 +4685,42 @@ function getIdentityForKey(key) {
   return MailServices.accounts.getIdentity(key);
 }
 
 function getCurrentIdentity() {
   return getIdentityForKey(getCurrentIdentityKey());
 }
 
 function AdjustFocus() {
-  let element = document.getElementById("toAddrContainer");
+  // If is NNTP account, check the newsgroup field.
+  let account = MailServices.accounts.getAccount(getCurrentAccountKey());
+  let accountType = account.incomingServer.type;
+
+  let element =
+    accountType == "nntp"
+      ? document.getElementById("newsgroupsAddrContainer")
+      : document.getElementById("toAddrContainer");
+
+  // Focus on the recipient input field if no pills are present.
   if (element.querySelectorAll("mail-address-pill").length == 0) {
-    // Focus on the "To" recipient field.
-    document.getElementById("toAddrInput").focus();
-  } else {
-    element = document.getElementById("msgSubject");
-    if (element.value == "") {
-      // Focus subject.
-      element.focus();
-    } else {
-      // Focus message body.
-      SetMsgBodyFrameFocus();
-    }
-  }
+    element
+      .querySelector(`input[is="autocomplete-input"][recipienttype]`)
+      .focus();
+    return;
+  }
+
+  // Focus subject if empty.
+  element = document.getElementById("msgSubject");
+  if (element.value == "") {
+    element.focus();
+    return;
+  }
+
+  // Focus message body.
+  SetMsgBodyFrameFocus();
 }
 
 /**
  * Set the compose window title with flavors (Write | Print Preview).
  *
  * @param isPrintPreview (optional) true:  Set title for 'Print Preview' window.
  *                                  false: Set title for 'Write' window (default).
  */
@@ -6225,60 +6238,79 @@ function DetermineConvertibility() {
   } catch (ex) {}
   return Ci.nsIMsgCompConvertible.No;
 }
 
 /**
  * Hides addressing options (To, CC, Bcc, Newsgroup, Followup-To, etc.)
  * that are not relevant for the account type used for sending.
  *
- * @param aAccountKey  Key of the account that is currently selected
- *                     as the sending account.
+ * @param {string} accountKey - Key of the account that is currently selected
+ *   as the sending account.
+ * @param {string} prevKey - Key of the account that was previously selected
+ *   as the sending account.
  */
-function hideIrrelevantAddressingOptions(aAccountKey) {
+function hideIrrelevantAddressingOptions(accountKey, prevKey) {
   let hideNews = true;
   for (let account of fixIterator(
     MailServices.accounts.accounts,
     Ci.nsIMsgAccount
   )) {
     if (account.incomingServer.type == "nntp") {
       hideNews = false;
     }
   }
   // If there is no News (NNTP) account existing then
   // hide the Newsgroup and Followup-To recipient type in all the menulists.
-  for (let item of document.querySelectorAll(".nntp-label")) {
+  for (let item of document.querySelectorAll(".news-label")) {
     item.collapsed = hideNews;
   }
 
+  let account = MailServices.accounts.getAccount(accountKey);
+  let accountType = account.incomingServer.type;
+
+  // If the new account is a News (NNTP) account.
+  if (accountType == "nntp") {
+    updateUIforNNTPAccount();
+    return;
+  }
+
+  // If the new account is a Mail account and a previous account was selected.
+  if (accountType != "nntp" && prevKey != "") {
+    updateUIforIMAPAccount();
+  }
+
   updateRecipientsPanelVisibility();
 }
 
 function LoadIdentity(startup) {
   var identityElement = document.getElementById("msgIdentity");
   var prevIdentity = gCurrentIdentity;
 
   if (identityElement) {
     let idKey = null;
     let accountKey = null;
+    let currKey = getCurrentAccountKey();
     if (identityElement.selectedItem) {
       // Set the identity key value on the menu list.
       idKey = identityElement.selectedItem.getAttribute("identitykey");
       identityElement.setAttribute("identitykey", idKey);
       gCurrentIdentity = MailServices.accounts.getIdentity(idKey);
 
       // Set the account key value on the menu list.
       accountKey = identityElement.selectedItem.getAttribute("accountkey");
       identityElement.setAttribute("accountkey", accountKey);
-      hideIrrelevantAddressingOptions(accountKey);
-    }
-
-    for (let input of document.querySelectorAll(
-      ".pop-imap-input,.nntp-input"
-    )) {
+
+      // Update the addressing options only if a new account was selected.
+      if (currKey != getCurrentAccountKey()) {
+        hideIrrelevantAddressingOptions(accountKey, currKey);
+      }
+    }
+
+    for (let input of document.querySelectorAll(".mail-input,.news-input")) {
       let params = JSON.parse(input.searchParam);
       params.idKey = idKey;
       params.accountKey = accountKey;
       input.searchParam = JSON.stringify(params);
     }
 
     if (!startup && prevIdentity && idKey != prevIdentity.key) {
       var prevReplyTo = prevIdentity.replyTo;
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -125,16 +125,19 @@ function CompFields2Recipients(msgCompFi
       let input = document.getElementById("replyAddrInput");
       input.focus();
       input.value = msgReplyTo.join(", ");
       recipientAddPill(input, true);
     }
 
     if (msgTo) {
       let input = document.getElementById("toAddrInput");
+      if (input.closest(".address-row").classList.contains("hidden")) {
+        showAddressRow(document.getElementById("addr_to"), "addressRowTo");
+      }
       input.focus();
       input.value = msgTo.join(", ");
       recipientAddPill(input, true);
     }
 
     if (msgCC) {
       showAddressRow(document.getElementById("addr_cc"), "addressRowCc");
       let input = document.getElementById("ccAddrInput");
@@ -178,16 +181,113 @@ function CompFields2Recipients(msgCompFi
     let currentAddress = gCurrentIdentity ? gCurrentIdentity.fullAddress : "";
     addRecipientsToIgnoreList(
       [currentAddress, msgTo, msgCC, msgBCC].filter(adr => adr).join(", ")
     );
   }
 }
 
 /**
+ * Update the recipients area UI to show News related fields and hide
+ * Mail releated fields.
+ */
+function updateUIforNNTPAccount() {
+  // Hide the `mail-primary-input` field row if no pills have been created.
+  let mailContainer = document
+    .querySelector(".mail-primary-input")
+    .closest(".address-container");
+  if (mailContainer.querySelectorAll("mail-address-pill").length == 0) {
+    mailContainer
+      .closest(".address-row")
+      .querySelector(".aw-firstColBox > label")
+      .click();
+  }
+
+  // Show the closing label.
+  mailContainer
+    .closest(".address-row")
+    .querySelector(".aw-firstColBox > label")
+    .removeAttribute("collapsed");
+
+  // Show the `news-primary-input` field row if not already visible.
+  let newsContainer = document
+    .querySelector(".news-primary-input")
+    .closest(".address-row");
+  if (newsContainer.classList.contains("hidden")) {
+    document.querySelector(".news-primary-label").click();
+  } else {
+    document
+      .querySelector(".news-primary-label")
+      .setAttribute("collapsed", "true");
+  }
+
+  // Hide the closing label.
+  newsContainer
+    .querySelector(".aw-firstColBox > label")
+    .setAttribute("collapsed", "true");
+
+  // Reorder `mail-label` menu items.
+  let panel = document.getElementById("extraRecipientsPanel");
+  for (let label of document.querySelectorAll(".mail-label")) {
+    panel.appendChild(label);
+  }
+
+  // Reorder `news-label` menu items.
+  let extraRecipients = document.querySelector(".address-extra-recipients");
+  for (let label of document.querySelectorAll(".news-label")) {
+    extraRecipients.prepend(label);
+  }
+}
+
+/**
+ * Update the recipients area UI to show Mail related fields and hide
+ * News releated fields. This method is called only if the UI was previously
+ * updated to accommodate a News account type.
+ */
+function updateUIforIMAPAccount() {
+  // Show the `mail-primary-input` field row if not already visible.
+  let mailContainer = document
+    .querySelector(".mail-primary-input")
+    .closest(".address-row");
+  if (mailContainer.classList.contains("hidden")) {
+    document.querySelector(".mail-primary-label").click();
+  }
+
+  // Hide the closing label.
+  mailContainer
+    .querySelector(".aw-firstColBox > label")
+    .setAttribute("collapsed", "true");
+
+  // Hide the `news-primary-input` field row if no pills have been created.
+  let newsContainer = document
+    .querySelector(".news-primary-input")
+    .closest(".address-row");
+  if (newsContainer.querySelectorAll("mail-address-pill").length == 0) {
+    newsContainer.querySelector(".aw-firstColBox > label").click();
+  }
+
+  // Show the closing label.
+  newsContainer
+    .querySelector(".aw-firstColBox > label")
+    .removeAttribute("collapsed");
+
+  // Reorder `mail-label` menu items.
+  let panel = document.getElementById("extraRecipientsPanel");
+  for (let label of document.querySelectorAll(".news-label")) {
+    panel.appendChild(label);
+  }
+
+  // Reorder `news-label` menu items.
+  let extraRecipients = document.querySelector(".address-extra-recipients");
+  for (let label of document.querySelectorAll(".mail-label")) {
+    extraRecipients.prepend(label);
+  }
+}
+
+/**
  * Clear a specific recipient row if is visible and pills are present. This is
  * commonly used when loading a new identity.
  *
  * @param {Array} msgCompFields - The array containing all the recipient fields.
  * @param {string} recipientType - Which recipient needs to be cleared.
  * @param {Array} recipientsList - The array containing the old recipients.
  */
 function awRemoveRecipients(msgCompFields, recipientType, recipientsList) {
@@ -526,17 +626,17 @@ function resetAddressContainer(element) 
   let isMailingList =
     listNames.length > 0 &&
     MailServices.ab.mailListNameExists(listNames[0].name);
 
   if (
     address &&
     (isValidAddress(address) ||
       isMailingList ||
-      element.classList.contains("nntp-input"))
+      element.classList.contains("news-input"))
   ) {
     recipientAddPill(element);
   }
 
   // Reset the input size if no pill was created.
   if (!address) {
     element.setAttribute("size", 1);
   }
@@ -674,17 +774,18 @@ function hideAddressRow(element, labelID
 
   // Reset the original input.
   let input = container.querySelector(`input[is="autocomplete-input"]`);
   input.value = "";
 
   container.classList.add("hidden");
   document.getElementById(labelID).removeAttribute("collapsed");
 
-  onRecipientsChanged();
+  // Update the sender button only if pills were deleted.
+  onRecipientsChanged(!pills.length);
   updateRecipientsPanelVisibility();
 }
 
 /**
  * Calculate the height of the composer header area every time a pill is created.
  * If the height is bigger than 2/3 of the compose window heigh, enable overflow.
  */
 function calculateHeaderHeight() {
--- a/mail/components/compose/content/messengercompose.xhtml
+++ b/mail/components/compose/content/messengercompose.xhtml
@@ -597,21 +597,21 @@
        onclick="this.hidePopup();">
   <label id="addr_reply" value="&replyAddr2.label;"
          onclick="showAddressRow(this, 'addressRowReply')"
          onkeypress="showAddressRowKeyPress(event, this, 'addressRowReply')"
          control="replyAddrInput" class="recipient-label"/>
   <label id="addr_newsgroups" value="&newsgroupsAddr2.label;"
          onclick="showAddressRow(this, 'addressRowNewsgroups')"
          onkeypress="showAddressRowKeyPress(event, this, 'addressRowNewsgroups')"
-         control="newsgroupsAddrInput" class="nntp-label recipient-label"/>
+         control="newsgroupsAddrInput" class="news-label news-primary-label recipient-label"/>
   <label id="addr_followup" value="&followupAddr2.label;"
          onclick="showAddressRow(this, 'addressRowFollowup')"
          onkeypress="showAddressRowKeyPress(event, this, 'addressRowFollowup')"
-         control="followupAddrInput" class="nntp-label recipient-label"/>
+         control="followupAddrInput" class="news-label recipient-label"/>
 </panel>
 
 <menupopup id="msgComposeContext"
            onpopupshowing="if (event.target != this) { return true; } openEditorContextMenu(this);">
 
   <!-- Spellchecking menu items -->
   <menuitem id="spellCheckNoSuggestions" label="&spellNoSuggestions.label;" disabled="true"/>
   <menuseparator id="spellCheckAddSep" />
@@ -2027,53 +2027,63 @@
                       disableautoselect="true" onkeypress="fromKeyPress(event);"
                       oncommand="LoadIdentity(false);" disableonsend="true">
               <menupopup id="msgIdentityPopup"/>
             </menulist>
 
             <hbox class="addressingWidgetItem">
               <hbox id="addressingWidgetLabels" class="address-extra-recipients"
                     flex="1" align="center">
-                <label id="addr_to" control="toAddrInput" hidden="true"/>
+                <label id="addr_to" value="&toAddr2.label;"
+                       onclick="showAddressRow(this, 'addressRowTo')"
+                       onkeypress="showAddressRowKeyPress(event, this, 'addressRowTo')"
+                       control="toAddrInput" class="mail-primary-label mail-label recipient-label"
+                       collapsed="true"/>
                 <label id="addr_cc" value="&ccAddr2.label;"
                        onclick="showAddressRow(this, 'addressRowCc')"
                        onkeypress="showAddressRowKeyPress(event, this, 'addressRowCc')"
-                       control="ccAddrInput" class="recipient-label"/>
+                       control="ccAddrInput" class="mail-label recipient-label"/>
                 <label id="addr_bcc" value="&bccAddr2.label;"
                        onclick="showAddressRow(this, 'addressRowBcc')"
                        onkeypress="showAddressRowKeyPress(event, this, 'addressRowBcc')"
-                       control="bccAddrInput" class="recipient-label"/>
+                       control="bccAddrInput" class="mail-label recipient-label"/>
 
                 <label id="extraRecipientsLabel"
                        onclick="showExtraRecipients(event);"
                        tooltiptext="&extraRecipients.tooltip;"
                        class="extra-recipients-label"
                        onkeypress="if (event.key == 'Enter') { showExtraRecipients(event); }">
                     <image class="overflow-icon"/>
                 </label>
 
               </hbox>
             </hbox>
           </hbox>
 
           <mail-recipients-area id="recipientsContainer" orient="vertical"
                                 class="recipients-container" flex="1">
             <hbox id="addressRowTo" class="addressingWidgetItem address-row">
-              <hbox class="aw-firstColBox"/>
+              <hbox class="aw-firstColBox" align="top">
+                <label onclick="hideAddressRow(this, 'addr_to');"
+                       onkeypress="if (event.key == 'Enter') { hideAddressRow(this, 'addr_to'); }"
+                       collapsed="true">
+                  <image class="close-icon"/>
+                </label>
+              </hbox>
               <hbox class="address-label-container" align="top" pack="end"
                     style="&headersSpace2.style;">
                 <label id="toAddrLabel" value="&toAddr2.label;"
                        control="toAddrInput"/>
               </hbox>
               <hbox id="toAddrContainer" flex="1" align="center"
                     class="input-container wrap-container address-container"
                     onclick="focusAddressInput(event);">
                 <html:input is="autocomplete-input" id="toAddrInput"
                             type="text"
-                            class="plain address-input pop-imap-input"
+                            class="plain address-input mail-input mail-primary-input"
                             disableonsend="true"
                             aria-labelledby="toAddrLabel"
                             autocompletesearch="mydomain addrbook ldap news"
                             autocompletesearchparam="{}"
                             timeout="300"
                             maxrows="6"
                             completedefaultindex="true"
                             forcecomplete="true"
@@ -2100,17 +2110,17 @@
                 <label id="ccAddrLabel" value="&ccAddr2.label;"
                        control="ccAddrInput"/>
               </hbox>
               <hbox id="ccAddrContainer" flex="1" align="center"
                     class="input-container wrap-container address-container"
                     onclick="focusAddressInput(event);">
                 <html:input is="autocomplete-input" id="ccAddrInput"
                             type="text"
-                            class="plain address-input pop-imap-input"
+                            class="plain address-input mail-input"
                             disableonsend="true"
                             aria-labelledby="ccAddrLabel"
                             autocompletesearch="mydomain addrbook ldap news"
                             autocompletesearchparam="{}"
                             timeout="300"
                             maxrows="6"
                             completedefaultindex="true"
                             forcecomplete="true"
@@ -2137,17 +2147,17 @@
                 <label id="bccAddrLabel" value="&bccAddr2.label;"
                        control="bccAddrInput"/>
               </hbox>
               <hbox id="bccAddrContainer" flex="1" align="center"
                     class="input-container wrap-container address-container"
                     onclick="focusAddressInput(event);">
                 <html:input is="autocomplete-input" id="bccAddrInput"
                             type="text"
-                            class="plain address-input pop-imap-input"
+                            class="plain address-input mail-input"
                             disableonsend="true"
                             aria-labelledby="bccAddrLabel"
                             autocompletesearch="mydomain addrbook ldap news"
                             autocompletesearchparam="{}"
                             timeout="300"
                             maxrows="6"
                             completedefaultindex="true"
                             forcecomplete="true"
@@ -2174,17 +2184,17 @@
                 <label id="replyAddrLabel" value="&replyAddr2.label;"
                        control="replyAddrInput"/>
               </hbox>
               <hbox id="replyAddrContainer" flex="1" align="center"
                     class="input-container wrap-container address-container"
                     onclick="focusAddressInput(event);">
                 <html:input is="autocomplete-input" id="replyAddrInput"
                             type="text"
-                            class="plain address-input pop-imap-input"
+                            class="plain address-input mail-input"
                             disableonsend="true"
                             aria-labelledby="replyAddrLabel"
                             autocompletesearch="mydomain addrbook ldap news"
                             autocompletesearchparam="{}"
                             timeout="300"
                             maxrows="6"
                             completedefaultindex="true"
                             forcecomplete="true"
@@ -2211,17 +2221,17 @@
                 <label id="newsgroupsAddrLabel" value="&newsgroupsAddr2.label;"
                        control="newsgroupsAddrInput"/>
               </hbox>
               <hbox id="newsgroupsAddrContainer" flex="1" align="center"
                     class="input-container wrap-container address-container"
                     onclick="focusAddressInput(event);">
                 <html:input is="autocomplete-input" id="newsgroupsAddrInput"
                             type="text"
-                            class="plain address-input nntp-input"
+                            class="plain address-input news-input news-primary-input"
                             disableonsend="true"
                             aria-labelledby="newsgroupsAddrLabel"
                             autocompletesearch="mydomain addrbook ldap news"
                             autocompletesearchparam="{}"
                             timeout="300"
                             maxrows="6"
                             completedefaultindex="true"
                             forcecomplete="true"
@@ -2248,17 +2258,17 @@
                 <label id="followupAddrLabel" value="&followupAddr2.label;"
                        control="followupAddrInput"/>
               </hbox>
               <hbox id="followupAddrContainer" flex="1" align="center"
                     class="input-container wrap-container address-container"
                     onclick="focusAddressInput(event);">
                 <html:input is="autocomplete-input" id="followupAddrInput"
                             type="text"
-                            class="plain address-input nntp-input"
+                            class="plain address-input news-input"
                             disableonsend="true"
                             aria-labelledby="followupAddrLabel"
                             autocompletesearch="mydomain addrbook ldap news"
                             autocompletesearchparam="{}"
                             timeout="300"
                             maxrows="6"
                             completedefaultindex="true"
                             forcecomplete="true"
--- a/mail/test/browser/composition/browser_addressWidgets.js
+++ b/mail/test/browser/composition/browser_addressWidgets.js
@@ -73,16 +73,23 @@ function check_nntp_address_types() {
     "addr_cc",
     "addr_reply",
     "addr_bcc",
     "addr_newsgroups",
     "addr_followup",
   ]);
 }
 
+/**
+ * With an NNTP account, the 'To' addressing row should be hidden.
+ */
+function check_collapsed_pop_recipient(cwc) {
+  Assert.ok(cwc.e("addressRowTo").classList.contains("hidden"));
+}
+
 function add_NNTP_account() {
   // Create a NNTP server
   let nntpServer = MailServices.accounts
     .createIncomingServer(null, "example.nntp.invalid", "nntp")
     .QueryInterface(Ci.nsINntpIncomingServer);
 
   let identity = MailServices.accounts.createIdentity();
   identity.email = "tinderbox2@example.invalid";
@@ -130,16 +137,17 @@ add_task(function test_address_types() {
 
   add_NNTP_account();
 
   // From now on, we should always get all possible address types offered,
   // regardless of which account is used of composing (bug 922614).
   be_in_folder(accountNNTP.incomingServer.rootFolder);
   cwc = open_compose_new_mail();
   check_nntp_address_types();
+  check_collapsed_pop_recipient(cwc);
   close_compose_window(cwc);
 
   // Now try the same accounts but choosing them in the From dropdown
   // inside compose window.
   be_in_folder(accountPOP3.incomingServer.rootFolder);
   cwc = open_compose_new_mail();
   check_nntp_address_types();