[GTK][WPE] Add API to provide browser information required by automation
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Aug 2017 06:06:34 +0000 (06:06 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Aug 2017 06:06:34 +0000 (06:06 +0000)
commit6478237ef17c2eadad2b03165fa77544af8064b6
tree95802a53fa4cc69ec2839ed8a8ea3000f6e57fbc
parent09ab73a01a5c7ebb4740e5942bde961b320af468
[GTK][WPE] Add API to provide browser information required by automation
https://bugs.webkit.org/show_bug.cgi?id=175130

Source/JavaScriptCore:

Reviewed by Brian Burg.

Add browserName and browserVersion to RemoteInspector::Client::Capabilities and virtual methods to the Client to
get them.

* inspector/remote/RemoteInspector.cpp:
(Inspector::RemoteInspector::updateClientCapabilities): Update also browserName and browserVersion.
* inspector/remote/RemoteInspector.h:
* inspector/remote/glib/RemoteInspectorGlib.cpp:
(Inspector::RemoteInspector::requestAutomationSession): Call updateClientCapabilities() after the session is
requested to ensure they are updated before StartAutomationSession reply is sent.
* inspector/remote/glib/RemoteInspectorServer.cpp: Add browserName and browserVersion as return values of
StartAutomationSession mesasage.

Source/WebDriver:

Reviewed by Brian Burg.

* Session.cpp:
(WebDriver::Session::createTopLevelBrowsingContext): Check if startAutomationSession and complete the command
with error in that case.
* SessionHost.h:
* glib/SessionHostGlib.cpp:
(WebDriver::SessionHost::matchCapabilities): Match the capabilities that are known only after the browser has
been launched.
(WebDriver::SessionHost::startAutomationSession): Handle the StartAutomationSession response, extracting the
capabilities and calling matchCapabilities() to match them.
(WebDriver::SessionHost::setTargetList): Return early if the session was rejected before due to invalid
capabilities.

Source/WebKit:

Reviewed by Michael Catanzaro.

When a new automation session is started, the web driver receives some required capabilities from the client,
like browser name and version. The session should be rejected if those required capabilities don't match with
the actual browser that is launched. We don't know that information in WebKit, so we need to add API so that
users can provide it when a new session request is made. This patch adds boxed object WebKitApplicationInfo that
can be used to set the application name and version. This object can be set to a WebKitAutomationSession when
WebKitWebContext::automation-started signal is emitted.

* PlatformGTK.cmake:
* PlatformWPE.cmake:
* UIProcess/API/glib/WebKitApplicationInfo.cpp: Added.
(webkit_application_info_new):
(webkit_application_info_ref):
(webkit_application_info_unref):
(webkit_application_info_set_name):
(webkit_application_info_get_name):
(webkit_application_info_set_version):
(webkit_application_info_get_version):
* UIProcess/API/glib/WebKitAutomationSession.cpp:
(webkitAutomationSessionDispose):
(webkit_automation_session_class_init):
(webkitAutomationSessionGetBrowserName):
(webkitAutomationSessionGetBrowserVersion):
(webkit_automation_session_set_application_info):
(webkit_automation_session_get_application_info):
* UIProcess/API/glib/WebKitAutomationSessionPrivate.h:
* UIProcess/API/glib/WebKitWebContext.cpp:
* UIProcess/API/gtk/WebKitApplicationInfo.h: Added.
* UIProcess/API/gtk/WebKitAutomationSession.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
* UIProcess/API/gtk/webkit2.h:
* UIProcess/API/wpe/WebKitApplicationInfo.h: Added.
* UIProcess/API/wpe/WebKitAutomationSession.h:
* UIProcess/API/wpe/webkit.h:

Tools:

Reviewed by Michael Catanzaro.

* MiniBrowser/gtk/main.c:
(automationStartedCallback): Set browser information when a new automation session is started.
* TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp:
(testAutomationSessionApplicationInfo):
(beforeAll):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220329 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/remote/RemoteInspector.cpp
Source/JavaScriptCore/inspector/remote/RemoteInspector.h
Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp
Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorServer.cpp
Source/WebDriver/ChangeLog
Source/WebDriver/Session.cpp
Source/WebDriver/SessionHost.h
Source/WebDriver/glib/SessionHostGlib.cpp
Source/WebKit/ChangeLog
Source/WebKit/PlatformGTK.cmake
Source/WebKit/PlatformWPE.cmake
Source/WebKit/UIProcess/API/glib/WebKitApplicationInfo.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp
Source/WebKit/UIProcess/API/glib/WebKitAutomationSessionPrivate.h
Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
Source/WebKit/UIProcess/API/gtk/WebKitApplicationInfo.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/gtk/WebKitAutomationSession.h
Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
Source/WebKit/UIProcess/API/gtk/webkit2.h
Source/WebKit/UIProcess/API/wpe/WebKitApplicationInfo.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/wpe/WebKitAutomationSession.h
Source/WebKit/UIProcess/API/wpe/webkit.h
Tools/ChangeLog
Tools/MiniBrowser/gtk/main.c
Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp