WebDriver on non-iOS ports cannot perform ActionChain which has scrolling down to...
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jun 2020 21:44:04 +0000 (21:44 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jun 2020 21:44:04 +0000 (21:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208232
<rdar://problem/59859491>

Reviewed by Devin Rousso.

Source/WebCore:

* platform/ScrollView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::rootViewToContents const):
Create a version of this function that works with FloatPoint.

Source/WebKit:

* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
(WebKit::WebAutomationSession::platformSimulateMouseInteraction):
The provided coordinates are in LayoutViewport coordinate system, which does
not take topContentInset into account. Add back in the topContentInset
when translating to flipped window coordinates.

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::computeElementLayout):
The calculations of element bounds and IVCP have an incorrect handling of
root coordinates as contents/absolute coordinates. Add the missing conversion.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262861 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm
Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp

index 82ceabd..d1e3820 100644 (file)
@@ -1,3 +1,16 @@
+2020-06-10  Brian Burg  <bburg@apple.com>
+
+        WebDriver on non-iOS ports cannot perform ActionChain which has scrolling down to the element and click it
+        https://bugs.webkit.org/show_bug.cgi?id=208232
+        <rdar://problem/59859491>
+
+        Reviewed by Devin Rousso.
+
+        * platform/ScrollView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::rootViewToContents const):
+        Create a version of this function that works with FloatPoint.
+
 2020-06-10  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, reverting r262718.
index e822d0f..6494c9f 100644 (file)
@@ -944,6 +944,11 @@ IntRect ScrollView::contentsToContainingViewContents(IntRect rect) const
     return contentsToView(rect);
 }
 
+FloatPoint ScrollView::rootViewToContents(const FloatPoint& rootViewPoint) const
+{
+    return viewToContents(convertFromRootView(rootViewPoint));
+}
+
 IntPoint ScrollView::rootViewToContents(const IntPoint& rootViewPoint) const
 {
     return viewToContents(convertFromRootView(rootViewPoint));
index e2ee613..7104153 100644 (file)
@@ -279,6 +279,7 @@ public:
     WEBCORE_EXPORT void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = false);
     bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; }
 
+    WEBCORE_EXPORT FloatPoint rootViewToContents(const FloatPoint&) const;
     WEBCORE_EXPORT IntPoint rootViewToContents(const IntPoint&) const;
     WEBCORE_EXPORT IntPoint contentsToRootView(const IntPoint&) const;
     WEBCORE_EXPORT FloatPoint contentsToRootView(const FloatPoint&) const;
index 33f5aab..50d7ade 100644 (file)
@@ -1,3 +1,22 @@
+2020-06-10  Brian Burg  <bburg@apple.com>
+
+        WebDriver on non-iOS ports cannot perform ActionChain which has scrolling down to the element and click it
+        https://bugs.webkit.org/show_bug.cgi?id=208232
+        <rdar://problem/59859491>
+
+        Reviewed by Devin Rousso.
+
+        * UIProcess/Automation/mac/WebAutomationSessionMac.mm:
+        (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
+        The provided coordinates are in LayoutViewport coordinate system, which does
+        not take topContentInset into account. Add back in the topContentInset
+        when translating to flipped window coordinates.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::computeElementLayout):
+        The calculations of element bounds and IVCP have an incorrect handling of
+        root coordinates as contents/absolute coordinates. Add the missing conversion.
+
 2020-06-10  Brent Fulgham  <bfulgham@apple.com>
 
         [iOS] Update sandbox rules for correct sanitizer paths in current OS releases
index baf8dce..3caecc3 100644 (file)
@@ -140,7 +140,7 @@ void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page,
 {
     IntRect windowRect;
 
-    IntPoint locationInView = WebCore::IntPoint(locationInViewport.x(), locationInViewport.y());
+    IntPoint locationInView = locationInViewport + IntPoint(0, page.topContentInset());
     page.rootViewToWindow(IntRect(locationInView, IntSize()), windowRect);
     IntPoint locationInWindow = windowRect.location();
 
index 0881a86..bae8e78 100644 (file)
@@ -688,7 +688,7 @@ void WebAutomationSessionProxy::computeElementLayout(WebCore::PageIdentifier pag
         resultElementBounds = enclosingIntRect(mainView->absoluteToDocumentRect(mainView->rootViewToContents(elementBoundsInRootCoordinates)));
         break;
     case CoordinateSystem::LayoutViewport:
-        resultElementBounds = enclosingIntRect(mainView->absoluteToLayoutViewportRect(elementBoundsInRootCoordinates));
+        resultElementBounds = enclosingIntRect(mainView->absoluteToLayoutViewportRect(mainView->rootViewToContents(elementBoundsInRootCoordinates)));
         break;
     }
 
@@ -742,10 +742,10 @@ void WebAutomationSessionProxy::computeElementLayout(WebCore::PageIdentifier pag
     auto inViewCenterPointInRootCoordinates = convertPointFromFrameClientToRootView(frameView, elementInViewCenterPoint);
     switch (coordinateSystem) {
     case CoordinateSystem::Page:
-        resultInViewCenterPoint = roundedIntPoint(mainView->absoluteToDocumentPoint(inViewCenterPointInRootCoordinates));
+        resultInViewCenterPoint = roundedIntPoint(mainView->absoluteToDocumentPoint(mainView->rootViewToContents(inViewCenterPointInRootCoordinates)));
         break;
     case CoordinateSystem::LayoutViewport:
-        resultInViewCenterPoint = roundedIntPoint(mainView->absoluteToLayoutViewportPoint(inViewCenterPointInRootCoordinates));
+        resultInViewCenterPoint = roundedIntPoint(mainView->absoluteToLayoutViewportPoint(mainView->rootViewToContents(inViewCenterPointInRootCoordinates)));
         break;
     }