Bug 1096006 - Backout of AM in pref tab. a=backout
authorJorg K <jorgk@jorgk.com>
Mon, 24 Jun 2019 22:27:34 +0200
changeset 35941 fac9fd23d58aca8af9df5ae1faa70b91fa5107af
parent 35940 0b01d4da30db1a135350792847dbf2f218f97813
child 35942 cf23f4f4e5abfd5d3a97382cb76754e767553bdd
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersbackout
bugs1096006
Bug 1096006 - Backout of AM in pref tab. a=backout
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/test/mozmill/account/test-ab-whitelist.js
mail/test/mozmill/account/test-account-actions.js
mail/test/mozmill/account/test-account-deletion.js
mail/test/mozmill/account/test-account-port-setting.js
mail/test/mozmill/account/test-account-settings-infrastructure.js
mail/test/mozmill/account/test-account-tree.js
mail/test/mozmill/account/test-account-values.js
mail/test/mozmill/account/test-archive-options.js
mail/test/mozmill/account/test-mail-account-setup-wizard.js
mail/test/mozmill/account/test-retest-config.js
mail/test/mozmill/shared-modules/test-account-manager-helpers.js
mail/test/mozmill/shared-modules/test-pref-window-helpers.js
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,17 +1549,26 @@ EmailConfigWizard.prototype = {
       alertPrompt(gStringsBundle.getString("error_creating_account"),
                   gStringsBundle.getString("incoming_server_exists"));
       return;
     }
 
     gEmailWizardLogger.info("creating account in backend");
     let newAccount = createAccountInBackend(configFilledIn);
 
-    MsgAccountManager("am-server.xul", newAccount.incomingServer);
+    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" });
+    }
     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,18 +40,17 @@
   <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://communicator/content/utilityOverlay.js"/>
+  <script src="chrome://messenger/content/accountUtils.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,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://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,18 +1,16 @@
 /* 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
@@ -307,17 +305,26 @@ var gAccountManager = {
       if (!incomingServer || incomingServer.type != "im")
         continue;
       if (incomingServer.wrappedJSObject.imAccount.numericId == imAccountId) {
         server = incomingServer;
         break;
       }
     }
 
-    MsgAccountManager(null, server);
+    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 });
+    }
   },
   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,18 +22,16 @@
         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,15 +1,12 @@
 /* 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");
 
@@ -175,17 +172,25 @@ var EmailAccountProvisioner = {
                                              account.defaultIdentity, null);
     });
 
     document.getElementById("success-addons").addEventListener("click", function() {
       EmailAccountProvisioner.openAddonsMgr();
     });
 
     document.getElementById("success-signature").addEventListener("click", function() {
-      MsgAccountManager(null, account.incomingServer);
+      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});
     });
 
     document.getElementById("window").style.display = "none";
     document.getElementById("successful_account").style.display = "block";
   },
 
   /**
    * Save the name entered into the search field to a pref, so we can
--- a/mail/components/newmailaccount/content/accountProvisioner.xhtml
+++ b/mail/components/newmailaccount/content/accountProvisioner.xhtml
@@ -17,24 +17,30 @@
    - 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 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"/>
+  <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>
 </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,17 +67,16 @@
 #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"
deleted file mode 100644
--- a/mail/components/preferences/accounts.inc.xul
+++ /dev/null
@@ -1,68 +0,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/.
-
-  <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>
deleted file mode 100644
--- a/mail/components/preferences/accounts.js
+++ /dev/null
@@ -1,30 +0,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/. */
-
-"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,9 +449,10 @@
                     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,11 +36,9 @@
 <!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,17 +6,16 @@ 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,21 +87,17 @@ function showPane(paneID) {
     if (currentlySelected == pane) {
       return;
     }
     currentlySelected.removeAttribute("selected");
   }
 
   selector.value = paneID;
   pane.setAttribute("selected", "true");
-  pane.dispatchEvent(new CustomEvent("paneSelected",
-    { bubbles: true,
-      detail: { oldPane: (currentlySelected ? currentlySelected.id : null),
-                newPane: paneID },
-    }));
+  pane.dispatchEvent(new CustomEvent("paneSelected", { bubbles: true }));
 
   document.documentElement.setAttribute("lastSelected", paneID);
   Services.xulStore.persist(document.documentElement, "lastSelected");
 }
 
 /**
  * Selects the specified preferences pane
  *
@@ -121,36 +117,25 @@ function selectPaneAndTab(prefWindow, pa
     }
   }
 }
 
 /**
  * Select the specified tab
  *
  * @param pane         prefpane to operate on
- * @param tabID        ID of tab to select on the prefpane (or server for AM)
+ * @param tabID        ID of tab to select on the prefpane
  * @param subdialogID  ID of button to activate, opening a subdialog
  */
 function showTab(pane, tabID, subdialogID) {
-  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);
-    }
+  pane.querySelector("tabbox").selectedTab = document.getElementById(tabID);
+  if (subdialogID) {
+    setTimeout(function() {
+      document.getElementById(subdialogID).click();
+    });
   }
 }
 
 /**
  * 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,28 +124,20 @@ 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: currentPane,
-      tabID: tabId,
+      paneID: aTab.paneID,
+      tabID: aTab.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,8 +15,20 @@
 <!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,8 +19,11 @@
 <!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/test/mozmill/account/test-ab-whitelist.js
+++ b/mail/test/mozmill/account/test-ab-whitelist.js
@@ -1,45 +1,44 @@
 /* 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 ../shared-modules/test-account-manager-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
 /* import-globals-from ../shared-modules/test-keyboard-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
 
 var MODULE_NAME = "test-ab-whitelist";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = [
   "folder-display-helpers",
   "window-helpers",
   "account-manager-helpers",
   "keyboard-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
 ];
 
 var mozmill = ChromeUtils.import("chrome://mozmill/content/modules/mozmill.jsm");
 var controller = ChromeUtils.import("chrome://mozmill/content/modules/controller.jsm");
 var elib = ChromeUtils.import("chrome://mozmill/content/modules/elementslib.jsm");
 
 var gOldWhiteList = null;
 var gKeyString = null;
 
 var gAccount = null;
 
 function setupModule(module) {
-  for (let lib of MODULE_REQUIRES) {
-    collector.getModule(lib).installInto(module);
-  }
+  let wh = collector.getModule("window-helpers");
+  wh.installInto(module);
+  let fdh = collector.getModule("folder-display-helpers");
+  fdh.installInto(module);
+  let amh = collector.getModule("account-manager-helpers");
+  amh.installInto(module);
 
   let server = MailServices.accounts
                            .FindServer("tinderbox", FAKE_SERVER_HOSTNAME, "pop3");
   gAccount = MailServices.accounts.FindAccountForServer(server);
   let serverKey = server.key;
 
   gKeyString = "mail.server." + serverKey + ".whiteListAbURI";
   gOldWhiteList = Services.prefs.getCharPref(gKeyString);
@@ -49,78 +48,75 @@ function setupModule(module) {
 function teardownModule(module) {
   Services.prefs.setCharPref(gKeyString, gOldWhiteList);
 }
 
 /* First, test that when we initially load the account manager, that
  * we're not whitelisting any address books.  Then, we'll check all
  * address books and save.
  */
