зеркало из https://github.com/mozilla/gecko-dev.git
Bug 598600 - New tabs should be added to the last active group after restart [r=dolske,a=blocking2.0]
--HG-- extra : rebase_source : f697d929331a23c5ac8333bb9d95392c0a8bb875
This commit is contained in:
Родитель
eaf0220c21
Коммит
95a2bfd922
|
@ -70,6 +70,7 @@ function GroupItem(listOfEls, options) {
|
||||||
options = {};
|
options = {};
|
||||||
|
|
||||||
this._inited = false;
|
this._inited = false;
|
||||||
|
this._uninited = false;
|
||||||
this._children = []; // an array of Items
|
this._children = []; // an array of Items
|
||||||
this.defaultSize = new Point(TabItems.tabWidth * 1.5, TabItems.tabHeight * 1.5);
|
this.defaultSize = new Point(TabItems.tabWidth * 1.5, TabItems.tabHeight * 1.5);
|
||||||
this.isAGroupItem = true;
|
this.isAGroupItem = true;
|
||||||
|
@ -366,7 +367,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||||
// Function: save
|
// Function: save
|
||||||
// Saves this groupItem to persistent storage.
|
// Saves this groupItem to persistent storage.
|
||||||
save: function GroupItem_save() {
|
save: function GroupItem_save() {
|
||||||
if (!this._inited) // too soon to save now
|
if (!this._inited || this._uninited) // too soon/late to save
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var data = this.getStorageData();
|
var data = this.getStorageData();
|
||||||
|
@ -374,6 +375,14 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||||
Storage.saveGroupItem(gWindow, data);
|
Storage.saveGroupItem(gWindow, data);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
// Function: deleteData
|
||||||
|
// Deletes the groupItem in the persistent storage.
|
||||||
|
deleteData: function GroupItem_deleteData() {
|
||||||
|
this._uninited = true;
|
||||||
|
Storage.deleteGroupItem(gWindow, this.id);
|
||||||
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: getTitle
|
// Function: getTitle
|
||||||
// Returns the title of this groupItem as a string.
|
// Returns the title of this groupItem as a string.
|
||||||
|
@ -561,7 +570,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Storage.deleteGroupItem(gWindow, this.id);
|
this.deleteData();
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
@ -647,7 +656,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||||
self.$undoContainer = null;
|
self.$undoContainer = null;
|
||||||
Items.unsquish();
|
Items.unsquish();
|
||||||
|
|
||||||
Storage.deleteGroupItem(gWindow, self.id);
|
self.deleteData();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$undoContainer.click(function(e) {
|
this.$undoContainer.click(function(e) {
|
||||||
|
@ -2072,7 +2081,7 @@ let GroupItems = {
|
||||||
child.close();
|
child.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
Storage.deleteGroupItem(gWindow, groupItem.id);
|
groupItem.deleteData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,9 +203,8 @@ function TabItem(tab, options) {
|
||||||
|
|
||||||
TabItems.register(this);
|
TabItems.register(this);
|
||||||
|
|
||||||
if (!this.reconnected) {
|
if (!this.reconnected)
|
||||||
GroupItems.newTab(this, options);
|
GroupItems.newTab(this, options);
|
||||||
}
|
|
||||||
|
|
||||||
// tabs which were not reconnected at all or were not immediately added
|
// tabs which were not reconnected at all or were not immediately added
|
||||||
// to a group get the same treatment.
|
// to a group get the same treatment.
|
||||||
|
@ -804,7 +803,7 @@ let TabItems = {
|
||||||
let oldURL = tabItem.url;
|
let oldURL = tabItem.url;
|
||||||
tabItem.url = tabUrl;
|
tabItem.url = tabUrl;
|
||||||
|
|
||||||
if (!tabItem.reconnected && (oldURL == 'about:blank' || !oldURL))
|
if (!tabItem.reconnected)
|
||||||
this.reconnect(tabItem);
|
this.reconnect(tabItem);
|
||||||
|
|
||||||
tabItem.save();
|
tabItem.save();
|
||||||
|
@ -1057,10 +1056,10 @@ let TabItems = {
|
||||||
item.reconnected = true;
|
item.reconnected = true;
|
||||||
found = {addedToGroup: tabData.groupID};
|
found = {addedToGroup: tabData.groupID};
|
||||||
} else {
|
} else {
|
||||||
// if it's not a blank tab or it belongs to a group, it would mean
|
// We should never have any orphaned tabs. Therefore, item is not
|
||||||
// the item is reconnected.
|
// connected if it has no parent and GroupItems.newTab() would handle
|
||||||
item.reconnected =
|
// the group creation.
|
||||||
(item.tab.linkedBrowser.currentURI.spec != 'about:blank' || item.parent);
|
item.reconnected = (item.parent != null);
|
||||||
}
|
}
|
||||||
item.save();
|
item.save();
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ _BROWSER_FILES = \
|
||||||
browser_tabview_bug595804.js \
|
browser_tabview_bug595804.js \
|
||||||
browser_tabview_bug595930.js \
|
browser_tabview_bug595930.js \
|
||||||
browser_tabview_bug595943.js \
|
browser_tabview_bug595943.js \
|
||||||
|
browser_tabview_bug598600.js \
|
||||||
browser_tabview_dragdrop.js \
|
browser_tabview_dragdrop.js \
|
||||||
browser_tabview_exit_button.js \
|
browser_tabview_exit_button.js \
|
||||||
browser_tabview_group.js \
|
browser_tabview_group.js \
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is tabview bug598600 test.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla Foundation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Raymond Lee <raymond@appcoast.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
let newWin;
|
||||||
|
let prefService;
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||||
|
prefService =
|
||||||
|
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).
|
||||||
|
getBranch("browser.panorama.");
|
||||||
|
// make sure we don't trigger the 'first run' behavior
|
||||||
|
prefService.setBoolPref("experienced_first_run", true);
|
||||||
|
|
||||||
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
// open a new window and setup the window state.
|
||||||
|
newWin = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
|
||||||
|
newWin.addEventListener("load", function(event) {
|
||||||
|
this.removeEventListener("load", arguments.callee, false);
|
||||||
|
|
||||||
|
let newState = {
|
||||||
|
windows: [{
|
||||||
|
tabs: [{
|
||||||
|
entries: [{ "url": "about:blank" }],
|
||||||
|
hidden: true,
|
||||||
|
attributes: {},
|
||||||
|
extData: {
|
||||||
|
"tabview-tab":
|
||||||
|
'{"bounds":{"left":20,"top":35,"width":280,"height":210},' +
|
||||||
|
'"userSize":null,"url":"about:blank","groupID":1,' +
|
||||||
|
'"imageData":null,"title":null}'
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
entries: [{ url: "about:blank" }],
|
||||||
|
index: 1,
|
||||||
|
hidden: false,
|
||||||
|
attributes: {},
|
||||||
|
extData: {
|
||||||
|
"tabview-tab":
|
||||||
|
'{"bounds":{"left":375,"top":35,"width":280,"height":210},' +
|
||||||
|
'"userSize":null,"url":"about:blank","groupID":2,' +
|
||||||
|
'"imageData":null,"title":null}'
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
selected:2,
|
||||||
|
_closedTabs: [],
|
||||||
|
extData: {
|
||||||
|
"tabview-groups": '{"nextID":3,"activeGroupId":2}',
|
||||||
|
"tabview-group":
|
||||||
|
'{"1":{"bounds":{"left":15,"top":10,"width":320,"height":375},' +
|
||||||
|
'"userSize":null,"locked":{},"title":"","id":1},' +
|
||||||
|
'"2":{"bounds":{"left":380,"top":5,"width":320,"height":375},' +
|
||||||
|
'"userSize":null,"locked":{},"title":"","id":2}}',
|
||||||
|
"tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":875,"height":650}}'
|
||||||
|
}, sizemode:"normal"
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
ss.setWindowState(newWin, JSON.stringify(newState), true);
|
||||||
|
|
||||||
|
// add a new tab.
|
||||||
|
newWin.gBrowser.addTab();
|
||||||
|
is(newWin.gBrowser.tabs.length, 3, "There are 3 browser tabs");
|
||||||
|
|
||||||
|
let onTabViewShow = function() {
|
||||||
|
newWin.removeEventListener("tabviewshown", onTabViewShow, false);
|
||||||
|
|
||||||
|
let contentWindow = newWin.document.getElementById("tab-view").contentWindow;
|
||||||
|
|
||||||
|
is(contentWindow.GroupItems.groupItems.length, 2, "Has two group items");
|
||||||
|
is(contentWindow.GroupItems.getOrphanedTabs().length, 0, "No orphan tabs");
|
||||||
|
|
||||||
|
// clean up and finish
|
||||||
|
prefService.setBoolPref("experienced_first_run", false);
|
||||||
|
newWin.close();
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
newWin.addEventListener("tabviewshown", onTabViewShow, false);
|
||||||
|
newWin.TabView.toggle();
|
||||||
|
}, false);
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче