Bug 1600369 - Restructure all <xul:dialog> usages such that they are not the top level element in mail/. r=mkmelin
authorKhushil Mistry <khushil324@gmail.com>
Wed, 11 Dec 2019 17:30:26 +1300
changeset 37731 4fdb9c85df1fa282053f122f4fe90fb869a7215e
parent 37730 076379af5446a147ee5a053693168bdda3a37884
child 37732 e5511e03843275c543c738989bf097f4b3b52350
push id397
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:16:13 +0000
reviewersmkmelin
bugs1600369
Bug 1600369 - Restructure all <xul:dialog> usages such that they are not the top level element in mail/. r=mkmelin
mail/base/content/newTagDialog.js
mail/base/content/newTagDialog.xul
mail/base/content/profileDowngrade.js
mail/base/content/profileDowngrade.xul
mail/base/content/safeMode.js
mail/base/content/safeMode.xul
mail/base/content/sanitize.xul
mail/base/content/sanitizeDialog.js
mail/base/content/systemIntegrationDialog.js
mail/base/content/systemIntegrationDialog.xul
mail/components/addrbook/content/abCard.js
mail/components/addrbook/content/abEditCardDialog.xul
mail/components/addrbook/content/abEditListDialog.xul
mail/components/addrbook/content/abMailListDialog.xul
mail/components/addrbook/content/abNewCardDialog.xul
mail/components/cloudfile/content/selectDialog.xul
mail/components/compose/content/dialogs/EdAdvancedEdit.js
mail/components/compose/content/dialogs/EdAdvancedEdit.xul
mail/components/compose/content/dialogs/EdColorPicker.js
mail/components/compose/content/dialogs/EdColorPicker.xul
mail/components/compose/content/dialogs/EdColorProps.xul
mail/components/compose/content/dialogs/EdConvertToTable.xul
mail/components/compose/content/dialogs/EdDictionary.xul
mail/components/compose/content/dialogs/EdHLineProps.xul
mail/components/compose/content/dialogs/EdImageDialog.js
mail/components/compose/content/dialogs/EdImageLinkLoader.js
mail/components/compose/content/dialogs/EdImageProps.xul
mail/components/compose/content/dialogs/EdInsSrc.js
mail/components/compose/content/dialogs/EdInsSrc.xul
mail/components/compose/content/dialogs/EdInsertChars.js
mail/components/compose/content/dialogs/EdInsertChars.xul
mail/components/compose/content/dialogs/EdInsertMath.js
mail/components/compose/content/dialogs/EdInsertMath.xul
mail/components/compose/content/dialogs/EdInsertTOC.xul
mail/components/compose/content/dialogs/EdInsertTable.js
mail/components/compose/content/dialogs/EdInsertTable.xul
mail/components/compose/content/dialogs/EdLinkProps.xul
mail/components/compose/content/dialogs/EdListProps.xul
mail/components/compose/content/dialogs/EdNamedAnchorProps.js
mail/components/compose/content/dialogs/EdNamedAnchorProps.xul
mail/components/compose/content/dialogs/EdReplace.xul
mail/components/compose/content/dialogs/EdSpellCheck.xul
mail/components/compose/content/dialogs/EdTableProps.js
mail/components/compose/content/dialogs/EdTableProps.xul
mail/components/im/content/addbuddy.js
mail/components/im/content/addbuddy.xul
mail/components/im/content/joinchat.xul
mail/components/preferences/applicationManager.xul
mail/components/preferences/attachmentReminder.xul
mail/components/preferences/colors.xul
mail/components/preferences/connection.xul
mail/components/preferences/dockoptions.xul
mail/components/preferences/fonts.xul
mail/components/preferences/messengerLanguages.xul
mail/components/preferences/notifications.xul
mail/components/preferences/offline.xul
mail/components/preferences/receipts.xul
mail/components/preferences/sendoptions.xul
mail/extensions/mailviews/content/mailViewList.xul
mail/extensions/mailviews/content/mailViewSetup.js
mail/extensions/mailviews/content/mailViewSetup.xul
mail/extensions/openpgp/content/ui/enigmailMsgBox.xul
mail/extensions/openpgp/content/ui/keyDetailsDlg.js
mail/extensions/openpgp/content/ui/keyDetailsDlg.xul
mail/test/mozmill/account/test-account-values.js
mail/test/mozmill/attachment/test-attachment.js
mail/test/mozmill/composition/test-attachment-reminder.js
mail/test/mozmill/composition/test-attachment.js
mail/test/mozmill/composition/test-forward-headers.js
mail/test/mozmill/composition/test-image-insertion-dialog.js
mail/test/mozmill/composition/test-multipart-related.js
mail/test/mozmill/content-policy/test-compose-mailto.js
mail/test/mozmill/content-policy/test-general-content-policy.js
mail/test/mozmill/content-tabs/test-content-tab.js
mail/test/mozmill/folder-display/test-columns.js
mail/test/mozmill/folder-display/test-message-commands.js
mail/test/mozmill/folder-display/test-message-window.js
mail/test/mozmill/folder-pane/test-folder-pane-consumers.js
mail/test/mozmill/message-header/test-phishing-bar.js
mail/test/mozmill/message-window/test-vcard-actions.js
mail/test/mozmill/search-window/test-search-window.js
mail/test/mozmill/shared-modules/AccountManagerHelpers.jsm
mail/test/mozmill/shared-modules/AddressBookHelpers.jsm
mail/test/mozmill/shared-modules/ComposeHelpers.jsm
--- a/mail/base/content/newTagDialog.js
+++ b/mail/base/content/newTagDialog.js
@@ -15,17 +15,17 @@ var dialog;
  * Pass in keyToEdit as a window argument to turn this dialog into an edit
  * tag dialog.
  */
 function onLoad() {
   let windowArgs = window.arguments[0];
 
   dialog = {};
 
-  dialog.OKButton = document.documentElement.getButton("accept");
+  dialog.OKButton = document.querySelector("dialog").getButton("accept");
   dialog.nameField = document.getElementById("name");
   dialog.nameField.focus();
 
   // call this when OK is pressed
   dialog.okCallback = windowArgs.okCallback;
   if (windowArgs.keyToEdit) {
     initializeForEditing(windowArgs.keyToEdit);
     document.addEventListener("dialogaccept", onOKEditTag);
--- a/mail/base/content/newTagDialog.xul
+++ b/mail/base/content/newTagDialog.xul
@@ -2,22 +2,23 @@
 
 <!-- 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"?>
 <?xml-stylesheet type="text/css" href="chrome://messenger/skin/input-fields.css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/newTagDialog.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/newTagDialog.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         title="&newTagDialog1.title;"
         onload="onLoad();">
+<dialog>
 
   <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/newTagDialog.js"/>
   <label id="nameLabel"
          value="&name.label;"
@@ -28,8 +29,9 @@
                 type="text"
                 oninput="doEnabling();"
                 class="input-inline"
                 aria-labelledby="nameLabel"/>
     <html:input type="color" id="tagColorPicker"/>
   </hbox>
   <separator/>
 </dialog>
+</window>
--- a/mail/base/content/profileDowngrade.js
+++ b/mail/base/content/profileDowngrade.js
@@ -18,17 +18,20 @@ function init() {
    *  1: A return argument, one of nsIToolkitProfileService.downgradeUIChoice.
    */
   gParams = window.arguments[0].QueryInterface(Ci.nsIDialogParamBlock);
 
   document.addEventListener("dialogextra1", createProfile);
   document.addEventListener("dialogaccept", quit);
   document.addEventListener("dialogcancel", quit);
 
-  document.documentElement.getButton("accept").focus();
+  document
+    .querySelector("dialog")
+    .getButton("accept")
+    .focus();
 }
 
 function quit() {
   gParams.SetInt(1, Ci.nsIToolkitProfileService.quit);
 }
 
 function createProfile() {
   gParams.SetInt(1, Ci.nsIToolkitProfileService.createNewProfile);
--- a/mail/base/content/profileDowngrade.xul
+++ b/mail/base/content/profileDowngrade.xul
@@ -1,26 +1,26 @@
 <?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/global.css" type="text/css"?>
 <?xml-stylesheet href="chrome://mozapps/skin/profile/profileDowngrade.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 %brandDTD;
 <!ENTITY % profileDTD SYSTEM "chrome://mozapps/locale/profile/profileDowngrade.dtd">
 %profileDTD;
 ]>
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="&window.title;" onload="init()" style="&window.style;"
-        buttonlabelextra1="&window.create;"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        title="&window.title;" onload="init()" style="&window.style;">
+<dialog buttonlabelextra1="&window.create;"
 #ifdef XP_WIN
         buttonlabelaccept="&window.quit-win;"
 #else
         buttonlabelaccept="&window.quit-nonwin;"
 #endif
         buttons="accept,extra1" buttonpack="end"
         nobuttonspacer="true">
 
@@ -35,8 +35,9 @@
         <label class="text-link" value="&window.moreinfo;"
                onclick="moreInfo(event)"
                onkeypress="moreInfo(event)"/>
       </hbox>
     </vbox>
   </hbox>
 
 </dialog>
+</window>
--- a/mail/base/content/safeMode.js
+++ b/mail/base/content/safeMode.js
@@ -70,12 +70,12 @@ function onCancel() {
 
 function onLoad() {
   document
     .getElementById("tasks")
     .addEventListener("CheckboxStateChange", updateOKButtonState);
 }
 
 function updateOKButtonState() {
-  document.documentElement.getButton("accept").disabled =
+  document.querySelector("dialog").getButton("accept").disabled =
     !document.getElementById("resetToolbars").checked &&
     !document.getElementById("disableAddons").checked;
 }
--- a/mail/base/content/safeMode.xul
+++ b/mail/base/content/safeMode.xul
@@ -1,42 +1,42 @@
 <?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/. -->
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 %brandDTD;
 <!ENTITY % safeModeDTD SYSTEM "chrome://messenger/locale/safeMode.dtd">
 %safeModeDTD;
 <!ENTITY % utilityDTD SYSTEM "chrome://communicator/locale/utilityOverlay.dtd">
 %utilityDTD;
 ]>
 
 <?xml-stylesheet href="chrome://global/skin/"?>
 
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        title="&safeModeDialog.title;"
+        width="&window.width;"
+        onload="onLoad();">
 <dialog id="safeModeDialog"
-            xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-            title="&safeModeDialog.title;"
-            buttons="accept,cancel,extra1"
-            buttonlabelaccept="&changeAndRestartButton.label;"
-            buttonaccesskeyaccept="&changeAndRestartButton.accesskey;"
+        buttons="accept,cancel,extra1"
+        buttonlabelaccept="&changeAndRestartButton.label;"
+        buttonaccesskeyaccept="&changeAndRestartButton.accesskey;"
 #ifdef XP_WIN
-            buttonlabelcancel="&quitApplicationCmd.label;"
-            buttonaccesskeycancel="&quitApplicationCmd.accesskey;"
+        buttonlabelcancel="&quitApplicationCmd.label;"
+        buttonaccesskeycancel="&quitApplicationCmd.accesskey;"
 #else
-            buttonlabelcancel="&quitApplicationCmdUnix.label;"
-            buttonaccesskeycancel="&quitApplicationCmdUnix.accesskey;"
+        buttonlabelcancel="&quitApplicationCmdUnix.label;"
+        buttonaccesskeycancel="&quitApplicationCmdUnix.accesskey;"
 #endif
-            buttonlabelextra1="&continueButton.label;"
-            buttonaccesskeyextra1="&continueButton.accesskey;"
-            width="&window.width;"
-            onload="onLoad();"
-            buttondisabledaccept="true">
+        buttonlabelextra1="&continueButton.label;"
+        buttonaccesskeyextra1="&continueButton.accesskey;"
+        buttondisabledaccept="true">
 
   <script src="chrome://messenger/content/safeMode.js"/>
 
   <stringbundle id="preferencesBundle" src="chrome://messenger/locale/preferences/preferences.properties"/>
 
   <description>&safeModeDescription.label;</description>
 
   <separator class="thin"/>
@@ -44,8 +44,9 @@
   <label value="&safeModeDescription2.label;"/>
   <vbox id="tasks">
     <checkbox id="disableAddons" label="&disableAddons.label;" accesskey="&disableAddons.accesskey;"/>
     <checkbox id="resetToolbars" label="&resetToolbars.label;" accesskey="&resetToolbars.accesskey;"/>
   </vbox>
 
   <separator class="thin"/>
 </dialog>
+</window>
--- a/mail/base/content/sanitize.xul
+++ b/mail/base/content/sanitize.xul
@@ -3,30 +3,31 @@
 <!-- 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/"?>
 <?xml-stylesheet href="chrome://messenger/skin/sanitizeDialog.css"?>
 <?xml-stylesheet href="chrome://messenger/content/sanitizeDialog.css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
   <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
   <!ENTITY % sanitizeDTD SYSTEM "chrome://messenger/locale/sanitize.dtd">
   %brandDTD;
   %sanitizeDTD;
 ]>
 
-<dialog id="SanitizeDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        dlgbuttons="accept,cancel"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         title="&sanitizeDialog2.title;"
         noneverythingtitle="&sanitizeDialog2.title;"
         style="width: &dialog.width;"
         onload="gSanitizePromptDialog.init();">
+<dialog id="SanitizeDialog"
+        dlgbuttons="accept,cancel"
+        type="child">
 
   <vbox id="SanitizeDialogPane">
     <stringbundle id="bundleBrowser"
             src="chrome://messenger/locale/messenger.properties"/>
 
     <script src="chrome://messenger/content/sanitize.js"/>
     <script src="chrome://messenger/content/sanitizeDialog.js"/>
 
@@ -90,8 +91,9 @@
       <checkbox label="&itemCache.label;"
                 accesskey="&itemCache.accesskey;"
                 preference="privacy.cpd.cache"
                 oncommand="gSanitizePromptDialog.onReadGeneric();"/>
     </vbox>
 
   </vbox>
 </dialog>
+</window>
--- a/mail/base/content/sanitizeDialog.js
+++ b/mail/base/content/sanitizeDialog.js
@@ -46,19 +46,21 @@ var gSanitizePromptDialog = {
         prefItem.checked = Services.prefs.getBoolPref(
           prefItem.getAttribute("preference")
         );
       }
     }
 
     this.onReadGeneric();
 
-    document.documentElement.getButton(
-      "accept"
-    ).label = this.bundleBrowser.getString("sanitizeButtonOK");
+    document
+      .querySelector("dialog")
+      .getButton("accept").label = this.bundleBrowser.getString(
+      "sanitizeButtonOK"
+    );
 
     if (this.selectedTimespan === Sanitizer.TIMESPAN_EVERYTHING) {
       this.prepareWarning();
       this.warningBox.hidden = false;
       document.title = this.bundleBrowser.getString(
         "sanitizeDialog2.everything.title"
       );
     } else {
@@ -155,17 +157,17 @@ var gSanitizePromptDialog = {
     for (let prefItem of sanitizeItemList) {
       found = !prefItem.disabled && prefItem.checked;
       if (found) {
         break;
       }
     }
 
     try {
-      document.documentElement.getButton("accept").disabled = !found;
+      document.querySelector("dialog").getButton("accept").disabled = !found;
     } catch (e) {}
 
     // Update the warning prompt if needed
     this.prepareWarning(true);
 
     return undefined;
   },
 
--- a/mail/base/content/systemIntegrationDialog.js
+++ b/mail/base/content/systemIntegrationDialog.js
@@ -48,19 +48,21 @@ var gSystemIntegrationDialog = {
       // Do this only if we are not called from the Preferences (Options) dialog.
       // In that case, the user may want to just check what the current state is.
       this._mailCheckbox.checked = true;
     } else {
       this._mailCheckbox.checked = this._mailCheckbox.disabled;
 
       // If called from preferences, use only a simpler "Cancel" label on the
       // cancel button.
-      document.documentElement.getButton(
-        "cancel"
-      ).label = document.documentElement.getAttribute("buttonlabelcancel2");
+      document
+        .querySelector("dialog")
+        .getButton("cancel").label = document
+        .querySelector("dialog")
+        .getAttribute("buttonlabelcancel2");
     }
 
     if (!this._mailCheckbox.disabled) {
       this._mailCheckbox.removeAttribute("tooltiptext");
     }
 
     this._newsCheckbox.checked = this._newsCheckbox.disabled = this._shellSvc.isDefaultClient(
       false,
--- a/mail/base/content/systemIntegrationDialog.xul
+++ b/mail/base/content/systemIntegrationDialog.xul
@@ -24,25 +24,25 @@
 #else
   <!ENTITY % searchIntegrationDefaultDTD SYSTEM
     "chrome://messenger/locale/searchIntegrationDefault.dtd">
   %searchIntegrationDefaultDTD;
 #endif
 #endif
 ]>
 
-<dialog xmlns:html="http://www.w3.org/1999/xhtml"
+<window xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        id="systemIntegrationDialog"
+        onload="gSystemIntegrationDialog.onLoad();"
+        title="&systemIntegration.title;">
+<dialog id="systemIntegrationDialog"
         buttons="accept,cancel"
         buttonlabelaccept="&acceptIntegration.label;"
         buttonlabelcancel="&cancelIntegration.label;"
-        buttonlabelcancel2="&cancelIntegration2.label;"
-        onload="gSystemIntegrationDialog.onLoad();"
-        title="&systemIntegration.title;">
+        buttonlabelcancel2="&cancelIntegration2.label;">
 
   <script src="chrome://messenger/content/systemIntegrationDialog.js"/>
 
   <label control="defaultClientList">&defaultClient.intro;</label>
   <vbox id="defaultClientList">
     <checkbox id="checkMail"
               label="&email.label;"
               tooltiptext="&unsetDefault.tooltip;"/>
@@ -63,8 +63,9 @@
 
   <separator class="thin"/>
 
   <checkbox id="checkOnStartup"
             label="&checkOnStartup.label;"
             accesskey="&checkOnStartup.accesskey;"/>
 
 </dialog>
+</window>
--- a/mail/components/addrbook/content/abCard.js
+++ b/mail/components/addrbook/content/abCard.js
@@ -348,17 +348,17 @@ function OnLoadEditCard() {
         document.getElementById(kPhoneticFields[3]).readOnly = true;
 
         // Also disable the mail format popup and allow remote content items.
         document.getElementById("PreferMailFormatPopup").disabled = true;
 
         // And the "prefer display name" checkbox
         document.getElementById("preferDisplayName").disabled = true;
 
-        document.documentElement.buttons = "accept";
+        document.querySelector("dialog").buttons = "accept";
         return;
       }
     }
   }
   document.addEventListener("dialogaccept", EditCardOKButton);
 }
 
 /* Registers functions that are called when loading the card
--- a/mail/components/addrbook/content/abEditCardDialog.xul
+++ b/mail/components/addrbook/content/abEditCardDialog.xul
@@ -2,27 +2,29 @@
 <!-- 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" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/addressbook/cardDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abCard.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abCard.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window windowtype="Mail:abcard"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        id="abcardWindow"
-        icon="abcardWindow"
-        onload="OnLoadEditCard()">
+        onload="OnLoadEditCard()"
+        icon="abcardWindow">
+<dialog id="abcardDialog">
 
   <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
 
   <script src="chrome://messenger/content/addressbook/abCommon.js"/>
   <script src="chrome://messenger/content/addressbook/abCard.js"/>
   <script><![CDATA[
     document.addEventListener("dialogcancel", EditCardCancelButton);
   ]]></script>
 
 #include abCard.inc.xul
 
 </dialog>
+</window>
--- a/mail/components/addrbook/content/abEditListDialog.xul
+++ b/mail/components/addrbook/content/abEditListDialog.xul
@@ -2,24 +2,24 @@
 
 <!-- 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/addressbook/cardDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        id="ablistWindow"
         onload="OnLoadEditList();"
         ondragover="DragOverAddressListTree(event);"
         ondrop="DropOnAddressListTree(event);">
+<dialog id="ablistWindow">
 
   <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- move needed functions into a single js file -->
   <script src="chrome://messenger/content/messengercompose/addressingWidgetOverlay.js"/>
   <script src="chrome://messenger/content/addressbook/abCommon.js"/>
@@ -71,8 +71,9 @@
                       minresultsforpopup="3"
                       onkeypress="awAbRecipientKeyPress(event, this);"
                       onkeydown="awRecipientKeyDown(event, this);"/>
         </hbox>
       </richlistitem>
     </richlistbox>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/addrbook/content/abMailListDialog.xul
+++ b/mail/components/addrbook/content/abMailListDialog.xul
@@ -2,24 +2,24 @@
 
 <!-- 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/addressbook/cardDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        id="ablistWindow"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         title="&mailListWindowAdd.title;"
         onload="OnLoadNewMailList();"
         ondragover="DragOverAddressListTree(event);"
         ondrop="DropOnAddressListTree(event);">
+<dialog id="ablistWindow">
 
   <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- move needed functions into a single js file -->
   <script src="chrome://messenger/content/messengercompose/addressingWidgetOverlay.js"/>
   <script src="chrome://messenger/content/addressbook/abCommon.js"/>
@@ -83,8 +83,9 @@
                       minresultsforpopup="3"
                       onkeypress="awAbRecipientKeyPress(event, this);"
                       onkeydown="awRecipientKeyDown(event, this);"/>
         </hbox>
       </richlistitem>
     </richlistbox>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/addrbook/content/abNewCardDialog.xul
+++ b/mail/components/addrbook/content/abNewCardDialog.xul
@@ -2,29 +2,29 @@
 <!-- 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" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/addressbook/cardDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
   <!ENTITY % newCardDTD SYSTEM "chrome://messenger/locale/addressbook/abNewCardDialog.dtd">
   %newCardDTD;
   <!ENTITY % abCardDTD SYSTEM "chrome://messenger/locale/addressbook/abCard.dtd">
   %abCardDTD;
 ]>
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        id="abcardWindow"
-        icon="abcardWindow"
         windowtype="mailnews:newcarddialog"
-        onload="OnLoadNewCard()">
+        onload="OnLoadNewCard()"
+        icon="abcardWindow">
+<dialog id="abcardDialog">
 
   <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
 
   <script src="chrome://messenger/content/addressbook/abCommon.js"/>
   <script src="chrome://messenger/content/addressbook/abCard.js"/>
   <script><![CDATA[
     document.addEventListener("dialogaccept", NewCardOKButton);
     document.addEventListener("dialogcancel", NewCardCancelButton);
@@ -35,8 +35,9 @@
     <menulist is="menulist-addrbooks" id="abPopup" writable="true"/>
   </hbox>
 
   <spacer style="height:1em"/>
 
 #include abCard.inc.xul
 
 </dialog>
+</window>
--- a/mail/components/cloudfile/content/selectDialog.xul
+++ b/mail/components/cloudfile/content/selectDialog.xul
@@ -1,23 +1,25 @@
 <?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/global.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/content/cloudfile/selectDialog.css" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://global/locale/commonDialog.dtd">
+<!DOCTYPE window SYSTEM "chrome://global/locale/commonDialog.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-      onload="cloudfileDialogOnLoad();">
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        onload="cloudfileDialogOnLoad();">
+<dialog>
 
   <script type="application/javascript" src="chrome://messenger/content/cloudfile/selectDialog.js" />
   <script type="application/javascript" src="chrome://global/content/selectDialog.js" />
   <keyset id="dialogKeys"/>
   <vbox style="width: 24em;margin: 5px;">
     <label id="info.txt"/>
     <vbox>
       <richlistbox id="list" class="theme-listbox" style="height: 8em;"/>
     </vbox>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdAdvancedEdit.js
+++ b/mail/components/compose/content/dialogs/EdAdvancedEdit.js
@@ -83,17 +83,17 @@ function Startup() {
   gDialog.AddCSSAttributeTree = document.getElementById("CSSATree");
   gDialog.AddJSEAttributeNameList = document.getElementById(
     "AddJSEAttributeNameList"
   );
   gDialog.AddJSEAttributeValueInput = document.getElementById(
     "AddJSEAttributeValueInput"
   );
   gDialog.AddJSEAttributeTree = document.getElementById("JSEATree");
-  gDialog.okButton = document.documentElement.getButton("accept");
+  gDialog.okButton = document.querySelector("dialog").getButton("accept");
 
   // build the attribute trees
   BuildHTMLAttributeTable();
   BuildCSSAttributeTable();
   BuildJSEAttributeTable();
 
   // Build attribute name arrays for menulists
   BuildJSEAttributeNameList();
--- a/mail/components/compose/content/dialogs/EdAdvancedEdit.xul
+++ b/mail/components/compose/content/dialogs/EdAdvancedEdit.xul
@@ -6,23 +6,23 @@
 <!-- first checkin of the year 2000!      -->
 <!-- Ben Goodger, 12:50AM, 01/00/00 NZST  -->
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/menulist.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EdAdvancedEdit.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EdAdvancedEdit.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        id="advancedEditDlg"
+<Window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         style="width: 40em;"
         title="&WindowTitle.label;"
         onload="Startup()">
+<dialog id="advancedEditDlg">
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <!-- element page functions -->
   <script src="chrome://messenger/content/messengercompose/EdAEHTMLAttributes.js"/>
@@ -171,8 +171,9 @@
                         onchange="onInputJSEAttributeValue();"
                         aria-labelledby="AddJSEAttributeValueLabel"/>
           </vbox>
         </hbox>
       </vbox>
     </tabpanels>
   </tabbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdColorPicker.js
+++ b/mail/components/compose/content/dialogs/EdColorPicker.js
@@ -37,17 +37,17 @@ function Startup() {
   gDialog.ColorPicker = document.getElementById("ColorPicker");
   gDialog.ColorInput = document.getElementById("ColorInput");
   gDialog.LastPickedButton = document.getElementById("LastPickedButton");
   gDialog.LastPickedColor = document.getElementById("LastPickedColor");
   gDialog.CellOrTableGroup = document.getElementById("CellOrTableGroup");
   gDialog.TableRadio = document.getElementById("TableRadio");
   gDialog.CellRadio = document.getElementById("CellRadio");
   gDialog.ColorSwatch = document.getElementById("ColorPickerSwatch");
-  gDialog.Ok = document.documentElement.getButton("accept");
+  gDialog.Ok = document.querySelector("dialog").getButton("accept");
 
   // The type of color we are setting:
   //  text: Text, Link, ActiveLink, VisitedLink,
   //  or background: Page, Table, or Cell
   if (gColorObj.Type) {
     ColorType = gColorObj.Type;
     // Get string for dialog title from passed-in type
     //   (note constraint on editor.properties string name)
--- a/mail/components/compose/content/dialogs/EdColorPicker.xul
+++ b/mail/components/compose/content/dialogs/EdColorPicker.xul
@@ -1,22 +1,23 @@
 <?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://editor/skin/EditorDialog.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EdColorPicker.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EdColorPicker.dtd">
 
-<dialog title="&windowTitle.label;"
+<window title="&windowTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         onload="Startup()">
+<dialog>
 
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdColorPicker.js"/>
 
   <spacer id="location" offsetY="50" persist="offsetX offsetY"/>
 
   <hbox id="TableOrCellGroup" align="center" collapsed="true">
@@ -50,8 +51,9 @@
       <spacer id="ColorPickerSwatch"/>
       <spacer flex="1"/>
       <button id="DefaultColorButton" label="&default.label;" accesskey="&default.accessKey;"
               style="margin-right:0px;" oncommand="RemoveColor()"/>
     </hbox>
   </vbox>
   <separator class="groove"/>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdColorProps.xul
+++ b/mail/components/compose/content/dialogs/EdColorProps.xul
@@ -2,29 +2,30 @@
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet type="text/css" href="chrome://messenger/skin/input-fields.css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % edColorPropertiesDTD SYSTEM "chrome://messenger/locale/messengercompose/EditorColorProperties.dtd">
 %edColorPropertiesDTD;
 <!ENTITY % composeEditorOverlayDTD SYSTEM "chrome://messenger/locale/messengercompose/mailComposeEditorOverlay.dtd">
 %composeEditorOverlayDTD;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
-<dialog title="&windowTitle.label;"
+<window title="&windowTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         onload="Startup()">
+<dialog>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdColorProps.js"/>
 
   <spacer id="location" offsetY="50" persist="offsetX offsetY"/>
@@ -135,8 +136,9 @@
     <button id="AdvancedEditButton"
             oncommand="onAdvancedEdit();"
             label="&AdvancedEditButton.label;"
             accesskey="&AdvancedEditButton.accessKey;"
             tooltiptext="&AdvancedEditButton.tooltip;"/>
   </hbox>
   <separator class="groove"/>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdConvertToTable.xul
+++ b/mail/components/compose/content/dialogs/EdConvertToTable.xul
@@ -3,23 +3,24 @@
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet type="text/css" href="chrome://messenger/skin/input-fields.css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EdConvertToTable.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EdConvertToTable.dtd">
 
-<dialog title="&windowTitle.label;"
+<window title="&windowTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         onload="Startup()"
         style="min-width:20em">
+<dialog>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <!--- Element-specific methods -->
   <script src="chrome://messenger/content/messengercompose/EdConvertToTable.js"/>
@@ -41,8 +42,9 @@
       <html:input id="SepCharacterInput" type="text" aria-labelledby="other"
                   class="narrow input-inline" oninput="InputSepCharacter()"/>
     </hbox>
   </radiogroup>
   <spacer class="spacer"/>
   <checkbox id="DeleteSepCharacter" label="&deleteCharCheck.label;" persist="checked"/>
   <spacer class="spacer"/>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdDictionary.xul
+++ b/mail/components/compose/content/dialogs/EdDictionary.xul
@@ -3,26 +3,26 @@
    - 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/shared/grid-layout.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EditorPersonalDictionary.dtd">
-<dialog title="&windowTitle.label;"
-        buttons="accept"
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EditorPersonalDictionary.dtd">
+<window title="&windowTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         persist="screenX screenY"
-        buttonlabelaccept="&CloseButton.label;"
+        onload="Startup()">
+<dialog buttonlabelaccept="&CloseButton.label;"
         buttonaccesskeyaccept="&CloseButton.accessKey;"
-        onload="Startup()">
+        buttons="accept">
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDictionary.js"/>
 
@@ -59,8 +59,9 @@
         <xul:button id="RemoveWord"
                     oncommand="RemoveWord()"
                     label="&RemoveButton.label;"
                     accesskey="&RemoveButton.accessKey;"/>
       </div>
     </div>
   </hbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdHLineProps.xul
+++ b/mail/components/compose/content/dialogs/EdHLineProps.xul
@@ -3,26 +3,27 @@
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % edHLineProperties SYSTEM "chrome://messenger/locale/messengercompose/EditorHLineProperties.dtd">
 %edHLineProperties;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
-<dialog title="&windowTitle.label;"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-    onload="Startup()">
+<window title="&windowTitle.label;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="Startup()">
+<dialog>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <!--- Element-specific methods -->
   <script src="chrome://messenger/content/messengercompose/EdHLineProps.js"/>
@@ -90,8 +91,9 @@
     <button id="AdvancedEditButton"
             oncommand="onAdvancedEdit();"
             label="&AdvancedEditButton.label;"
             accesskey="&AdvancedEditButton.accessKey;"
             tooltiptext="&AdvancedEditButton.tooltip;"/>
   </hbox>
   <separator class="groove"/>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdImageDialog.js
+++ b/mail/components/compose/content/dialogs/EdImageDialog.js
@@ -62,17 +62,17 @@ function ImageStartup() {
   gDialog.imagetbInput = document.getElementById("imagetopbottomInput");
   gDialog.border = document.getElementById("border");
   gDialog.alignTypeSelect = document.getElementById("alignTypeSelect");
   gDialog.ImageHolder = document.getElementById("preview-image-holder");
   gDialog.PreviewWidth = document.getElementById("PreviewWidth");
   gDialog.PreviewHeight = document.getElementById("PreviewHeight");
   gDialog.PreviewSize = document.getElementById("PreviewSize");
   gDialog.PreviewImage = null;
-  gDialog.OkButton = document.documentElement.getButton("accept");
+  gDialog.OkButton = document.querySelector("dialog").getButton("accept");
 }
 
 // Set dialog widgets with attribute data
 // We get them from globalElement copy so this can be used
 //   by AdvancedEdit(), which is shared by all property dialogs
 function InitImage() {
   // Set the controls to the image's attributes
   var src = globalElement.getAttribute("src");
--- a/mail/components/compose/content/dialogs/EdImageLinkLoader.js
+++ b/mail/components/compose/content/dialogs/EdImageLinkLoader.js
@@ -22,17 +22,17 @@ function OnLoadDialog() {
     editor.flags & Ci.nsIPlaintextEditor.eEditorMailMask
   ) {
     SetRelativeCheckbox = function() {
       SetAttachCheckbox();
     };
     // initialize the AttachSourceToMail checkbox
     gMsgCompAttachSourceElement.hidden = false;
 
-    switch (document.documentElement.id) {
+    switch (document.querySelector("dialog").id) {
       case "imageDlg":
         gMsgCompInputElement = gDialog.srcInput;
         gMsgCompProcessLink = false;
         break;
       case "linkDlg":
         gMsgCompInputElement = gDialog.hrefInput;
         gMsgCompProcessLink = true;
         break;
--- a/mail/components/compose/content/dialogs/EdImageProps.xul
+++ b/mail/components/compose/content/dialogs/EdImageProps.xul
@@ -2,29 +2,31 @@
 # 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % edImageProperties SYSTEM "chrome://messenger/locale/messengercompose/EditorImageProperties.dtd">
 %edImageProperties;
 <!ENTITY % composeEditorOverlayDTD SYSTEM "chrome://messenger/locale/messengercompose/mailComposeEditorOverlay.dtd">
 %composeEditorOverlayDTD;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
 <!-- dialog containing a control requiring initial setup -->
-<dialog id="imageDlg" title="&windowTitle.label;"
+<window windowtype="Mail:image"
+        title="&windowTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        onload="Startup()"
+        onload="Startup()">
+<dialog id="imageDlg"
         buttons="accept,cancel">
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdImageProps.js"/>
   <script src="chrome://messenger/content/messengercompose/EdImageDialog.js"/>
@@ -114,8 +116,9 @@
         <button id="AdvancedEditButton1" oncommand="onAdvancedEdit()" label="&AdvancedEditButton.label;"
                 accesskey="&AdvancedEditButton.accessKey;" tooltiptext="&AdvancedEditButton.tooltip;"/>
       </hbox>
     </vbox>
   </hbox>
   <separator class="groove"/>
 
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdInsSrc.js
+++ b/mail/components/compose/content/dialogs/EdInsSrc.js
@@ -17,17 +17,20 @@ document.addEventListener("dialogcancel"
 
 function Startup() {
   let editor = GetCurrentEditor();
   if (!editor) {
     window.close();
     return;
   }
 
-  document.documentElement.getButton("accept").removeAttribute("default");
+  document
+    .querySelector("dialog")
+    .getButton("accept")
+    .removeAttribute("default");
 
   // Create dialog object to store controls for easy access
   gDialog.srcInput = document.getElementById("srcInput");
 
   // Attach a paste listener so we can detect pasted data URIs we need to shorten.
   gDialog.srcInput.addEventListener("paste", onPaste);
 
   let selection;
--- a/mail/components/compose/content/dialogs/EdInsSrc.xul
+++ b/mail/components/compose/content/dialogs/EdInsSrc.xul
@@ -2,24 +2,24 @@
 
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertSource.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertSource.dtd">
 
-<dialog title="&windowTitle.label;"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-    xmlns:html="http://www.w3.org/1999/xhtml"
-    onload = "Startup()"
-    buttonlabelaccept="&insertButton.label;"
-    buttonaccesskeyaccept="&insertButton.accesskey;">
+<window title="&windowTitle.label;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="Startup()">
+<dialog buttonlabelaccept="&insertButton.label;"
+        buttonaccesskeyaccept="&insertButton.accesskey;">
 
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdInsSrc.js"/>
 
@@ -35,8 +35,9 @@
     <label value="&example.label;"/>
     <label class="bold" value="&exampleOpenTag.label;"/>
     <label class="bold italic" value="&exampleText.label;"/>
     <label class="bold" value="&exampleCloseTag.label;"/>
   </hbox>
   <spacer class="spacer"/>
   <separator class="groove"/>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdInsertChars.js
+++ b/mail/components/compose/content/dialogs/EdInsertChars.js
@@ -55,17 +55,20 @@ function onAccept(event) {
 
 // Don't allow inserting in HTML Source Mode
 function onFocus() {
   var enable = true;
   if ("gEditorDisplayMode" in window.opener) {
     enable = !window.opener.IsInHTMLSourceMode();
   }
 
-  SetElementEnabled(document.documentElement.getButton("accept"), enable);
+  SetElementEnabled(
+    document.querySelector("dialog").getButton("accept"),
+    enable
+  );
 }
 
 function onClose() {
   window.opener.InsertCharWindow = null;
   SaveWindowLocation();
 }
 
 // ------------------------------------------------------------------
--- a/mail/components/compose/content/dialogs/EdInsertChars.xul
+++ b/mail/components/compose/content/dialogs/EdInsertChars.xul
@@ -1,25 +1,26 @@
 <?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://editor/skin/EditorDialog.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertChars.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertChars.dtd">
 
-<dialog id="insertCharsDlg" title="&windowTitle.label;"
+<dialog title="&windowTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        onload = "Startup()"
-        onfocus = "onFocus()"
+        onload="Startup()"
+        onfocus="onFocus()"
+        style="width: 20em">
+<dialog id="insertCharsDlg"
         buttonlabelaccept="&insertButton.label;"
-        buttonlabelcancel="&closeButton.label;"
-        style = "width: 20em">
+        buttonlabelcancel="&closeButton.label;">
 
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdInsertChars.js"/>
 
   <spacer id="location" offsetY="50" persist="offsetX offsetY"/>
 
@@ -48,8 +49,9 @@
       <label id="LatinM_Label" control="LatinM" value="&character.label;" accesskey="&character.accessKey;"/>
       <menulist class="larger" flex="1" id="LatinM" oncommand="SelectLatinModifier()">
         <menupopup/>
       </menulist>
     </vbox>
   </hbox>
   <separator class="groove"/>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdInsertMath.js
+++ b/mail/components/compose/content/dialogs/EdInsertMath.js
@@ -14,17 +14,17 @@ document.addEventListener("dialogcancel"
 function Startup() {
   var editor = GetCurrentEditor();
   if (!editor) {
     window.close();
     return;
   }
 
   // Create dialog object for easy access
-  gDialog.accept = document.documentElement.getButton("accept");
+  gDialog.accept = document.querySelector("dialog").getButton("accept");
   gDialog.mode = document.getElementById("optionMode");
   gDialog.direction = document.getElementById("optionDirection");
   gDialog.input = document.getElementById("input");
   gDialog.output = document.getElementById("output");
   gDialog.tabbox = document.getElementById("tabboxInsertLaTeXCommand");
 
   // Set initial focus
   gDialog.input.focus();
--- a/mail/components/compose/content/dialogs/EdInsertMath.xul
+++ b/mail/components/compose/content/dialogs/EdInsertMath.xul
@@ -2,23 +2,23 @@
 
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertMath.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertMath.dtd">
 
-<dialog title="&windowTitle.label;"
+<window title="&windowTitle.label;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        onload="Startup();"
-        buttonlabelaccept="&insertButton.label;"
+        onload="Startup();">
+<dialog buttonlabelaccept="&insertButton.label;"
         buttonaccesskeyaccept="&insertButton.accesskey;">
 
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdInsertMath.js"/>
@@ -53,8 +53,9 @@
         <radio label="&optionRTL.label;"
                accesskey="&optionRTL.accesskey;"/>
       </radiogroup>
     </hbox>
   </groupbox>
   <spacer class="spacer"/>
   <separator class="groove"/>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdInsertTOC.xul
+++ b/mail/components/compose/content/dialogs/EdInsertTOC.xul
@@ -3,23 +3,24 @@
    - 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://editor/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertTOC.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertTOC.dtd">
 
-<dialog title="&Window.title;"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-    xmlns:html="http://www.w3.org/1999/xhtml"
-    onload="Startup();"
-    oncancel="window.close(); return true;">
+<window title="&Window.title;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="Startup();"
+        oncancel="window.close(); return true;">
+<dialog>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
 
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdInsertTOC.js"/>
@@ -249,8 +250,9 @@
                 oncommand="ToggleOrderedList(this)"/>
       <checkbox id="readOnlyCheckbox"
                 label="&makeReadOnly.label;"
                 oncommand="ToggleReadOnlyToc(this)"/>
     </vbox>
     <separator class="groove"/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdInsertTable.js
+++ b/mail/components/compose/content/dialogs/EdInsertTable.js
@@ -36,17 +36,17 @@ function Startup() {
   }
   gDialog.rowsInput = document.getElementById("rowsInput");
   gDialog.columnsInput = document.getElementById("columnsInput");
   gDialog.widthInput = document.getElementById("widthInput");
   gDialog.borderInput = document.getElementById("borderInput");
   gDialog.widthPixelOrPercentMenulist = document.getElementById(
     "widthPixelOrPercentMenulist"
   );
-  gDialog.OkButton = document.documentElement.getButton("accept");
+  gDialog.OkButton = document.querySelector("dialog").getButton("accept");
 
   // Make a copy to use for AdvancedEdit
   globalElement = gTableElement.cloneNode(false);
   try {
     if (
       Services.prefs.getBoolPref("editor.use_css") &&
       IsHTMLEditor() &&
       !(gActiveEditor.flags & Ci.nsIPlaintextEditor.eEditorMailMask)
--- a/mail/components/compose/content/dialogs/EdInsertTable.xul
+++ b/mail/components/compose/content/dialogs/EdInsertTable.xul
@@ -2,26 +2,27 @@
 
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % edInsertTable SYSTEM "chrome://messenger/locale/messengercompose/EditorInsertTable.dtd">
 %edInsertTable;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
-<dialog title="&windowTitle.label;"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-    onload = "Startup()">
+<window title="&windowTitle.label;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="Startup()">
+<dialog>
 
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdInsertTable.js"/>
 
   <spacer id="location" offsetY="50" persist="offsetX offsetY"/>
   <groupbox>
@@ -87,8 +88,9 @@
       <!-- This will right-align the button -->
       <spacer flex="1"/>
       <button id="AdvancedEditButton1" oncommand="onAdvancedEdit()" label="&AdvancedEditButton.label;"
               accesskey="&AdvancedEditButton.accessKey;" tooltiptext="&AdvancedEditButton.tooltip;"/>
     </hbox>
     <separator id="advancedSeparator" class="groove"/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdLinkProps.xul
+++ b/mail/components/compose/content/dialogs/EdLinkProps.xul
@@ -3,28 +3,29 @@
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % linkPropertiesDTD SYSTEM "chrome://messenger/locale/messengercompose/EditorLinkProperties.dtd">
 %linkPropertiesDTD;
 <!ENTITY % composeEditorOverlayDTD SYSTEM "chrome://messenger/locale/messengercompose/mailComposeEditorOverlay.dtd">
 %composeEditorOverlayDTD;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
-<dialog id="linkDlg" title="&windowTitle.label;"
-   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-   onload = "Startup()">
+<window title="&windowTitle.label;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        onload = "Startup()">
+<dialog id="linkDlg">
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdLinkProps.js"/>
   <script src="chrome://messenger/content/messengercompose/EdImageLinkLoader.js"/>
 
@@ -78,8 +79,9 @@
       <!-- This will right-align the button -->
       <spacer flex="1"/>
       <button id="AdvancedEditButton1" oncommand="onAdvancedEdit()" label="&AdvancedEditButton.label;"
               accesskey="&AdvancedEditButton.accessKey;" tooltiptext="&AdvancedEditButton.tooltip;"/>
     </hbox>
     <separator id="advancedSeparator" class="groove"/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdListProps.xul
+++ b/mail/components/compose/content/dialogs/EdListProps.xul
@@ -2,26 +2,27 @@
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % edListProperties SYSTEM "chrome://messenger/locale/messengercompose/EditorListProperties.dtd">
 %edListProperties;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
-<dialog title="&windowTitle.label;"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-    onload="Startup()">
+<window title="&windowTitle.label;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="Startup()">
+<dialog>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdListProps.js"/>
 
@@ -71,8 +72,9 @@
       <!-- This will right-align the button -->
       <spacer flex="1"/>
       <button id="AdvancedEditButton1" oncommand="onAdvancedEdit()" label="&AdvancedEditButton.label;"
               accesskey="&AdvancedEditButton.accessKey;" tooltiptext="&AdvancedEditButton.tooltip;"/>
     </hbox>
     <separator id="advancedSeparator" class="groove"/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdNamedAnchorProps.js
+++ b/mail/components/compose/content/dialogs/EdNamedAnchorProps.js
@@ -17,17 +17,17 @@ document.addEventListener("dialogcancel"
 
 function Startup() {
   var editor = GetCurrentEditor();
   if (!editor) {
     window.close();
     return;
   }
 
-  gDialog.OkButton = document.documentElement.getButton("accept");
+  gDialog.OkButton = document.querySelector("dialog").getButton("accept");
   gDialog.NameInput = document.getElementById("nameInput");
 
   // Get a single selected element of the desired type
   gAnchorElement = editor.getSelectedElement(kTagName);
 
   if (gAnchorElement) {
     // We found an element and don't need to insert one
     gInsertNew = false;
--- a/mail/components/compose/content/dialogs/EdNamedAnchorProps.xul
+++ b/mail/components/compose/content/dialogs/EdNamedAnchorProps.xul
@@ -3,26 +3,27 @@
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % edNamedAnchorProperties SYSTEM "chrome://messenger/locale/messengercompose/EdNamedAnchorProperties.dtd">
 %edNamedAnchorProperties;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
-<dialog title="&windowTitle.label;"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-    onload="Startup()">
+<window title="&windowTitle.label;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="Startup()">
+<dialog>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdNamedAnchorProps.js"/>
 
@@ -42,8 +43,9 @@
       <!-- This will right-align the button -->
       <spacer flex="1"/>
       <button id="AdvancedEditButton1" oncommand="onAdvancedEdit()" label="&AdvancedEditButton.label;"
               accesskey="&AdvancedEditButton.accessKey;" tooltiptext="&AdvancedEditButton.tooltip;"/>
     </hbox>
     <separator id="advancedSeparator" class="groove"/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdReplace.xul
+++ b/mail/components/compose/content/dialogs/EdReplace.xul
@@ -4,23 +4,24 @@
    - 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/shared/grid-layout.css" type="text/css"?>
 <?xml-stylesheet type="text/css" href="chrome://messenger/skin/input-fields.css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EditorReplace.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EditorReplace.dtd">
 
-<dialog id="replaceDlg" title="&replaceDialog.title;"
-   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-   persist="screenX screenY"
-   buttons="cancel"
-   onload="onLoad()">
+<window title="&replaceDialog.title;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        persist="screenX screenY"
+        onload="onLoad()">
+<dialog id="replaceDlg"
+        buttons="cancel">
 
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdReplace.js"/>
   <stringbundle id="findBundle" src="chrome://global/locale/finddialog.properties"/>
 
   <hbox>
@@ -60,8 +61,9 @@
       <button id="replaceAndFind" label="&replaceAndFindButton.label;"
           accesskey="&replaceAndFindButton.accesskey;" oncommand="onReplace(); onFindNext();"/>
       <button id="replaceAll" label="&replaceAllButton.label;"
           accesskey="&replaceAllButton.accesskey;" oncommand="onReplaceAll();"/>
       <button dlgtype="cancel" label="&closeButton.label;" accesskey="&closeButton.accesskey;"/>
     </vbox>
   </hbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdSpellCheck.xul
+++ b/mail/components/compose/content/dialogs/EdSpellCheck.xul
@@ -3,23 +3,25 @@
 <!-- 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://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/shared/grid-layout.css" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/EditorSpellCheck.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/EditorSpellCheck.dtd">
 
 <!-- dialog containing a control requiring initial setup -->
-<dialog id="spellCheckDlg" buttons="cancel" title="&windowTitle.label;"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-    persist="screenX screenY"
-    onload="Startup()">
+<window title="&windowTitle.label;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        persist="screenX screenY"
+        onload="Startup()">
+<dialog id="spellCheckDlg"
+        buttons="cancel">
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://communicator/content/utilityOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/EdSpellCheck.js"/>
   <script src="chrome://global/content/contentAreaUtils.js"/>
@@ -121,8 +123,9 @@
                 accesskey="&closeButton.accessKey;"/>
         <button id="Send" class="spell-check" label="&sendButton.label;" oncommand="onClose();"
                 accesskey="&sendButton.accessKey;" hidden="true"/>
       </hbox>
     </html:div>
   </html:div>
   </hbox>
 </dialog>
+</window>
--- a/mail/components/compose/content/dialogs/EdTableProps.js
+++ b/mail/components/compose/content/dialogs/EdTableProps.js
@@ -1393,20 +1393,22 @@ function ApplyAttributesToOneCell(destEl
   if (gDialog.CellColorCheckbox.checked) {
     CloneAttribute(destElement, globalCellElement, "bgcolor");
   }
 }
 
 function SetCloseButton() {
   // Change text on "Cancel" button after Apply is used
   if (!gApplyUsed) {
-    document.documentElement.setAttribute(
-      "buttonlabelcancel",
-      document.documentElement.getAttribute("buttonlabelclose")
-    );
+    document
+      .querySelector("dialog")
+      .setAttribute(
+        "buttonlabelcancel",
+        document.querySelector("dialog").getAttribute("buttonlabelclose")
+      );
     gApplyUsed = true;
   }
 }
 
 function Apply() {
   if (ValidateData()) {
     gActiveEditor.beginTransaction();
 
--- a/mail/components/compose/content/dialogs/EdTableProps.xul
+++ b/mail/components/compose/content/dialogs/EdTableProps.xul
@@ -4,31 +4,31 @@
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/shared/grid-layout.css" type="text/css" ?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css" ?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % edTableProperties SYSTEM "chrome://messenger/locale/messengercompose/EditorTableProperties.dtd">
 %edTableProperties;
 <!ENTITY % edDialogOverlay SYSTEM "chrome://messenger/locale/messengercompose/EdDialogOverlay.dtd">
 %edDialogOverlay;
 ]>
 
-<dialog title="&tableWindow.title;"
-    id="tableDlg"
-    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-    onload="Startup()"
-    buttons="accept,extra1,cancel"
-    buttonlabelclose="&closeButton.label;"
-    buttonlabelextra1="&applyButton.label;"
-    buttonaccesskeyextra1="&applyButton.accesskey;">
+<window title="&tableWindow.title;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="Startup()">
+<dialog id="tableDlg"
+        buttons="accept,extra1,cancel"
+        buttonlabelclose="&closeButton.label;"
+        buttonlabelextra1="&applyButton.label;"
+        buttonaccesskeyextra1="&applyButton.accesskey;">
 
   <!-- Methods common to all editor dialogs -->
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
   <script src="chrome://messenger/content/messengercompose/EdDialogCommon.js"/>
   <script src="chrome://messenger/content/messengercompose/EdTableProps.js"/>
 
@@ -342,8 +342,9 @@
                   tooltiptext="&AdvancedEditButton.tooltip;"/>
         </hbox>
         <spacer flex="1"/>
       </vbox><!-- Cell Panel -->
     </tabpanels>
   </tabbox>
   <spacer class="spacer"/>
 </dialog>
+</window>
--- a/mail/components/im/content/addbuddy.js
+++ b/mail/components/im/content/addbuddy.js
@@ -22,19 +22,19 @@ var addBuddy = {
     if (!accountList.itemCount) {
       document.getElementById("addBuddyDialog").cancelDialog();
       throw new Error("No connected account!");
     }
     accountList.selectedIndex = 0;
   },
 
   oninput() {
-    document.documentElement.getButton("accept").disabled = !addBuddy.getValue(
-      "name"
-    );
+    document
+      .querySelector("dialog")
+      .getButton("accept").disabled = !addBuddy.getValue("name");
   },
 
   getValue(aId) {
     return document.getElementById(aId).value;
   },
 
   create() {
     let account = Services.accounts.getAccountById(
--- a/mail/components/im/content/addbuddy.xul
+++ b/mail/components/im/content/addbuddy.xul
@@ -4,23 +4,23 @@
    - 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/imMenulist.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css" type="text/css"?>
 
 <!DOCTYPE window SYSTEM "chrome://messenger/locale/addbuddy.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        id="addBuddyDialog"
         windowtype="Messenger:AddBuddy"
         title="&addBuddyWindow.title;"
+        onload="addBuddy.onload()">
+<dialog id="addBuddyDialog"
         buttons="accept,cancel"
-        onload="addBuddy.onload()"
         buttondisabledaccept="true">
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/chat/addbuddy.js"/>
 
   <stringbundle id="chatBundle" src="chrome://messenger/locale/chat.properties"/>
   <hbox>
@@ -36,8 +36,9 @@
       <html:input id="name"
                   type="text"
                   class="input-inline"
                   oninput="addBuddy.oninput()"/>
       <menulist id="accountlist"/>
     </vbox>
   </hbox>
 </dialog>
+</window>
--- a/mail/components/im/content/joinchat.xul
+++ b/mail/components/im/content/joinchat.xul
@@ -5,25 +5,25 @@
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/menulist.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/content/chat/chat.css" type="text/css"?>
 <?xml-stylesheet type="text/css" href="chrome://messenger/skin/input-fields.css"?>
 
 <!DOCTYPE window SYSTEM "chrome://messenger/locale/joinChat.dtd">
 
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        id="joinChatDialog"
         windowtype="Messenger:JoinChat"
         title="&joinChatWindow.title;"
-        buttons="accept,cancel"
         onload="joinChat.onload()"
         autojoinLabel="&autojoin.label;"
         autojoinAccesskey="&autojoin.accesskey;">
+<dialog id="joinChatDialog"
+        buttons="accept,cancel">
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://messenger/content/chat/joinchat.js"/>
 
   <div xmlns="http://www.w3.org/1999/xhtml" id="joinChatGrid">
     <div>
       <xul:label value="&account.label;" control="accountlist"/>
@@ -34,8 +34,9 @@
     <div class="optional-col required">
       <xul:label value="&optional.label;"/>
     </div>
   </div>
   <hbox>
     <checkbox id="autojoin" label="&autojoin.label;" accesskey="&autojoin.accesskey;"/>
   </hbox>
 </dialog>
+</window>
--- a/mail/components/preferences/applicationManager.xul
+++ b/mail/components/preferences/applicationManager.xul
@@ -1,26 +1,26 @@
 <?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/"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/preferences/applicationManager.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/preferences/applicationManager.dtd">
 
-<dialog id="appManager"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        buttons="accept,cancel"
         onload="gAppManagerDialog.init();"
         title="&appManager.title;"
         style="&appManager.style;"
         persist="screenX screenY">
+<dialog id="appManager"
+        buttons="accept,cancel">
 
   <script src="chrome://global/content/preferencesBindings.js"/>
   <script src="chrome://messenger/content/preferences/general.js"/>
   <script src="chrome://messenger/content/preferences/applicationManager.js"/>
 
   <commandset id="appManagerCommandSet">
     <command id="cmd_delete"
              oncommand="gAppManagerDialog.remove();"
@@ -50,8 +50,9 @@
     </vbox>
   </hbox>
   <vbox id="appDetails">
     <separator class="thin"/>
     <label id="appType"/>
     <html:input id="appLocation" type="text" readonly="readonly"/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/preferences/attachmentReminder.xul
+++ b/mail/components/preferences/attachmentReminder.xul
@@ -1,29 +1,30 @@
 <?xml version="1.0"?>
 <!-- -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
    - 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/"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 %brandDTD;
 <!ENTITY % sendOptionsDTD SYSTEM "chrome://messenger/locale/preferences/attachmentReminder.dtd">
 %sendOptionsDTD;
 ]>
 
-<dialog id="attachmentReminderOptionsDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        dlgbuttons="accept,cancel"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         title="&attachmentReminderDialog.title;"
         onload="gAttachmentReminderOptionsDialog.init();"
         style="width:38em;">
+<dialog id="attachmentReminderOptionsDialog"
+        type="child"
+        dlgbuttons="accept,cancel">
 
   <prefpane id="attachmentReminderOptionsDialogPane">
     <script src="chrome://messenger/content/preferences/attachmentReminder.js"/>
     <stringbundle id="bundlePreferences" src="chrome://messenger/locale/preferences/preferences.properties"/>
 
     <groupbox>
       <label control="keywordList">&attachKeywordText.label;</label>
       <hbox>
@@ -36,8 +37,9 @@
                   oncommand="gAttachmentReminderOptionsDialog.editKeyword();"/>
           <button label="&removeKeywordButton.label;" accesskey="&removeKeywordButton.accesskey;"
                   oncommand="gAttachmentReminderOptionsDialog.removeKeyword();"/>
         </vbox>
       </hbox>
     </groupbox>
   </prefpane>
 </dialog>
+</window>
--- a/mail/components/preferences/colors.xul
+++ b/mail/components/preferences/colors.xul
@@ -3,28 +3,29 @@
 # -*- 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/.
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/preferences/colors.dtd" >
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/preferences/colors.dtd" >
 
-<dialog id="ColorsDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         title="&colorsDialog.title;"
-        dlgbuttons="accept,cancel"
 #ifdef XP_MACOSX
         style="width: &window.macWidth; !important;">
 #else
         style="width: &window.width; !important;">
 #endif
+<dialog id="ColorsDialog"
+        type="child"
+        dlgbuttons="accept,cancel">
   <prefpane id="ColorsDialogPane">
     <hbox>
       <groupbox flex="1">
         <label><html:h2>&color;</html:h2></label>
         <hbox align="center">
           <label value="&textColor.label;" accesskey="&textColor.accesskey;" control="foregroundtextmenu"/>
           <spacer flex="1"/>
           <html:input type="color" id="foregroundtextmenu" preference="browser.display.foreground_color"/>
@@ -79,8 +80,9 @@
         </menupopup>
       </menulist>
     </vbox>
   </prefpane>
 
   <script src="chrome://global/content/preferencesBindings.js"/>
   <script src="chrome://messenger/content/preferences/colors.js"/>
 </dialog>
+</window>
--- a/mail/components/preferences/connection.xul
+++ b/mail/components/preferences/connection.xul
@@ -1,33 +1,34 @@
 <?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/. -->
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/preferences/connection.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/preferences/connection.dtd">
 
 <?xml-stylesheet href="chrome://global/skin/"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://messenger/skin/input-fields.css"?>
 
-<dialog id="ConnectionsDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         title="&connectionsDialog.title;"
-        dlgbuttons="accept,cancel"
         onbeforeaccept="return gConnectionsDialog.beforeAccept();"
         onload="gConnectionsDialog.checkForSystemProxy();"
 #ifdef XP_MACOSX
         style="width: &window.macWidth; !important;">
 #else
         style="width: &window.width; !important;">
 #endif
+<dialog id="ConnectionsDialog"
+        type="child"
+        dlgbuttons="accept,cancel">
 
   <linkset>
     <html:link rel="localization" href="messenger/preferences/connection.ftl"/>
   </linkset>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
   <script src="chrome://global/content/preferencesBindings.js"/>
@@ -161,8 +162,9 @@
       </hbox>
       <html:input id="networkCustomDnsOverHttpsInput"
                   type="url"
                   preference="network.trr.custom_uri"/>
     </hbox>
   </vbox>
   <separator/>
 </dialog>
+</window>
--- a/mail/components/preferences/dockoptions.xul
+++ b/mail/components/preferences/dockoptions.xul
@@ -2,23 +2,26 @@
 <!-- -*- 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/" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/preferences/dockoptions.dtd">
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/preferences/dockoptions.dtd">
 
-<dialog id="DockOptionsDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        title="&dockOptionsDialog.title;" dlgbuttons="accept,cancel"
+        title="&dockOptionsDialog.title;"
         style="width: &window.macWidth;">
+<dialog id="DockOptionsDialog"
+        type="child"
+        dlgbuttons="accept,cancel">
+
   <prefpane id="DockOptionsDialogPane">
     <hbox orient="vertical">
       <checkbox id="newMailNotificationBounce"
                 label="&bounceSystemDockIcon.label;"
                 preference="mail.biff.animate_dock_icon"
                 accesskey="&bounceSystemDockIcon.accesskey;"/>
       <separator class="thin"/>
       <groupbox flex="1">
@@ -39,8 +42,9 @@
       <separator/>
       <description class="bold">&directNotificationSettings.label;</description>
     </hbox>
   </prefpane>
 
   <script src="chrome://global/content/preferencesBindings.js"/>
   <script src="chrome://messenger/content/preferences/dockoptions.js"/>
 </dialog>
+</window>
--- a/mail/components/preferences/fonts.xul
+++ b/mail/components/preferences/fonts.xul
@@ -1,28 +1,30 @@
 <?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/"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % fontsDTD SYSTEM "chrome://messenger/locale/preferences/fonts.dtd" >
 %fontsDTD;
 ]>
 
-<dialog id="FontsDialog" type="child" class="prefwindow"
-            xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-            xmlns:html="http://www.w3.org/1999/xhtml"
-            title="&fontsAndEncodingsDialog.title;"
-            buttons="accept,cancel"
-            persist="lastSelected screenX screenY"
-            role="dialog">
+<window class="prefwindow"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        xmlns:html="http://www.w3.org/1999/xhtml"
+        title="&fontsAndEncodingsDialog.title;"
+        persist="lastSelected screenX screenY"
+        role="dialog">
+<dialog id="FontsDialog"
+        type="child"
+        buttons="accept,cancel">
 
   <keyset>
     <key data-l10n-id="fonts-window-close" modifiers="accel" oncommand="Preferences.close(event)"/>
   </keyset>
 
   <vbox id="FontsDialogPane" class="prefpane largeDialogContainer">
 
     <stringbundle id="bundlePreferences" src="chrome://messenger/locale/preferences/preferences.properties"/>
@@ -277,8 +279,9 @@
 
       <checkbox id="replyInDefaultCharset" label="&replyInDefaultCharset3.label;"
                 preference="mailnews.reply_in_default_charset"
                 accesskey="&replyInDefaultCharset3.accesskey;"/>
     </groupbox>
     <separator/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/preferences/messengerLanguages.xul
+++ b/mail/components/preferences/messengerLanguages.xul
@@ -1,25 +1,27 @@
 <?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/"?>
 
-<dialog id="MessengerLanguagesDialog" type="child" class="prefwindow"
+<window class="prefwindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         data-l10n-id="messenger-languages-window"
         data-l10n-attrs="title, style"
-        buttons="accept,cancel"
         role="dialog"
         onload="gMessengerLanguagesDialog.onLoad();"
         onbeforeaccept="return gMessengerLanguagesDialog.beforeAccept();">
+<dialog id="MessengerLanguagesDialog"
+        type="child"
+        buttons="accept,cancel">
 
   <linkset>
     <html:link rel="localization" href="branding/brand.ftl"/>
     <html:link rel="localization" href="messenger/preferences/languages.ftl"/>
   </linkset>
 
   <script src="chrome://global/content/preferencesBindings.js"/>
   <script src="chrome://messenger/content/preferences/messengerLanguages.js"/>
@@ -61,8 +63,9 @@
     </hbox>
     <hbox id="warning-message" class="message-bar message-bar-warning" hidden="true">
       <image class="message-bar-icon"/>
       <description class="message-bar-description" data-l10n-id="messenger-languages-error"/>
     </hbox>
     <separator class="thin"/>
   </vbox>
 </dialog>
+</window>
--- a/mail/components/preferences/notifications.xul
+++ b/mail/components/preferences/notifications.xul
@@ -3,25 +3,26 @@
 <!-- -*- 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/"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
   <!ENTITY % notificationsDTD SYSTEM "chrome://messenger/locale/preferences/notifications.dtd">
   %notificationsDTD;
 ]>
 
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        title="&notificationsDialog2.title;">
 <dialog id="NotificationsDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        dlgbuttons="accept,cancel"
-        title="&notificationsDialog2.title;">
+        dlgbuttons="accept,cancel">
+
   <prefpane id="NotificationsDialogPane">
     <description>&alertCustomization.intro;</description>
     <checkbox id="previewText" class="indent" label="&previewText.label;" accesskey="&previewText.accesskey;" preference="mail.biff.alert.show_preview"/>
     <checkbox id="subject" class="indent" label="&subject.label;" accesskey="&subject.accesskey;" preference="mail.biff.alert.show_subject"/>
     <checkbox id="sender"  class="indent" label="&sender.label;" accesskey="&sender.accesskey;" preference="mail.biff.alert.show_sender"/>
 
     <separator/>
     <hbox align="center">
@@ -35,8 +36,9 @@
       <label id="totalOpenTimeEnd" value="&totalOpenTimeEnd.label;"/>
     </hbox>
     <separator/>
   </prefpane>
 
   <script src="chrome://global/content/preferencesBindings.js"/>
   <script src="chrome://messenger/content/preferences/notifications.js"/>
 </dialog>
+</window>
--- a/mail/components/preferences/offline.xul
+++ b/mail/components/preferences/offline.xul
@@ -2,26 +2,27 @@
 <!-- -*- 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/"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
   <!ENTITY % offlineDTD SYSTEM "chrome://messenger/locale/preferences/offline.dtd">
   %offlineDTD;
 ]>
 
-<dialog id="OfflineSettingsDialog" type="child"
-            xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-            onload="gOfflineDialog.dialogSetup();"
-            dlgbuttons="accept,cancel"
-            title="&offlineDialog.title;">
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        onload="gOfflineDialog.dialogSetup();"
+        title="&offlineDialog.title;">
+<dialog id="OfflineSettingsDialog"
+        type="child"
+        dlgbuttons="accept,cancel">
 
   <prefpane id="OfflineSettingsDialogPane">
     <script src="chrome://global/content/preferencesBindings.js"/>
     <script src="chrome://messenger/content/preferences/offline.js"/>
 
     <checkbox label="&checkAutoDetect.label;"
               accesskey="&checkAutoDetect.accesskey;"
               preference="offline.autoDetect"/>
@@ -58,8 +59,9 @@
                 preference="offline.download.download_messages">
       <radio value="1" label="&radioAutoDownload.label;" accesskey="&radioAutoDownload.accesskey;"/>
       <radio value="2" label="&radioNotDownload.label;"  accesskey="&radioNotDownload.accesskey;"/>
       <radio value="0" label="&radioAskDownload.label;"  accesskey="&radioAskDownload.accesskey;"/>
     </radiogroup>
     <separator/>
   </prefpane>
 </dialog>
+</window>
--- a/mail/components/preferences/receipts.xul
+++ b/mail/components/preferences/receipts.xul
@@ -2,26 +2,27 @@
 <!-- -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
    - 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"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % receiptsDTD SYSTEM "chrome://messenger/locale/preferences/receipts.dtd">
 %receiptsDTD;
 ]>
 
-<dialog id="ReturnReceiptsDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
-        dlgbuttons="accept,cancel"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         title="&dialog.title;"
         onload="enableDisableAllowedReceipts();">
+<dialog id="ReturnReceiptsDialog"
+        type="child"
+        dlgbuttons="accept,cancel">
 
   <prefpane id="ReturnReceiptsDialogPane">
     <script src="chrome://global/content/preferencesBindings.js"/>
     <script src="chrome://messenger/content/preferences/receipts.js"/>
 
     <vbox id="returnReceiptSettings" align="start">
       <checkbox id="alwaysRequest" label="&requestReceipt.label;"
                 preference="mail.receipt.request_return_receipt_on"
@@ -94,8 +95,9 @@
             </menupopup>
           </menulist>
         </hbox>
       </vbox>
     </radiogroup>
     <separator/>
   </prefpane>
 </dialog>
+</window>
--- a/mail/components/preferences/sendoptions.xul
+++ b/mail/components/preferences/sendoptions.xul
@@ -2,30 +2,30 @@
 <!-- -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
    - This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xml-stylesheet href="chrome://global/skin/"?>
 <?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % sendOptionsDTD SYSTEM "chrome://messenger/locale/preferences/sendoptions.dtd" >
 %sendOptionsDTD;
 ]>
 
-<dialog id="SendOptionsDialog" type="child"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        dlgbuttons="accept,cancel"
         style="min-height: 33em;"
         title="&dialog.title;"
         onload="gSendOptionsDialog.init();">
+<dialog id="SendOptionsDialog" type="child"
+        dlgbuttons="accept,cancel">
 
   <prefpane id="SendOptionsDialogPane">
     <script src="chrome://global/content/preferencesBindings.js"/>
     <script src="chrome://messenger/content/preferences/sendoptions.js"/>
 
     <stringbundle id="bundlePreferences" src="chrome://messenger/locale/preferences/preferences.properties"/>
 
     <groupbox>
@@ -95,8 +95,9 @@
         </vbox>
 
       </tabpanels>
     </tabbox>
 
     <separator/>
   </prefpane>
 </dialog>
+</window>
--- a/mail/extensions/mailviews/content/mailViewList.xul
+++ b/mail/extensions/mailviews/content/mailViewList.xul
@@ -1,31 +1,31 @@
 <?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/dialogs.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
 <!ENTITY % mailViewLisDTD SYSTEM "chrome://messenger/locale/mailViewList.dtd">
 %mailViewLisDTD;
 <!ENTITY % FilterListDialogDTD SYSTEM "chrome://messenger/locale/FilterListDialog.dtd">
 %FilterListDialogDTD;
 ]>
 
-<dialog id="mailViewListDialog"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
         onload="mailViewListOnLoad();"
         windowtype="mailnews:mailviewlist"
         title="&mailViewListTitle.label;"
         width="400" height="340"
-        buttons="accept"
         persist="screenX screenY width height">
+<dialog id="mailViewListDialog"
+        buttons="accept">
 
   <script src="chrome://messenger/content/mailViewList.js"/>
 
   <vbox flex="1">
     <hbox flex="1">
       <richlistbox id="mailViewList"
                    class="theme-listbox"
                    flex="1"
@@ -34,8 +34,9 @@
       <vbox>
         <button id="newButton" label="&newButton.label;" accesskey="&newButton.accesskey;" oncommand="onNewMailView();"/>
         <button id="editButton" label="&editButton.label;" accesskey="&editButton.accesskey;" oncommand="onEditMailView();"/>
         <button id="deleteButton" label="&deleteButton.label;" accesskey="&deleteButton.accesskey;" oncommand="onDeleteMailView();"/>
       </vbox>
     </hbox>
   </vbox>
 </dialog>
+</window>
--- a/mail/extensions/mailviews/content/mailViewSetup.js
+++ b/mail/extensions/mailviews/content/mailViewSetup.js
@@ -21,17 +21,17 @@ function mailViewOnLoad() {
     if ("mailView" in args) {
       gMailView = window.arguments[0].mailView;
     }
     if ("onOkCallback" in args) {
       dialog.okCallback = window.arguments[0].onOkCallback;
     }
   }
 
-  dialog.OKButton = document.documentElement.getButton("accept");
+  dialog.OKButton = document.querySelector("dialog").getButton("accept");
   dialog.nameField = document.getElementById("name");
   dialog.nameField.focus();
 
   setSearchScope(Ci.nsMsgSearchScope.offlineMail);
 
   if (gMailView) {
     dialog.nameField.value = gMailView.prettyName;
     initializeSearchRows(
--- a/mail/extensions/mailviews/content/mailViewSetup.xul
+++ b/mail/extensions/mailviews/content/mailViewSetup.xul
@@ -1,34 +1,34 @@
 <?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/shared/input-fields.css" type="text/css" ?>
 <?xml-stylesheet href="chrome://messenger/skin/searchDialog.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
   <!ENTITY % mailViewDTD SYSTEM "chrome://messenger/locale/mailViewSetup.dtd">
   %mailViewDTD;
   <!ENTITY % searchTermDTD SYSTEM "chrome://messenger/locale/searchTermOverlay.dtd">
   %searchTermDTD;
 ]>
 
-<dialog id="mailViewSetupDialog"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         onload="mailViewOnLoad();"
         onunload="mailViewOnUnLoad();"
-        buttons="accept,cancel"
-        buttonalign="end"
         windowtype="mailnews:mailview"
         title="&mailViewSetupTitle.label;"
         style="width: 52em; height: 22em;"
         persist="screenX screenY width height">
+<dialog id="mailViewSetupDialog"
+        buttons="accept,cancel"
+        buttonalign="end">
 
   <stringbundle id="bundle_search" src="chrome://messenger/locale/search.properties"/>
 
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://messenger/content/mailViewSetup.js"/>
   <script src="chrome://messenger/content/searchTerm.js"/>
   <script src="chrome://messenger/content/searchWidgets.js"/>
   <script src="chrome://messenger/content/dateFormat.js"/>
@@ -51,8 +51,9 @@
     <label value="&searchTermCaption.label;"/>
     <hbox flex="1">
       <vbox id="searchTermListBox" flex="1">
 #include ../../../../mailnews/base/search/content/searchTerm.inc.xul
     </hbox>
   </vbox>
 
 </dialog>
+</window>
--- a/mail/extensions/openpgp/content/ui/enigmailMsgBox.xul
+++ b/mail/extensions/openpgp/content/ui/enigmailMsgBox.xul
@@ -12,22 +12,22 @@
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % enigMailDTD SYSTEM "chrome://openpgp/content/strings/enigmail.dtd" >
 %enigMailDTD;
 <!ENTITY % utilityDTD SYSTEM "chrome://communicator/locale/utilityOverlay.dtd">
 %utilityDTD;
 ]>
 
-<dialog id="enigmailMsgBox"
-        title=""
+<window title=""
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         buttons="accept,help,cancel,extra1,extra2"
         onload="onLoad();"
-        xmlns:html="http://www.w3.org/1999/xhtml"
+        xmlns:html="http://www.w3.org/1999/xhtml">
+<dialog id="enigmailMsgBox"
         buttonpack="center">
 
   <script type="application/x-javascript" src="chrome://openpgp/content/ui/enigmailMsgBox.js"/>
 
   <popupset>
     <menupopup id="ctxmenu">
       <menuitem label="&copyCmd.label;" oncommand="copyToClipbrd()"/>
     </menupopup>
@@ -57,8 +57,9 @@
     </row>
     <row id="checkboxContainer" hidden="true">
       <spacer/>
       <checkbox id="theCheckBox" checked="false" oncommand="checkboxCb()"/>
     </row>
   </rows>
 </grid>
 </dialog>
+</window>
--- a/mail/extensions/openpgp/content/ui/keyDetailsDlg.js
+++ b/mail/extensions/openpgp/content/ui/keyDetailsDlg.js
@@ -27,17 +27,19 @@ var gUserId = null;
 var gKeyList = null;
 var gTreeFuncs = null;
 
 function onLoad() {
   window.arguments[1].refresh = false;
 
   gKeyId = window.arguments[0].keyId;
 
-  let accept = document.getElementById("enigmailKeyDetailsDlg").getButton("accept");
+  let accept = document
+    .getElementById("enigmailKeyDetailsDlg")
+    .getButton("accept");
   accept.focus();
 
   reloadData();
 }
 
 /***
  * Set the label text of a HTML element
  */
