Bug 1604187 - fix browser_messageCommandsOnMsgstore.js test failures, as well as adding some assertions so that mochitest wouldn't complain it didn't get to check anything. r=darktrojan
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sun, 22 Dec 2019 21:51:41 +0200
changeset 37800 8d381659342943cfa560352e47ebd044bea18a6c
parent 37799 239192d9246bcdf945f1b20b73df74453198eca2
child 37801 81c5718b290ee7232e534979e446e810a01a9a51
push id397
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:16:13 +0000
reviewersdarktrojan
bugs1604187
Bug 1604187 - fix browser_messageCommandsOnMsgstore.js test failures, as well as adding some assertions so that mochitest wouldn't complain it didn't get to check anything. r=darktrojan
mail/base/content/msgHdrView.js
mail/base/content/multimessageview.js
mail/components/compose/content/addressingWidgetOverlay.js
mail/test/browser/folder-display/browser_folderPaneVisibility.js
mail/test/browser/folder-display/browser_messageCommandsOnMsgstore.js
mail/test/browser/folder-display/browser_messagePaneVisibility.js
--- a/mail/base/content/msgHdrView.js
+++ b/mail/base/content/msgHdrView.js
@@ -3505,22 +3505,24 @@ ConversationOpener.prototype = {
     } catch (e) {
       logException(e);
     }
   },
   isSelectedMessageIndexed() {
     let glodaEnabled = Services.prefs.getBoolPref(
       "mailnews.database.global.indexer.enabled"
     );
-
-    if (glodaEnabled && gFolderDisplay.selectedCount > 0) {
-      let message = gFolderDisplay.selectedMessage;
-      return Gloda.isMessageIndexed(message);
+    if (!glodaEnabled) {
+      return false;
     }
-    return false;
+    let message = gFolderDisplay.selectedMessage;
+    if (!message) {
+      return false;
+    }
+    return Gloda.isMessageIndexed(message);
   },
   onItemsAdded(aItems) {},
   onItemsModified(aItems) {},
   onItemsRemoved(aItems) {},
   onQueryCompleted(aCollection) {
     try {
       if (!aCollection.items.length) {
         Cu.reportError("Couldn't find a collection for msg: " + this._msgHdr);
--- a/mail/base/content/multimessageview.js
+++ b/mail/base/content/multimessageview.js
@@ -469,16 +469,19 @@ MultiMessageSummary.prototype = {
       // Unread and starred will get set if any of the messages in a collapsed
       // thread qualify.  The trick here is that we may get multiple items
       // corresponding to the same thread (and hence DOM node), so we need to
       // detect when we get the first item for a particular DOM node, stash the
       // preexisting status of that DOM node, an only do transitions if the
       // items warrant it.
       let key = glodaMsg.messageKey + glodaMsg.folder.uri;
       let headerNode = this._msgNodes[key];
+      if (!headerNode) {
+        continue;
+      }
       if (!knownMessageNodes.has(headerNode)) {
         knownMessageNodes.set(headerNode, {
           read: true,
           starred: false,
           tags: new Set(),
         });
       }
 
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -473,17 +473,19 @@ function recipientAddPill(element, autom
   // Reset the input element.
   element.removeAttribute("nomatch");
   element.setAttribute("size", 1);
   element.value = "";
 
   // We need to detach the autocomplete Controller to prevent the input
   // to be filled with the previously selected address when the "blur" event
   // gets triggered.
-  element.detachController();
+  if (element.mController.input) {
+    element.detachController();
+  }
   // Attach it again to enable autocomplete.
   element.attachController();
 
   onRecipientsChanged(automatic);
   calculateHeaderHeight();
 }
 
 /**
--- a/mail/test/browser/folder-display/browser_folderPaneVisibility.js
+++ b/mail/test/browser/folder-display/browser_folderPaneVisibility.js
@@ -23,16 +23,17 @@ var {
   "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
 );
 
 var folder;
 
 add_task(function setupModule(module) {
   folder = create_folder("FolderPaneVisibility");
   make_new_sets_in_folder(folder, [{ count: 3 }]);
+  Assert.ok(true, "setupModule ran to completion");
 });
 
 /**
  * When displaying a folder, assert that the folder pane is visible and all the
  * menus, splitters, etc. are set up right.
  */
 function assert_folder_pane_visible() {
   if (!mc.folderDisplay.folderPaneVisible) {
@@ -54,16 +55,17 @@ function assert_folder_pane_visible() {
 
   // - the menu item should be checked
   // force the view menu to update.
   mc.window.view_init();
   let paneMenuItem = mc.e("menu_showFolderPane");
   if (paneMenuItem.getAttribute("checked") != "true") {
     throw new Error("The Folder Pane menu item should be checked.");
   }
+  Assert.ok(true, "assert_folder_pane_visible ran to completion");
 }
 
 /**
  * When displaying a folder, assert that the folder pane is hidden and all the
  * menus, splitters, etc. are set up right.
  *
  * @param aFolderPaneIllegal Is the folder pane illegal to display at this time?
  *     This impacts whether the folder pane splitter should be visible.
@@ -95,46 +97,51 @@ function assert_folder_pane_hidden(aFold
   } else {
     if (mc.e("folderpane_splitter").collapsed === true) {
       throw new Error("folderpane_splitter should not be collapsed!");
     }
     if (paneMenuItem.getAttribute("checked") == "true") {
       throw new Error("The Folder Pane menu item should not be checked.");
     }
   }
+  Assert.ok(true, "assert_folder_pane_hidden ran to completion");
 }
 
 function toggle_folder_pane() {
   // Since we don't have a shortcut to toggle the folder pane, we're going to
   // have to collapse it ourselves
   mc.window.MsgToggleFolderPane();
+  Assert.ok(true, "toggle_folder_pane ran to completion");
 }
 
 /**
  * By default, the folder pane should be visible.
  */
 add_task(function test_folder_pane_visible_state_is_right() {
   be_in_folder(folder);
   assert_folder_pane_visible();
+  Assert.ok(true, "test_folder_pane_visible_state_is_right ran to completion");
 });
 
 /**
  * Toggle the folder pane off.
  */
 add_task(function test_toggle_folder_pane_off() {
   toggle_folder_pane();
   assert_folder_pane_hidden();
+  Assert.ok(true, "test_toggle_folder_pane_off ran to completion");
 });
 
 /**
  * Toggle the folder pane on.
  */
 add_task(function test_toggle_folder_pane_on() {
   toggle_folder_pane();
   assert_folder_pane_visible();
+  Assert.ok(true, "test_toggle_folder_pane_on ran to completion");
 });
 
 /**
  * Make sure that switching to message tabs of folder tabs with a different
  * folder pane state does not break. This test should cover all transition
  * states.
  */
 add_task(function test_folder_pane_is_sticky() {
@@ -191,16 +198,18 @@ add_task(function test_folder_pane_is_st
 
   // [folder+ => folder-]
   close_tab(tabFolderB);
   assert_folder_pane_hidden();
 
   // (redundant) [ folder pane toggle - => + ]
   toggle_folder_pane();
   assert_folder_pane_visible();
+
+  Assert.ok(true, "test_folder_pane_is_sticky ran to completion");
 });
 
 /**
  * Test that if we serialize and restore the tabs then the folder pane is in the
  * expected collapsed/non-collapsed state. Because of the special "first tab"
  * situation, we need to do this twice to test each case for the first tab.  For
  * additional thoroughness we also flip the state we have the other tabs be in.
  */
@@ -265,9 +274,14 @@ add_task(function test_folder_pane_persi
     closeTabs();
 
     // toggle the first tab again.  This sets - properly for the second pass and
     // restores it to + for when we are done.
     toggle_folder_pane();
   }
   // For one last time, make sure.
   assert_folder_pane_visible();
+
+  Assert.ok(
+    true,
+    "test_folder_pane_persistence_generally_works ran to completion"
+  );
 });
--- a/mail/test/browser/folder-display/browser_messageCommandsOnMsgstore.js
+++ b/mail/test/browser/folder-display/browser_messageCommandsOnMsgstore.js
@@ -267,18 +267,24 @@ add_task(function test_mark_messages_rep
 add_task(function test_mark_messages_forwarded() {
   be_in_folder(gInbox);
   // Forward a clean message.
   reply_forward_message(3, false);
   let curMessage = select_click_row(3);
   check_status(curMessage, null, null, Ci.nsMsgMessageFlags.Forwarded);
 
   // Forward a message that is read and already replied to.
+  curMessage = select_click_row(2);
+  check_status(
+    curMessage,
+    null,
+    null,
+    Ci.nsMsgMessageFlags.Replied + Ci.nsMsgMessageFlags.Read
+  );
   reply_forward_message(2, false);
-  curMessage = select_click_row(2);
   check_status(
     curMessage,
     null,
     null,
     Ci.nsMsgMessageFlags.Forwarded +
       Ci.nsMsgMessageFlags.Replied +
       Ci.nsMsgMessageFlags.Read
   );
--- a/mail/test/browser/folder-display/browser_messagePaneVisibility.js
+++ b/mail/test/browser/folder-display/browser_messagePaneVisibility.js
@@ -26,52 +26,57 @@ var {
   "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
 );
 
 var folder;
 
 add_task(function setupModule(module) {
   folder = create_folder("MessagePaneVisibility");
   make_new_sets_in_folder(folder, [{ count: 3 }]);
+  Assert.ok(true, "setupModule ran to completion");
 });
 
 /**
  * By default, the message pane should be visible.  Make sure that this state of
  *  affairs is correct in terms of menu options, splitters, etc.
  */
 add_task(function test_message_pane_visible_state_is_right() {
   be_in_folder(folder);
   assert_message_pane_visible();
+  Assert.ok(true, "test_message_pane_visible_state_is_right ran to completion");
 });
 
 /**
  * Make sure the account central page does not have the message pane splitter
  *  visible.  This should go elsewhere once we have more tests involving
  *  account central.  (Layout tests?)
  */
 add_task(function test_account_central_has_no_splitter() {
   be_in_folder(folder.rootFolder);
   assert_message_pane_hidden(true);
   be_in_folder(folder);
+  Assert.ok(true, "test_account_central_has_no_splitter ran to completion");
 });
 
 /**
  * Toggle the message off.
  */
 add_task(function test_toggle_message_pane_off() {
   toggle_message_pane();
   assert_message_pane_hidden();
+  Assert.ok(true, "test_toggle_message_pane_off ran to completion");
 });
 
 /**
  * Toggle the message pane on.
  */
 add_task(function test_toggle_message_pane_on() {
   toggle_message_pane();
   assert_message_pane_visible();
+  Assert.ok(true, "test_toggle_message_pane_on ran to completion");
 });
 
 /**
  * Make sure that the message tab isn't broken by being invoked from a folder tab
  *  with a collapsed message pane.
  */
 add_task(function test_collapsed_message_pane_does_not_break_message_tab() {
   be_in_folder(folder);
@@ -86,16 +91,21 @@ add_task(function test_collapsed_message
   assert_message_pane_visible(true);
 
   // - close the tab, sanity check the transition was okay
   close_tab(tabMessage);
   assert_message_pane_hidden();
 
   // - restore the state...
   toggle_message_pane();
+
+  Assert.ok(
+    true,
+    "test_collapsed_message_pane_does_not_break_message_tab ran to completion"
+  );
 });
 
 /**
  * Make sure that switching to message tabs or folder pane tabs with a different
  *  message pane state does not break.  This test should cover all transition
  *  states.
  */
 add_task(function test_message_pane_is_sticky() {
@@ -152,16 +162,18 @@ add_task(function test_message_pane_is_s
 
   // [folder+ => folder-]
   close_tab(tabFolderB);
   assert_message_pane_hidden();
 
   // (redundant) [ folder pane toggle - => + ]
   toggle_message_pane();
   assert_message_pane_visible();
+
+  Assert.ok(true, "test_message_pane_is_sticky ran to completion");
 });
 
 /**
  * Test that if we serialize and restore the tabs that the message pane is in
  *  the expected collapsed/non-collapsed state.  Because of the special "first
  *  tab" situation, we need to do this twice to test each case for the first
  *  tab.  For additional thoroughness we also flip the state we have the other
  *  tabs be in.
@@ -232,9 +244,14 @@ add_task(function test_message_pane_pers
     verifyTabs(config);
     SimpleTest.ignoreAllUncaughtExceptions(false);
     closeTabs();
 
     // toggle the first tab again.  This sets - properly for the second pass and
     //  restores it to + for when we are done.
     toggle_message_pane();
   }
+
+  Assert.ok(
+    true,
+    "test_message_pane_persistence_generally_works ran to completion"
+  );
 });