WebKit Bugzilla
Attachment 343157 Details for
Bug 186788
: Provide a way for Injected Bundles to indicate classes approved for secure encoding/decoding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v2 (Fix 32-bit build)
bug-186788-20180620082006.patch (text/plain), 26.04 KB, created by
Brent Fulgham
on 2018-06-20 08:20:07 PDT
(
hide
)
Description:
Patch v2 (Fix 32-bit build)
Filename:
MIME Type:
Creator:
Brent Fulgham
Created:
2018-06-20 08:20:07 PDT
Size:
26.04 KB
patch
obsolete
>Subversion Revision: 232847 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ed44a723ee625011cdd69ce07b77208b4ffce201..91434e18241a9cb89ee3ffe42109204675d35c6f 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2018-06-19 Brent Fulgham <bfulgham@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ 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/mac/WKBundleMac.h: >+ * WebProcess/InjectedBundle/API/c/mac/WKBundleMac.mm: >+ (WKBundleExtendClassesForParameterCoder): Added. >+ * WebProcess/InjectedBundle/InjectedBundle.h: >+ * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm: >+ (WebKit::InjectedBundle::extendClassesForParameterCoder): >+ (WebKit::InjectedBundle::classesForCoder): Helper function. >+ (WebKit::InjectedBundle::setBundleParameter): Modified to use the new set of valid >+ classes for NSSecureCoding. >+ > 2018-06-14 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][WPE] WebDriver: handle acceptInsecureCertificates capability >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.h b/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.h >index 639653caddb2db52dab6a838b5ffbaa8dc43cab6..8b5f9bbbd482123142fe0458d99dc39615c4e1e1 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.h >@@ -36,6 +36,7 @@ extern "C" { > > WK_EXPORT id WKBundleGetParameters(WKBundleRef bundle); > >+WK_EXPORT void WKBundleExtendClassesForParameterCoder(WKBundleRef bundle, WKArrayRef classes); > #endif > > #ifdef __cplusplus >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.mm b/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.mm >index d7acc39a0538d896a55672afacca5d374f329128..4b4a1929e332943b7d3bf53044eff0ac58a72b6b 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.mm >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundleMac.mm >@@ -26,6 +26,7 @@ > #import "config.h" > #import "WKBundleMac.h" > >+#import "APIArray.h" > #import "InjectedBundle.h" > #import "WKBundleAPICast.h" > >@@ -37,3 +38,11 @@ id WKBundleGetParameters(WKBundleRef bundle) > return nil; > #endif > } >+ >+void WKBundleExtendClassesForParameterCoder(WKBundleRef bundle, WKArrayRef classes) >+{ >+#if WK_API_ENABLED >+ WebKit::toImpl(bundle)->extendClassesForParameterCoder(*WebKit::toImpl(classes)); >+#endif >+} >+ >diff --git a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h >index 6f8fe7bd89258f8f0f9d10382fd6b3eabfbe307b..16c7c2f2bd2ca867260ede0634ec812595daa17b 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2010-2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -40,6 +40,7 @@ typedef struct _GModule GModule; > #endif > > #if USE(FOUNDATION) >+OBJC_CLASS NSSet; > OBJC_CLASS NSBundle; > OBJC_CLASS NSMutableDictionary; > OBJC_CLASS WKWebProcessBundleParameters; >@@ -156,6 +157,9 @@ public: > > #if PLATFORM(COCOA) && WK_API_ENABLED > WKWebProcessBundleParameters *bundleParameters(); >+ >+ void extendClassesForParameterCoder(API::Array& classes); >+ NSSet* classesForCoder(); > #endif > > private: >@@ -170,6 +174,7 @@ private: > > #if PLATFORM(COCOA) && WK_API_ENABLED > RetainPtr<WKWebProcessBundleParameters> m_bundleParameters; >+ RetainPtr<NSSet> m_classesForCoder; > #endif > }; > >diff --git a/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm b/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm >index 6d3e8d9618e78e35a918823c52e1155e2d338105..b1bc821c61419cd2cadc84cda35648a4f6e035ba 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm >+++ b/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2010 Apple Inc. All rights reserved. >+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -26,6 +26,7 @@ > #import "config.h" > #import "InjectedBundle.h" > >+#import "APIArray.h" > #import "APIData.h" > #import "ObjCObjectGraph.h" > #import "WKBundleAPICast.h" >@@ -36,6 +37,7 @@ > #import <CoreFoundation/CFURL.h> > #import <Foundation/NSBundle.h> > #import <dlfcn.h> >+#import <objc/runtime.h> > #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> > #import <stdio.h> > #import <wtf/RetainPtr.h> >@@ -170,6 +172,40 @@ WKWebProcessBundleParameters *InjectedBundle::bundleParameters() > > return m_bundleParameters.get(); > } >+ >+void InjectedBundle::extendClassesForParameterCoder(API::Array& classes) >+{ >+ size_t size = classes.size(); >+ >+ auto mutableSet = adoptNS([classesForCoder() mutableCopy]); >+ >+ for (size_t i = 0; i < size; ++i) { >+ API::String* classNameString = classes.at<API::String>(i); >+ if (!classNameString) { >+ WTFLogAlways("InjectedBundle::extendClassesForParameterCoder - No class provided as argument %d.\n", i); >+ break; >+ } >+ >+ CString className = classNameString->string().utf8(); >+ Class objectClass = objc_lookUpClass(className.data()); >+ if (!objectClass) { >+ WTFLogAlways("InjectedBundle::extendClassesForParameterCoder - Class %s is not a valid Objective C class.\n", className.data()); >+ break; >+ } >+ >+ [mutableSet.get() addObject:objectClass]; >+ } >+ >+ m_classesForCoder = mutableSet; >+} >+ >+NSSet* InjectedBundle::classesForCoder() >+{ >+ if (!m_classesForCoder) >+ 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]); >+ >+ return m_classesForCoder.get(); >+} > #endif > > void InjectedBundle::setBundleParameter(const String& key, const IPC::DataReference& value) >@@ -181,7 +217,7 @@ void InjectedBundle::setBundleParameter(const String& key, const IPC::DataRefere > > id parameter = nil; > @try { >- 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"]; >+ parameter = [unarchiver decodeObjectOfClasses:classesForCoder() forKey:@"parameter"]; > } @catch (NSException *exception) { > LOG_ERROR("Failed to decode bundle parameter: %@", exception); > return; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index f0df078584dd747b97ad1f9b584a867da24ce219..5cb69ab8eed9945563963bf8b23e1efee9833eda 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,28 @@ >+2018-06-19 Brent Fulgham <bfulgham@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ 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): >+ > 2018-06-14 Carlos Alberto Lopez Perez <clopez@igalia.com> > > [GTK] Enable tests on the GTK EWS queue >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 128a87a661ec6012493e7c263d5b4382a91b15a0..d2661679ec42f19e32e58dfc2389f899fa08582d 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -318,6 +318,10 @@ > 7A909A831D877480007E10F8 /* IntSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A909A751D877475007E10F8 /* IntSize.cpp */; }; > 7A95BDE11E9BEC5F00865498 /* InjectedBundleAppleEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A95BDE01E9BEC4000865498 /* InjectedBundleAppleEvent.cpp */; }; > 7A95BDE21E9BEC7400865498 /* InjectedBundleAppleEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A95BDDF1E9BEC4000865498 /* InjectedBundleAppleEvent_Bundle.cpp */; }; >+ 7AC7B56D20D9769F002C09A0 /* CustomBundleParameter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56C20D9768F002C09A0 /* CustomBundleParameter.mm */; }; >+ 7AC7B56E20D976A7002C09A0 /* CustomBundleParameter_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56B20D9768E002C09A0 /* CustomBundleParameter_Bundle.mm */; }; >+ 7AC7B57020D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */; }; >+ 7AC7B57120D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */; }; > 7AD3FE8E1D76131200B169A4 /* TransformationMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */; }; > 7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AE9E5081AE5AE8B00CF874B /* test.pdf */; }; > 7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */; }; >@@ -1553,6 +1557,10 @@ > 7A99D9931AD4A29D00373141 /* MenuTypesForMouseEvents.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MenuTypesForMouseEvents.mm; sourceTree = "<group>"; }; > 7AA021BA1AB09EA70052953F /* DateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateMath.cpp; sourceTree = "<group>"; }; > 7AA6A1511AAC0B31002B2ED3 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; }; >+ 7AC7B56B20D9768E002C09A0 /* CustomBundleParameter_Bundle.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomBundleParameter_Bundle.mm; sourceTree = "<group>"; }; >+ 7AC7B56C20D9768F002C09A0 /* CustomBundleParameter.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomBundleParameter.mm; sourceTree = "<group>"; }; >+ 7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomBundleObject.mm; sourceTree = "<group>"; }; >+ 7AC7B57220D9BAF0002C09A0 /* CustomBundleObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomBundleObject.h; sourceTree = "<group>"; }; > 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformationMatrix.cpp; sourceTree = "<group>"; }; > 7AE9E5081AE5AE8B00CF874B /* test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test.pdf; sourceTree = "<group>"; }; > 7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CrossPartitionFileSchemeAccess.mm; sourceTree = "<group>"; }; >@@ -3163,6 +3171,10 @@ > 8349D3C11DB96DDA004A9F65 /* ContextMenuDownload.mm */, > CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */, > CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */, >+ 7AC7B57220D9BAF0002C09A0 /* CustomBundleObject.h */, >+ 7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */, >+ 7AC7B56C20D9768F002C09A0 /* CustomBundleParameter.mm */, >+ 7AC7B56B20D9768E002C09A0 /* CustomBundleParameter_Bundle.mm */, > BCAA485714A044D40088FAC4 /* EditorCommands.mm */, > C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */, > C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */, >@@ -3544,6 +3556,8 @@ > 7CCE7EAC1A411A3400447C4C /* Counters.cpp in Sources */, > 7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */, > 7CCE7EDB1A411A9200447C4C /* CSSParser.cpp in Sources */, >+ 7AC7B57020D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */, >+ 7AC7B56D20D9769F002C09A0 /* CustomBundleParameter.mm in Sources */, > 7CCE7F291A411B1000447C4C /* CustomProtocolsInvalidScheme.mm in Sources */, > 7CCE7F2A1A411B1000447C4C /* CustomProtocolsSyncXHRTest.mm in Sources */, > 7CCE7F2B1A411B1000447C4C /* CustomProtocolsTest.mm in Sources */, >@@ -3926,6 +3940,8 @@ > buildActionMask = 2147483647; > files = ( > BC246D9C132F1FF000B56D7C /* CanHandleRequest_Bundle.cpp in Sources */, >+ 7AC7B57120D9BA5B002C09A0 /* CustomBundleObject.mm in Sources */, >+ 7AC7B56E20D976A7002C09A0 /* CustomBundleParameter_Bundle.mm in Sources */, > 297234B7173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp in Sources */, > F6B7BE9517469212008A3445 /* DidAssociateFormControls_Bundle.cpp in Sources */, > AD57AC201DA7465000FF1BDE /* DidRemoveFrameFromHiearchyInPageCache_Bundle.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.h b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ff950499a3754cb08e378eb98a4d89cf4cd9f617 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.h >@@ -0,0 +1,32 @@ >+/* >+ * Copyright (C) 2018 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. >+ */ >+ >+#pragma once >+ >+@interface CustomBundleObject : NSObject <NSCopying, NSSecureCoding> >+@property long somePayload; >+ >+- (id)initWithValue:(long)value; >+@end >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.mm b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..b69877b3b1255baeddc54d5d5919b147318e097f >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.mm >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2018 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 "CustomBundleObject.h" >+ >+#import <Foundation/Foundation.h> >+ >+@implementation CustomBundleObject >+ >+- (id)initWithValue:(long)value >+{ >+ self = [super init]; >+ if (!self) >+ return nil; >+ >+ self.somePayload = value; >+ return self; >+} >+ >++ (BOOL)supportsSecureCoding >+{ >+ return YES; >+} >+ >+- (id)copyWithZone:(NSZone *)zone >+{ >+ return [self retain]; >+} >+ >+- (instancetype)initWithCoder:(NSCoder *)decoder >+{ >+ self = [super init]; >+ if (!self) >+ return nil; >+ >+ self.somePayload = [decoder decodeIntForKey:@"Payload"]; >+ return self; >+} >+ >+- (void)encodeWithCoder:(NSCoder *)coder >+{ >+ [coder encodeInt:static_cast<long>(_somePayload) forKey:@"Payload"]; >+} >+@end >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter.mm b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..2e79da7ac4076d3e649c43c754439e7e56c79c54 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter.mm >@@ -0,0 +1,106 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if WK_HAVE_C_SPI >+ >+#import "CustomBundleObject.h" >+#import "PlatformUtilities.h" >+#import "PlatformWebView.h" >+#import "Test.h" >+#import <WebKit/WKProcessPoolPrivate.h> >+#import <WebKit/WKRetainPtr.h> >+#import <cmath> >+#import <wtf/RetainPtr.h> >+ >+namespace TestWebKitAPI { >+ >+static bool done; >+static bool loadDone; >+static bool messageReceived; >+ >+static void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo) >+{ >+ messageReceived = true; >+ >+ EXPECT_WK_STREQ("DidRegisterCustomClass", messageName); >+ ASSERT_NOT_NULL(messageBody); >+ EXPECT_EQ(WKDoubleGetTypeID(), WKGetTypeID(messageBody)); >+ >+ WKDoubleRef returnCodeMessage = static_cast<WKDoubleRef>(messageBody); >+ double returnCode = WKDoubleGetValue(returnCodeMessage); >+ EXPECT_TRUE(std::isfinite(returnCode)); >+ >+ EXPECT_NE(0, returnCode); >+ >+ // Attempt to set a parameter using the Objective C API: >+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ >+ CustomBundleObject *customObject = [[CustomBundleObject alloc] initWithValue:1234]; >+ [[configuration processPool] _setObject:customObject forBundleParameter:@"TestParameter1"]; >+ >+ if (loadDone) >+ done = true; >+} >+ >+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) >+{ >+ loadDone = true; >+ if (messageReceived) >+ done = true; >+} >+ >+TEST(WebKit, CustomBundleParameter) >+{ >+ WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("CustomBundleParameterTest")); >+ >+ WKContextInjectedBundleClientV0 injectedBundleClient; >+ memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); >+ >+ injectedBundleClient.base.version = 0; >+ injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; >+ >+ WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base); >+ >+ PlatformWebView webView(context.get()); >+ >+ WKPageLoaderClientV0 loaderClient; >+ memset(&loaderClient, 0, sizeof(loaderClient)); >+ >+ loaderClient.base.version = 0; >+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; >+ >+ WKPageSetPageLoaderClient(webView.page(), &loaderClient.base); >+ >+ WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html")); >+ WKPageLoadURL(webView.page(), url.get()); >+ >+ Util::run(&done); >+} >+ >+} // namespace TestWebKitAPI >+ >+#endif >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter_Bundle.mm b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter_Bundle.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..0a7532f1ddcd176f63d308d55fb053ee46e8044b >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter_Bundle.mm >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if WK_HAVE_C_SPI >+ >+#import "CustomBundleObject.h" >+#import "InjectedBundleTest.h" >+#import "PlatformUtilities.h" >+#import <WebKit/WKBundleMac.h> >+#import <WebKit/WKRetainPtr.h> >+#import <WebKit/WKStringCF.h> >+ >+namespace TestWebKitAPI { >+ >+class CustomBundleParameterTest : public InjectedBundleTest { >+public: >+ CustomBundleParameterTest(const std::string& identifier) >+ : InjectedBundleTest(identifier) >+ { >+ } >+ >+ virtual void didCreatePage(WKBundleRef bundle, WKBundlePageRef page) >+ { >+ WKTypeRef typeName = WKStringCreateWithCFString((__bridge CFStringRef)[CustomBundleObject className]); >+ auto array = adoptWK(WKArrayCreateAdoptingValues(&typeName, 1)); >+ >+ WKBundleExtendClassesForParameterCoder(bundle, array.get()); >+ >+ WKRetainPtr<WKDoubleRef> returnCode = adoptWK(WKDoubleCreate(1234)); >+ WKBundlePostMessage(bundle, Util::toWK("DidRegisterCustomClass").get(), returnCode.get()); >+ } >+}; >+ >+static InjectedBundleTest::Register<CustomBundleParameterTest> registrar("CustomBundleParameterTest"); >+ >+} // namespace TestWebKitAPI >+ >+#endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186788
:
343117
|
343157
|
343207
|
343209
|
343214
|
343241
|
343245
|
343246
|
343255
|
343256
|
343271
|
343282
|
343616