--- a/mail/extensions/openpgp/content/ui/keyDetailsDlg.xul
+++ b/mail/extensions/openpgp/content/ui/keyDetailsDlg.xul
@@ -10,26 +10,25 @@
 
 <!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % enigMailDTD SYSTEM "chrome://openpgp/content/strings/enigmail.dtd" >
 %enigMailDTD;
 ]>
 
-<dialog id="enigmailKeyDetailsDlg"
-        title="&enigmail.keyDetails.title;"
+<window title="&enigmail.keyDetails.title;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
-        buttons="accept"
         minwidth="450px"
         persist="width height"
-        buttonlabelaccept="&enigmail.cardDetails.closeWindow.label;"
         onload="onLoad();">
-
+<dialog id="enigmailKeyDetailsDlg"
+        buttons="accept"
+        buttonlabelaccept="&enigmail.cardDetails.closeWindow.label;">
 
   <script type="application/x-javascript" src="chrome://openpgp/content/ui/enigmailCommon.js"/>
   <script type="application/x-javascript" src="chrome://openpgp/content/ui/keyDetailsDlg.js"/>
   <script type="application/x-javascript" src="chrome://openpgp/content/ui/enigmailKeyManager.js"/>
 
   <broadcasterset>
     <broadcaster id="ownKeyCommands" hidden="true"/>
   </broadcasterset>
