Injected bundle messages should be at the page level.
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Apr 2015 23:22:19 +0000 (23:22 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Apr 2015 23:22:19 +0000 (23:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143283

Reviewed by Alexey Proskuryakov.

Source/WebKit2:

All the messages between the injected bundle and the UI
process should be page level messages instead of context.
The author of this patch is Tim Horton, I just finished it.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageInjectedBundleClient):
* UIProcess/API/C/WKPage.h:
* UIProcess/API/C/WKPageInjectedBundleClient.h: Added.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _pageForTesting]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/WebPageInjectedBundleClient.cpp: Added.
(WebKit::WebPageInjectedBundleClient::didReceiveMessageFromInjectedBundle):
(WebKit::WebPageInjectedBundleClient::didReceiveSynchronousMessageFromInjectedBundle):
* UIProcess/WebPageInjectedBundleClient.h: Added.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setInjectedBundleClient):
(WebKit::WebPageProxy::handleMessage):
(WebKit::WebPageProxy::handleSynchronousMessage):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::injectedBundleClient):
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::handleMessage):
* WebKit2.xcodeproj/project.pbxproj:
* CMakeLists.txt:
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePagePostMessage):
(WKBundlePagePostSynchronousMessage):
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::postMessage):
(WebKit::WebPage::postSynchronousMessage):
* WebProcess/WebPage/WebPage.h:

Tools:

Updating WebKitTestRunner to use the new page level messaging.
The author of this patch is Tim Horton, I just finished it.

* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::mouseDown):
(WTR::EventSendingController::mouseUp):
(WTR::EventSendingController::mouseMoveTo):
(WTR::EventSendingController::leapForward):
(WTR::EventSendingController::scheduleAsynchronousClick):
(WTR::EventSendingController::keyDown):
(WTR::EventSendingController::scheduleAsynchronousKeyDown):
(WTR::EventSendingController::mouseScrollBy):
(WTR::EventSendingController::mouseScrollByWithWheelAndMomentumPhases):
(WTR::EventSendingController::continuousMouseScrollBy):
(WTR::EventSendingController::addTouchPoint):
(WTR::EventSendingController::updateTouchPoint):
(WTR::EventSendingController::setTouchModifier):
(WTR::EventSendingController::setTouchPointRadius):
(WTR::EventSendingController::touchStart):
(WTR::EventSendingController::touchMove):
(WTR::EventSendingController::touchEnd):
(WTR::EventSendingController::touchCancel):
(WTR::EventSendingController::clearTouchPoints):
(WTR::EventSendingController::releaseTouchPoint):
(WTR::EventSendingController::cancelTouchPoint):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessage):
(WTR::InjectedBundle::didReceiveMessageToPage):
(WTR::InjectedBundle::done):
(WTR::InjectedBundle::outputText):
(WTR::InjectedBundle::postNewBeforeUnloadReturnValue):
(WTR::InjectedBundle::postAddChromeInputField):
(WTR::InjectedBundle::postRemoveChromeInputField):
(WTR::InjectedBundle::postFocusWebView):
(WTR::InjectedBundle::postSetBackingScaleFactor):
(WTR::InjectedBundle::postSetWindowIsKey):
(WTR::InjectedBundle::postSimulateWebNotificationClick):
(WTR::InjectedBundle::postSetAddsVisitedLinks):
(WTR::InjectedBundle::setGeolocationPermission):
(WTR::InjectedBundle::setMockGeolocationPosition):
(WTR::InjectedBundle::setMockGeolocationPositionUnavailableError):
(WTR::InjectedBundle::setUserMediaPermission):
(WTR::InjectedBundle::setCustomPolicyDelegate):
(WTR::InjectedBundle::setHidden):
(WTR::InjectedBundle::setCacheModel):
(WTR::InjectedBundle::shouldProcessWorkQueue):
(WTR::InjectedBundle::processWorkQueue):
(WTR::InjectedBundle::queueBackNavigation):
(WTR::InjectedBundle::queueForwardNavigation):
(WTR::InjectedBundle::queueLoad):
(WTR::InjectedBundle::queueLoadHTMLString):
(WTR::InjectedBundle::queueReload):
(WTR::InjectedBundle::queueLoadingScript):
(WTR::InjectedBundle::queueNonLoadingScript):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setHandlesAuthenticationChallenges):
(WTR::TestRunner::setAuthenticationUsername):
(WTR::TestRunner::setAuthenticationPassword):
(WTR::TestRunner::secureEventInputIsEnabled):
(WTR::TestRunner::setBlockAllPlugins):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions):
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::didReceivePageMessageFromInjectedBundle):
(WTR::TestController::didReceiveSynchronousPageMessageFromInjectedBundle):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::invoke):
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182260 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/API/C/WKPageInjectedBundleClient.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/WebPageInjectedBundleClient.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebPageInjectedBundleClient.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index 7b568da..e924e60 100644 (file)
@@ -374,6 +374,7 @@ set(WebKit2_SOURCES
     UIProcess/WebOriginDataManagerProxy.cpp
     UIProcess/WebPageDiagnosticLoggingClient.cpp
     UIProcess/WebPageGroup.cpp
+    UIProcess/WebPageInjectedBundleClient.cpp
     UIProcess/WebPageProxy.cpp
     UIProcess/WebPasteboardProxy.cpp
     UIProcess/WebPreferences.cpp
index 4294b72..a89a4e0 100644 (file)
@@ -1,3 +1,45 @@
+2015-04-01  Enrica Casucci  <enrica@apple.com>
+
+        Injected bundle messages should be at the page level.
+        https://bugs.webkit.org/show_bug.cgi?id=143283
+
+        Reviewed by Alexey Proskuryakov.
+
+        All the messages between the injected bundle and the UI
+        process should be page level messages instead of context.
+        The author of this patch is Tim Horton, I just finished it.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageInjectedBundleClient):
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/API/C/WKPageInjectedBundleClient.h: Added.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _pageForTesting]):
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/WebPageInjectedBundleClient.cpp: Added.
+        (WebKit::WebPageInjectedBundleClient::didReceiveMessageFromInjectedBundle):
+        (WebKit::WebPageInjectedBundleClient::didReceiveSynchronousMessageFromInjectedBundle):
+        * UIProcess/WebPageInjectedBundleClient.h: Added.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setInjectedBundleClient):
+        (WebKit::WebPageProxy::handleMessage):
+        (WebKit::WebPageProxy::handleSynchronousMessage):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::injectedBundleClient):
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::handleMessage):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * CMakeLists.txt:
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePagePostMessage):
+        (WKBundlePagePostSynchronousMessage):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::postMessage):
+        (WebKit::WebPage::postSynchronousMessage):
+        * WebProcess/WebPage/WebPage.h:
+
 2015-04-01  Alexey Proskuryakov  <ap@apple.com>
 
         [iOS] WebContent should have access to the entirety of its caches directory
index 3f62720..70ff188 100644 (file)
@@ -881,6 +881,11 @@ void WKPageSetPageFindMatchesClient(WKPageRef pageRef, const WKPageFindMatchesCl
     toImpl(pageRef)->initializeFindMatchesClient(wkClient);
 }
 
+void WKPageSetPageInjectedBundleClient(WKPageRef pageRef, const WKPageInjectedBundleClientBase* wkClient)
+{
+    toImpl(pageRef)->setInjectedBundleClient(wkClient);
+}
+
 void WKPageSetPageFormClient(WKPageRef pageRef, const WKPageFormClientBase* wkClient)
 {
     toImpl(pageRef)->setFormClient(std::make_unique<WebFormClient>(wkClient));
index 5134a06..f6a1970 100644 (file)
@@ -37,6 +37,7 @@
 #include <WebKit/WKPageFindClient.h>
 #include <WebKit/WKPageFindMatchesClient.h>
 #include <WebKit/WKPageFormClient.h>
+#include <WebKit/WKPageInjectedBundleClient.h>
 #include <WebKit/WKPageLoadTypes.h>
 #include <WebKit/WKPageLoaderClient.h>
 #include <WebKit/WKPageNavigationClient.h>
@@ -214,6 +215,7 @@ WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClientBas
 WK_EXPORT void WKPageSetPageFindMatchesClient(WKPageRef page, const WKPageFindMatchesClientBase* client);
 WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClientBase* client);
 WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClientBase* client);
+WK_EXPORT void WKPageSetPageInjectedBundleClient(WKPageRef page, const WKPageInjectedBundleClientBase* client);
 
 // A client can implement either a navigation client or loader and policy clients, but never both.
 WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClientBase* client);
diff --git a/Source/WebKit2/UIProcess/API/C/WKPageInjectedBundleClient.h b/Source/WebKit2/UIProcess/API/C/WKPageInjectedBundleClient.h
new file mode 100644 (file)
index 0000000..b22c3eb
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 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 WKPageInjectedBundleClient_h
+#define WKPageInjectedBundleClient_h
+
+#include <WebKit/WKBase.h>
+
+typedef void (*WKPageDidReceiveMessageFromInjectedBundleCallback)(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
+typedef void (*WKPageDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo);
+typedef WKTypeRef (*WKPageGetInjectedBundleInitializationUserDataCallback)(WKPageRef page, const void *clientInfo);
+
+typedef struct WKPageInjectedBundleClientBase {
+    int                                                                 version;
+    const void *                                                        clientInfo;
+} WKPageInjectedBundleClientBase;
+
+typedef struct WKPageInjectedBundleClientV0 {
+    WKPageInjectedBundleClientBase                                   base;
+
+    // Version 0.
+    WKPageDidReceiveMessageFromInjectedBundleCallback                didReceiveMessageFromInjectedBundle;
+    WKPageDidReceiveSynchronousMessageFromInjectedBundleCallback     didReceiveSynchronousMessageFromInjectedBundle;
+} WKPageInjectedBundleClientV0;
+
+#endif // WKPageInjectedBundleClient_h
index ab84a97..a5de78a 100644 (file)
@@ -620,6 +620,11 @@ static WKErrorCode callbackErrorCode(WebKit::CallbackBase::Error error)
     _page->setCustomUserAgent(customUserAgent);
 }
 
+- (WKPageRef)_pageForTesting
+{
+    return toAPI(_page.get());
+}
+
 #pragma mark iOS-specific methods
 
 #if PLATFORM(IOS)
index d4f64db..a7ac597 100644 (file)
@@ -46,6 +46,8 @@
 #define WK_WEB_VIEW_PROTOCOLS
 #endif
 
+typedef const struct OpaqueWKPage* WKPageRef;
+
 namespace WebKit {
 class ViewSnapshot;
 class WebPageProxy;
@@ -106,6 +108,8 @@ struct PrintInfo;
 @property (nonatomic, setter=_setIgnoresNonWheelEvents:) BOOL _ignoresNonWheelEvents;
 #endif
 
+- (WKPageRef)_pageForTesting;
+
 @end
 
 WKWebView* fromWebPageProxy(WebKit::WebPageProxy&);
diff --git a/Source/WebKit2/UIProcess/WebPageInjectedBundleClient.cpp b/Source/WebKit2/UIProcess/WebPageInjectedBundleClient.cpp
new file mode 100644 (file)
index 0000000..a893575
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 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 "WebPageInjectedBundleClient.h"
+
+#include "WKAPICast.h"
+#include "WebProcessPool.h"
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebPageInjectedBundleClient::didReceiveMessageFromInjectedBundle(WebPageProxy* page, const String& messageName, API::Object* messageBody)
+{
+    if (!m_client.didReceiveMessageFromInjectedBundle)
+        return;
+
+    m_client.didReceiveMessageFromInjectedBundle(toAPI(page), toAPI(messageName.impl()), toAPI(messageBody), m_client.base.clientInfo);
+}
+
+void WebPageInjectedBundleClient::didReceiveSynchronousMessageFromInjectedBundle(WebPageProxy* page, const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData)
+{
+    if (!m_client.didReceiveSynchronousMessageFromInjectedBundle)
+        return;
+
+    WKTypeRef returnDataRef = 0;
+    m_client.didReceiveSynchronousMessageFromInjectedBundle(toAPI(page), toAPI(messageName.impl()), toAPI(messageBody), &returnDataRef, m_client.base.clientInfo);
+    returnData = adoptRef(toImpl(returnDataRef));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPageInjectedBundleClient.h b/Source/WebKit2/UIProcess/WebPageInjectedBundleClient.h
new file mode 100644 (file)
index 0000000..30c7f35
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 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 WebPageInjectedBundleClient_h
+#define WebPageInjectedBundleClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include <wtf/Forward.h>
+
+namespace API {
+class Object;
+
+template<> struct ClientTraits<WKPageInjectedBundleClientBase> {
+    typedef std::tuple<WKPageInjectedBundleClientV0> Versions;
+};
+}
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebPageInjectedBundleClient : public API::Client<WKPageInjectedBundleClientBase> {
+public:
+    void didReceiveMessageFromInjectedBundle(WebPageProxy*, const String&, API::Object*);
+    void didReceiveSynchronousMessageFromInjectedBundle(WebPageProxy*, const String&, API::Object*, RefPtr<API::Object>& returnData);
+};
+
+} // namespace WebKit
+
+#endif // WebPageInjectedBundleClient_h
index 43de138..dbc36ff 100644 (file)
@@ -604,6 +604,36 @@ void WebPageProxy::setContextMenuClient(std::unique_ptr<API::ContextMenuClient>
 }
 #endif
 
+void WebPageProxy::setInjectedBundleClient(const WKPageInjectedBundleClientBase* client)
+{
+    if (!client) {
+        m_injectedBundleClient = nullptr;
+        return;
+    }
+
+    m_injectedBundleClient = std::make_unique<WebPageInjectedBundleClient>();
+    m_injectedBundleClient->initialize(client);
+}
+
+void WebPageProxy::handleMessage(IPC::Connection& connection, const String& messageName, const WebKit::UserData& messageBody)
+{
+    auto* webProcessProxy = WebProcessProxy::fromConnection(&connection);
+    if (!webProcessProxy || !m_injectedBundleClient)
+        return;
+    m_injectedBundleClient->didReceiveMessageFromInjectedBundle(this, messageName, webProcessProxy->transformHandlesToObjects(messageBody.object()).get());
+}
+
+void WebPageProxy::handleSynchronousMessage(IPC::Connection& connection, const String& messageName, const UserData& messageBody, UserData& returnUserData)
+{
+    if (!WebProcessProxy::fromConnection(&connection) || !m_injectedBundleClient)
+        return;
+
+    RefPtr<API::Object> returnData;
+    m_injectedBundleClient->didReceiveSynchronousMessageFromInjectedBundle(this, messageName, WebProcessProxy::fromConnection(&connection)->transformHandlesToObjects(messageBody.object()).get(), returnData);
+    returnUserData = UserData(WebProcessProxy::fromConnection(&connection)->transformObjectsToHandles(returnData.get()));
+}
+
+
 void WebPageProxy::reattachToWebProcess()
 {
     ASSERT(!m_isClosed);
index fca5980..2993c8b 100644 (file)
@@ -57,6 +57,7 @@
 #include "WebFrameProxy.h"
 #include "WebPageCreationParameters.h"
 #include "WebPageDiagnosticLoggingClient.h"
+#include "WebPageInjectedBundleClient.h"
 #include "WebPreferences.h"
 #include <WebCore/AlternativeTextClient.h> // FIXME: Needed by WebPageProxyMessages.h for DICTATION_ALTERNATIVES.
 #include "WebPageProxyMessages.h"
@@ -330,6 +331,8 @@ public:
     void setHistoryClient(std::unique_ptr<API::HistoryClient>);
     void setLoaderClient(std::unique_ptr<API::LoaderClient>);
     void setPolicyClient(std::unique_ptr<API::PolicyClient>);
+    void setInjectedBundleClient(const WKPageInjectedBundleClientBase*);
+    WebPageInjectedBundleClient* injectedBundleClient() { return m_injectedBundleClient.get(); }
 
     API::UIClient& uiClient() { return *m_uiClient; }
     void setUIClient(std::unique_ptr<API::UIClient>);
@@ -1414,6 +1417,9 @@ private:
 
     void handleAutoFillButtonClick(const UserData&);
 
+    void handleMessage(IPC::Connection&, const String& messageName, const UserData& messageBody);
+    void handleSynchronousMessage(IPC::Connection&, const String& messageName, const UserData& messageBody, UserData& returnUserData);
+
     PageClient& m_pageClient;
     std::unique_ptr<API::LoaderClient> m_loaderClient;
     std::unique_ptr<API::PolicyClient> m_policyClient;
@@ -1430,6 +1436,7 @@ private:
 #if ENABLE(CONTEXT_MENUS)
     std::unique_ptr<API::ContextMenuClient> m_contextMenuClient;
 #endif
+    std::unique_ptr<WebPageInjectedBundleClient> m_injectedBundleClient;
 
     std::unique_ptr<WebNavigationState> m_navigationState;
 
index b65599e..7d32713 100644 (file)
@@ -426,6 +426,8 @@ messages -> WebPageProxy {
 #if PLATFORM(MAC)
     DidPerformActionMenuHitTest(struct WebKit::ActionMenuHitTestResult result, bool forImmediateAction, WebKit::UserData userData)
 #endif
+    HandleMessage(String messageName, WebKit::UserData messageBody) WantsConnection
+    HandleSynchronousMessage(String messageName, WebKit::UserData messageBody) -> (WebKit::UserData returnData) WantsConnection
 
     HandleAutoFillButtonClick(WebKit::UserData userData);
 
index 124ef17..9277dfd 100644 (file)
@@ -1310,7 +1310,6 @@ void WebProcessPool::handleMessage(IPC::Connection& connection, const String& me
     auto* webProcessProxy = WebProcessProxy::fromConnection(&connection);
     if (!webProcessProxy)
         return;
-
     m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, messageName, webProcessProxy->transformHandlesToObjects(messageBody.object()).get());
 }
 
index 0df443a..287073d 100644 (file)
                2D8710171828415D0018FA01 /* PlatformCALayerRemoteCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */; };
                2D8949F0182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8949EE182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp */; };
                2D8949F1182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8949EF182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h */; };
+               2D9EA30D1A96CB59002D2807 /* WKPageInjectedBundleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D9EA30C1A96CB59002D2807 /* WKPageInjectedBundleClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               2D9EA30F1A96CBFF002D2807 /* WebPageInjectedBundleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D9EA30E1A96CBFF002D2807 /* WebPageInjectedBundleClient.h */; };
+               2D9EA3111A96D9EB002D2807 /* WebPageInjectedBundleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D9EA3101A96D9EB002D2807 /* WebPageInjectedBundleClient.cpp */; };
                2DA049B3180CCCD300AAFA9E /* PlatformCALayerRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */; };
                2DA049B4180CCCD300AAFA9E /* PlatformCALayerRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */; };
                2DA049B7180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DA049B5180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp */; };
                2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteCustom.h; sourceTree = "<group>"; };
                2D8949EE182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemoteTiledBacking.cpp; sourceTree = "<group>"; };
                2D8949EF182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteTiledBacking.h; sourceTree = "<group>"; };
+               2D9EA30C1A96CB59002D2807 /* WKPageInjectedBundleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageInjectedBundleClient.h; sourceTree = "<group>"; };
+               2D9EA30E1A96CBFF002D2807 /* WebPageInjectedBundleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageInjectedBundleClient.h; sourceTree = "<group>"; };
+               2D9EA3101A96D9EB002D2807 /* WebPageInjectedBundleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageInjectedBundleClient.cpp; sourceTree = "<group>"; };
                2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemote.cpp; sourceTree = "<group>"; };
                2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemote.h; sourceTree = "<group>"; };
                2DA049B5180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerCARemote.cpp; sourceTree = "<group>"; };
                                8372DB271A67562800C697C5 /* WebPageDiagnosticLoggingClient.h */,
                                BC7B6205129A0A6700D174A4 /* WebPageGroup.cpp */,
                                BC7B6204129A0A6700D174A4 /* WebPageGroup.h */,
