Begin fleshing out an API test for WKRemoteObjectRegistry
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2013 21:51:42 +0000 (21:51 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2013 21:51:42 +0000 (21:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123531

Reviewed by Andreas Kling.

Source/WebKit2:

* Shared/API/Cocoa/WKRemoteObjectInterface.h:
Add WK_API_CLASS annotation.

* Shared/API/Cocoa/WKRemoteObjectRegistry.h:
Add WK_API_CLASS annotation.

* Shared/API/Cocoa/WKRemoteObjectRegistry.mm:
Add a WebConnection ivar.

(-[WKRemoteObjectRegistry _initWithConnectionRef:]):
Add SPI to create an WKRemoteObjectRegistry object with an existing WKConnectionRef.

(-[WKRemoteObjectRegistry _handleMessageWithName:body:]):
Add SPI that will be used to process incoming messages from an existing WKConnectionRef.

* Shared/API/Cocoa/WKRemoteObjectRegistryPrivate.h: Added.
Add SPI header.

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

Tools:

Add a very simple test that doesn't really test anything for now.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm: Added.
* TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm: Added.
* TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h: Added.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.h
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.h
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryPrivate.h [new file with mode: 0644]
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h [new file with mode: 0644]

index 1dc0084..0c700b4 100644 (file)
@@ -1,3 +1,31 @@
+2013-10-30  Anders Carlsson  <andersca@apple.com>
+
+        Begin fleshing out an API test for WKRemoteObjectRegistry
+        https://bugs.webkit.org/show_bug.cgi?id=123531
+
+        Reviewed by Andreas Kling.
+
+        * Shared/API/Cocoa/WKRemoteObjectInterface.h:
+        Add WK_API_CLASS annotation.
+
+        * Shared/API/Cocoa/WKRemoteObjectRegistry.h:
+        Add WK_API_CLASS annotation.
+
+        * Shared/API/Cocoa/WKRemoteObjectRegistry.mm:
+        Add a WebConnection ivar.
+
+        (-[WKRemoteObjectRegistry _initWithConnectionRef:]):
+        Add SPI to create an WKRemoteObjectRegistry object with an existing WKConnectionRef.
+
+        (-[WKRemoteObjectRegistry _handleMessageWithName:body:]):
+        Add SPI that will be used to process incoming messages from an existing WKConnectionRef.
+
+        * Shared/API/Cocoa/WKRemoteObjectRegistryPrivate.h: Added.
+        Add SPI header.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add new files.
+
 2013-10-30  Tim Horton  <timothy_horton@apple.com>
 
         Remote Layer Tree: Lots of ASSERT(m_children.isEmpty()); on Poster Circle
index 5fc6824..dace5cd 100644 (file)
@@ -27,6 +27,7 @@
 
 #if WK_API_ENABLED
 
+WK_API_CLASS
 @interface WKRemoteObjectInterface : NSObject
 
 @property (readonly) Protocol *protocol;
index 40cd58e..c6e9121 100644 (file)
@@ -29,6 +29,7 @@
 
 @class WKRemoteObjectInterface;
 
+WK_API_CLASS
 @interface WKRemoteObjectRegistry : NSObject
 
 - (void)registerExportedObject:(id)object interface:(WKRemoteObjectInterface *)interface;
index 5a4a6c0..6e68d28 100644 (file)
 
 #import "config.h"
 #import "WKRemoteObjectRegistry.h"
+#import "WKRemoteObjectRegistryPrivate.h"
+
+#import "Connection.h"
+#import "WKConnectionRef.h"
+#import "WebConnection.h"
+#import "WKSharedAPICast.h"
 
 #if WK_API_ENABLED
 
-@implementation WKRemoteObjectRegistry
+using namespace WebKit;
+
+@implementation WKRemoteObjectRegistry {
+    RefPtr<WebConnection> _connection;
+}
 
 - (void)registerExportedObject:(id)object interface:(WKRemoteObjectInterface *)interface
 {
 
 @end
 
+@implementation WKRemoteObjectRegistry (WKPrivate)
+
+- (id)_initWithConnectionRef:(WKConnectionRef)connectionRef
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _connection = toImpl(connectionRef);
+
+    return self;
+}
+
+- (BOOL)_handleMessageWithName:(WKStringRef)name body:(WKTypeRef)body
+{
+    // FIXME: Implement.
+    return NO;
+}
+
+@end
+
 #endif // WK_API_ENABLED
diff --git a/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryPrivate.h b/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryPrivate.h
new file mode 100644 (file)
index 0000000..87cbed9
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#import <WebKit2/WKFoundation.h>
+#import <WebKit2/WKRemoteObjectRegistry.h>
+
+#import <WebKit2/WKBase.h>
+
+#if WK_API_ENABLED
+
+@interface WKRemoteObjectRegistry (WKPrivate)
+
+- (id)_initWithConnectionRef:(WKConnectionRef)connectionRef;
+- (BOOL)_handleMessageWithName:(WKStringRef)name body:(WKTypeRef)body;
+
+@end
+
+#endif
index 99c2716..b24720b 100644 (file)
                1A91010B1268C8CA001842F5 /* FindIndicatorWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9101091268C8CA001842F5 /* FindIndicatorWindow.mm */; };
                1A92DC1112F8BA460017AF65 /* LayerTreeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A92DC1012F8BA460017AF65 /* LayerTreeContext.h */; };
                1A92DC1312F8BAB90017AF65 /* LayerTreeContextMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A92DC1212F8BAB90017AF65 /* LayerTreeContextMac.mm */; };
