Title: [198736] trunk/Source/WebKit2
Revision
198736
Author
timo...@apple.com
Date
2016-03-28 08:56:53 -0700 (Mon, 28 Mar 2016)

Log Message

Add WebAutomationSessionProxy for WebProcess side automation tasks

https://bugs.webkit.org/show_bug.cgi?id=155221
rdar://problem/25054868

Reviewed by Joseph Pecoraro.

* CMakeLists.txt: Add build step to build-in WebAutomationSessionProxy.js.
* DerivedSources.make: Ditto.

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::~WebAutomationSession):
(WebKit::WebAutomationSession::setProcessPool): Add / remove message receiver.
* UIProcess/Automation/WebAutomationSession.h:

* UIProcess/Automation/WebAutomationSession.messages.in: Added.
Test message to get things to build.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::removeMessageReceiver):
(WebKit::WebProcessPool::setAutomationSession):
* UIProcess/WebProcessPool.h:

* WebKit2.xcodeproj/project.pbxproj: Added new files.

* WebProcess/Automation/WebAutomationSessionProxy.cpp: Added.
(WebKit::toJSString):
(WebKit::toJSValue):
(WebKit::WebAutomationSessionProxy::WebAutomationSessionProxy):
(WebKit::WebAutomationSessionProxy::~WebAutomationSessionProxy):
(WebKit::evaluate):
(WebKit::createUUID):
(WebKit::WebAutomationSessionProxy::scriptObjectForFrame):
(WebKit::WebAutomationSessionProxy::didClearWindowObjectForFrame):
Create a script object per frame that is evaluated from WebAutomationSessionProxy.js.
Clear the script object when the window object is cleared.

* WebProcess/Automation/WebAutomationSessionProxy.h: Added.
(WebKit::WebAutomationSessionProxy::test):
Added test message to let the messages files build.

* WebProcess/Automation/WebAutomationSessionProxy.js: Added.

* WebProcess/Automation/WebAutomationSessionProxy.messages.in: Added.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
Call WebAutomationSessionProxy::didClearWindowObjectForFrame to clear the script object.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureAutomationSessionProxy):
(WebKit::WebProcess::destroyAutomationSessionProxy):
Creates and destroys the WebAutomationSessionProxy when the UIProcess WebAutomationSession
is set or removed on the WebProcessPool.

* WebProcess/WebProcess.h:
(WebKit::WebProcess::automationSessionProxy): Added.

* WebProcess/WebProcess.messages.in: Added. Test message to get things to build.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/CMakeLists.txt (198735 => 198736)


--- trunk/Source/WebKit2/CMakeLists.txt	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/CMakeLists.txt	2016-03-28 15:56:53 UTC (rev 198736)
@@ -42,6 +42,7 @@
     "${WEBKIT2_DIR}/UIProcess/WebsiteData"
     "${WEBKIT2_DIR}/WebProcess"
     "${WEBKIT2_DIR}/WebProcess/ApplicationCache"
+    "${WEBKIT2_DIR}/WebProcess/Automation"
     "${WEBKIT2_DIR}/WebProcess/Battery"
     "${WEBKIT2_DIR}/WebProcess/Cookies"
     "${WEBKIT2_DIR}/WebProcess/Databases"
@@ -502,6 +503,8 @@
     WebProcess/WebConnectionToUIProcess.cpp
     WebProcess/WebProcess.cpp
 
+    WebProcess/Automation/WebAutomationSessionProxy.cpp
+
     WebProcess/Battery/WebBatteryManager.cpp
 
     WebProcess/Cookies/WebCookieManager.cpp
@@ -673,6 +676,8 @@
     UIProcess/WebResourceLoadStatisticsStore.messages.in
     UIProcess/WebVibrationProxy.messages.in
 
+    UIProcess/Automation/WebAutomationSession.messages.in
+
     UIProcess/Databases/DatabaseProcessProxy.messages.in
 
     UIProcess/Downloads/DownloadProxy.messages.in
@@ -689,6 +694,8 @@
 
     WebProcess/WebProcess.messages.in
 
+    WebProcess/Automation/WebAutomationSessionProxy.messages.in
+
     WebProcess/Battery/WebBatteryManager.messages.in
 
     WebProcess/Cookies/WebCookieManager.messages.in
@@ -798,6 +805,19 @@
     ${DERIVED_SOURCES_WEBKIT2_DIR}/AutomationProtocolObjects.cpp
 )
 
+add_custom_command(
+    OUTPUT ${DERIVED_SOURCES_WEBKIT2_DIR}/WebAutomationSessionProxyScriptSource.h ${DERIVED_SOURCES_WEBKIT2_DIR}/WebAutomationSessionProxy.min.js
+    MAIN_DEPENDENCY ${WEBKIT2_DIR}/WebProcess/Automation/WebAutomationSessionProxy.js
+    DEPENDS ${_javascript_Core_SCRIPTS_DIR}/xxd.pl ${_javascript_Core_SCRIPTS_DIR}/jsmin.py
+    COMMAND ${CMAKE_COMMAND} -E echo "//# sourceURL=__WebAutomationInjectedScript__" > ${DERIVED_SOURCES_WEBKIT2_DIR}/WebAutomationSessionProxy.min.js
+    COMMAND ${PYTHON_EXECUTABLE} ${_javascript_Core_SCRIPTS_DIR}/jsmin.py < ${WEBKIT2_DIR}/WebProcess/Automation/WebAutomationSessionProxy.js >> ${DERIVED_SOURCES_WEBKIT2_DIR}/WebAutomationSessionProxy.min.js
+    COMMAND ${PERL_EXECUTABLE} ${_javascript_Core_SCRIPTS_DIR}/xxd.pl WebAutomationSessionProxyScriptSource ${DERIVED_SOURCES_WEBKIT2_DIR}/WebAutomationSessionProxy.min.js ${DERIVED_SOURCES_WEBKIT2_DIR}/WebAutomationSessionProxyScriptSource.h
+    VERBATIM)
+
+list(APPEND WebKit2_HEADERS
+    ${DERIVED_SOURCES_WEBKIT2_DIR}/WebauotmationSessionProxyScriptSource.h
+)
+
 WEBKIT_FRAMEWORK(WebKit2)
 add_dependencies(WebKit2 WebCore ${WEBKIT2_EXTRA_DEPENDENCIES})
 add_webkit2_prefix_header(WebKit2)

Modified: trunk/Source/WebKit2/ChangeLog (198735 => 198736)


--- trunk/Source/WebKit2/ChangeLog	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/ChangeLog	2016-03-28 15:56:53 UTC (rev 198736)
@@ -1,3 +1,65 @@
+2016-03-14  Timothy Hatcher  <timo...@apple.com>
+
+        Add WebAutomationSessionProxy for WebProcess side automation tasks
+
+        https://bugs.webkit.org/show_bug.cgi?id=155221
+        rdar://problem/25054868
+
+        Reviewed by Joseph Pecoraro.
+
+        * CMakeLists.txt: Add build step to build-in WebAutomationSessionProxy.js.
+        * DerivedSources.make: Ditto.
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::~WebAutomationSession):
+        (WebKit::WebAutomationSession::setProcessPool): Add / remove message receiver.
+        * UIProcess/Automation/WebAutomationSession.h:
+
+        * UIProcess/Automation/WebAutomationSession.messages.in: Added.
+        Test message to get things to build.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::removeMessageReceiver):
+        (WebKit::WebProcessPool::setAutomationSession):
+        * UIProcess/WebProcessPool.h:
+
+        * WebKit2.xcodeproj/project.pbxproj: Added new files.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp: Added.
+        (WebKit::toJSString):
+        (WebKit::toJSValue):
+        (WebKit::WebAutomationSessionProxy::WebAutomationSessionProxy):
+        (WebKit::WebAutomationSessionProxy::~WebAutomationSessionProxy):
+        (WebKit::evaluate):
+        (WebKit::createUUID):
+        (WebKit::WebAutomationSessionProxy::scriptObjectForFrame):
+        (WebKit::WebAutomationSessionProxy::didClearWindowObjectForFrame):
+        Create a script object per frame that is evaluated from WebAutomationSessionProxy.js.
+        Clear the script object when the window object is cleared.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.h: Added.
+        (WebKit::WebAutomationSessionProxy::test):
+        Added test message to let the messages files build.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.js: Added.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.messages.in: Added.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
+        Call WebAutomationSessionProxy::didClearWindowObjectForFrame to clear the script object.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::ensureAutomationSessionProxy):
+        (WebKit::WebProcess::destroyAutomationSessionProxy):
+        Creates and destroys the WebAutomationSessionProxy when the UIProcess WebAutomationSession
+        is set or removed on the WebProcessPool.
+
+        * WebProcess/WebProcess.h:
+        (WebKit::WebProcess::automationSessionProxy): Added.
+
+        * WebProcess/WebProcess.messages.in: Added. Test message to get things to build.
+
 2016-03-28  Dan Bernstein  <m...@apple.com>
 
         Tried to fix the build after r198728.

Modified: trunk/Source/WebKit2/DerivedSources.make (198735 => 198736)


--- trunk/Source/WebKit2/DerivedSources.make	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/DerivedSources.make	2016-03-28 15:56:53 UTC (rev 198736)
@@ -36,6 +36,7 @@
     $(WebKit2)/Shared/Authentication \
     $(WebKit2)/Shared/mac \
     $(WebKit2)/WebProcess/ApplicationCache \
