- Revision
- 150609
- Author
- [email protected]
- Date
- 2013-05-23 13:08:21 -0700 (Thu, 23 May 2013)
Log Message
Crash in convertMainResourceLoadToDownload when downloading file by option-return
https://bugs.webkit.org/show_bug.cgi?id=116451
Reviewed by Andreas Kling.
Source/WebCore:
Handle MainResourceLoader being null here which will happen when loading a cached main resource.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
Source/WebKit/mac:
If the main resource loader is null, create a new download instead since there's no existing loader to convert.
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::convertMainResourceLoadToDownload):
Source/WebKit2:
If the main resource loader is null, create a new download instead since there's no existing loader to convert.
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::convertMainResourceLoadToDownload):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::convertMainResourceLoadToDownload):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (150608 => 150609)
--- trunk/Source/WebCore/ChangeLog 2013-05-23 19:56:14 UTC (rev 150608)
+++ trunk/Source/WebCore/ChangeLog 2013-05-23 20:08:21 UTC (rev 150609)
@@ -1,3 +1,15 @@
+2013-05-23 Anders Carlsson <[email protected]>
+
+ Crash in convertMainResourceLoadToDownload when downloading file by option-return
+ https://bugs.webkit.org/show_bug.cgi?id=116451
+
+ Reviewed by Andreas Kling.
+
+ Handle MainResourceLoader being null here which will happen when loading a cached main resource.
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::continueAfterContentPolicy):
+
2013-05-23 Benjamin Poulain <[email protected]>
KURL::createCFURL() should return a RetainPtr<CFURLRef>
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (150608 => 150609)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2013-05-23 19:56:14 UTC (rev 150608)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2013-05-23 20:08:21 UTC (rev 150609)
@@ -668,8 +668,10 @@
mainReceivedError(frameLoader()->client()->cannotShowURLError(m_request));
return;
}
- InspectorInstrumentation::continueWithPolicyDownload(m_frame, this, mainResourceLoader()->identifier(), m_response);
+ if (ResourceLoader* mainResourceLoader = this->mainResourceLoader())
+ InspectorInstrumentation::continueWithPolicyDownload(m_frame, this, mainResourceLoader->identifier(), m_response);
+
// When starting the request, we didn't know that it would result in download and not navigation. Now we know that main document URL didn't change.
// Download may use this knowledge for purposes unrelated to cookies, notably for setting file quarantine data.
frameLoader()->setOriginalURLForDownloadRequest(m_request);
@@ -681,7 +683,8 @@
return;
}
case PolicyIgnore:
- InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, mainResourceLoader()->identifier(), m_response);
+ if (ResourceLoader* mainResourceLoader = this->mainResourceLoader())
+ InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, mainResourceLoader->identifier(), m_response);
stopLoadingForPolicyChange();
return;
Modified: trunk/Source/WebKit/mac/ChangeLog (150608 => 150609)
--- trunk/Source/WebKit/mac/ChangeLog 2013-05-23 19:56:14 UTC (rev 150608)
+++ trunk/Source/WebKit/mac/ChangeLog 2013-05-23 20:08:21 UTC (rev 150609)
@@ -1,3 +1,15 @@
+2013-05-23 Anders Carlsson <[email protected]>
+
+ Crash in convertMainResourceLoadToDownload when downloading file by option-return
+ https://bugs.webkit.org/show_bug.cgi?id=116451
+
+ Reviewed by Andreas Kling.
+
+ If the main resource loader is null, create a new download instead since there's no existing loader to convert.
+
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::convertMainResourceLoadToDownload):
+
2013-05-22 Simon Fraser <[email protected]>
Fix issues with focus rings on search fields
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (150608 => 150609)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm 2013-05-23 19:56:14 UTC (rev 150608)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm 2013-05-23 20:08:21 UTC (rev 150609)
@@ -278,11 +278,19 @@
void WebFrameLoaderClient::convertMainResourceLoadToDownload(DocumentLoader* documentLoader, const ResourceRequest& request, const ResourceResponse& response)
{
+ WebView *webView = getWebView(m_webFrame.get());
+
+ if (!documentLoader->mainResourceLoader()) {
+ // The resource has already been cached, start a new download.
+ WebDownload *webDownload = [[WebDownload alloc] initWithRequest:request.nsURLRequest(UpdateHTTPBody) delegate:[webView downloadDelegate]];
+ [webDownload autorelease];
+ return;
+ }
+
ResourceHandle* handle = documentLoader->mainResourceLoader()->handle();
#if USE(CFNETWORK)
ASSERT([WebDownload respondsToSelector:@selector(_downloadWithLoadingCFURLConnection:request:response:delegate:proxy:)]);
- WebView *webView = getWebView(m_webFrame.get());
CFURLConnectionRef connection = handle->connection();
[WebDownload _downloadWithLoadingCFURLConnection:connection
request:request.cfURLRequest(UpdateHTTPBody)
@@ -294,7 +302,6 @@
handle->releaseConnectionForDownload();
CFRelease(connection);
#else
- WebView *webView = getWebView(m_webFrame.get());
[WebDownload _downloadWithLoadingConnection:handle->connection()
request:request.nsURLRequest(UpdateHTTPBody)
response:response.nsURLResponse()
Modified: trunk/Source/WebKit2/ChangeLog (150608 => 150609)
--- trunk/Source/WebKit2/ChangeLog 2013-05-23 19:56:14 UTC (rev 150608)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-23 20:08:21 UTC (rev 150609)
@@ -1,3 +1,17 @@
+2013-05-23 Anders Carlsson <[email protected]>
+
+ Crash in convertMainResourceLoadToDownload when downloading file by option-return
+ https://bugs.webkit.org/show_bug.cgi?id=116451
+
+ Reviewed by Andreas Kling.
+
+ If the main resource loader is null, create a new download instead since there's no existing loader to convert.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::convertMainResourceLoadToDownload):
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::convertMainResourceLoadToDownload):
+
2013-05-22 Alexey Proskuryakov <[email protected]>
<rdar://problem/13849260> Sandbox violations reading .CFUserTextEncoding
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (150608 => 150609)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2013-05-23 19:56:14 UTC (rev 150608)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2013-05-23 20:08:21 UTC (rev 150609)
@@ -175,6 +175,11 @@
void NetworkConnectionToWebProcess::convertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, const ResourceRequest& request, const ResourceResponse& response)
{
+ if (!mainResourceLoadIdentifier) {
+ NetworkProcess::shared().downloadManager().startDownload(downloadID, request);
+ return;
+ }
+
NetworkResourceLoader* loader = m_networkResourceLoaders.get(mainResourceLoadIdentifier);
NetworkProcess::shared().downloadManager().convertHandleToDownload(downloadID, loader->handle(), request, response);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (150608 => 150609)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2013-05-23 19:56:14 UTC (rev 150608)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2013-05-23 20:08:21 UTC (rev 150609)
@@ -256,13 +256,29 @@
uint64_t policyDownloadID = m_policyDownloadID;
m_policyDownloadID = 0;
+ ResourceLoader* mainResourceLoader = documentLoader->mainResourceLoader();
+
#if ENABLE(NETWORK_PROCESS)
if (WebProcess::shared().usesNetworkProcess()) {
- WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ConvertMainResourceLoadToDownload(documentLoader->mainResourceLoader()->identifier(), policyDownloadID, request, response), 0);
+ // Use 0 to indicate that there is no main resource loader.
+ // This can happen if the main resource is in the WebCore memory cache.
+ uint64_t mainResourceLoadIdentifier;
+ if (mainResourceLoader)
+ mainResourceLoadIdentifier = mainResourceLoader->identifier();
+ else
+ mainResourceLoadIdentifier = 0;
+
+ WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ConvertMainResourceLoadToDownload(mainResourceLoadIdentifier, policyDownloadID, request, response), 0);
return;
}
#endif
+ if (!mainResourceLoader) {
+ // The main resource has already been loaded. Start a new download instead.
+ WebProcess::shared().downloadManager().startDownload(policyDownloadID, request);
+ return;
+ }
+
WebProcess::shared().downloadManager().convertHandleToDownload(policyDownloadID, documentLoader->mainResourceLoader()->handle(), request, response);
}