Title: [251373] trunk/Source/_javascript_Core
Revision
251373
Author
[email protected]
Date
2019-10-21 12:25:52 -0700 (Mon, 21 Oct 2019)

Log Message

[WinCairo][PlayStation] Add automation support for RemoteInspector SocketServer implementation.
https://bugs.webkit.org/show_bug.cgi?id=199070

Reviewed by Ross Kirsling.

Added handler for StartAutomationSession event from WebDriver and preparing for automation session.

* inspector/remote/RemoteInspector.h:
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::listingForAutomationTarget const):
(Inspector::RemoteInspector::sendAutomaticInspectionCandidateMessage):
(Inspector::RemoteInspector::requestAutomationSession):
(Inspector::RemoteInspector::dispatchMap):
(Inspector::RemoteInspector::startAutomationSession):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (251372 => 251373)


--- trunk/Source/_javascript_Core/ChangeLog	2019-10-21 19:15:26 UTC (rev 251372)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-10-21 19:25:52 UTC (rev 251373)
@@ -1,3 +1,20 @@
+2019-10-21  Basuke Suzuki  <[email protected]>
+
+        [WinCairo][PlayStation] Add automation support for RemoteInspector SocketServer implementation.
+        https://bugs.webkit.org/show_bug.cgi?id=199070
+
+        Reviewed by Ross Kirsling.
+
+        Added handler for StartAutomationSession event from WebDriver and preparing for automation session.
+
+        * inspector/remote/RemoteInspector.h:
+        * inspector/remote/socket/RemoteInspectorSocket.cpp:
+        (Inspector::RemoteInspector::listingForAutomationTarget const):
+        (Inspector::RemoteInspector::sendAutomaticInspectionCandidateMessage):
+        (Inspector::RemoteInspector::requestAutomationSession):
+        (Inspector::RemoteInspector::dispatchMap):
+        (Inspector::RemoteInspector::startAutomationSession):
+
 2019-10-21  Mark Lam  <[email protected]>
 
         Remove all uses of untagCodePtr in debugging code.

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h (251372 => 251373)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h	2019-10-21 19:15:26 UTC (rev 251372)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h	2019-10-21 19:25:52 UTC (rev 251373)
@@ -149,7 +149,7 @@
     void sendMessageToTarget(TargetID, const char* message);
 #endif
 #if USE(INSPECTOR_SOCKET_SERVER)
-    void requestAutomationSession(String&& sessionID, const Client::SessionCapabilities&);
+    void requestAutomationSession(const String& sessionID, const Client::SessionCapabilities&);
 
     bool isConnected() const { return !!m_clientConnection; }
     void connect(ConnectionID);
@@ -221,7 +221,10 @@
     void setupTarget(const Event&);
     void frontendDidClose(const Event&);
     void sendMessageToBackend(const Event&);
+    void startAutomationSession(const Event&);
 
+    void receivedAutomationSessionRequestMessage(const Event&);
+
     String backendCommands() const;
 #endif
     static bool startEnabled;

Modified: trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp (251372 => 251373)


--- trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp	2019-10-21 19:15:26 UTC (rev 251372)
+++ trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp	2019-10-21 19:25:52 UTC (rev 251373)
@@ -135,9 +135,14 @@
     return targetListing;
 }
 
-TargetListing RemoteInspector::listingForAutomationTarget(const RemoteAutomationTarget&) const
+TargetListing RemoteInspector::listingForAutomationTarget(const RemoteAutomationTarget& target) const
 {
-    return nullptr;
+    TargetListing targetListing = JSON::Object::create();
+    targetListing->setString("type"_s, "automation"_s);
+    targetListing->setString("name"_s, target.name());
+    targetListing->setInteger("targetID"_s, target.targetIdentifier());
+    targetListing->setBoolean("isPaired"_s, target.isPaired());
+    return targetListing;
 }
 
 void RemoteInspector::pushListingsNow()
@@ -178,8 +183,32 @@
 
 void RemoteInspector::sendAutomaticInspectionCandidateMessage()
 {
+    ASSERT(m_enabled);
+    ASSERT(m_automaticInspectionEnabled);
+    ASSERT(m_automaticInspectionPaused);
+    ASSERT(m_automaticInspectionCandidateTargetIdentifier);
+    // FIXME: Implement automatic inspection.
 }
 
+void RemoteInspector::requestAutomationSession(const String& sessionID, const Client::SessionCapabilities& capabilities)
+{
+    if (!m_client)
+        return;
+
+    if (!m_clientCapabilities || !m_clientCapabilities->remoteAutomationAllowed) {
+        LOG_ERROR("Error: Remote automation is not allowed");
+        return;
+    }
+
+    if (sessionID.isNull()) {
+        LOG_ERROR("Client error: SESSION ID cannot be null");
+        return;
+    }
+
+    m_client->requestAutomationSession(sessionID, capabilities);
+    updateClientCapabilities();
+}
+
 void RemoteInspector::sendMessageToRemote(TargetID targetIdentifier, const String& message)
 {
     if (!m_clientConnection)
@@ -251,6 +280,7 @@
         { "Setup"_s, static_cast<CallHandler>(&RemoteInspector::setupTarget) },
         { "FrontendDidClose"_s, static_cast<CallHandler>(&RemoteInspector::frontendDidClose) },
         { "SendMessageToBackend"_s, static_cast<CallHandler>(&RemoteInspector::sendMessageToBackend) },
+        { "StartAutomationSession"_s, static_cast<CallHandler>(&RemoteInspector::startAutomationSession) },
     });
 
     return methods;
@@ -321,6 +351,32 @@
     connectionToTarget->sendMessageToTarget(event.message.value());
 }
 
+void RemoteInspector::startAutomationSession(const Event& event)
+{
+    ASSERT(isMainThread());
+
+    if (!event.message)
+        return;
+
+    requestAutomationSession(event.message.value(), { });
+
+    auto sendEvent = JSON::Object::create();
+    sendEvent->setString("event"_s, "SetCapabilities"_s);
+
+    auto capability = clientCapabilities();
+
+    auto message = JSON::Object::create();
+    message->setString("browserName"_s, capability ? capability->browserName : "");
+    message->setString("browserVersion"_s, capability ? capability->browserVersion : "");
+    sendEvent->setString("message"_s, message->toJSONString());
+    sendWebInspectorEvent(sendEvent->toJSONString());
+
+    m_readyToPushListings = true;
+
+    LockHolder lock(m_mutex);
+    pushListingsNow();
+}
+
 } // namespace Inspector
 
 #endif // ENABLE(REMOTE_INSPECTOR)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to