Web Automation: use automation session configurations to propagate per-session settings
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Aug 2017 21:08:09 +0000 (21:08 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Aug 2017 21:08:09 +0000 (21:08 +0000)
commitda218f729cc87309c9bb048b31d038dd1595a8ab
tree897ebe97fd5f9d3544aec10124ba2fa8f2ecd281
parentce48ded2f2a498905ef2fce1b804acb899018135
Web Automation: use automation session configurations to propagate per-session settings
https://bugs.webkit.org/show_bug.cgi?id=175562
<rdar://problem/30853362>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

Add a Cocoa-specific code path to forward capabilities when requesting
a new session from the remote inspector (i.e., automation) client.

If other ports want to use this, then we can convert Cocoa types to WebKit types later.

* inspector/remote/RemoteInspector.h:
* inspector/remote/RemoteInspectorConstants.h:
* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::receivedAutomationSessionRequestMessage):

Source/WebKit:

Some WebDriver capabilities need WebKit support in order to be implemented correctly.
There is currently no easy way to forward WebDriver capability keys and values to WebKit
at session creation time. This is unfortunate, as it would be best to implement many of
them via existing mechanisms (i.e., WKPreferences properties) that need to be set up
before any windows are opened in the session.

This patch adds WebKit-side plumbing to forward named capabilities from a remote
WebDriver client to the _WKAutomationSession and its delegate in WebKit2 UIProcess.
These capabilities are exposed via API in ways that abstract away details of how the
capabilities are represented in RWI wire protocol messages.

In the Cocoa API, these capabilities are exposed via a session configuration object
that's similar to WKWebView's WKWebViewConfiguration. A session's configuration is copied
and used at initialization and cannot be modified after the session is created.
Code in the Cocoa subclass of API::AutomationClient translates between RWI protocol
capability names and property values on the _WKAutomationSessionConfiguration it
uses to request a new session.

Later patches will hook up the two properties present in the configuration in this patch.
Most of this patch is just generic plumbing without doing any capability-specific work.

* UIProcess/API/Cocoa/_WKAutomationDelegate.h:
* UIProcess/API/Cocoa/_WKAutomationSession.h:
* UIProcess/API/Cocoa/_WKAutomationSession.mm:
(-[_WKAutomationSession init]):
(-[_WKAutomationSession initWithConfiguration:]):
(-[_WKAutomationSession configuration]):
* UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKAutomationDelegate.h.
* UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.mm: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSession.h.
(-[_WKAutomationSessionConfiguration init]):
(-[_WKAutomationSessionConfiguration description]):
* UIProcess/Cocoa/AutomationClient.h:
* UIProcess/Cocoa/AutomationClient.mm:
(WebKit::AutomationClient::AutomationClient):
(WebKit::AutomationClient::requestAutomationSession):
(WebKit::AutomationClient::requestAutomationSessionWithCapabilities):
* WebKit.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/remote/RemoteInspector.h
Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h
Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/_WKAutomationDelegate.h
Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSession.h
Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSession.mm
Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.mm [new file with mode: 0644]
Source/WebKit/UIProcess/Cocoa/AutomationClient.h
Source/WebKit/UIProcess/Cocoa/AutomationClient.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj