зеркало из https://github.com/mozilla/pjs.git
Bug 608158 - Exiting Panorama when nothing but hidden groups and no app tabs, should create new tab [r=ian, a=beltzner]
This commit is contained in:
Родитель
93f5208e6d
Коммит
63174a46ba
|
@ -365,6 +365,7 @@ SearchEventHandlerClass.prototype = {
|
|||
// Function: inSearchKeyHandler
|
||||
// Handles all keypresses while search mode.
|
||||
inSearchKeyHandler: function (event) {
|
||||
let term = iQ("#searchbox").val();
|
||||
if ((event.keyCode == event.DOM_VK_ESCAPE) ||
|
||||
(event.keyCode == event.DOM_VK_BACK_SPACE && term.length <= 1)) {
|
||||
hideSearch(event);
|
||||
|
|
|
@ -173,7 +173,6 @@ let UI = {
|
|||
this._addTabActionHandlers();
|
||||
|
||||
// ___ Storage
|
||||
|
||||
GroupItems.pauseArrange();
|
||||
GroupItems.init();
|
||||
|
||||
|
@ -757,7 +756,7 @@ let UI = {
|
|||
|
||||
if (currentTab && currentTab.tabItem)
|
||||
oldItem = currentTab.tabItem;
|
||||
|
||||
|
||||
// update the tab bar for the new tab's group
|
||||
if (tab && tab.tabItem) {
|
||||
newItem = tab.tabItem;
|
||||
|
@ -1216,16 +1215,51 @@ let UI = {
|
|||
}
|
||||
|
||||
if (!zoomedIn) {
|
||||
let unhiddenGroups = GroupItems.groupItems.filter(function(groupItem) {
|
||||
return (!groupItem.hidden && groupItem.getChildren().length > 0);
|
||||
});
|
||||
// no visible groups, no orphaned tabs and no apps tabs, open a new group
|
||||
// with a blank tab
|
||||
if (unhiddenGroups.length == 0 && GroupItems.getOrphanedTabs().length == 0 &&
|
||||
gBrowser._numPinnedTabs == 0) {
|
||||
let box = new Rect(20, 20, 250, 200);
|
||||
let groupItem = new GroupItem([], { bounds: box, immediately: true });
|
||||
groupItem.newTab();
|
||||
return;
|
||||
}
|
||||
|
||||
// If there's an active TabItem, zoom into it. If not (for instance when the
|
||||
// selected tab is an app tab), just go there.
|
||||
let activeTabItem = this.getActiveTab();
|
||||
if (!activeTabItem)
|
||||
activeTabItem = gBrowser.selectedTab.tabItem;
|
||||
if (!activeTabItem) {
|
||||
let tabItem = gBrowser.selectedTab.tabItem;
|
||||
if (tabItem) {
|
||||
if (!tabItem.parent || !tabItem.parent.hidden) {
|
||||
activeTabItem = tabItem;
|
||||
} else { // set active tab item if there is at least one unhidden group
|
||||
if (unhiddenGroups.length > 0)
|
||||
activeTabItem = unhiddenGroups[0].getActiveTab();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (activeTabItem)
|
||||
if (activeTabItem) {
|
||||
activeTabItem.zoomIn();
|
||||
else
|
||||
self.goToTab(gBrowser.selectedTab);
|
||||
} else {
|
||||
if (gBrowser._numPinnedTabs > 0) {
|
||||
if (gBrowser.selectedTab.pinned) {
|
||||
self.goToTab(gBrowser.selectedTab);
|
||||
} else {
|
||||
Array.some(gBrowser.tabs, function(tab) {
|
||||
if (tab.pinned) {
|
||||
self.goToTab(tab);
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ _BROWSER_FILES = \
|
|||
browser_tabview_bug600645.js \
|
||||
browser_tabview_bug606905.js \
|
||||
browser_tabview_bug608037.js \
|
||||
browser_tabview_bug608158.js \
|
||||
browser_tabview_dragdrop.js \
|
||||
browser_tabview_exit_button.js \
|
||||
browser_tabview_group.js \
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/* ***** 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 a test for bug 608158.
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
|
||||
TabView.toggle();
|
||||
}
|
||||
|
||||
function onTabViewWindowLoaded() {
|
||||
window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
|
||||
|
||||
let contentWindow = document.getElementById("tab-view").contentWindow;
|
||||
|
||||
is(contentWindow.GroupItems.groupItems.length, 1,
|
||||
"There is one group item on startup");
|
||||
is(gBrowser.tabs.length, 1, "There is one tab on startup");
|
||||
let groupItem = contentWindow.GroupItems.groupItems[0];
|
||||
|
||||
groupItem.addSubscriber(groupItem, "groupHidden", function() {
|
||||
groupItem.removeSubscriber(groupItem, "groupHidden");
|
||||
|
||||
let onTabViewHidden = function() {
|
||||
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
|
||||
is(contentWindow.GroupItems.groupItems.length, 1,
|
||||
"There is still one group item");
|
||||
isnot(groupItem, contentWindow.GroupItems.groupItems[0],
|
||||
"The initial group item is not the same as the final group item");
|
||||
is(gBrowser.tabs.length, 1, "There is only one tab");
|
||||
ok(!TabView.isVisible(), "Tab View is hidden");
|
||||
finish();
|
||||
};
|
||||
window.addEventListener("tabviewhidden", onTabViewHidden, false);
|
||||
|
||||
TabView.hide();
|
||||
});
|
||||
groupItem.closeAll();
|
||||
}
|
Загрузка…
Ссылка в новой задаче