Diff
Modified: trunk/Source/WebKit2/ChangeLog (216069 => 216070)
--- trunk/Source/WebKit2/ChangeLog 2017-05-02 14:30:30 UTC (rev 216069)
+++ trunk/Source/WebKit2/ChangeLog 2017-05-02 14:33:57 UTC (rev 216070)
@@ -1,3 +1,23 @@
+2017-05-02 Carlos Garcia Campos <[email protected]>
+
+ Web Automation: generate resizeWindowOfBrowsingContext and moveWindowOfBrowsingContext for all platforms
+ https://bugs.webkit.org/show_bug.cgi?id=171107
+
+ Reviewed by Brian Burg.
+
+ The implementation is actually cross-platform, so it could be moved from WebAutomationSessionMac.mm to
+ WebAutomationSession.cpp and simply return a NotImplemented error for iOS. This will allow to use these methods
+ in other platforms.
+
+ * UIProcess/Automation/Automation.json:
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::resizeWindowOfBrowsingContext):
+ (WebKit::WebAutomationSession::moveWindowOfBrowsingContext):
+ * UIProcess/Automation/WebAutomationSession.h:
+ * UIProcess/Automation/mac/WebAutomationSessionMac.mm:
+ (WebKit::WebAutomationSession::resizeWindowOfBrowsingContext): Deleted.
+ (WebKit::WebAutomationSession::moveWindowOfBrowsingContext): Deleted.
+
2017-05-01 Chris Dumez <[email protected]>
Use RELEASE_LOG_ERROR() to do process termination logging
Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (216069 => 216070)
--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json 2017-05-02 14:30:30 UTC (rev 216069)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json 2017-05-02 14:33:57 UTC (rev 216070)
@@ -248,7 +248,6 @@
{
"name": "resizeWindowOfBrowsingContext",
"description": "Resizes the window of the specified browsing context to the specified size.",
- "platform": "macos",
"parameters": [
{ "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be resized." },
{ "name": "size", "$ref": "Size", "description": "The new size for the browsing context's window." }
@@ -257,7 +256,6 @@
{
"name": "moveWindowOfBrowsingContext",
"description": "Moves the window of the specified browsing context to the specified position.",
- "platform": "macos",
"parameters": [
{ "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be moved." },
{ "name": "origin", "$ref": "Point", "description": "The new origin for the browsing context's window. The position is interpreted in screen coordinate space, relative to the upper left corner of the screen." }
Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (216069 => 216070)
--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp 2017-05-02 14:30:30 UTC (rev 216069)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp 2017-05-02 14:33:57 UTC (rev 216070)
@@ -288,6 +288,88 @@
page->process().send(Messages::WebAutomationSessionProxy::FocusFrame(page->pageID(), frameID.value()), 0);
}
+void WebAutomationSession::resizeWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& sizeObject)
+{
+#if PLATFORM(IOS)
+ FAIL_WITH_PREDEFINED_ERROR(NotImplemented);
+#else
+ float width;
+ if (!sizeObject.getDouble(WTF::ASCIILiteral("width"), width))
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'width' parameter was not found or invalid.");
+
+ float height;
+ if (!sizeObject.getDouble(WTF::ASCIILiteral("height"), height))
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'height' parameter was not found or invalid.");
+
+ if (width < 0)
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'width' parameter had an invalid value.");
+
+ if (height < 0)
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'height' parameter had an invalid value.");
+
+ WebPageProxy* page = webPageProxyForHandle(handle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
+
+ WebCore::FloatRect originalFrame;
+ page->getWindowFrame(originalFrame);
+
+ WebCore::FloatRect newFrame = WebCore::FloatRect(originalFrame.location(), WebCore::FloatSize(width, height));
+ if (newFrame == originalFrame)
+ return;
+
+ page->setWindowFrame(newFrame);
+
+ // If nothing changed at all, it's probably fair to report that something went wrong.
+ // (We can't assume that the requested frame size will be honored exactly, however.)
+ WebCore::FloatRect updatedFrame;
+ page->getWindowFrame(updatedFrame);
+ if (originalFrame == updatedFrame)
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window size was expected to have changed, but did not.");
+#endif
+}
+
+void WebAutomationSession::moveWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& positionObject)
+{
+#if PLATFORM(IOS)
+ FAIL_WITH_PREDEFINED_ERROR(NotImplemented);
+#else
+ float x;
+ if (!positionObject.getDouble(WTF::ASCIILiteral("x"), x))
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'x' parameter was not found or invalid.");
+
+ float y;
+ if (!positionObject.getDouble(WTF::ASCIILiteral("y"), y))
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'y' parameter was not found or invalid.");
+
+ if (x < 0)
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'x' parameter had an invalid value.");
+
+ if (y < 0)
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'y' parameter had an invalid value.");
+
+ WebPageProxy* page = webPageProxyForHandle(handle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
+
+ WebCore::FloatRect originalFrame;
+ page->getWindowFrame(originalFrame);
+
+ WebCore::FloatRect newFrame = WebCore::FloatRect(WebCore::FloatPoint(x, y), originalFrame.size());
+ if (newFrame == originalFrame)
+ return;
+
+ page->setWindowFrame(newFrame);
+
+ // If nothing changed at all, it's probably fair to report that something went wrong.
+ // (We can't assume that the requested frame size will be honored exactly, however.)
+ WebCore::FloatRect updatedFrame;
+ page->getWindowFrame(updatedFrame);
+ if (originalFrame == updatedFrame)
+ FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window position was expected to have changed, but did not.");
+#endif
+}
+
void WebAutomationSession::navigateBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const String& url, Ref<NavigateBrowsingContextCallback>&& callback)
{
WebPageProxy* page = webPageProxyForHandle(handle);
Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (216069 => 216070)
--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h 2017-05-02 14:30:30 UTC (rev 216069)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h 2017-05-02 14:33:57 UTC (rev 216070)
@@ -109,6 +109,8 @@
void createBrowsingContext(Inspector::ErrorString&, String*) override;
void closeBrowsingContext(Inspector::ErrorString&, const String&) override;
void switchToBrowsingContext(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle) override;
+ void resizeWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& size) override;
+ void moveWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& position) override;
void navigateBrowsingContext(Inspector::ErrorString&, const String& handle, const String& url, Ref<NavigateBrowsingContextCallback>&&) override;
void goBackInBrowsingContext(Inspector::ErrorString&, const String&, Ref<GoBackInBrowsingContextCallback>&&) override;
void goForwardInBrowsingContext(Inspector::ErrorString&, const String&, Ref<GoForwardInBrowsingContextCallback>&&) override;
@@ -132,8 +134,6 @@
// Platform: macOS
#if PLATFORM(MAC)
- void resizeWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& size) override;
- void moveWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& position) override;
void inspectBrowsingContext(Inspector::ErrorString&, const String&, const bool* optionalEnableAutoCapturing, Ref<InspectBrowsingContextCallback>&&) override;
#endif
Modified: trunk/Source/WebKit2/UIProcess/Automation/mac/WebAutomationSessionMac.mm (216069 => 216070)
--- trunk/Source/WebKit2/UIProcess/Automation/mac/WebAutomationSessionMac.mm 2017-05-02 14:30:30 UTC (rev 216069)
+++ trunk/Source/WebKit2/UIProcess/Automation/mac/WebAutomationSessionMac.mm 2017-05-02 14:33:57 UTC (rev 216070)
@@ -44,80 +44,6 @@
#pragma mark Commands for Platform: 'macOS'
-void WebAutomationSession::resizeWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& sizeObject)
-{
- float width;
- if (!sizeObject.getDouble(WTF::ASCIILiteral("width"), width))
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'width' parameter was not found or invalid.");
-
- float height;
- if (!sizeObject.getDouble(WTF::ASCIILiteral("height"), height))
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'height' parameter was not found or invalid.");
-
- if (width < 0)
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'width' parameter had an invalid value.");
-
- if (height < 0)
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'height' parameter had an invalid value.");
-
- WebPageProxy* page = webPageProxyForHandle(handle);
- if (!page)
- FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
-
- WebCore::FloatRect originalFrame;
- page->getWindowFrame(originalFrame);
-
- WebCore::FloatRect newFrame = WebCore::FloatRect(originalFrame.location(), WebCore::FloatSize(width, height));
- if (newFrame == originalFrame)
- return;
-
- page->setWindowFrame(newFrame);
-
- // If nothing changed at all, it's probably fair to report that something went wrong.
- // (We can't assume that the requested frame size will be honored exactly, however.)
- WebCore::FloatRect updatedFrame;
- page->getWindowFrame(updatedFrame);
- if (originalFrame == updatedFrame)
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window size was expected to have changed, but did not.");
-}
-
-void WebAutomationSession::moveWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& positionObject)
-{
- float x;
- if (!positionObject.getDouble(WTF::ASCIILiteral("x"), x))
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'x' parameter was not found or invalid.");
-
- float y;
- if (!positionObject.getDouble(WTF::ASCIILiteral("y"), y))
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The 'y' parameter was not found or invalid.");
-
- if (x < 0)
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'x' parameter had an invalid value.");
-
- if (y < 0)
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The 'y' parameter had an invalid value.");
-
- WebPageProxy* page = webPageProxyForHandle(handle);
- if (!page)
- FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
-
- WebCore::FloatRect originalFrame;
- page->getWindowFrame(originalFrame);
-
- WebCore::FloatRect newFrame = WebCore::FloatRect(WebCore::FloatPoint(x, y), originalFrame.size());
- if (newFrame == originalFrame)
- return;
-
- page->setWindowFrame(newFrame);
-
- // If nothing changed at all, it's probably fair to report that something went wrong.
- // (We can't assume that the requested frame size will be honored exactly, however.)
- WebCore::FloatRect updatedFrame;
- page->getWindowFrame(updatedFrame);
- if (originalFrame == updatedFrame)
- FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The window position was expected to have changed, but did not.");
-}
-
void WebAutomationSession::inspectBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const bool* optionalEnableAutoCapturing, Ref<InspectBrowsingContextCallback>&& callback)
{
WebPageProxy* page = webPageProxyForHandle(handle);