Bug 1489314 - Use get_compose_body() in TB MozMill tests where appropriate. r=jorgk
authoraceman <acelists@atlas.sk>
Thu, 06 Sep 2018 14:37:00 +0200
changeset 33087 a86f6197340ca93718eed554ae3c9a5417f4899a
parent 33086 4e7bcb952b297e85c6768466c639bf55c735a442
child 33088 0cac668a566b3f8bbfda07a76506b279d50215ec
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersjorgk
bugs1489314
Bug 1489314 - Use get_compose_body() in TB MozMill tests where appropriate. r=jorgk
mail/test/mozmill/composition/test-drafts.js
mail/test/mozmill/composition/test-eml-actions.js
mail/test/mozmill/composition/test-forwarded-eml-actions.js
mail/test/mozmill/shared-modules/test-compose-helpers.js
--- a/mail/test/mozmill/composition/test-drafts.js
+++ b/mail/test/mozmill/composition/test-drafts.js
@@ -256,19 +256,17 @@ function test_remove_space_stuffing_form
 
   // Wait for the notification with the Edit button.
   wait_for_notification_to_show(mc, kBoxId, "draftMsgContent");
 
   plan_for_new_window("msgcompose");
   mc.click(mc.eid(kBoxId, {tagName: "button", label: "Edit"}));
   cwc = wait_for_compose_window();
 
-  let bodyText = cwc.e("content-frame").contentDocument
-                    .querySelector("body").innerHTML;
-
+  let bodyText = get_compose_body(cwc).innerHTML;
   if (!bodyText.includes("NoSpace<br> OneSpace<br>  TwoSpaces")) {
     assert_true(false, "Something went wrong with space stuffing");
   }
 
   // Clean up the created draft.
   press_delete(mc);
 
   Services.prefs.setBoolPref("mail.identity.default.compose_html", oldHtmlPref);
--- a/mail/test/mozmill/composition/test-eml-actions.js
+++ b/mail/test/mozmill/composition/test-eml-actions.js
@@ -103,19 +103,17 @@ function test_reply_eml_subject() {
 function test_reply_to_base64_eml() {
   // Open an .eml file.
   let file = os.getFileForPath(
     os.abspath("./base64-encoded-msg.eml", os.getFileForPath(__file__)));
   let msgc = open_message_from_file(file);
 
   let compWin = open_compose_with_reply(msgc);
 
-  let bodyText = compWin.e("content-frame").contentDocument
-                        .querySelector("body").textContent;
-
+  let bodyText = get_compose_body(compWin).textContent;
   const message = "You have decoded this text from base64.";
   if (!bodyText.includes(message))
     throw new Error("body text didn't contain the decoded text; message=" +
                     message + ", bodyText=" + bodyText);
 
   close_compose_window(compWin);
   close_window(msgc);
 }
@@ -126,19 +124,17 @@ function test_reply_to_base64_eml() {
 function test_forward_base64_eml() {
   // Open an .eml file.
   let file = os.getFileForPath(
     os.abspath("./base64-encoded-msg.eml", os.getFileForPath(__file__)));
   let msgc = open_message_from_file(file);
 
   let compWin = open_compose_with_forward(msgc);
 
-  let bodyText = compWin.e("content-frame").contentDocument
-                        .querySelector("body").textContent;
-
+  let bodyText = get_compose_body(compWin).textContent;
   const message = "You have decoded this text from base64.";
   if (!bodyText.includes(message))
     throw new Error("body text didn't contain the decoded text; message=" +
                     message + ", bodyText=" + bodyText);
 
   close_compose_window(compWin);
   close_window(msgc);
 }
--- a/mail/test/mozmill/composition/test-forwarded-eml-actions.js
+++ b/mail/test/mozmill/composition/test-forwarded-eml-actions.js
@@ -78,17 +78,17 @@ var setupModule = function(module) {
     "\n" +
     "--------------080806020206040800000503--\n";
 
   folder.QueryInterface(Ci.nsIMsgLocalMailFolder);
   folder.addMessage(source);
 }
 
 /**
- * Helper to opend an attached .eml file, invoke the hotkey and check some
+ * Helper to open an attached .eml file, invoke the hotkey and check some
  * properties of the composition content we get.
  */
 function setupWindowAndTest(hotkeyToHit, hotkeyModifiers) {
   be_in_folder(folder);
 
   let msg = select_click_row(0);
   assert_selected_and_displayed(mc, msg);
 
@@ -96,18 +96,17 @@ function setupWindowAndTest(hotkeyToHit,
   mc.click(mc.eid("attachmentName"));
   let msgWin = wait_for_new_window("mail:messageWindow");
   wait_for_message_display_completion(msgWin, false);
 
   plan_for_new_window("msgcompose");
   msgWin.keypress(null, hotkeyToHit, hotkeyModifiers);
   let compWin = wait_for_compose_window(msgWin);
 
-  let bodyText= compWin.e("content-frame").contentDocument
-                       .querySelector("body").textContent;
+  let bodyText = get_compose_body(compWin).textContent;
   if (bodyText.includes("html"))
     throw new Error("body text contains raw html; bodyText=" + bodyText);
 
   if (!bodyText.includes(msgbodyA))
     throw new Error("body text didn't contain the body text; msgbodyA=" +
                     msgbodyB + ", bodyText=" + bodyText);
 
   let subjectText = compWin.e("msgSubject").value;
--- a/mail/test/mozmill/shared-modules/test-compose-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-compose-helpers.js
@@ -387,18 +387,20 @@ function delete_attachment(aComposeWindo
 }
 
 /**
  * Helper function returns the message body element of a composer window.
  *
  * @param aController the controller for a compose window.
  */
 function get_compose_body(aController) {
-  let mailDoc = aController.e("content-frame").contentDocument;
-  return mailDoc.querySelector("body");
+  let mailBody = aController.e("content-frame").contentDocument.querySelector("body");
+  if (!mailBody)
+    throw new Error("Compose body not found!");
+  return mailBody;
 }
 
 /**
  * Given some compose window controller, type some text into that composer,
  * pressing enter after each line except for the last.
  *
  * @param aController a compose window controller.
  * @param aText an array of strings to type.