[iOS][WK2] KeyboardEvent.key always returns an empty string
[WebKit-https.git] / LayoutTests / fast / events / ios / keyboard-event-key-attribute.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta name="viewport" content="width=device-width">
5 <script src="../../../resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <input id="testInput" type="text">
9 <script>
10 description("Tests that KeyboardEvent.key is properly initialized on iOS.");
11 jsTestIsAsync = true;
12
13 function getTypingUIScript(x, y)
14 {
15     return `
16         (function() {
17             uiController.didShowKeyboardCallback = function() {
18                 uiController.typeCharacterUsingHardwareKeyboard('a', function() {
19                     uiController.uiScriptComplete();
20                 });
21             };
22             uiController.singleTapAtPoint(${x}, ${y}, function() { });
23         })();`
24 }
25
26 var testInput = document.getElementById("testInput");
27 testInput.onkeydown = function(e) {
28     event = e;
29     shouldBeEqualToString("event.key", "a");
30     finishJSTest();
31 };
32
33 const x = testInput.offsetLeft + 5;
34 const y = testInput.offsetTop + 5;
35 testRunner.runUIScript(getTypingUIScript(x, y), function() { });
36 </script>
37 <script src="../../../resources/js-test-post.js"></script>
38 </body>
39 </html>