+                               2D9EA3101A96D9EB002D2807 /* WebPageInjectedBundleClient.cpp */,
+                               2D9EA30E1A96CBFF002D2807 /* WebPageInjectedBundleClient.h */,
                                BC111B0B112F5E4F00337BAB /* WebPageProxy.cpp */,
                                BC032DCB10F4389F0058C15A /* WebPageProxy.h */,
                                BCBD38FA125BAB9A00D2C29F /* WebPageProxy.messages.in */,
                                1AB8A1EF18400B0000E9AE69 /* WKPageFormClient.h */,
                                BC7B633612A45ABA00D174A4 /* WKPageGroup.cpp */,
                                BC7B633512A45ABA00D174A4 /* WKPageGroup.h */,
+                               2D9EA30C1A96CB59002D2807 /* WKPageInjectedBundleClient.h */,
                                1AB8A1EB1840080900E9AE69 /* WKPageLoaderClient.h */,
                                2D7303781A7C2B7500F8F487 /* WKPageNavigationClient.h */,
                                1AB8A1ED18400ACB00E9AE69 /* WKPagePolicyClient.h */,
                                51BA24441858EE3000EA2811 /* AsyncTask.h in Headers */,
                                BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */,
                                E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */,
+                               2D9EA30F1A96CBFF002D2807 /* WebPageInjectedBundleClient.h in Headers */,
                                512F589712A8838800629530 /* AuthenticationChallengeProxy.h in Headers */,
                                512F589912A8838800629530 /* AuthenticationDecisionListener.h in Headers */,
                                518E8EF916B2091C00E91429 /* AuthenticationManager.h in Headers */,
                                8372DB2F1A677D4A00C697C5 /* WKDiagnosticLoggingResultType.h in Headers */,
                                1AB474E4184D44980051B622 /* WKBundlePageContextMenuClient.h in Headers */,
                                1AB474E8184D44D00051B622 /* WKBundlePageDiagnosticLoggingClient.h in Headers */,
+                               2D9EA30D1A96CB59002D2807 /* WKPageInjectedBundleClient.h in Headers */,
                                7C89D2BC1A6B0F5B003A5FDE /* _WKUserContentFilterInternal.h in Headers */,
                                1AB474E0184D446A0051B622 /* WKBundlePageEditorClient.h in Headers */,
                                1AB474E2184D44800051B622 /* WKBundlePageFormClient.h in Headers */,
                                51FB08FF1639DE1A00EC324A /* WebResourceLoadScheduler.cpp in Sources */,
                                7C361D721927FA360036A59D /* WebScriptMessageHandler.cpp in Sources */,
                                D3B9484811FF4B6500032B39 /* WebSearchPopupMenu.cpp in Sources */,
+                               2D9EA3111A96D9EB002D2807 /* WebPageInjectedBundleClient.cpp in Sources */,
                                1A53C2A91A32572B004E8C70 /* WebsiteDataStore.cpp in Sources */,
                                CEDBA84719FDA00A006866A5 /* WebSQLiteDatabaseTracker.cpp in Sources */,
                                1A52C0F71A38CDC70016160A /* WebStorageNamespaceProvider.cpp in Sources */,
index af48353..ae27fd5 100644 (file)
@@ -572,3 +572,17 @@ void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef pageRef, boo
     toImpl(pageRef)->setUseTestingViewportConfiguration(useTestingViewportConfiguration);
 }
 #endif
+
+void WKBundlePagePostMessage(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
+{
+    toImpl(pageRef)->postMessage(toWTFString(messageNameRef), toImpl(messageBodyRef));
+}
+
+void WKBundlePagePostSynchronousMessage(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef)
+{
+    RefPtr<API::Object> returnData;
+    toImpl(pageRef)->postSynchronousMessage(toWTFString(messageNameRef), toImpl(messageBodyRef), returnData);
+    if (returnDataRef)
+        *returnDataRef = toAPI(returnData.release().leakRef());
+}
+
index 59bd348..829b6a3 100644 (file)
@@ -109,6 +109,9 @@ WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
 
 WK_EXPORT bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef page);
 
+WK_EXPORT void WKBundlePagePostMessage(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody);
+WK_EXPORT void WKBundlePagePostSynchronousMessage(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData);
+
 #ifdef __cplusplus
 }
 #endif
index b5f2c4d..eb8a9dc 100644 (file)
@@ -4832,4 +4832,20 @@ void WebPage::didChangeScrollOffsetForFrame(Frame* frame)
     updateMainFrameScrollOffsetPinning();
 }
 
+void WebPage::postMessage(const String& messageName, API::Object* messageBody)
+{
+    send(Messages::WebPageProxy::HandleMessage(messageName, UserData(WebProcess::singleton().transformObjectsToHandles(messageBody))));
+}
+
+void WebPage::postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData)
+{
+    UserData returnUserData;
+
+    auto& webProcess = WebProcess::singleton();
+    if (!sendSync(Messages::WebPageProxy::HandleSynchronousMessage(messageName, UserData(webProcess.transformObjectsToHandles(messageBody))), Messages::WebPageProxy::HandleSynchronousMessage::Reply(returnUserData)))
+        returnData = nullptr;
+    else
+        returnData = webProcess.transformHandlesToObjects(returnUserData.object());
+}
+
 } // namespace WebKit
index 1aea803..b4aa379 100644 (file)
@@ -865,6 +865,9 @@ public:
 
     void setPageActivityState(WebCore::PageActivityState::Flags);
 
+    void postMessage(const String& messageName, API::Object* messageBody);
+    void postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData);
+
 private:
     WebPage(uint64_t pageID, const WebPageCreationParameters&);
 
index 2b9c6ca..259b101 100644 (file)
@@ -1,3 +1,80 @@
+2015-04-01  Enrica Casucci  <enrica@apple.com>
+
+        Injected bundle messages should be at the page level.
+        https://bugs.webkit.org/show_bug.cgi?id=143283
+
+        Reviewed by Alexey Proskuryakov.
+
+        Updating WebKitTestRunner to use the new page level messaging.
+        The author of this patch is Tim Horton, I just finished it.
+
+        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+        (WTR::EventSendingController::mouseDown):
+        (WTR::EventSendingController::mouseUp):
+        (WTR::EventSendingController::mouseMoveTo):
+        (WTR::EventSendingController::leapForward):
+        (WTR::EventSendingController::scheduleAsynchronousClick):
+        (WTR::EventSendingController::keyDown):
+        (WTR::EventSendingController::scheduleAsynchronousKeyDown):
+        (WTR::EventSendingController::mouseScrollBy):
+        (WTR::EventSendingController::mouseScrollByWithWheelAndMomentumPhases):
+        (WTR::EventSendingController::continuousMouseScrollBy):
+        (WTR::EventSendingController::addTouchPoint):
+        (WTR::EventSendingController::updateTouchPoint):
+        (WTR::EventSendingController::setTouchModifier):
+        (WTR::EventSendingController::setTouchPointRadius):
+        (WTR::EventSendingController::touchStart):
+        (WTR::EventSendingController::touchMove):
+        (WTR::EventSendingController::touchEnd):
+        (WTR::EventSendingController::touchCancel):
+        (WTR::EventSendingController::clearTouchPoints):
+        (WTR::EventSendingController::releaseTouchPoint):
+        (WTR::EventSendingController::cancelTouchPoint):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessage):
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+        (WTR::InjectedBundle::done):
+        (WTR::InjectedBundle::outputText):
+        (WTR::InjectedBundle::postNewBeforeUnloadReturnValue):
+        (WTR::InjectedBundle::postAddChromeInputField):
+        (WTR::InjectedBundle::postRemoveChromeInputField):
+        (WTR::InjectedBundle::postFocusWebView):
+        (WTR::InjectedBundle::postSetBackingScaleFactor):
+        (WTR::InjectedBundle::postSetWindowIsKey):
+        (WTR::InjectedBundle::postSimulateWebNotificationClick):
+        (WTR::InjectedBundle::postSetAddsVisitedLinks):
+        (WTR::InjectedBundle::setGeolocationPermission):
+        (WTR::InjectedBundle::setMockGeolocationPosition):
+        (WTR::InjectedBundle::setMockGeolocationPositionUnavailableError):
+        (WTR::InjectedBundle::setUserMediaPermission):
+        (WTR::InjectedBundle::setCustomPolicyDelegate):
+        (WTR::InjectedBundle::setHidden):
+        (WTR::InjectedBundle::setCacheModel):
+        (WTR::InjectedBundle::shouldProcessWorkQueue):
+        (WTR::InjectedBundle::processWorkQueue):
+        (WTR::InjectedBundle::queueBackNavigation):
+        (WTR::InjectedBundle::queueForwardNavigation):
+        (WTR::InjectedBundle::queueLoad):
+        (WTR::InjectedBundle::queueLoadHTMLString):
+        (WTR::InjectedBundle::queueReload):
+        (WTR::InjectedBundle::queueLoadingScript):
+        (WTR::InjectedBundle::queueNonLoadingScript):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setHandlesAuthenticationChallenges):
+        (WTR::TestRunner::setAuthenticationUsername):
+        (WTR::TestRunner::setAuthenticationPassword):
+        (WTR::TestRunner::secureEventInputIsEnabled):
+        (WTR::TestRunner::setBlockAllPlugins):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createWebViewWithOptions):
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::didReceivePageMessageFromInjectedBundle):
+        (WTR::TestController::didReceiveSynchronousPageMessageFromInjectedBundle):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::invoke):
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
 2015-04-01  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r182174 and r182177.
index 2e01064..89c5a6c 100644 (file)
@@ -208,8 +208,8 @@ static WKMutableDictionaryRef createMouseMessageBody(MouseState state, int butto
 
 void EventSendingController::mouseDown(int button, JSValueRef modifierArray) 
 {
-    auto& injectedBungle = InjectedBundle::singleton();
-    WKBundlePageRef page = injectedBungle.page()->page();
+    auto& injectedBundle = InjectedBundle::singleton();
+    WKBundlePageRef page = injectedBundle.page()->page();
     WKBundleFrameRef frame = WKBundlePageGetMainFrame(page);
     JSContextRef context = WKBundleFrameGetJavaScriptContext(frame);
     WKEventModifiers modifiers = parseModifierArray(context, modifierArray);
@@ -217,7 +217,7 @@ void EventSendingController::mouseDown(int button, JSValueRef modifierArray)
     WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
     WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, createMouseMessageBody(MouseDown, button, modifiers));
 
-    WKBundlePostSynchronousMessage(injectedBungle.bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(page, EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::mouseUp(int button, JSValueRef modifierArray)
@@ -230,7 +230,7 @@ void EventSendingController::mouseUp(int button, JSValueRef modifierArray)
     WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
     WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, createMouseMessageBody(MouseUp, button, modifiers));
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::mouseMoveTo(int x, int y)
@@ -250,7 +250,7 @@ void EventSendingController::mouseMoveTo(int x, int y)
     WKRetainPtr<WKDoubleRef> yRef(AdoptWK, WKDoubleCreate(y));
     WKDictionarySetItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::leapForward(int milliseconds)
@@ -266,7 +266,7 @@ void EventSendingController::leapForward(int milliseconds)
     WKRetainPtr<WKUInt64Ref> timeRef(AdoptWK, WKUInt64Create(milliseconds));
     WKDictionarySetItem(EventSenderMessageBody.get(), timeKey.get(), timeRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::scheduleAsynchronousClick()
@@ -278,11 +278,11 @@ void EventSendingController::scheduleAsynchronousClick()
 
     // Asynchronous mouse down.
     WKRetainPtr<WKMutableDictionaryRef> mouseDownMessageBody(AdoptWK, createMouseMessageBody(MouseDown, button, modifiers));
-    WKBundlePostMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), mouseDownMessageBody.get());
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), mouseDownMessageBody.get());
 
     // Asynchronous mouse up.
     WKRetainPtr<WKMutableDictionaryRef> mouseUpMessageBody(AdoptWK, createMouseMessageBody(MouseUp, button, modifiers));
-    WKBundlePostMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), mouseUpMessageBody.get());
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), mouseUpMessageBody.get());
 }
 
 static WKRetainPtr<WKMutableDictionaryRef> createKeyDownMessageBody(JSStringRef key, WKEventModifiers modifiers, int location)
@@ -317,7 +317,7 @@ void EventSendingController::keyDown(JSStringRef key, JSValueRef modifierArray,
     WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
     WKRetainPtr<WKMutableDictionaryRef> keyDownMessageBody = createKeyDownMessageBody(key, modifiers, location);
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), keyDownMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), keyDownMessageBody.get(), 0);
 }
 
 void EventSendingController::scheduleAsynchronousKeyDown(JSStringRef key)
@@ -325,7 +325,7 @@ void EventSendingController::scheduleAsynchronousKeyDown(JSStringRef key)
     WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
     WKRetainPtr<WKMutableDictionaryRef> keyDownMessageBody = createKeyDownMessageBody(key, 0 /* modifiers */, 0 /* location */);
 
-    WKBundlePostMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), keyDownMessageBody.get());
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), keyDownMessageBody.get());
 }
 
 void EventSendingController::mouseScrollBy(int x, int y)
@@ -345,7 +345,7 @@ void EventSendingController::mouseScrollBy(int x, int y)
     WKRetainPtr<WKDoubleRef> yRef(AdoptWK, WKDoubleCreate(y));
     WKDictionarySetItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::mouseScrollByWithWheelAndMomentumPhases(int x, int y, JSStringRef phaseStr, JSStringRef momentumStr, bool asyncScrolling)
@@ -398,9 +398,9 @@ void EventSendingController::mouseScrollByWithWheelAndMomentumPhases(int x, int
     WKDictionarySetItem(EventSenderMessageBody.get(), momentumKey.get(), momentumRef.get());
 
     if (asyncScrolling)
-        WKBundlePostMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get());
+        WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get());
     else
-        WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+        WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::continuousMouseScrollBy(int x, int y, bool paged)
@@ -424,7 +424,7 @@ void EventSendingController::continuousMouseScrollBy(int x, int y, bool paged)
     WKRetainPtr<WKUInt64Ref> pagedRef(AdoptWK, WKUInt64Create(paged));
     WKDictionarySetItem(EventSenderMessageBody.get(), pagedKey.get(), pagedRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 JSValueRef EventSendingController::contextClick()
@@ -519,7 +519,7 @@ void EventSendingController::addTouchPoint(int x, int y)
     WKRetainPtr<WKUInt64Ref> yRef(AdoptWK, WKUInt64Create(y));
     WKDictionarySetItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::updateTouchPoint(int index, int x, int y)
@@ -543,7 +543,7 @@ void EventSendingController::updateTouchPoint(int index, int x, int y)
     WKRetainPtr<WKUInt64Ref> yRef(AdoptWK, WKUInt64Create(y));
     WKDictionarySetItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::setTouchModifier(const JSStringRef &modifier, bool enable)
@@ -573,7 +573,7 @@ void EventSendingController::setTouchModifier(const JSStringRef &modifier, bool
     WKRetainPtr<WKUInt64Ref> enableRef(AdoptWK, WKUInt64Create(enable));
     WKDictionarySetItem(EventSenderMessageBody.get(), enableKey.get(), enableRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 
@@ -594,7 +594,7 @@ void EventSendingController::setTouchPointRadius(int radiusX, int radiusY)
     WKRetainPtr<WKUInt64Ref> yRef(AdoptWK, WKUInt64Create(radiusY));
     WKDictionarySetItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::touchStart()
@@ -606,7 +606,7 @@ void EventSendingController::touchStart()
     WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("TouchStart"));
     WKDictionarySetItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::touchMove()
@@ -618,7 +618,7 @@ void EventSendingController::touchMove()
     WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("TouchMove"));
     WKDictionarySetItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::touchEnd()
@@ -630,7 +630,7 @@ void EventSendingController::touchEnd()
     WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("TouchEnd"));
     WKDictionarySetItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::touchCancel()
@@ -642,7 +642,7 @@ void EventSendingController::touchCancel()
     WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("TouchCancel"));
     WKDictionarySetItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::clearTouchPoints()
@@ -654,7 +654,7 @@ void EventSendingController::clearTouchPoints()
     WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("ClearTouchPoints"));
     WKDictionarySetItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::releaseTouchPoint(int index)
@@ -670,7 +670,7 @@ void EventSendingController::releaseTouchPoint(int index)
     WKRetainPtr<WKUInt64Ref> indexRef(AdoptWK, WKUInt64Create(index));
     WKDictionarySetItem(EventSenderMessageBody.get(), indexKey.get(), indexRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 
 void EventSendingController::cancelTouchPoint(int index)
@@ -686,7 +686,7 @@ void EventSendingController::cancelTouchPoint(int index)
     WKRetainPtr<WKUInt64Ref> indexRef(AdoptWK, WKUInt64Create(index));
     WKDictionarySetItem(EventSenderMessageBody.get(), indexKey.get(), indexRef.get());
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0);
 }
 #endif
 
index 8cfccf0..b2eef36 100644 (file)
@@ -133,6 +133,13 @@ void InjectedBundle::resetLocalSettings()
 
 void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
 {
+    WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error"));
+    WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown"));
+    WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get());
+}
+
+void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody)
+{
     if (WKStringIsEqualToUTF8CString(messageName, "BeginTest")) {
         ASSERT(messageBody);
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
@@ -149,12 +156,12 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
 
         WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack"));
         WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest"));
-        WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());
+        WKBundlePagePostMessage(page, ackMessageName.get(), ackMessageBody.get());
 
         beginTesting(messageBodyDictionary);
         return;
     }
-    
+
     if (WKStringIsEqualToUTF8CString(messageName, "Reset")) {
         ASSERT(messageBody);
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
@@ -183,7 +190,7 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
         resetLocalSettings();
         m_testRunner->removeAllWebNotificationPermissions();
 
-        page()->resetAfterTest();
+        InjectedBundle::page()->resetAfterTest();
 
         return;
     }
@@ -206,24 +213,17 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
     if (WKStringIsEqualToUTF8CString(messageName, "CallSetBackingScaleFactorCallback")) {
         m_testRunner->callSetBackingScaleFactorCallback();
         return;
-    }   
+    }
 
     if (WKStringIsEqualToUTF8CString(messageName, "WorkQueueProcessedCallback")) {
         if (!topLoadingFrame() && !m_testRunner->waitToDump())
-            page()->dump();
+            InjectedBundle::page()->dump();
         return;
     }
 
     WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error"));
     WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown"));
-    WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get());
-}
-
-void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody)
-{
-    WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error"));
-    WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown"));
-    WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get());
+    WKBundlePagePostMessage(page, errorMessageName.get(), errorMessageBody.get());
 }
 
 bool InjectedBundle::booleanForKey(WKDictionaryRef dictionary, const char* key)
@@ -310,7 +310,7 @@ void InjectedBundle::done()
     WKRetainPtr<WKStringRef> audioResultKey = adoptWK(WKStringCreateWithUTF8CString("AudioResult"));
     WKDictionarySetItem(doneMessageBody.get(), audioResultKey.get(), m_audioResult.get());
 
-    WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
+    WKBundlePagePostMessage(page()->page(), doneMessageName.get(), doneMessageBody.get());
 
     closeOtherPages();
 
