[Cocoa] API tests using the Modern WebKit API should be able to create web process...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Aug 2015 22:31:32 +0000 (22:31 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Aug 2015 22:31:32 +0000 (22:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148317

Reviewed by Dan Bernstein.

Added the ability for Modern WebKit API tests to create WKWebProcessPlugIns. A test can create a plug-in by
creating a class that conforms to WKWebProcessPlugIn, adding it to the WebProcessPlugIn target, and using the
WKWebViewConfiguration returned by +[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:]
when creating WKWebViews.

Since TestWebKitAPI relies on a bundle parameter to know which test class to instantiate in the plug-in, I also
added a new API test for bundle parameters.

* TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig: Added. Named the bundle TestWebKitAPI.wkbundle and
named its executable TestWebKitAPI.bundle.
* TestWebKitAPI/PlatformUtilities.h: Declared TestPlugInClassNameParameter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added the WebProcessPlugIn target.
* TestWebKitAPI/Tests/WebKit2Cocoa/BundleParameters.mm: Added.
(TEST): Tested bundle parameters by verifying that parameter changes in the UI process are observed in the bundle.
* TestWebKitAPI/Tests/WebKit2Cocoa/BundleParametersPlugIn.mm: Added.
(-[BundleParametersPlugIn webProcessPlugIn:didCreateBrowserContextController:]): Started observing changes to a
bundle parameter and asked for an initial notification.
(-[BundleParametersPlugIn dealloc]): Stopped observing changes to a bundle parameter.
(-[BundleParametersPlugIn observeValueForKeyPath:ofObject:change:context:]): When a bundle parameter changes,
mirror its value in the main frame's JSContext.
* TestWebKitAPI/WKWebViewConfigurationExtras.h: Added.
* TestWebKitAPI/WKWebViewConfigurationExtras.mm: Added.
(+[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:]): Created a configuration with
TestWebKitAPI's bundle URL and set a bundle parameter indicating the test plug-in's class name.
* TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm: Defined TestPlugInClassNameParameter.
* TestWebKitAPI/cocoa/WebProcessPlugIn/Info.plist: Added. Set the principal class to WebProcessPlugIn.
* TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm: Added.
(-[WebProcessPlugIn webProcessPlugIn:initializeWithObject:]): Forwarded to a newly-created test class instance.
(-[WebProcessPlugIn respondsToSelector:]): Returned YES if the test class instance response.
(-[WebProcessPlugIn forwardingTargetForSelector:]): Forwarded unimplemented methods to the test class instance.

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

Tools/ChangeLog
Tools/TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig [new file with mode: 0644]
Tools/TestWebKitAPI/PlatformUtilities.h
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/BundleParameters.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/BundleParametersPlugIn.mm [new file with mode: 0644]
Tools/TestWebKitAPI/WKWebViewConfigurationExtras.h [new file with mode: 0644]
Tools/TestWebKitAPI/WKWebViewConfigurationExtras.mm [new file with mode: 0644]
Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm
Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/Info.plist [new file with mode: 0644]
Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm [new file with mode: 0644]

index 6571c8e84c30c88fdcc14d1932e8a053692c94c6..4576853782dbd8865313dc5c2a52d63c27b3902a 100644 (file)
@@ -1,3 +1,41 @@
+2015-08-22  Andy Estes  <aestes@apple.com>
+
+        [Cocoa] API tests using the Modern WebKit API should be able to create web process plug-ins
+        https://bugs.webkit.org/show_bug.cgi?id=148317
+
+        Reviewed by Dan Bernstein.
+
+        Added the ability for Modern WebKit API tests to create WKWebProcessPlugIns. A test can create a plug-in by
+        creating a class that conforms to WKWebProcessPlugIn, adding it to the WebProcessPlugIn target, and using the
+        WKWebViewConfiguration returned by +[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:]
+        when creating WKWebViews.
+
+        Since TestWebKitAPI relies on a bundle parameter to know which test class to instantiate in the plug-in, I also
+        added a new API test for bundle parameters.
+
+        * TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig: Added. Named the bundle TestWebKitAPI.wkbundle and
+        named its executable TestWebKitAPI.bundle.
+        * TestWebKitAPI/PlatformUtilities.h: Declared TestPlugInClassNameParameter.
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added the WebProcessPlugIn target.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/BundleParameters.mm: Added.
+        (TEST): Tested bundle parameters by verifying that parameter changes in the UI process are observed in the bundle.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/BundleParametersPlugIn.mm: Added.
+        (-[BundleParametersPlugIn webProcessPlugIn:didCreateBrowserContextController:]): Started observing changes to a
+        bundle parameter and asked for an initial notification.
+        (-[BundleParametersPlugIn dealloc]): Stopped observing changes to a bundle parameter.
+        (-[BundleParametersPlugIn observeValueForKeyPath:ofObject:change:context:]): When a bundle parameter changes,
+        mirror its value in the main frame's JSContext.
+        * TestWebKitAPI/WKWebViewConfigurationExtras.h: Added.
+        * TestWebKitAPI/WKWebViewConfigurationExtras.mm: Added.
+        (+[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:]): Created a configuration with
+        TestWebKitAPI's bundle URL and set a bundle parameter indicating the test plug-in's class name.
+        * TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm: Defined TestPlugInClassNameParameter.
+        * TestWebKitAPI/cocoa/WebProcessPlugIn/Info.plist: Added. Set the principal class to WebProcessPlugIn.
+        * TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm: Added.
+        (-[WebProcessPlugIn webProcessPlugIn:initializeWithObject:]): Forwarded to a newly-created test class instance.
+        (-[WebProcessPlugIn respondsToSelector:]): Returned YES if the test class instance response.
+        (-[WebProcessPlugIn forwardingTargetForSelector:]): Forwarded unimplemented methods to the test class instance.
+
 2015-08-23  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         URTBF after r188828.
diff --git a/Tools/TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig b/Tools/TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig
new file mode 100644 (file)
index 0000000..539bd3d
--- /dev/null
@@ -0,0 +1,30 @@
+//
+// 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.
+//
+
+INFOPLIST_FILE = cocoa/WebProcessPlugIn/Info.plist;
+PRODUCT_NAME = TestWebKitAPI;
+EXECUTABLE_SUFFIX = .bundle;
+WRAPPER_EXTENSION = wkbundle;
+OTHER_LDFLAGS = $(inherited) -framework JavaScriptCore -framework WebKit;
index 2e1e1b0b74cd9e2ab3ff819439ded4dd6bda1bba..7583e4ee077e3e883e6a57db5d1b89ec4794294b 100644 (file)
@@ -75,6 +75,10 @@ static inline ::testing::AssertionResult assertWKStringEqual(const char* expecte
 #define EXPECT_WK_STREQ(expected, actual) \
     EXPECT_PRED_FORMAT2(TestWebKitAPI::Util::assertWKStringEqual, expected, actual)
 
+#if WK_API_ENABLED
+extern NSString * const TestPlugInClassNameParameter;
+#endif
+
 } // namespace Util
 } // namespace TestWebKitAPI
 
index ac4cccdc2441d5131003ec2259f30cba3571e1b8..c31004b02f40c0fbf186dca3c2b342b745d270f9 100644 (file)
                93F7E86F14DC8E5C00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */; };
                9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
                9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
