mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 593283 - Persist each group's active tab across sessions; r=dietrich
This commit is contained in:
parent
4cf87784b3
commit
1e1f921184
@ -223,11 +223,15 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
// Function: getStorageData
|
||||
// Get data to be used for persistent storage of this object.
|
||||
getStorageData: function TabItem_getStorageData() {
|
||||
return {
|
||||
let data = {
|
||||
url: this.tab.linkedBrowser.currentURI.spec,
|
||||
groupID: (this.parent ? this.parent.id : 0),
|
||||
title: this.tab.label
|
||||
};
|
||||
if (this.parent.getActiveTab() == this)
|
||||
data.active = true;
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
// ----------
|
||||
@ -339,14 +343,13 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
Utils.assertThrow(!this._reconnected, "shouldn't already be reconnected");
|
||||
Utils.assertThrow(this.tab, "should have a xul:tab");
|
||||
|
||||
let self = this;
|
||||
let tabData = Storage.getTabData(this.tab);
|
||||
|
||||
if (tabData && TabItems.storageSanity(tabData)) {
|
||||
this.loadThumbnail(tabData);
|
||||
|
||||
if (self.parent)
|
||||
self.parent.remove(self, {immediately: true});
|
||||
if (this.parent)
|
||||
this.parent.remove(this, {immediately: true});
|
||||
|
||||
let groupItem;
|
||||
|
||||
@ -357,22 +360,26 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
}
|
||||
|
||||
if (groupItem) {
|
||||
groupItem.add(self, {immediately: true});
|
||||
groupItem.add(this, {immediately: true});
|
||||
|
||||
// restore the active tab for each group between browser sessions
|
||||
if (tabData.active)
|
||||
groupItem.setActiveTab(this);
|
||||
|
||||
// if it matches the selected tab or no active tab and the browser
|
||||
// tab is hidden, the active group item would be set.
|
||||
if (self.tab == gBrowser.selectedTab ||
|
||||
(!GroupItems.getActiveGroupItem() && !self.tab.hidden))
|
||||
UI.setActive(self.parent);
|
||||
if (this.tab == gBrowser.selectedTab ||
|
||||
(!GroupItems.getActiveGroupItem() && !this.tab.hidden))
|
||||
UI.setActive(this.parent);
|
||||
}
|
||||
} else {
|
||||
// create tab group by double click is handled in UI_init().
|
||||
GroupItems.newTab(self, {immediately: true});
|
||||
GroupItems.newTab(this, {immediately: true});
|
||||
}
|
||||
|
||||
self._reconnected = true;
|
||||
self.save();
|
||||
self._sendToSubscribers("reconnected");
|
||||
this._reconnected = true;
|
||||
this.save();
|
||||
this._sendToSubscribers("reconnected");
|
||||
},
|
||||
|
||||
// ----------
|
||||
|
@ -58,6 +58,7 @@ _BROWSER_FILES = \
|
||||
browser_tabview_bug589324.js \
|
||||
browser_tabview_bug590606.js \
|
||||
browser_tabview_bug591706.js \
|
||||
browser_tabview_bug593283.js \
|
||||
browser_tabview_bug594958.js \
|
||||
browser_tabview_bug595020.js \
|
||||
browser_tabview_bug595191.js \
|
||||
|
@ -0,0 +1,75 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const DUMMY_PAGE_URL = "http://example.com/";
|
||||
|
||||
let state = {
|
||||
windows: [{
|
||||
tabs: [{
|
||||
entries: [{ url: DUMMY_PAGE_URL }],
|
||||
hidden: false,
|
||||
attributes: {},
|
||||
extData: {
|
||||
"tabview-tab": '{"url":"' + DUMMY_PAGE_URL + '","groupID":1,"title":null,"active":true}'
|
||||
}
|
||||
},{
|
||||
entries: [{ url: DUMMY_PAGE_URL }],
|
||||
hidden: false,
|
||||
attributes: {},
|
||||
extData: {
|
||||
"tabview-tab": '{"url":"' + DUMMY_PAGE_URL + '","groupID":1,"title":null}'
|
||||
}
|
||||
},{
|
||||
entries: [{ url: DUMMY_PAGE_URL }],
|
||||
hidden: true,
|
||||
attributes: {},
|
||||
extData: {
|
||||
"tabview-tab": '{"url":"' + DUMMY_PAGE_URL + '","groupID":2,"title":null}'
|
||||
},
|
||||
},{
|
||||
entries: [{ url: DUMMY_PAGE_URL }],
|
||||
hidden: true,
|
||||
attributes: {},
|
||||
extData: {
|
||||
"tabview-tab": '{"url":"' + DUMMY_PAGE_URL + '","groupID":2,"title":null,"active":true}'
|
||||
},
|
||||
}],
|
||||
selected:1,
|
||||
_closedTabs: [],
|
||||
extData: {
|
||||
"tabview-groups": '{"nextID":3,"activeGroupId":2,"totalNumber":2}',
|
||||
"tabview-group":
|
||||
'{"1":{"bounds":{"left":15,"top":28,"width":546,"height":218},' +
|
||||
'"userSize":{"x":546,"y":218},"title":"","id":1},' +
|
||||
'"2":{"bounds":{"left":15,"top":261,"width":546,"height":199},' +
|
||||
'"userSize":{"x":546,"y":199},"title":"","id":2}}',
|
||||
"tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":976,"height":663}}'
|
||||
}, sizemode:"normal"
|
||||
}]
|
||||
};
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
newWindowWithState(state, function (win) {
|
||||
registerCleanupFunction(function () win.close());
|
||||
|
||||
showTabView(function() {
|
||||
let cw = win.TabView.getContentWindow();
|
||||
let groupItems = cw.GroupItems.groupItems;
|
||||
let groupOne = groupItems[0];
|
||||
let groupTwo = groupItems[1];
|
||||
|
||||
// check the active tab of each group
|
||||
is(groupOne.getActiveTab(), groupOne.getChild(0), "The active tab item of group one is the first one");
|
||||
is(groupTwo.getActiveTab(), groupTwo.getChild(1), "The active tab item of group two is the second one");
|
||||
|
||||
is(cw.UI.getActiveTab(), groupOne.getChild(0), "The hightlighted tab item is the first one in group one");
|
||||
// select a group and the second tab should be hightlighted
|
||||
cw.UI.setActive(groupTwo);
|
||||
is(cw.UI.getActiveTab(), groupTwo.getChild(1), "The hightlighted tab item is the second one in group two");
|
||||
|
||||
finish();
|
||||
}, win);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user