-               1A9E32891821636900F5D04C /* WKRemoteObjectRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E32871821636900F5D04C /* WKRemoteObjectRegistry.h */; };
+               1A9E32891821636900F5D04C /* WKRemoteObjectRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E32871821636900F5D04C /* WKRemoteObjectRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A9E328A1821636900F5D04C /* WKRemoteObjectRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */; };
-               1A9E328D182165A900F5D04C /* WKRemoteObjectInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E328B182165A900F5D04C /* WKRemoteObjectInterface.h */; };
+               1A9E328D182165A900F5D04C /* WKRemoteObjectInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E328B182165A900F5D04C /* WKRemoteObjectInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A9E328E182165A900F5D04C /* WKRemoteObjectInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E328C182165A900F5D04C /* WKRemoteObjectInterface.mm */; };
+               1A9E329718219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A9FBA8D13FF04E600DEED67 /* PluginComplexTextInputState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9FBA8C13FF04E600DEED67 /* PluginComplexTextInputState.h */; };
                1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2E51B12E4C05E00BC4966 /* CGUtilities.h */; };
                1AA2E51E12E4C05E00BC4966 /* CGUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */; };
                1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObjectRegistry.mm; sourceTree = "<group>"; };
                1A9E328B182165A900F5D04C /* WKRemoteObjectInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObjectInterface.h; sourceTree = "<group>"; };
                1A9E328C182165A900F5D04C /* WKRemoteObjectInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObjectInterface.mm; sourceTree = "<group>"; };
+               1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObjectRegistryPrivate.h; sourceTree = "<group>"; };
                1A9FBA8C13FF04E600DEED67 /* PluginComplexTextInputState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginComplexTextInputState.h; sourceTree = "<group>"; };
                1AA1C79A100E7FC50078DEBC /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                        isa = PBXGroup;
                        children = (
                                37DFA6FF1810BB92001F4A9F /* WKFoundation.h */,
-                               1A9E32871821636900F5D04C /* WKRemoteObjectRegistry.h */,
-                               1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */,
                                1A9E328B182165A900F5D04C /* WKRemoteObjectInterface.h */,
                                1A9E328C182165A900F5D04C /* WKRemoteObjectInterface.mm */,
+                               1A9E32871821636900F5D04C /* WKRemoteObjectRegistry.h */,
+                               1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */,
+                               1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */,
                        );
                        path = Cocoa;
                        sourceTree = "<group>";
                                33AA1067131F060000D4A575 /* WebCookieManagerProxyClient.h in Headers */,
                                3309344A1315B9220097A7BC /* WebCookieManagerProxyMessages.h in Headers */,
                                BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
+                               1A9E329718219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h in Headers */,
                                512F589B12A8838800629530 /* WebCredential.h in Headers */,
                                51578B831209ECEF00A37C4A /* WebData.h in Headers */,
                                F6A25FDD12ADC6CC00DC40CC /* WebDatabaseManager.h in Headers */,
index e4e5a54..64a7964 100644 (file)
@@ -1,3 +1,17 @@
+2013-10-30  Anders Carlsson  <andersca@apple.com>
+
+        Begin fleshing out an API test for WKRemoteObjectRegistry
+        https://bugs.webkit.org/show_bug.cgi?id=123531
+
+        Reviewed by Andreas Kling.
+
+        Add a very simple test that doesn't really test anything for now.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm: Added.
+        * TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm: Added.
+        * TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h: Added.
+
 2013-10-30  Filip Pizlo  <fpizlo@apple.com>
 
         Remove unnecessary touch
index 22b11cd..ada36dc 100644 (file)
@@ -22,6 +22,8 @@
                1A7BFC0C171A0BDB00BC5F64 /* WillSendSubmitEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */; };
                1A7E8B34181208DE00AEB74A /* FragmentNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */; };
                1A7E8B3618120B2F00AEB74A /* FragmentNavigation.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A7E8B351812093600AEB74A /* FragmentNavigation.html */; };
+               1A9E3291182187F800F5D04C /* WKRemoteObjectRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E328F182187F800F5D04C /* WKRemoteObjectRegistry.mm */; };
+               1A9E32941821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E32921821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm */; };
                1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C045F9461385C2F800C0F3CD /* 18-characters.html */; };
                1AA9E55914980A9900001A8A /* Functional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA9E55714980A9900001A8A /* Functional.cpp */; };
                1ADBEFAE130C689C00D61D19 /* ForceRepaint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ADBEFAD130C689C00D61D19 /* ForceRepaint.cpp */; };
                1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WillSendSubmitEvent.mm; sourceTree = "<group>"; };
                1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FragmentNavigation.mm; sourceTree = "<group>"; };
                1A7E8B351812093600AEB74A /* FragmentNavigation.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FragmentNavigation.html; sourceTree = "<group>"; };
+               1A9E328F182187F800F5D04C /* WKRemoteObjectRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKRemoteObjectRegistry.mm; path = WebKit2ObjC/WKRemoteObjectRegistry.mm; sourceTree = "<group>"; };
+               1A9E32921821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKRemoteObjectRegistry_Bundle.mm; path = mac/WKRemoteObjectRegistry_Bundle.mm; sourceTree = "<group>"; };
+               1A9E329518219AE100F5D04C /* WKRemoteObjectRegistry_Shared.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKRemoteObjectRegistry_Shared.h; path = mac/WKRemoteObjectRegistry_Shared.h; sourceTree = "<group>"; };
                1AA9E55714980A9900001A8A /* Functional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Functional.cpp; sourceTree = "<group>"; };
                1ADBEFAD130C689C00D61D19 /* ForceRepaint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ForceRepaint.cpp; sourceTree = "<group>"; };
                1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-accelerated-compositing.html"; sourceTree = "<group>"; };
                BC3C4C6F14575B1D0025FB62 /* WebKit2 Objective-C */ = {
                        isa = PBXGroup;
                        children = (
-                               B55AD1D3179F3ABF00AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp */,
-                               B55AD1D1179F336600AC1494 /* PreventImageLoadWithAutoResizing.mm */,
                                297234B2173AD04800983601 /* CustomProtocolsInvalidScheme.mm */,
                                297234B5173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp */,
-                               29AB8A9F164C735800D49BEC /* CustomProtocolsTest.mm */,
                                290F4276172A232C00939FF0 /* CustomProtocolsSyncXHRTest.mm */,
+                               29AB8A9F164C735800D49BEC /* CustomProtocolsTest.mm */,
+                               B55AD1D1179F336600AC1494 /* PreventImageLoadWithAutoResizing.mm */,
+                               B55AD1D3179F3ABF00AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp */,
                                2943BE84161DFEB800999E3D /* UserContentTest.mm */,
                                BC3C4C7D14587AA60025FB62 /* WKBrowsingContextGroupTest.mm */,
                                BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */,
+                               1A9E328F182187F800F5D04C /* WKRemoteObjectRegistry.mm */,
+                               1A9E32921821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm */,
+                               1A9E329518219AE100F5D04C /* WKRemoteObjectRegistry_Shared.h */,
                        );
                        name = "WebKit2 Objective-C";
                        sourceTree = "<group>";
                                BC3C4C7214575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm in Sources */,
                                BC901E241492ADCE0074A667 /* WKConnection.cpp in Sources */,
                                51E93017156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp in Sources */,
+                               1A9E3291182187F800F5D04C /* WKRemoteObjectRegistry.mm in Sources */,
                                BC7B61AA129A038700D174A4 /* WKPreferences.cpp in Sources */,
                                BC90995E12567BC100083756 /* WKString.cpp in Sources */,
                                BC9099941256ACF100083756 /* WKStringJSString.cpp in Sources */,
                                BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */,
                                520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */,
                                76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */,
+                               1A9E32941821945C00F5D04C /* WKRemoteObjectRegistry_Bundle.mm in Sources */,
                                BC901E331492AF390074A667 /* WKConnection_Bundle.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm b/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm
new file mode 100644 (file)
index 0000000..8d622e5
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#import "config.h"
+#import "Test.h"
+
+#import "WKRemoteObjectRegistry_Shared.h"
+#import "PlatformUtilities.h"
+#import "PlatformWebView.h"
+#import <WebKit2/WKRetainPtr.h>
+#import <WebKit2/WKRemoteObjectInterface.h>
+#import <WebKit2/WKRemoteObjectRegistryPrivate.h>
+
+namespace TestWebKitAPI {
+
+static bool connectionEstablished;
+static WKRemoteObjectRegistry *remoteObjectRegistry;
+
+
+/* WKConnectionClient */
+static void connectionDidReceiveMessage(WKConnectionRef connection, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
+{
+    // FIXME: Implement this.
+}
+
+static void connectionDidClose(WKConnectionRef connection, const void* clientInfo)
+{
+    // FIXME: Implement this.
+}
+
+/* WKContextConnectionClient */
+static void didCreateConnection(WKContextRef context, WKConnectionRef connection, const void* clientInfo)
+{
+    connectionEstablished = true;
+
+    // Setup a client on the connection so we can listen for messages and
+    // tear down notifications.
+    WKConnectionClient connectionClient;
+    memset(&connectionClient, 0, sizeof(connectionClient));
+    connectionClient.version = WKConnectionClientCurrentVersion;
+    connectionClient.clientInfo = 0;
+    connectionClient.didReceiveMessage = connectionDidReceiveMessage;
+    connectionClient.didClose = connectionDidClose;
+    WKConnectionSetConnectionClient(connection, &connectionClient);
+
+    // Store off the conneciton to use.
+    remoteObjectRegistry = [[WKRemoteObjectRegistry alloc] _initWithConnectionRef:connection];
+}
+
+TEST(WebKit2, WKRemoteObjectRegistryTest)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("WKConnectionTest"));
+
+    // Set up the context's connection client so that we can access the connection when
+    // it is created.
+    WKContextConnectionClient contextConnectionClient;
+    memset(&contextConnectionClient, 0, sizeof(contextConnectionClient));
+    contextConnectionClient.version = kWKContextConnectionClientCurrentVersion;
+    contextConnectionClient.clientInfo = 0;
+    contextConnectionClient.didCreateConnection = didCreateConnection;
+    WKContextSetConnectionClient(context.get(), &contextConnectionClient);
+
+    // Load a simple page to start the WebProcess and establish a connection.
+    PlatformWebView webView(context.get());
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    // Wait until the connection is established.
+    Util::run(&connectionEstablished);
+    ASSERT_NOT_NULL(remoteObjectRegistry);
+
+    WKRemoteObjectInterface *bundleInterface = [WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(BundleInterface)];
+
+    id <BundleInterface> remoteObjectProxy = [remoteObjectRegistry remoteObjectProxyWithInterface:bundleInterface];
+    [remoteObjectProxy sayHello];
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm b/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Bundle.mm
new file mode 100644 (file)
index 0000000..56ce514
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 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 "InjectedBundleTest.h"
+#include "PlatformUtilities.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+/* WKConnectionClient */
+static void connectionDidReceiveMessage(WKConnectionRef connection, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
+{
+    // FIXME: Implement this.
+}
+
+class WKRemoteObjectRegistryTest : public InjectedBundleTest {
+public:
+    WKRemoteObjectRegistryTest(const std::string& identifier)
+        : InjectedBundleTest(identifier)
+    {
+    }
+
+    virtual void initialize(WKBundleRef bundle, WKTypeRef)
+    {
+        WKConnectionClient connectionClient;
+        memset(&connectionClient, 0, sizeof(connectionClient));
+        connectionClient.version = WKConnectionClientCurrentVersion;
+        connectionClient.clientInfo = 0;
+        connectionClient.didReceiveMessage = connectionDidReceiveMessage;
+        WKConnectionSetConnectionClient(WKBundleGetApplicationConnection(bundle), &connectionClient);
+    }
+};
+
+static InjectedBundleTest::Register<WKRemoteObjectRegistryTest> registrar("WKRemoteObjectRegistry");
+
+} // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h b/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h
new file mode 100644 (file)
index 0000000..1373fb3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+@protocol BundleInterface <NSObject>
+
+- (void)sayHello;
+
+@end