Bug 1096006 - Migrate the Account Manager from a standalone window to a pane in the Preferences tab. r=aceman,darktrojan; ui-r=Paenglab
authorRichard Marti <richard.marti@gmail.com>, Geoff Lankow <geoff@darktrojan.net>, aceman <acelists@atlas.sk>
Thu, 20 Jun 2019 07:13:39 +0200
changeset 35899 2b61ea9688aab7271c591137e543e999340dbfe9
parent 35898 d2122e452112c2c87573d4a27e670be6076302b0
child 35900 b9e0333084838171ff9adb08398e14842e131244
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersaceman, darktrojan, Paenglab
bugs1096006
Bug 1096006 - Migrate the Account Manager from a standalone window to a pane in the Preferences tab. r=aceman,darktrojan; ui-r=Paenglab
mail/components/accountcreation/content/emailWizard.js
mail/components/accountcreation/content/emailWizard.xul
mail/components/im/content/am-im.xul
mail/components/im/content/imAccounts.js
mail/components/im/content/imAccounts.xul
mail/components/newmailaccount/content/accountProvisioner.js
mail/components/newmailaccount/content/accountProvisioner.xhtml
mail/components/preferences/aboutPreferences.xul
mail/components/preferences/accounts.inc.xul
mail/components/preferences/accounts.js
mail/components/preferences/advanced.inc.xul
mail/components/preferences/doctype.inc.xul
mail/components/preferences/jar.mn
mail/components/preferences/preferences.js
mail/components/preferences/preferencesTab.js
mail/locales/en-US/chrome/messenger/AccountManager.dtd
mail/locales/en-US/chrome/messenger/preferences/preferences.dtd
mail/themes/linux/mail/accountManage.css
mail/themes/linux/mail/preferences/aboutPreferences.css
mail/themes/osx/mail/accountManage.css
mail/themes/osx/mail/preferences/aboutPreferences.css
mail/themes/shared/mail/incontentprefs/aboutPreferences.css
mail/themes/windows/mail/accountManage.css
mail/themes/windows/mail/messenger.css
mailnews/base/prefs/content/AccountManager.js
mailnews/base/prefs/content/AccountManager.xul
mailnews/base/prefs/content/AccountWizard.js
mailnews/base/prefs/content/SmtpServerEdit.xul
mailnews/base/prefs/content/accountUtils.js
mailnews/base/prefs/content/am-addressing.xul
mailnews/base/prefs/content/am-archiveoptions.xul
mailnews/base/prefs/content/am-copies.xul
mailnews/base/prefs/content/am-identities-list.js
mailnews/base/prefs/content/am-identities-list.xul
mailnews/base/prefs/content/am-identity-edit.js
mailnews/base/prefs/content/am-identity-edit.xul
mailnews/base/prefs/content/am-junk.xul
mailnews/base/prefs/content/am-main.js
mailnews/base/prefs/content/am-main.xul
mailnews/base/prefs/content/am-offline.js
mailnews/base/prefs/content/am-offline.xul
mailnews/base/prefs/content/am-server-advanced.xul
mailnews/base/prefs/content/am-server.js
mailnews/base/prefs/content/am-server.xul
mailnews/base/prefs/content/am-serverwithnoidentities.js
mailnews/base/prefs/content/am-serverwithnoidentities.xul
mailnews/base/prefs/content/am-smtp.xul
mailnews/extensions/mdn/content/am-mdn.xul
mailnews/extensions/newsblog/content/am-newsblog.xul
mailnews/extensions/smime/content/am-smime.inc.xul
mailnews/jar.mn
--- a/mail/components/accountcreation/content/emailWizard.js
+++ b/mail/components/accountcreation/content/emailWizard.js
@@ -1549,26 +1549,17 @@ EmailConfigWizard.prototype = {
       alertPrompt(gStringsBundle.getString("error_creating_account"),
                   gStringsBundle.getString("incoming_server_exists"));
       return;
     }
 
     gEmailWizardLogger.info("creating account in backend");
     let newAccount = createAccountInBackend(configFilledIn);
 
-    let existingAccountManager = Services.wm
-        .getMostRecentWindow("mailnews:accountmanager");
-    if (existingAccountManager) {
-      existingAccountManager.focus();
-    } else {
-      window.openDialog("chrome://messenger/content/AccountManager.xul",
-                        "AccountManager", "chrome,centerscreen,modal,titlebar",
-                        { server: newAccount.incomingServer,
-                          selectPage: "am-server.xul" });
-    }
+    MsgAccountManager("am-server.xul", newAccount.incomingServer);
     window.close();
   },
 
   /**
    * [Re-test] button click handler.
    * Restarts the config guessing process after a person editing the server
    * fields.
    * It's called "half-manual", because we take the user-entered values
--- a/mail/components/accountcreation/content/emailWizard.xul
+++ b/mail/components/accountcreation/content/emailWizard.xul
@@ -40,17 +40,18 @@
   <script src="chrome://messenger/content/accountcreation/fetchhttp.js"/>
   <script src="chrome://messenger/content/accountcreation/readFromXML.js"/>
   <script src="chrome://messenger/content/accountcreation/guessConfig.js"/>
   <script src="chrome://messenger/content/accountcreation/verifyConfig.js"/>
   <script src="chrome://messenger/content/accountcreation/fetchConfig.js"/>
   <script src="chrome://messenger/content/accountcreation/exchangeAutoDiscover.js"/>
   <script src="chrome://messenger/content/accountcreation/createInBackend.js"/>
   <script src="chrome://messenger/content/accountcreation/MyBadCertHandler.js"/>
-  <script src="chrome://messenger/content/accountUtils.js" />
+  <script src="chrome://messenger/content/accountUtils.js"/>
+  <script src="chrome://communicator/content/utilityOverlay.js"/>
   <script src="chrome://messenger/content/customElements.js"/>
 
   <keyset id="mailKeys">
     <key keycode="VK_ESCAPE" oncommand="window.close();"/>
   </keyset>
 
   <panel id="insecureserver-cleartext-panel" class="popup-panel">
     <hbox>
--- a/mail/components/im/content/am-im.xul
+++ b/mail/components/im/content/am-im.xul
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE window [
   <!ENTITY % imDTD SYSTEM "chrome://messenger/locale/am-im.dtd">
   <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
   %imDTD;
   %brandDTD;
 ]>
--- a/mail/components/im/content/imAccounts.js
+++ b/mail/components/im/content/imAccounts.js
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // mail/base/content/nsDragAndDrop.js
 /* globals FlavourSet, TransferData, MozElements */
 // imStatusSelector.js
 /* globals statusSelector */
+// mailnews/base/prefs/content/accountUtils.js
+/* globals MsgAccountManager */
 
 var {Services} = ChromeUtils.import("resource:///modules/imServices.jsm");
 var {fixIterator} = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 var {DownloadUtils} = ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm");
 
 // This is the list of notifications that the account manager window observes
@@ -305,26 +307,17 @@ var gAccountManager = {
       if (!incomingServer || incomingServer.type != "im")
         continue;
       if (incomingServer.wrappedJSObject.imAccount.numericId == imAccountId) {
         server = incomingServer;
         break;
       }
     }
 
