Skip to content

Commit

Permalink
pointerevent_movementxy.html?mouse WPT is failing on safaridriver aft…
Browse files Browse the repository at this point in the history
…er 265730@main

https://bugs.webkit.org/show_bug.cgi?id=260633
rdar://114350545

Reviewed by Aditya Keerthi.

The pointerevent_movementxy.html?mouse WPT was made to pass on WKTR in
265730@main, but this test continued to fail when run through the WPT +
safaridriver tooling.

It turns out that we're just never propagating the mousemove event
deltas before sending NSEvent instances in
WebAutomationSession::platformSimulateMouseInteraction. To fix this, we
make two changes:

1. Keep track of the previous mouse click by calling into
WebAutomationSession::updateClickCount().
2. Follow the precedent set by EventSenderProxy in WKTR and assign the
deltaX/Y fields of a CGEvent, finally initializing an NSEvent from it.

No new tests because we do not expect WebKit behavior to change.

* Source/WebKit/UIProcess/Automation/WebAutomationSession.h:

Provide default values to the maxTime and maxDistance arguments in
WebAutomationSession::updateClickCount(). This matches the time and
distance heuristics used in EventSenderProxy::updateClickCountForButton.

* Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm:
(WebKit::WebAutomationSession::platformSimulateMouseInteraction):

Canonical link: https://commits.webkit.org/267367@main
  • Loading branch information
aprotyas committed Aug 28, 2023
1 parent df67bee commit 7d047e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/Automation/WebAutomationSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class WebAutomationSession final : public API::ObjectImpl<API::Object::Type::Aut

// Platform-dependent implementations.
#if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS)
void updateClickCount(MouseButton, const WebCore::IntPoint&, Seconds maxTime, int maxDistance);
void updateClickCount(MouseButton, const WebCore::IntPoint&, Seconds maxTime = 1_s, int maxDistance = 0);
void resetClickCount();
void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInViewport, OptionSet<WebEventModifier>, const String& pointerType);
static OptionSet<WebEventModifier> platformWebModifiersFromRaw(unsigned modifiers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,16 @@ static WebMouseEventButton automationMouseButtonToPlatformMouseButton(MouseButto
NSInteger eventNumber = synthesizedMouseEventMagicEventNumber;

switch (interaction) {
case MouseInteraction::Move:
case MouseInteraction::Move: {
ASSERT(dragEventType);
[eventsToBeSent addObject:[NSEvent mouseEventWithType:dragEventType location:locationInWindow modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:0 pressure:0.0f]];
NSEvent *event = [NSEvent mouseEventWithType:dragEventType location:locationInWindow modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:0 pressure:0.0f];
CGEventRef cgEvent = event.CGEvent;
CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaX, locationInWindow.x() - m_lastClickPosition.x());
CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaY, -1 * (locationInWindow.y() - m_lastClickPosition.y()));
event = [NSEvent eventWithCGEvent:cgEvent];
[eventsToBeSent addObject:event];
break;
}
case MouseInteraction::Down:
ASSERT(downEventType);

Expand Down Expand Up @@ -248,6 +254,7 @@ static WebMouseEventButton automationMouseButtonToPlatformMouseButton(MouseButto
[eventsToBeSent addObject:[NSEvent mouseEventWithType:downEventType location:locationInWindow modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:2 pressure:WebCore::ForceAtClick]];
[eventsToBeSent addObject:[NSEvent mouseEventWithType:upEventType location:locationInWindow modifierFlags:modifiers timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:eventNumber clickCount:2 pressure:0.0f]];
}
updateClickCount(button, locationInWindow);

sendSynthesizedEventsToPage(page, eventsToBeSent.get());
}
Expand Down

0 comments on commit 7d047e3

Please sign in to comment.