RESOLVED INVALID 58048
Implement keyDown in WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=58048
Summary Implement keyDown in WebKitTestRunner
Chang Shu
Reported 2011-04-07 09:13:31 PDT
A WebProcess-only version.
Attachments
fix patch (32.99 KB, patch)
2011-04-13 09:12 PDT, Chang Shu
adele: review-
fix patch 2: fix build break (32.05 KB, patch)
2011-05-02 14:22 PDT, Chang Shu
no flags
fix patch 3 (24.82 KB, patch)
2011-05-12 08:18 PDT, Chang Shu
no flags
Chang Shu
Comment 1 2011-04-07 09:14:38 PDT
Darin, I am going to work on this. Let me know if you already have done some work. Thanks.
Darin Adler
Comment 2 2011-04-07 09:58:51 PDT
No, I didn’t do anything yet and I won’t have time to work on this for weeks, so please go for it!
Chang Shu
Comment 3 2011-04-07 14:49:18 PDT
It seems calling handleKeyEvent in WebProcess/WebPage/WebPage.cpp will cause a UIProcess crash as WebProcess is trying to send back a message while UIProcess does not expect it. We should either handle the crash on UIProcess side or suppress the sending on WebProcess side. Part of the call stack looks like this: 0 com.apple.WebKit2 0x0000000100024053 WebKit::PageClientImpl::interpretKeyEvent(WebKit::NativeWebKeyboardEvent const&, WebKit::TextInputState const&, WTF::Vector<WebCore::KeypressCommand, 0ul>&) + 11 (PageClientImpl.mm:293) 1 com.apple.WebKit2 0x00000001000cdb51 WebKit::WebPageProxy::interpretQueuedKeyEvent(WebKit::TextInputState const&, bool&, WTF::Vector<WebCore::KeypressCommand, 0ul>&) + 53 (WebPageProxyMac.mm:226) 2 com.apple.WebKit2 0x00000001000a9989 void CoreIPC::handleMessage<Messages::WebPageProxy::InterpretQueuedKeyEvent, WebKit::WebPageProxy, void (WebKit::WebPageProxy::*)(WebKit::TextInputState const&, bool&, WTF::Vector<WebCore::KeypressCommand, 0ul>&)>(CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*, WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(WebKit::TextInputState const&, bool&, WTF::Vector<WebCore::KeypressCommand, 0ul>&)) + 134 (ArgumentCoder.h:39) 3 com.apple.WebKit2 0x00000001000a6bd0 WebKit::WebPageProxy::didReceiveSyncWebPageProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*) + 1452 (WebPageProxyMessageReceiver.cpp:475) 4 com.apple.WebKit2 0x00000001000700ec WebKit::WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*) + 242 (WebProcessProxy.cpp:308) 5 com.apple.WebKit2 0x00000001000145c9 CoreIPC::Connection::dispatchSyncMessage(CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) + 149
Alexey Proskuryakov
Comment 4 2011-04-07 16:03:44 PDT
handleKeyEvent should only be called as a response to keyDown, because there needs to be a native NSEvent queued in the UI process.
Chang Shu
Comment 5 2011-04-07 16:16:07 PDT
(In reply to comment #4) > handleKeyEvent should only be called as a response to keyDown, because there needs to be a native NSEvent queued in the UI process. that's the issue we have now for the webprocess-only approach. Interestingly, it's not a problem for mouse events. Anyway, based on your comments, it seems better to fix the problem on the webprocess side, but the code would look pretty hacky.
Alexey Proskuryakov
Comment 6 2011-04-07 16:28:03 PDT
I still think that it's not very useful for eventSender to work from web process side. It's the interaction of both sides that is primarily being tested.
Darin Adler
Comment 7 2011-04-07 16:30:09 PDT
(In reply to comment #6) > I still think that it's not very useful for eventSender to work from web process side. It's the interaction of both sides that is primarily being tested. I don’t agree with your comment. I do agree that it is even better to have an eventSender that tests the entire code path including the UI process. But what is primarily being tested is lots of WebCore code that works the same way in any case. You are overstating the case when you say “the interaction of both sides” is the primary things we are testing. It would be quite helpful to have a working implementation that was web process side only even if we plan to do a UI process side implementation later.
Chang Shu
Comment 8 2011-04-08 05:58:59 PDT
The cross-process approach would be the ultimate solution but I do see the two important benefits of webprocess-only approach: simplicity and platform-independence. I would see how many tests could pass after I make it work.
Chang Shu
Comment 9 2011-04-13 09:12:37 PDT
Created attachment 89385 [details] fix patch
Build Bot
Comment 10 2011-04-13 09:48:15 PDT
Adele Peterson
Comment 11 2011-04-26 16:07:53 PDT
Comment on attachment 89385 [details] fix patch r- because the win-EWS bot says this will fail on Windows
Chang Shu
Comment 12 2011-05-02 14:22:24 PDT
Created attachment 91980 [details] fix patch 2: fix build break fix win-EWS and some code refactoring.
WebKit Review Bot
Comment 13 2011-05-02 14:24:59 PDT
Attachment 91980 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/plat..." exit_code: 1 Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2404: One line control clauses should not use braces. [whitespace/braces] [4] Total errors found: 1 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 14 2011-05-02 15:38:59 PDT
Comment on attachment 91980 [details] fix patch 2: fix build break View in context: https://bugs.webkit.org/attachment.cgi?id=91980&action=review > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2283 > +#define KEYCODE_DEL 127 > +#define KEYCODE_BACKSPACE 8 > +#define KEYCODE_LEFTARROW 0xf702 > +#define KEYCODE_RIGHTARROW 0xf703 > +#define KEYCODE_UPARROW 0xf700 > +#define KEYCODE_DOWNARROW 0xf701 Normally we’d use C++ const instead of #define for something like this. > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2285 > +WebKeyboardEvent WebPage::createWebKeyboardEventFromKeyString(WebKeyboardEvent::Type type, const String& key, WKEventModifiers modifiers, int location) I’m not sure we should really have all this code to make from a key string to a keyboard event inside this function. It seems out of place and more related to the testing machinery and perhaps should be in the test runner instead of WebKit2. Maybe this function should instead take more arguments. > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2287 > + String text, unmodifiedText, keyIdentifier; We normally declare only one function per line. > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2307 > + if (modifiers == kWKEventModifiersAltKey) > + modifiers = kWKEventModifiersControlKey; Why? > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2309 > + } else if (code == 'y' && modifiers == kWKEventModifiersControlKey) { Why is Control-Y the letter C? What is going on here? > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2310 > + text = String("c"); No need for the explicit String() here.
Alexey Proskuryakov
Comment 15 2011-05-02 16:16:34 PDT
Comment on attachment 91980 [details] fix patch 2: fix build break View in context: https://bugs.webkit.org/attachment.cgi?id=91980&action=review >> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2283 >> +#define KEYCODE_DOWNARROW 0xf701 > > Normally we’d use C++ const instead of #define for something like this. It seems unfortunate that we have to duplicate constants from Cocoa/NSEvent.h.
Chang Shu
Comment 16 2011-05-02 19:08:27 PDT
> > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2285 > > +WebKeyboardEvent WebPage::createWebKeyboardEventFromKeyString(WebKeyboardEvent::Type type, const String& key, WKEventModifiers modifiers, int location) > > I’m not sure we should really have all this code to make from a key string to a keyboard event inside this function. It seems out of place and more related to the testing machinery and perhaps should be in the test runner instead of WebKit2. Maybe this function should instead take more arguments. Good point. I will move this conversion code to WTR. > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2307 > > + if (modifiers == kWKEventModifiersAltKey) > > + modifiers = kWKEventModifiersControlKey; > > Why? > > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2309 > > + } else if (code == 'y' && modifiers == kWKEventModifiersControlKey) { > > Why is Control-Y the letter C? What is going on here? Sorry the code wasn't polished enough. They were basically copied from EventSenderQt.cpp. It seems I should make a more cross-platform version even that means I should throw away some platform-specific support.
Chang Shu
Comment 17 2011-05-04 11:41:20 PDT
(In reply to comment #16) > > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2285 > > > +WebKeyboardEvent WebPage::createWebKeyboardEventFromKeyString(WebKeyboardEvent::Type type, const String& key, WKEventModifiers modifiers, int location) > > > > I’m not sure we should really have all this code to make from a key string to a keyboard event inside this function. It seems out of place and more related to the testing machinery and perhaps should be in the test runner instead of WebKit2. Maybe this function should instead take more arguments. > > Good point. I will move this conversion code to WTR. There's some difficulty about this as constants like VK_RETURN are defined inside WebCore, which are not accessible from WTR.
Chang Shu
Comment 18 2011-05-06 07:16:11 PDT
> > > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2285 > > > > +WebKeyboardEvent WebPage::createWebKeyboardEventFromKeyString(WebKeyboardEvent::Type type, const String& key, WKEventModifiers modifiers, int location) > > > > > > I’m not sure we should really have all this code to make from a key string to a keyboard event inside this function. It seems out of place and more related to the testing machinery and perhaps should be in the test runner instead of WebKit2. Maybe this function should instead take more arguments. Does it make sense to move the function to WebKit2/InjectedBundle?
Chang Shu
Comment 19 2011-05-12 08:18:55 PDT
Created attachment 93288 [details] fix patch 3
Chang Shu
Comment 20 2011-05-24 14:58:26 PDT
Comment on attachment 93288 [details] fix patch 3 I am getting close to a more complete implementation of keydown event (bug 57515). It will most likely make this patch obsolete.
Chang Shu
Comment 21 2011-09-21 12:00:28 PDT
This bug is no longer valid.
Note You need to log in before you can comment on or make changes to this bug.