Changeset 233207 in webkit


Ignore:
Timestamp:
Jun 26, 2018 11:16:57 AM (6 years ago)
Author:
Brent Fulgham
Message:

Provide a way for Injected Bundles to indicate classes approved for NSSecureCoding
https://bugs.webkit.org/show_bug.cgi?id=186788
<rdar://problem/41094167>

Reviewed by Chris Dumez.

Source/WebKit:

InjectedBundles support a mechanism to serialize data between the UIProcess and the
WebContent process hosting the bundle. In some cases, we want to be able to serialize
a custom data object that is not part of WebKit's native data types.

After switching to strict NSSecureCoding, WebKit clients attempting to serialize these
custom objects trigger a failure.

This patch makes it possible for the InjectedBundle author to specify one (or more) data
classes that are allowed to be serialized between the two processes.

  • WebProcess/InjectedBundle/API/c/WKBundle.cpp:

(WKBundleExtendClassesForParameterCoder): Added.

  • WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h:
  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm:

(createWKArray): Added.
(-[WKWebProcessPlugInController extendClassesForParameterCoder:]): Added.

  • WebProcess/InjectedBundle/InjectedBundle.h:
  • WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:

(WebKit::InjectedBundle::extendClassesForParameterCoder): Added.
(WebKit::InjectedBundle::classesForCoder): New helper function.
(WebKit::InjectedBundle::setBundleParameter): Modified to use the new set of valid
classes for NSSecureCoding.

Tools:

Add a new test case to exercise the class check during NSSecureCoding.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.h: Added.
  • TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.mm: Added.

(-[CustomBundleObject initWithValue:]):
(+[CustomBundleObject supportsSecureCoding]):
(-[CustomBundleObject copyWithZone:]):
(-[CustomBundleObject initWithCoder:]):
(-[CustomBundleObject encodeWithCoder:]):

  • TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter.mm: Added.

(TestWebKitAPI::didReceiveMessageFromInjectedBundle):
(TestWebKitAPI::didFinishLoadForFrame):

  • TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter_Bundle.mm: Added.

(TestWebKitAPI::CustomBundleParameterTest::CustomBundleParameterTest):
(TestWebKitAPI::CustomBundleParameterTest::didCreatePage):

Location:
trunk
Files:
1 added
9 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r233203 r233207  
     12018-06-26  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Provide a way for Injected Bundles to indicate classes approved for NSSecureCoding
     4        https://bugs.webkit.org/show_bug.cgi?id=186788
     5        <rdar://problem/41094167>
     6
     7        Reviewed by Chris Dumez.
     8
     9        InjectedBundles support a mechanism to serialize data between the UIProcess and the
     10        WebContent process hosting the bundle. In some cases, we want to be able to serialize
     11        a custom data object that is not part of WebKit's native data types.
     12
     13        After switching to strict NSSecureCoding, WebKit clients attempting to serialize these
     14        custom objects trigger a failure.
     15
     16        This patch makes it possible for the InjectedBundle author to specify one (or more) data
     17        classes that are allowed to be serialized between the two processes.
     18       
     19        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
     20        (WKBundleExtendClassesForParameterCoder): Added.
     21        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
     22        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h:
     23        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm:
     24        (createWKArray): Added.
     25        (-[WKWebProcessPlugInController extendClassesForParameterCoder:]): Added.
     26        * WebProcess/InjectedBundle/InjectedBundle.h:
     27        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
     28        (WebKit::InjectedBundle::extendClassesForParameterCoder): Added.
     29        (WebKit::InjectedBundle::classesForCoder): New helper function.
     30        (WebKit::InjectedBundle::setBundleParameter): Modified to use the new set of valid
     31        classes for NSSecureCoding.
     32
    1332018-06-26  Eric Carlson  <eric.carlson@apple.com>
    234
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp

    r226510 r233207  
    294294    ResourceLoadObserver::shared().notifyObserver();
    295295}
     296
     297
     298void WKBundleExtendClassesForParameterCoder(WKBundleRef bundle, WKArrayRef classes)
     299{
     300#if WK_API_ENABLED
     301    auto classList = WebKit::toImpl(classes);
     302    if (!classList)
     303        return;
     304
     305    toImpl(bundle)->extendClassesForParameterCoder(*classList);
     306#endif
     307}
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h

    r223565 r233207  
    9595WK_EXPORT void WKBundleResourceLoadStatisticsNotifyObserver(WKBundleRef);
    9696
     97WK_EXPORT void WKBundleExtendClassesForParameterCoder(WKBundleRef bundle, WKArrayRef classes);
     98
    9799#ifdef __cplusplus
    98100}
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h

    r202789 r233207  
    4444WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0))
    4545@interface WKWebProcessPlugInController : NSObject
     46- (void)extendClassesForParameterCoder:(NSArray *)classes;
    4647
    4748@property (readonly) WKConnection *connection;
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm

    r232520 r233207  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#if WK_API_ENABLED
    3030
     31#import "APIArray.h"
    3132#import "WKConnectionInternal.h"
    3233#import "WKBundle.h"
    3334#import "WKBundleAPICast.h"
    3435#import "WKRetainPtr.h"
     36#import "WKStringCF.h"
    3537#import "WKWebProcessPlugInBrowserContextControllerInternal.h"
    3638#import <wtf/RetainPtr.h>
     
    102104}
    103105
     106static Ref<API::Array> createWKArray(NSArray *array)
     107{
     108    NSUInteger count = [array count];
     109    Vector<RefPtr<API::Object>> strings;
     110    strings.reserveInitialCapacity(count);
     111   
     112    for (id entry in array) {
     113        if ([entry isKindOfClass:[NSString class]])
     114            strings.uncheckedAppend(adoptRef(toImpl(WKStringCreateWithCFString((__bridge CFStringRef)entry))));
     115    }
     116   
     117    return API::Array::create(WTFMove(strings));
     118}
     119
     120- (void)extendClassesForParameterCoder:(NSArray *)classes
     121{
     122    auto classList = createWKArray(classes);
     123    _bundle->extendClassesForParameterCoder(classList.get());
     124}
     125
    104126#pragma mark WKObject protocol implementation
    105127
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h

    r231798 r233207  
    11/*
    2  * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141
    4242#if USE(FOUNDATION)
     43OBJC_CLASS NSSet;
    4344OBJC_CLASS NSBundle;
    4445OBJC_CLASS NSMutableDictionary;
     
    157158#if PLATFORM(COCOA) && WK_API_ENABLED
    158159    WKWebProcessBundleParameters *bundleParameters();
     160
     161    void extendClassesForParameterCoder(API::Array& classes);
     162    NSSet* classesForCoder();
    159163#endif
    160164
     
    171175#if PLATFORM(COCOA) && WK_API_ENABLED
    172176    RetainPtr<WKWebProcessBundleParameters> m_bundleParameters;
     177    RetainPtr<NSSet> m_classesForCoder;
    173178#endif
    174179};
  • trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm

    r232520 r233207  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#import "InjectedBundle.h"
    2828
     29#import "APIArray.h"
    2930#import "APIData.h"
    3031#import "ObjCObjectGraph.h"
     
    3738#import <Foundation/NSBundle.h>
    3839#import <dlfcn.h>
     40#import <objc/runtime.h>
    3941#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    4042#import <stdio.h>
     
    171173    return m_bundleParameters.get();
    172174}
     175
     176void InjectedBundle::extendClassesForParameterCoder(API::Array& classes)
     177{
     178    size_t size = classes.size();
     179
     180    auto mutableSet = adoptNS([classesForCoder() mutableCopy]);
     181
     182    for (size_t i = 0; i < size; ++i) {
     183        API::String* classNameString = classes.at<API::String>(i);
     184        if (!classNameString) {
     185            WTFLogAlways("InjectedBundle::extendClassesForParameterCoder - No class provided as argument %d.\n", i);
     186            break;
     187        }
     188   
     189        CString className = classNameString->string().utf8();
     190        Class objectClass = objc_lookUpClass(className.data());
     191        if (!objectClass) {
     192            WTFLogAlways("InjectedBundle::extendClassesForParameterCoder - Class %s is not a valid Objective C class.\n", className.data());
     193            break;
     194        }
     195
     196        [mutableSet.get() addObject:objectClass];
     197    }
     198
     199    m_classesForCoder = mutableSet;
     200}
     201
     202NSSet* InjectedBundle::classesForCoder()
     203{
     204    if (!m_classesForCoder)
     205        m_classesForCoder = retainPtr([NSSet setWithObjects:[NSArray class], [NSData class], [NSDate class], [NSDictionary class], [NSNull class], [NSNumber class], [NSSet class], [NSString class], [NSTimeZone class], [NSURL class], [NSUUID class], nil]);
     206
     207    return m_classesForCoder.get();
     208}
    173209#endif
    174210
     
    182218    id parameter = nil;
    183219    @try {
    184         parameter = [unarchiver decodeObjectOfClasses:[NSSet setWithObjects:[NSArray class], [NSData class], [NSDate class], [NSDictionary class], [NSNull class], [NSNumber class], [NSSet class], [NSString class], [NSTimeZone class], [NSURL class], [NSUUID class], nil] forKey:@"parameter"];
     220        parameter = [unarchiver decodeObjectOfClasses:classesForCoder() forKey:@"parameter"];
    185221    } @catch (NSException *exception) {
    186222        LOG_ERROR("Failed to decode bundle parameter: %@", exception);
  • trunk/Tools/ChangeLog

    r233190 r233207  
     12018-06-26  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Provide a way for Injected Bundles to indicate classes approved for NSSecureCoding
     4        https://bugs.webkit.org/show_bug.cgi?id=186788
     5        <rdar://problem/41094167>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Add a new test case to exercise the class check during NSSecureCoding.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.h: Added.
     13        * TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.mm: Added.
     14        (-[CustomBundleObject initWithValue:]):
     15        (+[CustomBundleObject supportsSecureCoding]):
     16        (-[CustomBundleObject copyWithZone:]):
     17        (-[CustomBundleObject initWithCoder:]):
     18        (-[CustomBundleObject encodeWithCoder:]):
     19        * TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter.mm: Added.
     20        (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
     21        (TestWebKitAPI::didFinishLoadForFrame):
     22        * TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter_Bundle.mm: Added.
     23        (TestWebKitAPI::CustomBundleParameterTest::CustomBundleParameterTest):
     24        (TestWebKitAPI::CustomBundleParameterTest::didCreatePage):
     25
    1262018-06-25  Daniel Bates  <dabates@apple.com>
    227
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r233025 r233207  
    322322                7A95BDE11E9BEC5F00865498 /* InjectedBundleAppleEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A95BDE01E9BEC4000865498 /* InjectedBundleAppleEvent.cpp */; };
    323323                7A95BDE21E9BEC7400865498 /* InjectedBundleAppleEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A95BDDF1E9BEC4000865498 /* InjectedBundleAppleEvent_Bundle.cpp */; };
     324                7AC7B56D20D9769F002C09A0 /* CustomBundleParameter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56C20D9768F002C09A0 /* CustomBundleParameter.mm */; };
     325                7AC7B56E20D976A7002C09A0 /* CustomBundleParameter_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56B20D9768E002C09A0 /* CustomBundleParameter_Bundle.mm */; };
     326                7AC7B57020D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */; };
     327                7AC7B57120D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */; };
    324328                7AD3FE8E1D76131200B169A4 /* TransformationMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */; };
    325329                7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AE9E5081AE5AE8B00CF874B /* test.pdf */; };
     
    15661570                7AA021BA1AB09EA70052953F /* DateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateMath.cpp; sourceTree = "<group>"; };
    15671571                7AA6A1511AAC0B31002B2ED3 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
     1572                7AC7B56B20D9768E002C09A0 /* CustomBundleParameter_Bundle.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomBundleParameter_Bundle.mm; sourceTree = "<group>"; };
     1573                7AC7B56C20D9768F002C09A0 /* CustomBundleParameter.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomBundleParameter.mm; sourceTree = "<group>"; };
     1574                7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomBundleObject.mm; sourceTree = "<group>"; };
     1575                7AC7B57220D9BAF0002C09A0 /* CustomBundleObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomBundleObject.h; sourceTree = "<group>"; };
    15681576                7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformationMatrix.cpp; sourceTree = "<group>"; };
    15691577                7AE9E5081AE5AE8B00CF874B /* test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test.pdf; sourceTree = "<group>"; };
     
    31833191                                CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */,
    31843192                                CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */,
     3193                                7AC7B57220D9BAF0002C09A0 /* CustomBundleObject.h */,
     3194                                7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */,
     3195                                7AC7B56C20D9768F002C09A0 /* CustomBundleParameter.mm */,
     3196                                7AC7B56B20D9768E002C09A0 /* CustomBundleParameter_Bundle.mm */,
    31853197                                BCAA485714A044D40088FAC4 /* EditorCommands.mm */,
    31863198                                C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */,
     
    35643576                                7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */,
    35653577                                7CCE7EDB1A411A9200447C4C /* CSSParser.cpp in Sources */,
     3578                                7AC7B57020D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */,
     3579                                7AC7B56D20D9769F002C09A0 /* CustomBundleParameter.mm in Sources */,
    35663580                                7CCE7F291A411B1000447C4C /* CustomProtocolsInvalidScheme.mm in Sources */,
    35673581                                7CCE7F2A1A411B1000447C4C /* CustomProtocolsSyncXHRTest.mm in Sources */,
     
    39473961                        files = (
    39483962                                BC246D9C132F1FF000B56D7C /* CanHandleRequest_Bundle.cpp in Sources */,
     3963                                7AC7B57120D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */,
     3964                                7AC7B56E20D976A7002C09A0 /* CustomBundleParameter_Bundle.mm in Sources */,
    39493965                                297234B7173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp in Sources */,
    39503966                                F6B7BE9517469212008A3445 /* DidAssociateFormControls_Bundle.cpp in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.h

    r233206 r233207  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import <WebKit/WKFoundation.h>
     26#pragma once
    2727
    28 #if WK_API_ENABLED
     28@interface CustomBundleObject : NSObject <NSCopying, NSSecureCoding> {
     29    long _somePayload;
     30}
    2931
    30 #import <Foundation/Foundation.h>
    31 #import <WebKit/WKBase.h>
     32@property (nonatomic) long somePayload;
    3233
    33 @class WKConnection;
    34 @class WKWebProcessPlugInController;
    35 @class WKWebProcessPlugInBrowserContextController;
    36 
    37 @protocol WKWebProcessPlugIn <NSObject>
    38 @optional
    39 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController initializeWithObject:(id)initializationObject;
    40 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
    41 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController willDestroyBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
     34- (id)initWithValue:(long)value;
    4235@end
    43 
    44 WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0))
    45 @interface WKWebProcessPlugInController : NSObject
    46 
    47 @property (readonly) WKConnection *connection;
    48 
    49 @property (readonly) id parameters;
    50 
    51 @end
    52 
    53 #endif // WK_API_ENABLED
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.mm

    r233206 r233207  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import <WebKit/WKFoundation.h>
     26#import "config.h"
     27#import "CustomBundleObject.h"
    2728
    28 #if WK_API_ENABLED
     29#if WK_HAVE_C_SPI
    2930
    3031#import <Foundation/Foundation.h>
    31 #import <WebKit/WKBase.h>
    3232
    33 @class WKConnection;
    34 @class WKWebProcessPlugInController;
    35 @class WKWebProcessPlugInBrowserContextController;
     33@implementation CustomBundleObject
    3634
    37 @protocol WKWebProcessPlugIn <NSObject>
    38 @optional
    39 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController initializeWithObject:(id)initializationObject;
    40 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
    41 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController willDestroyBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
     35@synthesize somePayload=_somePayload;
     36
     37- (id)initWithValue:(long)value
     38{
     39    self = [super init];
     40    if (!self)
     41        return nil;
     42   
     43    self.somePayload = value;
     44    return self;
     45}
     46
     47+ (BOOL)supportsSecureCoding
     48{
     49    return YES;
     50}
     51
     52- (id)copyWithZone:(NSZone *)zone
     53{
     54    return [self retain];
     55}
     56
     57- (instancetype)initWithCoder:(NSCoder *)decoder
     58{
     59    self = [super init];
     60    if (!self)
     61        return nil;
     62   
     63    self.somePayload = [decoder decodeIntForKey:@"Payload"];
     64    return self;
     65}
     66
     67- (void)encodeWithCoder:(NSCoder *)coder
     68{
     69    [coder encodeInt:static_cast<long>(_somePayload) forKey:@"Payload"];
     70}
    4271@end
    4372
    44 WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0))
    45 @interface WKWebProcessPlugInController : NSObject
    46 
    47 @property (readonly) WKConnection *connection;
    48 
    49 @property (readonly) id parameters;
    50 
    51 @end
    52 
    53 #endif // WK_API_ENABLED
     73#endif
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter_Bundle.mm

    r233206 r233207  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import <WebKit/WKFoundation.h>
     26#include "config.h"
    2727
    28 #if WK_API_ENABLED
     28#if WK_HAVE_C_SPI
    2929
    30 #import <Foundation/Foundation.h>
    31 #import <WebKit/WKBase.h>
     30#import "CustomBundleObject.h"
     31#import "InjectedBundleTest.h"
     32#import "PlatformUtilities.h"
     33#import <WebKit/WKBundlePrivate.h>
     34#import <WebKit/WKRetainPtr.h>
     35#import <WebKit/WKStringCF.h>
    3236
    33 @class WKConnection;
    34 @class WKWebProcessPlugInController;
    35 @class WKWebProcessPlugInBrowserContextController;
     37namespace TestWebKitAPI {
     38   
     39class CustomBundleParameterTest : public InjectedBundleTest {
     40public:
     41    CustomBundleParameterTest(const std::string& identifier)
     42        : InjectedBundleTest(identifier)
     43    {
     44    }
     45   
     46    virtual void didCreatePage(WKBundleRef bundle, WKBundlePageRef page)
     47    {
     48        WKTypeRef typeName = WKStringCreateWithCFString((__bridge CFStringRef)[CustomBundleObject className]);
     49        auto array = adoptWK(WKArrayCreateAdoptingValues(&typeName, 1));
    3650
    37 @protocol WKWebProcessPlugIn <NSObject>
    38 @optional
    39 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController initializeWithObject:(id)initializationObject;
    40 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
    41 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController willDestroyBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
    42 @end
     51        WKBundleExtendClassesForParameterCoder(bundle, array.get());
     52       
     53        WKRetainPtr<WKDoubleRef> returnCode = adoptWK(WKDoubleCreate(1234));
     54        WKBundlePostMessage(bundle, Util::toWK("DidRegisterCustomClass").get(), returnCode.get());
     55    }
     56};
    4357
    44 WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0))
    45 @interface WKWebProcessPlugInController : NSObject
     58static InjectedBundleTest::Register<CustomBundleParameterTest> registrar("CustomBundleParameterTest");
     59   
     60} // namespace TestWebKitAPI
    4661
    47 @property (readonly) WKConnection *connection;
    48 
    49 @property (readonly) id parameters;
    50 
    51 @end
    52 
    53 #endif // WK_API_ENABLED
     62#endif
Note: See TracChangeset for help on using the changeset viewer.