Changeset 273181 in webkit
- Timestamp:
- Feb 19, 2021 4:26:29 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r273180 r273181 1 2021-02-19 Alex Christensen <achristensen@webkit.org> 2 3 NSError returned by WebKit API should actually conform to NSSecureCoding 4 https://bugs.webkit.org/show_bug.cgi?id=222204 5 <rdar://problem/63893583> 6 7 Reviewed by Chris Dumez. 8 9 When an NSError is encoded, its userInfo is encoded, which means everything we put in userInfo should be encodable. 10 WKReloadFrameErrorRecoveryAttempter was not, so let's make it! When encoded, it will just encode nothing. 11 When decoded, it will produce a WKReloadFrameErrorRecoveryAttempter that does nothing, which is valid behavior, 12 and more desirable than crashing. 13 14 * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.h: 15 * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm: 16 (-[WKReloadFrameErrorRecoveryAttempter encodeWithCoder:]): 17 (-[WKReloadFrameErrorRecoveryAttempter initWithCoder:]): 18 (+[WKReloadFrameErrorRecoveryAttempter supportsSecureCoding]): 19 1 20 2021-02-19 Alex Christensen <achristensen@webkit.org> 2 21 -
trunk/Source/WebKit/UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.h
r242339 r273181 24 24 */ 25 25 26 #import "_WKErrorRecoveryAttempting.h" 26 27 #import <WebKit/WKFoundation.h> 27 28 28 #import <wtf/Forward.h> 29 29 … … 31 31 @class _WKFrameHandle; 32 32 33 @interface WKReloadFrameErrorRecoveryAttempter : NSObject 33 @interface WKReloadFrameErrorRecoveryAttempter : NSObject<_WKErrorRecoveryAttempting, NSSecureCoding> 34 34 35 35 - (id)initWithWebView:(WKWebView *)webView frameHandle:(_WKFrameHandle *)frameHandle urlString:(const String&)urlString; -
trunk/Source/WebKit/UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
r254409 r273181 37 37 #import <wtf/WeakObjCPtr.h> 38 38 39 @interface WKReloadFrameErrorRecoveryAttempter () <_WKErrorRecoveryAttempting>39 @interface WKReloadFrameErrorRecoveryAttempter () 40 40 @end 41 41 … … 72 72 } 73 73 74 - (void)encodeWithCoder:(NSCoder *)coder 75 { 76 } 77 78 - (instancetype)initWithCoder:(NSCoder *)coder 79 { 80 return [super init]; 81 } 82 83 + (BOOL)supportsSecureCoding 84 { 85 return YES; 86 } 87 74 88 @end -
trunk/Tools/ChangeLog
r273167 r273181 1 2021-02-19 Alex Christensen <achristensen@webkit.org> 2 3 NSError returned by WebKit API should actually conform to NSSecureCoding 4 https://bugs.webkit.org/show_bug.cgi?id=222204 5 <rdar://problem/63893583> 6 7 Reviewed by Chris Dumez. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm: 10 (TestWebKitAPI::TEST): 11 * TestWebKitAPI/cocoa/TestNavigationDelegate.h: 12 * TestWebKitAPI/cocoa/TestNavigationDelegate.mm: 13 (-[TestNavigationDelegate waitForDidFailProvisionalNavigation]): 14 1 15 2021-02-16 Jiewen Tan <jiewen_tan@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm
r273062 r273181 574 574 } 575 575 576 TEST(WebKit, ErrorSecureCoding) 577 { 578 HTTPServer server({{ "/", { HTTPResponse::TerminateConnection::Yes }}}); 579 auto webView = [[WKWebView new] autorelease]; 580 auto delegate = [[TestNavigationDelegate new] autorelease]; 581 webView.navigationDelegate = delegate; 582 [webView loadRequest:server.request()]; 583 NSError *error = [delegate waitForDidFailProvisionalNavigation]; 584 585 EXPECT_WK_STREQ(NSStringFromClass([error.userInfo[_WKRecoveryAttempterErrorKey] class]), @"WKReloadFrameErrorRecoveryAttempter"); 586 auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]); 587 [archiver encodeObject:error forKey:NSKeyedArchiveRootObjectKey]; 588 [archiver finishEncoding]; 589 auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:archiver.get().encodedData error:nullptr]); 590 NSError *decodedError = [unarchiver decodeObjectOfClasses:[NSSet setWithObjects:[NSDictionary class], [NSString class], [NSError class], NSClassFromString(@"WKReloadFrameErrorRecoveryAttempter"), nil] forKey:NSKeyedArchiveRootObjectKey]; 591 EXPECT_EQ(decodedError.code, NSURLErrorNetworkConnectionLost); 592 EXPECT_WK_STREQ(decodedError.domain, NSURLErrorDomain); 593 EXPECT_WK_STREQ(NSStringFromClass([decodedError.userInfo[_WKRecoveryAttempterErrorKey] class]), @"WKReloadFrameErrorRecoveryAttempter"); 594 } 595 576 596 // FIXME: Find out why these tests time out on Mojave. 577 597 #if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 -
trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h
r269703 r273181 43 43 - (void)waitForDidFinishNavigation; 44 44 - (void)waitForDidFinishNavigationWithPreferences:(WKWebpagePreferences *)preferences; 45 - ( void)waitForDidFailProvisionalNavigation;45 - (NSError *)waitForDidFailProvisionalNavigation; 46 46 47 47 @end -
trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm
r269703 r273181 31 31 #import <wtf/RetainPtr.h> 32 32 33 @implementation TestNavigationDelegate 33 @implementation TestNavigationDelegate { 34 RetainPtr<NSError> _navigationError; 35 } 34 36 35 37 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler … … 152 154 } 153 155 154 - ( void)waitForDidFailProvisionalNavigation156 - (NSError *)waitForDidFailProvisionalNavigation 155 157 { 156 158 EXPECT_FALSE(self.didFailProvisionalNavigation); 157 159 158 160 __block bool finished = false; 159 self.didFailProvisionalNavigation = ^(WKWebView *, WKNavigation *, NSError *) { 161 self.didFailProvisionalNavigation = ^(WKWebView *, WKNavigation *, NSError *error) { 162 _navigationError = error; 160 163 finished = true; 161 164 }; … … 164 167 165 168 self.didFailProvisionalNavigation = nil; 169 return _navigationError.autorelease(); 166 170 } 167 171
Note: See TracChangeset
for help on using the changeset viewer.