Bug 1300937 part.3 NativeKeyCodes.js should specify scan code to WIN_VK_ABNT_C1 explicitly for avoiding (perhaps) a bug of MapVirtualKeyEx() API r?smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 13 Sep 2016 19:55:29 +0900
changeset 414379 f07ec26506b4d72313972b1f0f85acb51b4c0ee2
parent 414378 832c8c11ee33da17861b056bcdffbcfaa786ef39
child 414380 26b925859b6807d39da21961bcdf5ba724539dee
push id29650
push usermasayuki@d-toybox.com
push dateFri, 16 Sep 2016 07:02:08 +0000
reviewerssmaug
bugs1300937
milestone51.0a1
Bug 1300937 part.3 NativeKeyCodes.js should specify scan code to WIN_VK_ABNT_C1 explicitly for avoiding (perhaps) a bug of MapVirtualKeyEx() API r?smaug Unfortunately, MapVirtualKeyEx() doesn't compute ABNT C1's scan code from its virtual keycode, 0xC1. Therefore, NativeKeyCodes.js should specify 0x0056 explicitly. Fortunately, this key in physical keyboard always generates the scan code value with any keyboard layouts. Therefore, this can test new regressions as expected. FYI: ABNT C1 key is a key in Brazilian keyboard. It's at between "ShiftLeft" and "KeyZ". MozReview-Commit-ID: GmpnFKOsnKD
testing/mochitest/tests/SimpleTest/NativeKeyCodes.js
widget/tests/test_keycodes.xul
--- a/testing/mochitest/tests/SimpleTest/NativeKeyCodes.js
+++ b/testing/mochitest/tests/SimpleTest/NativeKeyCodes.js
@@ -5,16 +5,23 @@
  */
 
 // Windows
 // Windows' native key code values may include scan code value which can be
 // retrieved with |((code & 0xFFFF0000 >> 16)|.  If the value is 0, it will
 // be computed with active keyboard layout automatically.
 // FYI: Don't define scan code here for printable keys, numeric keys and
 //      IME keys because they depend on active keyboard layout.
+// XXX: Although, ABNT C1 key depends on keyboard layout in strictly speaking.
+//      However, computing its scan code from the virtual keycode,
+//      WIN_VK_ABNT_C1, doesn't work fine (computed as 0x0073, "IntlRo").
+//      Therefore, we should specify it here explicitly (it should be 0x0056,
+//      "IntlBackslash").  Fortunately, the key always generates 0x0056 with
+//      any keyboard layouts as far as I've tested.  So, this must be safe to
+//      test new regressions.
 
 const WIN_VK_LBUTTON                    = 0x00000001;
 const WIN_VK_RBUTTON                    = 0x00000002;
 const WIN_VK_CANCEL                     = 0xE0460003;
 const WIN_VK_MBUTTON                    = 0x00000004;
 const WIN_VK_XBUTTON1                   = 0x00000005;
 const WIN_VK_XBUTTON2                   = 0x00000006;
 const WIN_VK_BACK                       = 0x000E0008;
@@ -172,17 +179,17 @@ const WIN_VK_LAUNCH_APP1                
 const WIN_VK_LAUNCH_APP2                = 0xE02100B7;
 const WIN_VK_OEM_1                      = 0x000000BA;
 const WIN_VK_OEM_PLUS                   = 0x000000BB;
 const WIN_VK_OEM_COMMA                  = 0x000000BC;
 const WIN_VK_OEM_MINUS                  = 0x000000BD;
 const WIN_VK_OEM_PERIOD                 = 0x000000BE;
 const WIN_VK_OEM_2                      = 0x000000BF;
 const WIN_VK_OEM_3                      = 0x000000C0;
-const WIN_VK_ABNT_C1                    = 0x000000C1;
+const WIN_VK_ABNT_C1                    = 0x005600C1;
 const WIN_VK_ABNT_C2                    = 0x000000C2;
 const WIN_VK_OEM_4                      = 0x000000DB;
 const WIN_VK_OEM_5                      = 0x000000DC;
 const WIN_VK_OEM_6                      = 0x000000DD;
 const WIN_VK_OEM_7                      = 0x000000DE;
 const WIN_VK_OEM_8                      = 0x000000DF;
 const WIN_VK_OEM_NEC_DP1                = 0x000000E0;
 const WIN_VK_OEM_AX                     = 0x000000E1;
--- a/widget/tests/test_keycodes.xul
+++ b/widget/tests/test_keycodes.xul
@@ -2842,20 +2842,20 @@ function* runKeyEventTests()
                   "|", "Backquote", nsIDOMKeyEvent.DOM_VK_PIPE, "|", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
     yield testKey({layout:KEYBOARD_LAYOUT_NORWEGIAN, keyCode:WIN_VK_OEM_5,
                    modifiers:{shiftKey:1}, chars:"\u00A7"},
                   "\u00A7", "Backquote", nsIDOMKeyEvent.DOM_VK_PIPE, "\u00A7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
 
     // Brazilian ABNT
     yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_ABNT_C1,
                    modifiers:{}, chars:"/"},
-                  "/", "IntlRo" /* TODO, should be "IntlBackslash" */, nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
+                  "/", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
     yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_ABNT_C1,
                    modifiers:{shiftKey:1}, chars:"?"},
-                  "?", "IntlRo" /* TODO, should be "IntlBackslash" */, nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
+                  "?", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
     yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_ABNT_C2,
                    modifiers:{numLockKey:1}, chars:"."},
                   ".", "NumpadComma", nsIDOMKeyEvent.DOM_VK_SEPARATOR, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD);
     yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_DECIMAL,
                    modifiers:{numLockKey:1}, chars:","},
                   ",", "NumpadDecimal", nsIDOMKeyEvent.DOM_VK_DECIMAL, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD);
 
     // Mac JIS keyboard