Bug 634077 - tabviewshown/hidden events are dispatched before Storage.saveVisibilityData() was called [r=ian, a=sdwilsh]
authorTim Taubert <tim.taubert@gmx.de>
Tue, 15 Feb 2011 19:56:57 +0100
changeset 62569 9487445572ced105c1875cb32e04503ca6874ba6
parent 62568 4f3ad7dc68394b21e1c3643215ee33c9abb1f8f1
child 62605 cdde780d7503dbc30bf625ca3dfbaccf80bea110
push id18792
push usereakhgari@mozilla.com
push dateTue, 15 Feb 2011 19:49:53 +0000
treeherdermozilla-central@9487445572ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersian, sdwilsh
bugs634077
milestone2.0b12pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 634077 - tabviewshown/hidden events are dispatched before Storage.saveVisibilityData() was called [r=ian, a=sdwilsh]
browser/base/content/tabview/ui.js
browser/base/content/test/tabview/Makefile.in
browser/base/content/test/tabview/browser_tabview_bug634077.js
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -474,16 +474,18 @@ let UI = {
 
     gBrowser.updateTitlebar();
 #ifdef XP_MACOSX
     this.setTitlebarColors(true);
 #endif
     let event = document.createEvent("Events");
     event.initEvent("tabviewshown", true, false);
 
+    Storage.saveVisibilityData(gWindow, "true");
+
     // Close the active group if it was empty. This will happen when the
     // user returns to Panorama after looking at an app tab, having
     // closed all other tabs. (If the user is looking at an orphan tab, then
     // there is no active group for the purposes of this check.)
     let activeGroupItem = null;
     if (!GroupItems.getActiveOrphanTab()) {
       activeGroupItem = GroupItems.getActiveGroupItem();
       if (activeGroupItem && activeGroupItem.closeIfEmpty())
@@ -518,18 +520,16 @@ let UI = {
       self.setActiveTab(null);
       dispatchEvent(event);
 
       // Flush pending updates
       GroupItems.flushAppTabUpdates();
 
       TabItems.resumePainting();
     }
-
-    Storage.saveVisibilityData(gWindow, "true");
   },
 
   // ----------
   // Function: hideTabView
   // Hides TabView and shows the main browser UI.
   hideTabView: function UI_hideTabView() {
     if (!this.isTabViewVisible())
       return;
@@ -553,21 +553,21 @@ let UI = {
     gTabViewDeck.selectedIndex = 0;
     gWindow.TabsInTitlebar.allowedBy("tabview-open", true);
     gBrowser.contentWindow.focus();
 
     gBrowser.updateTitlebar();
 #ifdef XP_MACOSX
     this.setTitlebarColors(false);
 #endif
+    Storage.saveVisibilityData(gWindow, "false");
+
     let event = document.createEvent("Events");
     event.initEvent("tabviewhidden", true, false);
     dispatchEvent(event);
-
-    Storage.saveVisibilityData(gWindow, "false");
   },
 
 #ifdef XP_MACOSX
   // ----------
   // Function: setTitlebarColors
   // Used on the Mac to make the title bar match the gradient in the rest of the
   // TabView UI.
   //
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -107,16 +107,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug627736.js \
                  browser_tabview_bug628165.js \
                  browser_tabview_bug628270.js \
                  browser_tabview_bug629189.js \
                  browser_tabview_bug629195.js \
                  browser_tabview_bug630102.js \
                  browser_tabview_bug630157.js \
                  browser_tabview_bug631662.js \
+                 browser_tabview_bug634077.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_expander.js \
                  browser_tabview_group.js \
                  browser_tabview_launch.js \
                  browser_tabview_multiwindow_search.js \
                  browser_tabview_orphaned_tabs.js \
                  browser_tabview_privatebrowsing.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug634077.js
@@ -0,0 +1,25 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  let ss = Cc["@mozilla.org/browser/sessionstore;1"]
+                     .getService(Ci.nsISessionStore);
+
+  let assertVisibilityDataEquals = function (val, msg) {
+    is(ss.getWindowValue(window, TabView.VISIBILITY_IDENTIFIER), val, msg);
+  }
+
+  waitForExplicitFinish();
+
+  ss.setWindowValue(window, window.TabView.VISIBILITY_IDENTIFIER, "null");
+  assertVisibilityDataEquals("null", "we start with <null>");
+
+  showTabView(function () {
+    assertVisibilityDataEquals("true", "after showing visibility data is <true>");
+
+    hideTabView(function () {
+      assertVisibilityDataEquals("false", "after hiding visibility data is <false>");
+      finish();
+    });
+  });
+}