@@ -205,8 +204,9 @@
         <menuitem label="&enigmail.keyMan.changePwd.label;" oncommand="changePassword()"/>
         <menuitem label="&enigmail.keyMan.revokeKey.label;" oncommand="revokeKey()"/>
         <menuitem label="&enigmail.keyMan.ctxGenRevoke.label;" oncommand="genRevocationCert()"/>
       </menupopup>
     </button>
   </hbox>
 
 </dialog>
+</window>
--- a/mail/test/mozmill/account/test-account-values.js
+++ b/mail/test/mozmill/account/test-account-values.js
@@ -226,25 +226,27 @@ function subtest_check_account_name(aAcc
     assert_equals(username.value, aAccount.incomingServer.realUsername);
 
     // Now change the server user name.
     username.value = aNewUsername;
   }
 
   if (aNewUsername) {
     // If username has changed, we get a confirmation dialog.
-    plan_for_modal_dialog("commonDialog", function(cdc) {
+    plan_for_modal_dialog("commonDialogWindow", function(cdc) {
       // Just dismiss it.
-      cdc.window.document.documentElement.acceptDialog();
+      cdc.window.document.documentElement
+        .querySelector("dialog")
+        .acceptDialog();
     });
   }
   // We really need to save the new values so click OK on the Account settings.
-  amc.window.document.documentElement.acceptDialog();
+  amc.window.document.documentElement.querySelector("dialog").acceptDialog();
   if (aNewUsername) {
-    wait_for_modal_dialog("commonDialog");
+    wait_for_modal_dialog("commonDialogWindow");
   }
 }
 
 /**
  * Bug 536768.
  * Check if invalid junk target settings (folders) are fixed to sane values.
  */
 function test_invalid_junk_target() {
@@ -275,17 +277,17 @@ function test_invalid_junk_target() {
  *
  * @param amc  the account options controller
  */
 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 so click OK on the Account settings.
-  amc.window.document.documentElement.acceptDialog();
+  amc.window.document.documentElement.querySelector("dialog").acceptDialog();
 }
 
 /**
  * Bug 327812.
  * Checks if invalid server hostnames are not accepted.
  */
 function test_invalid_hostname() {
   let branch = Services.prefs.getBranch(
@@ -331,25 +333,27 @@ function subtest_check_invalid_hostname(
     click_account_tree_row(amc, accountRow);
 
     // ...let's check that:
     iframe = amc.window.document.getElementById("contentFrame");
     hostname = iframe.contentDocument.getElementById("server.realHostName");
     assert_equals(hostname.value, aOriginalHostname);
   } else {
     // If the hostname is bad, we should get a warning dialog.
-    plan_for_modal_dialog("commonDialog", function(cdc) {
+    plan_for_modal_dialog("commonDialogWindow", function(cdc) {
       // Just dismiss it.
-      cdc.window.document.documentElement.acceptDialog();
+      cdc.window.document.documentElement
+        .querySelector("dialog")
+        .acceptDialog();
     });
 
     // Click OK on the Account settings.
-    amc.window.document.documentElement.acceptDialog();
+    amc.window.document.documentElement.querySelector("dialog").acceptDialog();
 
-    wait_for_modal_dialog("commonDialog");
+    wait_for_modal_dialog("commonDialogWindow");
   }
 }
 
 /**
  * Bug 1426328.
  * Check that the AM will trim user added spaces around text values.
  */
 const badName = "trailing  space ";
@@ -381,10 +385,10 @@ function subtest_check_trailing_spaces(a
   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 so click OK on the Account settings.
-  amc.window.document.documentElement.acceptDialog();
+  amc.window.document.documentElement.querySelector("dialog").acceptDialog();
 }
--- a/mail/test/mozmill/attachment/test-attachment.js
+++ b/mail/test/mozmill/attachment/test-attachment.js
@@ -308,19 +308,19 @@ function test_attachment_name_click() {
 
   assert_true(
     attachmentList.collapsed,
     "Attachment list should start out collapsed!"
   );
 
   // Ensure the open dialog appears when clicking on the attachment name and
   // that the attachment list doesn't expand.
-  plan_for_modal_dialog("unknownContentType", function() {});
+  plan_for_modal_dialog("unknownContentTypeWindow", function() {});
   mc.click(mc.eid("attachmentName"));
-  wait_for_modal_dialog("unknownContentType");
+  wait_for_modal_dialog("unknownContentTypeWindow");
   assert_true(
     attachmentList.collapsed,
     "Attachment list should not expand when clicking on attachmentName!"
   );
 }
 
 /**
  * Test that right-clicking on a particular element opens the expected context
@@ -530,28 +530,28 @@ function test_delete_attachment_key() {
 
   // Expand the attachment list.
   mc.click(mc.eid("attachmentToggle"));
 
   let firstAttachment = new elib.Elem(mc.e("attachmentList").firstElementChild);
   mc.click(firstAttachment, 5, 5);
 
   // Try deleting with the delete key
-  plan_for_modal_dialog("commonDialog", function(cdc) {
-    cdc.window.document.documentElement.cancelDialog();
+  plan_for_modal_dialog("commonDialogWindow", function(cdc) {
+    cdc.window.document.documentElement.querySelector("dialog").cancelDialog();
   });
   mc.keypress(firstAttachment, "VK_DELETE", {});
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   // Try deleting with the shift-delete key combo.
-  plan_for_modal_dialog("commonDialog", function(cdc) {
-    cdc.window.document.documentElement.cancelDialog();
+  plan_for_modal_dialog("commonDialogWindow", function(cdc) {
+    cdc.window.document.documentElement.querySelector("dialog").cancelDialog();
   });
   mc.keypress(firstAttachment, "VK_DELETE", { shiftKey: true });
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 }
 
 function test_attachments_compose_menu() {
   be_in_folder(folder);
 
   // First, select the message with two attachments.
   select_none();
   select_click_row(3);
--- a/mail/test/mozmill/composition/test-attachment-reminder.js
+++ b/mail/test/mozmill/composition/test-attachment-reminder.js
@@ -173,19 +173,19 @@ function test_attachment_reminder_appear
     )
   );
   wait_for_reminder_state(cwc, false);
 
   // The manual reminder should be enabled now.
   assert_manual_reminder_state(cwc, true);
 
   // Now try to send, make sure we get the alert.
-  plan_for_modal_dialog("commonDialog", click_oh_i_did);
+  plan_for_modal_dialog("commonDialogWindow", click_oh_i_did);
   cwc.click(cwc.eid("button-send"));
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   // After confirming the reminder the menuitem should get disabled.
   assert_manual_reminder_state(cwc, false);
 
   close_compose_window(cwc);
 }
 
 /**
@@ -209,19 +209,19 @@ function test_attachment_reminder_dismis
 
   // Give the notification time to appear.
   wait_for_reminder_state(cwc, true);
 
   assert_equals(get_reminder_keywords(cwc), "test.doc, attachment, attached");
 
   // We didn't click the "Remind Me Later" - the alert should pop up
   // on send anyway.
-  plan_for_modal_dialog("commonDialog", click_oh_i_did);
+  plan_for_modal_dialog("commonDialogWindow", click_oh_i_did);
   cwc.click(cwc.eid("button-send"));
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   let notification = assert_automatic_reminder_state(cwc, true);
 
   notification.close();
   assert_automatic_reminder_state(cwc, false);
 
   click_send_and_handle_send_error(cwc);
 
@@ -319,19 +319,19 @@ function test_no_send_now_sends() {
     "test@example.org",
     "will the 'No, Send Now' button work?",
     "Hello, I got your attachment!"
   );
 
   wait_for_reminder_state(cwc, true);
 
   // Click the send button again, this time choose "No, Send Now".
-  plan_for_modal_dialog("commonDialog", click_no_send_now);
+  plan_for_modal_dialog("commonDialogWindow", click_no_send_now);
   cwc.click(cwc.eid("button-send"));
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   // After clicking "Send Now" sending is proceeding, just handle the error.
   click_send_and_handle_send_error(cwc, true);
 
   // We're now back in the compose window, let's close it then.
   close_compose_window(cwc);
 }
 
@@ -373,19 +373,19 @@ function test_manual_attachment_reminder
   );
 
   // Enable the manual reminder.
   click_manual_reminder(cwc, true);
   // There should be no attachment notification.
   assert_automatic_reminder_state(cwc, false);
 
   // Now close the message with saving it as draft.
-  plan_for_modal_dialog("commonDialog", click_save_message);
+  plan_for_modal_dialog("commonDialogWindow", click_save_message);
   cwc.window.goDoCommand("cmd_close");
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   // Open another blank compose window.
   cwc = open_compose_new_mail();
   // This one should have the reminder disabled.
   assert_manual_reminder_state(cwc, false);
   // There should be no attachment notification.
   assert_automatic_reminder_state(cwc, false);
 
@@ -406,19 +406,19 @@ function test_manual_attachment_reminder
   cwc = wait_for_compose_window();
 
   // Check the reminder enablement was preserved in the message.
   assert_manual_reminder_state(cwc, true);
   // There should be no attachment notification.
   assert_automatic_reminder_state(cwc, false);
 
   // Now try to send, make sure we get the alert.
-  plan_for_modal_dialog("commonDialog", click_oh_i_did);
+  plan_for_modal_dialog("commonDialogWindow", click_oh_i_did);
   cwc.click(cwc.eid("button-send"));
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   // We were alerted once and the manual reminder is automatically turned off.
   assert_manual_reminder_state(cwc, false);
 
   // Enable the manual reminder and disable it again to see if it toggles right.
   click_manual_reminder(cwc, true);
   cwc.sleep(2000);
   click_manual_reminder(cwc, false);
@@ -669,19 +669,19 @@ function test_reminder_in_draft() {
   // Add some keyword so the automatic notification
   // could potentially show up.
   setup_msg_contents(cwc, "", "", " and look for your attachment!");
 
   // Give the notification time to appear.
   wait_for_reminder_state(cwc, true);
 
   // Now close the message with saving it as draft.
-  plan_for_modal_dialog("commonDialog", click_save_message);
+  plan_for_modal_dialog("commonDialogWindow", click_save_message);
   cwc.window.goDoCommand("cmd_close");
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   // The draft message was saved into Local Folders/Drafts.
   be_in_folder(gDrafts);
 
   select_click_row(0);
   // Wait for the notification with the Edit button.
   wait_for_notification_to_show(mc, "mail-notification-top", "draftMsgContent");
   // Edit the draft again...
@@ -783,52 +783,64 @@ function test_disabling_attachment_remin
  * Click the send button and handle the send error dialog popping up.
  * It will return us back to the compose window.
  *
  * @param aController
  * @param aAlreadySending  Set this to true if sending was already triggered
  *                         by other means.
  */
 function click_send_and_handle_send_error(aController, aAlreadySending) {
-  plan_for_modal_dialog("commonDialog", click_ok_on_send_error);
+  plan_for_modal_dialog("commonDialogWindow", click_ok_on_send_error);
   if (!aAlreadySending) {
     aController.click(aController.eid("button-send"));
   }
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 }
 
 /**
  * Click the "Oh, I Did!" button in the attachment reminder dialog.
  */
 function click_oh_i_did(controller) {
-  controller.window.document.documentElement.getButton("extra1").doCommand();
+  controller.window.document
+    .querySelector("dialog")
+    .getButton("extra1")
+    .doCommand();
 }
 
 /**
  * Click the "No, Send Now" button in the attachment reminder dialog.
  */
 function click_no_send_now(controller) {
-  controller.window.document.documentElement.getButton("accept").doCommand();
+  controller.window.document
+    .querySelector("dialog")
+    .getButton("accept")
+    .doCommand();
 }
 
 /**
  * Click Ok in the Send Message Error dialog.
  */
 function click_ok_on_send_error(controller) {
   if (controller.window.document.title != "Send Message Error") {
     throw new Error(
       "Not a send error dialog; title=" + controller.window.document.title
     );
   }
-  controller.window.document.documentElement.getButton("accept").doCommand();
+  controller.window.document
+    .querySelector("dialog")
+    .getButton("accept")
+    .doCommand();
 }
 
 /**
  * Click Save in the Save message dialog.
  */
 function click_save_message(controller) {
   if (controller.window.document.title != "Save Message") {
     throw new Error(
       "Not a Save message dialog; title=" + controller.window.document.title
     );
   }
-  controller.window.document.documentElement.getButton("accept").doCommand();
+  controller.window.document
+    .querySelector("dialog")
+    .getButton("accept")
+    .doCommand();
 }
--- a/mail/test/mozmill/composition/test-attachment.js
+++ b/mail/test/mozmill/composition/test-attachment.js
@@ -258,45 +258,51 @@ function test_delete_attachments() {
   delete_attachment(cwc, 0);
   check_total_attachment_size(cwc, files.length - 1);
 
   close_compose_window(cwc);
 }
 
 function subtest_rename_attachment(cwc) {
   cwc.e("loginTextbox").value = "renamed.txt";
-  cwc.window.document.documentElement.getButton("accept").doCommand();
+  cwc.window.document
+    .querySelector("dialog")
+    .getButton("accept")
+    .doCommand();
 }
 
 function test_rename_attachment() {
   let cwc = open_compose_new_mail();
 
   let url = filePrefix + "some/file/here.txt";
   let size = 1234;
 
   add_attachments(cwc, url, size);
 
   // Now, rename the attachment.
   let bucket = cwc.e("attachmentBucket");
   let node = bucket.querySelector("richlistitem.attachmentItem");
   cwc.click(new elib.Elem(node));
-  plan_for_modal_dialog("commonDialog", subtest_rename_attachment);
+  plan_for_modal_dialog("commonDialogWindow", subtest_rename_attachment);
   cwc.window.RenameSelectedAttachment();
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
 
   assert_equals(node.getAttribute("name"), "renamed.txt");
 
   check_attachment_size(cwc, 0, size);
   check_total_attachment_size(cwc, 1);
 
   close_compose_window(cwc);
 }
 
 function subtest_open_attachment(cwc) {
-  cwc.window.document.documentElement.getButton("cancel").doCommand();
+  cwc.window.document
+    .querySelector("dialog")
+    .getButton("cancel")
+    .doCommand();
 }
 
 function test_open_attachment() {
   let cwc = open_compose_new_mail();
 
   // set up our external file for attaching
   let thisFilePath = os.getFileForPath(__file__);
   let file = os.getFileForPath(os.abspath("./attachment.txt", thisFilePath));
@@ -306,19 +312,19 @@ function test_open_attachment() {
   let url = fileHandler.getURLSpecFromFile(file);
   let size = file.fileSize;
 
   add_attachments(cwc, url, size);
 
   // Now, open the attachment.
   let bucket = cwc.e("attachmentBucket");
   let node = bucket.querySelector("richlistitem.attachmentItem");
-  plan_for_modal_dialog("unknownContentType", subtest_open_attachment);
+  plan_for_modal_dialog("unknownContentTypeWindow", subtest_open_attachment);
   cwc.doubleClick(new elib.Elem(node));
-  wait_for_modal_dialog("unknownContentType");
+  wait_for_modal_dialog("unknownContentTypeWindow");
 
   close_compose_window(cwc);
 }
 
 function test_forward_raw_attachment() {
   be_in_folder(folder);
   select_click_row(1);
 
--- a/mail/test/mozmill/composition/test-forward-headers.js
+++ b/mail/test/mozmill/composition/test-forward-headers.js
@@ -69,19 +69,22 @@ function forward_selected_messages_and_g
   cwc = f(mc);
   cwc.type(cwc.eid("content-frame"), kText);
 
   let mailBody = get_compose_body(cwc);
   assert_previous_text(mailBody.firstChild, [kText]);
 
   plan_for_window_close(cwc);
   // mwc is modal window controller
-  plan_for_modal_dialog("commonDialog", function click_save(mwc) {
+  plan_for_modal_dialog("commonDialogWindow", function click_save(mwc) {
     // accept saving
-    mwc.window.document.documentElement.getButton("accept").doCommand();
+    mwc.window.document
+      .querySelector("dialog")
+      .getButton("accept")
+      .doCommand();
   });
 
   // quit -> do you want to save ?
   cwc.window.goDoCommand("cmd_close");
   // wait for the modal dialog to return
   wait_for_modal_dialog();
   // Actually quit the window.
   wait_for_window_close();
--- a/mail/test/mozmill/composition/test-image-insertion-dialog.js
+++ b/mail/test/mozmill/composition/test-image-insertion-dialog.js
@@ -27,108 +27,108 @@ var wh = ChromeUtils.import(
 
 function test_image_insertion_dialog_persist() {
   let cwc = open_compose_new_mail();
 
   // First focus on the editor element
   cwc.e("content-frame").focus();
 
   // Now open the image window
-  wh.plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     // Insert the url of the image.
     let srcloc = mwc.window.document.getElementById("srcInput");
     srcloc.focus();
 
     input_value(mwc, "whateverItDoesntMatterAnyway.png");
     mwc.sleep(0);
 
     // Don't add alternate text
     mwc.click(mwc.eid("noAltTextRadio"));
 
-    mwc.window.document.documentElement.acceptDialog();
+    mwc.window.document.documentElement.querySelector("dialog").acceptDialog();
   });
   cwc.click(cwc.eid("insertImage"));
   wh.wait_for_modal_dialog();
   wh.wait_for_window_close();
 
   // Check that the radio option persists
-  wh.plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     assert_true(
       mwc.window.document.getElementById("noAltTextRadio").selected,
       "We should persist the previously selected value"
     );
     // We change to "use alt text"
     mwc.click(mwc.eid("altTextRadio"));
-    mwc.window.document.documentElement.cancelDialog();
+    mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
   });
   cwc.click(cwc.eid("insertImage"));
   wh.wait_for_modal_dialog();
   wh.wait_for_window_close();
 
   // Check that the radio option still persists (be really sure)
-  wh.plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     assert_true(
       mwc.window.document.getElementById("altTextRadio").selected,
       "We should persist the previously selected value"
     );
     // Accept the dialog
-    mwc.window.document.documentElement.cancelDialog();
+    mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
   });
   cwc.click(cwc.eid("insertImage"));
   wh.wait_for_modal_dialog();
   wh.wait_for_window_close();
   cwc.sleep(500);
 
   // Get the inserted image, double-click it, make sure we switch to "no alt
   // text", despite the persisted value being "use alt text"
   let img = cwc.e("content-frame").contentDocument.querySelector("img");
-  wh.plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     assert_true(
       mwc.window.document.getElementById("noAltTextRadio").selected,
       "We shouldn't use the persisted value because the insert image has no alt text"
     );
-    mwc.window.document.documentElement.cancelDialog();
+    mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
   });
   cwc.doubleClick(new elib.Elem(img));
   wh.wait_for_modal_dialog();
   wh.wait_for_window_close();
   // It's not clear why we have to wait here to avoid test failures,
   // see bug 1246094.
   cwc.sleep(500);
 
   // Now use some alt text for the edit image dialog
-  wh.plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     assert_true(
       mwc.window.document.getElementById("noAltTextRadio").selected,
       "That value should persist still..."
     );
     mwc.click(mwc.eid("altTextRadio"));
 
     let srcloc = mwc.window.document.getElementById("altTextInput");
     srcloc.focus();
     input_value(mwc, "some alt text");
     mwc.sleep(0);
     // Accept the dialog
-    mwc.window.document.documentElement.acceptDialog();
+    mwc.window.document.documentElement.querySelector("dialog").acceptDialog();
   });
   cwc.doubleClick(new elib.Elem(img));
   wh.wait_for_modal_dialog();
   wh.wait_for_window_close();
   // It's not clear why we have to wait here to avoid test failures,
   // see bug 1246094.
   cwc.sleep(500);
 
   // Make sure next time we edit it, we still have "use alt text" selected.
   img = cwc.e("content-frame").contentDocument.querySelector("img");
-  wh.plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     assert_true(
       mwc.window.document.getElementById("altTextRadio").selected,
       "We edited the image to make it have alt text, we should keep it selected"
     );
     // Accept the dialog
-    mwc.window.document.documentElement.cancelDialog();
+    mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
   });
   cwc.doubleClick(new elib.Elem(img));
   wh.wait_for_modal_dialog();
   wh.wait_for_window_close();
 
   close_compose_window(cwc);
 }
--- a/mail/test/mozmill/composition/test-multipart-related.js
+++ b/mail/test/mozmill/composition/test-multipart-related.js
@@ -94,24 +94,24 @@ function test_basic_multipart_related() 
   const fname = "./tb-logo.png";
   let file = os.getFileForPath(os.abspath(fname, os.getFileForPath(__file__)));
   let fileHandler = Services.io
     .getProtocolHandler("file")
     .QueryInterface(Ci.nsIFileProtocolHandler);
   let fileURL = fileHandler.getURLSpecFromFile(file);
 
   // Add a simple image to our dialog
-  plan_for_modal_dialog("imageDlg", function(dialog) {
+  plan_for_modal_dialog("Mail:image", function(dialog) {
     // Insert the url of the image.
     dialog.type(null, fileURL);
     dialog.type(dialog.eid("altTextInput"), "Alt text");
     dialog.sleep(0);
 
     // Accept the dialog
-    dialog.window.document.getElementById("imageDlg").acceptDialog();
+    dialog.window.document.querySelector("dialog").acceptDialog();
   });
   compWin.click(compWin.eid("insertImage"));
   wait_for_modal_dialog();
   wait_for_window_close();
 
   // Ctrl+S = save as draft.
   compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
   close_compose_window(compWin);
--- a/mail/test/mozmill/content-policy/test-compose-mailto.js
+++ b/mail/test/mozmill/content-policy/test-compose-mailto.js
@@ -43,29 +43,29 @@ function test_openComposeFromMailToLink(
   );
 }
 
 function test_checkInsertImage() {
   // First focus on the editor element
   gComposeWin.e("content-frame").focus();
 
   // Now open the image window
-  plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     // Insert the url of the image.
     let srcloc = mwc.window.document.getElementById("srcInput");
     srcloc.focus();
 
     input_value(mwc, url + "pass.png");
     mwc.sleep(0);
 
     // Don't add alternate text
     mwc.click(mwc.eid("noAltTextRadio"));
 
     // Accept the dialog
-    mwc.window.document.getElementById("imageDlg").acceptDialog();
+    mwc.window.document.querySelector("dialog").acceptDialog();
   });
   gComposeWin.click(gComposeWin.eid("insertImage"));
 
   wait_for_modal_dialog();
   wait_for_window_close();
 
   //  gComposeWin.sleep(500);
 
