RESOLVED FIXED104074
Web Inspector: Add command for dispatching mouse events
https://bugs.webkit.org/show_bug.cgi?id=104074
Summary Web Inspector: Add command for dispatching mouse events
Ken Kania
Reported 2012-12-04 18:00:48 PST
We'd like to be able to dispatch mouse events via the remote debugging protocol. I plan on adding a hidden Input.dispatchMouseEvent command, which just calls the EventHandler handleMouse*Event methods.
Attachments
Patch (11.15 KB, patch)
2012-12-06 15:26 PST, Ken Kania
no flags
Patch (11.14 KB, patch)
2012-12-10 10:24 PST, Ken Kania
no flags
Patch (12.75 KB, patch)
2012-12-10 12:45 PST, Ken Kania
no flags
Ken Kania
Comment 1 2012-12-06 15:26:33 PST
Yury Semikhatsky
Comment 2 2012-12-07 02:31:52 PST
Comment on attachment 178092 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=178092&action=review > Source/WebCore/inspector/Inspector.json:3291 > + { "name": "button", "type": "string", "enum": ["none", "left", "middle", "right"], "optional": true, "description": "Mouse button (default: \"none\")." }, What would be a reason for sending button=none or clickCount=0? Does it make any sense? > Source/WebCore/inspector/Inspector.json:3293 > + { "name": "x", "type": "integer", "description": "X coordinate of the event relative to the frame's viewport."}, It is always relative to the _main_ frame, the description should reflect this. Alternatively we may pass frame id to specify in which frame the event should be dispatched. > Source/WebCore/inspector/InspectorInputAgent.cpp:101 > + else if (type == "mouseReleased") I think we should teach CodeGeneratorInspector.py to generate string values for enum elements to avoid using constant values like this. But this is not directly related to this change and should be addressed separately.
Ken Kania
Comment 3 2012-12-10 10:24:52 PST
Ken Kania
Comment 4 2012-12-10 10:28:51 PST
(In reply to comment #2) > (From update of attachment 178092 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=178092&action=review > > > Source/WebCore/inspector/Inspector.json:3291 > > + { "name": "button", "type": "string", "enum": ["none", "left", "middle", "right"], "optional": true, "description": "Mouse button (default: \"none\")." }, > > What would be a reason for sending button=none or clickCount=0? Does it make any sense? > button=none and clickCount=0 make sense for mouse moves where the user isn't holding a button down. > > Source/WebCore/inspector/Inspector.json:3293 > > + { "name": "x", "type": "integer", "description": "X coordinate of the event relative to the frame's viewport."}, > > It is always relative to the _main_ frame, the description should reflect this. Alternatively we may pass frame id to specify in which frame the event should be dispatched. I think its best to always use the main frame. Clarified this for the x and y parameters. > > > Source/WebCore/inspector/InspectorInputAgent.cpp:101 > > + else if (type == "mouseReleased") > > I think we should teach CodeGeneratorInspector.py to generate string values for enum elements to avoid using constant values like this. But this is not directly related to this change and should be addressed separately.
Pavel Feldman
Comment 5 2012-12-10 10:40:32 PST
Comment on attachment 178584 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=178584&action=review > Source/WebCore/inspector/InspectorInputAgent.cpp:134 > + modifiers ? *modifiers & PlatformEvent::ShiftKey : false, you could do int convertedModifiers = modifiers ? *modifiers : 0; to improve the readability here. > LayoutTests/inspector-protocol/input/dispatchMouseEvent.html:57 > + InspectorTest.sendCommand("Input.dispatchMouseEvent", events.shift(), continueTest); As with keyboard, these will be naturally serialized, so you don't need to wait for previous command to finish in order to start the new one. You only need to wait for the last one to complete before calling completeTest()
Ken Kania
Comment 6 2012-12-10 12:45:23 PST
Ken Kania
Comment 7 2012-12-10 12:45:54 PST
(In reply to comment #5) > (From update of attachment 178584 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=178584&action=review > > > Source/WebCore/inspector/InspectorInputAgent.cpp:134 > > + modifiers ? *modifiers & PlatformEvent::ShiftKey : false, > > you could do int convertedModifiers = modifiers ? *modifiers : 0; to improve the readability here. done > > > LayoutTests/inspector-protocol/input/dispatchMouseEvent.html:57 > > + InspectorTest.sendCommand("Input.dispatchMouseEvent", events.shift(), continueTest); > > As with keyboard, these will be naturally serialized, so you don't need to wait for previous command to finish in order to start the new one. You only need to wait for the last one to complete before calling completeTest() done
WebKit Review Bot
Comment 8 2012-12-11 04:28:40 PST
Comment on attachment 178611 [details] Patch Clearing flags on attachment: 178611 Committed r137291: <http://trac.webkit.org/changeset/137291>
WebKit Review Bot
Comment 9 2012-12-11 04:28:44 PST
All reviewed patches have been landed. Closing bug.
Yury Semikhatsky
Comment 10 2012-12-14 06:42:18 PST
This patch introduced the following closure compiler error: yurys@yurys-lin:/sources/WebKit (master)$ Source/WebCore/inspector/compile-front-end.py .... ^ Source/WebCore/inspector/front-end/protocol-externs.js:2939: WARNING - optional arguments must be at the end InputAgent.dispatchMouseEvent = function(type, opt_modifiers, opt_timestamp, opt_button, opt_clickCount, x, y, opt_callback) {} ^ ... We should reorder parameters to pass required ones first.
Note You need to log in before you can comment on or make changes to this bug.