Changeset 188844 in webkit


Ignore:
Timestamp:
Aug 23, 2015 3:31:32 PM (9 years ago)
Author:
aestes@apple.com
Message:

[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.

Location:
trunk/Tools
Files:
6 added
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r188840 r188844  
     12015-08-22  Andy Estes  <aestes@apple.com>
     2
     3        [Cocoa] API tests using the Modern WebKit API should be able to create web process plug-ins
     4        https://bugs.webkit.org/show_bug.cgi?id=148317
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Added the ability for Modern WebKit API tests to create WKWebProcessPlugIns. A test can create a plug-in by
     9        creating a class that conforms to WKWebProcessPlugIn, adding it to the WebProcessPlugIn target, and using the
     10        WKWebViewConfiguration returned by +[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:]
     11        when creating WKWebViews.
     12
     13        Since TestWebKitAPI relies on a bundle parameter to know which test class to instantiate in the plug-in, I also
     14        added a new API test for bundle parameters.
     15
     16        * TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig: Added. Named the bundle TestWebKitAPI.wkbundle and
     17        named its executable TestWebKitAPI.bundle.
     18        * TestWebKitAPI/PlatformUtilities.h: Declared TestPlugInClassNameParameter.
     19        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added the WebProcessPlugIn target.
     20        * TestWebKitAPI/Tests/WebKit2Cocoa/BundleParameters.mm: Added.
     21        (TEST): Tested bundle parameters by verifying that parameter changes in the UI process are observed in the bundle.
     22        * TestWebKitAPI/Tests/WebKit2Cocoa/BundleParametersPlugIn.mm: Added.
     23        (-[BundleParametersPlugIn webProcessPlugIn:didCreateBrowserContextController:]): Started observing changes to a
     24        bundle parameter and asked for an initial notification.
     25        (-[BundleParametersPlugIn dealloc]): Stopped observing changes to a bundle parameter.
     26        (-[BundleParametersPlugIn observeValueForKeyPath:ofObject:change:context:]): When a bundle parameter changes,
     27        mirror its value in the main frame's JSContext.
     28        * TestWebKitAPI/WKWebViewConfigurationExtras.h: Added.
     29        * TestWebKitAPI/WKWebViewConfigurationExtras.mm: Added.
     30        (+[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:]): Created a configuration with
     31        TestWebKitAPI's bundle URL and set a bundle parameter indicating the test plug-in's class name.
     32        * TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm: Defined TestPlugInClassNameParameter.
     33        * TestWebKitAPI/cocoa/WebProcessPlugIn/Info.plist: Added. Set the principal class to WebProcessPlugIn.
     34        * TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm: Added.
     35        (-[WebProcessPlugIn webProcessPlugIn:initializeWithObject:]): Forwarded to a newly-created test class instance.
     36        (-[WebProcessPlugIn respondsToSelector:]): Returned YES if the test class instance response.
     37        (-[WebProcessPlugIn forwardingTargetForSelector:]): Forwarded unimplemented methods to the test class instance.
     38
    1392015-08-23  Csaba Osztrogonác  <ossy@webkit.org>
    240
  • trunk/Tools/TestWebKitAPI/PlatformUtilities.h

    r177506 r188844  
    7676    EXPECT_PRED_FORMAT2(TestWebKitAPI::Util::assertWKStringEqual, expected, actual)
    7777
     78#if WK_API_ENABLED
     79extern NSString * const TestPlugInClassNameParameter;
     80#endif
     81
    7882} // namespace Util
    7983} // namespace TestWebKitAPI
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r188400 r188844  
    265265                9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
    266266                9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
     267                A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */; };
     268                A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; };
     269                A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */; };
     270                A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAC1B87436F00097110 /* BundleParameters.mm */; };
     271                A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */; };
    267272                A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; };
    268273                A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
     
    324329                        remoteGlobalIDString = 7CCE7E8B1A41144E00447C4C;
    325330                        remoteInfo = TestWebKitAPILibrary;
     331                };
     332                A13EBBB21B87441900097110 /* PBXContainerItemProxy */ = {
     333                        isa = PBXContainerItemProxy;
     334                        containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
     335                        proxyType = 1;
     336                        remoteGlobalIDString = A13EBB481B87339E00097110;
     337                        remoteInfo = WebProcessPlugIn;
    326338                };
    327339                BC575A95126E74E7006F0F12 /* PBXContainerItemProxy */ = {
     
    620632                9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; };
    621633                9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; };
     634                A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestWebKitAPI.wkbundle; sourceTree = BUILT_PRODUCTS_DIR; };
     635                A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcessPlugIn.xcconfig; sourceTree = "<group>"; };
     636                A13EBB541B8734E000097110 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
     637                A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessPlugIn.mm; sourceTree = "<group>"; };
     638                A13EBBAC1B87436F00097110 /* BundleParameters.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleParameters.mm; sourceTree = "<group>"; };
     639                A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleParametersPlugIn.mm; sourceTree = "<group>"; };
     640                A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewConfigurationExtras.mm; sourceTree = "<group>"; };
     641                A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewConfigurationExtras.h; sourceTree = "<group>"; };
    622642                A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = "<group>"; };
    623643                A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCreateCGImageCrash.cpp; sourceTree = "<group>"; };
     
    837857                        isa = PBXGroup;
    838858                        children = (
     859                                A13EBB441B87332B00097110 /* WebProcessPlugIn */,
    839860                                0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */,
     861                                A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */,
     862                                A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */,
    840863                        );
    841864                        name = cocoa;
     
    856879                                BC575980126E74AF006F0F12 /* InjectedBundleTestWebKitAPI.bundle */,
    857880                                7CCE7E8C1A41144E00447C4C /* libTestWebKitAPI.a */,
     881                                A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */,
    858882                        );
    859883                        name = Products;
     
    864888                        children = (
    865889                                7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */,
     890                                A13EBBAC1B87436F00097110 /* BundleParameters.mm */,
     891                                A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */,
    866892                                A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
    867893                                2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
     
    932958                        sourceTree = "<group>";
    933959                };
     960                A13EBB441B87332B00097110 /* WebProcessPlugIn */ = {
     961                        isa = PBXGroup;
     962                        children = (
     963                                A13EBB541B8734E000097110 /* Info.plist */,
     964                                A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */,
     965                        );
     966                        name = WebProcessPlugIn;
     967                        path = cocoa/WebProcessPlugIn;
     968                        sourceTree = "<group>";
     969                };
    934970                BC029B1A1486B23800817DA9 /* ns */ = {
    935971                        isa = PBXGroup;
     
    9761012                                BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */,
    9771013                                7CCE7EA31A4115CB00447C4C /* TestWebKitAPILibrary.xcconfig */,
     1014                                A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */,
    9781015                        );
    9791016                        path = Configurations;
     
    13791416                        );
    13801417                        dependencies = (
     1418                                A13EBBB31B87441900097110 /* PBXTargetDependency */,
    13811419                                BC575A96126E74E7006F0F12 /* PBXTargetDependency */,
    13821420                                7CCE7F511A4124DB00447C4C /* PBXTargetDependency */,
     
    13871425                        productReference = 8DD76FA10486AA7600D96B5E /* TestWebKitAPI */;
    13881426                        productType = "com.apple.product-type.tool";
     1427                };
     1428                A13EBB481B87339E00097110 /* WebProcessPlugIn */ = {
     1429                        isa = PBXNativeTarget;
     1430                        buildConfigurationList = A13EBB4C1B87339E00097110 /* Build configuration list for PBXNativeTarget "WebProcessPlugIn" */;
     1431                        buildPhases = (
     1432                                A13EBB451B87339E00097110 /* Sources */,
     1433                        );
     1434                        buildRules = (
     1435                        );
     1436                        dependencies = (
     1437                        );
     1438                        name = WebProcessPlugIn;
     1439                        productName = WebProcessPlugIn;
     1440                        productReference = A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */;
     1441                        productType = "com.apple.product-type.bundle";
    13891442                };
    13901443                BC57597F126E74AF006F0F12 /* InjectedBundleTestWebKitAPI */ = {
     
    14171470                                                CreatedOnToolsVersion = 6.3;
    14181471                                        };
     1472                                        A13EBB481B87339E00097110 = {
     1473                                                CreatedOnToolsVersion = 7.0;
     1474                                        };
    14191475                                };
    14201476                        };
     
    14361492                                BC57597F126E74AF006F0F12 /* InjectedBundleTestWebKitAPI */,
    14371493                                7CCE7E8B1A41144E00447C4C /* TestWebKitAPILibrary */,
     1494                                A13EBB481B87339E00097110 /* WebProcessPlugIn */,
    14381495                        );
    14391496                };
     
    15311588                                7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
    15321589                                7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */,
     1590                                A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */,
    15331591                                7CCE7F381A411B8E00447C4C /* ListHashSet.cpp in Sources */,
    15341592                                37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,
     
    15991657                                7CCE7ECF1A411A7E00447C4C /* StopLoadingFromDidReceiveResponse.mm in Sources */,
    16001658                                7CCE7F441A411B8E00447C4C /* StringBuilder.cpp in Sources */,
     1659                                A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */,
    16011660                                7CB184C61AA3F2100066EDFD /* ContentExtensions.cpp in Sources */,
    16021661                                7CCE7ED01A411A7E00447C4C /* StringByEvaluatingJavaScriptFromString.mm in Sources */,
     
    16711730                        runOnlyForDeploymentPostprocessing = 0;
    16721731                };
     1732                A13EBB451B87339E00097110 /* Sources */ = {
     1733                        isa = PBXSourcesBuildPhase;
     1734                        buildActionMask = 2147483647;
     1735                        files = (
     1736                                A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */,
     1737                                A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
     1738                                A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
     1739                        );
     1740                        runOnlyForDeploymentPostprocessing = 0;
     1741                };
    16731742                BC57597D126E74AF006F0F12 /* Sources */ = {
    16741743                        isa = PBXSourcesBuildPhase;
     
    17221791                        targetProxy = 7CCE7F501A4124DB00447C4C /* PBXContainerItemProxy */;
    17231792                };
     1793                A13EBBB31B87441900097110 /* PBXTargetDependency */ = {
     1794                        isa = PBXTargetDependency;
     1795                        target = A13EBB481B87339E00097110 /* WebProcessPlugIn */;
     1796                        targetProxy = A13EBBB21B87441900097110 /* PBXContainerItemProxy */;
     1797                };
    17241798                BC575A96126E74E7006F0F12 /* PBXTargetDependency */ = {
    17251799                        isa = PBXTargetDependency;
     
    17741848                        name = Release;
    17751849                };
     1850                A13EBB4D1B87339E00097110 /* Debug */ = {
     1851                        isa = XCBuildConfiguration;
     1852                        baseConfigurationReference = A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */;
     1853                        buildSettings = {
     1854                        };
     1855                        name = Debug;
     1856                };
     1857                A13EBB4E1B87339E00097110 /* Release */ = {
     1858                        isa = XCBuildConfiguration;
     1859                        baseConfigurationReference = A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */;
     1860                        buildSettings = {
     1861                        };
     1862                        name = Release;
     1863                };
    17761864                BC575984126E74AF006F0F12 /* Debug */ = {
    17771865                        isa = XCBuildConfiguration;
     
    18181906                        defaultConfigurationName = Release;
    18191907                };
     1908                A13EBB4C1B87339E00097110 /* Build configuration list for PBXNativeTarget "WebProcessPlugIn" */ = {
     1909                        isa = XCConfigurationList;
     1910                        buildConfigurations = (
     1911                                A13EBB4D1B87339E00097110 /* Debug */,
     1912                                A13EBB4E1B87339E00097110 /* Release */,
     1913                        );
     1914                        defaultConfigurationIsVisible = 0;
     1915                        defaultConfigurationName = Release;
     1916                };
    18201917                BC575986126E74AF006F0F12 /* Build configuration list for PBXNativeTarget "InjectedBundleTestWebKitAPI" */ = {
    18211918                        isa = XCConfigurationList;
  • trunk/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.h

    r188843 r188844  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "PlatformUtilities.h"
    28 
    29 #include <wtf/RetainPtr.h>
    30 #include <wtf/StdLibExtras.h>
    31 
    32 namespace TestWebKitAPI {
    33 namespace Util {
    34 
    35 void run(bool* done)
    36 {
    37     while (!*done)
    38         [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
    39 }
    40 
    41 void sleep(double seconds)
    42 {
    43     usleep(seconds * 1000000);
    44 }
    45 
    46 std::string toSTD(NSString *string)
    47 {
    48     if (!string)
    49         return std::string();
    50 
    51     size_t bufferSize = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
    52     auto buffer = std::make_unique<char[]>(bufferSize);
    53     NSUInteger stringLength;
    54     [string getBytes:buffer.get() maxLength:bufferSize usedLength:&stringLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, [string length]) remainingRange:0];
    55     return std::string(buffer.get(), stringLength);
    56 }
    57 
    58 } // namespace Util
    59 } // namespace TestWebKitAPI
     26@interface WKWebViewConfiguration (TestWebKitAPIExtras)
     27+ (instancetype)testwebkitapi_configurationWithTestPlugInClassName:(NSString *)className;
     28@end
  • trunk/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.mm

    r188843 r188844  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "PlatformUtilities.h"
     26#import "config.h"
     27#import "WKWebViewConfigurationExtras.h"
    2828
    29 #include <wtf/RetainPtr.h>
    30 #include <wtf/StdLibExtras.h>
     29#if WK_API_ENABLED
    3130
    32 namespace TestWebKitAPI {
    33 namespace Util {
     31#import "PlatformUtilities.h"
     32#import <WebKit/WKProcessPoolPrivate.h>
     33#import <WebKit/WKWebViewConfiguration.h>
     34#import <WebKit/_WKProcessPoolConfiguration.h>
     35#import <wtf/RetainPtr.h>
    3436
    35 void run(bool* done)
     37@implementation WKWebViewConfiguration (TestWebKitAPIExtras)
     38
     39+ (instancetype)testwebkitapi_configurationWithTestPlugInClassName:(NSString *)className
    3640{
    37     while (!*done)
    38         [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
     41    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
     42    [processPoolConfiguration setInjectedBundleURL:[[NSBundle mainBundle] URLForResource:@"TestWebKitAPI" withExtension:@"wkbundle"]];
     43
     44    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     45    [processPool _setObject:className forBundleParameter:TestWebKitAPI::Util::TestPlugInClassNameParameter];
     46
     47    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     48    [webViewConfiguration setProcessPool:processPool.get()];
     49
     50    return webViewConfiguration.autorelease();
    3951}
    4052
    41 void sleep(double seconds)
    42 {
    43     usleep(seconds * 1000000);
    44 }
     53@end
    4554
    46 std::string toSTD(NSString *string)
    47 {
    48     if (!string)
    49         return std::string();
    50 
    51     size_t bufferSize = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
    52     auto buffer = std::make_unique<char[]>(bufferSize);
    53     NSUInteger stringLength;
    54     [string getBytes:buffer.get() maxLength:bufferSize usedLength:&stringLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, [string length]) remainingRange:0];
    55     return std::string(buffer.get(), stringLength);
    56 }
    57 
    58 } // namespace Util
    59 } // namespace TestWebKitAPI
     55#endif // WK_API_ENABLED
  • trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm

    r177506 r188844  
    5656}
    5757
     58#if WK_API_ENABLED
     59NSString * const TestPlugInClassNameParameter = @"TestPlugInPrincipalClassName";
     60#endif
    5861} // namespace Util
    5962} // namespace TestWebKitAPI
Note: See TracChangeset for help on using the changeset viewer.