Changeset 206801 in webkit
- Timestamp:
- Oct 4, 2016, 6:02:27 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206796 r206801 1 2016-10-04 Andy Estes <aestes@apple.com> 2 3 [iOS] Crash in WebResourceLoaderQuickLookDelegate when the client cancels the navigation to a QuickLook resource 4 https://bugs.webkit.org/show_bug.cgi?id=162950 5 <rdar://problem/23759114> 6 7 Reviewed by Brady Eidson. 8 9 When we receive data from QLPreviewConverter for the first time, we call 10 ResourceLoader::didReceiveResponse() with the preview NSURLResponse from QuickLook. If the 11 client decides to cancel this navigation in decidePolicyForResponse(), 12 WebResourceLoaderQuickLookDelegate will end up with a null _resourceLoader after 13 didReceiveResponse() returns. This change adds null checks in the methods that use 14 _resourceLoader after calling -_sendDidReceiveResponseIfNecessary. 15 16 New API test: QuickLook.CancelNavigationAfterResponse 17 18 * platform/network/ios/QuickLook.mm: 19 (-[WebResourceLoaderQuickLookDelegate connection:didReceiveDataArray:]): Changed to only 20 call ResourceLoader::didReceiveDataArray() if _resourceLoader is non-null. 21 (-[WebResourceLoaderQuickLookDelegate connection:didReceiveData:lengthReceived:]): Ditto for 22 ResourceLoader::didReceiveData(). 23 (-[WebResourceLoaderQuickLookDelegate connection:didFailWithError:]): Ditto for 24 ResourceLoader::didFail(). 25 1 26 2016-10-04 Chris Dumez <cdumez@apple.com> 2 27 -
trunk/Source/WebCore/platform/network/ios/QuickLook.mm
r199669 r206801 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2009-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 310 310 return; 311 311 312 _resourceLoader->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray)); 312 if (_resourceLoader) 313 _resourceLoader->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray)); 313 314 } 314 315 #endif … … 328 329 if (![data length]) 329 330 return; 330 _resourceLoader->didReceiveData(reinterpret_cast<const char*>([data bytes]), [data length], lengthReceived, DataPayloadBytes); 331 332 if (_resourceLoader) 333 _resourceLoader->didReceiveData(reinterpret_cast<const char*>([data bytes]), [data length], lengthReceived, DataPayloadBytes); 331 334 } 332 335 … … 349 352 return; 350 353 351 _resourceLoader->didFail(ResourceError(error)); 354 if (_resourceLoader) 355 _resourceLoader->didFail(ResourceError(error)); 352 356 } 353 357 -
trunk/Tools/ChangeLog
r206800 r206801 1 2016-10-04 Andy Estes <aestes@apple.com> 2 3 [iOS] Crash in WebResourceLoaderQuickLookDelegate when the client cancels the navigation to a QuickLook resource 4 https://bugs.webkit.org/show_bug.cgi?id=162950 5 <rdar://problem/23759114> 6 7 Reviewed by Brady Eidson. 8 9 Added a new API test. 10 11 * TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm: Sorted imports and removed redundant 12 initialization of static bools. 13 (runTest): Factored out the common test logic between QuickLook.NavigationDelegate and 14 QuickLook.CancelNavigationAfterResponse. 15 (TEST): Added QuickLook.CancelNavigationAfterResponse. 16 (-[QuickLookDecidePolicyDelegate 17 webView:decidePolicyForNavigationResponse:decisionHandler:]): Canceled the navigation. 18 (-[QuickLookDecidePolicyDelegate webView:didFailProvisionalNavigation:withError:]): Set 19 isDone to true. 20 1 21 2016-10-04 Ryosuke Niwa <rniwa@webkit.org> 2 22 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm
r189997 r206801 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if PLATFORM(IOS) 29 29 30 #import "PlatformUtilities.h" 30 31 #import <WebKit/WKNavigationDelegatePrivate.h> 31 32 #import <WebKit/WKWebView.h> 32 33 #import <wtf/RetainPtr.h> 33 #import "PlatformUtilities.h"34 34 35 static bool isDone = false;36 static bool didStartQuickLookLoad = false;37 static bool didFinishQuickLookLoad = false;35 static bool isDone; 36 static bool didStartQuickLookLoad; 37 static bool didFinishQuickLookLoad; 38 38 39 39 @interface QuickLookNavigationDelegate : NSObject <WKNavigationDelegatePrivate> … … 62 62 @end 63 63 64 TEST(QuickLook, NavigationDelegate)64 static void runTest(Class navigationDelegateClass) 65 65 { 66 66 auto webView = adoptNS([[WKWebView alloc] init]); 67 auto navigationDelegate = adoptNS([[ QuickLookNavigationDelegatealloc] init]);67 auto navigationDelegate = adoptNS([[navigationDelegateClass alloc] init]); 68 68 [webView setNavigationDelegate:navigationDelegate.get()]; 69 69 [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"pages" withExtension:@"pages" subdirectory:@"TestWebKitAPI.resources"]]]; 70 70 71 isDone = false; 71 72 TestWebKitAPI::Util::run(&isDone); 73 } 72 74 75 TEST(QuickLook, NavigationDelegate) 76 { 77 runTest([QuickLookNavigationDelegate class]); 73 78 EXPECT_TRUE(didStartQuickLookLoad); 74 79 EXPECT_TRUE(didFinishQuickLookLoad); 75 80 } 76 81 82 @interface QuickLookDecidePolicyDelegate : NSObject <WKNavigationDelegate> 83 @end 84 85 @implementation QuickLookDecidePolicyDelegate 86 87 - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler 88 { 89 decisionHandler(WKNavigationResponsePolicyCancel); 90 } 91 92 - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error 93 { 94 isDone = true; 95 } 96 97 @end 98 99 TEST(QuickLook, CancelNavigationAfterResponse) 100 { 101 runTest([QuickLookDecidePolicyDelegate class]); 102 } 103 77 104 #endif // PLATFORM(IOS)
Note:
See TracChangeset
for help on using the changeset viewer.