+    $(WebKit2)/WebProcess/Automation \
     $(WebKit2)/WebProcess/Cookies \
     $(WebKit2)/WebProcess/Databases/IndexedDB \
     $(WebKit2)/WebProcess/FullScreen \
@@ -71,6 +72,15 @@
     $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) \
 #
 
+PYTHON = python
+PERL = perl
+
+ifeq ($(OS),Windows_NT)
+    DELETE = cmd //C del
+else
+    DELETE = rm -f
+endif
+
 MESSAGE_RECEIVERS = \
     AuthenticationManager \
     ChildProcess \
@@ -108,6 +118,8 @@
     ViewUpdateDispatcher \
     VisitedLinkStore \
     VisitedLinkTableController \
+    WebAutomationSession \
+    WebAutomationSessionProxy \
     WebConnection \
     WebCookieManager \
     WebCookieManagerProxy \
@@ -219,3 +231,11 @@
 	$(PYTHON) $(_javascript_Core_SCRIPTS_DIR)/generate-inspector-protocol-bindings.py --framework WebKit --backend --outputDir . $(AUTOMATION_PROTOCOL_INPUT_FILES)
 
 all : $(firstword $(AUTOMATION_PROTOCOL_OUTPUT_FILES))
+
+%ScriptSource.h : %.js $(_javascript_Core_SCRIPTS_DIR)/jsmin.py $(_javascript_Core_SCRIPTS_DIR)/xxd.pl
+	echo "//# sourceURL=__WebAutomationInjectedScript__" > $(basename $(notdir $<)).min.js
+	$(PYTHON) $(_javascript_Core_SCRIPTS_DIR)/jsmin.py < $< >> $(basename $(notdir $<)).min.js
+	$(PERL) $(_javascript_Core_SCRIPTS_DIR)/xxd.pl $(basename $(notdir $<))ScriptSource $(basename $(notdir $<)).min.js $@
+	$(DELETE) $(basename $(notdir $<)).min.js
+
+all : WebAutomationSessionProxyScriptSource.h

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (198735 => 198736)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2016-03-28 15:56:53 UTC (rev 198736)
@@ -28,6 +28,8 @@
 
 #include "APIAutomationSessionClient.h"
 #include "AutomationProtocolObjects.h"
+#include "WebAutomationSessionMessages.h"
+#include "WebAutomationSessionProxyMessages.h"
 #include "WebProcessPool.h"
 #include <_javascript_Core/InspectorBackendDispatcher.h>
 #include <_javascript_Core/InspectorFrontendRouter.h>
@@ -57,6 +59,9 @@
 WebAutomationSession::~WebAutomationSession()
 {
     ASSERT(!m_client);
+
+    if (m_processPool)
+        m_processPool->removeMessageReceiver(Messages::WebAutomationSession::messageReceiverName());
 }
 
 void WebAutomationSession::setClient(std::unique_ptr<API::AutomationSessionClient> client)
@@ -64,6 +69,17 @@
     m_client = WTFMove(client);
 }
 
+void WebAutomationSession::setProcessPool(WebKit::WebProcessPool* processPool)
+{
+    if (m_processPool)
+        m_processPool->removeMessageReceiver(Messages::WebAutomationSession::messageReceiverName());
+
+    m_processPool = processPool;
+
+    if (m_processPool)
+        m_processPool->addMessageReceiver(Messages::WebAutomationSession::messageReceiverName(), *this);
+}
+
 // NOTE: this class could be split at some point to support local and remote automation sessions.
 // For now, it only works with a remote automation driver over a RemoteInspector connection.
 

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (198735 => 198736)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h	2016-03-28 15:56:53 UTC (rev 198736)
@@ -28,6 +28,7 @@
 
 #include "APIObject.h"
 #include "AutomationBackendDispatchers.h"
+#include "Connection.h"
 #include <wtf/Forward.h>
 
 #if ENABLE(REMOTE_INSPECTOR)
@@ -49,7 +50,7 @@
 class WebPageProxy;
 class WebProcessPool;
 
-class WebAutomationSession final : public API::ObjectImpl<API::Object::Type::AutomationSession>
+class WebAutomationSession final : public API::ObjectImpl<API::Object::Type::AutomationSession>, public IPC::MessageReceiver
 #if ENABLE(REMOTE_INSPECTOR)
     , public Inspector::RemoteAutomationTarget
 #endif
@@ -68,7 +69,7 @@
     String sessionIdentifier() const { return m_sessionIdentifier; }
 
     WebKit::WebProcessPool* processPool() const { return m_processPool; }
-    void setProcessPool(WebKit::WebProcessPool* processPool) { m_processPool = processPool; }
+    void setProcessPool(WebKit::WebProcessPool*);
 
 #if ENABLE(REMOTE_INSPECTOR)
     // Inspector::RemoteAutomationTarget API
