зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1303273 part.4 Add automated tests for bug 1293505, bug 1307703 and bug 1297985 r=m_kato
Now, NativeKey respects following WM_CHAR message. Therefore, we can create a test for bug 1293505 which a function key causes a printable character. Additionally, bug 1307703 is now fixed by the previous patch. So, let's add automated test for it too. Finally, now, I found a way to test with some keyboard layouts which are not available on old Windows. Therefore, we should add automated tests for bug 1297985 too. MozReview-Commit-ID: IqCEPbPYrcQ --HG-- extra : rebase_source : 451d0264f1180cae7d7035a498f1c13416d53246
This commit is contained in:
Родитель
8c926d5f82
Коммит
ae437d0a9a
|
@ -870,10 +870,14 @@ const KEYBOARD_LAYOUT_HEBREW =
|
||||||
{ name: "Hebrew", Mac: 8, Win: 0x0000040D };
|
{ name: "Hebrew", Mac: 8, Win: 0x0000040D };
|
||||||
const KEYBOARD_LAYOUT_JAPANESE =
|
const KEYBOARD_LAYOUT_JAPANESE =
|
||||||
{ name: "Japanese", Mac: null, Win: 0x00000411 };
|
{ name: "Japanese", Mac: null, Win: 0x00000411 };
|
||||||
|
const KEYBOARD_LAYOUT_KHMER =
|
||||||
|
{ name: "Khmer", Mac: null, Win: 0x00000453 }; // available on Win7 or later.
|
||||||
const KEYBOARD_LAYOUT_LITHUANIAN =
|
const KEYBOARD_LAYOUT_LITHUANIAN =
|
||||||
{ name: "Lithuanian", Mac: 9, Win: 0x00010427 };
|
{ name: "Lithuanian", Mac: 9, Win: 0x00010427 };
|
||||||
const KEYBOARD_LAYOUT_NORWEGIAN =
|
const KEYBOARD_LAYOUT_NORWEGIAN =
|
||||||
{ name: "Norwegian", Mac: 10, Win: 0x00000414 };
|
{ name: "Norwegian", Mac: 10, Win: 0x00000414 };
|
||||||
|
const KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC =
|
||||||
|
{ name: "Russian - Mnemonic", Mac: null, Win: 0x00020419 }; // available on Win8 or later.
|
||||||
const KEYBOARD_LAYOUT_SPANISH =
|
const KEYBOARD_LAYOUT_SPANISH =
|
||||||
{ name: "Spanish", Mac: 11, Win: 0x0000040A };
|
{ name: "Spanish", Mac: 11, Win: 0x0000040A };
|
||||||
const KEYBOARD_LAYOUT_SWEDISH =
|
const KEYBOARD_LAYOUT_SWEDISH =
|
||||||
|
|
|
@ -51,6 +51,12 @@
|
||||||
|
|
||||||
const IS_MAC = navigator.platform.indexOf("Mac") == 0;
|
const IS_MAC = navigator.platform.indexOf("Mac") == 0;
|
||||||
const IS_WIN = navigator.platform.indexOf("Win") == 0;
|
const IS_WIN = navigator.platform.indexOf("Win") == 0;
|
||||||
|
const OS_VERSION =
|
||||||
|
IS_WIN ? parseFloat(Components.classes["@mozilla.org/system-info;1"]
|
||||||
|
.getService(Components.interfaces.nsIPropertyBag2)
|
||||||
|
.getProperty("version")) : 0;
|
||||||
|
const WIN7 = 6.1;
|
||||||
|
const WIN8 = 6.2;
|
||||||
|
|
||||||
function isModifierKeyEvent(aEvent)
|
function isModifierKeyEvent(aEvent)
|
||||||
{
|
{
|
||||||
|
@ -359,9 +365,9 @@ function* runKeyEventTests()
|
||||||
var e = eventList[i];
|
var e = eventList[i];
|
||||||
if (e.type == "keypress") {
|
if (e.type == "keypress") {
|
||||||
var isCtrlExpected =
|
var isCtrlExpected =
|
||||||
!!(aEvent.modifiers.ctrlKey || aEvent.modifiers.ctrlRightKey);
|
!!(aEvent.modifiers.ctrlKey || aEvent.modifiers.ctrlRightKey) && !aEvent.isInputtingCharacters;
|
||||||
var isAltExpected =
|
var isAltExpected =
|
||||||
!!(aEvent.modifiers.altKey || aEvent.modifiers.altRightKey);
|
!!(aEvent.modifiers.altKey || aEvent.modifiers.altRightKey) && !aEvent.isInputtingCharacters;
|
||||||
if (IS_WIN && (aEvent.modifiers.altGrKey || isCtrlExpected && isAltExpected)) {
|
if (IS_WIN && (aEvent.modifiers.altGrKey || isCtrlExpected && isAltExpected)) {
|
||||||
isCtrlExpected = isAltExpected = (aEvent.chars == "");
|
isCtrlExpected = isAltExpected = (aEvent.chars == "");
|
||||||
}
|
}
|
||||||
|
@ -2084,6 +2090,13 @@ function* runKeyEventTests()
|
||||||
modifiers:{ctrl:1, altKey:1}, chars:""},
|
modifiers:{ctrl:1, altKey:1}, chars:""},
|
||||||
"Enter", "Enter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
"Enter", "Enter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
|
||||||
|
// Even non-printable key could be mapped as a printable key.
|
||||||
|
// Only "keyup" event cannot know if it *did* cause inputting text.
|
||||||
|
// Therefore, only "keydown" and "keypress" event's key value should be the character inputted by the key.
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F4,
|
||||||
|
modifiers:{}, chars:"a"},
|
||||||
|
["a", "a", "F4"], "F4", nsIDOMKeyEvent.DOM_VK_F4, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
|
||||||
// US
|
// US
|
||||||
// Alphabet
|
// Alphabet
|
||||||
yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A,
|
yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A,
|
||||||
|
@ -3376,6 +3389,34 @@ function* runKeyEventTests()
|
||||||
modifiers:{shiftKey:1}, chars:"'"},
|
modifiers:{shiftKey:1}, chars:"'"},
|
||||||
"'", "Backslash", nsIDOMKeyEvent.DOM_VK_HASH, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
"'", "Backslash", nsIDOMKeyEvent.DOM_VK_HASH, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
|
||||||
|
// Khmer
|
||||||
|
if (OS_VERSION >= WIN7) {
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2,
|
||||||
|
modifiers:{}, chars:"\u17E2"},
|
||||||
|
"\u17E2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2,
|
||||||
|
modifiers:{shiftKey:1}, chars:"\u17D7"},
|
||||||
|
"\u17D7", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17D7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, // Ctrl+2 should cause inputting Euro sign.
|
||||||
|
modifiers:{ctrlKey:1}, chars:"\u20AC", isInputtingCharacters:true},
|
||||||
|
"\u20AC", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u20AC", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, // Ctrl+Shift+2 shouldn't cause any input.
|
||||||
|
modifiers:{ctrlKey:1, shiftKey:1}, chars:""},
|
||||||
|
"\u17D7", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17D7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2,
|
||||||
|
modifiers:{altKey:1}, chars:"\u17E2"},
|
||||||
|
"\u17E2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2,
|
||||||
|
modifiers:{altKey:1, shiftKey:1}, chars:"\u17D7"},
|
||||||
|
"\u17D7", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17D7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2,
|
||||||
|
modifiers:{altGrKey:1}, chars:"2"},
|
||||||
|
"2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2,
|
||||||
|
modifiers:{altGrKey:1, shiftKey:1}, chars:"\u19E2"},
|
||||||
|
"\u19E2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u19E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
}
|
||||||
|
|
||||||
// Norwegian
|
// Norwegian
|
||||||
yield testKey({layout:KEYBOARD_LAYOUT_NORWEGIAN, keyCode:WIN_VK_OEM_5,
|
yield testKey({layout:KEYBOARD_LAYOUT_NORWEGIAN, keyCode:WIN_VK_OEM_5,
|
||||||
modifiers:{}, chars:"|"},
|
modifiers:{}, chars:"|"},
|
||||||
|
@ -3576,6 +3617,30 @@ function* runKeyEventTests()
|
||||||
modifiers:{shiftKey:1}, chars:"\u00A8Q"},
|
modifiers:{shiftKey:1}, chars:"\u00A8Q"},
|
||||||
["\u00A8Q", "\u00A8", "Q", "Q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "\u00A8Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
["\u00A8Q", "\u00A8", "Q", "Q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "\u00A8Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
|
||||||
|
if (OS_VERSION >= WIN8) {
|
||||||
|
// On Russian Mnemonic layout, both 'KeyS' and 'KeyC' are dead key. However, the sequence 'KeyS' -> 'KeyC' causes a composite character.
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_S,
|
||||||
|
modifiers:{}, chars:""},
|
||||||
|
"Dead", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_S,
|
||||||
|
modifiers:{}, chars:"\u0441\u0441"},
|
||||||
|
["\u0441\u0441", "\u0441", "\u0441", "\u0441"], "KeyS", nsIDOMKeyEvent.DOM_VK_S, "\u0441\u0441", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_C,
|
||||||
|
modifiers:{}, chars:""},
|
||||||
|
"Dead", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_C,
|
||||||
|
modifiers:{}, chars:"\u0446\u0446"},
|
||||||
|
["\u0446\u0446", "\u0446", "\u0446", "\u0446"], "KeyC", nsIDOMKeyEvent.DOM_VK_C, "\u0446\u0446", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_S,
|
||||||
|
modifiers:{}, chars:""},
|
||||||
|
"Dead", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_C,
|
||||||
|
modifiers:{}, chars:"\u0449"},
|
||||||
|
["\u0449", "\u0449", "\u0446"], "KeyC", nsIDOMKeyEvent.DOM_VK_C, "\u0449", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
|
||||||
|
}
|
||||||
|
|
||||||
// When Alt key is pressed, dead key sequence is generated with WM_SYSKEYDOWN, WM_SYSDEADCHAR, WM_SYSCHAR and WM_SYSKEYUP.
|
// When Alt key is pressed, dead key sequence is generated with WM_SYSKEYDOWN, WM_SYSDEADCHAR, WM_SYSCHAR and WM_SYSKEYUP.
|
||||||
yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1,
|
yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1,
|
||||||
modifiers:{altKey:1}, chars:""},
|
modifiers:{altKey:1}, chars:""},
|
||||||
|
@ -4213,6 +4278,10 @@ function runTest()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_WIN && OS_VERSION >= WIN8) {
|
||||||
|
// Switching keyboard layout to Russian - Mnemonic causes 2 assertions in KeyboardLayout::LoadLayout().
|
||||||
|
SimpleTest.expectAssertions(2, 2);
|
||||||
|
}
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
clearInfobars();
|
clearInfobars();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче