- Revision
- 196980
- Author
- [email protected]
- Date
- 2016-02-23 09:40:20 -0800 (Tue, 23 Feb 2016)
Log Message
Connect WebAutomationSession to its backend dispatcher as if it were an agent and add stub implementations
https://bugs.webkit.org/show_bug.cgi?id=154518
<rdar://problem/24761096>
Reviewed by Timothy Hatcher.
Source/_javascript_Core:
* inspector/InspectorBackendDispatcher.h:
Export all the classes since they are used by WebKit::WebAutomationSession.
Source/WebKit2:
Add a domain dispatcher for the 'Automation' domain, and register the
WebAutomationSession itself as the handler for Automation commands.
Stub out these command implementations so the code will compile.
* UIProcess/Automation/Automation.json:
Fix the createWindow command's parameters and description.
Add an ErrorMessage string enumeration and document how it can be used
to signal well-known errors to the frontend.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::WebAutomationSession):
Add the domain backend dispatcher. It further parses commands that were deemed
valid by the generic dispatcher and match the 'Automation' domain prefix.
(WebKit::WebAutomationSession::getWindows):
(WebKit::WebAutomationSession::openWindow):
(WebKit::WebAutomationSession::closeWindow):
Stub these out with our new ErrorMessage enumeration and a macro to
make this code pattern more readable.
* UIProcess/Automation/WebAutomationSession.h:
Add new declarations and members.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (196979 => 196980)
--- trunk/Source/_javascript_Core/ChangeLog 2016-02-23 17:38:38 UTC (rev 196979)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-02-23 17:40:20 UTC (rev 196980)
@@ -1,3 +1,14 @@
+2016-02-23 Brian Burg <[email protected]>
+
+ Connect WebAutomationSession to its backend dispatcher as if it were an agent and add stub implementations
+ https://bugs.webkit.org/show_bug.cgi?id=154518
+ <rdar://problem/24761096>
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/InspectorBackendDispatcher.h:
+ Export all the classes since they are used by WebKit::WebAutomationSession.
+
2016-02-22 Brian Burg <[email protected]>
Web Inspector: add 'Automation' protocol domain and generate its backend classes separately in WebKit2
Modified: trunk/Source/_javascript_Core/inspector/InspectorBackendDispatcher.h (196979 => 196980)
--- trunk/Source/_javascript_Core/inspector/InspectorBackendDispatcher.h 2016-02-23 17:38:38 UTC (rev 196979)
+++ trunk/Source/_javascript_Core/inspector/InspectorBackendDispatcher.h 2016-02-23 17:40:20 UTC (rev 196980)
@@ -39,7 +39,7 @@
typedef String ErrorString;
-class SupplementalBackendDispatcher : public RefCounted<SupplementalBackendDispatcher> {
+class JS_EXPORT_PRIVATE SupplementalBackendDispatcher : public RefCounted<SupplementalBackendDispatcher> {
public:
SupplementalBackendDispatcher(BackendDispatcher&);
virtual ~SupplementalBackendDispatcher();
@@ -48,9 +48,9 @@
Ref<BackendDispatcher> m_backendDispatcher;
};
-class BackendDispatcher : public RefCounted<BackendDispatcher> {
+class JS_EXPORT_PRIVATE BackendDispatcher : public RefCounted<BackendDispatcher> {
public:
- JS_EXPORT_PRIVATE static Ref<BackendDispatcher> create(Ref<FrontendRouter>&&);
+ static Ref<BackendDispatcher> create(Ref<FrontendRouter>&&);
class JS_EXPORT_PRIVATE CallbackBase : public RefCounted<CallbackBase> {
public:
@@ -82,13 +82,13 @@
};
void registerDispatcherForDomain(const String& domain, SupplementalBackendDispatcher*);
- JS_EXPORT_PRIVATE void dispatch(const String& message);
+ void dispatch(const String& message);
- JS_EXPORT_PRIVATE void sendResponse(long requestId, RefPtr<InspectorObject>&& result);
- JS_EXPORT_PRIVATE void sendPendingErrors();
+ void sendResponse(long requestId, RefPtr<InspectorObject>&& result);
+ void sendPendingErrors();
void reportProtocolError(CommonErrorCode, const String& errorMessage);
- JS_EXPORT_PRIVATE void reportProtocolError(Optional<long> relatedRequestId, CommonErrorCode, const String& errorMessage);
+ void reportProtocolError(Optional<long> relatedRequestId, CommonErrorCode, const String& errorMessage);
template<typename T>
T getPropertyValue(InspectorObject*, const String& name, bool* out_optionalValueFound, T defaultValue, std::function<bool(InspectorValue&, T&)>, const char* typeName);
Modified: trunk/Source/WebKit2/ChangeLog (196979 => 196980)
--- trunk/Source/WebKit2/ChangeLog 2016-02-23 17:38:38 UTC (rev 196979)
+++ trunk/Source/WebKit2/ChangeLog 2016-02-23 17:40:20 UTC (rev 196980)
@@ -1,3 +1,34 @@
+2016-02-23 Brian Burg <[email protected]>
+
+ Connect WebAutomationSession to its backend dispatcher as if it were an agent and add stub implementations
+ https://bugs.webkit.org/show_bug.cgi?id=154518
+ <rdar://problem/24761096>
+
+ Reviewed by Timothy Hatcher.
+
+ Add a domain dispatcher for the 'Automation' domain, and register the
+ WebAutomationSession itself as the handler for Automation commands.
+ Stub out these command implementations so the code will compile.
+
+ * UIProcess/Automation/Automation.json:
+ Fix the createWindow command's parameters and description.
+ Add an ErrorMessage string enumeration and document how it can be used
+ to signal well-known errors to the frontend.
+
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::WebAutomationSession):
+ Add the domain backend dispatcher. It further parses commands that were deemed
+ valid by the generic dispatcher and match the 'Automation' domain prefix.
+
+ (WebKit::WebAutomationSession::getWindows):
+ (WebKit::WebAutomationSession::openWindow):
+ (WebKit::WebAutomationSession::closeWindow):
+ Stub these out with our new ErrorMessage enumeration and a macro to
+ make this code pattern more readable.
+
+ * UIProcess/Automation/WebAutomationSession.h:
+ Add new declarations and members.
+
2016-02-23 Antti Koivisto <[email protected]>
Remove tab suspension code
Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (196979 => 196980)
--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json 2016-02-23 17:38:38 UTC (rev 196979)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json 2016-02-23 17:40:20 UTC (rev 196980)
@@ -8,6 +8,14 @@
"description": "An opaque identifier for a window."
},
{
+ "id": "ErrorMessage",
+ "type": "string",
+ "enum": [
+ "NotImplemented"
+ ],
+ "description": "This enum contains predefined error messages that can be used to signal a well-defined error condition, such as a missing implementation, unknown window handle, and so forth. The backend signals one of these errors by using it as a prefix of the commands's error message (the errorString argument in generated C++ backend dispatchers). This will be reported to the frontend as a protocol error with a JSON-RPC error code of 'ServerError'. It is up to the frontend whether and how to deal with errors."
+ },
+ {
"id": "BrowsingWindow",
"type": "object",
"description": "A handle representing an open window or tab in the automation session.",
Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (196979 => 196980)
--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp 2016-02-23 17:38:38 UTC (rev 196979)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp 2016-02-23 17:40:20 UTC (rev 196980)
@@ -27,20 +27,27 @@
#include "WebAutomationSession.h"
#include "APIAutomationSessionClient.h"
+#include "InspectorProtocolObjects.h"
#include <_javascript_Core/InspectorBackendDispatcher.h>
#include <_javascript_Core/InspectorFrontendRouter.h>
using namespace Inspector;
+#define FAIL_WITH_PREDEFINED_ERROR_MESSAGE(messageName) \
+do { \
+ auto enumValue = Inspector::Protocol::Automation::ErrorMessage::messageName; \
+ errorString = Inspector::Protocol::getEnumConstantValue(enumValue); \
+ return; \
+} while (false)
+
namespace WebKit {
WebAutomationSession::WebAutomationSession()
: m_client(std::make_unique<API::AutomationSessionClient>())
, m_frontendRouter(FrontendRouter::create())
, m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))
+ , m_domainDispatcher(AutomationBackendDispatcher::create(m_backendDispatcher, this))
{
- // FIXME: to actually handle incoming commands, an agent needs to be created
- // and registered with the backend dispatcher in the constructor.
}
WebAutomationSession::~WebAutomationSession()
@@ -90,4 +97,21 @@
#endif // ENABLE(REMOTE_INSPECTOR)
+// Inspector::AutomationBackendDispatcherHandler API
+
+void WebAutomationSession::getWindows(Inspector::ErrorString& errorString, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingWindow>>& out_windows)
+{
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented);
+}
+
+void WebAutomationSession::openWindow(Inspector::ErrorString& errorString)
+{
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented);
+}
+
+void WebAutomationSession::closeWindow(Inspector::ErrorString& errorString, const String& in_handle)
+{
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented);
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (196979 => 196980)
--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h 2016-02-23 17:38:38 UTC (rev 196979)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h 2016-02-23 17:40:20 UTC (rev 196980)
@@ -27,6 +27,7 @@
#define WebAutomationSession_h
#include "APIObject.h"
+#include "InspectorBackendDispatchers.h"
#include <wtf/Forward.h>
#if ENABLE(REMOTE_INSPECTOR)
@@ -50,6 +51,7 @@
#if ENABLE(REMOTE_INSPECTOR)
, public Inspector::RemoteAutomationTarget
#endif
+ , public Inspector::AutomationBackendDispatcherHandler
{
public:
WebAutomationSession();
@@ -68,11 +70,17 @@
virtual void disconnect(Inspector::FrontendChannel*) override;
#endif
+ // Inspector::AutomationBackendDispatcherHandler API
+ virtual void getWindows(Inspector::ErrorString&, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingWindow>>& out_windows) override;
+ virtual void openWindow(Inspector::ErrorString&) override;
+ virtual void closeWindow(Inspector::ErrorString&, const String& in_handle) override;
+
private:
std::unique_ptr<API::AutomationSessionClient> m_client;
String m_sessionIdentifier { ASCIILiteral("Untitled Session") };
Ref<Inspector::FrontendRouter> m_frontendRouter;
Ref<Inspector::BackendDispatcher> m_backendDispatcher;
+ Ref<Inspector::AutomationBackendDispatcher> m_domainDispatcher;
#if ENABLE(REMOTE_INSPECTOR)
Inspector::FrontendChannel* m_remoteChannel { nullptr };