-    let win = Services.wm.getMostRecentWindow("mailnews:accountmanager");
-    if (win) {
-      win.focus();
-      win.selectServer(server);
-    } else {
-      window.openDialog("chrome://messenger/content/AccountManager.xul",
-                        "AccountManager",
-                        "chrome,centerscreen,modal,titlebar,resizable",
-                        { server, selectPage: null });
-    }
+    MsgAccountManager(null, server);
   },
   autologin() {
     var elt = this.accountList.selectedItem;
     elt.autoLogin = !elt.autoLogin;
   },
   close() {
     // If a modal dialog is opened, we can't close this window now
     if (this.modalDialog)
--- a/mail/components/im/content/imAccounts.xul
+++ b/mail/components/im/content/imAccounts.xul
@@ -22,16 +22,18 @@
         xmlns:html="http://www.w3.org/1999/xhtml"
         id="accountManager"
         windowtype="Messenger:Accounts"
         title="&accountsWindow.title;"
         style="&accountsWindow2.style;"
         persist="width height screenX screenY">
  <script src="chrome://messenger/content/chat/imAccounts.js"/>
  <script src="chrome://messenger/content/chat/imStatusSelector.js"/>
+ <script src="chrome://messenger/content/accountUtils.js"/>
+ <script src="chrome://communicator/content/utilityOverlay.js"/>
  <script src="chrome://global/content/nsDragAndDrop.js" />
  <script src="chrome://global/content/nsTransferable.js" />
  <script src="chrome://chat/content/chat-account-richlistitem.js" />
  <stringbundle id="accountsBundle" src="chrome://messenger/locale/imAccounts.properties"/>
 
  <linkset>
    <html:link rel="localization" href="security/certificates/certManager.ftl"/>
  </linkset>
--- a/mail/components/newmailaccount/content/accountProvisioner.js
+++ b/mail/components/newmailaccount/content/accountProvisioner.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+// mailnews/base/prefs/content/accountUtils.js
+/* globals MsgAccountManager */
+
 var {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 var {PluralForm} = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 var {StringBundle} = ChromeUtils.import("resource:///modules/StringBundle.js");
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 var { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js");
 
@@ -187,25 +190,17 @@ var EmailAccountProvisioner = {
                                              account.defaultIdentity, null);
     });
 
     document.getElementById("success-addons").addEventListener("click", function() {
       EmailAccountProvisioner.openAddonsMgr();
     });
 
     document.getElementById("success-signature").addEventListener("click", function() {
-      var existingAccountManager =
-        Services.wm.getMostRecentWindow("mailnews:accountmanager");
-
-      if (existingAccountManager)
-        existingAccountManager.focus();
-      else
-        window.openDialog("chrome://messenger/content/AccountManager.xul",
-                          "AccountManager", "chrome,centerscreen,modal,titlebar",
-                          {server: account.incomingServer});
+      MsgAccountManager(null, account.incomingServer);
     });
 
     document.getElementById("window").style.display = "none";
     document.getElementById("successful_account").style.display = "block";
   },
 
   /**
    * Save the name inputted in the search field to localstorage, so we can
--- a/mail/components/newmailaccount/content/accountProvisioner.xhtml
+++ b/mail/components/newmailaccount/content/accountProvisioner.xhtml
@@ -17,30 +17,24 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
   <title>&window.title;</title>
 
   <link rel="stylesheet"
         type="text/css"
         href="chrome://messenger/skin/newmailaccount/accountProvisioner.css" />
 
-  <script src="chrome://messenger/content/accountcreation/util.js">
-  </script>
-  <script src="chrome://messenger/content/accountcreation/accountConfig.js">
-  </script>
-  <script src="chrome://messenger/content/accountcreation/sanitizeDatatypes.js">
-  </script>
-  <script src="chrome://messenger/content/accountcreation/readFromXML.js">
-  </script>
-  <script src="chrome://messenger/content/accountcreation/createInBackend.js">
-  </script>
-  <script src="chrome://communicator/content/utilityOverlay.js">
-  </script>
-  <script src="chrome://messenger/content/newmailaccount/accountProvisioner.js">
-  </script>
+  <script src="chrome://messenger/content/accountcreation/util.js"/>
+  <script src="chrome://messenger/content/accountcreation/accountConfig.js"/>
+  <script src="chrome://messenger/content/accountcreation/sanitizeDatatypes.js"/>
+  <script src="chrome://messenger/content/accountcreation/readFromXML.js"/>
+  <script src="chrome://messenger/content/accountcreation/createInBackend.js"/>
+  <script src="chrome://communicator/content/utilityOverlay.js"/>
+  <script src="chrome://messenger/content/accountUtils.js"/>
+  <script src="chrome://messenger/content/newmailaccount/accountProvisioner.js"/>
 </head>
 <body dir="&locale.dir;">
   <div id="window" class="vbox">
 
     <div id="content" class="boxFlex vbox">
 
       <div id="upper" class="contentPadded">
         <div class="header">
--- a/mail/components/preferences/aboutPreferences.xul
+++ b/mail/components/preferences/aboutPreferences.xul
@@ -1,19 +1,19 @@
 <?xml version="1.0"?>
 # -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-<?xml-stylesheet href="chrome://global/skin/global.css"?>
 <?xml-stylesheet href="chrome://messenger/content/messenger.css"?>
 <?xml-stylesheet href="chrome://messenger/content/preferences/handlers.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/filefield.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/applications.css"?>
+<?xml-stylesheet href="chrome://messenger/skin/accountManage.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://global/skin/in-content/common.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/aboutPreferences.css"?>
 
 #include doctype.inc.xul
 
 <preftab id="MailPreferences" flex="1"
          windowtype="Mail:Preferences"
@@ -67,16 +67,17 @@
 #include display.inc.xul
 #include compose.inc.xul
 #include chat.inc.xul
 #include privacy.inc.xul
 #include security.inc.xul
 #include applications.inc.xul
             <prefpane id="paneLightning" label="&paneLightning.title;"/>
 #include advanced.inc.xul
+#include accounts.inc.xul
           </hbox>
         </hbox>
       </hbox>
     </hbox>
     <stack id="dialogStack" hidden="true"/>
     <vbox id="dialogTemplate"
           class="dialogOverlay"
           align="center"
new file mode 100644
--- /dev/null
+++ b/mail/components/preferences/accounts.inc.xul
@@ -0,0 +1,68 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+  <prefpane id="paneAccount" label="&paneAccount.title;">
+    <script src="chrome://messenger/content/AccountManager.js"/>
+    <script src="chrome://messenger/content/am-prefs.js"/>
+    <script src="chrome://messenger/content/accountUtils.js"/>
+    <script src="chrome://messenger/content/amUtils.js"/>
+    <script src="chrome://messenger/content/preferences/accounts.js"/>
+
+    <stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
+    <stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"/>
+
+    <hbox flex="1" id="accountManager">
+      <vbox flex="1">
+        <tree flex="1" onselect="onAccountTreeSelect(null, null);" id="accounttree"
+              seltype="single" hidecolumnpicker="true">
+          <treecols>
+            <treecol id="AccountCol" flex="1" primary="true" hideheader="true"/>
+          </treecols>
+          <treechildren id="account-tree-children"/>
+        </tree>
+
+        <button id="accountActionsButton" type="menu"
+                label="&accountActionsButton.label;"
+                accesskey="&accountActionsButton.accesskey;">
+          <menupopup id="accountActionsDropdown"
+                     onpopupshowing="initAccountActionsButtons(this);">
+            <menuitem id="accountActionsAddMailAccount"
+                      label="&addMailAccountButton.label;"
+                      accesskey="&addMailAccountButton.accesskey;"
+                      prefstring="mail.disable_new_account_addition"
+                      oncommand="AddMailAccount(event); event.stopPropagation();"/>
+            <menuitem id="accountActionsAddIMAccount"
+                      label="&addIMAccountButton.label;"
+                      accesskey="&addIMAccountButton.accesskey;"
+                      prefstring="mail.disable_new_account_addition"
+                      oncommand="AddIMAccount(event); event.stopPropagation();"/>
+            <menuitem id="accountActionsAddFeedAccount"
+                      label="&addFeedAccountButton.label;"
+                      accesskey="&addFeedAccountButton.accesskey;"
+                      prefstring="mail.disable_new_account_addition"
+                      oncommand="AddFeedAccount(event); event.stopPropagation();"/>
+            <menuitem id="accountActionsAddOtherAccount"
+                      label="&addOtherAccountButton.label;"
+                      accesskey="&addOtherAccountButton.accesskey;"
+                      prefstring="mail.disable_new_account_addition"
+                      oncommand="onAddAccount(event); event.stopPropagation();"/>
+            <menuseparator id="accountActionsDropdownSep1"/>
+            <menuitem id="accountActionsDropdownSetDefault"
+                      label="&setDefaultButton.label;"
+                      accesskey="&setDefaultButton.accesskey;"
+                      prefstring="mail.disable_button.set_default_account"
+                      oncommand="onSetDefault(event); event.stopPropagation();"/>
+            <menuitem id="accountActionsDropdownRemove"
+                      label="&removeButton.label;"
+                      accesskey="&removeButton.accesskey;"
+                      prefstring="mail.disable_button.delete_account"
+                      oncommand="onRemoveAccount(event); event.stopPropagation();"/>
+          </menupopup>
+        </button>
+      </vbox>
+      <vbox flex="5">
+        <iframe id="contentFrame" name="contentFrame" flex="1"/>
+      </vbox>
+    </hbox>
+  </prefpane>
new file mode 100644
--- /dev/null
+++ b/mail/components/preferences/accounts.js
@@ -0,0 +1,30 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+/* import-globals-from ../../../mailnews/base/prefs/content/AccountManager.js */
+
+var gAccountsPane = {
+  paneSelectionChanged(event) {
+    if (event.detail.newPane == "paneAccount") {
+      if (!document.getElementById("account-tree-children").hasChildNodes()) {
+        // Only load the account tree when the pane is first shown.
+        onLoad();
+      }
+    }
+    if (event.detail.oldPane == "paneAccount") {
+      onAccept(false);
+    }
+  },
+
+  unload() {
+    onAccept(false);
+    onUnload();
+  },
+};
+
+window.addEventListener("paneSelected", gAccountsPane.paneSelectionChanged);
+window.addEventListener("unload", () => gAccountsPane.unload());
--- a/mail/components/preferences/advanced.inc.xul
+++ b/mail/components/preferences/advanced.inc.xul
@@ -449,10 +449,9 @@
                     label="&viewSecurityDevices.label;"
                     accesskey="&viewSecurityDevices.accesskey;"
                     oncommand="gAdvancedPane.showSecurityDevices();"
                     preference="security.disable_button.openDeviceManager"/>
           </hbox>
         </tabpanel>
       </tabpanels>
     </tabbox>
-    <separator/>
   </prefpane>
--- a/mail/components/preferences/doctype.inc.xul
+++ b/mail/components/preferences/doctype.inc.xul
@@ -36,9 +36,11 @@
 <!ENTITY % searchIntegrationDefaultDTD SYSTEM "chrome://messenger/locale/searchIntegrationDefault.dtd" >
 %searchIntegrationDefaultDTD;
 #endif
 #endif
 #ifdef MOZ_UPDATER
 <!ENTITY % aboutDialogDTD SYSTEM "chrome://messenger/locale/aboutDialog.dtd" >
 %aboutDialogDTD;
 #endif
+<!ENTITY % accountDTD SYSTEM "chrome://messenger/locale/AccountManager.dtd">
+%accountDTD;
 ]>
--- a/mail/components/preferences/jar.mn
+++ b/mail/components/preferences/jar.mn
@@ -6,16 +6,17 @@ messenger.jar:
 *   content/messenger/preferences/aboutPreferences.xul
     content/messenger/preferences/preferences.js
     content/messenger/preferences/preferencesTab.js
     content/messenger/preferences/general.js
 #ifdef XP_MACOSX
     content/messenger/preferences/dockoptions.js
     content/messenger/preferences/dockoptions.xul
 #endif
+    content/messenger/preferences/accounts.js
     content/messenger/preferences/display.js
     content/messenger/preferences/chat.js
     content/messenger/preferences/messagestyle.js
     content/messenger/preferences/messengerLanguages.js
     content/messenger/preferences/messengerLanguages.xul
     content/messenger/preferences/colors.js
 *   content/messenger/preferences/colors.xul
     content/messenger/preferences/compose.js
--- a/mail/components/preferences/preferences.js
+++ b/mail/components/preferences/preferences.js
@@ -87,17 +87,21 @@ function showPane(paneID) {
     if (currentlySelected == pane) {
       return;
     }
     currentlySelected.removeAttribute("selected");
   }
 
   selector.value = paneID;
   pane.setAttribute("selected", "true");
-  pane.dispatchEvent(new CustomEvent("paneSelected", { bubbles: true }));
+  pane.dispatchEvent(new CustomEvent("paneSelected",
+    { bubbles: true,
+      detail: { oldPane: (currentlySelected ? currentlySelected.id : null),
+                newPane: paneID },
+    }));
 
   document.documentElement.setAttribute("lastSelected", paneID);
   Services.xulStore.persist(document.documentElement, "lastSelected");
 }
 
 /**
  * Selects the specified preferences pane
  *
@@ -117,25 +121,36 @@ function selectPaneAndTab(prefWindow, pa
     }
   }
 }
 
 /**
  * Select the specified tab
  *
  * @param pane         prefpane to operate on
- * @param tabID        ID of tab to select on the prefpane
+ * @param tabID        ID of tab to select on the prefpane (or server for AM)
  * @param subdialogID  ID of button to activate, opening a subdialog
  */
 function showTab(pane, tabID, subdialogID) {
-  pane.querySelector("tabbox").selectedTab = document.getElementById(tabID);
-  if (subdialogID) {
-    setTimeout(function() {
-      document.getElementById(subdialogID).click();
-    });
+  if (pane.id != "paneAccount") {
+    pane.querySelector("tabbox").selectedTab = document.getElementById(tabID);
+    if (subdialogID) {
+      setTimeout(function() {
+        document.getElementById(subdialogID).click();
+      });
+    }
+  } else {
+    // For the accounts pane, tabID is the server key, subdialogID is the settings pane.
+    let accountTree = document.getElementById("account-tree-children");
+    if (!accountTree.hasAttribute("tree-loaded")) {
+      accountTree.addEventListener("account-tree-loaded",
+        () => window.selectServerByKey(tabID, subdialogID), {once: true});
+    } else {
+      window.selectServerByKey(tabID, subdialogID);
+    }
   }
 }
 
 /**
  * Get the ID of the current pane.
  */
 function getCurrentPaneID() {
   let currentlySelected = paneDeck.querySelector("#paneDeck > prefpane[selected]");
--- a/mail/components/preferences/preferencesTab.js
+++ b/mail/components/preferences/preferencesTab.js
@@ -124,20 +124,28 @@ var preferencesTabType = {
     gPrefTab = aTab;
     this.lastBrowserId++;
   },
 
   persistTab(aTab) {
     if (aTab.browser.currentURI.spec == "about:blank")
       return null;
 
+    let currentPane = aTab.browser.contentWindow.getCurrentPaneID();
+    let tabId;
+    if (currentPane == "paneAccount") {
+      let account = aTab.browser.contentWindow.getCurrentAccount();
+      tabId = (account ? account.incomingServer.key : null);
+    } else {
+      tabId = aTab.tabID;
+    }
     return {
       tabURI: aTab.url,
-      paneID: aTab.paneID,
-      tabID: aTab.tabID,
+      paneID: currentPane,
+      tabID: tabId,
       otherArgs: aTab.otherArgs,
     };
   },
 
   restoreTab(aTabmail, aPersistedState) {
     aTabmail.openTab("preferencesTab", {
       contentPage: aPersistedState.tabURI,
       paneID: aPersistedState.paneID,
--- a/mail/locales/en-US/chrome/messenger/AccountManager.dtd
+++ b/mail/locales/en-US/chrome/messenger/AccountManager.dtd
@@ -15,20 +15,8 @@
 <!ENTITY addFeedAccountButton.label "Add Feed Account…">
 <!ENTITY addFeedAccountButton.accesskey "F">
 <!ENTITY addOtherAccountButton.label "Add Other Account…">
 <!ENTITY addOtherAccountButton.accesskey "O">
 <!ENTITY setDefaultButton.label "Set as Default">
 <!ENTITY setDefaultButton.accesskey "D">
 <!ENTITY removeButton.label "Remove Account">
 <!ENTITY removeButton.accesskey "R">
-
-<!-- AccountManager.xul -->
-<!-- LOCALIZATION NOTE : this is part of an inline-style attribute on the account
-     setting dialog, which specifies the width and height in em units of the dialog.
-     Localizers ONLY can increase these widths if they are having difficulty getting
-     panel content to fit.
-     1ch = The width of the "0" (ZERO, U+0030) glyph for the current font.
-     1em = The height of the font.
-     XUL/FE DEVELOPERS: DO NOT MODIFY THIS VALUE. It represents the correct size of
-     this window for en-US. -->
-<!ENTITY accountManager.size "width: 105ch; height: 55em;">
-<!ENTITY accountTree.width "width: 32ch;">
--- a/mail/locales/en-US/chrome/messenger/preferences/preferences.dtd
+++ b/mail/locales/en-US/chrome/messenger/preferences/preferences.dtd
@@ -19,11 +19,8 @@
 <!ENTITY paneAttachments.title    "Attachments">
 <!ENTITY panePrivacy.title        "Privacy">
 <!ENTITY paneSecurity.title       "Security">
 <!ENTITY paneLightning.title      "Calendar">
 <!ENTITY paneAdvanced.title       "Advanced">
 <!ENTITY paneAccount.title        "Accounts">
 
 <!ENTITY addonsButton.label       "Extensions &amp; Themes">
-
-<!ENTITY okButton.title           "OK">
-<!ENTITY okButton.accesskey       "O">
--- a/mail/themes/linux/mail/accountManage.css
+++ b/mail/themes/linux/mail/accountManage.css
@@ -2,20 +2,31 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* ===== accountManage.css ==============================================
   == Styles for the Mail Account Manager.
   ======================================================================= */
 
 @import url("chrome://messenger/skin/");
-@import url("chrome://messenger/content/bindings.css");
+@import url("chrome://global/skin/in-content/common.css");
+@import url("chrome://messenger/skin/preferences/aboutPreferences.css");
 
 @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
 
+page {
+  font-size: 0.95em;
+  margin-inline-start: 4px;
+}
+
+page groupbox {
+  margin-left: 6px;
+  margin-right: 6px;
+}
+
 /* ::::: account manager :::::: */
 
 .specialFolderPickerGrid {
   margin-inline-start: 20px;
 }
 
 .fccReplyFollowsParent {
   margin-inline-start: 20px;
@@ -42,53 +53,54 @@ treechildren::-moz-tree-image(folderName
 treechildren::-moz-tree-image(folderNameCol, isServer-true, serverType-im) {
   list-style-image: url("chrome://chat/skin/prpl-generic/icon.png");
 }
 
 #accounttree treechildren::-moz-tree-indentation {
   width: 1ch;
 }
 
+#accountActionsButton {
+  margin-left: 0;
+  margin-right: 0;
+}
+
 #accountActionsDropdown {
   min-width: 30ch;
 }
 
 /* ::::: SMTP Server Panel :::::: */
 
-.smtpServerListItem {
-  padding-inline-start: 3px;
+#smtpList {
+  margin-inline-start: 6px;
 }
 
 #backgroundBox {
-  background-color: #FFFFFF;
-  opacity: 0.5;
+  background-color: var(--in-content-box-background);
 }
 
 #smtpServerInfoBox {
-  border: 1px solid ThreeDShadow;
-  border-right-color: ThreeDHighlight;
-  border-bottom-color: ThreeDHighlight;
-  margin: 0 5px 5px;
+  background-color: var(--in-content-box-background);
+  margin: 0 6px 5px;
+}
+
+#smtpServerInfoBox label {
+  height: 30px;
+  padding-top: 5px;
+  margin-top: 0;
+  margin-bottom: 0;
 }
 
 #smtpServerInfoBox textbox {
-  background-color: transparent;
-}
-
-#archiveTree > treechildren {
-  background-color: -moz-Field;
+  background-color: transparent !important;
 }
 
 /* ::::: dialog header ::::: */
 
-.dialogheader {
-  margin: 0 5px 5px;
-  border: 1px solid ThreeDDarkShadow;
-  padding: 5px 8px;
-  background-color: Highlight;
-  color: HighlightText;
+.dialogheader-title {
+  margin-top: 0;
+  margin-bottom: 8px;
+  margin-inline-start: 6px;
+  font-size: 1.46em;
+  font-weight: 300;
+  line-height: 1.3em;
+  color: var(--in-content-text-color);
 }
-
-.dialogheader-title {
-  margin: 0 !important;
-  font-size: larger;
-  font-weight: bold;
-}
--- a/mail/themes/linux/mail/preferences/aboutPreferences.css
+++ b/mail/themes/linux/mail/preferences/aboutPreferences.css
@@ -24,16 +24,23 @@ radio[pane] > .radio-label-box {
   margin-inline-end: 8px;
 }
 
 menulist.actionsMenu > .menulist-dropmarker {
   margin-top: 11px;
   margin-bottom: 11px;
 }
 
+button[type="menu"] > .button-box > .button-menu-dropmarker {
+  margin-inline-end: 4px;
+  list-style-image: url("chrome://global/skin/icons/arrow-dropdown-12.svg");
+  -moz-context-properties: fill;
+  fill: currentColor;
+}
+
 textbox[type="number"] {
   -moz-appearance: none;
   border: 1px solid var(--in-content-box-border-color);
   background-color: var(--in-content-box-background);
 }
 
 html|input[type="number"]::-moz-number-spin-up {
   min-height: 10px;
--- a/mail/themes/osx/mail/accountManage.css
+++ b/mail/themes/osx/mail/accountManage.css
@@ -2,20 +2,31 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* ===== accountManage.css ==============================================
   == Styles for the Mail Account Manager.
   ======================================================================= */
 
 @import url("chrome://messenger/skin/");
-@import url("chrome://messenger/content/bindings.css");
+@import url("chrome://global/skin/in-content/common.css");
+@import url("chrome://messenger/skin/preferences/aboutPreferences.css");
 
 @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
 
+page {
+  font-size: 0.95em;
+  margin-inline-start: 4px;
+}
+
+page groupbox {
+  margin-left: 6px;
+  margin-right: 6px;
+}
+
 /* ::::: account manager :::::: */
 
 .specialFolderPickerGrid {
   margin-inline-start: 20px;
 }
 
 .fccReplyFollowsParent {
   margin-inline-start: 20px;
@@ -28,18 +39,19 @@
 #am-main-title, .dialogheader {
   display: none;
 }
 
 .dialog-button[dlgtype="help"] {
   display: none;
 }
 
-#accounttree {
-  margin-inline-end: 8px;
+#accountActionsButton {
+  margin-left: 0;
+  margin-right: 0;
 }
 
 #accountActionsDropdown {
   min-width: 30ch;
 }
 
 listitem[default="true"],
 #identitiesList > listitem:first-child,
@@ -72,40 +84,43 @@ treechildren::-moz-tree-image(folderName
     list-style-image: url("chrome://chat/skin/prpl-generic/icon32.png");
   }
 }
 
 #accounttree treechildren::-moz-tree-indentation {
   width: 1ch;
 }
 
-button:not(.dialog-button) {
-  min-height: 19px; /* aqua size for small buttons */
-}
-
 description {
   margin: 4px 4px 8px;
 }
 
-#archiveTree > treechildren {
-  background-color: #FFFFFF;
+#smtpList {
+  margin-inline-start: 6px;
+}
+
+#backgroundBox {
+  background-color: var(--in-content-box-background);
 }
 
 #smtpServerInfoBox {
-  border: 1px solid ThreeDShadow;
-  border-right-color: ThreeDHighlight;
-  border-bottom-color: ThreeDHighlight;
-  margin: 0 5px 5px;
+  background-color: var(--in-content-box-background);
+  margin: 0 6px 5px;
+}
+
+#smtpServerInfoBox label {
+  height: 30px;
+  padding-top: 5px;
+  margin-top: 0;
+  margin-bottom: 0;
 }
 
 /* ::::: dialog header ::::: */
 