@@ -93,6 +94,13 @@
     WebKit::WebPageProxy* webPageProxyForHandle(const String&);
     String handleForWebPageProxy(WebKit::WebPageProxy*);
 
+    // Implemented in generated WebAutomationSessionMessageReceiver.cpp
+    void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
+
+    // Called by WebAutomationSession messages
+    // FIXME: Add message functions here.
+    void test() { };
+
     WebKit::WebProcessPool* m_processPool { nullptr };
     std::unique_ptr<API::AutomationSessionClient> m_client;
     String m_sessionIdentifier { ASCIILiteral("Untitled Session") };

Added: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in (0 => 198736)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in	2016-03-28 15:56:53 UTC (rev 198736)
@@ -0,0 +1,26 @@
+# Copyright (C) 2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+messages -> WebAutomationSession {
+    // FIXME: Add messages here.
+    Test()
+}

Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (198735 => 198736)


--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp	2016-03-28 15:56:53 UTC (rev 198736)
@@ -647,6 +647,9 @@
     if (WebPreferences::anyPagesAreUsingPrivateBrowsing())
         process->send(Messages::WebProcess::EnsurePrivateBrowsingSession(SessionID::legacyPrivateSessionID()), 0);
 
+    if (m_automationSession)
+        process->send(Messages::WebProcess::EnsureAutomationSessionProxy(m_automationSession->sessionIdentifier()), 0);
+
     m_processes.append(process.ptr());
 
     ASSERT(m_messagesToInjectedBundlePostedToEmptyContext.isEmpty());
@@ -992,6 +995,11 @@
     m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver);
 }
 
+void WebProcessPool::removeMessageReceiver(IPC::StringReference messageReceiverName)
+{
+    m_messageReceiverMap.removeMessageReceiver(messageReceiverName);
+}
+
 void WebProcessPool::removeMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID)
 {
     m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID);
@@ -1127,7 +1135,10 @@
     if (m_automationSession) {
         m_automationSession->init();
         m_automationSession->setProcessPool(this);
-    }
+
+        sendToAllProcesses(Messages::WebProcess::EnsureAutomationSessionProxy(m_automationSession->sessionIdentifier()));
+    } else
+        sendToAllProcesses(Messages::WebProcess::DestroyAutomationSessionProxy());
 #endif
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (198735 => 198736)


--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2016-03-28 15:56:53 UTC (rev 198736)
@@ -126,6 +126,7 @@
 
     void addMessageReceiver(IPC::StringReference messageReceiverName, IPC::MessageReceiver&);
     void addMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID, IPC::MessageReceiver&);
+    void removeMessageReceiver(IPC::StringReference messageReceiverName);
     void removeMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID);
 
     bool dispatchMessage(IPC::Connection&, IPC::MessageDecoder&);

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (198735 => 198736)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-03-28 15:56:53 UTC (rev 198736)
@@ -517,6 +517,13 @@
 		1AFE436518B6C081009C7A48 /* UIDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AFE436318B6C081009C7A48 /* UIDelegate.mm */; };
 		1AFE436618B6C081009C7A48 /* UIDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFE436418B6C081009C7A48 /* UIDelegate.h */; };
 		1AFF49001833DE78009AB15A /* WKDeprecatedFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFF48FE1833DE78009AB15A /* WKDeprecatedFunctions.cpp */; };
+		1C0A19461C8FF1A800FE0EBB /* WebAutomationSessionProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C0A19441C8FF1A800FE0EBB /* WebAutomationSessionProxy.cpp */; };
+		1C0A19471C8FF1A800FE0EBB /* WebAutomationSessionProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0A19451C8FF1A800FE0EBB /* WebAutomationSessionProxy.h */; };
+		1C0A19531C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C0A19511C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp */; };
+		1C0A19541C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0A19521C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessages.h */; };
+		1C0A19571C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C0A19551C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp */; };
+		1C0A19581C90068F00FE0EBB /* WebAutomationSessionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0A19561C90068F00FE0EBB /* WebAutomationSessionMessages.h */; };
+		1C0A195C1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0A195B1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h */; };
 		1C891D6519B124FF00BA79DD /* WebInspectorUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C891D6219B124FF00BA79DD /* WebInspectorUI.cpp */; };
 		1C891D6619B124FF00BA79DD /* WebInspectorUI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C891D6319B124FF00BA79DD /* WebInspectorUI.h */; };
 		1C8E28201275D15400BC7BD0 /* WebInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8E281E1275D15400BC7BD0 /* WebInspector.h */; };
@@ -2476,6 +2483,16 @@
 		1AFE436418B6C081009C7A48 /* UIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDelegate.h; sourceTree = "<group>"; };
 		1AFF48FE1833DE78009AB15A /* WKDeprecatedFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKDeprecatedFunctions.cpp; sourceTree = "<group>"; };
 		1BB417C912C00CCA002BE67B /* TextCheckerCompletion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCheckerCompletion.cpp; sourceTree = "<group>"; };
+		1C0A19441C8FF1A800FE0EBB /* WebAutomationSessionProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAutomationSessionProxy.cpp; sourceTree = "<group>"; };
+		1C0A19451C8FF1A800FE0EBB /* WebAutomationSessionProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAutomationSessionProxy.h; sourceTree = "<group>"; };
+		1C0A19481C8FF30E00FE0EBB /* WebAutomationSessionProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebAutomationSessionProxy.messages.in; sourceTree = "<group>"; };
+		1C0A19511C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAutomationSessionProxyMessageReceiver.cpp; sourceTree = "<group>"; };
+		1C0A19521C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAutomationSessionProxyMessages.h; sourceTree = "<group>"; };
+		1C0A19551C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAutomationSessionMessageReceiver.cpp; sourceTree = "<group>"; };
+		1C0A19561C90068F00FE0EBB /* WebAutomationSessionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAutomationSessionMessages.h; sourceTree = "<group>"; };
+		1C0A19591C9006EA00FE0EBB /* WebAutomationSession.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebAutomationSession.messages.in; sourceTree = "<group>"; };
+		1C0A195A1C91669500FE0EBB /* WebAutomationSessionProxy.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode._javascript_; path = WebAutomationSessionProxy.js; sourceTree = "<group>"; };
+		1C0A195B1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAutomationSessionProxyScriptSource.h; sourceTree = "<group>"; };
 		1C77C1951288A872006A742F /* WebInspectorProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebInspectorProxy.messages.in; sourceTree = "<group>"; };
 		1C891D6219B124FF00BA79DD /* WebInspectorUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorUI.cpp; sourceTree = "<group>"; };
 		1C891D6319B124FF00BA79DD /* WebInspectorUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorUI.h; sourceTree = "<group>"; };
@@ -4709,6 +4726,17 @@
 			path = mac;
 			sourceTree = "<group>";
 		};
+		1C0A19431C8FF1A800FE0EBB /* Automation */ = {
+			isa = PBXGroup;
+			children = (
+				1C0A19441C8FF1A800FE0EBB /* WebAutomationSessionProxy.cpp */,
+				1C0A19451C8FF1A800FE0EBB /* WebAutomationSessionProxy.h */,
+				1C0A195A1C91669500FE0EBB /* WebAutomationSessionProxy.js */,
+				1C0A19481C8FF30E00FE0EBB /* WebAutomationSessionProxy.messages.in */,
+			);
+			path = Automation;
+			sourceTree = "<group>";
+		};
 		1F0181681858DC1500F92884 /* Cocoa */ = {
 			isa = PBXGroup;
 			children = (
@@ -5595,6 +5623,7 @@
 				9955A6E91C7980BB00EB6A93 /* Automation.json */,
 				9955A6EA1C7980BB00EB6A93 /* WebAutomationSession.cpp */,
 				9955A6EB1C7980BB00EB6A93 /* WebAutomationSession.h */,
+				1C0A19591C9006EA00FE0EBB /* WebAutomationSession.messages.in */,
 			);
 			path = Automation;
 			sourceTree = "<group>";
@@ -5654,6 +5683,7 @@
 			isa = PBXGroup;
 			children = (
 				7C6E70F818B2D47E00F24E2E /* cocoa */,
+				1C0A19431C8FF1A800FE0EBB /* Automation */,
 				3309344B1315B93A0097A7BC /* Cookies */,
 				512A9754180DF9270039A149 /* Databases */,
 				BCACC43B16B24C5D00B6E092 /* EntryPoint */,
@@ -6875,6 +6905,11 @@
 				1A60224B18C16B9F00C3E8C9 /* VisitedLinkStoreMessages.h */,
 				1A8E7D3A18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp */,
 				1A8E7D3B18C15149005A702A /* VisitedLinkTableControllerMessages.h */,
+				1C0A19551C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp */,
+				1C0A19561C90068F00FE0EBB /* WebAutomationSessionMessages.h */,
+				1C0A19511C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp */,
+				1C0A19521C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessages.h */,
+				1C0A195B1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h */,
 				1A1FEC1A1627B45600700F6D /* WebConnectionMessageReceiver.cpp */,
 				1A1FEC1B1627B45700700F6D /* WebConnectionMessages.h */,
 				330934431315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp */,
@@ -7348,6 +7383,7 @@
 				BC8147A912F64CDA007B2C32 /* InjectedBundlePagePolicyClient.h in Headers */,
 				BCA8C6B011E3C08700812FB7 /* InjectedBundlePageUIClient.h in Headers */,
 				9955A6F71C7986E500EB6A93 /* AutomationProtocolObjects.h in Headers */,
+				1C0A19581C90068F00FE0EBB /* WebAutomationSessionMessages.h in Headers */,
 				BC33E0D112408E8600360F3F /* InjectedBundleRangeHandle.h in Headers */,
 				BC14DF77120B5B7900826C0C /* InjectedBundleScriptWorld.h in Headers */,
 				C58CDF2A1887548B00871536 /* InteractionInformationAtPosition.h in Headers */,
@@ -7364,6 +7400,7 @@
 				1A24B5F311F531E800C38269 /* MachUtilities.h in Headers */,
 				CE1A0BD51A48E6C60054EF74 /* ManagedConfigurationSPI.h in Headers */,
 				51933DEF1965EB31008AC3EA /* MenuUtilities.h in Headers */,
+				1C0A195C1C916E1B00FE0EBB /* WebAutomationSessionProxyScriptSource.h in Headers */,
 				1A232903162C867300D82F7A /* MessageDecoder.h in Headers */,
 				1A2328FF162C866A00D82F7A /* MessageEncoder.h in Headers */,
 				1AC4C82916B876A90069DCCD /* MessageFlags.h in Headers */,
@@ -7427,6 +7464,7 @@
 				1A2D843A127F65D5001EB962 /* NPObjectMessageReceiverMessages.h in Headers */,
 				1A2D82A7127F4EAB001EB962 /* NPObjectProxy.h in Headers */,
 				1A2D82A9127F4EAB001EB962 /* NPRemoteObjectMap.h in Headers */,
+				1C0A19471C8FF1A800FE0EBB /* WebAutomationSessionProxy.h in Headers */,
 				1A2161B011F37664008AD0F5 /* NPRuntimeObjectMap.h in Headers */,
 				1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */,
 				1A2D84A3127F6AD1001EB962 /* NPVariantData.h in Headers */,
@@ -7455,6 +7493,7 @@
 				1A8EF96F1252AF6B00F7067F /* PluginControllerProxyMessages.h in Headers */,
 				1A179780137EE82C00F97D45 /* PluginCreationParameters.h in Headers */,
 				7C3F8C91173AF52D007B7F39 /* PluginInformation.h in Headers */,
+				1C0A19541C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessages.h in Headers */,
 				1AEFCC1211D01F96008219D3 /* PluginInfoStore.h in Headers */,
 				1A3D610213A7CC2A00F95D4E /* PluginModuleInfo.h in Headers */,
 				1A043976124D034800FFBFB5 /* PluginProcess.h in Headers */,
@@ -8876,6 +8915,7 @@
 				1A2D82A4127F4EAB001EB962 /* NPObjectMessageReceiver.cpp in Sources */,
 				1A2D8439127F65D5001EB962 /* NPObjectMessageReceiverMessageReceiver.cpp in Sources */,
 				1A2D82A6127F4EAB001EB962 /* NPObjectProxy.cpp in Sources */,
+				1C0A19531C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp in Sources */,
 				1A2D82A8127F4EAB001EB962 /* NPRemoteObjectMap.cpp in Sources */,
 				1A2161B111F37664008AD0F5 /* NPRuntimeObjectMap.cpp in Sources */,
 				1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */,
@@ -9117,6 +9157,7 @@
 				1CA8B945127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp in Sources */,
 				1C891D6519B124FF00BA79DD /* WebInspectorUI.cpp in Sources */,
 				1CA8B954127C891500576C2B /* WebInspectorUIMac.mm in Sources */,
+				1C0A19571C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp in Sources */,
 				1CBBE4A019B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp in Sources */,
 				2DA944A11884E4F000ED86DB /* WebIOSEventFactory.mm in Sources */,
 				C0337DD3127A2A0E008FF4F4 /* WebKeyboardEvent.cpp in Sources */,
@@ -9212,6 +9253,7 @@
 				1A52C0F71A38CDC70016160A /* WebStorageNamespaceProvider.cpp in Sources */,
 				BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */,
 				51032F18180F73BB00961BB7 /* WebToDatabaseProcessConnection.cpp in Sources */,
+				1C0A19461C8FF1A800FE0EBB /* WebAutomationSessionProxy.cpp in Sources */,
 				C0337DD8127A51B6008FF4F4 /* WebTouchEvent.cpp in Sources */,
 				2DA944A31884E4F000ED86DB /* WebTouchEventIOS.cpp in Sources */,
 				BCA0EF8012331E78007D3CFB /* WebUndoStep.cpp in Sources */,

Added: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp (0 => 198736)


--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp	2016-03-28 15:56:53 UTC (rev 198736)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAutomationSessionProxy.h"
+
+#include "WebAutomationSessionMessages.h"
+#include "WebAutomationSessionProxyMessages.h"
+#include "WebAutomationSessionProxyScriptSource.h"
+#include "WebFrame.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+#include <_javascript_Core/JSRetainPtr.h>
+#include <_javascript_Core/JSStringRefPrivate.h>
+#include <_javascript_Core/OpaqueJSString.h>
+#include <WebCore/UUID.h>
+
+namespace WebKit {
+
+static inline JSRetainPtr<JSStringRef> toJSString(const String& string)
+{
+    return JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(string).leakRef());
+}
+
+static inline JSValueRef toJSValue(JSContextRef context, const String& string)
+{
+    return JSValueMakeString(context, toJSString(string).get());
+}
+
+WebAutomationSessionProxy::WebAutomationSessionProxy(const String& sessionIdentifier)
+    : m_sessionIdentifier(sessionIdentifier)
+{
+    WebProcess::singleton().addMessageReceiver(Messages::WebAutomationSessionProxy::messageReceiverName(), *this);
+}
+
+WebAutomationSessionProxy::~WebAutomationSessionProxy()
+{
+    WebProcess::singleton().removeMessageReceiver(Messages::WebAutomationSessionProxy::messageReceiverName());
+}
+
+static JSValueRef evaluate(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    ASSERT_ARG(argumentCount, argumentCount == 1);
+    ASSERT_ARG(arguments, JSValueIsString(context, arguments[0]));
+
+    if (argumentCount != 1)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    return JSEvaluateScript(context, script.get(), nullptr, nullptr, 0, exception);
+}
+
+static JSValueRef createUUID(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    return toJSValue(context, WebCore::createCanonicalUUIDString().convertToASCIIUppercase());
+}
+
+JSObjectRef WebAutomationSessionProxy::scriptObjectForFrame(WebFrame& frame)
+{
+    if (JSObjectRef scriptObject = m_webFrameScriptObjectMap.get(frame.frameID()))
+        return scriptObject;
+
+    JSValueRef exception = nullptr;
+    JSGlobalContextRef context = frame.jsContext();
+
+    JSValueRef sessionIdentifier = toJSValue(context, m_sessionIdentifier);
+    JSObjectRef evaluateFunction = JSObjectMakeFunctionWithCallback(context, nullptr, evaluate);
+    JSObjectRef createUUIDFunction = JSObjectMakeFunctionWithCallback(context, nullptr, createUUID);
+
+    String script = StringImpl::createWithoutCopying(WebAutomationSessionProxyScriptSource, sizeof(WebAutomationSessionProxyScriptSource));
+
+    JSObjectRef scriptObjectFunction = const_cast<JSObjectRef>(JSEvaluateScript(context, toJSString(script).get(), nullptr, nullptr, 0, &exception));
+    ASSERT(JSValueIsObject(context, scriptObjectFunction));
+
+    JSValueRef arguments[] = { sessionIdentifier, evaluateFunction, createUUIDFunction };
+    JSObjectRef scriptObject = const_cast<JSObjectRef>(JSObjectCallAsFunction(context, scriptObjectFunction, nullptr, WTF_ARRAY_LENGTH(arguments), arguments, &exception));
+    ASSERT(JSValueIsObject(context, scriptObject));
+
+    JSValueProtect(context, scriptObject);
+    m_webFrameScriptObjectMap.add(frame.frameID(), scriptObject);
+
+    return scriptObject;
+}
+
+void WebAutomationSessionProxy::didClearWindowObjectForFrame(WebFrame& frame)
+{
+    if (JSObjectRef scriptObject = m_webFrameScriptObjectMap.take(frame.frameID()))
+        JSValueUnprotect(frame.jsContext(), scriptObject);
+}
+
+} // namespace WebKit

Added: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h (0 => 198736)


--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h	2016-03-28 15:56:53 UTC (rev 198736)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebAutomationSessionProxy_h
+#define WebAutomationSessionProxy_h
+
+#include "Connection.h"
+#include <_javascript_Core/JSBase.h>
+
+namespace WebKit {
+
+class WebFrame;
+class WebPage;
+
+class WebAutomationSessionProxy : public IPC::MessageReceiver {
+public:
+    WebAutomationSessionProxy(const String& sessionIdentifier);
+    ~WebAutomationSessionProxy();
+
+    String sessionIdentifier() const { return m_sessionIdentifier; }
+
+    void didClearWindowObjectForFrame(WebFrame&);
+
+private:
+    JSObjectRef scriptObjectForFrame(WebFrame&);
+
+    // Implemented in generated WebAutomationSessionProxyMessageReceiver.cpp
+    void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&);
+
+    // Called by WebAutomationSessionProxy messages
+    // FIXME: Add message functions here.
+    void test() { };
+
+    String m_sessionIdentifier;
+
+    typedef HashMap<uint64_t, JSObjectRef> WebFrameScriptObjectMap;
+    WebFrameScriptObjectMap m_webFrameScriptObjectMap;
+};
+
+} // namespace WebKit
+
+#endif // WebAutomationSessionProxy_h

Added: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js (0 => 198736)


--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js	2016-03-28 15:56:53 UTC (rev 198736)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+//# sourceURL=__WebAutomationInjectedScript__
+
+(function (sessionIdentifier, evaluate, createUUID) {
+
+// Protect against Object overwritten by the page.
+let Object = {}.constructor;
+
+let AutomationSessionProxy = class AutomationSessionProxy
+{
+    // Public
+
+    // FIXME: Add functions here.
+};
+
+return new AutomationSessionProxy;
+
+})

Added: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in (0 => 198736)


--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in	2016-03-28 15:56:53 UTC (rev 198736)
@@ -0,0 +1,26 @@
+# Copyright (C) 2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+messages -> WebAutomationSessionProxy {
+    // FIXME: Add messages here.
+    Test()
+}

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (198735 => 198736)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2016-03-28 15:56:53 UTC (rev 198736)
@@ -37,6 +37,7 @@
 #include "PluginView.h"
 #include "UserData.h"
 #include "WKBundleAPICast.h"
+#include "WebAutomationSessionProxy.h"
 #include "WebBackForwardListProxy.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebDocumentLoader.h"
@@ -1579,6 +1580,9 @@
 
     webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world);
 
+    if (auto automationSessionProxy = WebProcess::singleton().automationSessionProxy())
+        automationSessionProxy->didClearWindowObjectForFrame(*m_frame);
+
 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
     // Ensure the accessibility hierarchy is updated.
     webPage->updateAccessibilityTree();

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (198735 => 198736)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2016-03-28 15:56:53 UTC (rev 198736)
@@ -41,6 +41,7 @@
 #include "SessionTracker.h"
 #include "StatisticsData.h"
 #include "UserData.h"