+               A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */; };
+               A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; };
+               A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */; };
+               A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAC1B87436F00097110 /* BundleParameters.mm */; };
+               A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */; };
                A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; };
                A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
                B55AD1D5179F3B3000AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55AD1D3179F3ABF00AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp */; };
                        remoteGlobalIDString = 7CCE7E8B1A41144E00447C4C;
                        remoteInfo = TestWebKitAPILibrary;
                };
+               A13EBBB21B87441900097110 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = A13EBB481B87339E00097110;
+                       remoteInfo = WebProcessPlugIn;
+               };
                BC575A95126E74E7006F0F12 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
                9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLFormCollectionNamedItem.html; sourceTree = "<group>"; };
                9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; };
                9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; };
+               A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestWebKitAPI.wkbundle; sourceTree = BUILT_PRODUCTS_DIR; };
+               A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcessPlugIn.xcconfig; sourceTree = "<group>"; };
+               A13EBB541B8734E000097110 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+               A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessPlugIn.mm; sourceTree = "<group>"; };
+               A13EBBAC1B87436F00097110 /* BundleParameters.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleParameters.mm; sourceTree = "<group>"; };
+               A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleParametersPlugIn.mm; sourceTree = "<group>"; };
+               A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewConfigurationExtras.mm; sourceTree = "<group>"; };
+               A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewConfigurationExtras.h; sourceTree = "<group>"; };
                A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = "<group>"; };
                A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCreateCGImageCrash.cpp; sourceTree = "<group>"; };
                A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageVisibilityStateWithWindowChanges.mm; sourceTree = "<group>"; };
                0F139E711A423A1D00F590F5 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               A13EBB441B87332B00097110 /* WebProcessPlugIn */,
                                0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */,
