Intermittent mozmill failure attempted fix: When switching to a tab with no
authorAndrew Sutherland <asutherland@asutherland.org>
Sat, 08 Aug 2009 21:04:41 -0700
changeset 3256 53a43c27c37de789ffd637585ee26260a2c45782
parent 3255 eff5af44c25493596e83c0ba99eebf711634557b
child 3257 4197d090fb6f2955506ec42eae0e9d66222aa225
push idunknown
push userunknown
push dateunknown
Intermittent mozmill failure attempted fix: When switching to a tab with no selected messages, wait for the message pane to become blank.
mail/test/mozmill/shared-modules/test-folder-display-helpers.js
--- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
@@ -345,17 +345,22 @@ function open_selected_message_in_new_wi
  */
 function switch_tab(aNewTab) {
   // If we're still loading a message at this point, wait for that to finish
   wait_for_message_display_completion();
   let targetTab = (aNewTab != null) ? aNewTab : otherTab;
   // now the current tab will be the 'other' tab after we switch
   otherTab = mc.tabmail.currentTabInfo;
   mc.tabmail.switchToTab(targetTab);
-  wait_for_message_display_completion();
+  // if there is something selected, wait for display completion
+  if (mc.folderDisplay.selectedCount)
+    wait_for_message_display_completion();
+  // otherwise wait for the pane to end up blank
+  else
+    wait_for_blank_content_pane();
 }
 
 /**
  * Assert that the currently selected tab is the given one.
  *
  * @param aTab The tab that should currently be selected.
  */
 function assert_selected_tab(aTab) {
@@ -876,16 +881,38 @@ function wait_for_message_display_comple
   controller.waitForEval('subject()',
                          NORMAL_TIMEOUT,
                          FAST_INTERVAL, isLoadedChecker);
   // the above may return immediately, meaning the event queue might not get a
   //  chance.  give it a chance now.
   aController.sleep(0);
 }
 
+/**
+ * Wait for the content pane to be blank because no message is to be displayed.
+ * You would not want to call this once folder summaries land and if they are
+ *  enabled.
+ *
+ * @param aController optional controller, defaulting to |mc|.
+ */
+function wait_for_blank_content_pane(aController) {
+  if (aController === undefined)
+    aController = mc;
+
+  let isBlankChecker = function() {
+    return aController.window.content.location.href == "about:blank";
+  };
+  controller.waitForEval('subject()',
+                         NORMAL_TIMEOUT,
+                         FAST_INTERVAL, isBlankChecker);
+  // the above may return immediately, meaning the event queue might not get a
+  //  chance.  give it a chance now.
+  aController.sleep(0);
+}
+
 
 var FolderListener = {
   _inited: false,
   ensureInited: function() {
     if (this._inited)
       return;
 
     let mailSession =