Bug 707466 - No tab item is selected after removing last tab in a group outside Panorama (follow up) t=tim
authorRaymond Lee <raymond@raysquare.com>
Wed, 07 Dec 2011 22:28:50 +0800
changeset 82267 8d91ee82719ce78ac5c65c7be215ea9e35f8d659
parent 82266 cf3ed43164811e0ba3e0b1c80073b79ff38e2c97
child 82268 06c0a1711186a5e6945df9751300720a4e75f247
push id21589
push usertim.taubert@gmx.de
push dateFri, 09 Dec 2011 04:57:11 +0000
treeherdermozilla-central@9e7239c0f557 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs707466
milestone11.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 707466 - No tab item is selected after removing last tab in a group outside Panorama (follow up) t=tim
browser/components/tabview/test/Makefile.in
browser/components/tabview/test/browser_tabview_bug707466.js
browser/components/tabview/ui.js
--- a/browser/components/tabview/test/Makefile.in
+++ b/browser/components/tabview/test/Makefile.in
@@ -164,16 +164,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug685476.js \
                  browser_tabview_bug685692.js \
                  browser_tabview_bug686654.js \
                  browser_tabview_bug696602.js \
                  browser_tabview_bug697390.js \
                  browser_tabview_bug705621.js \
                  browser_tabview_bug706430.js \
                  browser_tabview_bug706736.js \
+                 browser_tabview_bug707466.js \
                  browser_tabview_click_group.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 \
new file mode 100644
--- /dev/null
+++ b/browser/components/tabview/test/browser_tabview_bug707466.js
@@ -0,0 +1,60 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  waitForExplicitFinish();
+
+  // create two groups and each group has one tab item
+  let newState = {
+    windows: [{
+      tabs: [{
+        entries: [{ url: "about:blank" }],
+        hidden: true,
+        attributes: {},
+        extData: {
+          "tabview-tab":
+            '{"bounds":{"left":21,"top":29,"width":204,"height":153},' +
+            '"userSize":null,"url":"about:blank","groupID":1,' +
+            '"imageData":null,"title":null}'
+        }
+      },{
+        entries: [{ url: "about:blank" }],
+        hidden: false,
+        attributes: {},
+        extData: {
+          "tabview-tab":
+            '{"bounds":{"left":315,"top":29,"width":111,"height":84},' +
+            '"userSize":null,"url":"about:blank","groupID":2,' +
+            '"imageData":null,"title":null}'
+        },
+      }],
+      selected:2,
+      _closedTabs: [],
+      extData: {
+        "tabview-groups": '{"nextID":3,"activeGroupId":2}',
+        "tabview-group":
+          '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},' +
+          '"userSize":null,"title":"","id":1},' +
+          '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},' +
+          '"userSize":null,"title":"","id":2}}',
+        "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}'
+      }, sizemode:"normal"
+    }]
+  };
+
+  newWindowWithState(newState, function(win) {
+    registerCleanupFunction(function () win.close());
+
+    whenTabViewIsShown(function() {
+      let cw = win.TabView.getContentWindow();
+
+      is(cw.GroupItems.groupItems.length, 2, "There are still two groups");
+      is(win.gBrowser.tabs.length, 1, "There is only one tab");
+      is(cw.UI.getActiveTab(), win.gBrowser.selectedTab._tabViewTabItem, "The last tab is selected");
+
+      finish();
+    }, win);
+    win.gBrowser.removeTab(win.gBrowser.selectedTab);
+  });
+}
+
--- a/browser/components/tabview/ui.js
+++ b/browser/components/tabview/ui.js
@@ -470,17 +470,17 @@ let UI = {
     if (item.isATabItem) {
       if (item.parent)
         GroupItems.setActiveGroupItem(item.parent);
       if (!options || !options.dontSetActiveTabInGroup)
         this._setActiveTab(item);
     } else {
       GroupItems.setActiveGroupItem(item);
       if (!options || !options.dontSetActiveTabInGroup) {
-        let activeTab = item.getActiveTab()
+        let activeTab = item.getActiveTab();
         if (activeTab)
           this._setActiveTab(activeTab);
       }
     }
   },
 
   // ----------
   // Function: clearActiveTab
@@ -569,17 +569,18 @@ let UI = {
         dispatchEvent(event);
 
         // Flush pending updates
         GroupItems.flushAppTabUpdates();
 
         TabItems.resumePainting();
       });
     } else {
-      self.clearActiveTab();
+      if (!currentTab || !currentTab._tabViewTabItem)
+        self.clearActiveTab();
       self._isChangingVisibility = false;
       dispatchEvent(event);
 
       // Flush pending updates
       GroupItems.flushAppTabUpdates();
 
       TabItems.resumePainting();
     }