Implement keyboard event sending for iOS in WebKitTestRunner
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Oct 2015 14:28:38 +0000 (14:28 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Oct 2015 14:28:38 +0000 (14:28 +0000)
commit3f1bdbe2e7f8265826c360e99e443ec7b630d2aa
tree3af42a8429c66ff7488f97b9673e73f93426bd98
parent626b9e9480294afc1b687b59f1d1058af7370e33
Implement keyboard event sending for iOS in WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=149676

Reviewed by Simon Fraser.

Tools:

Adds support for generating and sending key events in WebKitTestRunner. This is accomplished in a similar
way as touch events, using IOHIDEvent machinery. Also adds callbacks to the UIScriptController JS API that
allows us to run code when the keyboard is shown or hidden.

* WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl: Adds the typeCharacter JS interface.
* WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::setDidShowKeyboardCallback):
(WTR::UIScriptController::didShowKeyboardCallback):
(WTR::UIScriptController::setDidHideKeyboardCallback):
(WTR::UIScriptController::didHideKeyboardCallback):
(WTR::UIScriptController::typeCharacterUsingHardwareKeyboard):
(WTR::UIScriptController::platformSetDidShowKeyboardCallback):
(WTR::UIScriptController::platformSetDidHideKeyboardCallback):
* WebKitTestRunner/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView initWithFrame:configuration:]): Registers the TestRunnerWKWebView to listen to
        the notifications that the keyboard has been raised or lowered.
(-[TestRunnerWKWebView _keyboardDidShow:]):
(-[TestRunnerWKWebView _keyboardDidHide:]):
* WebKitTestRunner/ios/HIDEventGenerator.h:
* WebKitTestRunner/ios/HIDEventGenerator.m:
(-[HIDEventGenerator _sendIOHIDKeyboardEvent:usage:isKeyDown:]): Helper to send a HID keyboard event.
(shouldWrapWithShiftKeyEventForCharacter): Helper used to generate key events.
(hidUsageCodeForCharacter): Ditto.
(-[HIDEventGenerator keyDown:completionBlock:]): Synthesizes and sends HIDKeyboardEvents, triggering
        a keyDown event in WebKit.
* WebKitTestRunner/ios/IOKitSPI.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:

LayoutTests:

Adds a new basic test for the oninput event listener when typing in a text field.

* fast/events/ios/input-value-after-oninput-expected.txt: Added.
* fast/events/ios/input-value-after-oninput.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190407 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/ios/input-value-after-oninput-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/input-value-after-oninput.html [new file with mode: 0644]
Tools/ChangeLog
Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl
Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp
Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h
Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm
Tools/WebKitTestRunner/ios/HIDEventGenerator.h
Tools/WebKitTestRunner/ios/HIDEventGenerator.mm
Tools/WebKitTestRunner/ios/IOKitSPI.h
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm