diff --git a/browser/base/content/browser-tabview.js b/browser/base/content/browser-tabview.js index 79b577ed2409..0a117d3b0822 100644 --- a/browser/base/content/browser-tabview.js +++ b/browser/base/content/browser-tabview.js @@ -360,8 +360,10 @@ let TabView = { if (!tabItem) return; - // Switch to the new tab - window.gBrowser.selectedTab = tabItem.tab; + if (gBrowser.selectedTab.pinned) + groupItems.updateActiveGroupItemAndTabBar(tabItem, {dontSetActiveTabInGroup: true}); + else + gBrowser.selectedTab = tabItem.tab; }); } }, true); diff --git a/browser/components/tabview/groupitems.js b/browser/components/tabview/groupitems.js index 7467c8d0d377..76cb78301db7 100644 --- a/browser/components/tabview/groupitems.js +++ b/browser/components/tabview/groupitems.js @@ -2472,10 +2472,14 @@ let GroupItems = { // ---------- // Function: updateActiveGroupItemAndTabBar // Sets active TabItem and GroupItem, and updates tab bar appropriately. - updateActiveGroupItemAndTabBar: function GroupItems_updateActiveGroupItemAndTabBar(tabItem) { + // Parameters: + // tabItem - the tab item + // options - is passed to UI.setActive() directly + updateActiveGroupItemAndTabBar: + function GroupItems_updateActiveGroupItemAndTabBar(tabItem, options) { Utils.assertThrow(tabItem && tabItem.isATabItem, "tabItem must be a TabItem"); - UI.setActive(tabItem); + UI.setActive(tabItem, options); this._updateTabBar(); }, diff --git a/browser/components/tabview/test/Makefile.in b/browser/components/tabview/test/Makefile.in index 58581a9cc7b4..10efe121914d 100644 --- a/browser/components/tabview/test/Makefile.in +++ b/browser/components/tabview/test/Makefile.in @@ -87,8 +87,9 @@ _BROWSER_FILES = \ browser_tabview_bug606905.js \ browser_tabview_bug607108.js \ browser_tabview_bug608037.js \ - browser_tabview_bug608184.js \ + browser_tabview_bug608153.js \ browser_tabview_bug608158.js \ + browser_tabview_bug608184.js \ browser_tabview_bug608405.js \ browser_tabview_bug610208.js \ browser_tabview_bug610242.js \ diff --git a/browser/components/tabview/test/browser_tabview_bug608153.js b/browser/components/tabview/test/browser_tabview_bug608153.js new file mode 100644 index 000000000000..0b6aec56bcff --- /dev/null +++ b/browser/components/tabview/test/browser_tabview_bug608153.js @@ -0,0 +1,48 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + waitForExplicitFinish(); + + let pinnedTab = gBrowser.addTab(); + gBrowser.pinTab(pinnedTab); + + registerCleanupFunction(function() { + gBrowser.unpinTab(pinnedTab); + while (gBrowser.tabs[1]) + gBrowser.removeTab(gBrowser.tabs[1]); + hideTabView(); + }); + + showTabView(function() { + let cw = TabView.getContentWindow(); + let groupItemOne = cw.GroupItems.groupItems[0]; + let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1); + + is(cw.GroupItems.groupItems.length, 2, "Two group items"); + + hideTabView(function() { + gBrowser.selectedTab = pinnedTab; + is(cw.GroupItems.getActiveGroupItem(), groupItemTwo, "Group two is active"); + is(gBrowser.selectedTab, pinnedTab, "Selected tab is the pinned tab"); + + goToNextGroup(); + is(cw.GroupItems.getActiveGroupItem(), groupItemOne, "Group one is active"); + is(gBrowser.selectedTab, pinnedTab, "Selected tab is the pinned tab"); + + finish(); + }); + }); +} + +function goToNextGroup() { + let utils = + QueryInterface(Ci.nsIInterfaceRequestor). + getInterface(Ci.nsIDOMWindowUtils); + + const masks = Ci.nsIDOMNSEvent; + let mval = 0; + mval |= masks.CONTROL_MASK; + + utils.sendKeyEvent("keypress", 0, 96, mval); +} diff --git a/browser/components/tabview/ui.js b/browser/components/tabview/ui.js index ee0b1783aa6a..f7f662c2a789 100644 --- a/browser/components/tabview/ui.js +++ b/browser/components/tabview/ui.js @@ -466,7 +466,8 @@ let UI = { if (item.isATabItem) { if (item.parent) GroupItems.setActiveGroupItem(item.parent); - this._setActiveTab(item); + if (!options || !options.dontSetActiveTabInGroup) + this._setActiveTab(item); } else { GroupItems.setActiveGroupItem(item); if (!options || !options.dontSetActiveTabInGroup) {