Bug 706430 - Restoring a session without Panorama data fails with Panorama already loaded; r=dietrich

This commit is contained in:
Tim Taubert 2011-12-01 10:51:03 +01:00
Родитель fc9ec86fa5
Коммит de766e6f69
3 изменённых файлов: 83 добавлений и 15 удалений

Просмотреть файл

@ -2234,29 +2234,31 @@ let GroupItems = {
}
toClose.forEach(function(groupItem) {
// 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.
let children = groupItem.getChildren().concat();
children.forEach(function (tabItem) {
if (tabItem.parent && tabItem.parent.hidden)
// all tabs still existing in closed groups will be moved to new
// groups. prepare them to be reconnected later.
groupItem.getChildren().forEach(function (tabItem) {
if (tabItem.parent.hidden)
iQ(tabItem.container).show();
tabItem._reconnected = false;
// 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);
if (tabData) {
let parentGroup = GroupItems.groupItem(tabData.groupID);
// the tab's group id could be invalid or point to a non-existing
// group. correct it by assigning the active group id or the first
// group of the just restored session.
if (!parentGroup || -1 < toClose.indexOf(parentGroup)) {
tabData.groupID = activeGroupId || Object.keys(groupItemData)[0];
Storage.saveTab(tabItem.tab, tabData);
}
}
tabItem._reconnected = false;
tabItem._reconnect();
});
// this closes the group but not its children
groupItem.close({immediately: true});
});
}

Просмотреть файл

@ -165,6 +165,7 @@ _BROWSER_FILES = \
browser_tabview_bug686654.js \
browser_tabview_bug697390.js \
browser_tabview_bug705621.js \
browser_tabview_bug706430.js \
browser_tabview_click_group.js \
browser_tabview_dragdrop.js \
browser_tabview_exit_button.js \

Просмотреть файл

@ -0,0 +1,65 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let state1 = {
windows: [{
tabs: [{
entries: [{ url: "about:blank#1" }],
hidden: true,
extData: {"tabview-tab": '{"url":"about:blank#1","groupID":1,"bounds":{"left":120,"top":20,"width":20,"height":20}}'}
},{
entries: [{ url: "about:blank#2" }],
hidden: false,
extData: {"tabview-tab": '{"url":"about:blank#2","groupID":2,"bounds":{"left":20,"top":20,"width":20,"height":20}}'},
}],
selected: 2,
extData: {
"tabview-groups": '{"nextID":3,"activeGroupId":2, "totalNumber":2}',
"tabview-group":
'{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},"id":1},' +
'"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},"id":2}}'
}
}]
};
let state2 = {
windows: [{
tabs: [{entries: [{ url: "about:blank#1" }], hidden: true},
{entries: [{ url: "about:blank#2" }], hidden: false}],
selected: 2
}]
};
let ss = Cc["@mozilla.org/browser/sessionstore;1"]
.getService(Ci.nsISessionStore);
function test() {
waitForExplicitFinish();
newWindowWithState(state1, function (win) {
registerCleanupFunction(function () win.close());
showTabView(function () {
let cw = win.TabView.getContentWindow();
let [group1, group2] = cw.GroupItems.groupItems;
let [tab1, tab2] = win.gBrowser.tabs;
checkUrl(group1.getChild(0), "about:blank#1", "tab1 is in first group");
checkUrl(group2.getChild(0), "about:blank#2", "tab2 is in second group");
whenWindowStateReady(win, function () {
let groups = cw.GroupItems.groupItems;
is(groups.length, 1, "one groupItem");
is(groups[0].getChildren().length, 2, "single groupItem has two children");
finish();
});
ss.setWindowState(win, JSON.stringify(state2), true);
}, win);
});
}
function checkUrl(aTabItem, aUrl, aMsg) {
is(aTabItem.tab.linkedBrowser.currentURI.spec, aUrl, aMsg);
}