-function test_check_whitelist_init_and_save() {
-  let tab = open_advanced_settings();
+function subtest_check_whitelist_init_and_save(amc) {
   // Ok, the advanced settings window is open.  Let's choose
   // the junkmail settings.
-  let accountRow = get_account_tree_row(gAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  let accountRow = get_account_tree_row(gAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let doc = content_tab_e(tab, "contentFrame").contentDocument;
+  let doc = amc.window.document.getElementById("contentFrame").contentDocument;
 
   // At this point, we shouldn't have anything checked, but we should have
   // the two default address books (Personal and Collected) displayed
   let list = doc.getElementById("whiteListAbURI");
   assert_equals(2, list.getRowCount(),
                 "There was an unexpected number of address books");
 
   // Now we'll check both address books
   for (let i = 0; i < list.getRowCount(); i++) {
     let abNode = list.getItemAtIndex(i);
-    mc.click(new elib.Elem(abNode.firstChild));
+    amc.click(new elib.Elem(abNode.firstChild));
   }
 
   // And close the dialog
-  close_advanced_settings(tab);
+  amc.window.document.getElementById("accountManager").acceptDialog();
 }
 
 /* Next, we'll make sure that the address books we checked in
  * subtest_check_whitelist_init_and_save were properly saved.
  * Then, we'll clear the address books and save.
  */
-function test_check_whitelist_load_and_clear() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_whitelist_load_and_clear(amc) {
+  let accountRow = get_account_tree_row(gAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let doc = content_tab_e(tab, "contentFrame").contentDocument;
+  let doc = amc.window.document.getElementById("contentFrame").contentDocument;
   let list = doc.getElementById("whiteListAbURI");
   let whiteListURIs = Services.prefs.getCharPref(gKeyString).split(" ");
 
   for (let i = 0; i < list.getRowCount(); i++) {
     let abNode = list.getItemAtIndex(i);
     assert_equals("true", abNode.firstChild.getAttribute("checked"),
                   "Should have been checked");
     // Also ensure that the address book URI was properly saved in the
     // prefs
     assert_true(whiteListURIs.includes(abNode.getAttribute("value")));
     // Now un-check that address book
-    mc.click(new elib.Elem(abNode.firstChild));
+    amc.click(new elib.Elem(abNode.firstChild));
   }
 
   // And close the dialog
-  close_advanced_settings(tab);
+  amc.window.document.getElementById("accountManager").acceptDialog();
 }
 
 /* Finally, we'll make sure that the address books we cleared
  * were actually cleared.
  */
-function test_check_whitelist_load_cleared() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_whitelist_load_cleared(amc) {
+  let accountRow = get_account_tree_row(gAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let doc = content_tab_e(tab, "contentFrame").contentDocument;
+  let doc = amc.window.document.getElementById("contentFrame").contentDocument;
   let list = doc.getElementById("whiteListAbURI");
   let whiteListURIs = "";
 
   try {
     whiteListURIs = Services.prefs.getCharPref(gKeyString);
     // We should have failed here, because the pref should have been cleared
     // out.
     throw Error("The whitelist preference for this server wasn't properly "
@@ -133,10 +129,16 @@ function test_check_whitelist_load_clear
     assert_equals("false", abNode.firstChild.getAttribute("checked"),
                   "Should not have been checked");
     // Also ensure that the address book URI was properly cleared in the
     // prefs
     assert_false(whiteListURIs.includes(abNode.getAttribute("value")));
   }
 
   // And close the dialog
-  close_advanced_settings(tab);
+  amc.window.document.getElementById("accountManager").acceptDialog();
 }
+
+function test_address_book_whitelist() {
+  open_advanced_settings(subtest_check_whitelist_init_and_save);
+  open_advanced_settings(subtest_check_whitelist_load_and_clear);
+  open_advanced_settings(subtest_check_whitelist_load_cleared);
+}
--- a/mail/test/mozmill/account/test-account-actions.js
+++ b/mail/test/mozmill/account/test-account-actions.js
@@ -1,36 +1,28 @@
 /* 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 ../shared-modules/test-account-manager-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
 
 var MODULE_NAME = "test-account-actions";
 var RELATIVE_ROOT = "../shared-modules";
-var MODULE_REQUIRES = [
-  "folder-display-helpers",
-  "window-helpers",
-  "account-manager-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
-];
+var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers", "account-manager-helpers"];
 
 var imapAccount, nntpAccount, originalAccountCount;
 
 function setupModule(module) {
-  for (let lib of MODULE_REQUIRES) {
-    collector.getModule(lib).installInto(module);
-  }
+  collector.getModule("window-helpers").installInto(module);
+  collector.getModule("folder-display-helpers").installInto(module);
+  collector.getModule("account-manager-helpers").installInto(module);
 
   // There may be pre-existing accounts from other tests.
   originalAccountCount = MailServices.accounts.allServers.length;
   // There already should be a Local Folders account created.
   // It is needed for this test.
   assert_true(MailServices.accounts.localFoldersServer);
 
   // Create an IMAP server
@@ -66,93 +58,104 @@ function teardownModule(module) {
   MailServices.accounts.removeAccount(imapAccount);
   // There should be only the original accounts left.
   assert_equals(MailServices.accounts.allServers.length, originalAccountCount);
 }
 
 /**
  * Check that the account actions for the account are enabled or disabled appropriately.
  *
+ * @param amc          the account options controller
  * @param aAccountKey  the key of the account to select
  * @param aIsSetAsDefaultEnabled  true if the menuitem should be enabled, false otherwise
  * @param aIsRemoveEnabled        true if the menuitem should be enabled, false otherwise
  * @param aIsAddAccountEnabled    true if the menuitems (Add Mail Account+Add Other Account)
  *                                should be enabled, false otherwise
  */
-function subtest_check_account_actions(aAccountKey, aIsSetAsDefaultEnabled,
+function subtest_check_account_actions(amc, aAccountKey, aIsSetAsDefaultEnabled,
                                        aIsRemoveEnabled, aIsAddAccountEnabled) {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(aAccountKey, null, tab);
-  click_account_tree_row(tab, accountRow);
+  let accountRow = get_account_tree_row(aAccountKey, null, amc);
+  click_account_tree_row(amc, accountRow);
 
   // click the Actions Button to bring up the popup with menuitems to test
-  mc.click(content_tab_eid(tab, "accountActionsButton"), 5, 5);
-  wait_for_popup_to_open(content_tab_e(tab, "accountActionsDropdown"));
+  amc.click(amc.eid("accountActionsButton"), 5, 5);
+  wait_for_popup_to_open(amc.e("accountActionsDropdown"));
 
-  let actionAddMailAccount = content_tab_e(tab, "accountActionsAddMailAccount");
+  let actionAddMailAccount = amc.e("accountActionsAddMailAccount");
   assert_not_equals(actionAddMailAccount, undefined);
   assert_equals(!actionAddMailAccount.getAttribute("disabled"), aIsAddAccountEnabled);
 
-  let actionAddOtherAccount = content_tab_e(tab, "accountActionsAddOtherAccount");
+  let actionAddOtherAccount = amc.e("accountActionsAddOtherAccount");
   assert_not_equals(actionAddOtherAccount, undefined);
   assert_equals(!actionAddOtherAccount.getAttribute("disabled"), aIsAddAccountEnabled);
 
-  let actionSetDefault = content_tab_e(tab, "accountActionsDropdownSetDefault");
+  let actionSetDefault = amc.e("accountActionsDropdownSetDefault");
   assert_not_equals(actionSetDefault, undefined);
   assert_equals(!actionSetDefault.getAttribute("disabled"), aIsSetAsDefaultEnabled);
 
-  let actionRemove = content_tab_e(tab, "accountActionsDropdownRemove");
+  let actionRemove = amc.e("accountActionsDropdownRemove");
   assert_not_equals(actionRemove, undefined);
   assert_equals(!actionRemove.getAttribute("disabled"), aIsRemoveEnabled);
 
-  close_popup(mc, content_tab_eid(tab, "accountActionsDropdown"));
-
-  close_advanced_settings(tab);
+  close_popup(amc, amc.eid("accountActionsDropdown"));
 }
 
 function test_account_actions() {
   // IMAP account: can be default, can be removed.
-  subtest_check_account_actions(imapAccount.key, true, true, true);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_actions(amc, imapAccount.key, true, true, true);
+  });
 
   // NNTP (News) account: can't be default, can be removed.
-  subtest_check_account_actions(nntpAccount.key, false, true, true);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_actions(amc, nntpAccount.key, false, true, true);
+  });
 
   // Local Folders account: can't be removed, can't be default.
   var localFoldersAccount = MailServices.accounts.FindAccountForServer(MailServices.accounts.localFoldersServer);
-  subtest_check_account_actions(localFoldersAccount.key, false, false, true);
-
+  open_advanced_settings(function(amc) {
+    subtest_check_account_actions(amc, localFoldersAccount.key, false, false, true);
+  });
   // SMTP server row: can't be removed, can't be default.
-  subtest_check_account_actions(null, false, false, true);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_actions(amc, null, false, false, true);
+  });
 
   // on the IMAP account, disable Delete Account menu item
   let disableItemPref = "mail.disable_button.delete_account";
 
   // Set the pref on the default branch, otherwise .getBoolPref on it throws.
   Services.prefs.getDefaultBranch("").setBoolPref(disableItemPref, true);
   Services.prefs.lockPref(disableItemPref);
 
-  subtest_check_account_actions(imapAccount.key, true, false, true);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_actions(amc, imapAccount.key, true, false, true);
+  });
 
   Services.prefs.unlockPref(disableItemPref);
   Services.prefs.getDefaultBranch("").deleteBranch(disableItemPref);
 
   // on the IMAP account, disable Set as Default menu item
   disableItemPref = "mail.disable_button.set_default_account";
 
   Services.prefs.getDefaultBranch("").setBoolPref(disableItemPref, true);
   Services.prefs.lockPref(disableItemPref);
 
-  subtest_check_account_actions(imapAccount.key, false, true, true);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_actions(amc, imapAccount.key, false, true, true);
+  });
 
   Services.prefs.unlockPref(disableItemPref);
   Services.prefs.getDefaultBranch("").deleteBranch(disableItemPref);
 
   // on the IMAP account, disable Add new Account menu items
   disableItemPref = "mail.disable_new_account_addition";
 
   Services.prefs.getDefaultBranch("").setBoolPref(disableItemPref, true);
   Services.prefs.lockPref(disableItemPref);
 
-  subtest_check_account_actions(imapAccount.key, true, true, false);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_actions(amc, imapAccount.key, true, true, false);
+  });
 
   Services.prefs.unlockPref(disableItemPref);
   Services.prefs.getDefaultBranch("").deleteBranch(disableItemPref);
 }
--- a/mail/test/mozmill/account/test-account-deletion.js
+++ b/mail/test/mozmill/account/test-account-deletion.js
@@ -4,30 +4,22 @@
 
 /**
  * This test checks proper deletion of an account from the Account manager.
  */
 
 "use strict";
 
 /* import-globals-from ../shared-modules/test-account-manager-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
 
 var MODULE_NAME = "test-account-deletion";
 var RELATIVE_ROOT = "../shared-modules";
-var MODULE_REQUIRES = [
-  "folder-display-helpers",
-  "window-helpers",
-  "account-manager-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
-];
+var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers", "account-manager-helpers"];
 
 var gPopAccount, gImapAccount, gNntpAccount, gOriginalAccountCount;
 
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
     collector.getModule(lib).installInto(module);
   }
 
@@ -61,51 +53,55 @@ function setupModule(module) {
   assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount + 2);
 }
 
 function teardownModule(module) {
   // There should be only the original accounts left.
   assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
 }
 
+function test_account_data_deletion() {
+  open_advanced_settings(function(amc) {
+    subtest_account_data_deletion1(amc);
+  });
+
+  open_advanced_settings(function(amc) {
+    subtest_account_data_deletion2(amc);
+  });
+}
+
 /**
  * Bug 274452
  * Check if files of an account are preserved.
  *
  * @param amc  The account options controller.
  */