--- a/mail/test/mozmill/content-policy/test-general-content-policy.js
+++ b/mail/test/mozmill/content-policy/test-general-content-policy.js
@@ -645,29 +645,29 @@ function subtest_insertImageIntoReplyFor
 
   // Now insert the image
   // (copied from test-compose-mailto.js:test_checkInsertImage()).
 
   // First focus on the editor element
   replyWindow.e("content-frame").focus();
 
   // Now open the image window
-  plan_for_modal_dialog("imageDlg", function insert_image(mwc) {
+  plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
     // Insert the url of the image.
     let srcloc = mwc.window.document.getElementById("srcInput");
     srcloc.focus();
 
     input_value(mwc, url + "pass.png");
     mwc.sleep(0);
 
     // Don't add alternate text
     mwc.click(mwc.eid("noAltTextRadio"));
 
     // Accept the dialog
-    mwc.window.document.getElementById("imageDlg").acceptDialog();
+    mwc.window.document.querySelector("dialog").acceptDialog();
   });
   replyWindow.click(replyWindow.eid("insertImage"));
 
   wait_for_modal_dialog();
   wait_for_window_close();
 
   // Paste an image.
   putHTMLOnClipboard("<img id='tmp-img' src='" + url + "pass.png' />");
--- a/mail/test/mozmill/content-tabs/test-content-tab.js
+++ b/mail/test/mozmill/content-tabs/test-content-tab.js
@@ -198,18 +198,21 @@ function test_content_tab_onbeforeunload
   let tab = mc.tabmail.tabInfo[count - 1];
   tab.browser.contentWindow.addEventListener("beforeunload", function(event) {
     event.returnValue = "Green llama in your car";
   });
 
   const interactionPref = "dom.require_user_interaction_for_beforeunload";
   Services.prefs.setBoolPref(interactionPref, false);
 
