зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1268450 - Fix 'Plus' key shortcut support. r=jryans
This commit is contained in:
Родитель
f4727ff5fd
Коммит
9274a23b5b
|
@ -34,7 +34,6 @@ const ElectronKeysMapping = {
|
|||
"F22": "DOM_VK_F22",
|
||||
"F23": "DOM_VK_F23",
|
||||
"F24": "DOM_VK_F24",
|
||||
"Plus": "DOM_VK_PLUS",
|
||||
"Space": "DOM_VK_SPACE",
|
||||
"Backspace": "DOM_VK_BACK_SPACE",
|
||||
"Delete": "DOM_VK_DELETE",
|
||||
|
@ -122,7 +121,13 @@ KeyShortcuts.parseElectronKey = function (window, str) {
|
|||
}
|
||||
}
|
||||
|
||||
if (typeof (key) === "string" && key.length === 1) {
|
||||
// Plus is a special case. It's a character key and shouldn't be matched
|
||||
// against a keycode as it is only accessible via Shift/Capslock
|
||||
if (key === "Plus") {
|
||||
key = "+";
|
||||
}
|
||||
|
||||
if (typeof key === "string" && key.length === 1) {
|
||||
// Match any single character
|
||||
shortcut.key = key.toLowerCase();
|
||||
} else if (key in ElectronKeysMapping) {
|
||||
|
|
|
@ -9,6 +9,7 @@ add_task(function* () {
|
|||
});
|
||||
yield testSimple(shortcuts);
|
||||
yield testNonLetterCharacter(shortcuts);
|
||||
yield testPlusCharacter(shortcuts);
|
||||
yield testMixup(shortcuts);
|
||||
yield testLooseDigits(shortcuts);
|
||||
yield testExactModifiers(shortcuts);
|
||||
|
@ -62,6 +63,20 @@ function testNonLetterCharacter(shortcuts) {
|
|||
yield onKey;
|
||||
}
|
||||
|
||||
// Plus is special. It's keycode is the one for "=". That's because it requires
|
||||
// shift to be pressed and is behind "=" key. So it should be considered as a
|
||||
// character key
|
||||
function testPlusCharacter(shortcuts) {
|
||||
info("Test 'Plus' key shortcuts");
|
||||
|
||||
let onKey = once(shortcuts, "Plus", (key, event) => {
|
||||
is(event.key, "+");
|
||||
});
|
||||
|
||||
EventUtils.synthesizeKey("+", { keyCode: 61, shiftKey: true }, window);
|
||||
yield onKey;
|
||||
}
|
||||
|
||||
// Test they listeners are not mixed up between shortcuts
|
||||
function testMixup(shortcuts) {
|
||||
info("Test possible listener mixup");
|
||||
|
|
Загрузка…
Ссылка в новой задаче