[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
weinig at apple.com
weinig at apple.com
Wed Dec 22 11:37:06 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 5a7304b8addae9538732ad8b9c33726c36cf8827
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jul 31 01:58:28 2010 +0000
Patch for https://bugs.webkit.org/show_bug.cgi?id=43290
Add structured message passing from the injected bundle to UIProcess
Reviewed by Maciej Stachowiak.
WebKit2:
* Platform/CoreIPC/MessageID.h:
* Shared/CoreIPCSupport/WebContextMessageKinds.h: Added.
* Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h:
(WebProcessProxyMessage::):
* UIProcess/API/C/WKContext.h:
* UIProcess/WebContext.cpp:
(WebKit::):
(WebKit::PostMessageEncoder::PostMessageDecoder::PostMessageDecoder):
(WebKit::PostMessageEncoder::PostMessageDecoder::decode):
(WebKit::WebContext::didReceiveMessageFromInjectedBundle):
(WebKit::WebContext::didReceiveMessage):
* UIProcess/WebContext.h:
* UIProcess/WebContextInjectedBundleClient.cpp:
(WebKit::WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle):
* UIProcess/WebContextInjectedBundleClient.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didReceiveMessage):
(WebKit::WebProcessProxy::didReceiveSyncMessage):
* UIProcess/WebProcessProxy.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundlePostMessage):
* WebProcess/InjectedBundle/API/c/WKBundle.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::):
(WebKit::InjectedBundle::InjectedBundle):
(WebKit::InjectedBundle::~InjectedBundle):
(WebKit::InjectedBundle::initializeClient):
(WebKit::InjectedBundle::postMessage):
(WebKit::InjectedBundle::setShouldTrackVisitedLinks):
(WebKit::InjectedBundle::removeAllVisitedLinks):
(WebKit::InjectedBundle::didCreatePage):
(WebKit::InjectedBundle::willDestroyPage):
(WebKit::InjectedBundle::didReceiveMessage):
* WebProcess/InjectedBundle/InjectedBundle.h:
WebKitTools:
* MiniBrowser/mac/AppDelegate.m:
(didRecieveMessageFromInjectedBundle):
* MiniBrowser/mac/WebBundle/WebBundleMain.m:
(didClearWindowForFrame):
(didRecieveMessage):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::done):
(WTR::InjectedBundle::didReceiveMessage):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
(WTR::TestController::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/TestInvocation.h:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index d64602d..39e2af0 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,46 @@
+2010-07-30 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Maciej Stachowiak.
+
+ Patch for https://bugs.webkit.org/show_bug.cgi?id=43290
+ Add structured message passing from the injected bundle to UIProcess
+
+ * Platform/CoreIPC/MessageID.h:
+ * Shared/CoreIPCSupport/WebContextMessageKinds.h: Added.
+ * Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h:
+ (WebProcessProxyMessage::):
+ * UIProcess/API/C/WKContext.h:
+ * UIProcess/WebContext.cpp:
+ (WebKit::):
+ (WebKit::PostMessageEncoder::PostMessageDecoder::PostMessageDecoder):
+ (WebKit::PostMessageEncoder::PostMessageDecoder::decode):
+ (WebKit::WebContext::didReceiveMessageFromInjectedBundle):
+ (WebKit::WebContext::didReceiveMessage):
+ * UIProcess/WebContext.h:
+ * UIProcess/WebContextInjectedBundleClient.cpp:
+ (WebKit::WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle):
+ * UIProcess/WebContextInjectedBundleClient.h:
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::didReceiveMessage):
+ (WebKit::WebProcessProxy::didReceiveSyncMessage):
+ * UIProcess/WebProcessProxy.h:
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+ (WKBundlePostMessage):
+ * WebProcess/InjectedBundle/API/c/WKBundle.h:
+ * WebProcess/InjectedBundle/InjectedBundle.cpp:
+ (WebKit::):
+ (WebKit::InjectedBundle::InjectedBundle):
+ (WebKit::InjectedBundle::~InjectedBundle):
+ (WebKit::InjectedBundle::initializeClient):
+ (WebKit::InjectedBundle::postMessage):
+ (WebKit::InjectedBundle::setShouldTrackVisitedLinks):
+ (WebKit::InjectedBundle::removeAllVisitedLinks):
+ (WebKit::InjectedBundle::didCreatePage):
+ (WebKit::InjectedBundle::willDestroyPage):
+ (WebKit::InjectedBundle::didReceiveMessage):
+ * WebProcess/InjectedBundle/InjectedBundle.h:
+
2010-07-30 Andy Estes <aestes at apple.com>
Reviewed by David Kilzer.
diff --git a/WebKit2/Platform/CoreIPC/MessageID.h b/WebKit2/Platform/CoreIPC/MessageID.h
index e314670..0b0f893 100644
--- a/WebKit2/Platform/CoreIPC/MessageID.h
+++ b/WebKit2/Platform/CoreIPC/MessageID.h
@@ -41,6 +41,7 @@ enum MessageClass {
MessageClassDrawingArea,
// Messages sent by the web process to the UI process.
+ MessageClassWebContext,
MessageClassWebProcessProxy,
MessageClassWebPageProxy,
MessageClassDrawingAreaProxy
diff --git a/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h
new file mode 100644
index 0000000..4f6ea1b
--- /dev/null
+++ b/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 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 WebContextMessageKinds_h
+#define WebContextMessageKinds_h
+
+// Messages sent from the injected bundle to the WebContext.
+
+#include "MessageID.h"
+
+namespace WebContextMessage {
+
+enum Kind {
+ PostMessage
+};
+
+}
+
+namespace CoreIPC {
+
+template<> struct MessageKindTraits<WebContextMessage::Kind> {
+ static const MessageClass messageClass = MessageClassWebContext;
+};
+
+}
+
+#endif // InjectedBundleMessageKinds_h
diff --git a/WebKit2/Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h
index fbc9522..ddf9fde 100644
--- a/WebKit2/Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h
+++ b/WebKit2/Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h
@@ -41,7 +41,6 @@ enum Kind {
GetPluginHostConnection,
GetPlugins,
PopulateVisitedLinks,
- PostMessage,
};
}
diff --git a/WebKit2/UIProcess/API/C/WKContext.h b/WebKit2/UIProcess/API/C/WKContext.h
index 3232d47..2345550 100644
--- a/WebKit2/UIProcess/API/C/WKContext.h
+++ b/WebKit2/UIProcess/API/C/WKContext.h
@@ -33,7 +33,7 @@ extern "C" {
#endif
// Injected Bundle Client
-typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef message, const void *clientInfo);
+typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
struct WKContextInjectedBundleClient {
int version;
diff --git a/WebKit2/UIProcess/WebContext.cpp b/WebKit2/UIProcess/WebContext.cpp
index 254e75b..6c5f15d 100644
--- a/WebKit2/UIProcess/WebContext.cpp
+++ b/WebKit2/UIProcess/WebContext.cpp
@@ -28,12 +28,14 @@
#include "ImmutableArray.h"
#include "InjectedBundleMessageKinds.h"
#include "RunLoop.h"
+#include "WebContextMessageKinds.h"
#include "WebCoreArgumentCoders.h"
#include "WebPageNamespace.h"
#include "WebPreferences.h"
#include "WebProcessManager.h"
#include "WebProcessMessageKinds.h"
#include "WebProcessProxy.h"
+#include <wtf/OwnArrayPtr.h>
#include "WKContextPrivate.h"
@@ -45,6 +47,125 @@ using namespace WebCore;
namespace WebKit {
+namespace {
+
+// FIXME: We should try to abstract out the shared logic from these and
+// and the PostMessageEncoder/PostMessageDecoders in InjectedBundle.cpp into
+// a shared baseclass.
+
+// Encodes postMessage messages from the UIProcess -> InjectedBundle
+
+// - Array -> Array
+// - String -> String
+// - Page -> BundlePage
+
+class PostMessageEncoder {
+public:
+ PostMessageEncoder(APIObject* root)
+ : m_root(root)
+ {
+ }
+
+ void encode(CoreIPC::ArgumentEncoder& encoder) const
+ {
+ APIObject::Type type = m_root->type();
+ encoder.encode(static_cast<uint32_t>(type));
+ switch (type) {
+ case APIObject::TypeArray: {
+ ImmutableArray* array = static_cast<ImmutableArray*>(m_root);
+ encoder.encode(static_cast<uint64_t>(array->size()));
+ for (size_t i = 0; i < array->size(); ++i)
+ encoder.encode(PostMessageEncoder(array->at(i)));
+ break;
+ }
+ case APIObject::TypeString: {
+ WebString* string = static_cast<WebString*>(m_root);
+ encoder.encode(string->string());
+ break;
+ }
+ case APIObject::TypePage: {
+ WebPageProxy* page = static_cast<WebPageProxy*>(m_root);
+ encoder.encode(page->pageID());
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+private:
+ APIObject* m_root;
+};
+
+// Decodes postMessage messages going from the InjectedBundle -> UIProcess
+
+// - Array -> Array
+// - String -> String
+// - BundlePage -> Page
+
+class PostMessageDecoder {
+public:
+ PostMessageDecoder(APIObject** root, WebContext* context)
+ : m_root(root)
+ , m_context(context)
+ {
+ }
+
+ static bool decode(CoreIPC::ArgumentDecoder& decoder, PostMessageDecoder& coder)
+ {
+ uint32_t type;
+ if (!decoder.decode(type))
+ return false;
+
+ switch (type) {
+ case APIObject::TypeArray: {
+ uint64_t size;
+ if (!decoder.decode(size))
+ return false;
+
+ OwnArrayPtr<APIObject*> array;
+ array.set(new APIObject*[size]);
+
+ for (size_t i = 0; i < size; ++i) {
+ APIObject* element;
+ PostMessageDecoder messageCoder(&element, coder.m_context);
+ if (!decoder.decode(messageCoder))
+ return false;
+ array[i] = element;
+ }
+
+ *(coder.m_root) = ImmutableArray::create(array.release(), size).leakRef();
+ break;
+ }
+ case APIObject::TypeString: {
+ String string;
+ if (!decoder.decode(string))
+ return false;
+ *(coder.m_root) = WebString::create(string).leakRef();
+ break;
+ }
+ case APIObject::TypeBundlePage: {
+ uint64_t pageID;
+ if (!decoder.decode(pageID))
+ return false;
+ *(coder.m_root) = coder.m_context->process()->webPage(pageID);
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+private:
+ APIObject** m_root;
+ WebContext* m_context;
+};
+
+}
+
#ifndef NDEBUG
static WTF::RefCountedLeakCounter webContextCounter("WebContext");
#endif
@@ -167,55 +288,6 @@ void WebContext::preferencesDidChange()
}
}
-namespace {
-
-// Encodes postMessage messages from the UIProcess -> InjectedBundle
-
-// - Array -> Array
-// - String -> String
-// - Page -> BundlePage
-
-class PostMessageEncoder {
-public:
- PostMessageEncoder(APIObject* root)
- : m_root(root)
- {
- }
-
- void encode(CoreIPC::ArgumentEncoder& encoder) const
- {
- APIObject::Type type = m_root->type();
- encoder.encode(static_cast<uint32_t>(type));
- switch (type) {
- case APIObject::TypeArray: {
- ImmutableArray* array = static_cast<ImmutableArray*>(m_root);
- encoder.encode(static_cast<uint64_t>(array->size()));
- for (size_t i = 0; i < array->size(); ++i)
- encoder.encode(PostMessageEncoder(array->at(i)));
- break;
- }
- case APIObject::TypeString: {
- WebString* string = static_cast<WebString*>(m_root);
- encoder.encode(string->string());
- break;
- }
- case APIObject::TypePage: {
- WebPageProxy* page = static_cast<WebPageProxy*>(m_root);
- encoder.encode(page->pageID());
- break;
- }
- default:
- ASSERT_NOT_REACHED();
- break;
- }
- }
-
-private:
- APIObject* m_root;
-};
-
-}
-
void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
{
if (!m_process)
@@ -228,9 +300,9 @@ void WebContext::postMessageToInjectedBundle(const String& messageName, APIObjec
// InjectedBundle client
-void WebContext::didReceiveMessageFromInjectedBundle(const String& message)
+void WebContext::didReceiveMessageFromInjectedBundle(const String& messageName, APIObject* messageBody)
{
- m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, message);
+ m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, messageName, messageBody);
}
// HistoryClient
@@ -292,4 +364,26 @@ void WebContext::registerURLSchemeAsEmptyDocument(const String& urlScheme)
m_process->send(WebProcessMessage::RegisterURLSchemeAsEmptyDocument, 0, CoreIPC::In(urlScheme));
}
+void WebContext::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments)
+{
+ switch (messageID.get<WebContextMessage::Kind>()) {
+ case WebContextMessage::PostMessage: {
+ String messageName;
+ // FIXME: This should be a RefPtr<APIObject>
+ APIObject* messageBody = 0;
+ PostMessageDecoder messageCoder(&messageBody, this);
+ if (!arguments.decode(CoreIPC::Out(messageName, messageCoder)))
+ return;
+
+ didReceiveMessageFromInjectedBundle(messageName, messageBody);
+
+ messageBody->deref();
+
+ return;
+ }
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebContext.h b/WebKit2/UIProcess/WebContext.h
index 3b1bfc1..34fce7d 100644
--- a/WebKit2/UIProcess/WebContext.h
+++ b/WebKit2/UIProcess/WebContext.h
@@ -83,7 +83,7 @@ public:
void postMessageToInjectedBundle(const WebCore::String&, APIObject*);
// InjectedBundle client
- void didReceiveMessageFromInjectedBundle(const WebCore::String&);
+ void didReceiveMessageFromInjectedBundle(const WebCore::String&, APIObject*);
// History client
void didNavigateWithNavigationData(WebFrameProxy*, const WebNavigationDataStore&);
@@ -100,6 +100,8 @@ public:
void registerURLSchemeAsEmptyDocument(const WebCore::String&);
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&);
+
private:
WebContext(ProcessModel, const WebCore::String& injectedBundlePath);
diff --git a/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp b/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp
index 3434af1..f7848a0 100644
--- a/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp
+++ b/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp
@@ -45,12 +45,12 @@ void WebContextInjectedBundleClient::initialize(const WKContextInjectedBundleCli
memset(&m_client, 0, sizeof(m_client));
}
-void WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle(WebContext* context, const String& message)
+void WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle(WebContext* context, const String& messageName, APIObject* messageBody)
{
if (!m_client.didReceiveMessageFromInjectedBundle)
return;
- m_client.didReceiveMessageFromInjectedBundle(toRef(context), toRef(message.impl()), m_client.clientInfo);
+ m_client.didReceiveMessageFromInjectedBundle(toRef(context), toRef(messageName.impl()), toRef(messageBody), m_client.clientInfo);
}
} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebContextInjectedBundleClient.h b/WebKit2/UIProcess/WebContextInjectedBundleClient.h
index 121f716..c19c70a 100644
--- a/WebKit2/UIProcess/WebContextInjectedBundleClient.h
+++ b/WebKit2/UIProcess/WebContextInjectedBundleClient.h
@@ -34,6 +34,7 @@ namespace WebCore {
namespace WebKit {
+class APIObject;
class WebContext;
class WebContextInjectedBundleClient {
@@ -41,7 +42,7 @@ public:
WebContextInjectedBundleClient();
void initialize(const WKContextInjectedBundleClient*);
- void didReceiveMessageFromInjectedBundle(WebContext*, const WebCore::String&);
+ void didReceiveMessageFromInjectedBundle(WebContext*, const WebCore::String&, APIObject*);
private:
WKContextInjectedBundleClient m_client;
diff --git a/WebKit2/UIProcess/WebProcessProxy.cpp b/WebKit2/UIProcess/WebProcessProxy.cpp
index 56f07e3..5fa82db 100644
--- a/WebKit2/UIProcess/WebProcessProxy.cpp
+++ b/WebKit2/UIProcess/WebProcessProxy.cpp
@@ -183,11 +183,6 @@ WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) con
return m_backForwardListItemMap.get(itemID).get();
}
-void WebProcessProxy::forwardMessageToWebContext(const String& message)
-{
- m_context->didReceiveMessageFromInjectedBundle(message);
-}
-
void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins)
{
if (refresh)
@@ -225,14 +220,6 @@ void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC
{
if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) {
switch (messageID.get<WebProcessProxyMessage::Kind>()) {
- case WebProcessProxyMessage::PostMessage: {
- String message;
- if (!arguments->decode(CoreIPC::Out(message)))
- return;
-
- forwardMessageToWebContext(message);
- return;
- }
case WebProcessProxyMessage::AddBackForwardItem: {
uint64_t itemID;
String originalURL;
@@ -316,6 +303,11 @@ void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC
}
}
+ if (messageID.is<CoreIPC::MessageClassWebContext>()) {
+ m_context->didReceiveMessage(connection, messageID, *arguments);
+ return;
+ }
+
uint64_t pageID = arguments->destinationID();
if (!pageID)
return;
@@ -365,13 +357,12 @@ void WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, Cor
case WebProcessProxyMessage::DidPerformServerRedirect:
case WebProcessProxyMessage::DidUpdateHistoryTitle:
case WebProcessProxyMessage::PopulateVisitedLinks:
- case WebProcessProxyMessage::PostMessage:
case WebProcessProxyMessage::AddBackForwardItem:
ASSERT_NOT_REACHED();
break;
}
}
-
+
uint64_t pageID = arguments->destinationID();
if (!pageID)
return;
diff --git a/WebKit2/UIProcess/WebProcessProxy.h b/WebKit2/UIProcess/WebProcessProxy.h
index a95085c..60bf9f8 100644
--- a/WebKit2/UIProcess/WebProcessProxy.h
+++ b/WebKit2/UIProcess/WebProcessProxy.h
@@ -96,7 +96,6 @@ private:
bool sendMessage(CoreIPC::MessageID, PassOwnPtr<CoreIPC::ArgumentEncoder>);
- void forwardMessageToWebContext(const WebCore::String&);
void getPlugins(bool refresh, Vector<WebCore::PluginInfo>&);
void getPluginHostConnection(const WebCore::String& mimeType, const WebCore::KURL& url, WebCore::String& pluginPath);
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index a1c873c..15fe421 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -232,6 +232,7 @@
BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCC5715A115ADAEF001CCAF9 /* WebSystemInterface.mm */; };
BCC57162115ADB42001CCAF9 /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC57161115ADB42001CCAF9 /* NotImplemented.h */; };
BCC938E11180DE440085E5FE /* WKContextPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCC938E01180DE440085E5FE /* WKContextPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ BCCB75C61203A1CE00222D1B /* WebContextMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */; };
BCD0042D110C1E27003B8A67 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCD0042C110C1E27003B8A67 /* CoreServices.framework */; };
BCD0139B110FA420003B8A67 /* WKFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD01397110FA420003B8A67 /* WKFrame.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCD0139C110FA420003B8A67 /* WKFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD01398110FA420003B8A67 /* WKFrame.cpp */; };
@@ -529,6 +530,7 @@
BCC5715A115ADAEF001CCAF9 /* WebSystemInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSystemInterface.mm; sourceTree = "<group>"; };
BCC57161115ADB42001CCAF9 /* NotImplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotImplemented.h; sourceTree = "<group>"; };
BCC938E01180DE440085E5FE /* WKContextPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContextPrivate.h; sourceTree = "<group>"; };
+ BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMessageKinds.h; sourceTree = "<group>"; };
BCD0042C110C1E27003B8A67 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
BCD01397110FA420003B8A67 /* WKFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFrame.h; sourceTree = "<group>"; };
BCD01398110FA420003B8A67 /* WKFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKFrame.cpp; sourceTree = "<group>"; };
@@ -1043,6 +1045,7 @@
BC9E969B11457F3F00870E71 /* DrawingAreaMessageKinds.h */,
BC9E969911457EDE00870E71 /* DrawingAreaProxyMessageKinds.h */,
BCB28CBF120233D9007D99BC /* InjectedBundleMessageKinds.h */,
+ BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */,
BC111B60112F638300337BAB /* WebPageMessageKinds.h */,
BC111B61112F638300337BAB /* WebPageProxyMessageKinds.h */,
BC111B62112F638300337BAB /* WebProcessMessageKinds.h */,
@@ -1321,6 +1324,7 @@
BCDB85821200EC57007254BE /* WKType.h in Headers */,
BCDB86C11200FB97007254BE /* WebURL.h in Headers */,
BCB28CC0120233D9007D99BC /* InjectedBundleMessageKinds.h in Headers */,
+ BCCB75C61203A1CE00222D1B /* WebContextMessageKinds.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
index 3974b53..77abb17 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
@@ -43,9 +43,9 @@ void WKBundleSetClient(WKBundleRef bundleRef, WKBundleClient * wkClient)
toWK(bundleRef)->initializeClient(wkClient);
}
-void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageRef)
+void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
{
- toWK(bundleRef)->postMessage(toWK(messageRef)->string());
+ toWK(bundleRef)->postMessage(toWK(messageNameRef)->string(), toWK(messageBodyRef));
}
void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundleRef, bool shouldTrackVisitedLinks)
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
index b8ab493..e5a7135 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
@@ -51,7 +51,7 @@ WK_EXPORT WKTypeID WKBundleGetTypeID();
WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClient * client);
-WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef message);
+WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody);
#ifdef __cplusplus
}
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
index b140d51..9e2a2ec 100644
--- a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
@@ -27,13 +27,13 @@
#include "Arguments.h"
#include "ImmutableArray.h"
+#include "WebContextMessageKinds.h"
#include "InjectedBundleMessageKinds.h"
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
#include "WebCoreArgumentCoders.h"
#include "WebPage.h"
#include "WebProcess.h"
-#include "WebProcessProxyMessageKinds.h"
#include <WebCore/PageGroup.h>
#include <wtf/OwnArrayPtr.h>
@@ -41,7 +41,125 @@ using namespace WebCore;
namespace WebKit {
-InjectedBundle::InjectedBundle(const WebCore::String& path)
+namespace {
+
+// FIXME: We should try to abstract out the shared logic from these and
+// and the PostMessageEncoder/PostMessageDecoders in WebContext.cpp into
+// a shared baseclass.
+
+// Encodes postMessage messages from the InjectedBundle -> UIProcess
+
+// - Array -> Array
+// - String -> String
+// - BundlePage -> Page
+
+class PostMessageEncoder {
+public:
+ PostMessageEncoder(APIObject* root)
+ : m_root(root)
+ {
+ }
+
+ void encode(CoreIPC::ArgumentEncoder& encoder) const
+ {
+ APIObject::Type type = m_root->type();
+ encoder.encode(static_cast<uint32_t>(type));
+ switch (type) {
+ case APIObject::TypeArray: {
+ ImmutableArray* array = static_cast<ImmutableArray*>(m_root);
+ encoder.encode(static_cast<uint64_t>(array->size()));
+ for (size_t i = 0; i < array->size(); ++i)
+ encoder.encode(PostMessageEncoder(array->at(i)));
+ break;
+ }
+ case APIObject::TypeString: {
+ WebString* string = static_cast<WebString*>(m_root);
+ encoder.encode(string->string());
+ break;
+ }
+ case APIObject::TypeBundlePage: {
+ WebPage* page = static_cast<WebPage*>(m_root);
+ encoder.encode(page->pageID());
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+private:
+ APIObject* m_root;
+};
+
+
+// Decodes postMessage messages going from the UIProcess -> InjectedBundle
+
+// - Array -> Array
+// - String -> String
+// - Page -> BundlePage
+
+class PostMessageDecoder {
+public:
+ PostMessageDecoder(APIObject** root)
+ : m_root(root)
+ {
+ }
+
+ static bool decode(CoreIPC::ArgumentDecoder& decoder, PostMessageDecoder& coder)
+ {
+ uint32_t type;
+ if (!decoder.decode(type))
+ return false;
+
+ switch (type) {
+ case APIObject::TypeArray: {
+ uint64_t size;
+ if (!decoder.decode(size))
+ return false;
+
+ OwnArrayPtr<APIObject*> array;
+ array.set(new APIObject*[size]);
+
+ for (size_t i = 0; i < size; ++i) {
+ APIObject* element;
+ PostMessageDecoder messageCoder(&element);
+ if (!decoder.decode(messageCoder))
+ return false;
+ array[i] = element;
+ }
+
+ *(coder.m_root) = ImmutableArray::create(array.release(), size).leakRef();
+ break;
+ }
+ case APIObject::TypeString: {
+ String string;
+ if (!decoder.decode(string))
+ return false;
+ *(coder.m_root) = WebString::create(string).leakRef();
+ break;
+ }
+ case APIObject::TypePage: {
+ uint64_t pageID;
+ if (!decoder.decode(pageID))
+ return false;
+ *(coder.m_root) = WebProcess::shared().webPage(pageID);
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+private:
+ APIObject** m_root;
+};
+
+}
+
+InjectedBundle::InjectedBundle(const String& path)
: m_path(path)
, m_platformBundle(0)
{
@@ -60,9 +178,9 @@ void InjectedBundle::initializeClient(WKBundleClient* client)
memset(&m_client, 0, sizeof(m_client));
}
-void InjectedBundle::postMessage(const String& message)
+void InjectedBundle::postMessage(const String& messageName, APIObject* messageBody)
{
- WebProcess::shared().connection()->send(WebProcessProxyMessage::PostMessage, 0, CoreIPC::In(message));
+ WebProcess::shared().connection()->send(WebContextMessage::PostMessage, 0, CoreIPC::In(messageName, PostMessageEncoder(messageBody)));
}
void InjectedBundle::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks)
@@ -87,80 +205,12 @@ void InjectedBundle::willDestroyPage(WebPage* page)
m_client.willDestroyPage(toRef(this), toRef(page), m_client.clientInfo);
}
-void InjectedBundle::didReceiveMessage(const WebCore::String& messageName, APIObject* messageBody)
+void InjectedBundle::didReceiveMessage(const String& messageName, APIObject* messageBody)
{
if (m_client.didReceiveMessage)
m_client.didReceiveMessage(toRef(this), toRef(messageName.impl()), toRef(messageBody), m_client.clientInfo);
}
-namespace {
-
-// Decodes postMessage messages going from the UIProcess -> InjectedBundle
-
-// - Array -> Array
-// - String -> String
-// - Page -> BundlePage
-
-class PostMessageDecoder {
-public:
- PostMessageDecoder(APIObject** root)
- : m_root(root)
- {
- }
-
- static bool decode(CoreIPC::ArgumentDecoder& decoder, PostMessageDecoder& coder)
- {
- uint32_t type;
- if (!decoder.decode(type))
- return false;
-
- switch (type) {
- case APIObject::TypeArray: {
- uint64_t size;
- if (!decoder.decode(size))
- return false;
-
- OwnArrayPtr<APIObject*> array;
- array.set(new APIObject*[size]);
-
- for (size_t i = 0; i < size; ++i) {
- APIObject* element;
- PostMessageDecoder messageCoder(&element);
- if (!decoder.decode(messageCoder))
- return false;
- array[i] = element;
- }
-
- *(coder.m_root) = ImmutableArray::create(array.release(), size).leakRef();
- break;
- }
- case APIObject::TypeString: {
- String string;
- if (!decoder.decode(string))
- return false;
- *(coder.m_root) = WebString::create(string).leakRef();
- break;
- }
- case APIObject::TypePage: {
- uint64_t pageID;
- if (!decoder.decode(pageID))
- return false;
- *(coder.m_root) = WebProcess::shared().webPage(pageID);
- break;
- }
- default:
- return false;
- }
-
- return true;
- }
-
-private:
- APIObject** m_root;
-};
-
-}
-
void InjectedBundle::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments)
{
switch (messageID.get<InjectedBundleMessage::Kind>()) {
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
index 8f49c65..7ac7130 100644
--- a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
@@ -67,7 +67,7 @@ public:
// API
void initializeClient(WKBundleClient*);
- void postMessage(const WebCore::String&);
+ void postMessage(const WebCore::String&, APIObject*);
void setShouldTrackVisitedLinks(bool);
void removeAllVisitedLinks();
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 79fadae..48773fd 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,29 @@
2010-07-30 Sam Weinig <sam at webkit.org>
+ Reviewed by Maciej Stachowiak.
+
+ Patch for https://bugs.webkit.org/show_bug.cgi?id=43290
+ Add structured message passing from the injected bundle to UIProcess
+
+ * MiniBrowser/mac/AppDelegate.m:
+ (didRecieveMessageFromInjectedBundle):
+ * MiniBrowser/mac/WebBundle/WebBundleMain.m:
+ (didClearWindowForFrame):
+ (didRecieveMessage):
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::done):
+ (WTR::InjectedBundle::didReceiveMessage):
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::initialize):
+ (WTR::TestController::didReceiveMessageFromInjectedBundle):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+ * WebKitTestRunner/TestInvocation.h:
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+
+2010-07-30 Sam Weinig <sam at webkit.org>
+
Reviewed by Anders Carlsson.
Patch for https://bugs.webkit.org/show_bug.cgi?id=43275
diff --git a/WebKitTools/MiniBrowser/mac/AppDelegate.m b/WebKitTools/MiniBrowser/mac/AppDelegate.m
index 834b063..ffb6363 100644
--- a/WebKitTools/MiniBrowser/mac/AppDelegate.m
+++ b/WebKitTools/MiniBrowser/mac/AppDelegate.m
@@ -36,20 +36,28 @@ static NSString *defaultURL = @"http://www.webkit.org/";
@implementation BrowserAppDelegate
-void didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
+void didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
- CFStringRef cfMessage = WKStringCopyCFString(0, message);
- LOG(@"ContextInjectedBundleClient - didRecieveMessage - message: %@", cfMessage);
- CFRelease(cfMessage);
+ CFStringRef cfMessageName = WKStringCopyCFString(0, messageName);
+
+ WKTypeID typeID = WKGetTypeID(messageBody);
+ if (typeID == WKStringGetTypeID()) {
+ CFStringRef cfMessageBody = WKStringCopyCFString(0, (WKStringRef)messageBody);
+ LOG(@"ContextInjectedBundleClient - didRecieveMessage - MessageName: %@ MessageBody %@", cfMessageName, cfMessageBody);
+ CFRelease(cfMessageBody);
+ } else {
+ LOG(@"ContextInjectedBundleClient - didRecieveMessage - MessageName: %@ (MessageBody Unhandeled)\n", cfMessageName);
+ }
+
+ CFRelease(cfMessageName);
WKStringRef newMessageName = WKStringCreateWithCFString(CFSTR("Response"));
WKStringRef newMessageBody = WKStringCreateWithCFString(CFSTR("Roger that!"));
- LOG(@"my info: %d", (int)WKGetTypeID(newMessageBody));
-
WKContextPostMessageToInjectedBundle(context, newMessageName, newMessageBody);
WKStringRelease(newMessageName);
+ WKStringRelease(newMessageBody);
}
#pragma mark History Client Callbacks
diff --git a/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m b/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m
index 055c2ae..c4f4a68 100644
--- a/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m
+++ b/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m
@@ -74,9 +74,11 @@ void didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSGlob
LOG(@"WKBundlePageClient - didClearWindowForFrame %@", [(NSURL *)cfURL absoluteString]);
CFRelease(cfURL);
- WKStringRef message = WKStringCreateWithCFString(CFSTR("Window was cleared"));
- WKBundlePostMessage(globalBundle, message);
- WKStringRelease(message);
+ WKStringRef messageName = WKStringCreateWithCFString(CFSTR("Callback"));
+ WKStringRef messageBody = WKStringCreateWithCFString(CFSTR("Window was cleared"));
+ WKBundlePostMessage(globalBundle, messageName, messageBody);
+ WKStringRelease(messageName);
+ WKStringRelease(messageBody);
}
@@ -113,12 +115,12 @@ void didRecieveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef me
WKTypeID typeID = WKGetTypeID(messageBody);
if (typeID == WKStringGetTypeID()) {
CFStringRef cfMessageBody = WKStringCopyCFString(0, (WKStringRef)messageBody);
- LOG(@"WKBundleClient - didRecieveMessage %@ (Type=String) %@\n", cfMessageName, cfMessageBody);
+ LOG(@"WKBundleClient - didRecieveMessage - MessageName: %@ MessageBody %@", cfMessageName, cfMessageBody);
CFRelease(cfMessageBody);
} else {
- LOG(@"WKBundleClient - didRecieveMessage %@ (Type=Unhandeled)\n", cfMessageName);
+ LOG(@"WKBundleClient - didRecieveMessage - MessageName: %@ (MessageBody Unhandeled)\n", cfMessageName);
}
-
+
CFRelease(cfMessageName);
}
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index 150f6d1..0daf954 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -81,10 +81,13 @@ void InjectedBundle::initialize(WKBundleRef bundle)
void InjectedBundle::done()
{
+ WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Done")));
+
std::string output = m_outputStream.str();
RetainPtr<CFStringRef> outputCFString(AdoptCF, CFStringCreateWithCString(0, output.c_str(), kCFStringEncodingUTF8));
- WKRetainPtr<WKStringRef> doneMessage(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
- WKBundlePostMessage(m_bundle, doneMessage.get());
+ WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
+
+ WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
}
void InjectedBundle::didCreatePage(WKBundlePageRef page)
@@ -103,15 +106,17 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
{
CFStringRef cfMessage = WKStringCopyCFString(0, messageName);
if (CFEqual(cfMessage, CFSTR("BeginTest"))) {
- WKRetainPtr<WKStringRef> ackMessage(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTestAck")));
- WKBundlePostMessage(m_bundle, ackMessage.get());
+ WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Ack")));
+ WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
+ WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());
reset();
return;
}
- WKRetainPtr<WKStringRef> errorMessage(AdoptWK, WKStringCreateWithCFString(CFSTR("Error: Unknown.")));
- WKBundlePostMessage(m_bundle, errorMessage.get());
+ WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Error")));
+ WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("Unknown")));
+ WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get());
}
void InjectedBundle::reset()
diff --git a/WebKitTools/WebKitTestRunner/TestController.cpp b/WebKitTools/WebKitTestRunner/TestController.cpp
index e3a6b90..a5b0de2 100644
--- a/WebKitTools/WebKitTestRunner/TestController.cpp
+++ b/WebKitTools/WebKitTestRunner/TestController.cpp
@@ -82,7 +82,7 @@ void TestController::initialize(int argc, const char* argv[])
WKContextInjectedBundleClient injectedBundlePathClient = {
0,
this,
- _didReceiveMessageFromInjectedBundle
+ didReceiveMessageFromInjectedBundle
};
WKContextSetInjectedBundleClient(m_context.get(), &injectedBundlePathClient);
@@ -126,14 +126,14 @@ bool TestController::run()
return true;
}
-void TestController::_didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
+void TestController::didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
- static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(message);
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(messageName, messageBody);
}
-void TestController::didReceiveMessageFromInjectedBundle(WKStringRef message)
+void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
{
- m_currentInvocation->didReceiveMessageFromInjectedBundle(message);
+ m_currentInvocation->didReceiveMessageFromInjectedBundle(messageName, messageBody);
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/TestController.h b/WebKitTools/WebKitTestRunner/TestController.h
index ea09fae..f79b35c 100644
--- a/WebKitTools/WebKitTestRunner/TestController.h
+++ b/WebKitTools/WebKitTestRunner/TestController.h
@@ -67,8 +67,8 @@ private:
void initializeTestPluginDirectory();
// WKContextInjectedBundleClient
- static void _didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void*);
- void didReceiveMessageFromInjectedBundle(WKStringRef message);
+ static void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void*);
+ void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
OwnPtr<TestInvocation> m_currentInvocation;
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.cpp b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
index 539bb6e..658911b 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.cpp
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
@@ -140,11 +140,10 @@ void TestInvocation::dump(const char* stringToDump)
fflush(stderr);
}
-void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef message)
+void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
{
- RetainPtr<CFStringRef> cfMessage(AdoptCF, WKStringCopyCFString(0, message));
-
- if (CFEqual(cfMessage.get(), CFSTR("Error"))) {
+ RetainPtr<CFStringRef> cfMessageName(AdoptCF, WKStringCopyCFString(0, messageName));
+ if (CFEqual(cfMessageName.get(), CFSTR("Error"))) {
// Set all states to true to stop spinning the runloop.
m_gotInitialResponse = true;
m_gotFinalMessage = true;
@@ -152,15 +151,27 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef message)
return;
}
- if (CFEqual(cfMessage.get(), CFSTR("BeginTestAck"))) {
- m_gotInitialResponse = true;
- return;
+ if (CFEqual(cfMessageName.get(), CFSTR("Ack"))) {
+ ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+ RetainPtr<CFStringRef> cfMessageBody(AdoptCF, WKStringCopyCFString(0, static_cast<WKStringRef>(messageBody)));
+
+ if (CFEqual(cfMessageBody.get(), CFSTR("BeginTest"))) {
+ m_gotInitialResponse = true;
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
}
- OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(message);
+ if (CFEqual(cfMessageName.get(), CFSTR("Done"))) {
+ ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+ OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(static_cast<WKStringRef>(messageBody));
+ dump(utf8Message->data());
+ m_gotFinalMessage = true;
+ return;
+ }
- dump(utf8Message->data());
- m_gotFinalMessage = true;
+ ASSERT_NOT_REACHED();
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.h b/WebKitTools/WebKitTestRunner/TestInvocation.h
index e064a8f..484e61d 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.h
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.h
@@ -37,7 +37,7 @@ public:
~TestInvocation();
void invoke();
- void didReceiveMessageFromInjectedBundle(WKStringRef message);
+ void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
private:
void dump(const char*);
diff --git a/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj b/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
index 23fe79b..eccf330 100644
--- a/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
+++ b/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
@@ -108,7 +108,7 @@
BC952ED211F3C29F003398B4 /* LayoutTestController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LayoutTestController.idl; sourceTree = "<group>"; };
BC952ED311F3C318003398B4 /* CodeGeneratorTestRunner.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = CodeGeneratorTestRunner.pm; sourceTree = "<group>"; };
BC952F1D11F3C652003398B4 /* JSLayoutTestController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSLayoutTestController.cpp; path = DerivedSources/WebKitTestRunner/JSLayoutTestController.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
- BC952F1E11F3C652003398B4 /* JSLayoutTestController.h */ = {isa = PBXFileReference; fileEncoding = 4; name = JSLayoutTestController.h; path = DerivedSources/WebKitTestRunner/JSLayoutTestController.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ BC952F1E11F3C652003398B4 /* JSLayoutTestController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSLayoutTestController.h; path = DerivedSources/WebKitTestRunner/JSLayoutTestController.h; sourceTree = BUILT_PRODUCTS_DIR; };
BCC997A011D3C8F60017BCA2 /* InjectedBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundle.cpp; sourceTree = "<group>"; };
BCC997A111D3C8F60017BCA2 /* InjectedBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundle.h; sourceTree = "<group>"; };
BCC997A211D3C8F60017BCA2 /* InjectedBundlePage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePage.cpp; sourceTree = "<group>"; };
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list