+                               A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */,
+                               A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */,
                        );
                        name = cocoa;
                        sourceTree = "<group>";
                                8DD76FA10486AA7600D96B5E /* TestWebKitAPI */,
                                BC575980126E74AF006F0F12 /* InjectedBundleTestWebKitAPI.bundle */,
                                7CCE7E8C1A41144E00447C4C /* libTestWebKitAPI.a */,
+                               A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */,
                        );
                        name = Products;
                        sourceTree = "<group>";
                        isa = PBXGroup;
                        children = (
                                7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */,
+                               A13EBBAC1B87436F00097110 /* BundleParameters.mm */,
+                               A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */,
                                A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
                                2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
                                37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
                        path = darwin;
                        sourceTree = "<group>";
                };
+               A13EBB441B87332B00097110 /* WebProcessPlugIn */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A13EBB541B8734E000097110 /* Info.plist */,
+                               A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */,
+                       );
+                       name = WebProcessPlugIn;
+                       path = cocoa/WebProcessPlugIn;
+                       sourceTree = "<group>";
+               };
                BC029B1A1486B23800817DA9 /* ns */ = {
                        isa = PBXGroup;
                        children = (
                                BC575AE2126E88B1006F0F12 /* InjectedBundle.xcconfig */,
                                BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */,
                                7CCE7EA31A4115CB00447C4C /* TestWebKitAPILibrary.xcconfig */,
+                               A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */,
                        );
                        path = Configurations;
                        sourceTree = "<group>";
                        buildRules = (
                        );
                        dependencies = (
+                               A13EBBB31B87441900097110 /* PBXTargetDependency */,
                                BC575A96126E74E7006F0F12 /* PBXTargetDependency */,
                                7CCE7F511A4124DB00447C4C /* PBXTargetDependency */,
                        );
                        productReference = 8DD76FA10486AA7600D96B5E /* TestWebKitAPI */;
                        productType = "com.apple.product-type.tool";
                };
+               A13EBB481B87339E00097110 /* WebProcessPlugIn */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = A13EBB4C1B87339E00097110 /* Build configuration list for PBXNativeTarget "WebProcessPlugIn" */;
+                       buildPhases = (
+                               A13EBB451B87339E00097110 /* Sources */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = WebProcessPlugIn;
+                       productName = WebProcessPlugIn;
+                       productReference = A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */;
+                       productType = "com.apple.product-type.bundle";
+               };
                BC57597F126E74AF006F0F12 /* InjectedBundleTestWebKitAPI */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = BC575986126E74AF006F0F12 /* Build configuration list for PBXNativeTarget "InjectedBundleTestWebKitAPI" */;
                                        7CCE7E8B1A41144E00447C4C = {
                                                CreatedOnToolsVersion = 6.3;
                                        };
+                                       A13EBB481B87339E00097110 = {
+                                               CreatedOnToolsVersion = 7.0;
+                                       };
                                };
                        };
                        buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "TestWebKitAPI" */;
                                8DD76F960486AA7600D96B5E /* TestWebKitAPI */,
                                BC57597F126E74AF006F0F12 /* InjectedBundleTestWebKitAPI */,
                                7CCE7E8B1A41144E00447C4C /* TestWebKitAPILibrary */,
+                               A13EBB481B87339E00097110 /* WebProcessPlugIn */,
                        );
                };
 /* End PBXProject section */
                                7CCE7EC41A411A7E00447C4C /* JSWrapperForNodeInWebFrame.mm in Sources */,
                                7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
                                7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */,
+                               A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */,
                                7CCE7F381A411B8E00447C4C /* ListHashSet.cpp in Sources */,
                                37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,
                                7CCE7EFE1A411AE600447C4C /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
                                7CCE7ECE1A411A7E00447C4C /* StopLoadingFromDidFinishLoading.mm in Sources */,
                                7CCE7ECF1A411A7E00447C4C /* StopLoadingFromDidReceiveResponse.mm in Sources */,
                                7CCE7F441A411B8E00447C4C /* StringBuilder.cpp in Sources */,
+                               A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */,
                                7CB184C61AA3F2100066EDFD /* ContentExtensions.cpp in Sources */,
                                7CCE7ED01A411A7E00447C4C /* StringByEvaluatingJavaScriptFromString.mm in Sources */,
                                7CCE7F451A411B8E00447C4C /* StringHasher.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               A13EBB451B87339E00097110 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */,
+                               A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
+                               A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                BC57597D126E74AF006F0F12 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        target = 7CCE7E8B1A41144E00447C4C /* TestWebKitAPILibrary */;
                        targetProxy = 7CCE7F501A4124DB00447C4C /* PBXContainerItemProxy */;
                };
+               A13EBBB31B87441900097110 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = A13EBB481B87339E00097110 /* WebProcessPlugIn */;
+                       targetProxy = A13EBBB21B87441900097110 /* PBXContainerItemProxy */;
+               };
                BC575A96126E74E7006F0F12 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = BC57597F126E74AF006F0F12 /* InjectedBundleTestWebKitAPI */;
                        };
                        name = Release;
                };
+               A13EBB4D1B87339E00097110 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               A13EBB4E1B87339E00097110 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
                BC575984126E74AF006F0F12 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        baseConfigurationReference = BC575AE2126E88B1006F0F12 /* InjectedBundle.xcconfig */;
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               A13EBB4C1B87339E00097110 /* Build configuration list for PBXNativeTarget "WebProcessPlugIn" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               A13EBB4D1B87339E00097110 /* Debug */,
+                               A13EBB4E1B87339E00097110 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                BC575986126E74AF006F0F12 /* Build configuration list for PBXNativeTarget "InjectedBundleTestWebKitAPI" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/BundleParameters.mm b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/BundleParameters.mm
new file mode 100644 (file)
index 0000000..120188f
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <wtf/RetainPtr.h>
+
+static bool isDone;
+
+TEST(WebKit2, BundleParameters)
+{
+    @autoreleasepool {
+        NSString * const testPlugInClassName = @"BundleParametersPlugIn";
+        auto configuration = retainPtr([WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:testPlugInClassName]);
+        auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
+
+        [webView evaluateJavaScript:TestWebKitAPI::Util::TestPlugInClassNameParameter completionHandler:^(id result, NSError *error) {
+            EXPECT_TRUE([result isKindOfClass:[NSString class]]);
+            EXPECT_WK_STREQ(result, testPlugInClassName);
+            isDone = true;
+        }];
+
+        TestWebKitAPI::Util::run(&isDone);
+        isDone = false;
+
+        NSString * const testParameter = @"TestParameter";
+        [webView evaluateJavaScript:testParameter completionHandler:^(id result, NSError *error) {
+            EXPECT_NULL(result);
+            isDone = true;
+        }];
+
+        TestWebKitAPI::Util::run(&isDone);
+        isDone = false;
+
+        NSString * const testString = @"PASS";
+        [[configuration processPool] _setObject:testString forBundleParameter:testParameter];
+        [webView evaluateJavaScript:testParameter completionHandler:^(id result, NSError *error) {
+            EXPECT_TRUE([result isKindOfClass:[NSString class]]);
+            EXPECT_WK_STREQ(result, testString);
+            isDone = true;
+        }];
+
+        TestWebKitAPI::Util::run(&isDone);
+        isDone = false;
+
+        NSDictionary * const testDictionary = @{ @"result" : @"PASS" };
+        [[configuration processPool] _setObject:testDictionary forBundleParameter:testParameter];
+        [webView evaluateJavaScript:testParameter completionHandler:^(id result, NSError *error) {
+            EXPECT_TRUE([result isKindOfClass:[NSDictionary class]]);
+            EXPECT_TRUE([result isEqualToDictionary:testDictionary]);
+            isDone = true;
+        }];
+
+        TestWebKitAPI::Util::run(&isDone);
+        isDone = false;
+
+        [[configuration processPool] _setObject:nil forBundleParameter:testParameter];
+        [webView evaluateJavaScript:testParameter completionHandler:^(id result, NSError *error) {
+            EXPECT_NULL(result);
+            isDone = true;
+        }];
+
+        TestWebKitAPI::Util::run(&isDone);
+    }
+}
+
+#endif // WK_API_ENABLED
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/BundleParametersPlugIn.mm b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/BundleParametersPlugIn.mm
new file mode 100644 (file)
index 0000000..2b51a05
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <WebKit/WKWebProcessPlugInBrowserContextController.h>
+#import <WebKit/WKWebProcessPlugInFrame.h>
+#import <WebKit/WKWebProcessPlugInScriptWorld.h>
+#import <wtf/RetainPtr.h>
+
+static NSString * const testParameter = @"TestParameter";
+
+@interface BundleParametersPlugIn : NSObject <WKWebProcessPlugIn>
+@end
+
+@implementation BundleParametersPlugIn {
+    RetainPtr<WKWebProcessPlugInBrowserContextController> _browserContextController;
+    RetainPtr<WKWebProcessPlugInController> _plugInController;
+}
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+    ASSERT(!_browserContextController);
+    ASSERT(!_plugInController);
+    _browserContextController = browserContextController;
+    _plugInController = plugInController;
+    [plugInController.parameters addObserver:self forKeyPath:testParameter options:NSKeyValueObservingOptionInitial context:NULL];
+    [plugInController.parameters addObserver:self forKeyPath:TestWebKitAPI::Util::TestPlugInClassNameParameter options:NSKeyValueObservingOptionInitial context:NULL];
+}
+
+- (void)dealloc
+{
+    [[_plugInController parameters] removeObserver:self forKeyPath:testParameter];
+    [[_plugInController parameters] removeObserver:self forKeyPath:TestWebKitAPI::Util::TestPlugInClassNameParameter];
+    [super dealloc];
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+    JSContext *jsContext = [[_browserContextController mainFrame] jsContextForWorld:[WKWebProcessPlugInScriptWorld normalWorld]];
+    [jsContext setObject:[object valueForKey:keyPath] forKeyedSubscript:keyPath];
+}
+
+@end
+
+#endif // WK_API_ENABLED
diff --git a/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.h b/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.h
new file mode 100644 (file)
index 0000000..63e0abf
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+@interface WKWebViewConfiguration (TestWebKitAPIExtras)
++ (instancetype)testwebkitapi_configurationWithTestPlugInClassName:(NSString *)className;
+@end
diff --git a/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.mm b/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.mm
new file mode 100644 (file)
index 0000000..ab97a92
--- /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.
+ */
+
+#import "config.h"
+#import "WKWebViewConfigurationExtras.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+#import <wtf/RetainPtr.h>
+
+@implementation WKWebViewConfiguration (TestWebKitAPIExtras)
+
++ (instancetype)testwebkitapi_configurationWithTestPlugInClassName:(NSString *)className
+{
+    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+    [processPoolConfiguration setInjectedBundleURL:[[NSBundle mainBundle] URLForResource:@"TestWebKitAPI" withExtension:@"wkbundle"]];
+
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+    [processPool _setObject:className forBundleParameter:TestWebKitAPI::Util::TestPlugInClassNameParameter];
+
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [webViewConfiguration setProcessPool:processPool.get()];
+
+    return webViewConfiguration.autorelease();
+}
+
+@end
+
+#endif // WK_API_ENABLED
index 8c1dad1a3debe3fe2bace82327d768d96b8ce7c0..674ff389da425c20ba7c55ecc786bf737702e5a4 100644 (file)
@@ -55,5 +55,8 @@ std::string toSTD(NSString *string)
     return std::string(buffer.get(), stringLength);
 }
 
+#if WK_API_ENABLED
+NSString * const TestPlugInClassNameParameter = @"TestPlugInPrincipalClassName";
+#endif
 } // namespace Util
 } // namespace TestWebKitAPI
diff --git a/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/Info.plist b/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/Info.plist
new file mode 100644 (file)
index 0000000..d1f2a20
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>en</string>
+       <key>CFBundleExecutable</key>
+       <string>$(EXECUTABLE_NAME)</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>$(PRODUCT_NAME)</string>
+       <key>CFBundlePackageType</key>
+       <string>BNDL</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.0</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleVersion</key>
+       <string>1</string>
+       <key>NSPrincipalClass</key>
+       <string>WebProcessPlugIn</string>
+</dict>
+</plist>
diff --git a/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm b/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm
new file mode 100644 (file)
index 0000000..adbd011
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <wtf/RetainPtr.h>
+
+@interface WebProcessPlugIn : NSObject <WKWebProcessPlugIn>
+@end
+
+@implementation WebProcessPlugIn {
+    RetainPtr<id <WKWebProcessPlugIn>> _testPlugIn;
+}
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController initializeWithObject:(id)initializationObject
+{
+    NSString *testPlugInClassName = [plugInController.parameters valueForKey:TestWebKitAPI::Util::TestPlugInClassNameParameter];
+    ASSERT(testPlugInClassName);
+    ASSERT([testPlugInClassName isKindOfClass:[NSString class]]);
+
+    Class testPlugInClass = NSClassFromString(testPlugInClassName);
+    ASSERT(testPlugInClass);
+    ASSERT([testPlugInClass conformsToProtocol:@protocol(WKWebProcessPlugIn)]);
+
+    ASSERT(!_testPlugIn);
+    _testPlugIn = adoptNS([[testPlugInClass alloc] init]);
+
+    if ([_testPlugIn respondsToSelector:@selector(webProcessPlugIn:initializeWithObject:)])
+        [_testPlugIn webProcessPlugIn:plugInController initializeWithObject:initializationObject];
+}
+
+- (BOOL)respondsToSelector:(SEL)aSelector
+{
+    if ([_testPlugIn respondsToSelector:aSelector])
+        return YES;
+    return [super respondsToSelector:aSelector];
+}
+
+- (id)forwardingTargetForSelector:(SEL)aSelector
+{
+    return _testPlugIn.get();
+}
+
+@end
+
+#endif // WK_API_ENABLED