Bug 669694 - App tabs do not stay selected when toggling Panorama; r=dietrich
authorTim Taubert <tim.taubert@gmx.de>
Thu, 14 Jul 2011 10:54:15 -0700
changeset 72881 eb73d370834b
parent 72755 fc299923d422
child 72882 6d45f8181b55
push id20789
push usertim.taubert@gmx.de
push date2011-07-17 16:02 +0000
treeherdermozilla-central@7099d3efac02 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich
bugs669694
milestone8.0a1
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 669694 - App tabs do not stay selected when toggling Panorama; r=dietrich
browser/base/content/tabview/ui.js
browser/base/content/test/tabview/Makefile.in
browser/base/content/test/tabview/browser_tabview_bug669694.js
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -434,16 +434,23 @@ let UI = {
         let activeTab = item.getActiveTab()
         if (activeTab)
           this._setActiveTab(activeTab);
       }
     }
   },
 
   // ----------
+  // Function: clearActiveTab
+  // Sets the active tab to 'null'.
+  clearActiveTab: function UI_clearActiveTab() {
+    this._setActiveTab(null);
+  },
+
+  // ----------
   // Function: isTabViewVisible
   // Returns true if the TabView UI is currently shown.
   isTabViewVisible: function UI_isTabViewVisible() {
     return gTabViewDeck.selectedPanel == gTabViewFrame;
   },
 
   // ---------
   // Function: _initPageDirection
@@ -465,17 +472,16 @@ let UI = {
     if (this.isTabViewVisible())
       return;
 
     // initialize the direction of the page
     this._initPageDirection();
 
     var self = this;
     var currentTab = this._currentTab;
-    var item = null;
 
     this._reorderTabItemsOnShow.forEach(function(groupItem) {
       groupItem.reorderTabItemsBasedOnTabOrder();
     });
     this._reorderTabItemsOnShow = [];
 
 #ifdef XP_WIN
     // Restore the full height when showing TabView
@@ -490,17 +496,17 @@ let UI = {
     this.setTitlebarColors(true);
 #endif
     let event = document.createEvent("Events");
     event.initEvent("tabviewshown", true, false);
 
     Storage.saveVisibilityData(gWindow, "true");
 
     if (zoomOut && currentTab && currentTab._tabViewTabItem) {
-      item = currentTab._tabViewTabItem;
+      let item = currentTab._tabViewTabItem;
       // If there was a previous currentTab we want to animate
       // its thumbnail (canvas) for the zoom out.
       // Note that we start the animation on the chrome thread.
 
       // Zoom out!
       item.zoomOut(function() {
         if (!currentTab._tabViewTabItem) // if the tab's been destroyed
           item = null;
@@ -511,16 +517,17 @@ let UI = {
         dispatchEvent(event);
 
         // Flush pending updates
         GroupItems.flushAppTabUpdates();
 
         TabItems.resumePainting();
       });
     } else {
+      self.clearActiveTab();
       dispatchEvent(event);
 
       // Flush pending updates
       GroupItems.flushAppTabUpdates();
 
       TabItems.resumePainting();
     }
 
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -144,16 +144,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug654721.js \
                  browser_tabview_bug654941.js \
                  browser_tabview_bug655269.js \
                  browser_tabview_bug656778.js \
                  browser_tabview_bug656913.js \
                  browser_tabview_bug662266.js \
                  browser_tabview_bug663421.js \
                  browser_tabview_bug665502.js \
+                 browser_tabview_bug669694.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_expander.js \
                  browser_tabview_firstrun_pref.js \
                  browser_tabview_group.js \
                  browser_tabview_launch.js \
                  browser_tabview_multiwindow_search.js \
                  browser_tabview_privatebrowsing.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug669694.js
@@ -0,0 +1,48 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  waitForExplicitFinish();
+
+  function onLoad(win) {
+    registerCleanupFunction(function () win.close());
+
+    let tab = win.gBrowser.addTab();
+    win.gBrowser.pinTab(tab);
+  }
+
+  function onShow(win) {
+    let tabs = win.gBrowser.tabs;
+
+    // zoom into normal tab
+    zoomIn(tabs[1], function () {
+      is(win.gBrowser.selectedTab, tabs[1], "normal tab is selected");
+
+      // select app tab
+      win.gBrowser.selectedTab = tabs[0];
+
+      toggleTabView(win, function () {
+        is(win.gBrowser.selectedTab, tabs[0], "app tab is selected");
+        finish();
+      });
+    });
+  }
+
+  newWindowWithTabView(onShow, onLoad);
+}
+
+// ----------
+function zoomIn(tab, callback) {
+  whenTabViewIsHidden(function () {
+    executeSoon(callback);
+  }, tab.ownerDocument.defaultView);
+
+  tab._tabViewTabItem.zoomIn();
+}
+
+// ----------
+function toggleTabView(win, callback) {
+  showTabView(function () {
+    hideTabView(callback, win);
+  }, win);
+}