+#include "WebAutomationSessionProxy.h"
 #include "WebConnectionToUIProcess.h"
 #include "WebCookieManager.h"
 #include "WebCoreArgumentCoders.h"
@@ -1438,6 +1439,16 @@
 }
 #endif
 
+void WebProcess::ensureAutomationSessionProxy(const String& sessionIdentifier)
+{
+    m_automationSessionProxy = std::make_unique<WebAutomationSessionProxy>(sessionIdentifier);
+}
+
+void WebProcess::destroyAutomationSessionProxy()
+{
+    m_automationSessionProxy = nullptr;
+}
+
 void WebProcess::prefetchDNS(const String& hostname)
 {
     if (hostname.isEmpty())

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (198735 => 198736)


--- trunk/Source/WebKit2/WebProcess/WebProcess.h	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h	2016-03-28 15:56:53 UTC (rev 198736)
@@ -76,6 +76,7 @@
 class NetworkProcessConnection;
 class ObjCObjectGraph;
 class UserData;
+class WebAutomationSessionProxy;
 class WebConnectionToUIProcess;
 class WebFrame;
 class WebIconDatabaseProxy;
@@ -210,6 +211,8 @@
 
     void prefetchDNS(const String&);
 
+    WebAutomationSessionProxy* automationSessionProxy() { return m_automationSessionProxy.get(); }
+
 private:
     WebProcess();
     ~WebProcess();
@@ -284,6 +287,9 @@
     enum class ShouldAcknowledgeWhenReadyToSuspend { No, Yes };
     void actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend);
 
