Bug 1268441 - Fix support of all non-letter characters. r=bgrins

This commit is contained in:
Alexandre Poirot 2016-05-12 03:07:56 -07:00
Родитель 0e659215da
Коммит a3cd47760d
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -122,7 +122,7 @@ KeyShortcuts.parseElectronKey = function (window, str) {
}
}
if (key.match(/^\w$/)) {
if (typeof(key) === "string" && key.length === 1) {
// Match any single character
shortcut.key = key.toLowerCase();
} else if (key in ElectronKeysMapping) {

Просмотреть файл

@ -8,6 +8,7 @@ add_task(function* () {
window
});
yield testSimple(shortcuts);
yield testNonLetterCharacter(shortcuts);
yield testMixup(shortcuts);
yield testExactModifiers(shortcuts);
yield testLooseShiftModifier(shortcuts);
@ -38,7 +39,6 @@ function once(shortcuts, key, listener) {
function testSimple(shortcuts) {
info("Test simple key shortcuts");
let called = false;
let onKey = once(shortcuts, "0", (key, event) => {
is(event.key, "0");
@ -50,6 +50,17 @@ function testSimple(shortcuts) {
yield onKey;
}
function testNonLetterCharacter(shortcuts) {
info("Test non-naive character key shortcuts");
let onKey = once(shortcuts, "[", (key, event) => {
is(event.key, "[");
});
EventUtils.synthesizeKey("[", {}, window);
yield onKey;
}
// Test they listeners are not mixed up between shortcuts
function testMixup(shortcuts) {
info("Test possible listener mixup");