-.dialogheader {
-  margin: 0 5px 5px;
-  padding: 5px 8px;
+.dialogheader-title {
+  margin-top: 0;
+  margin-bottom: 8px;
+  margin-inline-start: 6px;
+  font-size: 1.46em;
+  font-weight: 300;
+  line-height: 1.3em;
+  color: var(--in-content-text-color);
 }
-
-.dialogheader-title {
-  margin: 0 !important;
-  font-size: larger;
-  font-weight: bold;
-  display: none;
-}
--- a/mail/themes/osx/mail/preferences/aboutPreferences.css
+++ b/mail/themes/osx/mail/preferences/aboutPreferences.css
@@ -60,16 +60,26 @@ radio[pane][selected] {
 }
 
 .actionsMenu > .menulist-label-box > .menulist-icon {
   margin-top: 2px;
   margin-inline-start: 2px;
   margin-inline-end: 8px !important;
 }
 
+button[type="menu"] > .button-box > .button-menu-dropmarker {
+  -moz-appearance: none;
+  display: -moz-box;
+  list-style-image: url("chrome://global/skin/icons/arrow-dropdown-12.svg");
+  -moz-context-properties: fill;
+  fill: currentColor;
+  width: 12px;
+  height: 12px;
+}
+
 .sidebar-footer-label {
   font-size: 1.224em;
 }
 
 tab:-moz-focusring > .tab-middle > .tab-text {
   outline: none;
 }
 
--- a/mail/themes/shared/mail/incontentprefs/aboutPreferences.css
+++ b/mail/themes/shared/mail/incontentprefs/aboutPreferences.css
@@ -1,12 +1,13 @@
 /* - This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this file,
    - You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+@import url("chrome://messenger/skin/folderPane.css");
 @namespace html "http://www.w3.org/1999/xhtml";
 
 :root {
   --in-content-categories-background: #ebebef;
   --in-content-dialogtitle-background: #f1f1f1;
   --in-content-dialogtitle-border: #c1c1c1;
   --in-content-warning-container: var(--grey-20);
 }
@@ -44,32 +45,42 @@ html|h2 {
 }
 
 html|h3 {
   font-size: 1em;
   font-weight: 600;
   margin: 4px 0 !important;
 }
 
+.header {
+  margin-bottom: 0;
+}
+
 #preferencesContainer {
   padding: 40px 28px;
   overflow: auto;
 }
 
 #MailPreferences prefpane {
   max-width: 800px;
   padding: 0;
   -moz-box-flex: 1;
   -moz-box-orient: vertical;
 }
 
 #MailPreferences prefpane:not([selected]) {
   display: none;
 }
 
+groupbox {
+  -moz-appearance: none;
+  margin: initial;
+  padding: initial;
+}
+
 tabpanel > label,
 tabpanel > description,
 tabpanel > hbox > description {
   margin-inline-start: 0;
 }
 
 textbox[type="number"][size="1"] {
   width: 4em;
@@ -317,16 +328,59 @@ separator.groove:not([orient="vertical"]
 tab:-moz-focusring {
   outline: var(--in-content-category-outline-focus);
 }
 
 tab:-moz-focusring > .tab-middle {
   outline: none;
 }
 
+/* Styles for the Account Actions button */
+button[type="menu"] > menupopup {
+  -moz-appearance: none;
+  border: 1px solid var(--in-content-box-border-color);
+  border-radius: 2px;
+  background-color: var(--in-content-box-background);
+}
+
+button[type="menu"] > menupopup menuitem {
+  -moz-appearance: none;
+  font-size: 1em;
+  color: var(--in-content-text-color);
+  padding-top: 0.2em;
+  padding-bottom: 0.2em;
+  padding-inline-start: 10px;
+  padding-inline-end: 30px;
+}
+
+button[type="menu"] > menupopup > menuitem:not([disabled="true"])[_moz-menuactive="true"] {
+  color: var(--in-content-text-color);
+  background-color: var(--in-content-item-hover);
+}
+
+button[type="menu"] > menupopup > menuitem:not([disabled="true"])[selected="true"] {
+  color: var(--in-content-selected-text);
+  background-color: var(--in-content-item-selected);
+}
+
+button[type="menu"] > menupopup > menuitem[disabled="true"] {
+  color: #999;
+  /* override the [_moz-menuactive="true"] background color from
+     global/menu.css */
+  background-color: transparent;
+}
+
+button[type="menu"] > menupopup menuseparator {
+  -moz-appearance: none;
+  margin: 0;
+  padding: 0;
+  border-top: 1px solid var(--in-content-box-border-color);
+  border-bottom: none;
+}
+
 #defaultWebSearchPopup > menuitem > .menu-iconic-left {
   display: -moz-box;
 }
 
 /* Applications Pane Styles */
 
 #applications-content {
   padding: 15px;
@@ -520,17 +574,17 @@ richlistbox richlistitem {
   background-image: none;
 }
 
 richlistbox richlistitem:hover {
   background-color: var(--in-content-item-hover);
 }
 
 richlistbox:focus > richlistitem[selected="true"] {
-  background-color: var(--in-content-item-selected);
+  background-color: var(--in-content-item-selected) !important;
   color: var(--in-content-selected-text) !important;
 }
 
 #messengerLanguagesDialogPane {
   min-height: 360px;
 }
 
 #defaultMessengerLanguage {
@@ -560,16 +614,29 @@ richlistbox:focus > richlistitem[selecte
   margin-inline-start: 4px;
 }
 
 .action-button {
   margin-inline-end: 0;
 }
 
 /* Menulist styles */
+
+menulist menupopup[type="folder"] {
+  -moz-appearance: none;
+  border: 1px solid var(--in-content-box-border-color);
+  border-radius: 2px;
+  background-color: var(--in-content-box-background);
+}
+
+menupopup[type="folder"] > .folderMenuItem[_moz-menuactive="true"] {
+  color: var(--in-content-text-color);
+  background-color: var(--in-content-item-hover);
+}
+
 .label-item {
   font-size: .8em;
 }
 
 /**
  * Dialog
  */
 
--- a/mail/themes/windows/mail/accountManage.css
+++ b/mail/themes/windows/mail/accountManage.css
@@ -2,20 +2,31 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* ===== accountManage.css ==============================================
   == Styles for the Mail Account Manager.
   ======================================================================= */
 
 @import url("chrome://messenger/skin/");
-@import url("chrome://messenger/content/bindings.css");
+@import url("chrome://global/skin/in-content/common.css");
+@import url("chrome://messenger/skin/preferences/aboutPreferences.css");
 
 @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
 
+page {
+  font-size: 0.95em;
+  margin-inline-start: 4px;
+}
+
+page groupbox {
+  margin-left: 6px;
+  margin-right: 6px;
+}
+
 /* ::::: account manager :::::: */
 
 .specialFolderPickerGrid {
   margin-inline-start: 20px;
 }
 
 .fccReplyFollowsParent {
   margin-inline-start: 20px;
@@ -42,53 +53,54 @@ treechildren::-moz-tree-image(folderName
 treechildren::-moz-tree-image(folderNameCol, isServer-true, serverType-im) {
   list-style-image: url("chrome://chat/skin/prpl-generic/icon.png");
 }
 
 #accounttree treechildren::-moz-tree-indentation {
   width: 1ch;
 }
 
+#accountActionsButton {
+  margin-left: 0;
+  margin-right: 0;
+}
+
 #accountActionsDropdown {
   min-width: 30ch;
 }
 
 /* ::::: SMTP Server Panel :::::: */
 
-.smtpServerListItem {
-  padding-inline-start: 3px;
+#smtpList {
+  margin-inline-start: 6px;
 }
 
 #backgroundBox {
-  background-color: #FFFFFF;
-  opacity: 0.5;
+  background-color: var(--in-content-box-background);
 }
 
 #smtpServerInfoBox {
-  border: 1px solid ThreeDShadow;
-  border-right-color: ThreeDHighlight;
-  border-bottom-color: ThreeDHighlight;
-  margin: 0 5px 5px;
+  background-color: var(--in-content-box-background);
+  margin: 0 6px 5px;
+}
+
+#smtpServerInfoBox label {
+  height: 30px;
+  padding-top: 5px;
+  margin-top: 0;
+  margin-bottom: 0;
 }
 
 #smtpServerInfoBox textbox {
   background-color: transparent;
 }
 
-#archiveTree > treechildren {
-  background-color: -moz-Field;
-}
-
 /* ::::: dialog header ::::: */
 
-.dialogheader {
-  margin: 0 5px 5px;
-  border: 1px solid ThreeDDarkShadow;
-  padding: 5px 8px;
-  background-color: Highlight;
-  color: HighlightText;
+.dialogheader-title {
+  margin-top: 0;
+  margin-bottom: 8px;
+  margin-inline-start: 6px;
+  font-size: 1.46em;
+  font-weight: 300;
+  line-height: 1.3em;
+  color: var(--in-content-text-color);
 }
-
-.dialogheader-title {
-  margin: 0 !important;
-  font-size: larger;
-  font-weight: bold;
-}
--- a/mail/themes/windows/mail/messenger.css
+++ b/mail/themes/windows/mail/messenger.css
@@ -899,18 +899,16 @@ findbar {
   border-top-color: var(--chrome-content-separator-color);
   color: var(--toolbar-color);
 }
 
 /* ::::: groupbox ::::: */
 
 groupbox {
   -moz-appearance: groupbox;
-  border: 2px groove ThreeDFace;
-  border-radius: 3px;
   margin: 3px;
   padding: 3px 3px 6px;
 }
 
 caption {
   margin: -5px 6px 6px;
   font-weight: bold;
 }
--- a/mailnews/base/prefs/content/AccountManager.js
+++ b/mailnews/base/prefs/content/AccountManager.js
@@ -32,22 +32,26 @@
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var {BrowserUtils} = ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm");
 var {Gloda} = ChromeUtils.import("resource:///modules/gloda/gloda.js");
 var {fixIterator} = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 var {allAccountsSorted} = ChromeUtils.import("resource:///modules/folderUtils.jsm");
 var {cleanUpHostName, isLegalHostNameOrIP} = ChromeUtils.import("resource:///modules/hostnameUtils.jsm");
 
-document.addEventListener("dialogcancel", onNotAccept);
-document.addEventListener("dialogaccept", (event) => {
-  if (!onAccept(true)) {
-    event.preventDefault();
-  }
-});
+var inContent = !!document.getElementById("paneAccount");
+
+if (!inContent) {
+  document.addEventListener("dialogcancel", onNotAccept);
+  document.addEventListener("dialogaccept", (event) => {
+    if (!onAccept(true)) {
+      event.preventDefault();
+    }
+  });
+}
 
 // If Local directory has changed the app needs to restart. Once this is set
 // a restart will be attempted at each attempt to close the Account manager with OK.
 var gRestartNeeded = false;
 
 // This is a hash-map for every account we've touched in the pane. Each entry
 // has additional maps of attribute-value pairs that we're going to want to save
 // when the user hits OK.
@@ -115,46 +119,79 @@ function updateElementWithKeys(account, 
       if (MailServices.smtp.defaultServer)
         element.serverkey = MailServices.smtp.defaultServer.key;
       break;
     default:
 //      dump("unknown element type! "+type+"\n");
   }
 }
 
