зеркало из https://github.com/mozilla/pjs.git
Bug 633788 - "closing last tab" inconsistency between main browser window and panorama [r=ian, a=beltzner]
This commit is contained in:
Родитель
89801036a5
Коммит
365c43846b
|
@ -806,7 +806,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
|||
toClose.forEach(function(child) {
|
||||
child.removeSubscriber(self, "close");
|
||||
|
||||
let removed = child.close();
|
||||
let removed = child.close(true);
|
||||
if (removed) {
|
||||
shouldRemoveTabItems.push(child);
|
||||
} else {
|
||||
|
|
|
@ -541,8 +541,24 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
|||
// Function: close
|
||||
// Closes this item (actually closes the tab associated with it, which automatically
|
||||
// closes the item.
|
||||
// Parameters:
|
||||
// groupClose - true if this method is called by group close action.
|
||||
// Returns true if this tab is removed.
|
||||
close: function TabItem_close() {
|
||||
close: function TabItem_close(groupClose) {
|
||||
// When the last tab is closed, put a new tab into closing tab's group. If
|
||||
// closing tab doesn't belong to a group and no empty group, create a new
|
||||
// one for the new tab.
|
||||
if (!groupClose && gBrowser.tabs.length == 1) {
|
||||
if (this.tab._tabViewTabItem.parent) {
|
||||
group = this.tab._tabViewTabItem.parent;
|
||||
} else {
|
||||
let emptyGroups = GroupItems.groupItems.filter(function (groupItem) {
|
||||
return (!groupItem.getChildren().length);
|
||||
});
|
||||
group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup());
|
||||
}
|
||||
group.newTab();
|
||||
}
|
||||
// when "TabClose" event is fired, the browser tab is about to close and our
|
||||
// item "close" is fired before the browser tab actually get closed.
|
||||
// Therefore, we need "tabRemoved" event below.
|
||||
|
|
|
@ -114,6 +114,7 @@ _BROWSER_FILES = \
|
|||
browser_tabview_bug630102.js \
|
||||
browser_tabview_bug630157.js \
|
||||
browser_tabview_bug631662.js \
|
||||
browser_tabview_bug633788.js \
|
||||
browser_tabview_bug634077.js \
|
||||
browser_tabview_bug634085.js \
|
||||
browser_tabview_bug634158.js \
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
showTabView(function () {
|
||||
is(gBrowser.tabs.length, 1, "There is only one tab");
|
||||
|
||||
let tab = gBrowser.tabs[0];
|
||||
let tabItem = tab._tabViewTabItem;
|
||||
ok(tabItem.parent, "The tab item belongs to a group");
|
||||
let groupId = tabItem.parent.id;
|
||||
|
||||
tab._tabViewTabItem.close();
|
||||
|
||||
whenTabViewIsHidden(function() {
|
||||
// a new tab with group should be opened
|
||||
is(gBrowser.tabs.length, 1, "There is still one tab");
|
||||
isnot(gBrowser.selectedTab, tab, "The tab is different");
|
||||
|
||||
tab = gBrowser.tabs[0];
|
||||
tabItem = tab._tabViewTabItem;
|
||||
ok(tabItem.parent, "This new tab item belongs to a group");
|
||||
|
||||
is(tabItem.parent.id, groupId, "The group is different");
|
||||
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}
|
Загрузка…
Ссылка в новой задаче