fix navigation in stand-alone msg window, and add mozmill test, r=asuth, sr=standard8, 498334
authorDavid Bienvenu <bienvenu@nventure.com>
Mon, 22 Jun 2009 07:50:55 -0700
changeset 2917 e4ef3c76755d
parent 2916 7ce6fcae7689
child 2918 8e9c7828dce7
push id2366
push userbienvenu@nventure.com
push dateMon, 22 Jun 2009 14:50:42 +0000
treeherdercomm-central@e4ef3c76755d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, standard8, 498334
bugs498334
fix navigation in stand-alone msg window, and add mozmill test, r=asuth, sr=standard8, 498334
mail/base/content/messageWindow.js
mail/test/mozmill/folder-display/test-message-window.js
mailnews/base/util/jsTreeSelection.js
--- a/mail/base/content/messageWindow.js
+++ b/mail/base/content/messageWindow.js
@@ -97,16 +97,17 @@ StandaloneFolderDisplayWidget.prototype 
 
   /**
    * We never have a real treeview, so we always want to tell the view about
    *  the fake tree box so it will actually do something in NoteChange.
    */
   onCreatedView:
       function StandaloneMessageDisplayWidget_onCreatedView() {
     this._fakeTreeBox.view = this.view.dbView;
+    this._magicTreeSelection.view = this.view.dbView;
     // only if we're not dealing with a dummy message (from .eml file /
     //  attachment should we try and hook up the selection object.)  Otherwise
     //  the view will not operate in stand alone message mode.
     // XXX the sequencing here may break re-using a message window that is
     //  showing an .eml file to go to a real message, at least in terms of
     //  having the selection object properly associated with the tree.
     if (!this.messageDisplay.isDummy) {
       this.view.dbView.setTree(this._fakeTreeBox);
--- a/mail/test/mozmill/folder-display/test-message-window.js
+++ b/mail/test/mozmill/folder-display/test-message-window.js
@@ -40,26 +40,27 @@
  *  folder pane.
  */
 var MODULE_NAME = 'test-message-window';
 
 var RELATIVE_ROOT = '../shared-modules';
 var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers'];
 
 var folder;
+var msgSet;
 
 function setupModule(module) {
   let fdh = collector.getModule('folder-display-helpers');
   fdh.installInto(module);
   let wh = collector.getModule('window-helpers');
   wh.installInto(module);
 
   folder = create_folder("MessageWindowA");
-  // create a single message in the folder to display
-  make_new_sets_in_folder(folder, [{count: 1}]);
+  // create three messages in the folder to display
+  [msgSet] = make_new_sets_in_folder(folder, [{count: 3}]);
 }
 
 /** The message window controller. */
 var msgc;
 
 function test_open_message_window() {
   be_in_folder(folder);
 
@@ -67,15 +68,25 @@ function test_open_message_window() {
   let curMessage = select_click_row(0);
 
   // display it
   msgc = open_selected_message_in_new_window();
   assert_selected_and_displayed(msgc, curMessage);
 }
 
 /**
+ * Use the "f" keyboard accelerator to navigate to the next message,
+ * and verify that it is indeed loaded.
+ */
+function test_navigate_to_next_message() {
+  msgc.keypress(null, "f", {});
+  wait_for_message_display_completion(msgc, true);
+  assert_selected_and_displayed(msgc, 1);
+}
+
+/**
  * Close the window by hitting escape.
  */
 function test_close_message_window() {
   plan_for_window_close(msgc);
   msgc.keypress(null, "VK_ESCAPE", {});
   wait_for_window_close(msgc);
 }
\ No newline at end of file
--- a/mailnews/base/util/jsTreeSelection.js
+++ b/mailnews/base/util/jsTreeSelection.js
@@ -111,23 +111,30 @@ JSTreeSelection.prototype = {
    *  non-adjacent 'tuples' sort in ascending order.
    */
   _ranges: [],
   /**
    * The number of currently selected rows.
    */
   _count: 0,
 
+  // In the case of the stand-alone message window, there's no tree, but
+  // there's a view.
+  _view: null,
+  
   get tree JSTreeSelection_get_treeBoxObject() {
     return this._treeBoxObject;
   },
   set tree JSTreeSelection_set_treeBoxObject(aTreeBoxObject) {
     this._treeBoxObject = aTreeBoxObject;
   },
 
+  set view JSTreeSelection_set_view(aView) {
+    this._view = aView;
+  },
   /**
    * Although the nsITreeSelection documentation doesn't say, what this method
    *  is supposed to do is check if the seltype attribute on the XUL tree is any
    *  of the following: "single" (only a single row may be selected at a time,
    *  "cell" (a single cell may be selected), or "text" (the row gets selected
    *  but only the primary column shows up as selected.)
    *
    * @return false because we don't support single-selection.
@@ -602,24 +609,23 @@ JSTreeSelection.prototype = {
    * Note that we bypass any XUL "onselect" handler that may exist and go
    *  straight to the view.  If you have a tree, you shouldn't be using us,
    *  so this seems aboot right.
    */
   _fireSelectionChanged: function JSTreeSelection__fireSelectionChanged() {
     // don't fire if we are suppressed; we will fire when un-suppressed
     if (this.selectEventsSuppressed)
       return;
-    // we need a box object to get at the view
-    if (!this._treeBoxObject)
-      return;
-    // we need a view to have a view...
-    if (!this._treeBoxObject.view)
-      return;
+    let view;
+    if (this._treeBoxObject && this._treeBoxObject.view)
+      view = this._treeBoxObject.view;
+    else 
+      view = this._view;
 
-    let view = this._treeBoxObject.view.QueryInterface(Ci.nsITreeView);
+    view = view.QueryInterface(Ci.nsITreeView);
     view.selectionChanged();
   },
 
   get currentIndex JSTreeSelection_get_currentIndex() {
     if (this._currentIndex == null)
       return -1;
     return this._currentIndex;
   },