-function test_account_data_deletion1() {
-  let tab = open_advanced_settings();
+function subtest_account_data_deletion1(amc) {
   let accountDir = gPopAccount.incomingServer.localPath;
   assert_true(accountDir.isDirectory());
 
   // Get some existing file in the POP3 account data dir.
   let inboxFile = accountDir.clone();
   inboxFile.append("Inbox.msf");
   assert_true(inboxFile.isFile());
 
-  remove_account(gPopAccount, tab, true, false);
+  remove_account(gPopAccount, amc, true, false);
   assert_true(accountDir.exists());
-
-  close_advanced_settings(tab);
 }
 
 /**
  * Bug 274452
  * Check if files of an account can be deleted.
  *
  * @param amc  The account options controller.
  */
-function test_account_data_deletion2() {
-  let tab = open_advanced_settings();
+function subtest_account_data_deletion2(amc) {
   let accountDir = gImapAccount.incomingServer.localPath;
   assert_true(accountDir.isDirectory());
 
   // Get some file in the IMAP account data dir.
   let inboxFile = accountDir.clone();
   inboxFile.append("INBOX.msf");
   assert_true(inboxFile.isFile());
 
-  remove_account(gImapAccount, tab, true, true);
+  remove_account(gImapAccount, amc, true, true);
   assert_false(accountDir.exists());
-
-  close_advanced_settings(tab);
 }
--- a/mail/test/mozmill/account/test-account-port-setting.js
+++ b/mail/test/mozmill/account/test-account-port-setting.js
@@ -1,79 +1,78 @@
 /* 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 ../shared-modules/test-account-manager-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
 /* import-globals-from ../shared-modules/test-keyboard-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
 
 var MODULE_NAME = "test-account-port-setting";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = [
   "folder-display-helpers",
   "window-helpers",
   "account-manager-helpers",
   "keyboard-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
 ];
 
 var elib = ChromeUtils.import("chrome://mozmill/content/modules/elementslib.jsm");
 
 var PORT_NUMBERS_TO_TEST =
   [
     "110", // The original port number. We don't input this though.
     "456", // Random port number.
     "995", // The SSL port number.
     "110", // Back to the original.
   ];
 
 var gTestNumber;
 
-function setupModule(module) {
-  for (let lib of MODULE_REQUIRES) {
-    collector.getModule(lib).installInto(module);
-  }
-}
-
-function subtest_check_set_port_number(aDontSet) {
+function subtest_check_set_port_number(amc, aDontSet) {
   // This test expects the following POP account to exist by default
   // with port number 110 and no security.
   let server = MailServices.accounts
                            .FindServer("tinderbox", FAKE_SERVER_HOSTNAME, "pop3");
   let account = MailServices.accounts.FindAccountForServer(server);
 
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(account.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  let accountRow = get_account_tree_row(account.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame");
+  let iframe = amc.window.document.getElementById("contentFrame");
   let portElem = iframe.contentDocument.getElementById("server.port");
   portElem.focus();
 
   if (portElem.value != PORT_NUMBERS_TO_TEST[gTestNumber - 1])
     throw new Error("Port Value is not " +
                     PORT_NUMBERS_TO_TEST[gTestNumber - 1] +
                     " as expected, it is: " + portElem.value);
 
   if (!aDontSet) {
-    delete_all_existing(mc, new elib.Elem(portElem));
-    input_value(mc, PORT_NUMBERS_TO_TEST[gTestNumber]);
+    delete_all_existing(amc, new elib.Elem(portElem));
+    input_value(amc, PORT_NUMBERS_TO_TEST[gTestNumber]);
 
     mc.sleep(0);
   }
 
-  close_advanced_settings(tab);
+  mc.click(new elib.Elem(amc.window.document.getElementById("accountManager").getButton("accept")));
+}
+
+function subtest_check_port_number(amc) {
+  subtest_check_set_port_number(amc, true);
+}
+
+function setupModule(module) {
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
 }
 
 function test_account_port_setting() {
   for (gTestNumber = 1; gTestNumber < PORT_NUMBERS_TO_TEST.length; ++gTestNumber) {
-    subtest_check_set_port_number(false);
+    open_advanced_settings(subtest_check_set_port_number);
   }
 
-  subtest_check_set_port_number(true);
+  open_advanced_settings(subtest_check_port_number);
 }
--- a/mail/test/mozmill/account/test-account-settings-infrastructure.js
+++ b/mail/test/mozmill/account/test-account-settings-infrastructure.js
@@ -8,39 +8,31 @@
  * panes are switched.
  *
  * New checks can be added to it as needed.
  */
 
 "use strict";
 
 /* import-globals-from ../shared-modules/test-account-manager-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
 
 var MODULE_NAME = "test-account-settings-infrastructure";
 var RELATIVE_ROOT = "../shared-modules";
-var MODULE_REQUIRES = [
-  "folder-display-helpers",
-  "window-helpers",
-  "account-manager-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
-];
+var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers", "account-manager-helpers"];
 
 var elib = ChromeUtils.import("chrome://mozmill/content/modules/elementslib.jsm");
 
 var gPopAccount, gImapAccount, gOriginalAccountCount;
 
 function setupModule(module) {
-  for (let lib of MODULE_REQUIRES) {
-    collector.getModule(lib).installInto(module);
-  }
+  collector.getModule("window-helpers").installInto(module);
+  collector.getModule("folder-display-helpers").installInto(module);
+  collector.getModule("account-manager-helpers").installInto(module);
 
   // There may be pre-existing accounts from other tests.
   gOriginalAccountCount = MailServices.accounts.allServers.length;
 
   // Create a POP server
   let popServer = MailServices.accounts
     .createIncomingServer("nobody", "pop.invalid", "pop3")
     .QueryInterface(Ci.nsIPop3IncomingServer);
@@ -76,133 +68,151 @@ function teardownModule(module) {
   // There should be only the original accounts left.
   assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
 }
 
 /**
  * Bug 525024.
  * Check that the options in the server pane are properly preserved across
  * pane switches.
- *
+ */
+function test_account_dot_IDs() {
+  open_advanced_settings(function(amc) {
+    subtest_check_account_dot_IDs(amc);
+  });
+}
+
+/**
  * Check that the options in the server pane are stored even if the id
  * of the element contains multiple dots (not used in standard TB yet
  * but extensions may want it).
+ *
+ * @param amc  the account options controller
  */
-function test_account_dot_IDs() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_account_dot_IDs(amc) {
+  let accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame").contentDocument;
+  let iframe = amc.e("contentFrame").contentDocument;
   // Check whether a standard element with "server.loginAtStartUp" stores its
   // value properly.
   let loginCheck = iframe.getElementById("server.loginAtStartUp");
   assert_false(loginCheck.checked);
-  mc.check(new elib.Elem(loginCheck), true);
+  amc.check(new elib.Elem(loginCheck), true);
 
-  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
   // Re-assign iframe.contentDocument because it was lost when changing panes
   // (uses loadURI to load a new document).
-  iframe = content_tab_e(tab, "contentFrame").contentDocument;
+  iframe = amc.e("contentFrame").contentDocument;
 
   // Check by element properties.
   loginCheck = iframe.getElementById("server.loginAtStartUp");
   assert_true(loginCheck.checked);
 
   // Check for correct value in the accountValues array, that will be saved into prefs.
-  let rawCheckValue = tab.browser.contentWindow.getAccountValue(gPopAccount,
-                        tab.browser.contentWindow.getValueArrayFor(gPopAccount),
-                        "server", "loginAtStartUp",
-                        null, false);
+  let rawCheckValue = amc.window.getAccountValue(gPopAccount,
+                                                 amc.window.getValueArrayFor(gPopAccount),
+                                                 "server", "loginAtStartUp",
+                                                 null, false);
 
   assert_true(rawCheckValue);
 
   // The "server.login.At.StartUp" value does not exist yet, so the value should be 'null'.
-  rawCheckValue = tab.browser.contentWindow.getAccountValue(gPopAccount,
-                    tab.browser.contentWindow.getValueArrayFor(gPopAccount),
-                    "server", "login.At.StartUp",
-                    null, false);
+  rawCheckValue = amc.window.getAccountValue(gPopAccount,
+                                             amc.window.getValueArrayFor(gPopAccount),
+                                             "server", "login.At.StartUp",
+                                             null, false);
   assert_equals(rawCheckValue, null);
 
   // Change the ID so that "server.login.At.StartUp" exists now.
   loginCheck.id = "server.login.At.StartUp";
 
-  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
   // Check for correct value in the accountValues array, that will be saved into prefs.
   // We can't check by element property here, because the am-server.xul pane was
   // reloaded and the element now has the original ID of "server.loginAtStartUp".
-  rawCheckValue = tab.browser.contentWindow.getAccountValue(gPopAccount,
-                    tab.browser.contentWindow.getValueArrayFor(gPopAccount),
-                    "server", "login.At.StartUp",
-                    null, false);
+  rawCheckValue = amc.window.getAccountValue(gPopAccount,
+                                             amc.window.getValueArrayFor(gPopAccount),
+                                             "server", "login.At.StartUp",
+                                             null, false);
 
   assert_true(rawCheckValue);
-
-  close_advanced_settings(tab);
 }
 
 /**
  * Test for bug 807101.
  * Check if form controls are properly disabled when their attached prefs are locked.
- *
+ */
+function test_account_locked_prefs() {
+  open_advanced_settings(function(amc) {
+    subtest_check_locked_prefs_addressing(amc);
+  });
+
+  open_advanced_settings(function(amc) {
+    subtest_check_locked_prefs_server(amc);
+  });
+}
+
+/**
  * Check that the LDAP server selection elements (radio group) are properly
  * disabled when their attached pref (prefstring attribute) is locked.
+ *
+ * @param amc  the account options controller
  */
-function test_locked_prefs_addressing() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, "am-addressing.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_locked_prefs_addressing(amc) {
+  let accountRow = get_account_tree_row(gPopAccount.key, "am-addressing.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame").contentDocument;
+  let iframe = amc.e("contentFrame").contentDocument;
 
   // By default, 'use global LDAP server preferences' is set, not the
   // 'different LDAP server'.
   let useLDAPdirectory = iframe.getElementById("directories");
   assert_false(useLDAPdirectory.selected);
 
   // So the server selector is disabled.
   let LDAPdirectory = iframe.getElementById("identity.directoryServer");
   assert_true(LDAPdirectory.disabled);
 
   // And the Edit button too.
   let LDAPeditButton = iframe.getElementById("editButton");
   assert_true(LDAPeditButton.disabled);
 
   // Now toggle the 'different LDAP server' on. The server selector
   // and edit button should enable.
-  mc.radio(new elib.Elem(useLDAPdirectory));
+  amc.radio(new elib.Elem(useLDAPdirectory));
   assert_false(LDAPdirectory.disabled);
   assert_false(LDAPeditButton.disabled);
 
   // Lock the pref for the server selector.
   let prefstring = LDAPdirectory.getAttribute("prefstring");
   let controlPref = prefstring.replace("%identitykey%", gPopAccount.defaultIdentity.key);
   Services.prefs.getDefaultBranch("").setBoolPref(controlPref, "xxx");
   Services.prefs.lockPref(controlPref);
 
   // Refresh the pane by switching to another one.
-  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  accountRow = get_account_tree_row(gPopAccount.key, "am-addressing.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-addressing.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
   // Re-assign iframe.contentDocument because it was lost when changing panes
   // (uses loadURI to load a new document).
-  iframe = content_tab_e(tab, "contentFrame").contentDocument;
+  iframe = amc.e("contentFrame").contentDocument;
 
   // We are now back and the 'different LDAP server' should still be selected
   // (the setting was saved).
   useLDAPdirectory = iframe.getElementById("directories");
   assert_true(useLDAPdirectory.selected);
 
   // But now the server selector should be disabled due to locked pref.
   LDAPdirectory = iframe.getElementById("identity.directoryServer");
@@ -210,76 +220,72 @@ function test_locked_prefs_addressing() 
 
   // The edit button still enabled (does not depend on the same pref lock)
   LDAPeditButton = iframe.getElementById("editButton");
   assert_false(LDAPeditButton.disabled);
 
   // Unlock the pref to clean up.
   Services.prefs.unlockPref(controlPref);
   Services.prefs.getDefaultBranch("").deleteBranch(controlPref);
-
-  close_advanced_settings(tab);
 }
 
 /**
- * Test for bug 807101.
- * Check if form controls are properly disabled when their attached prefs are locked.
- *
  * Check that the POP3 'keep on server' settings elements (2-level
  * checkboxes + textbox) are properly disabled when their attached pref
  * (prefstring attribute) is locked.
+ *
+ * @param amc  the account options controller
  */
-function test_locked_prefs_server() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_locked_prefs_server(amc) {
+  let accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame").contentDocument;
+  let iframe = amc.e("contentFrame").contentDocument;
 
   // Top level leaveOnServer checkbox, disabled by default.
   let leaveOnServer = iframe.getElementById("pop3.leaveMessagesOnServer");
   assert_false(leaveOnServer.disabled);
   assert_false(leaveOnServer.checked);
 
   // Second level deleteByAge checkbox, disabled by default.
   let deleteByAge = iframe.getElementById("pop3.deleteByAgeFromServer");
   assert_true(deleteByAge.disabled);
   assert_false(deleteByAge.checked);
 
   // Third level daysToLeave textbox, disabled by default.
   let daysToLeave = iframe.getElementById("pop3.numDaysToLeaveOnServer");
   assert_true(daysToLeave.disabled);
 
   // When leaveOnServer is checked, only deleteByAge will get enabled.
-  mc.check(new elib.Elem(leaveOnServer), true);
+  amc.check(new elib.Elem(leaveOnServer), true);
   assert_true(leaveOnServer.checked);
   assert_false(deleteByAge.disabled);
   assert_true(daysToLeave.disabled);
 
   // When deleteByAge is checked, daysToLeave will get enabled.
-  mc.check(new elib.Elem(deleteByAge), true);
+  amc.check(new elib.Elem(deleteByAge), true);
   assert_true(deleteByAge.checked);
   assert_false(daysToLeave.disabled);
 
   // Lock the pref deleteByAge checkbox (middle of the element hierarchy).
   let prefstring = deleteByAge.getAttribute("prefstring");
   let controlPref = prefstring.replace("%serverkey%", gPopAccount.incomingServer.key);
   Services.prefs.getDefaultBranch("").setBoolPref(controlPref, true);
   Services.prefs.lockPref(controlPref);
 
   // Refresh the pane by switching to another one.
-  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
   // Re-assign iframe.contentDocument because it was lost when changing panes
   // (uses loadURI to load a new document).
-  iframe = content_tab_e(tab, "contentFrame").contentDocument;
+  iframe = amc.e("contentFrame").contentDocument;
 
   // Now leaveOnServer was preserved as checked.
   leaveOnServer = iframe.getElementById("pop3.leaveMessagesOnServer");
   assert_false(leaveOnServer.disabled);
   assert_true(leaveOnServer.checked);
 
   // Now deleteByAge was preserved as checked but is locked/disabled.
   deleteByAge = iframe.getElementById("pop3.deleteByAgeFromServer");
@@ -287,101 +293,114 @@ function test_locked_prefs_server() {
   assert_true(deleteByAge.checked);
 
   // Because deleteByAge is checked, daysToLeave should be enabled.
   daysToLeave = iframe.getElementById("pop3.numDaysToLeaveOnServer");
   assert_false(daysToLeave.disabled);
 
   // When leaveOnserver is unchecked, both of deleteByAge and daysToLeave
   // should get disabled.
-  mc.check(new elib.Elem(leaveOnServer), false);
+  amc.check(new elib.Elem(leaveOnServer), false);
   assert_false(leaveOnServer.disabled);
   assert_false(leaveOnServer.checked);
 
   assert_true(deleteByAge.disabled);
   assert_true(deleteByAge.checked);
   assert_true(daysToLeave.disabled);
 
   // Unlock the pref to clean up.
   Services.prefs.unlockPref(controlPref);
   Services.prefs.getDefaultBranch("").deleteBranch(controlPref);
-
-  close_advanced_settings(tab);
 }
 
 /**
  * Bug 530142.
  * Check that that if one field is set to a value, switching directly to another
  * account pane showing the same field really loads the value from the new account,
  * even when empty. This is tested on the Reply-To field.
  */
 function test_replyTo_leak() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, null, tab);
-  click_account_tree_row(tab, accountRow);
+  open_advanced_settings(function(amc) {
+    subtest_check_replyTo_leak(amc);
+  });
+}
 
-  let iframe = content_tab_e(tab, "contentFrame");
+/**
+ * @param amc  the account options controller
+ */
+function subtest_check_replyTo_leak(amc) {
+  let accountRow = get_account_tree_row(gPopAccount.key, null, amc);
+  click_account_tree_row(amc, accountRow);
+
+  let iframe = amc.window.document.getElementById("contentFrame");
 
   // The Reply-To field should be empty.
   let replyAddress = iframe.contentDocument.getElementById("identity.replyTo");
   assert_equals(replyAddress.value, "");
 
   // Now we set a value into it and switch to another account, the main pane.
   replyAddress.value = "somewhere@else.com";
 
   // This test expects the following POP account to exist by default
   // in the test profile with port number 110 and no security.
   let firstServer = MailServices.accounts
                                 .FindServer("tinderbox", FAKE_SERVER_HOSTNAME, "pop3");
   let firstAccount = MailServices.accounts.FindAccountForServer(firstServer);
 
-  accountRow = get_account_tree_row(firstAccount.key, null, tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(firstAccount.key, null, amc);
+  click_account_tree_row(amc, accountRow);
 
   // the Reply-To field should be empty as this account does not have it set.
   replyAddress = iframe.contentDocument.getElementById("identity.replyTo");
   assert_equals(replyAddress.value, "");
-
-  close_advanced_settings(tab);
 }
 
 /**
  * Test for bug 804091.
  * Check if onchange handlers are properly executed when panes are switched.
  */
 function test_account_onchange_handler() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gImapAccount.key, "am-offline.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  open_advanced_settings(function(amc) {
+    subtest_check_onchange_handler(amc);
+  });
+}
 
