Title: [235584] trunk
Revision
235584
Author
[email protected]
Date
2018-09-01 16:14:31 -0700 (Sat, 01 Sep 2018)

Log Message

[Cocoa] Crash using KVO for 'serverTrust' property of WKWebView - "this class is not key value coding-compliant for the key serverTrust"
https://bugs.webkit.org/show_bug.cgi?id=189222
<rdar://problem/33283179>

Reviewed by Sam Weinig.

Source/WebKit:

Test: TestWebKitAPI/Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView valueForUndefinedKey:]): Override to handle the "serverTrust" key, which is not
  handled automatically by the KVC machinery since the getter’s return type is not an
  Objective-C type.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm: Added.
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (235583 => 235584)


--- trunk/Source/WebKit/ChangeLog	2018-09-01 20:16:01 UTC (rev 235583)
+++ trunk/Source/WebKit/ChangeLog	2018-09-01 23:14:31 UTC (rev 235584)
@@ -1,3 +1,18 @@
+2018-09-01  Dan Bernstein  <[email protected]>
+
+        [Cocoa] Crash using KVO for 'serverTrust' property of WKWebView - "this class is not key value coding-compliant for the key serverTrust"
+        https://bugs.webkit.org/show_bug.cgi?id=189222
+        <rdar://problem/33283179>
+
+        Reviewed by Sam Weinig.
+
+        Test: TestWebKitAPI/Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView valueForUndefinedKey:]): Override to handle the "serverTrust" key, which is not
+          handled automatically by the KVC machinery since the getter’s return type is not an
+          Objective-C type.
+
 2018-08-31  John Wilander  <[email protected]>
 
         Storage Access API: Maintain access through same-site navigations

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (235583 => 235584)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-09-01 20:16:01 UTC (rev 235583)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-09-01 23:14:31 UTC (rev 235584)
@@ -820,6 +820,13 @@
     [super dealloc];
 }
 
+- (id)valueForUndefinedKey:(NSString *)key {
+    if ([key isEqualToString:@"serverTrust"])
+        return (__bridge id)[self serverTrust];
+
+    return [super valueForUndefinedKey:key];
+}
+
 - (WKWebViewConfiguration *)configuration
 {
     return [[_configuration copy] autorelease];

Modified: trunk/Tools/ChangeLog (235583 => 235584)


--- trunk/Tools/ChangeLog	2018-09-01 20:16:01 UTC (rev 235583)
+++ trunk/Tools/ChangeLog	2018-09-01 23:14:31 UTC (rev 235584)
@@ -1,3 +1,15 @@
+2018-09-01  Dan Bernstein  <[email protected]>
+
+        [Cocoa] Crash using KVO for 'serverTrust' property of WKWebView - "this class is not key value coding-compliant for the key serverTrust"
+        https://bugs.webkit.org/show_bug.cgi?id=189222
+        <rdar://problem/33283179>
+
+        Reviewed by Sam Weinig.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm: Added.
+        (TEST):
+
 2018-08-31  Aditya Keerthi  <[email protected]>
 
         Unreviewed, add an alternate email for Aditya Keerthi.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (235583 => 235584)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-09-01 20:16:01 UTC (rev 235583)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-09-01 23:14:31 UTC (rev 235584)
@@ -142,6 +142,7 @@
 		37A22AA71DCAA27200AFBFC4 /* ObservedRenderingProgressEventsAfterCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37A22AA51DCAA27200AFBFC4 /* ObservedRenderingProgressEventsAfterCrash.mm */; };
 		37A709AE1E3EA8B000CA5969 /* BundleRangeHandle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37A709AD1E3EA8B000CA5969 /* BundleRangeHandle.mm */; };
 		37A709AF1E3EA97E00CA5969 /* BundleRangeHandlePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37A709AA1E3EA79000CA5969 /* BundleRangeHandlePlugIn.mm */; };
+		37A9DBE9213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */; };
 		37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37B47E2E1D64E7CA005F4EFF /* WKObject.mm */; };
 		37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */; };
 		37C7CC2D1EA4146B007BD956 /* WeakLinking.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C7CC2B1EA4146B007BD956 /* WeakLinking.cpp */; };
@@ -1397,6 +1398,7 @@
 		37A709AA1E3EA79000CA5969 /* BundleRangeHandlePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleRangeHandlePlugIn.mm; sourceTree = "<group>"; };
 		37A709AC1E3EA7E800CA5969 /* BundleRangeHandleProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BundleRangeHandleProtocol.h; sourceTree = "<group>"; };
 		37A709AD1E3EA8B000CA5969 /* BundleRangeHandle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleRangeHandle.mm; sourceTree = "<group>"; };
+		37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewServerTrustKVC.mm; sourceTree = "<group>"; };
 		37B47E2E1D64E7CA005F4EFF /* WKObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObject.mm; sourceTree = "<group>"; };
 		37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShouldOpenExternalURLsInNewWindowActions.mm; sourceTree = "<group>"; };
 		37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMNode.mm; sourceTree = "<group>"; };
@@ -2444,6 +2446,7 @@
 				2DB647871F4161F70051A89E /* WKWebViewDoesNotLogDuringInitialization.mm */,
 				0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */,
 				D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */,
+				37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */,
 				93F56DA81E5F9181003EDE84 /* WKWebViewSnapshot.mm */,
 				9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */,
 			);
@@ -4068,6 +4071,7 @@
 				0F3B94A71A77267400DE3272 /* WKWebViewEvaluateJavaScript.mm in Sources */,
 				D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */,
 				F4FA91811E61849B007B8C1D /* WKWebViewMacEditingTests.mm in Sources */,
+				37A9DBE9213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm in Sources */,
 				93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
 				9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
 				9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm (0 => 235584)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm	2018-09-01 23:14:31 UTC (rev 235584)
@@ -0,0 +1,39 @@
+/*
+ * 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"
+
+#if WK_API_ENABLED
+
+#import "Test.h"
+#import <wtf/RetainPtr.h>
+
+TEST(WKWebView, ServerTrustKVC)
+{
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    EXPECT_NULL([webView valueForKey:@"serverTrust"]);
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to