Bug 714337 - Make Quick Filter Bar remember icon state on mail window spawn. r=asuth.
authorMike Conley <mconley@mozilla.com>
Thu, 23 Feb 2012 15:15:36 -0500
changeset 10922 b8bdec7166ad6d3a24bdd6cc50680b42a8158073
parent 10921 6af8343175a6b62ef6e5b8a9e6268a92bfcfb086
child 10923 0750714622548cca1eaad2d333bd77eca928780f
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs714337
Bug 714337 - Make Quick Filter Bar remember icon state on mail window spawn. r=asuth.
mail/base/content/msgMail3PaneWindow.js
mail/test/mozmill/quick-filter-bar/test-display-issues.js
mail/test/mozmill/shared-modules/test-folder-display-helpers.js
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -277,22 +277,30 @@ function UpdateMailPaneConfig(aMsgWindow
     // The choice of the delay is basically a kludge because something like 10ms
     //  may be insufficient to ensure we get enqueued after whatever triggers
     //  the layout discontinuity.  (We need to wait for a paint to happen to
     //  trigger the XBL binding, and then there may be more complexities...)
     setTimeout(function UpdateMailPaneConfig_deferredFixup() {
       let threadPaneBox = document.getElementById("threadPaneBox");
       let overflowNodes =
         threadPaneBox.querySelectorAll("[onoverflow]");
+
       for (let iNode = 0; iNode < overflowNodes.length; iNode++) {
         let node = overflowNodes[iNode];
-        if (node.scrollWidth > node.clientWidth)
-          node.onoverflow();
-        else if (node.onresize)
-          node.onresize();
+
+        if (node.scrollWidth > node.clientWidth) {
+          let e = document.createEvent("HTMLEvents");
+          e.initEvent("overflow", false, false);
+          node.dispatchEvent(e);
+        }
+        else if (node.onresize) {
+          let e = document.createEvent("HTMLEvents");
+          e.initEvent("resize", false, false);
+          node.dispatchEvent(e);
+        }
       }
     }, 1500);
   }
 }
 
 const MailPrefObserver = {
   observe: function(subject, topic, prefName) {
     // verify that we're changing the mail pane config pref
--- a/mail/test/mozmill/quick-filter-bar/test-display-issues.js
+++ b/mail/test/mozmill/quick-filter-bar/test-display-issues.js
@@ -78,17 +78,16 @@ function resize_to(width, height) {
 function collapse_folder_pane(shouldBeCollapsed) {
   mark_action("test", "collapse_folder_pane",
               [shouldBeCollapsed]);
   mc.e("folderpane_splitter").setAttribute("state",
                                            shouldBeCollapsed ? "collapsed"
                                                              : "open");
 }
 
-
 /**
  * When the window gets too narrow the collapsible button labels need to get
  *  gone.  Then they need to come back when we get large enough again.
  *
  * Because the mozmill window sizing is weird and confusing, we force our size
  *  in both cases but do save/restore around our test.
  */
 function test_buttons_collapse_and_expand() {
@@ -157,15 +156,41 @@ function test_buttons_collapse_and_expan
   resize_to(1200, 600);
   collapse_folder_pane(true);
   // spin the event loop once
   mc.sleep(0);
   logState("giant again!");
   assertExpanded(1200);
 }
 
+function test_buttons_collapse_and_expand_on_spawn_in_vertical_mode() {
+  // Assume we're in classic layout to start - since this is where we'll
+  // reset to once we're done.
+  assert_pane_layout(kClassicMailLayout);
+
+  // Put us in vertical mode
+  set_pane_layout(kVerticalMailLayout);
+
+  // Make our window nice and wide.
+  resize_to(1200, 600);
+  wait_for_resize(1200);
+
+  // Now expand the message pane to cause the QFB buttons to shrink
+  let messagePaneWrapper = mc.e("messagepaneboxwrapper");
+  messagePaneWrapper.width = 500;
+
+  // Now spawn a new 3pane...
+  let mc2 = open_folder_in_new_window(folder);
+  let qfb = mc2.e("quick-filter-bar-collapsible-buttons");
+  mc2.waitFor(function () (qfb.getAttribute("shrink") == "true"),
+              "New 3pane should have had a collapsed QFB");
+  close_window(mc2);
+
+  set_pane_layout(kClassicMailLayout);
+}
+
 function teardownModule() {
   // restore window to nominal dimensions; saving was not working out
   //  See also: message-header/test-message-header.js if we change the
   //            default window size.
   resize_to(1024, 768);
   collapse_folder_pane(false);
 }
--- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
@@ -537,16 +537,29 @@ function open_folder_in_new_tab(aFolder)
   mark_action("fdh", "open_folder_in_new_tab",
               ["folder", aFolder,
                "tab info", _jsonize_tabmail_tab(mc.tabmail.currentTabInfo)]);
   wait_for_all_messages_to_load();
   return mc.tabmail.currentTabInfo;
 }
 
 /**
+ * Open a new mail:3pane window displaying a folder.
+ *
+ * @param aFolder the folder to be displayed in the new window
+ * @return the augmented controller for the new window
+ */
+function open_folder_in_new_window(aFolder) {
+  windowHelper.plan_for_new_window("mail:3pane");
+  mc.window.MsgOpenNewWindowForFolder(aFolder.URI);
+  let mail3pane = windowHelper.wait_for_new_window("mail:3pane");
+  return mail3pane;
+}
+
+/**
  * Open the selected message(s) by pressing Enter. The mail.openMessageBehavior
  * pref is supposed to determine how the messages are opened.
  *
  * Since we don't know where this is going to trigger a message load, you're
  * going to have to wait for message display completion yourself.
  *
  * @param aController The controller in whose context to do this, defaults to
  *     |mc| if omitted.