-  let iframe = content_tab_e(tab, "contentFrame").contentDocument;
+/**
+ * Check if onchange handlers are properly executed when panes are switched.
+ *
+ * @param amc  the account options controller
+ */
+function subtest_check_onchange_handler(amc) {
+  let accountRow = get_account_tree_row(gImapAccount.key, "am-offline.xul", amc);
+  click_account_tree_row(amc, accountRow);
+
+  let iframe = amc.e("contentFrame").contentDocument;
 
   let autoSync = iframe.getElementById("autosyncValue");
   // 30 is the default value so check if we are in clean state.
   assert_equals(autoSync.value, 30);
 
   let autoSyncInterval = iframe.getElementById("autosyncInterval");
   // 1 is the default value and means the 30 is in days.
   assert_equals(autoSyncInterval.value, 1);
 
   // Now type in 35 (days).
-  mc.radio(new elib.ID(iframe, "useAutosync.ByAge"));
+  amc.radio(new elib.ID(iframe, "useAutosync.ByAge"));
   autoSync.select();
-  mc.type(new elib.Elem(autoSync), "35");
+  amc.type(new elib.Elem(autoSync), "35");
 
   // Immediately switch to another pane and back.
-  accountRow = get_account_tree_row(gImapAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gImapAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  accountRow = get_account_tree_row(gImapAccount.key, "am-offline.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gImapAccount.key, "am-offline.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  iframe = content_tab_e(tab, "contentFrame").contentDocument;
+  iframe = amc.e("contentFrame").contentDocument;
 
   // The pane optimized the entered value a bit. So now we should find 5.
   autoSync = iframe.getElementById("autosyncValue");
   assert_equals(autoSync.value, 5);
 
   // And the unit is 7 days = week.
   autoSyncInterval = iframe.getElementById("autosyncInterval");
   assert_equals(autoSyncInterval.value, 7);
-  close_advanced_settings(tab);
 }
--- a/mail/test/mozmill/account/test-account-tree.js
+++ b/mail/test/mozmill/account/test-account-tree.js
@@ -4,37 +4,29 @@
 
 /**
  * This test checks proper operation of the account tree in the Account manager.
  */
 
 "use strict";
 
 /* import-globals-from ../shared-modules/test-account-manager-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
 
 var MODULE_NAME = "test-account-tree";
 var RELATIVE_ROOT = "../shared-modules";
-var MODULE_REQUIRES = [
-  "folder-display-helpers",
-  "window-helpers",
-  "account-manager-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
-];
+var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers", "account-manager-helpers"];
 
 var gPopAccount, gOriginalAccountCount;
 
 function setupModule(module) {
-  for (let lib of MODULE_REQUIRES) {
-    collector.getModule(lib).installInto(module);
-  }
+  collector.getModule("window-helpers").installInto(module);
+  collector.getModule("folder-display-helpers").installInto(module);
+  collector.getModule("account-manager-helpers").installInto(module);
 
   // There may be pre-existing accounts from other tests.
   gOriginalAccountCount = MailServices.accounts.allServers.length;
 
   // Create a POP server
   let popServer = MailServices.accounts
     .createIncomingServer("nobody", "foo.invalid", "pop3")
     .QueryInterface(Ci.nsIPop3IncomingServer);
@@ -57,114 +49,131 @@ function teardownModule(module) {
   assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
 }
 
 /**
  * Test for bug 536248.
  * Check if the account manager dialog remembers the open state of accounts.
  */
 function test_account_open_state() {
-  subtest_check_account_open_state(true);
-
-  subtest_check_account_open_state(false);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_open_state(amc, true);
+  });
+  open_advanced_settings(function(amc) {
+    subtest_check_account_open_state(amc, false);
+  });
   // After this test all the accounts must be "open".
 }
 
 /**
  * Check if the open state of accounts is in the wished state.
  *
+ * @param amc           The account options controller.
  * @param aWishedState  The open state in which the account row should be found (bool).
  */
-function subtest_check_account_open_state(aWishedState) {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, null, tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_account_open_state(amc, aWishedState) {
+  let accountRow = get_account_tree_row(gPopAccount.key, null, amc);
+  click_account_tree_row(amc, accountRow);
 
   // See if the account row is in the wished open state.
-  let accountTree = content_tab_e(tab, "accounttree");
+  let accountTree = amc.e("accounttree");
   assert_equals(accountRow, accountTree.view.selection.currentIndex);
   assert_equals(accountTree.view.isContainerOpen(accountRow), aWishedState);
 
   accountTree.view.toggleOpenState(accountRow);
   assert_equals(accountTree.view.isContainerOpen(accountRow), !aWishedState);
 
   // Whatever the open state of the account was, selecting one of its subpanes
   // must open it.
-  tab.browser.contentWindow.selectServer(gPopAccount.incomingServer, "am-junk.xul");
-  wait_for_account_tree_selection(tab);
+  amc.window.selectServer(gPopAccount.incomingServer, "am-junk.xul");
   assert_true(accountTree.view.isContainerOpen(accountRow));
 
   // Set the proper state again for continuation of the test.
   accountTree.view.getItemAtIndex(accountRow).setAttribute("open", !aWishedState);
   assert_equals(accountTree.view.isContainerOpen(accountRow), !aWishedState);
-  close_advanced_settings(tab);
 }
 
 /**
  * Bug 740617.
- * Check if the default account is styled in bold and another account is not.
+ * Check if the default account is styled in bold.
+ *
  */
 function test_default_account_highlight() {
-  let tab = open_advanced_settings();
+  open_advanced_settings(function(amc) {
+    subtest_check_default_account_highlight(amc);
+  });
+}
+
+/**
+ * Check if the default account is styled in bold and another account is not.
+ *
+ * @param amc           The account options controller.
+ */
+function subtest_check_default_account_highlight(amc) {
   // Select the default account.
-  let accountRow = get_account_tree_row(MailServices.accounts.defaultAccount.key, null, tab);
-  click_account_tree_row(tab, accountRow);
+  let accountRow = get_account_tree_row(MailServices.accounts.defaultAccount.key, null, amc);
+  click_account_tree_row(amc, accountRow);
 
-  let accountTree = content_tab_e(tab, "accounttree");
+  let accountTree = amc.e("accounttree");
   assert_equals(accountRow, accountTree.view.selection.currentIndex);
   let cell = accountTree.view.getItemAtIndex(accountRow).firstChild.firstChild;
   assert_equals(cell.tagName, "treecell");
 
   // We can't read the computed style of the tree cell directly, so at least see
   // if the isDefaultServer-true property is set on it. Hopefully the proper style
   // is attached to this property.
   let propArray = accountTree.view
     .getCellProperties(accountRow, accountTree.columns.getColumnAt(0)).split(" ");
   assert_true(propArray.includes("isDefaultServer-true"));
 
   // Now select another account that is not default.
-  accountRow = get_account_tree_row(gPopAccount.key, null, tab);
-  click_account_tree_row(tab, accountRow);
+  accountRow = get_account_tree_row(gPopAccount.key, null, amc);
+  click_account_tree_row(amc, accountRow);
 
   // There should isDefaultServer-true on its tree cell.
   propArray = accountTree.view
     .getCellProperties(accountRow, accountTree.columns.getColumnAt(0)).split(" ");
   assert_false(propArray.includes("isDefaultServer-true"));
-  close_advanced_settings(tab);
 }
-
 /**
  * Bug 58713.
  * Check if after deleting an account the next one is selected.
  *
  * This test should always be the last one as it removes our specially
  * created gPopAccount.
  */
 function test_selection_after_account_deletion() {
-  let tab = open_advanced_settings();
+  open_advanced_settings(function(amc) {
+    subtest_check_selection_after_account_deletion(amc);
+  });
+}
+
+/**
+ * Check if after deleting an account the next one is selected.
+ *
+ * @param amc           The account options controller.
+ */
+function subtest_check_selection_after_account_deletion(amc) {
   let accountList = [];
-  let accountTreeNode = content_tab_e(tab, "account-tree-children");
+  let accountTreeNode = amc.e("account-tree-children");
   // Build the list of accounts in the account tree (order is important).
   for (let i = 0; i < accountTreeNode.childNodes.length; i++) {
     if ("_account" in accountTreeNode.childNodes[i]) {
       let curAccount = accountTreeNode.childNodes[i]._account;
       if (!accountList.includes(curAccount))
         accountList.push(curAccount);
     }
   }
 
   // Get position of the current account in the account list.
   let accountIndex = accountList.indexOf(gPopAccount);
 
   // Remove our account.
-  remove_account(gPopAccount, tab);
+  remove_account(gPopAccount, amc);
   // Now there should be only the original accounts left.
   assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
 
   // See if the currently selected account is the one next in the account list.
-  let accountTree = content_tab_e(tab, "accounttree");
+  let accountTree = amc.e("accounttree");
   let accountRow = accountTree.view.selection.currentIndex;
-  wait_for_account_tree_selection(tab, accountRow);
   assert_equals(accountTree.view.getItemAtIndex(accountRow)._account,
                 accountList[accountIndex + 1]);
-
-  close_advanced_settings(tab);
 }
--- a/mail/test/mozmill/account/test-account-values.js
+++ b/mail/test/mozmill/account/test-account-values.js
@@ -5,31 +5,27 @@
 /**
  * This test checks proper operation of the account settings panes
  * when certain special or invalid values are entered into the fields.
  */
 
 "use strict";
 
 /* import-globals-from ../shared-modules/test-account-manager-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
 /* import-globals-from ../shared-modules/test-keyboard-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
 
 var MODULE_NAME = "test-account-values";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = [
   "folder-display-helpers",
   "window-helpers",
   "account-manager-helpers",
   "keyboard-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
 ];
 
 var elib = ChromeUtils.import("chrome://mozmill/content/modules/elementslib.jsm");
 
 var gPopAccount, gOriginalAccountCount;
 
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
@@ -63,43 +59,53 @@ function teardownModule(module) {
 }
 
 /**
  * Bug 208628.
  * Check that if the CC field is empty, enabling CC will automatically
  * prefill the currently default email address.
  */
 function test_default_CC_address() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, "am-copies.xul", tab);