+    void ensureAutomationSessionProxy(const String& sessionIdentifier);
+    void destroyAutomationSessionProxy();
+
     // ChildProcess
     void initializeProcess(const ChildProcessInitializationParameters&) override;
     void initializeProcessName(const ChildProcessInitializationParameters&) override;
@@ -353,6 +359,8 @@
     HashSet<String> m_dnsPrefetchedHosts;
     WebCore::HysteresisActivity m_dnsPrefetchHystereris;
 
+    std::unique_ptr<WebAutomationSessionProxy> m_automationSessionProxy;
+
 #if ENABLE(DATABASE_PROCESS)
     void ensureWebToDatabaseProcessConnection();
     RefPtr<WebToDatabaseProcessConnection> m_webToDatabaseProcessConnection;

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (198735 => 198736)


--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in	2016-03-28 15:23:01 UTC (rev 198735)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in	2016-03-28 15:56:53 UTC (rev 198736)
@@ -92,6 +92,9 @@
     SetEnabledServices(bool hasImageServices, bool hasSelectionServices, bool hasRichContentServices)
 #endif
 
+    EnsureAutomationSessionProxy(String sessionIdentifier)
+    DestroyAutomationSessionProxy()
+
     ProcessWillSuspendImminently() -> (bool handled)
     PrepareToSuspend()
     CancelPrepareToSuspend()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to