Diff
Modified: trunk/Source/WebKit/ChangeLog (248714 => 248715)
--- trunk/Source/WebKit/ChangeLog 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/ChangeLog 2019-08-15 16:02:26 UTC (rev 248715)
@@ -1,3 +1,42 @@
+2019-08-14 Brian Burg <bb...@apple.com>
+
+ 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.
+
2019-08-15 Simon Fraser <simon.fra...@apple.com>
Use ObjectIdentifier<FrameIdentifierType> for frameIDs
Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp (248714 => 248715)
--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp 2019-08-15 16:02:26 UTC (rev 248715)
@@ -296,7 +296,7 @@
} else if (a.location != b.location) {
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);
// FIXME: This does not interpolate mousemoves per the "perform a pointer move" algorithm (ยง17.4 Dispatching Actions).
- m_client.simulateMouseInteraction(m_page, MouseInteraction::Move, b.pressedMouseButton.valueOr(MouseButton::NoButton), b.location.value(), WTFMove(eventDispatchFinished));
+ m_client.simulateMouseInteraction(m_page, MouseInteraction::Move, b.pressedMouseButton.valueOr(MouseButton::None), b.location.value(), WTFMove(eventDispatchFinished));
} else
eventDispatchFinished(WTF::nullopt);
});
@@ -401,7 +401,7 @@
m_keyframes.append(SimulatedInputKeyFrame::keyFrameFromStateOfInputSources(m_inputSources));
m_keyframes.appendVector(WTFMove(keyFrames));
- LOG(Automation, "SimulatedInputDispatcher[%p]: starting input simulation using %d keyframes", this, m_keyframeIndex);
+ LOG(Automation, "SimulatedInputDispatcher[%p]: starting input simulation using %zu keyframes", this, m_keyframes.size());
transitionToNextKeyFrame();
}
Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h (248714 => 248715)
--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h 2019-08-15 16:02:26 UTC (rev 248715)
@@ -41,6 +41,7 @@
namespace Inspector { namespace Protocol { namespace Automation {
enum class ErrorMessage;
enum class KeyboardInteractionType;
+enum class MouseButton;
enum class MouseInteraction;
enum class MouseMoveOrigin;
enum class VirtualKey;
@@ -57,7 +58,7 @@
using VirtualKey = Inspector::Protocol::Automation::VirtualKey;
using VirtualKeySet = HashSet<VirtualKey, WTF::IntHash<VirtualKey>, WTF::StrongEnumHashTraits<VirtualKey>>;
using CharKey = char; // For WebDriver, this only needs to support ASCII characters on 102-key keyboard.
-using MouseButton = WebMouseEvent::Button;
+using MouseButton = Inspector::Protocol::Automation::MouseButton;
using MouseInteraction = Inspector::Protocol::Automation::MouseInteraction;
using MouseMoveOrigin = Inspector::Protocol::Automation::MouseMoveOrigin;
@@ -125,7 +126,7 @@
public:
virtual ~Client() { }
#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
- virtual void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) = 0;
+ virtual void simulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) = 0;
#endif
#if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
virtual void simulateTouchInteraction(WebPageProxy&, TouchInteraction, const WebCore::IntPoint& locationInView, Optional<Seconds> duration, AutomationCompletionHandler&&) = 0;
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (248714 => 248715)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2019-08-15 16:02:26 UTC (rev 248715)
@@ -1482,7 +1482,8 @@
}
#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
-void WebAutomationSession::simulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button mouseButton, const WebCore::IntPoint& locationInViewport, CompletionHandler<void(Optional<AutomationCommandError>)>&& completionHandler)
+
+void WebAutomationSession::simulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton mouseButton, const WebCore::IntPoint& locationInViewport, CompletionHandler<void(Optional<AutomationCommandError>)>&& completionHandler)
{
page.getWindowFrameWithCallback([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler), page = makeRef(page), interaction, mouseButton, locationInViewport](WebCore::FloatRect windowFrame) mutable {
auto clippedX = std::min(std::max(0.0f, (float)locationInViewport.x()), windowFrame.size().width());
@@ -1581,24 +1582,6 @@
}
#endif // ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
-#if ENABLE(WEBDRIVER_ACTIONS_API)
-static WebMouseEvent::Button protocolMouseButtonToWebMouseEventButton(Inspector::Protocol::Automation::MouseButton button)
-{
- switch (button) {
- case Inspector::Protocol::Automation::MouseButton::None:
- return WebMouseEvent::NoButton;
- case Inspector::Protocol::Automation::MouseButton::Left:
- return WebMouseEvent::LeftButton;
- case Inspector::Protocol::Automation::MouseButton::Middle:
- return WebMouseEvent::MiddleButton;
- case Inspector::Protocol::Automation::MouseButton::Right:
- return WebMouseEvent::RightButton;
- }
-
- RELEASE_ASSERT_NOT_REACHED();
-}
-#endif // ENABLE(WEBDRIVER_ACTIONS_API)
-
void WebAutomationSession::performMouseInteraction(const String& handle, const JSON::Object& requestedPositionObject, const String& mouseButtonString, const String& mouseInteractionString, const JSON::Array& keyModifierStrings, Ref<PerformMouseInteractionCallback>&& callback)
{
#if !ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
@@ -1659,7 +1642,7 @@
callbackInMap(AUTOMATION_COMMAND_ERROR_WITH_NAME(Timeout));
callbackInMap = WTFMove(mouseEventsFlushedCallback);
- platformSimulateMouseInteraction(page, parsedInteraction.value(), protocolMouseButtonToWebMouseEventButton(parsedButton.value()), locationInViewport, keyModifiers);
+ platformSimulateMouseInteraction(page, parsedInteraction.value(), parsedButton.value(), locationInViewport, keyModifiers);
// If the event location was previously clipped and does not hit test anything in the window, then it will not be processed.
// For compatibility with pre-W3C driver implementations, don't make this a hard error; just do nothing silently.
@@ -1901,7 +1884,7 @@
String pressedButtonString;
if (stateObject->getString("pressedButton"_s, pressedButtonString)) {
auto protocolButton = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(pressedButtonString);
- sourceState.pressedMouseButton = protocolMouseButtonToWebMouseEventButton(protocolButton.valueOr(Inspector::Protocol::Automation::MouseButton::None));
+ sourceState.pressedMouseButton = protocolButton.valueOr(MouseButton::None);
}
String originString;
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h (248714 => 248715)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2019-08-15 16:02:26 UTC (rev 248715)
@@ -145,7 +145,7 @@
// SimulatedInputDispatcher::Client API
#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
- void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) final;
+ void simulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) final;
#endif
#if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
void simulateTouchInteraction(WebPageProxy&, TouchInteraction, const WebCore::IntPoint& locationInView, Optional<Seconds> duration, AutomationCompletionHandler&&) final;
@@ -245,7 +245,7 @@
// Platform-dependent implementations.
#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
- void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier>);
+ void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier>);
#endif
#if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
// Simulates a single touch point being pressed, moved, and released.
Modified: trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp (248714 => 248715)
--- trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp 2019-08-15 16:02:26 UTC (rev 248715)
@@ -48,15 +48,15 @@
return state;
}
-static unsigned mouseButtonToGdkButton(WebMouseEvent::Button button)
+static unsigned mouseButtonToGdkButton(MouseButton button)
{
switch (button) {
- case WebMouseEvent::NoButton:
- case WebMouseEvent::LeftButton:
+ case MouseButton::None:
+ case MouseButton::Left:
return GDK_BUTTON_PRIMARY;
- case WebMouseEvent::MiddleButton:
+ case MouseButton::Middle:
return GDK_BUTTON_MIDDLE;
- case WebMouseEvent::RightButton:
+ case MouseButton::Right:
return GDK_BUTTON_SECONDARY;
}
return GDK_BUTTON_PRIMARY;
@@ -101,7 +101,7 @@
gtk_main_do_event(event.get());
}
-void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
+void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
{
unsigned gdkButton = mouseButtonToGdkButton(button);
auto modifier = stateModifierForGdkButton(gdkButton);
Modified: trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm (248714 => 248715)
--- trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm 2019-08-15 16:02:26 UTC (rev 248715)
@@ -121,9 +121,22 @@
#pragma mark Platform-dependent Implementations
#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
-void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier> keyModifiers)
+
+static WebMouseEvent::Button automationMouseButtonToPlatformMouseButton(MouseButton button)
{
+ switch (button) {
+ case MouseButton::Left: return WebMouseEvent::LeftButton;
+ case MouseButton::Middle: return WebMouseEvent::MiddleButton;
+ case MouseButton::Right: return WebMouseEvent::RightButton;
+ case MouseButton::None: return WebMouseEvent::NoButton;
+ default: ASSERT_NOT_REACHED();
+ }
+}
+
+void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier> keyModifiers)
+{
IntRect windowRect;
+
IntPoint locationInView = WebCore::IntPoint(locationInViewport.x(), locationInViewport.y() + page.topContentInset());
page.rootViewToWindow(IntRect(locationInView, IntSize()), windowRect);
IntPoint locationInWindow = windowRect.location();
@@ -147,7 +160,7 @@
NSEventType downEventType = (NSEventType)0;
NSEventType dragEventType = (NSEventType)0;
NSEventType upEventType = (NSEventType)0;
- switch (button) {
+ switch (automationMouseButtonToPlatformMouseButton(button)) {
case WebMouseEvent::NoButton:
downEventType = upEventType = dragEventType = NSEventTypeMouseMoved;
break;
Modified: trunk/Source/WebKit/UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp (248714 => 248715)
--- trunk/Source/WebKit/UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp 2019-08-15 15:56:52 UTC (rev 248714)
+++ trunk/Source/WebKit/UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp 2019-08-15 16:02:26 UTC (rev 248715)
@@ -44,15 +44,15 @@
return state;
}
-static unsigned mouseButtonToWPEButton(WebMouseEvent::Button button)
+static unsigned mouseButtonToWPEButton(MouseButton button)
{
switch (button) {
- case WebMouseEvent::NoButton:
- case WebMouseEvent::LeftButton:
+ case MouseButton::None:
+ case MouseButton::Left:
return 1;
- case WebMouseEvent::MiddleButton:
+ case MouseButton::Middle:
return 3;
- case WebMouseEvent::RightButton:
+ case MouseButton::Right:
return 2;
}
return 1;
@@ -91,7 +91,7 @@
wpe_view_backend_dispatch_pointer_event(viewBackend, &event);
}
-void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
+void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)
{
unsigned wpeButton = mouseButtonToWPEButton(button);
auto modifier = stateModifierForWPEButton(wpeButton);