-  click_account_tree_row(tab, accountRow);
+  open_advanced_settings(function(amc) {
+    subtest_check_default_CC_address(amc);
+  });
+}
 
-  let iframe = content_tab_e(tab, "contentFrame");
+/**
+ * Check that if the CC field is empty, enabling CC will automatically
+ * prefill the currently default email address.
+ *
+ * @param amc  the account options controller
+ */
+function subtest_check_default_CC_address(amc) {
+  let accountRow = get_account_tree_row(gPopAccount.key, "am-copies.xul", amc);
+  click_account_tree_row(amc, accountRow);
+
+  let iframe = amc.window.document.getElementById("contentFrame");
 
   let defaultAddress = iframe.contentDocument.getElementById("identity.email").value;
   let ccCheck = iframe.contentDocument.getElementById("identity.doCc");
   let ccAddress = iframe.contentDocument.getElementById("identity.doCcList");
   // The CC checkbox is not enabled and the address value is empty.
   assert_false(ccCheck.checked);
   assert_equals(ccAddress.value, "");
   // After ticking the CC checkbox the default address should be prefilled.
-  mc.check(new elib.Elem(ccCheck), true);
+  amc.check(new elib.Elem(ccCheck), true);
   assert_equals(ccAddress.value, defaultAddress);
 
   let bccCheck = iframe.contentDocument.getElementById("identity.doBcc");
   let bccAddress = iframe.contentDocument.getElementById("identity.doBccList");
   // The BCC checkbox is not enabled but we set the address value to something.
   assert_false(bccCheck.checked);
   assert_equals(bccAddress.value, "");
   let bccUserAddress = "somebody@else.invalid";
   bccAddress.value = bccUserAddress;
   // After ticking the BCC checkbox the current value of the address should not change.
-  mc.check(new elib.Elem(bccCheck), true);
+  amc.check(new elib.Elem(bccCheck), true);
   assert_equals(bccAddress.value, bccUserAddress);
-  close_advanced_settings(tab);
 }
 
 /**
  * Bug 720199.
  * Check if the account name automatically changes when the user changes
  * the username or hostname.
  */
 function test_account_name() {
@@ -122,69 +128,79 @@ function test_account_name() {
   // The automatic account name update works only if the name is
   // in the form of user@host.
   gPopAccount.incomingServer.prettyName = "nobody@example.invalid";
 
   let newHost = "some.host.invalid";
   let newUser = "somebody";
 
   // On NNTP there is no user name so just set new hostname.
-  subtest_check_account_name(nntpAccount, newHost, null);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_name(nntpAccount, newHost, null, amc);
+  });
 
   // And see if the account name is updated to it.
   assert_equals(nntpAccount.incomingServer.prettyName, newHost);
 
   // On POP3 there is both user name and host name.
   // Set new host name first.
-  subtest_check_account_name(gPopAccount, newHost, null);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_name(gPopAccount, newHost, null, amc);
+  });
 
   // And see if in the account name the host part is updated to it.
   assert_equals(gPopAccount.incomingServer.prettyName, "nobody@" + newHost);
 
   // Set new host name first.
-  subtest_check_account_name(gPopAccount, null, newUser);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_name(gPopAccount, null, newUser, amc);
+  });
 
   // And see if in the account name the user part is updated.
   assert_equals(gPopAccount.incomingServer.prettyName, newUser + "@" + newHost);
 
   newHost = "another.host.invalid";
   newUser = "anotherbody";
 
   // Set user name and host name at once.
-  subtest_check_account_name(gPopAccount, newHost, newUser);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_name(gPopAccount, newHost, newUser, amc);
+  });
 
   // And see if in the account name the host part is updated to it.
   assert_equals(gPopAccount.incomingServer.prettyName, newUser + "@" + newHost);
 
   // Now have an account name where the name does not match the hostname.
   gPopAccount.incomingServer.prettyName = newUser + "@example.invalid";
 
   newHost = "third.host.invalid";
   // Set the host name again.
-  subtest_check_account_name(gPopAccount, newHost, null);
+  open_advanced_settings(function(amc) {
+    subtest_check_account_name(gPopAccount, newHost, null, amc);
+  });
 
   // And the account name should not be touched.
   assert_equals(gPopAccount.incomingServer.prettyName, newUser + "@example.invalid");
 
   MailServices.accounts.removeAccount(nntpAccount);
 }
 
 /**
  * Changes the user name and hostname to the supplied values.
  *
  * @param aAccount      the account to change
  * @param aNewHostname  the hostname value to set
  * @param aNewUsername  the username value to set
+ * @param amc           the account options controller
  */
-function subtest_check_account_name(aAccount, aNewHostname, aNewUsername) {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(aAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_account_name(aAccount, aNewHostname, aNewUsername, amc) {
+  let accountRow = get_account_tree_row(aAccount.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame");
+  let iframe = amc.window.document.getElementById("contentFrame");
 
   if (aNewHostname) {
     let hostname = iframe.contentDocument.getElementById("server.realHostName");
     assert_equals(hostname.value, aAccount.incomingServer.realHostName);
 
     // Now change the server host name.
     hostname.value = aNewHostname;
   }
@@ -199,155 +215,155 @@ function subtest_check_account_name(aAcc
 
   if (aNewUsername) {
     // If username has changed, we get a confirmation dialog.
     plan_for_modal_dialog("commonDialog", function(cdc) {
       // Just dismiss it.
       cdc.window.document.documentElement.acceptDialog();
     });
   }
-  // We really need to save the new values.
-  close_advanced_settings(tab);
-
+  // We really need to save the new values so click OK on the Account settings.
+  amc.window.document.documentElement.acceptDialog();
   if (aNewUsername)
     wait_for_modal_dialog("commonDialog");
 }
 
 /**
  * Bug 536768.
  * Check if invalid junk target settings (folders) are fixed to sane values.
  */
 function test_invalid_junk_target() {
   // Set the junk target prefs to invalid values.
   let branch = Services.prefs.getBranch("mail.server." + gPopAccount.incomingServer.key + ".");
   branch.setCharPref("spamActionTargetAccount", "some random non-existent URI");
   branch.setCharPref("spamActionTargetFolder", "some random non-existent URI");
   let moveOnSpam = true;
   branch.setBoolPref("moveOnSpam", moveOnSpam);
-  subtest_check_invalid_junk_target();
+  open_advanced_settings(function(amc) {
+    subtest_check_invalid_junk_target(amc);
+  });
 
   // The pref has no default so its non-existence means it was cleared.
   moveOnSpam = branch.getBoolPref("moveOnSpam", false);
   assert_false(moveOnSpam);
   // The targets should point to the same pop account now.
   let targetAccount = branch.getCharPref("spamActionTargetAccount");
   assert_equals(targetAccount, gPopAccount.incomingServer.serverURI);
   let targetFolder = branch.getCharPref("spamActionTargetFolder");
   assert_equals(targetFolder, gPopAccount.incomingServer.serverURI + "/Junk");
 }
 
 /**
  * Just show the Junk settings pane and let it fix the values.
+ *
+ * @param amc  the account options controller
  */
-function subtest_check_invalid_junk_target() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_invalid_junk_target(amc) {
+  let accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  // We need to save the new fixed values.
-  close_advanced_settings(tab);
+  // We need to save the new fixed values so click OK on the Account settings.
+  amc.window.document.documentElement.acceptDialog();
 }
 
 /**
  * Bug 327812.
  * Checks if invalid server hostnames are not accepted.
  */
-test_invalid_hostname.__force_skip__ = true; // disabled temporarily, bug 1096006
 function test_invalid_hostname() {
   let branch = Services.prefs.getBranch("mail.server." + gPopAccount.incomingServer.key + ".");
   let origHostname = branch.getCharPref("realhostname");
 
-  subtest_check_invalid_hostname(false, origHostname);
-  subtest_check_invalid_hostname(true, origHostname);
+  open_advanced_settings(function(amc) {
+    subtest_check_invalid_hostname(amc, false, origHostname);
+  });
+  open_advanced_settings(function(amc) {
+    subtest_check_invalid_hostname(amc, true, origHostname);
+  });
 
   // The new bad hostname should not have been saved.
   let newHostname = branch.getCharPref("realhostname");
   assert_equals(origHostname, newHostname);
 }
 
 /**
  * Set the hostname to an invalid value and check if it gets fixed.
  *
+ * @param amc                the account options controller
  * @param aExitSettings      Attempt to close the Account settings dialog.
  * @param aOriginalHostname  Original hostname of this server.
  */
-function subtest_check_invalid_hostname(aExitSettings, aOriginalHostname) {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_invalid_hostname(amc, aExitSettings, aOriginalHostname) {
+  let accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame");
+  let iframe = amc.window.document.getElementById("contentFrame");
   let hostname = iframe.contentDocument.getElementById("server.realHostName");
   assert_equals(hostname.value, aOriginalHostname);
 
-  delete_all_existing(mc, new elib.Elem(hostname));
-  input_value(mc, "some_invalid+host&domain*in>invalid", new elib.Elem(hostname));
-
-  // As the hostname is bad, we should get a warning dialog.
-  plan_for_modal_dialog("commonDialog", function(cdc) {
-    // Just dismiss it.
-    cdc.window.document.documentElement.acceptDialog();
-  });
+  hostname.value = "some_invalid+host&domain*in>invalid";
 
   if (!aExitSettings) {
-    let newAccountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", tab);
-    click_account_tree_row(tab, newAccountRow, false);
-    wait_for_modal_dialog("commonDialog");
-    // The load of am-junk was prevented and we are back on the same pane.
-    mc.waitFor(() => tab.browser.contentWindow.pendingAccount == null,
-               "Timeout waiting for pendingAccount to become null");
+    accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xul", amc);
+    click_account_tree_row(amc, accountRow);
+
+    // The invalid hostname should be set back to previous value at this point...
+    accountRow = get_account_tree_row(gPopAccount.key, "am-server.xul", amc);
+    click_account_tree_row(amc, accountRow);
 
-    let tree = content_tab_e(tab, "accounttree");
-    wait_for_frame_load(content_tab_e(tab, "contentFrame"),
-      tab.browser.contentWindow.pageURL(tree.view.getItemAtIndex(accountRow)
-                               .getAttribute("PageTag")));
-    assert_equals(tab.browser.contentWindow.currentPageId, "am-server.xul");
-    iframe = content_tab_e(tab, "contentFrame");
-    // Revert the changes to be able to close AM without warning.
+    // ...let's check that:
+    iframe = amc.window.document.getElementById("contentFrame");
     hostname = iframe.contentDocument.getElementById("server.realHostName");
-    delete_all_existing(mc, new elib.Elem(hostname));
-    input_value(mc, aOriginalHostname, new elib.Elem(hostname));
-    close_advanced_settings(tab);
+    assert_equals(hostname.value, aOriginalHostname);
   } else {
-    // Close the tab to save the changes.
-    // The bad hostname should be automatically reverted.
-    close_advanced_settings(tab);
+    // If the hostname is bad, we should get a warning dialog.
+    plan_for_modal_dialog("commonDialog", function(cdc) {
+      // Just dismiss it.
+      cdc.window.document.documentElement.acceptDialog();
+    });
+
+    // Click OK on the Account settings.
+    amc.window.document.documentElement.acceptDialog();
+
     wait_for_modal_dialog("commonDialog");
   }
 }
 
 /**
  * Bug 1426328.
  * Check that the AM will trim user added spaces around text values.
  */
 const badName = "trailing  space ";
 const badEmail = " leading_space@example.com";
 
 function test_trailing_spaces() {
-  subtest_check_trailing_spaces();
+  open_advanced_settings(function(amc) {
+    subtest_check_trailing_spaces(amc);
+  });
   assert_equals(gPopAccount.incomingServer.prettyName, badName.trim());
   assert_equals(gPopAccount.defaultIdentity.email, badEmail.trim());
 }
 
 /**
  * Check that the AM will trim user added spaces around text values
  * when storing them into the account.
+ *
+ * @param amc  the account options controller
  */
-function subtest_check_trailing_spaces() {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(gPopAccount.key, null, tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_trailing_spaces(amc) {
+  let accountRow = get_account_tree_row(gPopAccount.key, null, amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame");
+  let iframe = amc.window.document.getElementById("contentFrame");
 
   let accountName = iframe.contentDocument.getElementById("server.prettyName");
   let defaultAddress = iframe.contentDocument.getElementById("identity.email");
-  delete_all_existing(mc, new elib.Elem(accountName));
-  delete_all_existing(mc, new elib.Elem(defaultAddress));
-  input_value(mc, badName, new elib.Elem(accountName));
-  input_value(mc, badEmail, new elib.Elem(defaultAddress));
+  delete_all_existing(amc, new elib.Elem(accountName));
+  delete_all_existing(amc, new elib.Elem(defaultAddress));
+  input_value(amc, badName, new elib.Elem(accountName));
+  input_value(amc, badEmail, new elib.Elem(defaultAddress));
 
   assert_equals(accountName.value, badName);
   assert_equals(defaultAddress.value, badEmail);
 
-  // We really need to save the new values.
-  close_advanced_settings(tab);
+  // We really need to save the new values so click OK on the Account settings.
+  amc.window.document.documentElement.acceptDialog();
 }
--- a/mail/test/mozmill/account/test-archive-options.js
+++ b/mail/test/mozmill/account/test-archive-options.js
@@ -2,59 +2,53 @@
  * 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 ../shared-modules/test-account-manager-helpers.js */
 /* import-globals-from ../shared-modules/test-folder-display-helpers.js */
 /* import-globals-from ../shared-modules/test-window-helpers.js */
-/* import-globals-from ../shared-modules/test-content-tab-helpers.js */
-/* import-globals-from ../shared-modules/test-pref-window-helpers.js */
 
 var MODULE_NAME = "test-archive-options";
 var RELATIVE_ROOT = "../shared-modules";
-var MODULE_REQUIRES = [
-  "folder-display-helpers",
-  "window-helpers",
-  "account-manager-helpers",
-  "content-tab-helpers",
-  "pref-window-helpers",
-];
+var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers", "account-manager-helpers"];
 
 var mozmill = ChromeUtils.import("chrome://mozmill/content/modules/mozmill.jsm");
 var controller = ChromeUtils.import("chrome://mozmill/content/modules/controller.jsm");
 var elib = ChromeUtils.import("chrome://mozmill/content/modules/elementslib.jsm");
 
 var defaultIdentity;
 
 function setupModule(module) {
-  for (let lib of MODULE_REQUIRES) {
-    collector.getModule(lib).installInto(module);
-  }
+  let wh = collector.getModule("window-helpers");
+  wh.installInto(module);
+  let fdh = collector.getModule("folder-display-helpers");
+  fdh.installInto(module);
+  let amh = collector.getModule("account-manager-helpers");
+  amh.installInto(module);
 
   defaultIdentity = MailServices.accounts.defaultAccount.defaultIdentity;
 }
 
 /**
  * Check that the archive options button is enabled or disabled appropriately.
  *
+ * @param amc          the account options controller
  * @param aAccountKey  key of the account the check
  * @param isEnabled    true if the button should be enabled, false otherwise
  */
-function subtest_check_archive_options_enabled(aAccountKey, isEnabled) {
-  let tab = open_advanced_settings();
-  let accountRow = get_account_tree_row(aAccountKey, "am-copies.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function subtest_check_archive_options_enabled(amc, aAccountKey, isEnabled) {
+  let accountRow = get_account_tree_row(aAccountKey, "am-copies.xul", amc);
+  click_account_tree_row(amc, accountRow);
 
-  let iframe = content_tab_e(tab, "contentFrame");
+  let iframe = amc.window.document.getElementById("contentFrame");
   let button = iframe.contentDocument.getElementById("archiveHierarchyButton");
 
   assert_equals(button.disabled, !isEnabled);
-  close_advanced_settings(tab);
 }
 
 function test_archive_options_enabled() {
   let defaultAccount = MailServices.accounts.defaultAccount;
   // First, create an IMAP server
   let imapServer = MailServices.accounts
     .createIncomingServer("nobody", "example.com", "imap")
     .QueryInterface(Ci.nsIImapIncomingServer);
@@ -70,22 +64,30 @@ function test_archive_options_enabled() 
 
   // Let the default identity archive to our IMAP folder, to ensure that the
   // archive folder's server is used to determine the enabled/disabled state
   // of the "archive options" button, *not* the incoming server for that
   // identity.
   defaultIdentity.archiveFolder = imapServer.rootFolder.URI;
 
   imapServer.isGMailServer = false;
-  subtest_check_archive_options_enabled(account.key, true);
-  subtest_check_archive_options_enabled(defaultAccount.key, true);
+  open_advanced_settings(function(amc) {
+    subtest_check_archive_options_enabled(amc, account.key, true);
+  });
+  open_advanced_settings(function(amc) {
+    subtest_check_archive_options_enabled(amc, defaultAccount.key, true);
+  });
 
   imapServer.isGMailServer = true;
-  subtest_check_archive_options_enabled(account.key, false);
-  subtest_check_archive_options_enabled(defaultAccount.key, false);
+  open_advanced_settings(function(amc) {
+    subtest_check_archive_options_enabled(amc, account.key, false);
+  });
+  open_advanced_settings(function(amc) {
+    subtest_check_archive_options_enabled(amc, defaultAccount.key, false);
+  });
 
   MailServices.accounts.removeAccount(account);
 }
 
 function subtest_initial_state(identity) {
   plan_for_modal_dialog("archive-options", function(ac) {
     assert_equals(ac.e("archiveGranularity").selectedIndex,
                   identity.archiveGranularity);
@@ -124,51 +126,53 @@ function test_save_archive_options() {
   defaultIdentity.archiveGranularity = 0;
   defaultIdentity.archiveKeepFolderStructure = false;
   subtest_save_state(defaultIdentity, 1, true);
 
   assert_equals(defaultIdentity.archiveGranularity, 1);
   assert_equals(defaultIdentity.archiveKeepFolderStructure, true);
 }
 
-function subtest_check_archive_enabled(archiveEnabled) {
-  let tab = open_advanced_settings();
+function subtest_check_archive_enabled(amc, archiveEnabled) {
   defaultIdentity.archiveEnabled = archiveEnabled;
 
-  click_account_tree_row(tab, 2);
+  click_account_tree_row(amc, 2);
 
-  let iframe = content_tab_e(tab, "contentFrame");
+  let iframe = amc.window.document.getElementById("contentFrame");
   let checkbox = iframe.contentDocument.getElementById("identity.archiveEnabled");
+
   assert_equals(checkbox.checked, archiveEnabled);
-  close_advanced_settings(tab);
 }
 
-test_archive_enabled.__force_skip__ = true; // disabled temporarily, bug 1096006
 function test_archive_enabled() {
-  subtest_check_archive_enabled(true);
+  open_advanced_settings(function(amc) {
+    subtest_check_archive_enabled(amc, true);
+  });
 
-  subtest_check_archive_enabled(false);
+  open_advanced_settings(function(amc) {
+    subtest_check_archive_enabled(amc, false);
+  });
 }
 
-test_disable_archive.__force_skip__ = true; // disabled temporarily, bug 1096006
-function test_disable_archive() {
-  let tab = open_advanced_settings();
+function subtest_disable_archive(amc) {
   defaultIdentity.archiveEnabled = true;
-  click_account_tree_row(tab, 2);
+  click_account_tree_row(amc, 2);
 
-  let iframe = content_tab_e(tab, "contentFrame");
+  let iframe = amc.window.document.getElementById("contentFrame");
   let checkbox = iframe.contentDocument.getElementById("identity.archiveEnabled");
 
   assert_true(checkbox.checked);
   assert_false(checkbox.disabled);
-  mc.click(new elib.Elem(checkbox));
+  amc.click(new elib.Elem(checkbox));
   utils.waitFor(() => !checkbox.checked, "Archive checkbox didn't toggle to unchecked");
-  plan_for_window_close(mc);
-  mc.window.document.getElementById("accountManager").acceptDialog();
+  plan_for_window_close(amc);
+  amc.window.document.getElementById("accountManager").acceptDialog();
   wait_for_window_close();
 
   assert_false(defaultIdentity.archiveEnabled);
-  close_advanced_settings(tab);
 }
 
+function test_disable_archive() {
+  open_advanced_settings(subtest_disable_archive);
+}
 // Disable test on Windows since for some yet unknown reason clicking the checkbox
 // doesn't have the desired result. See bug 1461173 for details.
-// test_disable_archive.EXCLUDED_PLATFORMS = ["winnt"];
+test_disable_archive.EXCLUDED_PLATFORMS = ["winnt"];
--- a/mail/test/mozmill/account/test-mail-account-setup-wizard.js
+++ b/mail/test/mozmill/account/test-mail-account-setup-wizard.js
@@ -33,18 +33,18 @@ var user = {
 
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
     collector.getModule(lib).installInto(module);
   }
 }
 
 // Remove an account in the Account Manager, but not via the UI.
-function remove_account_internal(tab, aAccount, aOutgoing) {
-  let win = tab.browser.contentWindow;
+function remove_account_internal(amc, aAccount, aOutgoing) {
+  let win = amc.window;
 
   try {
     // Remove the account and incoming server
     let serverId = aAccount.incomingServer.serverURI;
     MailServices.accounts.removeAccount(aAccount);
     if (serverId in win.accountArray)
       delete win.accountArray[serverId];
     win.selectServer(null, null);
@@ -85,26 +85,27 @@ function test_mail_account_setup() {
     // XXX: This should probably use a notification, once we fix bug 561143.
     awc.waitFor(() => awc.window.gEmailConfigWizard._currentConfig != null,
                 "Timeout waiting for current config to become non-null",
                 8000, 600);
 
     // Open the advanced settings (Account Manager) to create the account
     // immediately.  We use an invalid email/password so the setup will fail
     // anyway.
-    let tab = open_advanced_settings_from_account_wizard(awc);
-    subtest_verify_account(tab);
+    open_advanced_settings_from_account_wizard(subtest_verify_account, awc);
 
     // Clean up
     Services.prefs.clearUserPref(pref_name);
   });
 }
 
-function subtest_verify_account(tab) {
-  let account = tab.browser.contentWindow.currentAccount;
+function subtest_verify_account(amc) {
+  amc.waitFor(() => amc.window.currentAccount != null,
+              "Timeout waiting for currentAccount to become non-null");
+  let account = amc.window.currentAccount;
   let identity = account.defaultIdentity;
   let incoming = account.incomingServer;
   let outgoing = MailServices.smtp.getServerByKey(identity.smtpServerKey);
 
   let config = {
     "incoming server username": {
       actual: incoming.username, expected: user.email.split("@")[0],
     },
@@ -126,17 +127,17 @@ function subtest_verify_account(tab) {
   try {
     for (let i in config) {
       if (config[i].actual != config[i].expected) {
         throw new Error("Configured " + i + " is " + config[i].actual +
                         ". It should be " + config[i].expected + ".");
       }
     }
   } finally {
-    remove_account_internal(tab, account, outgoing);
+    remove_account_internal(amc, account, outgoing);
   }
 }
 
 /**
  * Make sure that we don't re-set the information we get from the config
  * file if the password is incorrect.
  */
 function test_bad_password_uses_old_settings() {
--- a/mail/test/mozmill/account/test-retest-config.js
+++ b/mail/test/mozmill/account/test-retest-config.js
@@ -96,8 +96,9 @@ function test_re_test_config() {
     assert_true(!awc.e("manual-edit_button").hidden,
       "We're not back to the original state!");
     assert_true(awc.e("advanced-setup_button").hidden,
       "We're not back to the original state!");
 
     close_window(awc);
   });
 }
+
--- a/mail/test/mozmill/shared-modules/test-account-manager-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-account-manager-helpers.js
@@ -1,104 +1,66 @@
 /* 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";
 
 var MODULE_NAME = "account-manager-helpers";
 var RELATIVE_ROOT = "../shared-modules";
-var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers",
-                       "pref-window-helpers", "content-tab-helpers"];
+var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers"];
 
 var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
 var elib = ChromeUtils.import("chrome://mozmill/content/modules/elementslib.jsm");
 
-var wh, fdh, pwh, cth, mc;
+var wh, fdh, mc;
 
 function setupModule() {
   fdh = collector.getModule("folder-display-helpers");
   mc = fdh.mc;
   wh = collector.getModule("window-helpers");
-  pwh = collector.getModule("pref-window-helpers");
-  cth = collector.getModule("content-tab-helpers");
 }
 
 function installInto(module) {
   setupModule();
 
   // Now copy helper functions
   module.open_advanced_settings = open_advanced_settings;
   module.open_advanced_settings_from_account_wizard =
     open_advanced_settings_from_account_wizard;
-  module.close_advanced_settings = close_advanced_settings;
   module.open_mail_account_setup_wizard = open_mail_account_setup_wizard;
   module.click_account_tree_row = click_account_tree_row;
   module.get_account_tree_row = get_account_tree_row;
-  module.wait_for_account_tree_load = wait_for_account_tree_load;
-  module.wait_for_account_tree_selection = wait_for_account_tree_selection;
   module.remove_account = remove_account;
 }
 
 /**
- * Waits until the Account Manager tree fully loads after first open.
- */
-function wait_for_account_tree_load(tab) {
-  mc.waitFor(() => tab.browser.contentWindow.currentAccount != null,
-              "Timeout waiting for currentAccount to become non-null");
-  var tree = cth.content_tab_e(tab, "account-tree-children");
-  mc.waitFor(() => tree.hasAttribute("tree-loaded"),
-              "Timeout waiting for account tree build");
-}
-
-/**
- * Ensure the page is fully loaded (e.g. onInit functions).
+ * Opens the Account Manager.
+ *
+ * @param callback Callback for the modal dialog that is opened.
  */
-function wait_for_account_tree_selection(tab, index = -1) {
-  utils.waitFor(() => tab.browser.contentWindow.pendingAccount == null,
-                "Timeout waiting for pendingAccount to become null");
+function open_advanced_settings(aCallback, aController) {
+  if (aController === undefined)
+    aController = mc;
 
-  var tree = cth.content_tab_e(tab, "accounttree");
-  if (index < 0)
-    index = tree.view.selection.currentIndex;
-  wh.wait_for_frame_load(cth.content_tab_e(tab, "contentFrame"),
-    tab.browser.contentWindow.pageURL(tree.view.getItemAtIndex(index)
-                             .getAttribute("PageTag")));
-}
-
-/**
- * Opens the Account Manager pane in pre Preferences tab.
- */
-function open_advanced_settings() {
-  var tab = pwh.open_pref_tab("paneAccount");
-  wait_for_account_tree_load(tab);
-  return tab;
+  wh.plan_for_modal_dialog("mailnews:accountmanager", aCallback);
+  aController.click(mc.eid("menu_accountmgr"));
+  return wh.wait_for_modal_dialog("mailnews:accountmanager");
 }
 
 /**
  * Opens the Account Manager from the mail account setup wizard.
  *
- * @param aController Controller of the Account Wizard window.
+ * @param callback Callback for the modal dialog that is opened.
  */
-function open_advanced_settings_from_account_wizard(aController) {
+function open_advanced_settings_from_account_wizard(aCallback, aController) {
+  wh.plan_for_modal_dialog("mailnews:accountmanager", aCallback);
   aController.e("manual-edit_button").click();
   aController.e("advanced-setup_button").click();
-  var tabmail = mc.e("tabmail");
-  tabmail.selectTabByMode("preferencesTab");
-  var tab;
-  mc.waitFor(
-    () => (tab = tabmail.getTabInfoForCurrentOrFirstModeInstance(
-           tabmail.tabModes.preferencesTab)) != null,
-             "Couldn't find the Preferences tab with the Account manager");
-  wait_for_account_tree_load(tab);
-  return tab;
-}
-
-function close_advanced_settings(tab) {
-  pwh.close_pref_tab(tab);
+  return wh.wait_for_modal_dialog("mailnews:accountmanager");
 }
 
 /**
  * Use File > New > Mail Account to open the Mail Account Setup Wizard.
  *
  * @param aCallback  Function to run once the dialog is open. The function
  *                   gets the new window controller passed as first argument.
  */
@@ -106,51 +68,52 @@ function open_mail_account_setup_wizard(
   wh.plan_for_modal_dialog("mail:autoconfig", aCallback);
   mc.click(new elib.Elem(mc.menus.menu_File.menu_New.newMailAccountMenuItem));
   return wh.wait_for_modal_dialog("mail:autoconfig", 30000);
 }
 
 /**
  * Click a row in the account settings tree
  *
- * @param tab       the account settings tab
- * @param rowIndex  the row to click
- * @param wait      whether to wait for finishing the load
+ * @param controller the Mozmill controller for the account settings dialog
+ * @param rowIndex the row to click
  */
-function click_account_tree_row(tab, rowIndex, wait = true) {
-  utils.waitFor(() => tab.browser.contentWindow.getCurrentAccount() != null,
+function click_account_tree_row(controller, rowIndex) {
+  utils.waitFor(() => controller.window.currentAccount != null,
                 "Timeout waiting for currentAccount to become non-null");
 
-  let tree = cth.content_tab_e(tab, "accounttree");
+  let tree = controller.window.document.getElementById("accounttree");
 
-  fdh.click_tree_row(tree, rowIndex, mc);
+  fdh.click_tree_row(tree, rowIndex, controller);
 
-  if (!wait)
-    return;
+  utils.waitFor(() => controller.window.pendingAccount == null,
+                "Timeout waiting for pendingAccount to become null");
 
-  wait_for_account_tree_selection(tab, rowIndex);
+  // Ensure the page is fully loaded (e.g. onInit functions).
+  wh.wait_for_frame_load(controller.e("contentFrame"),
+    controller.window.pageURL(tree.view.getItemAtIndex(rowIndex)
+                                              .getAttribute("PageTag")));
 }
 
 /**
  * Returns the index of the row in account tree corresponding to the wanted
  * account and its settings pane.
  *
  * @param aAccountKey  The key of the account to return.
  *                     If 'null', the SMTP pane is returned.
  * @param aPaneId      The ID of the account settings pane to select.
- * @param tab          the account settings tab
  *
  * @return  The row index of the account and pane. If it was not found return -1.
  *          Do not throw as callers may intentionally just check if a row exists.
  *          Just dump into the log so that a subsequent throw in
  *          click_account_tree_row has a useful context.
  */
-function get_account_tree_row(aAccountKey, aPaneId, tab) {
+function get_account_tree_row(aAccountKey, aPaneId, aController) {
   let rowIndex = 0;
-  let accountTreeNode = cth.content_tab_e(tab, "account-tree-children");
+  let accountTreeNode = aController.e("account-tree-children");
 
   for (let i = 0; i < accountTreeNode.childNodes.length; i++) {
     if ("_account" in accountTreeNode.childNodes[i]) {
       let accountHead = accountTreeNode.childNodes[i];
       if (aAccountKey == accountHead._account.key) {
         // If this is the wanted account, find the wanted settings pane.
         let accountBlock = accountHead.querySelectorAll("[PageTag]");
         // A null aPaneId means the main pane.
@@ -180,43 +143,37 @@ function get_account_tree_row(aAccountKe
   dump("The treerow for account " + aAccountKey + " was not found!\n");
   return -1;
 }
 
 /**
  * Remove an account via the account manager UI.
  *
  * @param aAccount        The account to remove.
- * @param tab             The account settings tab.
+ * @param aController     The controller of the account manager window.
  * @param aRemoveAccount  Remove the account itself.
  * @param aRemoveData     Remove the message data of the account.
  */
-function remove_account(aAccount, tab, aRemoveAccount = true, aRemoveData = false) {
-  let accountRow = get_account_tree_row(aAccount.key, "am-server.xul", tab);
-  click_account_tree_row(tab, accountRow);
+function remove_account(aAccount, aController, aRemoveAccount = true, aRemoveData = false) {
+  let accountRow = get_account_tree_row(aAccount.key, "am-server.xul", aController);
+  click_account_tree_row(aController, accountRow);
 
   wh.plan_for_modal_dialog("removeAccountDialog", function(cdc) {
     // Account removal confirmation dialog. Select what to remove.
     if (aRemoveAccount)
       cdc.click(new elib.Elem(cdc.window.document.getElementById("removeAccount")));
     if (aRemoveData)
       cdc.click(new elib.Elem(cdc.window.document.getElementById("removeData")));
 
     cdc.window.document.documentElement.acceptDialog();
     cdc.waitFor(() => !cdc.window.document.documentElement.getButton("accept").disabled,
                 "Timeout waiting for finish of account removal",
                 5000, 100);
     cdc.window.document.documentElement.acceptDialog();
   });
 
-  let treeBuilt = false;
-  cth.content_tab_e(tab, "account-tree-children")
-     .addEventListener("account-tree-built", () => { treeBuilt = true; },
-                       {once: true});
-
   // Use the Remove item in the Account actions menu.
-  mc.click(cth.content_tab_eid(tab, "accountActionsButton"));
-  mc.click_menus_in_sequence(cth.content_tab_e(tab, "accountActionsDropdown"),
+  aController.click(aController.eid("accountActionsButton"));
+  aController.click_menus_in_sequence(aController.e("accountActionsDropdown"),
                                       [ {id: "accountActionsDropdownRemove"} ]);
   wh.wait_for_modal_dialog("removeAccountDialog");
-  mc.waitFor(() => treeBuilt, "Timeout waiting for account tree rebuild");
-  wait_for_account_tree_selection(tab);
+  // TODO: For unknown reason this also closes the whole account manager.
 }
--- a/mail/test/mozmill/shared-modules/test-pref-window-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-pref-window-helpers.js
@@ -47,11 +47,10 @@ function open_pref_tab(aPaneID) {
 }
 
 /**
  * Close the preferences tab.
  *
  * @param aTab  The content tab to close.
  */
 function close_pref_tab(aTab) {
-  fdh.assert_true(aTab, "No Preferences tab specified for closing");
   fdh.mc.tabmail.closeTab(aTab);
 }
--- a/mail/themes/linux/mail/accountManage.css
+++ b/mail/themes/linux/mail/accountManage.css
@@ -2,31 +2,20 @@
  * 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://global/skin/in-content/common.css");
-@import url("chrome://messenger/skin/preferences/aboutPreferences.css");
+@import url("chrome://messenger/content/bindings.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;
@@ -53,54 +42,53 @@ 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 :::::: */
 
-#smtpList {
-  margin-inline-start: 6px;
+.smtpServerListItem {
+  padding-inline-start: 3px;
 }
 
 #backgroundBox {
-  background-color: var(--in-content-box-background);
+  background-color: #FFFFFF;
+  opacity: 0.5;
 }
 
 #smtpServerInfoBox {
-  background-color: var(--in-content-box-background);
-  margin: 0 6px 5px;
-}
-
-#smtpServerInfoBox label {
-  height: 30px;
-  padding-top: 5px;
-  margin-top: 0;
-  margin-bottom: 0;
+  border: 1px solid ThreeDShadow;
+  border-right-color: ThreeDHighlight;
+  border-bottom-color: ThreeDHighlight;
+  margin: 0 5px 5px;
 }
 
 #smtpServerInfoBox textbox {
-  background-color: transparent !important;
+  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);
+  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,23 +24,16 @@ 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;
-}
-
 html|input[type="number"]::-moz-number-spin-up {
   min-height: 10px;
 }
 
 html|input[type="number"]::-moz-number-spin-down {
   min-height: 11px;
 }
 
--- a/mail/themes/osx/mail/accountManage.css
+++ b/mail/themes/osx/mail/accountManage.css
@@ -2,31 +2,20 @@
  * 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://global/skin/in-content/common.css");
-@import url("chrome://messenger/skin/preferences/aboutPreferences.css");
+@import url("chrome://messenger/content/bindings.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;
@@ -39,19 +28,18 @@ page groupbox {
 #am-main-title, .dialogheader {
   display: none;
 }
 
 .dialog-button[dlgtype="help"] {
   display: none;
 }
 
-#accountActionsButton {
-  margin-left: 0;
-  margin-right: 0;
+#accounttree {
+  margin-inline-end: 8px;
 }
 
 #accountActionsDropdown {
   min-width: 30ch;
 }
 
 listitem[default="true"],
 #identitiesList > listitem:first-child,
@@ -84,43 +72,40 @@ 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;
 }
 
-#smtpList {
-  margin-inline-start: 6px;
-}
-
-#backgroundBox {
-  background-color: var(--in-content-box-background);
+#archiveTree > treechildren {
+  background-color: #FFFFFF;
 }
 
 #smtpServerInfoBox {
-  background-color: var(--in-content-box-background);
-  margin: 0 6px 5px;
-}
-
-#smtpServerInfoBox label {
-  height: 30px;
-  padding-top: 5px;
-  margin-top: 0;
-  margin-bottom: 0;
+  border: 1px solid ThreeDShadow;
+  border-right-color: ThreeDHighlight;
+  border-bottom-color: ThreeDHighlight;
+  margin: 0 5px 5px;
 }
 
 /* ::::: 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);
+  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
@@ -46,26 +46,16 @@ 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,13 +1,12 @@
 /* - 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);
 }
@@ -45,42 +44,32 @@ 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;
 }
 
 /* Web search menulist */
 #defaultWebSearch > .menulist-label-box > .menulist-icon[src] {
@@ -319,59 +308,16 @@ 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;
@@ -565,17 +511,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) !important;
+  background-color: var(--in-content-item-selected);
   color: var(--in-content-selected-text) !important;
 }
 
 #messengerLanguagesDialogPane {
   min-height: 360px;
 }
 
 #defaultMessengerLanguage {
@@ -605,29 +551,16 @@ 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,31 +2,20 @@
  * 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://global/skin/in-content/common.css");
-@import url("chrome://messenger/skin/preferences/aboutPreferences.css");
+@import url("chrome://messenger/content/bindings.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;
@@ -53,54 +42,53 @@ 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 :::::: */
 
-#smtpList {
-  margin-inline-start: 6px;
+.smtpServerListItem {
+  padding-inline-start: 3px;
 }
 
 #backgroundBox {
-  background-color: var(--in-content-box-background);
+  background-color: #FFFFFF;
+  opacity: 0.5;
 }
 
 #smtpServerInfoBox {
-  background-color: var(--in-content-box-background);
-  margin: 0 6px 5px;
-}
-
-#smtpServerInfoBox label {
-  height: 30px;
-  padding-top: 5px;
-  margin-top: 0;
-  margin-bottom: 0;
+  border: 1px solid ThreeDShadow;
+  border-right-color: ThreeDHighlight;
+  border-bottom-color: ThreeDHighlight;
+  margin: 0 5px 5px;
 }
 
 #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);
+  margin: 0 !important;
+  font-size: larger;
+  font-weight: bold;
 }
--- a/mail/themes/windows/mail/messenger.css
+++ b/mail/themes/windows/mail/messenger.css
@@ -897,16 +897,18 @@ 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;
   margin-top: 1em;
   padding: 3px 0 6px;
 }
 
 groupbox > .groupbox-title > .header {
   font-weight: normal;
   margin-top: -1em;
--- a/mailnews/base/prefs/content/AccountManager.js
+++ b/mailnews/base/prefs/content/AccountManager.js
@@ -32,26 +32,22 @@
 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");
 
-var inContent = !!document.getElementById("paneAccount");
-
-if (!inContent) {
-  document.addEventListener("dialogcancel", onNotAccept);
-  document.addEventListener("dialogaccept", (event) => {
-    if (!onAccept(true)) {
-      event.preventDefault();
-    }
-  });
-}
+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.
@@ -119,79 +115,46 @@ 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) {
@@ -255,42 +218,50 @@ function replaceWithDefaultSmtpServer(de
                                           "smtpServerKey", null, false);
       if (smtpServerKey == deletedSmtpServerKey)
         setAccountValue(accountValues, "identity", "smtpServerKey", "");
     }
   }
 }
 
 /**
- * Called when all the changes should be really saved
- * (e.g. OK was clicked in the dialog, or the Preferences tab closed).
+ * Called when OK is clicked on the dialog.
  *
- * @param abortOnFailure  If true, return without saving if data checks didn't pass.
+ * @param aDoChecks  If true, execute checks on data, otherwise hope they
+ *                   were already done elsewhere and proceed directly to saving
+ *                   the data.
  */
-function onAccept(abortOnFailure) {
+function onAccept(aDoChecks) {
+  if (aDoChecks) {
+    // Check if user/host have been modified correctly.
+    if (!checkUserServerChanges(true))
+      return false;
+
+    if (!checkAccountNameIsValid())
+      return false;
+  }
+
   // Run checks as if the page was being left.
-  if (currentAccount && ("onLeave" in top.frames.contentFrame)) {
-    if (!top.frames.contentFrame.onLeave(!abortOnFailure)) {
+  if ("onLeave" in top.frames.contentFrame) {
+    if (!top.frames.contentFrame.onLeave()) {
       // Prevent closing Account manager if user declined the changes.
-      if (abortOnFailure)
-        return false;
+      return false;
     }
   }
 
-  if (!onSave() && abortOnFailure)
+  if (!onSave())
     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
-    if (abortOnFailure)
-      return !gRestartNeeded;
+    return !gRestartNeeded;
   }
 
   return true;
 }
 
 /**
  * Runs when Cancel button is used.
  *
@@ -507,20 +478,21 @@ 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 restoreValuesOnFailure  show and alert if a problem with the host / user name is found
+ * @param showAlert  show and alert if a problem with the host / user name is found
  */
-function checkUserServerChanges(restoreValuesOnFailure) {
+function checkUserServerChanges(showAlert) {
   const prefBundle = document.getElementById("bundle_prefs");
   const alertTitle = prefBundle.getString("prefPanel-server");
   var alertText = null;
 
   var accountValues = getValueArrayFor(currentAccount);
   if (!accountValues)
     return true;
 
@@ -529,34 +501,31 @@ function checkUserServerChanges(restoreV
   // 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)
-    return true;
-
+  if (typeElem && userElem && hostElem) {
   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)) {
@@ -569,128 +538,107 @@ function checkUserServerChanges(restoreV
       } 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) {
-      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 (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;
     }
 
     // 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.
-    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 (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");
 
-    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");
-    let alertText = prefBundle.getFormattedString("localDirectoryChanged", [brandName]);
+    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 true;
+      return false;
     }
     gRestartNeeded = true;
   }
 
   return true;
 }
 
 /**
  * If account name is not valid, alert the user.
  */
-function checkAccountNameIsValid(restoreValuesOnFailure) {
+function checkAccountNameIsValid() {
   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() {
@@ -1059,48 +1007,60 @@ 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 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;
-  }
+  // Provide opportunity to do cleanups or checks when the current page is being left.
+  if ("onLeave" in top.frames.contentFrame)
+    top.frames.contentFrame.onLeave();
 
   // save the previous page
   savePage(currentAccount);
 
-  if (gRestartNeeded)
-    onAccept(false);
+  let changeAccount = (account != currentAccount);
 
-  let changeAccount = (account != currentAccount);
+  if (changeView)
+    selectServer(account.incomingServer, pageId);
 
   if (pageId != currentPageId) {
     // loading a complete different page
 
     // prevent overwriting with bad stuff
     currentAccount = currentPageId = null;
 
     pendingAccount = account;
@@ -1115,20 +1075,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 the page.
+    // the prefs. to do this, clear out the the old entry in
+    // the account data, and then restore theh page
     if (pageId == currentPageId) {
       var serverId = currentAccount ?
                      currentAccount.incomingServer.serverURI :
                      "global";
       delete accountArray[serverId];
       restorePage(currentPageId, currentAccount);
     }
   } else {
@@ -1512,17 +1472,16 @@ 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 = [];
@@ -1645,17 +1604,10 @@ 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,54 +1,93 @@
 <?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();"
+        onload="onLoad(event);"
         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,16 +47,18 @@ 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"?>
-<?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/. -->
+
 <?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,17 +1,16 @@
 /* -*- 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
 
@@ -222,52 +221,45 @@ 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 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.
+ * @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.
  */
-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;
+function MsgAccountManager(selectPage, aServer) {
+  var existingAccountManager = Services.wm.getMostRecentWindow("mailnews:accountmanager");
+
+  if (existingAccountManager) {
+    existingAccountManager.focus();
+  } 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 (AppConstants.MOZ_APP_NAME == "thunderbird") {
-    // Load the Account Manager in a tab.
-    openPreferencesTab("paneAccount", aServer ? aServer.key : null, aSelectPage);
-  } else {
-    // 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,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://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/accountManage.css" type="text/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/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,16 +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/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,21 +70,17 @@ 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,
-               width: window.arguments[0].width,
-               height: window.arguments[0].height,
-               result: false };
+  let args = { identity, account: gAccount, 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,16 +1,17 @@
 <?xml version="1.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/. -->
 
-<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
-<?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
-
 <!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,19 +15,26 @@ 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 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";
+  // 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";
+  }
 
   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,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://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,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/. -->
+   - 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,35 +24,27 @@ 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,
-               width: document.documentElement.clientWidth,
-               height: document.documentElement.clientHeight,
-               result: false };
+  var args = { account: gAccount, accountName, 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,18 +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/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(restoreValuesOnFailure) {
+function onLeave() {
   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,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://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,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://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/accountManage.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,21 +115,16 @@ 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,16 +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 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,21 +68,16 @@ 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,15 +1,14 @@
 <?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,15 +1,14 @@
 <?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,15 +1,16 @@
 <?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,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://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,20 +75,18 @@
 
           <radio id="encrypt_mail_always" wsm_persist="true" value="2"
                  label="&alwaysEncryptMessage.label;"
                  accesskey="&alwaysEncryptMessage.accesskey;"/>
         </radiogroup>
       </groupbox>
 
       <!-- Certificate manager -->
-      <groupbox id="smimeCertificateManager">
+      <groupbox id="smimeCertificateManager" orient="horizontal">
         <label class="header">&certificates.label;</label>
-        <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>
+        <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"/>
       </groupbox>
     </vbox>
--- a/mailnews/jar.mn
+++ b/mailnews/jar.mn
@@ -10,19 +10,17 @@ 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)
-#ifdef MOZ_SUITE
-    content/messenger/AccountManager.xul                                       (base/prefs/content/AccountManager.xul)
-#endif
+*   content/messenger/AccountManager.xul                                       (base/prefs/content/AccountManager.xul)
     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)