[iOS] uiController.typeCharacterUsingHardwareKeyboard("`", ...) dispatches DOM key...
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 23:08:34 +0000 (23:08 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 23:08:34 +0000 (23:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189325

Reviewed by Wenson Hsieh.

Tools:

Fixes an issue where the test infrastructure would incorrectly synthesized a shift key press followed
by a ` key press (i.e. type '~') when instructed to simulate typing a grave accent (`). Typing a
grave accent does not require holding the shift key.

* WebKitTestRunner/ios/HIDEventGenerator.mm:
(shouldWrapWithShiftKeyEventForCharacter):

LayoutTests:

Add a test to ensure that we dispatch the correct DOM key events when using uiController.typeCharacterUsingHardwareKeyboard("`")
(by way of UIHelper.typeCharacter()).

* fast/events/ios/keypress-grave-accent-expected.txt: Added.
* fast/events/ios/keypress-grave-accent.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235818 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/ios/keypress-grave-accent-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/keypress-grave-accent.html [new file with mode: 0644]
Tools/ChangeLog
Tools/WebKitTestRunner/ios/HIDEventGenerator.mm

index f46c7ea..087f982 100644 (file)
@@ -1,3 +1,16 @@
+2018-09-07  Daniel Bates  <dabates@apple.com>
+
+        [iOS] uiController.typeCharacterUsingHardwareKeyboard("`", ...) dispatches DOM key events for ~
+        https://bugs.webkit.org/show_bug.cgi?id=189325
+
+        Reviewed by Wenson Hsieh.
+
+        Add a test to ensure that we dispatch the correct DOM key events when using uiController.typeCharacterUsingHardwareKeyboard("`")
+        (by way of UIHelper.typeCharacter()).
+
+        * fast/events/ios/keypress-grave-accent-expected.txt: Added.
+        * fast/events/ios/keypress-grave-accent.html: Added.
+
 2018-09-07  Basuke Suzuki  <Basuke.Suzuki@sony.com>
 
         [Curl][WebKitLegacy] Stop sending credential embedded in the url via XHR.
diff --git a/LayoutTests/fast/events/ios/keypress-grave-accent-expected.txt b/LayoutTests/fast/events/ios/keypress-grave-accent-expected.txt
new file mode 100644 (file)
index 0000000..79064d4
--- /dev/null
@@ -0,0 +1,7 @@
+Tests that we dispatch DOM key events with the correct details when the grave accent key (`) is pressed on the keyboard.
+
+
+type: keydown, key: `, code: Backquote, keyIdentifier: U+0060, keyCode: 192, charCode: 0, keyCode: 192, which: 192
+type: keypress, key: `, code: Backquote, keyIdentifier: , keyCode: 96, charCode: 96, keyCode: 96, which: 96
+type: keyup, key: `, code: Unidentified, keyIdentifier: Unidentified, keyCode: 0, charCode: 0, keyCode: 0, which: 0
+
diff --git a/LayoutTests/fast/events/ios/keypress-grave-accent.html b/LayoutTests/fast/events/ios/keypress-grave-accent.html
new file mode 100644 (file)
index 0000000..42dfb17
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<script src="../../../resources/ui-helper.js"></script>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>Tests that we dispatch DOM key events with the correct details when the grave accent key (`) is pressed on the keyboard.</p>
+<input type="text" id="input" onkeydown="logKeyEvent(event)" onkeyup="logKeyEvent(event)" onkeypress="logKeyEvent(event)">
+<hr>
+<pre id="console"></pre>
+<script>
+var numberOfFiredKeyEvents = 0;
+var numberOfFiredKeyEventsForTestComplete = 3;
+
+function log(message)
+{
+    document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
+}
+
+function logKeyEvent(event)
+{
+    let pieces = [];
+    for (let propertyName of ["type", "key", "code", "keyIdentifier", "keyCode", "charCode", "keyCode", "which"])
+        pieces.push(`${propertyName}: ${event[propertyName]}`);
+    log(pieces.join(", "));
+    if (++numberOfFiredKeyEvents >= numberOfFiredKeyEventsForTestComplete && window.testRunner)
+        testRunner.notifyDone();
+}
+
+async function runTest()
+{
+    if (!window.testRunner)
+        return;
+    await UIHelper.activateFormControl(document.getElementById("input"));
+    await UIHelper.typeCharacter("`");
+}
+
+runTest();
+</script>
+</body>
+</html>
index 3ad2b21..b0f05d5 100644 (file)
@@ -1,3 +1,17 @@
+2018-09-07  Daniel Bates  <dabates@apple.com>
+
+        [iOS] uiController.typeCharacterUsingHardwareKeyboard("`", ...) dispatches DOM key events for ~
+        https://bugs.webkit.org/show_bug.cgi?id=189325
+
+        Reviewed by Wenson Hsieh.
+
+        Fixes an issue where the test infrastructure would incorrectly synthesized a shift key press followed
+        by a ` key press (i.e. type '~') when instructed to simulate typing a grave accent (`). Typing a
+        grave accent does not require holding the shift key.
+
+        * WebKitTestRunner/ios/HIDEventGenerator.mm:
+        (shouldWrapWithShiftKeyEventForCharacter):
+
 2018-09-07  Frederic Wang  <fwang@igalia.com>
 
         [CSSOM View] Handle the scrollingElement in Element::scroll(Left/Top/Width/Height/To)
index 29262a4..23ee370 100644 (file)
@@ -799,7 +799,6 @@ static inline bool shouldWrapWithShiftKeyEventForCharacter(NSString *key)
     if (65 <= keyCode && keyCode <= 90)
         return true;
     switch (keyCode) {
-    case '`':
     case '!':
     case '@':
     case '#':