From f48e05bc29d60630d933d707be4c7c85555d938d Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Tue, 18 Jun 2013 17:11:27 +0200 Subject: [PATCH] Bug 792806 - Update list of visible tabs only once after switching to another group; r=dao --- browser/components/tabview/groupitems.js | 20 ++++++--- .../browser_tabview_bug624265_perwindowpb.js | 44 ++----------------- 2 files changed, 19 insertions(+), 45 deletions(-) diff --git a/browser/components/tabview/groupitems.js b/browser/components/tabview/groupitems.js index df489429c710..df4293ffbb08 100644 --- a/browser/components/tabview/groupitems.js +++ b/browser/components/tabview/groupitems.js @@ -1920,6 +1920,7 @@ let GroupItems = { minGroupHeight: 110, minGroupWidth: 125, _lastActiveList: null, + _lastGroupToUpdateTabBar: null, // ---------- // Function: toString @@ -2285,6 +2286,10 @@ let GroupItems = { }); this._lastActiveList.remove(groupItem); + + if (this._lastGroupToUpdateTabBar == groupItem) + this._lastGroupToUpdateTabBar = null; + UI.updateTabButton(); }, @@ -2418,8 +2423,13 @@ let GroupItems = { Utils.assert(this._activeGroupItem, "There must be something to show in the tab bar!"); + // Update list of visible tabs only once after switching to another group. + if (this._activeGroupItem == this._lastGroupToUpdateTabBar) + return; + let tabItems = this._activeGroupItem._children; gBrowser.showOnlyTheseTabs(tabItems.map(function(item) item.tab)); + this._lastGroupToUpdateTabBar = this._activeGroupItem; }, // ---------- @@ -2537,7 +2547,7 @@ let GroupItems = { if (tab._tabViewTabItem.parent && tab._tabViewTabItem.parent.id == groupItemId) return; - let shouldUpdateTabBar = false; + let shouldHideTab = false; let shouldShowTabView = false; let groupItem; @@ -2545,12 +2555,12 @@ let GroupItems = { if (tab.selected) { if (gBrowser.visibleTabs.length > 1) { gBrowser._blurTab(tab); - shouldUpdateTabBar = true; + shouldHideTab = true; } else { shouldShowTabView = true; } } else { - shouldUpdateTabBar = true + shouldHideTab = true } // remove tab item from a groupItem @@ -2573,8 +2583,8 @@ let GroupItems = { new GroupItem([ tab._tabViewTabItem ], { bounds: box, immediately: true }); } - if (shouldUpdateTabBar) - this._updateTabBar(); + if (shouldHideTab) + gBrowser.hideTab(tab); else if (shouldShowTabView) UI.showTabView(); }, diff --git a/browser/components/tabview/test/browser_tabview_bug624265_perwindowpb.js b/browser/components/tabview/test/browser_tabview_bug624265_perwindowpb.js index f6450bb7403c..e1d32e59e083 100644 --- a/browser/components/tabview/test/browser_tabview_bug624265_perwindowpb.js +++ b/browser/components/tabview/test/browser_tabview_bug624265_perwindowpb.js @@ -99,47 +99,14 @@ function test() { }, aWindow); } - // [624102] check state after return from private browsing - let testPrivateBrowsing = function (aWindow) { - aWindow.gBrowser.loadOneTab('http://mochi.test:8888/#1', {inBackground: true}); - aWindow.gBrowser.loadOneTab('http://mochi.test:8888/#2', {inBackground: true}); - - let cw = getContentWindow(aWindow); - let box = new cw.Rect(20, 20, 250, 200); - let groupItem = new cw.GroupItem([], {bounds: box, immediately: true}); - cw.UI.setActive(groupItem); - - aWindow.gBrowser.selectedTab = aWindow.gBrowser.loadOneTab('http://mochi.test:8888/#3', {inBackground: true}); - aWindow.gBrowser.loadOneTab('http://mochi.test:8888/#4', {inBackground: true}); - - afterAllTabsLoaded(function () { - assertNumberOfVisibleTabs(aWindow, 2); - - enterAndLeavePrivateBrowsing(function () { - assertNumberOfVisibleTabs(aWindow, 2); - aWindow.gBrowser.selectedTab = aWindow.gBrowser.tabs[0]; - closeGroupItem(cw.GroupItems.groupItems[1], function() { - next(aWindow); - }); - }); - }, aWindow); - } - - function testOnWindow(aIsPrivate, aCallback) { - let win = OpenBrowserWindow({private: aIsPrivate}); + function testOnWindow(aCallback) { + let win = OpenBrowserWindow({private: false}); win.addEventListener("load", function onLoad() { win.removeEventListener("load", onLoad, false); executeSoon(function() { aCallback(win) }); }, false); } - function enterAndLeavePrivateBrowsing(callback) { - testOnWindow(true, function (aWindow) { - aWindow.close(); - callback(); - }); - } - waitForExplicitFinish(); // Tests for #624265 @@ -149,10 +116,7 @@ function test() { tests.push(testDuplicateTab); tests.push(testBackForwardDuplicateTab); - // Tests for #624102 - tests.push(testPrivateBrowsing); - - testOnWindow(false, function(aWindow) { + testOnWindow(function(aWindow) { loadTabView(function() { next(aWindow); }, aWindow); @@ -163,4 +127,4 @@ function loadTabView(callback, aWindow) { showTabView(function () { hideTabView(callback, aWindow); }, aWindow); -} \ No newline at end of file +}