Bug 1600369 follow-up: Copy mozmill changes to mochitest; rs=bustage-fix
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 11 Dec 2019 20:09:34 +1300
changeset 37733 8315ea31d2a6b01bd59b3f7a58244f0cb96226bc
parent 37732 e5511e03843275c543c738989bf097f4b3b52350
child 37734 0ccbdc62b6cd9839a3743c5bdfffe73d2730ba74
push id397
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:16:13 +0000
reviewersbustage-fix
bugs1600369
Bug 1600369 follow-up: Copy mozmill changes to mochitest; rs=bustage-fix
mail/test/browser/account/browser_values.js
mail/test/browser/attachment/browser_attachment.js
mail/test/browser/composition/browser_attachment.js
mail/test/browser/composition/browser_attachmentReminder.js
mail/test/browser/composition/browser_forwardHeaders.js
mail/test/browser/composition/browser_imageInsertionDialog.js
mail/test/browser/composition/browser_multipartRelated.js
mail/test/browser/content-policy/browser_composeMailto.js
mail/test/browser/content-policy/browser_generalContentPolicy.js
mail/test/browser/content-tabs/browser_contentTab.js
mail/test/browser/folder-display/browser_columns.js
mail/test/browser/folder-display/browser_messageCommands.js
mail/test/browser/folder-display/browser_messageWindow.js
mail/test/browser/folder-pane/browser_folderPaneConsumers.js
mail/test/browser/message-header/browser_phishingBar.js
mail/test/browser/message-window/browser_vcardActions.js
mail/test/browser/search-window/browser_searchWindow.js
--- a/mail/test/browser/account/browser_values.js
+++ b/mail/test/browser/account/browser_values.js
@@ -223,25 +223,27 @@ function subtest_check_account_name(aAcc
     Assert.equal(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.
  */
 add_task(function test_invalid_junk_target() {
@@ -272,17 +274,17 @@ add_task(function test_invalid_junk_targ
  *
  * @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.
  */
 add_task(function test_invalid_hostname() {
   let branch = Services.prefs.getBranch(
@@ -328,25 +330,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.equal(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 ";
@@ -378,10 +382,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.equal(accountName.value, badName);
   Assert.equal(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/browser/attachment/browser_attachment.js
+++ b/mail/test/browser/attachment/browser_attachment.js
@@ -306,19 +306,19 @@ add_task(function test_attachment_name_c
 
   Assert.ok(
     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.ok(
     attachmentList.collapsed,
     "Attachment list should not expand when clicking on attachmentName!"
   );
 });
 
 /**
  * Test that right-clicking on a particular element opens the expected context
@@ -528,28 +528,28 @@ add_task(function test_delete_attachment
 
   // 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");
 });
 
 add_task(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/browser/composition/browser_attachment.js
+++ b/mail/test/browser/composition/browser_attachment.js
@@ -257,45 +257,51 @@ add_task(function test_delete_attachment
   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();
 }
 
 add_task(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.equal(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();
 }
 
 add_task(function test_open_attachment() {
   let cwc = open_compose_new_mail();
 
   // set up our external file for attaching
   let file = new FileUtils.File(getTestFilePath("data/attachment.txt"));
   let fileHandler = Services.io
@@ -304,19 +310,19 @@ add_task(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);
 });
 
 add_task(function test_forward_raw_attachment() {
   be_in_folder(folder);
   select_click_row(1);
 
--- a/mail/test/browser/composition/browser_attachmentReminder.js
+++ b/mail/test/browser/composition/browser_attachmentReminder.js
@@ -177,19 +177,19 @@ add_task(function test_attachment_remind
     )
   );
   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);
 });
 
 /**
@@ -213,19 +213,19 @@ add_task(function test_attachment_remind
 
   // Give the notification time to appear.
   wait_for_reminder_state(cwc, true);
 
   Assert.equal(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);
 
@@ -323,19 +323,19 @@ add_task(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);
 });
 
@@ -377,19 +377,19 @@ add_task(function test_manual_attachment
   );
 
   // 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);
 
@@ -410,19 +410,19 @@ add_task(function test_manual_attachment
   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);
@@ -672,19 +672,19 @@ add_task(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...
@@ -786,52 +786,64 @@ add_task(function test_disabling_attachm
  * 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/browser/composition/browser_forwardHeaders.js
+++ b/mail/test/browser/composition/browser_forwardHeaders.js
@@ -67,19 +67,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/browser/composition/browser_imageInsertionDialog.js
+++ b/mail/test/browser/composition/browser_imageInsertionDialog.js
@@ -24,108 +24,108 @@ var wh = ChromeUtils.import(
 
 add_task(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.ok(
       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.ok(
       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.ok(
       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.ok(
       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.ok(
       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/browser/composition/browser_multipartRelated.js
+++ b/mail/test/browser/composition/browser_multipartRelated.js
@@ -93,24 +93,24 @@ add_task(function test_basic_multipart_r
   const fname = "data/tb-logo.png";
   let file = new FileUtils.File(getTestFilePath(fname));
   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/browser/content-policy/browser_composeMailto.js
+++ b/mail/test/browser/content-policy/browser_composeMailto.js
@@ -42,29 +42,29 @@ add_task(function test_openComposeFromMa
   );
 });
 
 add_task(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/browser/content-policy/browser_generalContentPolicy.js
+++ b/mail/test/browser/content-policy/browser_generalContentPolicy.js
@@ -646,29 +646,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/browser/content-tabs/browser_contentTab.js
+++ b/mail/test/browser/content-tabs/browser_contentTab.js
@@ -191,18 +191,21 @@ add_task(function test_content_tab_onbef
   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/browser/folder-display/browser_columns.js
+++ b/mail/test/browser/folder-display/browser_columns.js
@@ -418,36 +418,39 @@ add_task(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/browser/folder-display/browser_messageCommands.js
+++ b/mail/test/browser/folder-display/browser_messageCommands.js
@@ -309,82 +309,94 @@ add_task(function test_mark_all_read() {
 });
 
 add_task(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!
   SimpleTest.ignoreAllUncaughtExceptions(true);
   mc.keypress(null, "VK_DELETE", { shiftKey: true });
   SimpleTest.ignoreAllUncaughtExceptions(false);
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we didn't actually delete the message.
   Assert.equal(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.notEqual(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.notEqual(curMessage, select_click_row(0));
 
   Services.prefs.clearUserPref("mail.warn_on_shift_delete");
 });
 
 add_task(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!
   SimpleTest.ignoreAllUncaughtExceptions(true);
   mc.keypress(null, "VK_DELETE", {});
   SimpleTest.ignoreAllUncaughtExceptions(false);
-  wait_for_modal_dialog("commonDialog");
+  wait_for_modal_dialog("commonDialogWindow");
   // Make sure we didn't actually delete the message.
   Assert.equal(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.notEqual(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.notEqual(curMessage, select_click_row(0));
 
   Services.prefs.clearUserPref("mail.warn_on_collapsed_thread_operation");
 });
 
 add_task(function test_yearly_archive() {
   yearly_archive(false);
--- a/mail/test/browser/folder-display/browser_messageWindow.js
+++ b/mail/test/browser/folder-display/browser_messageWindow.js
@@ -106,36 +106,39 @@ add_task(function test_delete_single_mes
 add_task(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).
  */
 add_task(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/browser/folder-pane/browser_folderPaneConsumers.js
+++ b/mail/test/browser/folder-pane/browser_folderPaneConsumers.js
@@ -49,31 +49,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.ok(
     tree.view.rowCount > 0,
     "Folder tree was empty in virtual folder selection!"
   );
-  listc.window.document.documentElement.cancelDialog();
+  listc.window.document.documentElement.querySelector("dialog").cancelDialog();
 }
 
 add_task(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" }
@@ -86,30 +86,30 @@ 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.ok(
     tree.view.rowCount > 0,
     "Folder tree was empty in offline sync selection!"
   );
-  listc.window.document.documentElement.cancelDialog();
+  listc.window.document.documentElement.querySelector("dialog").cancelDialog();
 }
 
 registerCleanupFunction(function teardownModule() {
   MailServices.accounts.removeAccount(nntpAccount);
 
   document.getElementById("folderTree").focus();
 });
--- a/mail/test/browser/message-header/browser_phishingBar.js
+++ b/mail/test/browser/message-header/browser_phishingBar.js
@@ -239,17 +239,17 @@ add_task(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();
 
   Assert.ok(dialogAppeared);
 }
 add_task(test_phishing_warning_for_local_domain);
--- a/mail/test/browser/message-window/browser_vcardActions.js
+++ b/mail/test/browser/message-window/browser_vcardActions.js
@@ -37,17 +37,19 @@ add_task(function test_check_vcard_icon(
     "meister@example.com"
   );
   Assert.equal(newcards.length, 0);
 
   function subtest_check_card(cardc) {
     // Check new card is properly prefilled.
     let emailField = cardc.e("PrimaryEmail");
     Assert.equal(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/browser/search-window/browser_searchWindow.js
+++ b/mail/test/browser/search-window/browser_searchWindow.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();
 }
 
 add_task(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);