From 475c879b4856db80837ecb2a0707b5b9941d1755 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Wed, 30 Nov 2011 07:52:08 +0100 Subject: [PATCH] Bug 688695 - Deferred session restore doesn't behave correctly for a single tab group; r=zpao --- .../sessionstore/src/nsSessionStore.js | 22 +++++-------------- browser/components/tabview/groupitems.js | 16 +++++++++++++- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index 6f3e4ede9abf..66e9a29ec170 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -1646,25 +1646,13 @@ SessionStoreService.prototype = { // Inspect extData for Panorama identifiers. If found, then we want to // inspect further. If there is a single group, then we can use this // window. If there are multiple groups then we won't use this window. - let data = this.getWindowValue(aWindow, "tabview-group"); - if (data) { - data = JSON.parse(data); + let groupsData = this.getWindowValue(aWindow, "tabview-groups"); + if (groupsData) { + groupsData = JSON.parse(groupsData); - // Multiple keys means multiple groups, which means we don't want to use this window. - if (Object.keys(data).length > 1) { + // If there are multiple groups, we don't want to use this window. + if (groupsData.totalNumber > 1) return [false, false]; - } - else { - // If there is only one group, then we want to ensure that its group id - // is 0. This is how Panorama forces group merging when new tabs are opened. - //XXXzpao This is a hack and the proper fix really belongs in Panorama. - let groupKey = Object.keys(data)[0]; - if (groupKey !== "0") { - data["0"] = data[groupKey]; - delete data[groupKey]; - this.setWindowValue(aWindow, "tabview-groups", JSON.stringify(data)); - } - } } // Step 2 of processing: diff --git a/browser/components/tabview/groupitems.js b/browser/components/tabview/groupitems.js index 4fa7e70cfad3..a3f98c4e3db8 100644 --- a/browser/components/tabview/groupitems.js +++ b/browser/components/tabview/groupitems.js @@ -2233,12 +2233,26 @@ let GroupItems = { // All remaining children in to-be-closed groups are re-used by // session restore. Reconnect them so that they're put into their // right groups. - groupItem.getChildren().forEach(function (tabItem) { + let children = groupItem.getChildren().concat(); + + children.forEach(function (tabItem) { if (tabItem.parent && tabItem.parent.hidden) iQ(tabItem.container).show(); + + // sanity check the tab's groupID + let tabData = Storage.getTabData(tabItem.tab); + let parentGroup = GroupItems.groupItem(tabData.groupID); + + // correct the tab's groupID if necessary + if (!parentGroup || -1 < toClose.indexOf(parentGroup)) { + tabData.groupID = activeGroupId || Object.keys(groupItemData)[0]; + Storage.saveTab(tabItem.tab, tabData); + } + tabItem._reconnected = false; tabItem._reconnect(); }); + groupItem.close({immediately: true}); }); }