Diff
Modified: trunk/Source/WebDriver/ChangeLog (225500 => 225501)
--- trunk/Source/WebDriver/ChangeLog 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebDriver/ChangeLog 2017-12-05 00:06:25 UTC (rev 225501)
@@ -1,3 +1,17 @@
+2017-12-04 Brian Burg <[email protected]>
+
+ Web Automation: add flag to preserve legacy page screenshot behavior
+ https://bugs.webkit.org/show_bug.cgi?id=180313
+ <rdar://problem/34379930>
+
+ Reviewed by Joseph Pecoraro.
+
+ Set the clipToViewport flag to true when sending Automation.takeScreenshot.
+ This preserves the current behavior for this driver implementation.
+
+ * Session.cpp:
+ (WebDriver::Session::takeScreenshot):
+
2017-12-04 Carlos Garcia Campos <[email protected]>
WebDriver: implement element property command
Modified: trunk/Source/WebDriver/Session.cpp (225500 => 225501)
--- trunk/Source/WebDriver/Session.cpp 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebDriver/Session.cpp 2017-12-05 00:06:25 UTC (rev 225501)
@@ -2123,6 +2123,8 @@
parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
if (elementID)
parameters->setString(ASCIILiteral("nodeHandle"), elementID.value());
+ else
+ parameters->setBoolean(ASCIILiteral("clipToViewport"), true);
if (scrollIntoView.value_or(false))
parameters->setBoolean(ASCIILiteral("scrollIntoViewIfNeeded"), true);
m_host->sendCommandToBackend(ASCIILiteral("takeScreenshot"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) mutable {
Modified: trunk/Source/WebKit/ChangeLog (225500 => 225501)
--- trunk/Source/WebKit/ChangeLog 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebKit/ChangeLog 2017-12-05 00:06:25 UTC (rev 225501)
@@ -1,3 +1,27 @@
+2017-12-04 Brian Burg <[email protected]>
+
+ Web Automation: add flag to preserve legacy page screenshot behavior
+ https://bugs.webkit.org/show_bug.cgi?id=180313
+ <rdar://problem/34379930>
+
+ Reviewed by Joseph Pecoraro.
+
+ For compatibility with JSON Wire Protocol implemented by Safari,
+ we need to retain the ability to perform whole page contents
+ snapshots using Automation.takeScreenshot. Add an extra flag,
+ clipToViewport, which can be used by W3C-conforming drivers.
+
+ * UIProcess/Automation/Automation.json: Add new flag.
+ * UIProcess/Automation/WebAutomationSession.h:
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::takeScreenshot):
+ * WebProcess/Automation/WebAutomationSessionProxy.h:
+ * WebProcess/Automation/WebAutomationSessionProxy.messages.in:
+ * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+ (WebKit::snapshotRectForScreenshot):
+ (WebKit::WebAutomationSessionProxy::takeScreenshot):
+ If the flag is false, take a screenshot of the whole page contents.
+
2017-12-04 JF Bastien <[email protected]>
Update std::expected to match libc++ coding style
Modified: trunk/Source/WebKit/UIProcess/Automation/Automation.json (225500 => 225501)
--- trunk/Source/WebKit/UIProcess/Automation/Automation.json 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebKit/UIProcess/Automation/Automation.json 2017-12-05 00:06:25 UTC (rev 225501)
@@ -415,7 +415,8 @@
{ "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to take a screenshot of." },
{ "name": "frameHandle", "$ref": "FrameHandle", "optional": true, "description": "The handle for the frame that contains the element. The main frame is used if this parameter is empty string or excluded." },
{ "name": "nodeHandle", "$ref": "NodeHandle", "optional": true, "description": "The handle of the element to take a screenshot of. The browsing context document element is used if this parameter is excluded." },
- { "name": "scrollIntoViewIfNeeded", "type": "boolean", "optional": true, "description": "If the element should be scrolled into view before taking the screenshot." }
+ { "name": "scrollIntoViewIfNeeded", "type": "boolean", "optional": true, "description": "If the element should be scrolled into view before taking the screenshot." },
+ { "name": "clipToViewport", "type": "boolean", "optional": true, "description": "Whether a screenshot of the entire page should be clipped to the visual viewport. A value of 'false' preserves behavior for legacy protocol screenshots." }
],
"returns": [
{ "name": "data", "type": "string", "description": "Base64-encoded image data (PNG)." }
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (225500 => 225501)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2017-12-05 00:06:25 UTC (rev 225501)
@@ -1449,7 +1449,7 @@
#endif // PLATFORM(COCOA) || PLATFORM(GTK)
}
-void WebAutomationSession::takeScreenshot(ErrorString& errorString, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, Ref<TakeScreenshotCallback>&& callback)
+void WebAutomationSession::takeScreenshot(ErrorString& errorString, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* optionalClipToViewport, Ref<TakeScreenshotCallback>&& callback)
{
WebPageProxy* page = webPageProxyForHandle(handle);
if (!page)
@@ -1461,11 +1461,12 @@
bool scrollIntoViewIfNeeded = optionalScrollIntoViewIfNeeded ? *optionalScrollIntoViewIfNeeded : false;
String nodeHandle = optionalNodeHandle ? *optionalNodeHandle : emptyString();
+ bool clipToViewport = optionalClipToViewport ? *optionalClipToViewport : false;
uint64_t callbackID = m_nextScreenshotCallbackID++;
m_screenshotCallbacks.set(callbackID, WTFMove(callback));
- page->process().send(Messages::WebAutomationSessionProxy::TakeScreenshot(page->pageID(), frameID.value(), nodeHandle, scrollIntoViewIfNeeded, callbackID), 0);
+ page->process().send(Messages::WebAutomationSessionProxy::TakeScreenshot(page->pageID(), frameID.value(), nodeHandle, scrollIntoViewIfNeeded, clipToViewport, callbackID), 0);
}
void WebAutomationSession::didTakeScreenshot(uint64_t callbackID, const ShareableBitmap::Handle& imageDataHandle, const String& errorType)
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h (225500 => 225501)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2017-12-05 00:06:25 UTC (rev 225501)
@@ -132,7 +132,7 @@
void evaluateJavaScriptFunction(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const JSON::Array& arguments, const bool* optionalExpectsImplicitCallbackArgument, const int* optionalCallbackTimeout, Ref<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>&&) override;
void performMouseInteraction(Inspector::ErrorString&, const String& handle, const JSON::Object& requestedPosition, const String& mouseButton, const String& mouseInteraction, const JSON::Array& keyModifiers, Ref<PerformMouseInteractionCallback>&&) final;
void performKeyboardInteractions(Inspector::ErrorString&, const String& handle, const JSON::Array& interactions, Ref<PerformKeyboardInteractionsCallback>&&) override;
- void takeScreenshot(Inspector::ErrorString&, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, Ref<TakeScreenshotCallback>&&) override;
+ void takeScreenshot(Inspector::ErrorString&, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* optionalClipToViewport, Ref<TakeScreenshotCallback>&&) override;
void resolveChildFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const int* optionalOrdinal, const String* optionalName, const String* optionalNodeHandle, Ref<ResolveChildFrameHandleCallback>&&) override;
void resolveParentFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, Ref<ResolveParentFrameHandleCallback>&&) override;
void computeElementLayout(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, const String& nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const String& coordinateSystem, Ref<Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback>&&) override;
Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (225500 => 225501)
--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp 2017-12-05 00:06:25 UTC (rev 225501)
@@ -662,7 +662,7 @@
WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidSelectOptionElement(callbackID, { }), 0);
}
-static WebCore::IntRect snapshotRectForScreenshot(WebPage& page, WebCore::Element* element)
+static WebCore::IntRect snapshotRectForScreenshot(WebPage& page, WebCore::Element* element, bool clipToViewport)
{
if (element) {
if (!element->renderer())
@@ -673,12 +673,12 @@
}
if (auto* frameView = page.mainFrameView())
- return frameView->visibleContentRect();
+ return clipToViewport ? frameView->visibleContentRect() : WebCore::IntRect(WebCore::IntPoint(0, 0), frameView->contentsSize());
return { };
}
-void WebAutomationSessionProxy::takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, uint64_t callbackID)
+void WebAutomationSessionProxy::takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool clipToViewport, uint64_t callbackID)
{
ShareableBitmap::Handle handle;
@@ -707,7 +707,7 @@
}
String screenshotErrorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::ScreenshotError);
- WebCore::IntRect snapshotRect = snapshotRectForScreenshot(*page, coreElement);
+ WebCore::IntRect snapshotRect = snapshotRectForScreenshot(*page, coreElement, clipToViewport);
if (snapshotRect.isEmpty()) {
WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidTakeScreenshot(callbackID, handle, screenshotErrorType), 0);
return;
Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h (225500 => 225501)
--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h 2017-12-05 00:06:25 UTC (rev 225501)
@@ -66,7 +66,7 @@
void focusFrame(uint64_t pageID, uint64_t frameID);
void computeElementLayout(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, CoordinateSystem, uint64_t callbackID);
void selectOptionElement(uint64_t pageID, uint64_t frameID, String nodeHandle, uint64_t callbackID);
- void takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, uint64_t callbackID);
+ void takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool clipToViewport, uint64_t callbackID);
void getCookiesForFrame(uint64_t pageID, uint64_t frameID, uint64_t callbackID);
void deleteCookie(uint64_t pageID, uint64_t frameID, String cookieName, uint64_t callbackID);
Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.messages.in (225500 => 225501)
--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.messages.in 2017-12-05 00:03:38 UTC (rev 225500)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.messages.in 2017-12-05 00:06:25 UTC (rev 225501)
@@ -34,7 +34,7 @@
SelectOptionElement(uint64_t pageID, uint64_t frameID, String nodeHandle, uint64_t callbackID)
- TakeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, uint64_t callbackID)
+ TakeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool clipToViewport, uint64_t callbackID)
GetCookiesForFrame(uint64_t pageID, uint64_t frameID, uint64_t callbackID)
DeleteCookie(uint64_t pageID, uint64_t frameID, String cookieName, uint64_t callbackID)