Title: [206801] trunk
- Revision
- 206801
- Author
- aes...@apple.com
- Date
- 2016-10-04 18:02:27 -0700 (Tue, 04 Oct 2016)
Log Message
[iOS] Crash in WebResourceLoaderQuickLookDelegate when the client cancels the navigation to a QuickLook resource
https://bugs.webkit.org/show_bug.cgi?id=162950
<rdar://problem/23759114>
Reviewed by Brady Eidson.
Source/WebCore:
When we receive data from QLPreviewConverter for the first time, we call
ResourceLoader::didReceiveResponse() with the preview NSURLResponse from QuickLook. If the
client decides to cancel this navigation in decidePolicyForResponse(),
WebResourceLoaderQuickLookDelegate will end up with a null _resourceLoader after
didReceiveResponse() returns. This change adds null checks in the methods that use
_resourceLoader after calling -_sendDidReceiveResponseIfNecessary.
New API test: QuickLook.CancelNavigationAfterResponse
* platform/network/ios/QuickLook.mm:
(-[WebResourceLoaderQuickLookDelegate connection:didReceiveDataArray:]): Changed to only
call ResourceLoader::didReceiveDataArray() if _resourceLoader is non-null.
(-[WebResourceLoaderQuickLookDelegate connection:didReceiveData:lengthReceived:]): Ditto for
ResourceLoader::didReceiveData().
(-[WebResourceLoaderQuickLookDelegate connection:didFailWithError:]): Ditto for
ResourceLoader::didFail().
Tools:
Added a new API test.
* TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm: Sorted imports and removed redundant
initialization of static bools.
(runTest): Factored out the common test logic between QuickLook.NavigationDelegate and
QuickLook.CancelNavigationAfterResponse.
(TEST): Added QuickLook.CancelNavigationAfterResponse.
(-[QuickLookDecidePolicyDelegate
webView:decidePolicyForNavigationResponse:decisionHandler:]): Canceled the navigation.
(-[QuickLookDecidePolicyDelegate webView:didFailProvisionalNavigation:withError:]): Set
isDone to true.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (206800 => 206801)
--- trunk/Source/WebCore/ChangeLog 2016-10-05 00:42:37 UTC (rev 206800)
+++ trunk/Source/WebCore/ChangeLog 2016-10-05 01:02:27 UTC (rev 206801)
@@ -1,3 +1,28 @@
+2016-10-04 Andy Estes <aes...@apple.com>
+
+ [iOS] Crash in WebResourceLoaderQuickLookDelegate when the client cancels the navigation to a QuickLook resource
+ https://bugs.webkit.org/show_bug.cgi?id=162950
+ <rdar://problem/23759114>
+
+ Reviewed by Brady Eidson.
+
+ When we receive data from QLPreviewConverter for the first time, we call
+ ResourceLoader::didReceiveResponse() with the preview NSURLResponse from QuickLook. If the
+ client decides to cancel this navigation in decidePolicyForResponse(),
+ WebResourceLoaderQuickLookDelegate will end up with a null _resourceLoader after
+ didReceiveResponse() returns. This change adds null checks in the methods that use
+ _resourceLoader after calling -_sendDidReceiveResponseIfNecessary.
+
+ New API test: QuickLook.CancelNavigationAfterResponse
+
+ * platform/network/ios/QuickLook.mm:
+ (-[WebResourceLoaderQuickLookDelegate connection:didReceiveDataArray:]): Changed to only
+ call ResourceLoader::didReceiveDataArray() if _resourceLoader is non-null.
+ (-[WebResourceLoaderQuickLookDelegate connection:didReceiveData:lengthReceived:]): Ditto for
+ ResourceLoader::didReceiveData().
+ (-[WebResourceLoaderQuickLookDelegate connection:didFailWithError:]): Ditto for
+ ResourceLoader::didFail().
+
2016-10-04 Chris Dumez <cdu...@apple.com>
Add support for KeyboardEvent.isComposing attribute
Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.mm (206800 => 206801)
--- trunk/Source/WebCore/platform/network/ios/QuickLook.mm 2016-10-05 00:42:37 UTC (rev 206800)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.mm 2016-10-05 01:02:27 UTC (rev 206801)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -309,7 +309,8 @@
if (_hasFailed)
return;
- _resourceLoader->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray));
+ if (_resourceLoader)
+ _resourceLoader->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray));
}
#endif
@@ -327,7 +328,9 @@
// ResourceHandleMac.cpp added for a different bug.
if (![data length])
return;
- _resourceLoader->didReceiveData(reinterpret_cast<const char*>([data bytes]), [data length], lengthReceived, DataPayloadBytes);
+
+ if (_resourceLoader)
+ _resourceLoader->didReceiveData(reinterpret_cast<const char*>([data bytes]), [data length], lengthReceived, DataPayloadBytes);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
@@ -348,7 +351,8 @@
if (_hasFailed)
return;
- _resourceLoader->didFail(ResourceError(error));
+ if (_resourceLoader)
+ _resourceLoader->didFail(ResourceError(error));
}
- (void)detachHandle
Modified: trunk/Tools/ChangeLog (206800 => 206801)
--- trunk/Tools/ChangeLog 2016-10-05 00:42:37 UTC (rev 206800)
+++ trunk/Tools/ChangeLog 2016-10-05 01:02:27 UTC (rev 206801)
@@ -1,3 +1,23 @@
+2016-10-04 Andy Estes <aes...@apple.com>
+
+ [iOS] Crash in WebResourceLoaderQuickLookDelegate when the client cancels the navigation to a QuickLook resource
+ https://bugs.webkit.org/show_bug.cgi?id=162950
+ <rdar://problem/23759114>
+
+ Reviewed by Brady Eidson.
+
+ Added a new API test.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm: Sorted imports and removed redundant
+ initialization of static bools.
+ (runTest): Factored out the common test logic between QuickLook.NavigationDelegate and
+ QuickLook.CancelNavigationAfterResponse.
+ (TEST): Added QuickLook.CancelNavigationAfterResponse.
+ (-[QuickLookDecidePolicyDelegate
+ webView:decidePolicyForNavigationResponse:decisionHandler:]): Canceled the navigation.
+ (-[QuickLookDecidePolicyDelegate webView:didFailProvisionalNavigation:withError:]): Set
+ isDone to true.
+
2016-10-04 Ryosuke Niwa <rn...@webkit.org>
Add the support for running ES6SampleBench to run-benchmark
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm (206800 => 206801)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm 2016-10-05 00:42:37 UTC (rev 206800)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm 2016-10-05 01:02:27 UTC (rev 206801)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,14 +27,14 @@
#if PLATFORM(IOS)
+#import "PlatformUtilities.h"
#import <WebKit/WKNavigationDelegatePrivate.h>
#import <WebKit/WKWebView.h>
#import <wtf/RetainPtr.h>
-#import "PlatformUtilities.h"
-static bool isDone = false;
-static bool didStartQuickLookLoad = false;
-static bool didFinishQuickLookLoad = false;
+static bool isDone;
+static bool didStartQuickLookLoad;
+static bool didFinishQuickLookLoad;
@interface QuickLookNavigationDelegate : NSObject <WKNavigationDelegatePrivate>
@end
@@ -61,17 +61,44 @@
@end
-TEST(QuickLook, NavigationDelegate)
+static void runTest(Class navigationDelegateClass)
{
auto webView = adoptNS([[WKWebView alloc] init]);
- auto navigationDelegate = adoptNS([[QuickLookNavigationDelegate alloc] init]);
+ auto navigationDelegate = adoptNS([[navigationDelegateClass alloc] init]);
[webView setNavigationDelegate:navigationDelegate.get()];
[webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"pages" withExtension:@"pages" subdirectory:@"TestWebKitAPI.resources"]]];
+ isDone = false;
TestWebKitAPI::Util::run(&isDone);
+}
+TEST(QuickLook, NavigationDelegate)
+{
+ runTest([QuickLookNavigationDelegate class]);
EXPECT_TRUE(didStartQuickLookLoad);
EXPECT_TRUE(didFinishQuickLookLoad);
}
+@interface QuickLookDecidePolicyDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation QuickLookDecidePolicyDelegate
+
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
+{
+ decisionHandler(WKNavigationResponsePolicyCancel);
+}
+
+- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
+{
+ isDone = true;
+}
+
+@end
+
+TEST(QuickLook, CancelNavigationAfterResponse)
+{
+ runTest([QuickLookDecidePolicyDelegate class]);
+}
+
#endif // PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes