Changeset 248715 in webkit


Ignore:
Timestamp:
Aug 15, 2019 9:02:26 AM (5 years ago)
Author:
BJ Burg
Message:

Web Automation: mouse buttons are not correctly printed in SimulatedInputDispatcher log spew
https://bugs.webkit.org/show_bug.cgi?id=200729

Reviewed by Devin Rousso.

This was printing out gibberish because it was trying to decode a WebMouseEvent button
as an Automation protocol button. The logging was less useful because of it.

To fix this, push usage of Automation protocol-based MouseButton type alias all the way
to the platform-specific methods. The mouse buttons are the same for WebMouseEvent::Button
and the Automation protocol type, except the automation type has an auto-generated toString.

  • UIProcess/Automation/SimulatedInputDispatcher.h:
  • UIProcess/Automation/SimulatedInputDispatcher.cpp:

(WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
(WebKit::SimulatedInputDispatcher::run):
Fix types.

  • UIProcess/Automation/WebAutomationSession.h:
  • UIProcess/Automation/WebAutomationSession.cpp:

(WebKit::WebAutomationSession::simulateMouseInteraction):
(WebKit::WebAutomationSession::performMouseInteraction):
(WebKit::WebAutomationSession::performInteractionSequence):
(WebKit::protocolMouseButtonToWebMouseEventButton): Deleted.
Fix types.

  • UIProcess/Automation/mac/WebAutomationSessionMac.mm:

(WebKit::automationMouseButtonToPlatformMouseButton):
(WebKit::WebAutomationSession::platformSimulateMouseInteraction):

  • UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:

(WebKit::mouseButtonToGdkButton):
(WebKit::WebAutomationSession::platformSimulateMouseInteraction):

  • UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp:

(WebKit::mouseButtonToWPEButton):
(WebKit::WebAutomationSession::platformSimulateMouseInteraction):
Move translation between MouseButton and native button values to platform methods.

Location:
trunk/Source/WebKit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r248713 r248715  
     12019-08-14  Brian Burg  <bburg@apple.com>
     2
     3        Web Automation: mouse buttons are not correctly printed in SimulatedInputDispatcher log spew
     4        https://bugs.webkit.org/show_bug.cgi?id=200729
     5
     6        Reviewed by Devin Rousso.
     7
     8        This was printing out gibberish because it was trying to decode a WebMouseEvent button
     9        as an Automation protocol button. The logging was less useful because of it.
     10
     11        To fix this, push usage of Automation protocol-based MouseButton type alias all the way
     12        to the platform-specific methods. The mouse buttons are the same for WebMouseEvent::Button
     13        and the Automation protocol type, except the automation type has an auto-generated toString.
     14
     15        * UIProcess/Automation/SimulatedInputDispatcher.h:
     16        * UIProcess/Automation/SimulatedInputDispatcher.cpp:
     17        (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
     18        (WebKit::SimulatedInputDispatcher::run):
     19        Fix types.
     20
     21        * UIProcess/Automation/WebAutomationSession.h:
     22        * UIProcess/Automation/WebAutomationSession.cpp:
     23        (WebKit::WebAutomationSession::simulateMouseInteraction):
     24        (WebKit::WebAutomationSession::performMouseInteraction):
     25        (WebKit::WebAutomationSession::performInteractionSequence):
     26        (WebKit::protocolMouseButtonToWebMouseEventButton): Deleted.
     27        Fix types.
     28
     29        * UIProcess/Automation/mac/WebAutomationSessionMac.mm:
     30        (WebKit::automationMouseButtonToPlatformMouseButton):
     31        (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
     32        * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
     33        (WebKit::mouseButtonToGdkButton):
     34        (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
     35        * UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp:
     36        (WebKit::mouseButtonToWPEButton):
     37        (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
     38        Move translation between MouseButton and native button values to platform methods.
     39
    1402019-08-15  Simon Fraser  <simon.fraser@apple.com>
    241
  • trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp

    r248713 r248715  
    297297                LOG(Automation, "SimulatedInputDispatcher[%p]: simulating MouseMove from (%d, %d) to (%d, %d) for transition to %d.%d", this, a.location.value().x(), a.location.value().y(), b.location.value().x(), b.location.value().y(), m_keyframeIndex, m_inputSourceStateIndex);
    298298                // FIXME: This does not interpolate mousemoves per the "perform a pointer move" algorithm (§17.4 Dispatching Actions).
    299                 m_client.simulateMouseInteraction(m_page, MouseInteraction::Move, b.pressedMouseButton.valueOr(MouseButton::NoButton), b.location.value(), WTFMove(eventDispatchFinished));
     299                m_client.simulateMouseInteraction(m_page, MouseInteraction::Move, b.pressedMouseButton.valueOr(MouseButton::None), b.location.value(), WTFMove(eventDispatchFinished));
    300300            } else
    301301                eventDispatchFinished(WTF::nullopt);
     
    402402    m_keyframes.appendVector(WTFMove(keyFrames));
    403403
    404     LOG(Automation, "SimulatedInputDispatcher[%p]: starting input simulation using %d keyframes", this, m_keyframeIndex);
     404    LOG(Automation, "SimulatedInputDispatcher[%p]: starting input simulation using %zu keyframes", this, m_keyframes.size());
    405405
    406406    transitionToNextKeyFrame();
  • trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h

    r248713 r248715  
    4242enum class ErrorMessage;
    4343enum class KeyboardInteractionType;
     44enum class MouseButton;
    4445enum class MouseInteraction;
    4546enum class MouseMoveOrigin;
     
    5859using VirtualKeySet = HashSet<VirtualKey, WTF::IntHash<VirtualKey>, WTF::StrongEnumHashTraits<VirtualKey>>;
    5960using CharKey = char; // For WebDriver, this only needs to support ASCII characters on 102-key keyboard.
    60 using MouseButton = WebMouseEvent::Button;
     61using MouseButton = Inspector::Protocol::Automation::MouseButton;
    6162using MouseInteraction = Inspector::Protocol::Automation::MouseInteraction;
    6263using MouseMoveOrigin = Inspector::Protocol::Automation::MouseMoveOrigin;
     
    126127        virtual ~Client() { }
    127128#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
    128         virtual void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) = 0;
     129        virtual void simulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) = 0;
    129130#endif
    130131#if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r248713 r248715  
    14831483
    14841484#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
    1485 void WebAutomationSession::simulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button mouseButton, const WebCore::IntPoint& locationInViewport, CompletionHandler<void(Optional<AutomationCommandError>)>&& completionHandler)
     1485
     1486void WebAutomationSession::simulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton mouseButton, const WebCore::IntPoint& locationInViewport, CompletionHandler<void(Optional<AutomationCommandError>)>&& completionHandler)
    14861487{
    14871488    page.getWindowFrameWithCallback([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler), page = makeRef(page), interaction, mouseButton, locationInViewport](WebCore::FloatRect windowFrame) mutable {
     
    15821583#endif // ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
    15831584
    1584 #if ENABLE(WEBDRIVER_ACTIONS_API)
    1585 static WebMouseEvent::Button protocolMouseButtonToWebMouseEventButton(Inspector::Protocol::Automation::MouseButton button)
    1586 {
    1587     switch (button) {
    1588     case Inspector::Protocol::Automation::MouseButton::None:
    1589         return WebMouseEvent::NoButton;
    1590     case Inspector::Protocol::Automation::MouseButton::Left:
    1591         return WebMouseEvent::LeftButton;
    1592     case Inspector::Protocol::Automation::MouseButton::Middle:
    1593         return WebMouseEvent::MiddleButton;
    1594     case Inspector::Protocol::Automation::MouseButton::Right:
    1595         return WebMouseEvent::RightButton;
    1596     }
    1597 
    1598     RELEASE_ASSERT_NOT_REACHED();
    1599 }
    1600 #endif // ENABLE(WEBDRIVER_ACTIONS_API)
    1601 
    16021585void WebAutomationSession::performMouseInteraction(const String& handle, const JSON::Object& requestedPositionObject, const String& mouseButtonString, const String& mouseInteractionString, const JSON::Array& keyModifierStrings, Ref<PerformMouseInteractionCallback>&& callback)
    16031586{
     
    16601643        callbackInMap = WTFMove(mouseEventsFlushedCallback);
    16611644
    1662         platformSimulateMouseInteraction(page, parsedInteraction.value(), protocolMouseButtonToWebMouseEventButton(parsedButton.value()), locationInViewport, keyModifiers);
     1645        platformSimulateMouseInteraction(page, parsedInteraction.value(), parsedButton.value(), locationInViewport, keyModifiers);
    16631646
    16641647        // If the event location was previously clipped and does not hit test anything in the window, then it will not be processed.
     
    19021885            if (stateObject->getString("pressedButton"_s, pressedButtonString)) {
    19031886                auto protocolButton = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(pressedButtonString);
    1904                 sourceState.pressedMouseButton = protocolMouseButtonToWebMouseEventButton(protocolButton.valueOr(Inspector::Protocol::Automation::MouseButton::None));
     1887                sourceState.pressedMouseButton = protocolButton.valueOr(MouseButton::None);
    19051888            }
    19061889
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h

    r248713 r248715  
    146146    // SimulatedInputDispatcher::Client API
    147147#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
    148     void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) final;
     148    void simulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) final;
    149149#endif
    150150#if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
     
    246246    // Platform-dependent implementations.
    247247#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
    248     void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier>);
     248    void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier>);
    249249#endif
    250250#if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
  • trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp

    r246677 r248715  
    4949}
    5050
    51 static unsigned mouseButtonToGdkButton(WebMouseEvent::Button button)
     51static unsigned mouseButtonToGdkButton(MouseButton button)
    5252{
    5353    switch (button) {
    54     case WebMouseEvent::NoButton:
    55     case WebMouseEvent::LeftButton:
     54    case MouseButton::None:
     55    case MouseButton::Left:
    5656        return GDK_BUTTON_PRIMARY;
    57     case WebMouseEvent::MiddleButton:
     57    case MouseButton::Middle:
    5858        return GDK_BUTTON_MIDDLE;
    59     case WebMouseEvent::RightButton:
     59    case MouseButton::Right:
    6060        return GDK_BUTTON_SECONDARY;
    6161    }
     
    102102}
    103103
    104 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
     104void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
    105105{
    106106    unsigned gdkButton = mouseButtonToGdkButton(button);
  • trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm

    r248696 r248715  
    122122
    123123#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
    124 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier> keyModifiers)
     124
     125static WebMouseEvent::Button automationMouseButtonToPlatformMouseButton(MouseButton button)
     126{
     127    switch (button) {
     128    case MouseButton::Left:   return WebMouseEvent::LeftButton;
     129    case MouseButton::Middle: return WebMouseEvent::MiddleButton;
     130    case MouseButton::Right:  return WebMouseEvent::RightButton;
     131    case MouseButton::None:   return WebMouseEvent::NoButton;
     132    default: ASSERT_NOT_REACHED();
     133    }
     134}
     135
     136void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier> keyModifiers)
    125137{
    126138    IntRect windowRect;
     139
    127140    IntPoint locationInView = WebCore::IntPoint(locationInViewport.x(), locationInViewport.y() + page.topContentInset());
    128141    page.rootViewToWindow(IntRect(locationInView, IntSize()), windowRect);
     
    148161    NSEventType dragEventType = (NSEventType)0;
    149162    NSEventType upEventType = (NSEventType)0;
    150     switch (button) {
     163    switch (automationMouseButtonToPlatformMouseButton(button)) {
    151164    case WebMouseEvent::NoButton:
    152165        downEventType = upEventType = dragEventType = NSEventTypeMouseMoved;
  • trunk/Source/WebKit/UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp

    r241000 r248715  
    4545}
    4646
    47 static unsigned mouseButtonToWPEButton(WebMouseEvent::Button button)
     47static unsigned mouseButtonToWPEButton(MouseButton button)
    4848{
    4949    switch (button) {
    50     case WebMouseEvent::NoButton:
    51     case WebMouseEvent::LeftButton:
     50    case MouseButton::None:
     51    case MouseButton::Left:
    5252        return 1;
    53     case WebMouseEvent::MiddleButton:
     53    case MouseButton::Middle:
    5454        return 3;
    55     case WebMouseEvent::RightButton:
     55    case MouseButton::Right:
    5656        return 2;
    5757    }
     
    9292}
    9393
    94 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
     94void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
    9595{
    9696    unsigned wpeButton = mouseButtonToWPEButton(button);
Note: See TracChangeset for help on using the changeset viewer.