зеркало из https://github.com/mozilla/pjs.git
Bug 445768 – CTRL+Tab moves to location bar if only 1 tab is open. r=gavin
This commit is contained in:
Родитель
2d203c2ab5
Коммит
25d6b9bf3b
|
@ -447,14 +447,14 @@ var ctrlTab = {
|
|||
var propagate = !isOpen;
|
||||
switch (event.keyCode) {
|
||||
case event.DOM_VK_TAB:
|
||||
if (event.ctrlKey && !event.altKey && !event.metaKey && this.tabs.length > 1) {
|
||||
if (event.ctrlKey && !event.altKey && !event.metaKey) {
|
||||
propagate = false;
|
||||
this.invertDirection = event.shiftKey;
|
||||
if (isOpen)
|
||||
this.scroll();
|
||||
else if (this.tabs.length == 2)
|
||||
gBrowser.selectedTab = this.tabs[1];
|
||||
else
|
||||
else if (this.tabs.length > 2)
|
||||
this.open();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -19,8 +19,24 @@ function test() {
|
|||
ctrlTabTest([1] , 1, 0);
|
||||
|
||||
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
|
||||
|
||||
var focusedWindow = document.commandDispatcher.focusedWindow;
|
||||
var eventConsumed = true;
|
||||
var detectKeyEvent = function (event) {
|
||||
eventConsumed = event.getPreventDefault();
|
||||
};
|
||||
document.addEventListener("keypress", detectKeyEvent, false);
|
||||
pressCtrlTab();
|
||||
document.removeEventListener("keypress", detectKeyEvent, false);
|
||||
ok(eventConsumed, "Ctrl+Tab consumed by the tabbed browser if one tab is open");
|
||||
is(focusedWindow.location, document.commandDispatcher.focusedWindow.location,
|
||||
"Ctrl+Tab doesn't change focus if one tab is open");
|
||||
}
|
||||
|
||||
function pressCtrlTab() EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
|
||||
function releaseCtrl() EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
|
||||
|
||||
function ctrlTabTest(tabsToSelect, tabTimes, expectedIndex) {
|
||||
tabsToSelect.forEach(function (index) {
|
||||
gBrowser.selectedTab = gBrowser.mTabs[index];
|
||||
|
@ -33,7 +49,7 @@ function ctrlTabTest(tabsToSelect, tabTimes, expectedIndex) {
|
|||
normalized + " tabs back in most-recently-selected order";
|
||||
|
||||
for (let i = 0; i < tabTimes; i++) {
|
||||
EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
pressCtrlTab();
|
||||
|
||||
if (tabCount > 2)
|
||||
is(gBrowser.tabContainer.selectedIndex, indexStart,
|
||||
|
@ -47,7 +63,7 @@ function ctrlTabTest(tabsToSelect, tabTimes, expectedIndex) {
|
|||
is(ctrlTab.label.value, gBrowser.mTabs[expectedIndex].label,
|
||||
"Preview panel displays label of expected tab");
|
||||
|
||||
EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
|
||||
releaseCtrl();
|
||||
|
||||
ok(ctrlTab.panel.state == "hiding" || ctrlTab.panel.state == "closed",
|
||||
"Releasing Ctrl closes the preview panel");
|
||||
|
|
Загрузка…
Ссылка в новой задаче