+
+
+
 // called when the whole document loads
 // perform initialization here
 function onLoad() {
+  accountArray = {};
+  gGenericAttributeTypes = {};
+
+  gAccountTree.load();
+
+  if (inContent) {
+    setTimeout(() => {
+      // If we are in a preferences tab, we didn't get arguments via "window",
+      // select the default server first.
+      selectServer(null, null);
+      let accountTree = document.getElementById("account-tree-children");
+      accountTree.dispatchEvent(
+        new CustomEvent("account-tree-loaded", { bubbles: true, cancelable: false })
+      );
+      accountTree.setAttribute("tree-loaded", "true");
+    }, 0);
+    return;
+  }
+
   var selectedServer;
   var selectPage = null;
 
   // Arguments can have two properties: (1) "server," the nsIMsgIncomingServer
   // to select initially and (2) "selectPage," the page for that server to that
   // should be selected.
   if ("arguments" in window && window.arguments[0]) {
     selectedServer = window.arguments[0].server;
     selectPage = window.arguments[0].selectPage;
   }
 
-  accountArray = {};
-  gGenericAttributeTypes = {};
-
-  gAccountTree.load();
-
-  setTimeout(selectServer, 0, selectedServer, selectPage);
-
   // Make sure the account manager window fits the screen.
   document.getElementById("accountManager").style.maxHeight =
     (window.screen.availHeight - 30) + "px";
+  setTimeout(selectServer, 0, selectedServer, selectPage);
 }
 
 function onUnload() {
   gAccountTree.unload();
 }
 
+/**
+ * Select a specific account in the account tree.
+ *
+ * @param serverKey     The server key of the account to select.
+ * @param selectPageId  The xul file name of a page to select (a subpanel of the account).
+ */
+function selectServerByKey(serverKey, selectPageId) {
+  let server = MailServices.accounts.getIncomingServer(serverKey);
+  selectServer(server, selectPageId);
+}
+
+/**
+ * Select a specific account in the account tree.
+ *
+ * @param server        The nsIMsgServer of the account to select.
+ * @param selectPageId  The xul file name of a page to select (a subpanel of the account).
+ */
 function selectServer(server, selectPageId) {
   let childrenNode = document.getElementById("account-tree-children");
 
   // Default to showing the first account.
   let accountNode = childrenNode.firstChild;
 
   // Find the tree-node for the account we want to select
   if (server) {
@@ -218,50 +255,42 @@ function replaceWithDefaultSmtpServer(de
                                           "smtpServerKey", null, false);
       if (smtpServerKey == deletedSmtpServerKey)
         setAccountValue(accountValues, "identity", "smtpServerKey", "");
     }
   }
 }
 
 /**
- * Called when OK is clicked on the dialog.
+ * Called when all the changes should be really saved
+ * (e.g. OK was clicked in the dialog, or the Preferences tab closed).
  *
- * @param aDoChecks  If true, execute checks on data, otherwise hope they
- *                   were already done elsewhere and proceed directly to saving
- *                   the data.
+ * @param abortOnFailure  If true, return without saving if data checks didn't pass.
  */
-function onAccept(aDoChecks) {
-  if (aDoChecks) {
-    // Check if user/host have been modified correctly.
-    if (!checkUserServerChanges(true))
-      return false;
-
-    if (!checkAccountNameIsValid())
-      return false;
-  }
-
+function onAccept(abortOnFailure) {
   // Run checks as if the page was being left.
-  if ("onLeave" in top.frames.contentFrame) {
-    if (!top.frames.contentFrame.onLeave()) {
+  if (currentAccount && ("onLeave" in top.frames.contentFrame)) {
+    if (!top.frames.contentFrame.onLeave(!abortOnFailure)) {
       // Prevent closing Account manager if user declined the changes.
-      return false;
+      if (abortOnFailure)
+        return false;
     }
   }
 
-  if (!onSave())
+  if (!onSave() && abortOnFailure)
     return false;
 
   // hack hack - save the prefs file NOW in case we crash
   Services.prefs.savePrefFile(null);
 
   if (gRestartNeeded) {
     gRestartNeeded = !BrowserUtils.restartApplication();
     // returns false so that Account manager is not exited when restart failed
-    return !gRestartNeeded;
+    if (abortOnFailure)
+      return !gRestartNeeded;
   }
 
   return true;
 }
 
 /**
  * Runs when Cancel button is used.
  *
@@ -478,21 +507,20 @@ function checkDirectoryIsUsable(aLocalPa
   }
 
   return true;
 }
 
 /**
  * Check if the user and/or host names have been changed and if so check
  * if the new names already exists for an account or are empty.
- * Also check if the Local Directory path was changed.
  *
- * @param showAlert  show and alert if a problem with the host / user name is found
+ * @param restoreValuesOnFailure  show and alert if a problem with the host / user name is found
  */
-function checkUserServerChanges(showAlert) {
+function checkUserServerChanges(restoreValuesOnFailure) {
   const prefBundle = document.getElementById("bundle_prefs");
   const alertTitle = prefBundle.getString("prefPanel-server");
   var alertText = null;
 
   var accountValues = getValueArrayFor(currentAccount);
   if (!accountValues)
     return true;
 
@@ -501,31 +529,34 @@ function checkUserServerChanges(showAler
   // If this type doesn't exist (just removed) then return.
   if (!("server" in accountValues) || !accountValues.server)
     return true;
 
   // Get the new username, hostname and type from the page.
   var typeElem = getPageFormElement("server.type");
   var hostElem = getPageFormElement("server.realHostName");
   var userElem = getPageFormElement("server.realUsername");
-  if (typeElem && userElem && hostElem) {
+  if (!typeElem || !userElem || !hostElem)
+    return true;
+
   var newType = getFormElementValue(typeElem);
   var oldHost = getAccountValue(currentAccount, accountValues, "server", "realHostName",
                                 null, false);
   var newHost = getFormElementValue(hostElem);
   var oldUser = getAccountValue(currentAccount, accountValues, "server", "realUsername",
                                 null, false);
 
   var newUser = getFormElementValue(userElem);
   var checkUser = true;
   // There is no username needed for e.g. news so reset it.
   if (currentServer && !currentServer.protocolInfo.requiresUsername) {
     oldUser = newUser = "";
     checkUser = false;
   }
+
   alertText = null;
   // If something is changed then check if the new user/host already exists.
   if ((oldUser != newUser) || (oldHost != newHost)) {
     newUser = newUser.trim();
     newHost = cleanUpHostName(newHost);
     if (checkUser && (newUser == "")) {
       alertText = prefBundle.getString("userNameEmpty");
     } else if (!isLegalHostNameOrIP(newHost)) {
@@ -538,107 +569,128 @@ function checkUserServerChanges(showAler
       } else {
         // New hostname passed all checks. We may have cleaned it up so set
         // the new value back into the input element.
         setFormElementValue(hostElem, newHost);
       }
     }
 
     if (alertText) {
-      if (showAlert)
-        Services.prompt.alert(window, alertTitle, alertText);
-      // Restore the old values before return
-      if (checkUser)
-        setFormElementValue(userElem, oldUser);
-      setFormElementValue(hostElem, oldHost);
-      // If no message is shown to the user, silently revert the values
-      // and consider the check a success.
-      return !showAlert;
+      Services.prompt.alert(window, alertTitle, alertText);
+      if (restoreValuesOnFailure) {
+        // Restore the old values before return
+        if (checkUser)
+          setFormElementValue(userElem, oldUser);
+        setFormElementValue(hostElem, oldHost);
+        // If no message is shown to the user, silently revert the values
+        // and consider the check a success.
+      }
+      return false;
     }
 
     // If username is changed remind users to change Your Name and Email Address.
     // If server name is changed and has defined filters then remind users
     // to edit rules.
-    if (showAlert) {
-      let filterList;
-      if (currentServer && checkUser) {
-        filterList = currentServer.getEditableFilterList(null);
-      }
-      let changeText = "";
-      if ((oldHost != newHost) &&
-          (filterList != undefined) && filterList.filterCount)
-        changeText = prefBundle.getString("serverNameChanged");
-      // In the event that oldHost == newHost or oldUser == newUser,
-      // the \n\n will be trimmed off before the message is shown.
-      if (oldUser != newUser)
-        changeText = changeText + "\n\n" + prefBundle.getString("userNameChanged");
+    let filterList;
+    if (currentServer && checkUser) {
+      filterList = currentServer.getEditableFilterList(null);
+    }
+    let changeText = "";
+    if ((oldHost != newHost) &&
+        (filterList != undefined) && filterList.filterCount > 0)
+      changeText = prefBundle.getString("serverNameChanged");
+    // In the event that oldHost == newHost or oldUser == newUser,
+    // the \n\n will be trimmed off before the message is shown.
+    if (oldUser != newUser)
+      changeText = changeText + "\n\n" + prefBundle.getString("userNameChanged");
 
-      if (changeText != "")
-        Services.prompt.alert(window, alertTitle, changeText.trim());
-    }
+    if (changeText != "")
+      Services.prompt.alert(window, alertTitle, changeText.trim());
   }
-  }
+  return true;
+}
+
+/**
+ * Check if the Local Directory path was changed.
+ */
+function checkLocalPathChanges(restoreValuesOnFailure) {
+  var accountValues = getValueArrayFor(currentAccount);
+  if (!accountValues)
+    return true;
 
   // Check the new value of the server.localPath field for validity.
   var pathElem = getPageFormElement("server.localPath");
   if (!pathElem)
     return true;
 
+  const prefBundle = document.getElementById("bundle_prefs");
+  const alertTitle = prefBundle.getString("prefPanel-server");
+
   if (!checkDirectoryIsUsable(getFormElementValue(pathElem))) {
 //          return false; // Temporarily disable this. Just show warning but do not block. See bug 921371.
-          Cu.reportError("Local directory '" +
-            getFormElementValue(pathElem).path + "' of account " +
-            currentAccount.key + " is not safe to use. Consider changing it.");
+    Cu.reportError("Local directory '" +
+        getFormElementValue(pathElem).path + "' of account " +
+        currentAccount.key + " is not safe to use. Consider changing it.");
   }
 
   // Warn if the Local directory path was changed.
   // This can be removed once bug 2654 is fixed.
   let oldLocalDir = getAccountValue(currentAccount, accountValues, "server", "localPath",
                                     null, false); // both return nsIFile
   let newLocalDir = getFormElementValue(pathElem);
   if (oldLocalDir && newLocalDir && (oldLocalDir.path != newLocalDir.path)) {
     let brandName = document.getElementById("bundle_brand").getString("brandShortName");
-    alertText = prefBundle.getFormattedString("localDirectoryChanged", [brandName]);
+    let alertText = prefBundle.getFormattedString("localDirectoryChanged", [brandName]);
 
     let cancel = Services.prompt.confirmEx(window, alertTitle, alertText,
       (Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING) +
       (Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL),
       prefBundle.getString("localDirectoryRestart"), null, null, null, {});
     if (cancel) {
       setFormElementValue(pathElem, oldLocalDir);
-      return false;
+      return true;
     }
     gRestartNeeded = true;
   }
 
   return true;
 }
 
 /**
  * If account name is not valid, alert the user.
  */
-function checkAccountNameIsValid() {
+function checkAccountNameIsValid(restoreValuesOnFailure) {
   if (!currentAccount)
     return true;
 
+  let accountValues = getValueArrayFor(currentAccount);
+  if (!accountValues)
+    return true;
+
   const prefBundle = document.getElementById("bundle_prefs");
   let alertText = null;
 
   let serverNameElem = getPageFormElement("server.prettyName");
   if (serverNameElem) {
     let accountName = getFormElementValue(serverNameElem);
+    let oldName = getAccountValue(currentAccount, accountValues, "server", "prettyName",
+                                  null, false);
 
     if (!accountName)
       alertText = prefBundle.getString("accountNameEmpty");
     else if (accountNameExists(accountName, currentAccount.key))
       alertText = prefBundle.getString("accountNameExists");
 
     if (alertText) {
       const alertTitle = prefBundle.getString("accountWizard");
       Services.prompt.alert(window, alertTitle, alertText);
+      if (restoreValuesOnFailure) {
+        // Restore the old values before return.
+        setFormElementValue(serverNameElem, oldName);
+      }
       return false;
     }
   }
 
   return true;
 }
 
 function onSave() {
@@ -1016,60 +1068,48 @@ function onAccountTreeSelect(pageId, acc
   if (!changeView) {
     if (tree.view.selection.count < 1)
       return false;
 
     let node = tree.view.getItemAtIndex(tree.currentIndex);
     account = ("_account" in node) ? node._account : null;
 
     pageId = node.getAttribute("PageTag");
+    changeView = true;
   }
 
   if (pageId == currentPageId && account == currentAccount)
     return true;
 
-  if (document.getElementById("contentFrame").contentDocument.getElementById("server.localPath")) {
-    // Check if user/host names have been changed or the Local Directory is invalid.
-    if (!checkUserServerChanges(false)) {
-      changeView = true;
-      account = currentAccount;
-      pageId = currentPageId;
-    }
-
-    if (gRestartNeeded)
-      onAccept(false);
-  }
-
-  if (document.getElementById("contentFrame").contentDocument.getElementById("server.prettyName")) {
-    // Check if account name is valid.
-    if (!checkAccountNameIsValid()) {
-      changeView = true;
-      account = currentAccount;
-      pageId = currentPageId;
-    }
-  }
-
   if (currentPageId) {
     // Change focus to the account tree first so that any 'onchange' handlers
     // on elements in the current page have a chance to run before the page
     // is saved and replaced by the new one.
     tree.focus();
   }
 
-  // Provide opportunity to do cleanups or checks when the current page is being left.
-  if ("onLeave" in top.frames.contentFrame)
-    top.frames.contentFrame.onLeave();
+  // Provide opportunity to do cleanups and checks when the current page is being left.
+  if (currentAccount && ("onLeave" in top.frames.contentFrame)) {
+    if (!top.frames.contentFrame.onLeave()) {
+      changeView = false;
+    }
+  }
+
+  if (!changeView) {
+    selectServer(currentAccount.incomingServer, currentPageId);
+    return true;
+  }
 
   // save the previous page
   savePage(currentAccount);
 
-  let changeAccount = (account != currentAccount);
+  if (gRestartNeeded)
+    onAccept(false);
 
-  if (changeView)
-    selectServer(account.incomingServer, pageId);
+  let changeAccount = (account != currentAccount);
 
   if (pageId != currentPageId) {
     // loading a complete different page
 
     // prevent overwriting with bad stuff
     currentAccount = currentPageId = null;
 
     pendingAccount = account;
@@ -1084,20 +1124,20 @@ function onAccountTreeSelect(pageId, acc
     updateButtons(tree, account);
 
   return true;
 }
 
 // page has loaded
 function onPanelLoaded(pageId) {
   if (pageId != pendingPageId) {
-    // if we're reloading the current page, we'll assume the
+    // If we're reloading the current page, we'll assume the
     // page has asked itself to be completely reloaded from
-    // the prefs. to do this, clear out the the old entry in
-    // the account data, and then restore theh page
+    // the prefs. To do this, clear out the the old entry in
+    // the account data, and then restore the page.
     if (pageId == currentPageId) {
       var serverId = currentAccount ?
                      currentAccount.incomingServer.serverURI :
                      "global";
       delete accountArray[serverId];
       restorePage(currentPageId, currentAccount);
     }
   } else {
@@ -1481,16 +1521,17 @@ var gAccountTree = {
                   {string: getString("prefPanel-diskspace"), src: "am-offline.xul"},
                   {string: getString("prefPanel-addressing"), src: "am-addressing.xul"},
                   {string: getString("prefPanel-junk"), src: "am-junk.xul"}];
 
     let accounts = allAccountsSorted(false);
 
     let mainTree = document.getElementById("account-tree-children");
     // Clear off all children...
+    mainTree.removeAttribute("tree-built");
     while (mainTree.hasChildNodes())
       mainTree.lastChild.remove();
 
     for (let account of accounts) {
       let accountName = null;
       let accountKey = account.key;
       let amChrome = "about:blank";
       let panelsToKeep = [];
@@ -1613,10 +1654,17 @@ var gAccountTree = {
     let treerow = document.createXULElement("treerow");
     treeitem.appendChild(treerow);
     let treecell = document.createXULElement("treecell");
     treerow.appendChild(treecell);
     treecell.setAttribute("label", getString("prefPanel-smtp"));
     treeitem.setAttribute("PageTag", "am-smtp.xul");
     treecell.setAttribute("properties",
                           "folderNameCol isServer-true serverType-smtp");
+
+    mainTree.setAttribute("tree-built", "true");
+    // We need to notify the caller that the account tree is built so that
+    // it can now select a specific account if needed.
+    mainTree.dispatchEvent(
+      new CustomEvent("account-tree-built", { bubbles: true, cancelable: false })
+    );
   },
 };
--- a/mailnews/base/prefs/content/AccountManager.xul
+++ b/mailnews/base/prefs/content/AccountManager.xul
@@ -1,93 +1,54 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<!-- This file is only used by Seamonkey.
+     If you make a change relevant to Thunderbird too, update
+     mail/components/preferences/AccountManager.inc.xul. -->
+
 <?xml-stylesheet href="chrome://messenger/skin/folderPane.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://messenger/locale/AccountManager.dtd">
 <dialog id="accountManager"
         windowtype="mailnews:accountmanager"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         title="&accountManagerTitle.label;"
         style="&accountManager.size;"
         persist="width height screenX screenY"
         buttons="accept,cancel"
-        onload="onLoad(event);"
+        onload="onLoad();"
         onunload="onUnload();">
 <stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
 <stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"/>
 <script src="chrome://messenger/content/accountUtils.js"/>
 <script src="chrome://messenger/content/am-prefs.js"/>
 <script src="chrome://messenger/content/AccountManager.js"/>
-#ifdef MOZ_SUITE
 <script src="chrome://messenger/content/am-help.js"/>
-#endif
 <script src="chrome://messenger/content/amUtils.js"/>
 
   <hbox flex="1">
     <vbox style="&accountTree.width;">
       <tree flex="1" onselect="onAccountTreeSelect(null, null);" id="accounttree"
             seltype="single" hidecolumnpicker="true">
         <treecols>
           <treecol id="AccountCol" flex="1" primary="true" hideheader="true"/>
         </treecols>
         <treechildren id="account-tree-children"/>
       </tree>
 
-#ifdef MOZ_THUNDERBIRD
-      <button id="accountActionsButton" type="menu"
-              label="&accountActionsButton.label;"
-              accesskey="&accountActionsButton.accesskey;">
-        <menupopup id="accountActionsDropdown"
-                   onpopupshowing="initAccountActionsButtons(this);">
-          <menuitem id="accountActionsAddMailAccount"
-                    label="&addMailAccountButton.label;"
-                    accesskey="&addMailAccountButton.accesskey;"
-                    prefstring="mail.disable_new_account_addition"
-                    oncommand="AddMailAccount(event); event.stopPropagation();"/>
-          <menuitem id="accountActionsAddIMAccount"
-                    label="&addIMAccountButton.label;"
-                    accesskey="&addIMAccountButton.accesskey;"
-                    prefstring="mail.disable_new_account_addition"
-                    oncommand="AddIMAccount(event); event.stopPropagation();"/>
-          <menuitem id="accountActionsAddFeedAccount"
-                    label="&addFeedAccountButton.label;"
-                    accesskey="&addFeedAccountButton.accesskey;"
-                    prefstring="mail.disable_new_account_addition"
-                    oncommand="AddFeedAccount(event); event.stopPropagation();"/>
-          <menuitem id="accountActionsAddOtherAccount"
-                    label="&addOtherAccountButton.label;"
-                    accesskey="&addOtherAccountButton.accesskey;"
-                    prefstring="mail.disable_new_account_addition"
-                    oncommand="onAddAccount(event); event.stopPropagation();"/>
-          <menuseparator id="accountActionsDropdownSep1"/>
-          <menuitem id="accountActionsDropdownSetDefault"
-                    label="&setDefaultButton.label;"
-                    accesskey="&setDefaultButton.accesskey;"
-                    prefstring="mail.disable_button.set_default_account"
-                    oncommand="onSetDefault(event); event.stopPropagation();"/>
-          <menuitem id="accountActionsDropdownRemove"
-                    label="&removeButton.label;"
-                    accesskey="&removeButton.accesskey;"
-                    prefstring="mail.disable_button.delete_account"
-                    oncommand="onRemoveAccount(event); event.stopPropagation();"/>
-        </menupopup>
-      </button>
-#else
       <button label="&addAccountButton.label;" oncommand="onAddAccount(event);" id="addAccountButton"
               prefstring="mail.disable_new_account_addition"
               accesskey="&addAccountButton.accesskey;"/>
       <button label="&setDefaultButton.label;" oncommand="onSetDefault(event);" disabled="true" id="setDefaultButton"
               prefstring="mail.disable_button.set_default_account"
               accesskey="&setDefaultButton.accesskey;"/>
       <button disabled="true" label="&removeButton.label;" oncommand="onRemoveAccount(event);" id="removeButton"
               prefstring="mail.disable_button.delete_account"
               accesskey="&removeButton.accesskey;"/>
-#endif
     </vbox>
 
     <iframe id="contentFrame" name="contentFrame" flex="1"/>
   </hbox>
 </dialog>
--- a/mailnews/base/prefs/content/AccountWizard.js
+++ b/mailnews/base/prefs/content/AccountWizard.js
@@ -47,18 +47,16 @@ var okCallback = null;
 
    where the accounttype determines which path to take
    (server vs. newsserver)
 */
 
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var contentWindow;
-
 var gPageData;
 
 var nsIMsgIdentity = Ci.nsIMsgIdentity;
 var nsIMsgIncomingServer = Ci.nsIMsgIncomingServer;
 var gPrefsBundle, gMessengerBundle;
 
 // the current nsIMsgAccount
 var gCurrentAccount;
--- a/mailnews/base/prefs/content/SmtpServerEdit.xul
+++ b/mailnews/base/prefs/content/SmtpServerEdit.xul
@@ -1,19 +1,19 @@
 <?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
 
 #ifndef MOZ_SUITE
 <?xml-stylesheet href="chrome://messenger/content/bindings.css" type="text/css"?>
 #endif
 <?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
-
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
+<?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/dialogs.css" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://messenger/locale/smtpEditOverlay.dtd">
 
 <dialog title="&smtpEditTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         onload="onLoad();">
   <stringbundle id="bundle_prefs"
--- a/mailnews/base/prefs/content/accountUtils.js
+++ b/mailnews/base/prefs/content/accountUtils.js
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* import-globals-from AccountManager.js */
 /* globals SelectFolder */// From messageWindow.js or msgMail3PaneWindow.js.
 /* globals MsgGetMessage */// From mailWindowOverlay.js.
+/* globals openPreferencesTab */// From utilityOverlay.js.
 
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var gAnyValidIdentity = false; // If there are no valid identities for any account
 // returns the first account with an invalid server or identity
 
@@ -211,45 +212,52 @@ function AddFeedAccount() {
   window.openDialog("chrome://messenger-newsblog/content/feedAccountWizard.xul",
                     "", "chrome,modal,titlebar,centerscreen");
 }
 
 /**
  * Opens the account settings window on the specified account
  * and page of settings. If the window is already open it is only focused.
  *
- * @param selectPage  The xul file name for the viewing page or
- *                    null for the account main page. Other pages are
- *                    'am-server.xul', 'am-copies.xul', 'am-offline.xul',
- *                    'am-addressing.xul', 'am-smtp.xul'
- * @param  aServer    The server of the account to select. Optional.
+ * @param aSelectPage  The xul file name for the viewing page or
+ *                     null for the account main page. Other pages are
+ *                     'am-server.xul', 'am-copies.xul', 'am-offline.xul',
+ *                     'am-addressing.xul', 'am-smtp.xul'
+ * @param aServer      The server of the account to select. Optional.
  */
-function MsgAccountManager(selectPage, aServer) {
-  var existingAccountManager = Services.wm.getMostRecentWindow("mailnews:accountmanager");
+function MsgAccountManager(aSelectPage, aServer) {
+  if (!aServer) {
+    if (typeof window.GetSelectedMsgFolders === "function") {
+      let folders = window.GetSelectedMsgFolders();
+      if (folders.length > 0)
+        aServer = folders[0].server;
+    }
+    if (!aServer && (typeof window.GetDefaultAccountRootFolder === "function")) {
+      let folder = window.GetDefaultAccountRootFolder();
+      if (folder instanceof Ci.nsIMsgFolder)
+        aServer = folder.server;
+    }
+  }
 
-  if (existingAccountManager) {
-    existingAccountManager.focus();
+  if (AppConstants.MOZ_APP_NAME == "thunderbird") {
+    // Load the Account Manager in a tab.
+    openPreferencesTab("paneAccount", aServer ? aServer.key : null, aSelectPage);
   } else {
-    if (!aServer) {
-      if (typeof window.GetSelectedMsgFolders === "function") {
-        let folders = window.GetSelectedMsgFolders();
-        if (folders.length > 0)
-          aServer = folders[0].server;
-      }
-      if (!aServer && (typeof window.GetDefaultAccountRootFolder === "function")) {
-        let folder = window.GetDefaultAccountRootFolder();
-        if (folder instanceof Ci.nsIMsgFolder)
-          aServer = folder.server;
-      }
+    // If the Account Manager is already running, just focus the right server.
+    let existingAccountManager = Services.wm.getMostRecentWindow("mailnews:accountmanager");
+    if (existingAccountManager) {
+      existingAccountManager.focus();
+      existingAccountManager.selectServer(aServer);
+    } else {
+      // Load the Account Manager in a standalone dialog.
+      window.openDialog("chrome://messenger/content/AccountManager.xul",
+                        "AccountManager",
+                        "chrome,centerscreen,modal,titlebar,resizable",
+                        { server: aServer, selectPage: aSelectPage });
     }
-
-    window.openDialog("chrome://messenger/content/AccountManager.xul",
-                      "AccountManager",
-                      "chrome,centerscreen,modal,titlebar,resizable",
-                      { server: aServer, selectPage });
   }
 }
 
 function loadInboxForNewAccount() {
   // gNewAccountToLoad is set in the final screen of the Account Wizard if a POP account
   // was created, the download messages box is checked, and the wizard was opened from the 3pane
   if (gNewAccountToLoad) {
     var rootMsgFolder = gNewAccountToLoad.incomingServer.rootMsgFolder;
--- a/mailnews/base/prefs/content/am-addressing.xul
+++ b/mailnews/base/prefs/content/am-addressing.xul
@@ -1,15 +1,13 @@
 <?xml version="1.0"?>
-
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
-<?xml-stylesheet href="chrome://messenger/content/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE page SYSTEM "chrome://messenger/locale/am-addressing.dtd">
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
       title="&addressing.label;"
       onload="onLoad();">
 
--- a/mailnews/base/prefs/content/am-archiveoptions.xul
+++ b/mailnews/base/prefs/content/am-archiveoptions.xul
@@ -1,15 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
-<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderPane.css" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://messenger/locale/am-archiveoptions.dtd" >
 
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         id="archive-options"
         title="&dialogTitle.label;"
         width="350" height="350"
--- a/mailnews/base/prefs/content/am-copies.xul
+++ b/mailnews/base/prefs/content/am-copies.xul
@@ -1,15 +1,16 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
-<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 
 <!DOCTYPE page SYSTEM "chrome://messenger/locale/am-copies.dtd">
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
       title="&copyAndFolderTitle.label;"
       onload="parent.onPanelLoaded('am-copies.xul');">
 
--- a/mailnews/base/prefs/content/am-identities-list.js
+++ b/mailnews/base/prefs/content/am-identities-list.js
@@ -70,17 +70,21 @@ function refreshIdentityList(aSelectInde
 }
 
 /**
  * Opens the identity editor dialog.
  *
  * @param identity  the identity (if any) to load in the dialog
  */
 function openIdentityEditor(identity) {
-  let args = { identity, account: gAccount, result: false };
+  let args = { identity,
+               account: gAccount,
+               width: window.arguments[0].width,
+               height: window.arguments[0].height,
+               result: false };
 
   let indexToSelect = identity ? gIdentityListBox.selectedIndex :
                                  gIdentityListBox.itemCount;
 
   window.openDialog("am-identity-edit.xul", "",
                     "chrome,modal,resizable,centerscreen", args);
 
   if (args.result)
--- a/mailnews/base/prefs/content/am-identities-list.xul
+++ b/mailnews/base/prefs/content/am-identities-list.xul
@@ -1,17 +1,16 @@
 <?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
 <!DOCTYPE dialog SYSTEM "chrome://messenger/locale/am-identities-list.dtd">
 
 <dialog
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
   onload="onLoad();"
   buttons="accept"
   buttonlabelaccept="&identitiesListClose.label;"
   buttonaccesskeyaccept="&identitiesListClose.accesskey;"
--- a/mailnews/base/prefs/content/am-identity-edit.js
+++ b/mailnews/base/prefs/content/am-identity-edit.js
@@ -15,26 +15,19 @@ var gAccount = null;   // the account th
 document.addEventListener("dialogaccept", onOk);
 
 function onLoadIdentityProperties() {
   // extract the account
   gIdentity = window.arguments[0].identity;
   gAccount = window.arguments[0].account;
   let prefBundle = document.getElementById("bundle_prefs");
 
-  // Make the dialog the same height and 90% of the width of the main Account
-  // manager page when the Account manager is not maximized.
-  let accountDialog = Services.wm.getMostRecentWindow("mailnews:accountmanager")
-                              .document;
-  if (accountDialog.documentElement.getAttribute("sizemode") != "maximized") {
-    document.getElementById("identityDialog").style.width =
-      accountDialog.getElementById("accountManager").clientWidth * 0.9 + "px";
-    document.getElementById("identityDialog").style.height =
-      accountDialog.getElementById("accountManager").clientHeight + "px";
-  }
+  // Make the dialog the same height and width of the main Account manager page.
+  document.documentElement.style.width = window.arguments[0].width + "px";
+  document.documentElement.style.height = window.arguments[0].height + "px";
 
   if (gIdentity) {
     let listName = gIdentity.identityName;
     document.title = prefBundle
                      .getFormattedString("identityDialogTitleEdit", [listName]);
   } else {
     document.title = prefBundle.getString("identityDialogTitleAdd");
   }
--- a/mailnews/base/prefs/content/am-identity-edit.xul
+++ b/mailnews/base/prefs/content/am-identity-edit.xul
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE dialog [
 <!ENTITY % identityEditDTD SYSTEM "chrome://messenger/locale/am-identity-edit.dtd" >
 %identityEditDTD;
 <!ENTITY % identityDTD SYSTEM "chrome://messenger/locale/am-main.dtd" >
--- a/mailnews/base/prefs/content/am-junk.xul
+++ b/mailnews/base/prefs/content/am-junk.xul
@@ -1,17 +1,16 @@
 <?xml version="1.0"?>
-
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/.
--->
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
-<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 
 <!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 %brandDTD;
 <!ENTITY % junkMailDTD SYSTEM "chrome://messenger/locale/am-junk.dtd">
 %junkMailDTD;
 ]>
--- a/mailnews/base/prefs/content/am-main.js
+++ b/mailnews/base/prefs/content/am-main.js
@@ -24,27 +24,35 @@ function onInit(aPageId, aServerId) {
   setupSignatureItems();
 }
 
 function onPreInit(account, accountValues) {
   gAccount = account;
   loadSMTPServerList();
 }
 
+function onLeave(restoreValuesOnFailure) {
+  return top.checkAccountNameIsValid(restoreValuesOnFailure);
+}
+
 function manageIdentities() {
   // We want to save the current identity information before bringing up the multiple identities
   // UI. This ensures that the changes are reflected in the identity list dialog
   // onSave();
 
   if (!gAccount)
     return;
 
   var accountName = document.getElementById("server.prettyName").value;
 
-  var args = { account: gAccount, accountName, result: false };
+  var args = { account: gAccount,
+               accountName,
+               width: document.documentElement.clientWidth,
+               height: document.documentElement.clientHeight,
+               result: false };
 
   // save the current identity settings so they show up correctly
   // if the user just changed them in the manage identities dialog
   var identity = gAccount.defaultIdentity;
   saveIdentitySettings(identity);
 
   window.openDialog("am-identities-list.xul", "", "chrome,modal,resizable=no,centerscreen", args);
 
--- a/mailnews/base/prefs/content/am-main.xul
+++ b/mailnews/base/prefs/content/am-main.xul
@@ -1,17 +1,18 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
-
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
-<!DOCTYPE page SYSTEM "chrome://messenger/locale/am-main.dtd" >
+<!DOCTYPE page SYSTEM "chrome://messenger/locale/am-main.dtd">
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
       xmlns:html="http://www.w3.org/1999/xhtml"
       onload="parent.onPanelLoaded('am-main.xul');">
 
   <vbox flex="1" style="overflow: auto;">
     <stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"/>
     <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
--- a/mailnews/base/prefs/content/am-offline.js
+++ b/mailnews/base/prefs/content/am-offline.js
@@ -199,17 +199,17 @@ function onCancel() {
   // restore the offline flags for all folders
   restoreOfflineFolders(gOfflineMap);
   document.getElementById("offline.folders").checked = gOfflineFolders;
 }
 
 /**
  * Prompt to avoid unexpected folder sync changes.
  */
-function onLeave() {
+function onLeave(restoreValuesOnFailure) {
   let changed = false;
   if (gToggleOccurred) {
     let allFolders = gIncomingServer.rootFolder.descendants;
     for (let folder of fixIterator(allFolders, Ci.nsIMsgFolder)) {
       if (gOfflineMap[folder.folderURL] !=
           folder.getFlag(Ci.nsMsgFolderFlags.Offline)) {
         // A change to the Offline flag to a folder was made.
         changed = true;
--- a/mailnews/base/prefs/content/am-offline.xul
+++ b/mailnews/base/prefs/content/am-offline.xul
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE page SYSTEM "chrome://messenger/locale/am-offline.dtd">
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
       onload="parent.onPanelLoaded('am-offline.xul');">
 
   <vbox flex="1" style="overflow: auto;">
--- a/mailnews/base/prefs/content/am-server-advanced.xul
+++ b/mailnews/base/prefs/content/am-server-advanced.xul
@@ -1,16 +1,17 @@
 <?xml version="1.0"?>
-
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
+<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
-<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://messenger/locale/am-server-advanced.dtd">
 
 <dialog
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         title="&serverAdvanced.label;"
         buttons="accept,cancel"
--- a/mailnews/base/prefs/content/am-server.js
+++ b/mailnews/base/prefs/content/am-server.js
@@ -115,16 +115,21 @@ function onPreInit(account, accountValue
   gServer = account.incomingServer;
 
   if (!account.incomingServer.canEmptyTrashOnExit) {
     document.getElementById("server.emptyTrashOnExit").setAttribute("hidden", "true");
     document.getElementById("imap.deleteModel.box").setAttribute("hidden", "true");
   }
 }
 
+function onLeave(restoreValuesOnFailure) {
+  return (top.checkUserServerChanges(restoreValuesOnFailure) &&
+          top.checkLocalPathChanges(restoreValuesOnFailure));
+}
+
 function initServerType() {
   var serverType = document.getElementById("server.type").getAttribute("value");
   var propertyName = "serverType-" + serverType;
 
   var messengerBundle = document.getElementById("bundle_messenger");
   var verboseName = messengerBundle.getString(propertyName);
   setDivText("servertype.verbose", verboseName);
 
--- a/mailnews/base/prefs/content/am-server.xul
+++ b/mailnews/base/prefs/content/am-server.xul
@@ -1,15 +1,16 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
-<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/content/am-server.css" type="text/css"?>
 
 <!DOCTYPE page [
 <!ENTITY % trashDTD SYSTEM "chrome://messenger/locale/am-server-top.dtd">
 %trashDTD;
 ]>
 
--- a/mailnews/base/prefs/content/am-serverwithnoidentities.js
+++ b/mailnews/base/prefs/content/am-serverwithnoidentities.js
@@ -68,16 +68,21 @@ function onInit(aPageId, aServerId) {
   // Initialise 'gOriginalStoreType' to the item that was originally selected.
   gOriginalStoreType = storeTypeElement.value;
 }
 
 function onPreInit(account, accountValues) {
   gAccount = account;
 }
 
+function onLeave(restoreValuesOnFailure) {
+  return (top.checkAccountNameIsValid(restoreValuesOnFailure) &&
+          top.checkLocalPathChanges(restoreValuesOnFailure));
+}
+
 function onSave() {
   let storeContractID = document.getElementById("server.storeTypeMenulist")
                                 .selectedItem
                                 .value;
   document.getElementById("server.storeContractID")
           .setAttribute("value", storeContractID);
 }
 
--- a/mailnews/base/prefs/content/am-serverwithnoidentities.xul
+++ b/mailnews/base/prefs/content/am-serverwithnoidentities.xul
@@ -1,14 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
-
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE page [
 <!ENTITY % accountNoIdentDTD SYSTEM "chrome://messenger/locale/am-serverwithnoidentities.dtd" >%accountNoIdentDTD;
 <!ENTITY % accountServerTopDTD SYSTEM "chrome://messenger/locale/am-server-top.dtd">%accountServerTopDTD;
 ]>
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
--- a/mailnews/base/prefs/content/am-smtp.xul
+++ b/mailnews/base/prefs/content/am-smtp.xul
@@ -1,14 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
-
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE page SYSTEM "chrome://messenger/locale/am-advanced.dtd">
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
       title="&smtpServer.label;"
       onload="gSmtpServerListWindow.onLoad();">
   <script src="chrome://messenger/content/amUtils.js"/>
--- a/mailnews/extensions/mdn/content/am-mdn.xul
+++ b/mailnews/extensions/mdn/content/am-mdn.xul
@@ -1,16 +1,15 @@
 <?xml version="1.0"?>
-
-<!--
-
- This Source Code Form is subject to the terms of the Mozilla Public
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE page SYSTEM "chrome://messenger/locale/am-mdn.dtd">
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
       title="&pane.title;"
       onload="parent.onPanelLoaded('am-mdn.xul');">
 
--- a/mailnews/extensions/newsblog/content/am-newsblog.xul
+++ b/mailnews/extensions/newsblog/content/am-newsblog.xul
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger-newsblog/skin/feed-subscriptions.css" type="text/css"?>
 
 <!DOCTYPE page [
 <!ENTITY %         newsblogDTD SYSTEM "chrome://messenger-newsblog/locale/am-newsblog.dtd" >
 %newsblogDTD;
 <!ENTITY %             feedDTD SYSTEM "chrome://messenger-newsblog/locale/feed-subscriptions.dtd" >
 %feedDTD;
--- a/mailnews/extensions/smime/content/am-smime.inc.xul
+++ b/mailnews/extensions/smime/content/am-smime.inc.xul
@@ -75,18 +75,20 @@
 
           <radio id="encrypt_mail_always" wsm_persist="true" value="2"
                  label="&alwaysEncryptMessage.label;"
                  accesskey="&alwaysEncryptMessage.accesskey;"/>
         </radiogroup>
       </groupbox>
 
       <!-- Certificate manager -->
-      <groupbox id="smimeCertificateManager" orient="horizontal">
+      <groupbox id="smimeCertificateManager">
         <label class="header">&certificates.label;</label>
-        <button id="openCertManagerButton" oncommand="openCertManager();"
-                label="&manageCerts2.label;" accesskey="&manageCerts2.accesskey;"
-                prefstring="security.disable_button.openCertManager"/>
-        <button id="openDeviceManagerButton" oncommand="openDeviceManager();"
-                label="&manageDevices.label;" accesskey="&manageDevices.accesskey;"
-                prefstring="security.disable_button.openDeviceManager"/>
+        <hbox>
+          <button id="openCertManagerButton" oncommand="openCertManager();"
+                  label="&manageCerts2.label;" accesskey="&manageCerts2.accesskey;"
+                  prefstring="security.disable_button.openCertManager"/>
+          <button id="openDeviceManagerButton" oncommand="openDeviceManager();"
+                  label="&manageDevices.label;" accesskey="&manageDevices.accesskey;"
+                  prefstring="security.disable_button.openDeviceManager"/>
+        </hbox>
       </groupbox>
     </vbox>
--- a/mailnews/jar.mn
+++ b/mailnews/jar.mn
@@ -10,17 +10,19 @@ messenger.jar:
     content/messenger/addressbook/abAddressBookNameDialog.js                   (addrbook/content/abAddressBookNameDialog.js)
     content/messenger/addressbook/abAddressBookNameDialog.xul                  (addrbook/content/abAddressBookNameDialog.xul)
     content/messenger/addressbook/abResultsPane.js                             (addrbook/content/abResultsPane.js)
     content/messenger/addressbook/addrbookWidgets.xml                          (addrbook/content/addrbookWidgets.xml)
     content/messenger/addressbook/abDragDrop.js                                (addrbook/content/abDragDrop.js)
     content/messenger/addressbook/abMailListDialog.js                          (addrbook/content/abMailListDialog.js)
     content/messenger/addressbook/map-list.js                                  (addrbook/content/map-list.js)
     content/messagebody/addressbook/print.css                                  (addrbook/content/print.css)
-*   content/messenger/AccountManager.xul                                       (base/prefs/content/AccountManager.xul)
+#ifdef MOZ_SUITE
+    content/messenger/AccountManager.xul                                       (base/prefs/content/AccountManager.xul)
+#endif
     content/messenger/AccountManager.js                                        (base/prefs/content/AccountManager.js)
     content/messenger/am-main.xul                                              (base/prefs/content/am-main.xul)
     content/messenger/am-main.js                                               (base/prefs/content/am-main.js)
 #ifdef MOZ_SUITE
     content/messenger/am-help.js                                               (base/prefs/content/am-help.js)
 #endif
     content/messenger/am-server.xul                                            (base/prefs/content/am-server.xul)
     content/messenger/am-serverwithnoidentities.xul                            (base/prefs/content/am-serverwithnoidentities.xul)