Diff
Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog 2015-10-15 06:46:22 UTC (rev 191089)
@@ -1,5 +1,36 @@
2015-10-14 Matthew Hanson <matthew_han...@apple.com>
+ Merge r188486. rdar://problem/22707497
+
+ 2015-08-13 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Downloads do not start if policy decision is made asynchronously
+ https://bugs.webkit.org/show_bug.cgi?id=147985
+
+ Reviewed by Brady Eidson.
+
+ It's only possible to convert a NSURLConnection to a download while the connection delegate's
+ -connection:didReceiveResponse: is being called. However, WebKit clients can decide content policy
+ asynchronously. If a client chooses to download a response asynchronously, we can no longer convert the
+ connection to a download, so we should start a new download instead.
+
+ New API test: _WKDownload.AsynchronousDownloadPolicy
+
+ * dom/Document.cpp: Updated to include SubresourceLoader.h.
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::mainResourceLoader): Updated to return a SubresourceLoader.
+ (WebCore::DocumentLoader::continueAfterContentPolicy): Cast mainResourceLoader() to a ResourceLoader since
+ didFail() is private in SubresourceLoader.
+ * loader/DocumentLoader.h:
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::SubresourceLoader): Initialized m_callingDidReceiveResponse to false.
+ (WebCore::SubresourceLoader::didReceiveResponse): Used TemporaryChange<> to set m_callingDidReceiveResponse to true.
+ * loader/SubresourceLoader.h:
+ * loader/appcache/ApplicationCacheHost.cpp: Updated to include SubresourceLoader.h.
+ * loader/mac/DocumentLoaderMac.cpp: Ditto.
+
+2015-10-14 Matthew Hanson <matthew_han...@apple.com>
+
Merge r188416. rdar://problem/22803749
2015-08-13 Jer Noble <jer.no...@apple.com>
Modified: branches/safari-601.1.46-branch/Source/WebCore/dom/Document.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/dom/Document.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/dom/Document.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -124,7 +124,6 @@
#include "RenderView.h"
#include "RenderWidget.h"
#include "ResourceLoadScheduler.h"
-#include "ResourceLoader.h"
#include "RuntimeEnabledFeatures.h"
#include "SVGDocumentExtensions.h"
#include "SVGElement.h"
@@ -147,6 +146,7 @@
#include "StyleResolver.h"
#include "StyleSheetContents.h"
#include "StyleSheetList.h"
+#include "SubresourceLoader.h"
#include "TextNodeTraversal.h"
#include "TextResourceDecoder.h"
#include "TransformSource.h"
Modified: branches/safari-601.1.46-branch/Source/WebCore/loader/DocumentLoader.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/loader/DocumentLoader.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/loader/DocumentLoader.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -154,7 +154,7 @@
return &m_frame->loader();
}
-ResourceLoader* DocumentLoader::mainResourceLoader() const
+SubresourceLoader* DocumentLoader::mainResourceLoader() const
{
return m_mainResource ? m_mainResource->loader() : 0;
}
@@ -720,7 +720,7 @@
// It might have gone missing
if (mainResourceLoader())
- mainResourceLoader()->didFail(interruptedForPolicyChangeError());
+ static_cast<ResourceLoader*>(mainResourceLoader())->didFail(interruptedForPolicyChangeError());
return;
}
case PolicyIgnore:
Modified: branches/safari-601.1.46-branch/Source/WebCore/loader/DocumentLoader.h (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/loader/DocumentLoader.h 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/loader/DocumentLoader.h 2015-10-15 06:46:22 UTC (rev 191089)
@@ -70,6 +70,7 @@
class Page;
class ResourceLoader;
class SharedBuffer;
+ class SubresourceLoader;
class SubstituteResource;
#if ENABLE(CONTENT_FILTERING)
@@ -94,7 +95,7 @@
WEBCORE_EXPORT virtual void detachFromFrame();
WEBCORE_EXPORT FrameLoader* frameLoader() const;
- WEBCORE_EXPORT ResourceLoader* mainResourceLoader() const;
+ WEBCORE_EXPORT SubresourceLoader* mainResourceLoader() const;
WEBCORE_EXPORT PassRefPtr<SharedBuffer> mainResourceData() const;
DocumentWriter& writer() const { return m_writer; }
Modified: branches/safari-601.1.46-branch/Source/WebCore/loader/SubresourceLoader.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/loader/SubresourceLoader.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/loader/SubresourceLoader.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -44,6 +44,7 @@
#include <wtf/Ref.h>
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/StdLibExtras.h>
+#include <wtf/TemporaryChange.h>
#include <wtf/text/CString.h>
#if PLATFORM(IOS)
@@ -202,6 +203,8 @@
ASSERT(!response.isNull());
ASSERT(m_state == Initialized);
+ TemporaryChange<bool> callingDidReceiveResponse(m_callingDidReceiveResponse, true);
+
// Reference the object in this method since the additional processing can do
// anything including removing the last reference to this object; one example of this is 3266216.
Ref<SubresourceLoader> protect(*this);
Modified: branches/safari-601.1.46-branch/Source/WebCore/loader/SubresourceLoader.h (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/loader/SubresourceLoader.h 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/loader/SubresourceLoader.h 2015-10-15 06:46:22 UTC (rev 191089)
@@ -58,6 +58,8 @@
virtual const ResourceRequest& iOSOriginalRequest() const override { return m_iOSOriginalRequest; }
#endif
+ bool callingDidReceiveResponse() const { return m_callingDidReceiveResponse; }
+
private:
SubresourceLoader(Frame*, CachedResource*, const ResourceLoaderOptions&);
@@ -121,6 +123,7 @@
bool m_loadingMultipartContent;
SubresourceLoaderState m_state;
std::unique_ptr<RequestCountTracker> m_requestCountTracker;
+ bool m_callingDidReceiveResponse { false };
};
}
Modified: branches/safari-601.1.46-branch/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -39,9 +39,9 @@
#include "MainFrame.h"
#include "ProgressEvent.h"
#include "ResourceHandle.h"
-#include "ResourceLoader.h"
#include "ResourceRequest.h"
#include "Settings.h"
+#include "SubresourceLoader.h"
namespace WebCore {
Modified: branches/safari-601.1.46-branch/Source/WebCore/loader/mac/DocumentLoaderMac.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebCore/loader/mac/DocumentLoaderMac.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebCore/loader/mac/DocumentLoaderMac.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -29,7 +29,7 @@
#include "config.h"
#include "DocumentLoader.h"
-#include "ResourceLoader.h"
+#include "SubresourceLoader.h"
namespace WebCore {
Modified: branches/safari-601.1.46-branch/Source/WebKit/mac/ChangeLog (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebKit/mac/ChangeLog 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebKit/mac/ChangeLog 2015-10-15 06:46:22 UTC (rev 191089)
@@ -1,3 +1,17 @@
+2015-10-14 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r188486. rdar://problem/22707497
+
+ 2015-08-13 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Downloads do not start if policy decision is made asynchronously
+ https://bugs.webkit.org/show_bug.cgi?id=147985
+
+ Reviewed by Brady Eidson.
+
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::convertMainResourceLoadToDownload): Started a new download if the main resource loader is not calling didReceiveResponse.
+
2015-10-02 Babak Shafiei <bshaf...@apple.com>
Merge r190092.
Modified: branches/safari-601.1.46-branch/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm 2015-10-15 06:46:22 UTC (rev 191089)
@@ -111,10 +111,10 @@
#import <WebCore/ProtectionSpace.h>
#import <WebCore/ResourceError.h>
#import <WebCore/ResourceHandle.h>
-#import <WebCore/ResourceLoader.h>
#import <WebCore/ResourceRequest.h>
#import <WebCore/ScriptController.h>
#import <WebCore/SharedBuffer.h>
+#import <WebCore/SubresourceLoader.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <WebCore/WebScriptObjectPrivate.h>
#import <WebCore/Widget.h>
@@ -286,9 +286,10 @@
void WebFrameLoaderClient::convertMainResourceLoadToDownload(DocumentLoader* documentLoader, const ResourceRequest& request, const ResourceResponse& response)
{
WebView *webView = getWebView(m_webFrame.get());
+ SubresourceLoader* mainResourceLoader = documentLoader->mainResourceLoader();
- if (!documentLoader->mainResourceLoader()) {
- // The resource has already been cached, start a new download.
+ if (!mainResourceLoader || !mainResourceLoader->callingDidReceiveResponse()) {
+ // The resource has already been cached, or the conversion is being attmpted when not calling SubresourceLoader::didReceiveResponse().
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
WebDownload *webDownload = [[WebDownload alloc] initWithRequest:request.nsURLRequest(UpdateHTTPBody) delegate:[webView downloadDelegate]];
@@ -297,7 +298,7 @@
return;
}
- ResourceHandle* handle = documentLoader->mainResourceLoader()->handle();
+ ResourceHandle* handle = mainResourceLoader->handle();
#if USE(CFNETWORK)
ASSERT([WebDownload respondsToSelector:@selector(_downloadWithLoadingCFURLConnection:request:response:delegate:proxy:)]);
Modified: branches/safari-601.1.46-branch/Source/WebKit/win/ChangeLog (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebKit/win/ChangeLog 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebKit/win/ChangeLog 2015-10-15 06:46:22 UTC (rev 191089)
@@ -1 +1,14 @@
+2015-10-14 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r188486. rdar://problem/22707497
+
+ 2015-08-13 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Downloads do not start if policy decision is made asynchronously
+ https://bugs.webkit.org/show_bug.cgi?id=147985
+
+ Reviewed by Brady Eidson.
+
+ * WebCoreSupport/WebFrameLoaderClient.cpp: Updated to include SubresourceLoader.h.
+
== Rolled over to ChangeLog-2015-07-23 ==
Modified: branches/safari-601.1.46-branch/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -79,9 +79,9 @@
#include <WebCore/PolicyChecker.h>
#include <WebCore/RenderWidget.h>
#include <WebCore/ResourceHandle.h>
-#include <WebCore/ResourceLoader.h>
#include <WebCore/ScriptController.h>
#include <WebCore/Settings.h>
+#include <WebCore/SubresourceLoader.h>
using namespace WebCore;
using namespace HTMLNames;
Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-10-15 06:46:22 UTC (rev 191089)
@@ -1,3 +1,18 @@
+2015-10-14 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r188486. rdar://problem/22707497
+
+ 2015-08-13 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Downloads do not start if policy decision is made asynchronously
+ https://bugs.webkit.org/show_bug.cgi?id=147985
+
+ Reviewed by Brady Eidson.
+
+ * WebProcess/Network/WebResourceLoader.cpp: Updated to include SubresourceLoader.h.
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::convertMainResourceLoadToDownload): Started a new download if the main resource loader is not calling didReceiveResponse.
+
2015-10-13 Babak Shafiei <bshaf...@apple.com>
Merge r191022.
Modified: branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -40,6 +40,7 @@
#include <WebCore/DocumentLoader.h>
#include <WebCore/ResourceError.h>
#include <WebCore/ResourceLoader.h>
+#include <WebCore/SubresourceLoader.h>
using namespace WebCore;
Modified: branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (191088 => 191089)
--- branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp 2015-10-15 06:46:22 UTC (rev 191089)
@@ -70,9 +70,9 @@
#include <WebCore/Page.h>
#include <WebCore/PluginDocument.h>
#include <WebCore/RenderTreeAsText.h>
-#include <WebCore/ResourceLoader.h>
#include <WebCore/ScriptController.h>
#include <WebCore/SecurityOrigin.h>
+#include <WebCore/SubresourceLoader.h>
#include <WebCore/TextIterator.h>
#include <WebCore/TextResourceDecoder.h>
#include <wtf/text/StringBuilder.h>
@@ -274,15 +274,16 @@
uint64_t policyDownloadID = m_policyDownloadID;
m_policyDownloadID = 0;
- ResourceLoader* mainResourceLoader = documentLoader->mainResourceLoader();
+ SubresourceLoader* mainResourceLoader = documentLoader->mainResourceLoader();
auto& webProcess = WebProcess::singleton();
#if ENABLE(NETWORK_PROCESS)
if (webProcess.usesNetworkProcess()) {
- // Use 0 to indicate that there is no main resource loader.
- // This can happen if the main resource is in the WebCore memory cache.
+ // Use 0 to indicate that the resource load can't be converted and a new download must be started.
+ // This can happen if there is no loader because the main resource is in the WebCore memory cache,
+ // or because the conversion was attempted when not calling SubresourceLoader::didReceiveResponse().
uint64_t mainResourceLoadIdentifier;
- if (mainResourceLoader)
+ if (mainResourceLoader && mainResourceLoader->callingDidReceiveResponse())
mainResourceLoadIdentifier = mainResourceLoader->identifier();
else
mainResourceLoadIdentifier = 0;
@@ -292,7 +293,7 @@
}
#endif
- if (!mainResourceLoader) {
+ if (!mainResourceLoader || !mainResourceLoader->callingDidReceiveResponse()) {
// The main resource has already been loaded. Start a new download instead.
webProcess.downloadManager().startDownload(policyDownloadID, request);
return;
Modified: branches/safari-601.1.46-branch/Tools/ChangeLog (191088 => 191089)
--- branches/safari-601.1.46-branch/Tools/ChangeLog 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Tools/ChangeLog 2015-10-15 06:46:22 UTC (rev 191089)
@@ -1,3 +1,21 @@
+2015-10-14 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r188486. rdar://problem/22707497
+
+ 2015-08-13 Andy Estes <aes...@apple.com>
+
+ [Cocoa] Downloads do not start if policy decision is made asynchronously
+ https://bugs.webkit.org/show_bug.cgi?id=147985
+
+ Reviewed by Brady Eidson.
+
+ Added a new API test.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm:
+ (-[AsynchronousDownloadNavigationDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]):
+ (-[AsynchronousDownloadDelegate _downloadDidStart:]):
+ (TEST):
+
2015-10-08 Andy Estes <aes...@apple.com>
Merge r188486, r188517, r188531, r188844, r188845, r188851, r188852, r188880, r188881, r188988, r189193, r189289, and r190133.
Modified: branches/safari-601.1.46-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm (191088 => 191089)
--- branches/safari-601.1.46-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm 2015-10-15 06:46:15 UTC (rev 191088)
+++ branches/safari-601.1.46-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm 2015-10-15 06:46:22 UTC (rev 191089)
@@ -265,5 +265,34 @@
TestWebKitAPI::Util::run(&isDone);
}
+@interface AsynchronousDownloadNavigationDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation AsynchronousDownloadNavigationDelegate
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
+{
+ dispatch_async(dispatch_get_main_queue(), ^ {
+ decisionHandler(_WKNavigationResponsePolicyBecomeDownload);
+ });
+}
+@end
+
+@interface AsynchronousDownloadDelegate : NSObject <_WKDownloadDelegate>
+@end
+
+@implementation AsynchronousDownloadDelegate
+
+- (void)_downloadDidStart:(_WKDownload *)download
+{
+ isDone = true;
+}
+
+@end
+
+TEST(_WKDownload, AsynchronousDownloadPolicy)
+{
+ runTest(adoptNS([[AsynchronousDownloadNavigationDelegate alloc] init]).get(), adoptNS([[AsynchronousDownloadDelegate alloc] init]).get(), sourceURL);
+}
+
#endif
#endif