@@ -343,67 +343,67 @@ void InjectedBundle::outputText(const String& output)
         return;
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("TextOutput"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithUTF8CString(output.utf8().data()));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::postNewBeforeUnloadReturnValue(bool value)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("BeforeUnloadReturnValue"));
     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::postAddChromeInputField()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("AddChromeInputField"));
-    WKBundlePostMessage(m_bundle, messageName.get(), 0);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), 0);
 }
 
 void InjectedBundle::postRemoveChromeInputField()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("RemoveChromeInputField"));
-    WKBundlePostMessage(m_bundle, messageName.get(), 0);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), 0);
 }
 
 void InjectedBundle::postFocusWebView()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("FocusWebView"));
-    WKBundlePostMessage(m_bundle, messageName.get(), 0);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), 0);
 }
 
 void InjectedBundle::postSetBackingScaleFactor(double backingScaleFactor)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetBackingScaleFactor"));
     WKRetainPtr<WKDoubleRef> messageBody(AdoptWK, WKDoubleCreate(backingScaleFactor));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::postSetWindowIsKey(bool isKey)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetWindowIsKey"));
     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(isKey));
-    WKBundlePostSynchronousMessage(m_bundle, messageName.get(), messageBody.get(), 0);
+    WKBundlePagePostSynchronousMessage(page()->page(), messageName.get(), messageBody.get(), 0);
 }
 
 void InjectedBundle::postSimulateWebNotificationClick(uint64_t notificationID)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SimulateWebNotificationClick"));
     WKRetainPtr<WKUInt64Ref> messageBody(AdoptWK, WKUInt64Create(notificationID));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::postSetAddsVisitedLinks(bool addsVisitedLinks)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAddsVisitedLinks"));
     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(addsVisitedLinks));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::setGeolocationPermission(bool enabled)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetGeolocationPermission"));
     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(enabled));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
@@ -456,20 +456,20 @@ void InjectedBundle::setMockGeolocationPosition(double latitude, double longitud
     WKRetainPtr<WKDoubleRef> speedWK(AdoptWK, WKDoubleCreate(speed));
     WKDictionarySetItem(messageBody.get(), speedKeyWK.get(), speedWK.get());
 
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::setMockGeolocationPositionUnavailableError(WKStringRef errorMessage)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGeolocationPositionUnavailableError"));
-    WKBundlePostMessage(m_bundle, messageName.get(), errorMessage);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), errorMessage);
 }
 
 void InjectedBundle::setUserMediaPermission(bool enabled)
 {
     auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetUserMediaPermission"));
     auto messageBody = adoptWK(WKBooleanCreate(enabled));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::setCustomPolicyDelegate(bool enabled, bool permissive)
@@ -486,7 +486,7 @@ void InjectedBundle::setCustomPolicyDelegate(bool enabled, bool permissive)
     WKRetainPtr<WKBooleanRef> permissiveWK(AdoptWK, WKBooleanCreate(permissive));
     WKDictionarySetItem(messageBody.get(), permissiveKeyWK.get(), permissiveWK.get());
 
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::setHidden(bool hidden)
@@ -498,14 +498,14 @@ void InjectedBundle::setHidden(bool hidden)
     WKRetainPtr<WKBooleanRef> isInitialWK(AdoptWK, WKBooleanCreate(hidden));
     WKDictionarySetItem(messageBody.get(), isInitialKeyWK.get(), isInitialWK.get());
 
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::setCacheModel(int model)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetCacheModel"));
     WKRetainPtr<WKUInt64Ref> messageBody(AdoptWK, WKUInt64Create(model));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 bool InjectedBundle::shouldProcessWorkQueue() const
@@ -515,7 +515,7 @@ bool InjectedBundle::shouldProcessWorkQueue() const
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsWorkQueueEmpty"));
     WKTypeRef resultToPass = 0;
-    WKBundlePostSynchronousMessage(m_bundle, messageName.get(), 0, &resultToPass);
+    WKBundlePagePostSynchronousMessage(page()->page(), messageName.get(), 0, &resultToPass);
     WKRetainPtr<WKBooleanRef> isEmpty(AdoptWK, static_cast<WKBooleanRef>(resultToPass));
 
     return !WKBooleanGetValue(isEmpty.get());
@@ -524,7 +524,7 @@ bool InjectedBundle::shouldProcessWorkQueue() const
 void InjectedBundle::processWorkQueue()
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ProcessWorkQueue"));
-    WKBundlePostMessage(m_bundle, messageName.get(), 0);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), 0);
 }
 
 void InjectedBundle::queueBackNavigation(unsigned howFarBackward)
@@ -533,7 +533,7 @@ void InjectedBundle::queueBackNavigation(unsigned howFarBackward)
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueBackNavigation"));
     WKRetainPtr<WKUInt64Ref> messageBody(AdoptWK, WKUInt64Create(howFarBackward));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::queueForwardNavigation(unsigned howFarForward)
@@ -542,7 +542,7 @@ void InjectedBundle::queueForwardNavigation(unsigned howFarForward)
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueForwardNavigation"));
     WKRetainPtr<WKUInt64Ref> messageBody(AdoptWK, WKUInt64Create(howFarForward));
-    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
 void InjectedBundle::queueLoad(WKStringRef url, WKStringRef target)
@@ -559,7 +559,7 @@ void InjectedBundle::queueLoad(WKStringRef url, WKStringRef target)
     WKRetainPtr<WKStringRef> targetKey(AdoptWK, WKStringCreateWithUTF8CString("target"));
     WKDictionarySetItem(loadData.get(), targetKey.get(), target);
 
-    WKBundlePostMessage(m_bundle, messageName.get(), loadData.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), loadData.get());
 }
 
 void InjectedBundle::queueLoadHTMLString(WKStringRef content, WKStringRef baseURL, WKStringRef unreachableURL)
@@ -583,7 +583,7 @@ void InjectedBundle::queueLoadHTMLString(WKStringRef content, WKStringRef baseUR
         WKDictionarySetItem(loadData.get(), unreachableURLKey.get(), unreachableURL);
     }
 
-    WKBundlePostMessage(m_bundle, messageName.get(), loadData.get());
+    WKBundlePagePostMessage(page()->page(), messageName.get(), loadData.get());
 }
 
 void InjectedBundle::queueReload()
@@ -591,7 +591,7 @@ void InjectedBundle::queueReload()
     m_useWorkQueue = true;
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueReload"));
-    WKBundlePostMessage(m_bundle, messageName.get(), 0);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), 0);
 }
 
 void InjectedBundle::queueLoadingScript(WKStringRef script)
@@ -599,7 +599,7 @@ void InjectedBundle::queueLoadingScript(WKStringRef script)
     m_useWorkQueue = true;
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueLoadingScript"));
-    WKBundlePostMessage(m_bundle, messageName.get(), script);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), script);
 }
 
 void InjectedBundle::queueNonLoadingScript(WKStringRef script)
@@ -607,7 +607,7 @@ void InjectedBundle::queueNonLoadingScript(WKStringRef script)
     m_useWorkQueue = true;
 
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueNonLoadingScript"));
-    WKBundlePostMessage(m_bundle, messageName.get(), script);
+    WKBundlePagePostMessage(page()->page(), messageName.get(), script);
 }
 
 bool InjectedBundle::isAllowedHost(WKStringRef host)
index 285f59b..09d7aa2 100644 (file)
@@ -804,21 +804,21 @@ void TestRunner::setHandlesAuthenticationChallenges(bool handlesAuthenticationCh
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetHandlesAuthenticationChallenge"));
     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(handlesAuthenticationChallenges));
-    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
 }
 
 void TestRunner::setAuthenticationUsername(JSStringRef username)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAuthenticationUsername"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(username));
-    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
 }
 
 void TestRunner::setAuthenticationPassword(JSStringRef password)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAuthenticationPassword"));
     WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithJSString(password));
-    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
 }
 
 bool TestRunner::secureEventInputIsEnabled() const
@@ -826,7 +826,7 @@ bool TestRunner::secureEventInputIsEnabled() const
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SecureEventInputIsEnabled"));
     WKTypeRef returnData = 0;
 
-    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, &returnData);
+    WKBundlePagePostSynchronousMessage(InjectedBundle::singleton().page()->page(), messageName.get(), 0, &returnData);
     return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
 }
 
@@ -834,7 +834,7 @@ void TestRunner::setBlockAllPlugins(bool shouldBlock)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetBlockAllPlugins"));
     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(shouldBlock));
-    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
 }
 
 JSValueRef TestRunner::numberOfDFGCompiles(JSValueRef theFunction)
index f943d28..2cc4237 100644 (file)
@@ -44,6 +44,7 @@
 #include <WebKit/WKNotificationPermissionRequest.h>
 #include <WebKit/WKNumber.h>
 #include <WebKit/WKPageGroup.h>
+#include <WebKit/WKPageInjectedBundleClient.h>
 #include <WebKit/WKPagePrivate.h>
 #include <WebKit/WKPreferencesRefPrivate.h>
 #include <WebKit/WKProtectionSpace.h>
@@ -521,6 +522,15 @@ void TestController::createWebViewWithOptions(WKDictionaryRef options)
     };
     WKPageSetPageNavigationClient(m_mainWebView->page(), &pageNavigationClient.base);
 
+
+    // this should just be done on the page?
+    WKPageInjectedBundleClientV0 injectedBundleClient = {
+        { 0, this },
+        didReceivePageMessageFromInjectedBundle,
+        didReceiveSynchronousPageMessageFromInjectedBundle
+    };
+    WKPageSetPageInjectedBundleClient(m_mainWebView->page(), &injectedBundleClient.base);
+
     m_mainWebView->didInitializeClients();
 
     // Generally, the tests should default to running at 1x. updateWindowScaleForTest() will adjust the scale to
@@ -621,7 +631,7 @@ bool TestController::resetStateToConsistentValues()
     }
     WKDictionarySetItem(resetMessageBody.get(), allowedHostsKey.get(), allowedHostsValue.get());
 
-    WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), resetMessageBody.get());
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), resetMessageBody.get());
 
     WKContextSetShouldUseFontSmoothing(TestController::singleton().context(), false);
 
@@ -947,6 +957,18 @@ void TestController::didReceiveSynchronousMessageFromInjectedBundle(WKContextRef
     *returnData = static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody).leakRef();
 }
 
+// WKPageInjectedBundleClient
+
+void TestController::didReceivePageMessageFromInjectedBundle(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
+{
+    static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(messageName, messageBody);
+}
+
+void TestController::didReceiveSynchronousPageMessageFromInjectedBundle(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void* clientInfo)
+{
+    *returnData = static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody).leakRef();
+}
+
 void TestController::networkProcessDidCrash(WKContextRef context, const void *clientInfo)
 {
     static_cast<TestController*>(const_cast<void*>(clientInfo))->networkProcessDidCrash();
index 5675aef..1f89e03 100644 (file)
@@ -146,6 +146,10 @@ private:
     // WKContextInjectedBundleClient
     static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
     static void didReceiveSynchronousMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void*);
+
+    // WKPageInjectedBundleClient
+    static void didReceivePageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
+    static void didReceiveSynchronousPageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void*);
     void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
     WKRetainPtr<WKTypeRef> didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
 
index 712b6ff..9e0185c 100644 (file)
@@ -175,7 +175,7 @@ void TestInvocation::invoke()
     WKRetainPtr<WKUInt64Ref> timeoutValue = adoptWK(WKUInt64Create(m_timeout));
     WKDictionarySetItem(beginTestMessageBody.get(), timeoutKey.get(), timeoutValue.get());
 
-    WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), beginTestMessageBody.get());
+    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), beginTestMessageBody.get());
 
     TestController::singleton().runUntil(m_gotInitialResponse, TestController::shortTimeout);
     if (!m_gotInitialResponse) {
@@ -369,21 +369,21 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
     if (WKStringIsEqualToUTF8CString(messageName, "AddChromeInputField")) {
         TestController::singleton().mainWebView()->addChromeInputField();
         WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallAddChromeInputFieldCallback"));
-        WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), 0);
+        WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
         return;
     }
 
     if (WKStringIsEqualToUTF8CString(messageName, "RemoveChromeInputField")) {
         TestController::singleton().mainWebView()->removeChromeInputField();
         WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallRemoveChromeInputFieldCallback"));
-        WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), 0);
+        WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
         return;
     }
     
     if (WKStringIsEqualToUTF8CString(messageName, "FocusWebView")) {
         TestController::singleton().mainWebView()->makeWebViewFirstResponder();
         WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallFocusWebViewCallback"));
-        WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), 0);
+        WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
         return;
     }
 
@@ -393,7 +393,7 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         WKPageSetCustomBackingScaleFactor(TestController::singleton().mainWebView()->page(), backingScaleFactor);
 
         WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallSetBackingScaleFactorCallback"));
-        WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), 0);
+        WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
         return;
     }
 
@@ -522,7 +522,7 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
     if (WKStringIsEqualToUTF8CString(messageName, "ProcessWorkQueue")) {
         if (TestController::singleton().workQueueManager().processWorkQueue()) {
             WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("WorkQueueProcessedCallback"));
-            WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), 0);
+            WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
         }
         return;
     }