-  plan_for_modal_dialog("commonDialog", function(controller) {
-    controller.window.document.documentElement.getButton("accept").doCommand();
+  plan_for_modal_dialog("commonDialogWindow", function(controller) {
+    controller.window.document
+      .querySelector("dialog")
+      .getButton("accept")
+      .doCommand();
   });
   mc.tabmail.closeTab(tab);
   wait_for_modal_dialog();
 
   Services.prefs.clearUserPref(interactionPref);
 }
 
 // XXX todo
--- a/mail/test/mozmill/folder-display/test-columns.js
+++ b/mail/test/mozmill/folder-display/test-columns.js
@@ -418,36 +418,39 @@ function test_reset_to_inbox() {
   show_column("sizeCol");
   assert_visible_columns(conExtra);
 
   // reset!
   invoke_column_picker_option([{ anonid: "menuitem" }]);
 }
 
 function subtest_say_yes(cwc) {
-  cwc.window.document.documentElement.getButton("accept").doCommand();
+  cwc.window.document
+    .querySelector("dialog")
+    .getButton("accept")
+    .doCommand();
 }
 
 function _apply_to_folder_common(aChildrenToo, folder) {
   if (aChildrenToo) {
     plan_for_observable_event("msg-folder-columns-propagated");
   }
-  plan_for_modal_dialog("commonDialog", subtest_say_yes);
+  plan_for_modal_dialog("commonDialogWindow", subtest_say_yes);
   invoke_column_picker_option([
     { class: "applyTo-menu" },
     {
       class: aChildrenToo
         ? "applyToFolderAndChildren-menu"
         : "applyToFolder-menu",
     },
     { label: "Local Folders" },
     { label: folder.name },
     { label: folder.name },
   ]);
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   if (aChildrenToo) {
     wait_for_observable_event("msg-folder-columns-propagated");
   }
 }
 
 /**
  * Change settings in a folder, apply them to another folder that also has
  *  children.  Make sure the folder changes but the children do not.
--- a/mail/test/mozmill/folder-display/test-message-commands.js
+++ b/mail/test/mozmill/folder-display/test-message-commands.js
@@ -309,78 +309,90 @@ function test_mark_all_read() {
 }
 
 function test_shift_delete_prompt() {
   be_in_folder(shiftDeleteFolder);
   let curMessage = select_click_row(0);
 
   // First, try shift-deleting and then cancelling at the prompt.
   Services.prefs.setBoolPref("mail.warn_on_shift_delete", true);
-  plan_for_modal_dialog("commonDialog", function(controller) {
-    controller.window.document.documentElement.getButton("cancel").doCommand();
+  plan_for_modal_dialog("commonDialogWindow", function(controller) {
+    controller.window.document
+      .querySelector("dialog")
+      .getButton("cancel")
+      .doCommand();
   });
   // We don't use press_delete here because we're not actually deleting this
   // time!
   mc.keypress(null, "VK_DELETE", { shiftKey: true });
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we didn't actually delete the message.
   assert_equals(curMessage, select_click_row(0));
 
   // Second, try shift-deleting and then accepting the deletion.
-  plan_for_modal_dialog("commonDialog", function(controller) {
-    controller.window.document.documentElement.getButton("accept").doCommand();
+  plan_for_modal_dialog("commonDialogWindow", function(controller) {
+    controller.window.document
+      .querySelector("dialog")
+      .getButton("accept")
+      .doCommand();
   });
   press_delete(mc, { shiftKey: true });
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we really did delete the message.
   assert_not_equals(curMessage, select_click_row(0));
 
   // Finally, try shift-deleting when we turned off the prompt.
   Services.prefs.setBoolPref("mail.warn_on_shift_delete", false);
   curMessage = select_click_row(0);
   press_delete(mc, { shiftKey: true });
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we really did delete the message.
   assert_not_equals(curMessage, select_click_row(0));
 
   Services.prefs.clearUserPref("mail.warn_on_shift_delete");
 }
 
 function test_thread_delete_prompt() {
   be_in_folder(threadDeleteFolder);
   make_display_threaded();
   collapse_all_threads();
 
   let curMessage = select_click_row(0);
   // First, try deleting and then cancelling at the prompt.
   Services.prefs.setBoolPref("mail.warn_on_collapsed_thread_operation", true);
-  plan_for_modal_dialog("commonDialog", function(controller) {
-    controller.window.document.documentElement.getButton("cancel").doCommand();
+  plan_for_modal_dialog("commonDialogWindow", function(controller) {
+    controller.window.document
+      .querySelector("dialog")
+      .getButton("cancel")
+      .doCommand();
   });
   // We don't use press_delete here because we're not actually deleting this
   // time!
   mc.keypress(null, "VK_DELETE", {});
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we didn't actually delete the message.
   assert_equals(curMessage, select_click_row(0));
 
   // Second, try deleting and then accepting the deletion.
-  plan_for_modal_dialog("commonDialog", function(controller) {
-    controller.window.document.documentElement.getButton("accept").doCommand();
+  plan_for_modal_dialog("commonDialogWindow", function(controller) {
+    controller.window.document
+      .querySelector("dialog")
+      .getButton("accept")
+      .doCommand();
   });
   press_delete(mc);
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we really did delete the message.
   assert_not_equals(curMessage, select_click_row(0));
 
   // Finally, try shift-deleting when we turned off the prompt.
   Services.prefs.setBoolPref("mail.warn_on_collapsed_thread_operation", false);
   curMessage = select_click_row(0);
   press_delete(mc);
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we really did delete the message.
   assert_not_equals(curMessage, select_click_row(0));
 
   Services.prefs.clearUserPref("mail.warn_on_collapsed_thread_operation");
 }
 
 function test_yearly_archive() {
   yearly_archive(false);
--- a/mail/test/mozmill/folder-display/test-message-window.js
+++ b/mail/test/mozmill/folder-display/test-message-window.js
@@ -107,36 +107,39 @@ function test_delete_single_message() {
 function test_del_collapsed_thread() {
   press_delete(msgc);
   if (folderA.getTotalMessages(false) != 4) {
     throw new Error("should have only deleted one message");
   }
 }
 
 function subtest_say_yes(cwc) {
-  cwc.window.document.documentElement.getButton("accept").doCommand();
+  cwc.window.document
+    .querySelector("dialog")
+    .getButton("accept")
+    .doCommand();
 }
 
 /**
  * Hit n enough times to mark all messages in folder A read, and then accept the
  * modal dialog saying that we should move to the next folder. Then, assert that
  * the message displayed in the standalone message window is folder B's first
  * message (since all messages in folder B were unread).
  */
 function test_next_unread() {
   for (let i = 0; i < 3; ++i) {
     plan_for_message_display(msgc);
     msgc.keypress(null, "n", {});
     wait_for_message_display_completion(msgc, true);
   }
 
-  plan_for_modal_dialog("commonDialog", subtest_say_yes);
+  plan_for_modal_dialog("commonDialogWindow", subtest_say_yes);
   msgc.keypress(null, "n", {});
   plan_for_message_display(msgc);
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   wait_for_message_display_completion(msgc, true);
 
   // move to folder B
   be_in_folder(folderB);
 
   // select the first message, and make sure it's not read
   let msg = select_click_row(0);
 
--- a/mail/test/mozmill/folder-pane/test-folder-pane-consumers.js
+++ b/mail/test/mozmill/folder-pane/test-folder-pane-consumers.js
@@ -45,31 +45,31 @@ function subtest_create_virtual_folder(v
   // Open the folder chooser.
   plan_for_modal_dialog(
     "mailnews:virtualFolderList",
     subtest_check_virtual_folder_list
   );
   vfc.click(vfc.eid("folderListPicker"));
   wait_for_modal_dialog("mailnews:virtualFolderList");
 
-  vfc.window.document.documentElement.cancelDialog();
+  vfc.window.document.documentElement.querySelector("dialog").cancelDialog();
 }
 
 /**
  * Bug 464710
  * Check the folder list picker is not empty.
  */
 function subtest_check_virtual_folder_list(listc) {
   let tree = listc.e("folderPickerTree");
   // We should see the folders from the 2 base local accounts here.
   assert_true(
     tree.view.rowCount > 0,
     "Folder tree was empty in virtual folder selection!"
   );
-  listc.window.document.documentElement.cancelDialog();
+  listc.window.document.documentElement.querySelector("dialog").cancelDialog();
 }
 
 function test_offline_sync_folder_selection_tree() {
   plan_for_modal_dialog("mailnews:synchronizeOffline", subtest_offline_sync);
 
   mc.click_through_appmenu(
     [{ id: "appmenu_File" }, { id: "appmenu_offline" }],
     { id: "appmenu_synchronizeOffline" }
@@ -82,28 +82,28 @@ function subtest_offline_sync(osc) {
   // Open the folder chooser.
   plan_for_modal_dialog(
     "mailnews:selectOffline",
     subtest_check_offline_folder_list
   );
   osc.click(osc.eid("select"));
   wait_for_modal_dialog("mailnews:selectOffline");
 
-  osc.window.document.documentElement.cancelDialog();
+  osc.window.document.documentElement.querySelector("dialog").cancelDialog();
 }
 
 /**
  * Bug 464710
  * Check the folder list picker is not empty.
  */
 function subtest_check_offline_folder_list(listc) {
   let tree = listc.e("synchronizeTree");
   // We should see the newsgroups from the NNTP server here.
   assert_true(
     tree.view.rowCount > 0,
     "Folder tree was empty in offline sync selection!"
   );
-  listc.window.document.documentElement.cancelDialog();
+  listc.window.document.documentElement.querySelector("dialog").cancelDialog();
 }
 
 function teardownModule() {
   MailServices.accounts.removeAccount(nntpAccount);
 }
--- a/mail/test/mozmill/message-header/test-phishing-bar.js
+++ b/mail/test/mozmill/message-header/test-phishing-bar.js
@@ -232,17 +232,17 @@ function test_no_phishing_warning_for_su
  * has no TLD, we still warn as appropriate.
  */
 function test_phishing_warning_for_local_domain() {
   be_in_folder(folder);
   select_click_row(5);
 
   let dialogAppeared = false;
 
-  plan_for_modal_dialog("commonDialog", function(ctrler) {
+  plan_for_modal_dialog("commonDialogWindow", function(ctrler) {
     dialogAppeared = true;
   });
 
   click_link_if_available();
 
   return dialogAppeared;
 }
 
--- a/mail/test/mozmill/message-window/test-vcard-actions.js
+++ b/mail/test/mozmill/message-window/test-vcard-actions.js
@@ -36,17 +36,19 @@ function test_check_vcard_icon() {
     "meister@example.com"
   );
   assert_equals(newcards.length, 0);
 
   function subtest_check_card(cardc) {
     // Check new card is properly prefilled.
     let emailField = cardc.e("PrimaryEmail");
     assert_equals(emailField.value, "meister@example.com");
-    cardc.window.document.documentElement.acceptDialog();
+    cardc.window.document.documentElement
+      .querySelector("dialog")
+      .acceptDialog();
   }
 
   // Click icon on the vcard block.
   let vcard = msgc
     .e("messagepane")
     .contentDocument.querySelector(".moz-vcard-badge");
   // Check new card dialog opens.
   plan_for_modal_dialog("mailnews:newcarddialog", subtest_check_card);
--- a/mail/test/mozmill/search-window/test-search-window.js
+++ b/mail/test/mozmill/search-window/test-search-window.js
@@ -306,17 +306,17 @@ function subtest_save_search(savc) {
   savc.assertValue(searchVal1, "bar");
 
   // - name the search
   savc.type(savc.eid("name"), "SearchSaved");
 
   // - save it!
   // this will close the dialog, which wait_for_modal_dialog is making sure
   //  happens.
-  savc.window.document.documentElement.acceptDialog();
+  savc.window.document.documentElement.querySelector("dialog").acceptDialog();
 }
 
 function test_close_search_window() {
   swc.window.focus();
   // now close the search window
   plan_for_window_close(swc);
   swc.keypress(null, "VK_ESCAPE", {});
   wait_for_window_close(swc);
--- a/mail/test/mozmill/shared-modules/AccountManagerHelpers.jsm
+++ b/mail/test/mozmill/shared-modules/AccountManagerHelpers.jsm
@@ -184,24 +184,26 @@ function remove_account(
       );
     }
     if (aRemoveData) {
       cdc.click(
         new elib.Elem(cdc.window.document.getElementById("removeData"))
       );
     }
 
-    cdc.window.document.documentElement.acceptDialog();
+    cdc.window.document.documentElement.querySelector("dialog").acceptDialog();
     cdc.waitFor(
-      () => !cdc.window.document.documentElement.getButton("accept").disabled,
+      () =>
+        !cdc.window.document.querySelector("dialog").getButton("accept")
+          .disabled,
       "Timeout waiting for finish of account removal",
       5000,
       100
     );
-    cdc.window.document.documentElement.acceptDialog();
+    cdc.window.document.documentElement.querySelector("dialog").acceptDialog();
   });
 
   aAccount = null;
   // Use the Remove item in the Account actions menu.
   aController.click(aController.eid("accountActionsButton"));
   aController.click_menus_in_sequence(aController.e("accountActionsDropdown"), [
     { id: "accountActionsDropdownRemove" },
   ]);
--- a/mail/test/mozmill/shared-modules/AddressBookHelpers.jsm
+++ b/mail/test/mozmill/shared-modules/AddressBookHelpers.jsm
@@ -404,29 +404,33 @@ function select_contacts(aContacts) {
  *
  * @param aController the address book window controller to use.
  * @param aFunction the function to execute when the editing dialog
  *                  is opened (since it's a modal dialog).  The function
  *                  should take a single parameter, which will be the
  *                  augmented controller for the editing dialog.
  */
 function edit_selected_contact(aController, aFunction) {
-  windowHelper.plan_for_modal_dialog("abcardWindow", aFunction);
+  windowHelper.plan_for_modal_dialog("Mail:abcard", aFunction);
   aController.click(aController.eid("button-editcard"));
-  windowHelper.wait_for_modal_dialog("abcardWindow");
+  windowHelper.wait_for_modal_dialog("Mail:abcard");
 }
 
 /**
  * Accepts the changes entered into the contact editing dialog, and closes
  * the dialog.
  *
  * @param aController the contact editing dialog controller to use.
  */
 function accept_contact_changes(aController) {
-  if (!aController.window.document.documentElement.acceptDialog()) {
+  if (
+    !aController.window.document.documentElement
+      .querySelector("dialog")
+      .acceptDialog()
+  ) {
     throw new Error("Could not close the contact editing dialog!");
   }
 }
 
 /**
  * Deletes an address book.
  */
 function delete_address_book(aAddrBook) {
--- a/mail/test/mozmill/shared-modules/ComposeHelpers.jsm
+++ b/mail/test/mozmill/shared-modules/ComposeHelpers.jsm
@@ -228,23 +228,25 @@ function close_compose_window(aControlle
   if (aShouldPrompt === undefined) {
     // caller doesn't care if we get a prompt
     windowHelper.close_window(aController);
     return;
   }
 
   windowHelper.plan_for_window_close(aController);
   if (aShouldPrompt) {
-    windowHelper.plan_for_modal_dialog("commonDialog", function clickDontSave(
-      controller
-    ) {
-      controller.window.document.documentElement
-        .getButton("extra1")
-        .doCommand();
-    });
+    windowHelper.plan_for_modal_dialog(
+      "commonDialogWindow",
+      function clickDontSave(controller) {
+        controller.window.document
+          .querySelector("dialog")
+          .getButton("extra1")
+          .doCommand();
+      }
+    );
     // Try to close, we should get a prompt to save.
     aController.window.goDoCommand("cmd_close");
     windowHelper.wait_for_modal_dialog();
   } else {
     aController.window.goDoCommand("cmd_close");
   }
   windowHelper.wait_for_window_close();
 }