зеркало из https://github.com/mozilla/pjs.git
Bug 648294 - Opening and closing Panorama fails because keys as given in the DTD are not recognized anymore when synthesizing the key event; r=ian,dao
This commit is contained in:
Родитель
474f792440
Коммит
5b6c378422
|
@ -135,6 +135,10 @@ let UI = {
|
|||
// Used to keep track of allowed browser keys.
|
||||
_browserKeys: null,
|
||||
|
||||
// Variable: _browserKeysWithShift
|
||||
// Used to keep track of allowed browser keys with Shift key combination.
|
||||
_browserKeysWithShift: null,
|
||||
|
||||
// Variable: ignoreKeypressForSearch
|
||||
// Used to prevent keypress being handled after quitting search mode.
|
||||
ignoreKeypressForSearch: false,
|
||||
|
@ -973,11 +977,15 @@ let UI = {
|
|||
"selectAll", "find"
|
||||
].forEach(function(key) {
|
||||
let element = gWindow.document.getElementById("key_" + key);
|
||||
keys[key] = element.getAttribute("key").toLocaleLowerCase().charCodeAt(0);
|
||||
let code = element.getAttribute("key").toLocaleLowerCase().charCodeAt(0);
|
||||
keys[code] = key;
|
||||
});
|
||||
this._browserKeys = keys;
|
||||
|
||||
// for key combinations with shift key, the charCode of upper case letters
|
||||
// are different to the lower case ones so need to handle them differently.
|
||||
keys = {};
|
||||
// The lower case letters are passed to processBrowserKeys() even with shift
|
||||
// key when stimulating a key press using EventUtils.synthesizeKey() so need
|
||||
// to handle both upper and lower cases here.
|
||||
[
|
||||
#ifdef XP_UNIX
|
||||
"redo",
|
||||
|
@ -986,11 +994,10 @@ let UI = {
|
|||
"privatebrowsing"
|
||||
].forEach(function(key) {
|
||||
let element = gWindow.document.getElementById("key_" + key);
|
||||
keys[key] = element.getAttribute("key").toLocaleUpperCase().charCodeAt(0);
|
||||
let code = element.getAttribute("key").toLocaleLowerCase().charCodeAt(0);
|
||||
keys[code] = key;
|
||||
});
|
||||
|
||||
delete this._browserKeys;
|
||||
this._browserKeys = keys;
|
||||
this._browserKeysWithShift = keys;
|
||||
},
|
||||
|
||||
// ----------
|
||||
|
@ -1022,44 +1029,25 @@ let UI = {
|
|||
#endif
|
||||
let preventDefault = true;
|
||||
if (evt.shiftKey) {
|
||||
switch (evt.charCode) {
|
||||
case self._browserKeys.tabview:
|
||||
// when a user presses ctrl+shift+key, upper case letter charCode
|
||||
// is passed to processBrowserKeys() so converting back to lower
|
||||
// case charCode before doing the check
|
||||
let lowercaseCharCode =
|
||||
String.fromCharCode(evt.charCode).toLocaleLowerCase().charCodeAt(0);
|
||||
if (lowercaseCharCode in self._browserKeysWithShift) {
|
||||
let key = self._browserKeysWithShift[lowercaseCharCode];
|
||||
if (key == "tabview")
|
||||
self.exit();
|
||||
break;
|
||||
#ifdef XP_UNIX
|
||||
case self._browserKeys.redo:
|
||||
#endif
|
||||
case self._browserKeys.closeWindow:
|
||||
case self._browserKeys.undoCloseTab:
|
||||
case self._browserKeys.undoCloseWindow:
|
||||
case self._browserKeys.privatebrowsing:
|
||||
else
|
||||
preventDefault = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (evt.charCode) {
|
||||
case self._browserKeys.find:
|
||||
if (evt.charCode in self._browserKeys) {
|
||||
let key = self._browserKeys[evt.charCode];
|
||||
if (key == "find")
|
||||
self.enableSearch();
|
||||
break;
|
||||
#ifdef XP_UNIX
|
||||
case self._browserKeys.quitApplication:
|
||||
#else
|
||||
case self._browserKeys.redo:
|
||||
#endif
|
||||
#ifdef XP_MACOSX
|
||||
case self._browserKeys.preferencesCmdMac:
|
||||
case self._browserKeys.minimizeWindow:
|
||||
case self._browserKeys.hideThisAppCmdMac:
|
||||
#endif
|
||||
case self._browserKeys.newNavigator:
|
||||
case self._browserKeys.newNavigatorTab:
|
||||
case self._browserKeys.undo:
|
||||
case self._browserKeys.cut:
|
||||
case self._browserKeys.copy:
|
||||
case self._browserKeys.paste:
|
||||
case self._browserKeys.selectAll:
|
||||
else
|
||||
preventDefault = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (preventDefault) {
|
||||
|
|
|
@ -17,7 +17,7 @@ function test1() {
|
|||
ok(!TabView.isVisible(), "Tab View is not visible");
|
||||
showTabView(test2);
|
||||
});
|
||||
EventUtils.synthesizeKey("E", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
}
|
||||
|
||||
function test2() {
|
||||
|
@ -58,7 +58,7 @@ function test4() {
|
|||
executeSoon(function() {
|
||||
is(gBrowser.tabs.length, 1, "There is one tab after removing one");
|
||||
|
||||
EventUtils.synthesizeKey("T", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
EventUtils.synthesizeKey("t", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
is(gBrowser.tabs.length, 2, "There are two tabs after restoring one");
|
||||
|
||||
gBrowser.tabs[0].linkedBrowser.loadURI("about:blank");
|
||||
|
@ -96,7 +96,7 @@ function test9() {
|
|||
function test10() {
|
||||
is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + shift + a is pressed");
|
||||
// it would open about:addons on a new tab if it passes through the white list.
|
||||
EventUtils.synthesizeKey("A", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
EventUtils.synthesizeKey("a", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
|
||||
executeSoon(function() {
|
||||
is(gBrowser.tabs.length, 1, "There is still one tab after cmd/ctrl + shift + a is pressed");
|
||||
|
|
|
@ -57,5 +57,5 @@ function toggleTabViewTest(contentWindow) {
|
|||
}
|
||||
contentWindow.addEventListener("tabviewhidden", onTabViewHidden, false);
|
||||
// Use keyboard shortcut to toggle back to browser view
|
||||
EventUtils.synthesizeKey("E", { accelKey: true, shiftKey: true });
|
||||
EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true });
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ function onTabViewWindowLoaded() {
|
|||
// verify that the keyboard combo works (this is the crux of bug 595518)
|
||||
// Prepare the key combo
|
||||
window.addEventListener("tabviewshown", onTabViewShown, false);
|
||||
EventUtils.synthesizeKey("E", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, contentWindow);
|
||||
}
|
||||
|
||||
let onTabViewShown = function() {
|
||||
|
|
|
@ -41,7 +41,7 @@ function onTabViewWindowLoaded() {
|
|||
// the appropriate group would get selected when the key
|
||||
// combination is pressed
|
||||
executeSoon(function() {
|
||||
EventUtils.synthesizeKey("E", {accelKey : true, shiftKey: true}, contentWindow);
|
||||
EventUtils.synthesizeKey("e", {accelKey : true, shiftKey: true}, contentWindow);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ function part2(win) {
|
|||
finish();
|
||||
}, false);
|
||||
// show tabview
|
||||
EventUtils.synthesizeKey("E", { accelKey: true, shiftKey: true }, win);
|
||||
EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, win);
|
||||
// hide tabview
|
||||
EventUtils.synthesizeKey("E", { accelKey: true, shiftKey: true }, win);
|
||||
EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, win);
|
||||
})
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ function test() {
|
|||
newWin.document.getElementById("menu_tabview").doCommand();
|
||||
}, function() {
|
||||
testMethodToHideAndShowTabView(function() {
|
||||
EventUtils.synthesizeKey("E", { accelKey: true, shiftKey: true }, newWin);
|
||||
EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, newWin);
|
||||
}, finish);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче