diff --git a/browser/base/content/tabview/tabitems.js b/browser/base/content/tabview/tabitems.js index b6738dcc1d7..99ebcd27758 100644 --- a/browser/base/content/tabview/tabitems.js +++ b/browser/base/content/tabview/tabitems.js @@ -721,6 +721,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), { complete(); }; + UI.setActiveTab(this); TabItems._update(this.tab, {force: true}); $tab.addClass("front"); diff --git a/browser/base/content/test/tabview/browser_tabview_bug597980.js b/browser/base/content/test/tabview/browser_tabview_bug597980.js index 5012fe0090f..22553616e4a 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug597980.js +++ b/browser/base/content/test/tabview/browser_tabview_bug597980.js @@ -4,10 +4,12 @@ function test() { waitForExplicitFinish(); - newWindowWithTabView(onTabViewShown); + newWindowWithTabView(part1); } -function onTabViewShown(win) { +function part1(win) { + registerCleanupFunction(function() win.close()); + let contentWindow = win.document.getElementById("tab-view").contentWindow; is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); @@ -52,8 +54,32 @@ function onTabViewShown(win) { checkActive(function() { checkActive(function() { win.close(); - finish(); + newWindowWithTabView(part2); }); }, 490); }, 10) } + +function part2(win) { + registerCleanupFunction(function() win.close()); + + let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true}); + hideTabView(function() { + let selectedTab = win.gBrowser.selectedTab; + isnot(selectedTab, newTab, "They are different tabs"); + + // switch the selected tab to new tab + win.gBrowser.selectedTab = newTab; + + win.addEventListener("tabviewhidden", function () { + win.removeEventListener("tabviewhidden", arguments.callee, false); + is(win.gBrowser.selectedTab, newTab, "The seleted tab should be the same as before (new tab)"); + win.close(); + finish(); + }, false); + // show tabview + EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, win); + // hide tabview + EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, win); + }) +}