Diff
Modified: trunk/Source/WebCore/ChangeLog (198910 => 198911)
--- trunk/Source/WebCore/ChangeLog 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebCore/ChangeLog 2016-03-31 20:39:24 UTC (rev 198911)
@@ -1,3 +1,21 @@
+2016-03-31 Jiewen Tan <[email protected]>
+
+ WebKit should set Original URL of a download request correctly
+ https://bugs.webkit.org/show_bug.cgi?id=155914
+ <rdar://problem/10473811>
+
+ Reviewed by Anders Carlsson.
+
+ Added API tests.
+
+ Replace the old logic for identifying the Original URL of a download request
+ with a new method based on the logic from Document::firstPartyForCookies, which
+ does a much better job determining the URL a user actually visited.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::setOriginalURLForDownloadRequest):
+ (WebCore::originatingURLFromBackForwardList): Deleted.
+
2016-03-31 Antonio Gomes <[email protected]>
eventMayStartDrag() does not check for shiftKey or isOverLink
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (198910 => 198911)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2016-03-31 20:39:24 UTC (rev 198911)
@@ -2350,58 +2350,17 @@
m_provisionalDocumentLoader->startLoadingMainResource();
}
-static URL originatingURLFromBackForwardList(Page* page)
-{
- // FIXME: Can this logic be replaced with m_frame.document()->firstPartyForCookies()?
- // It has the same meaning of "page a user thinks is the current one".
-
- URL originalURL;
- int backCount = page->backForward().backCount();
- for (int backIndex = 0; backIndex <= backCount; backIndex++) {
- // FIXME: At one point we had code here to check a "was user gesture" flag.
- // Do we need to restore that logic?
- HistoryItem* historyItem = page->backForward().itemAtIndex(-backIndex);
- if (!historyItem)
- continue;
-
- originalURL = historyItem->originalURL();
- if (!originalURL.isNull())
- return originalURL;
- }
-
- return URL();
-}
-
void FrameLoader::setOriginalURLForDownloadRequest(ResourceRequest& request)
{
- URL originalURL;
-
- // If there is no referrer, assume that the download was initiated directly, so current document is
- // completely unrelated to it. See <rdar://problem/5294691>.
- // FIXME: Referrer is not sent in many other cases, so we will often miss this important information.
- // Find a better way to decide whether the download was unrelated to current document.
- if (!request.httpReferrer().isNull()) {
- // find the first item in the history that was originated by the user
- originalURL = originatingURLFromBackForwardList(m_frame.page());
- }
-
- if (originalURL.isNull())
- originalURL = request.url();
-
- if (!originalURL.protocol().isEmpty() && !originalURL.host().isEmpty()) {
- unsigned port = originalURL.port();
-
- // Original URL is needed to show the user where a file was downloaded from. We should make a URL that won't result in downloading the file again.
- // FIXME: Using host-only URL is a very heavy-handed approach. We should attempt to provide the actual page where the download was initiated from, as a reminder to the user.
- String hostOnlyURLString;
- if (port)
- hostOnlyURLString = makeString(originalURL.protocol(), "://", originalURL.host(), ':', String::number(port));
- else
- hostOnlyURLString = makeString(originalURL.protocol(), "://", originalURL.host());
-
- // FIXME: Rename firstPartyForCookies back to mainDocumentURL. It was a mistake to think that it was only used for cookies.
- request.setFirstPartyForCookies(URL(URL(), hostOnlyURLString));
- }
+ // FIXME: Rename firstPartyForCookies back to mainDocumentURL. It was a mistake to think that it was only used for cookies.
+ // The originalURL is defined as the URL of the page where the download was initiated.
+ URL originalURL = m_frame.document() ? m_frame.document()->firstPartyForCookies() : URL();
+ // If the originalURL is the same as the requested URL, we are processing a download
+ // initiated directly without a page and do not need to specify the originalURL.
+ if (originalURL == request.url())
+ request.setFirstPartyForCookies(URL());
+ else
+ request.setFirstPartyForCookies(originalURL);
}
void FrameLoader::didLayout(LayoutMilestones milestones)
Modified: trunk/Source/WebKit2/ChangeLog (198910 => 198911)
--- trunk/Source/WebKit2/ChangeLog 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-31 20:39:24 UTC (rev 198911)
@@ -1,3 +1,28 @@
+2016-03-31 Jiewen Tan <[email protected]>
+
+ WebKit should set Original URL of a download request correctly
+ https://bugs.webkit.org/show_bug.cgi?id=155914
+ <rdar://problem/10473811>
+
+ Reviewed by Anders Carlsson.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::convertMainResourceLoadToDownload):
+ * NetworkProcess/NetworkLoad.cpp:
+ (WebKit::NetworkLoad::convertTaskToDownload):
+ (WebKit::NetworkLoad::didReceiveResponseNetworkSession):
+ * NetworkProcess/NetworkLoad.h:
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::findPendingDownloadLocation):
+ * NetworkProcess/NetworkProcess.h:
+ Add logic to set the original URL of a download request when a main resource load
+ is converted to a download.
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::download):
+ * UIProcess/WebProcessPool.h:
+ Add logic to set the original URL of a download request during a context menu:
+ Download Linked File action.
+
2016-03-31 Joseph Pecoraro <[email protected]>
Web Automation: Add Automation.screenshot
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (198910 => 198911)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2016-03-31 20:39:24 UTC (rev 198911)
@@ -206,7 +206,7 @@
}
#if USE(NETWORK_SESSION)
- loader->networkLoad()->convertTaskToDownload(downloadID);
+ loader->networkLoad()->convertTaskToDownload(downloadID, request);
#else
networkProcess.downloadManager().convertHandleToDownload(downloadID, loader->networkLoad()->handle(), request, response);
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkLoad.cpp (198910 => 198911)
--- trunk/Source/WebKit2/NetworkProcess/NetworkLoad.cpp 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkLoad.cpp 2016-03-31 20:39:24 UTC (rev 198911)
@@ -169,7 +169,7 @@
#if USE(NETWORK_SESSION)
-void NetworkLoad::convertTaskToDownload(DownloadID downloadID)
+void NetworkLoad::convertTaskToDownload(DownloadID downloadID, const ResourceRequest& updatedRequest)
{
if (!m_task)
return;
@@ -178,7 +178,7 @@
ASSERT(m_responseCompletionHandler);
if (m_responseCompletionHandler)
- NetworkProcess::singleton().findPendingDownloadLocation(*m_task.get(), std::exchange(m_responseCompletionHandler, nullptr));
+ NetworkProcess::singleton().findPendingDownloadLocation(*m_task.get(), std::exchange(m_responseCompletionHandler, nullptr), updatedRequest);
}
void NetworkLoad::setPendingDownloadID(DownloadID downloadID)
@@ -230,7 +230,7 @@
{
ASSERT(isMainThread());
if (m_task && m_task->pendingDownloadID().downloadID())
- NetworkProcess::singleton().findPendingDownloadLocation(*m_task.get(), completionHandler);
+ NetworkProcess::singleton().findPendingDownloadLocation(*m_task.get(), completionHandler, m_task->currentRequest());
else if (sharedDidReceiveResponse(response) == NetworkLoadClient::ShouldContinueDidReceiveResponse::Yes)
completionHandler(PolicyUse);
else
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkLoad.h (198910 => 198911)
--- trunk/Source/WebKit2/NetworkProcess/NetworkLoad.h 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkLoad.h 2016-03-31 20:39:24 UTC (rev 198911)
@@ -58,7 +58,7 @@
void continueDidReceiveResponse();
#if USE(NETWORK_SESSION)
- void convertTaskToDownload(DownloadID);
+ void convertTaskToDownload(DownloadID, const WebCore::ResourceRequest&);
void setPendingDownloadID(DownloadID);
void setPendingDownload(PendingDownload&);
DownloadID pendingDownloadID() { return m_task->pendingDownloadID(); }
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (198910 => 198911)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2016-03-31 20:39:24 UTC (rev 198911)
@@ -497,11 +497,11 @@
downloadProxyConnection()->send(Messages::DownloadProxy::DidCancel({ }), downloadID.downloadID());
}
-void NetworkProcess::findPendingDownloadLocation(NetworkDataTask& networkDataTask, ResponseCompletionHandler completionHandler)
+void NetworkProcess::findPendingDownloadLocation(NetworkDataTask& networkDataTask, ResponseCompletionHandler completionHandler, const ResourceRequest& updatedRequest)
{
uint64_t destinationID = networkDataTask.pendingDownloadID().downloadID();
- downloadProxyConnection()->send(Messages::DownloadProxy::DidStart(networkDataTask.currentRequest(), String()), destinationID);
-
+ downloadProxyConnection()->send(Messages::DownloadProxy::DidStart(updatedRequest, String()), destinationID);
+
downloadManager().willDecidePendingDownloadDestination(networkDataTask, completionHandler);
downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), networkDataTask.suggestedFilename()), destinationID);
}
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (198910 => 198911)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2016-03-31 20:39:24 UTC (rev 198911)
@@ -105,7 +105,7 @@
#endif
#if USE(NETWORK_SESSION)
- void findPendingDownloadLocation(NetworkDataTask&, ResponseCompletionHandler);
+ void findPendingDownloadLocation(NetworkDataTask&, ResponseCompletionHandler, const WebCore::ResourceRequest&);
#endif
void prefetchDNS(const String&);
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (198910 => 198911)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2016-03-31 20:39:24 UTC (rev 198911)
@@ -788,8 +788,14 @@
SessionID sessionID = initiatingPage ? initiatingPage->sessionID() : SessionID::defaultSessionID();
if (networkProcess()) {
- // FIXME (NetworkProcess): Replicate whatever FrameLoader::setOriginalURLForDownloadRequest does with the request here.
- networkProcess()->send(Messages::NetworkProcess::DownloadRequest(sessionID, downloadProxy->downloadID(), request), 0);
+ ResourceRequest updatedRequest(request);
+ // Request's firstPartyForCookies will be used as Original URL of the download request.
+ // We set the value to top level document's URL.
+ if (initiatingPage)
+ updatedRequest.setFirstPartyForCookies(URL(URL(), initiatingPage->pageLoadState().url()));
+ else
+ updatedRequest.setFirstPartyForCookies(URL());
+ networkProcess()->send(Messages::NetworkProcess::DownloadRequest(sessionID, downloadProxy->downloadID(), updatedRequest), 0);
return downloadProxy;
}
Modified: trunk/Tools/ChangeLog (198910 => 198911)
--- trunk/Tools/ChangeLog 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Tools/ChangeLog 2016-03-31 20:39:24 UTC (rev 198911)
@@ -1,3 +1,21 @@
+2016-03-31 Jiewen Tan <[email protected]>
+
+ WebKit should set Original URL of a download request correctly
+ https://bugs.webkit.org/show_bug.cgi?id=155914
+ <rdar://problem/10473811>
+
+ Reviewed by Anders Carlsson.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm:
+ (-[DownloadRequestOriginalURLDelegate initWithExpectOriginalURL:]):
+ (-[DownloadRequestOriginalURLDelegate _downloadDidStart:]):
+ (-[DownloadRequestOriginalURLNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
+ (TEST):
+ * TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL2.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURLFrame.html: Added.
+
2016-03-30 Dewei Zhu <[email protected]>
Extend animometer timeout for slow CPUs.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (198910 => 198911)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-03-31 20:39:24 UTC (rev 198911)
@@ -88,6 +88,9 @@
52B8CF9815868D9100281053 /* SetDocumentURI.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 52B8CF9415868CF000281053 /* SetDocumentURI.html */; };
52D673EE1AFB127300FA19FE /* WKPageCopySessionStateWithFiltering.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52D673EC1AFB126800FA19FE /* WKPageCopySessionStateWithFiltering.cpp */; };
52E5CE4914D21EAB003B2BD8 /* ParentFrame_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52E5CE4814D21EAB003B2BD8 /* ParentFrame_Bundle.cpp */; };
+ 5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */; };
+ 5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */; };
+ 5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */; };
57F10D931C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */; };
57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */; };
764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */; };
@@ -408,6 +411,9 @@
dstPath = TestWebKitAPI.resources;
dstSubfolderSpec = 7;
files = (
+ 5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */,
+ 5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */,
+ 5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */,
CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */,
51BCEE4E1C84F53B0042C82E /* IndexedDBMultiProcess-1.html in Copy Resources */,
51BCEE4F1C84F53B0042C82E /* IndexedDBMultiProcess-2.html in Copy Resources */,
@@ -647,6 +653,9 @@
52D673EC1AFB126800FA19FE /* WKPageCopySessionStateWithFiltering.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageCopySessionStateWithFiltering.cpp; sourceTree = "<group>"; };
52E5CE4514D21E9D003B2BD8 /* ParentFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParentFrame.cpp; sourceTree = "<group>"; };
52E5CE4814D21EAB003B2BD8 /* ParentFrame_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParentFrame_Bundle.cpp; sourceTree = "<group>"; };
+ 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL.html; sourceTree = "<group>"; };
+ 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURLFrame.html; sourceTree = "<group>"; };
+ 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL2.html; sourceTree = "<group>"; };
57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IsNavigationActionTrusted.mm; sourceTree = "<group>"; };
57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IsNavigationActionTrusted.html; sourceTree = "<group>"; };
7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = "<group>"; };
@@ -1110,6 +1119,9 @@
isa = PBXGroup;
children = (
A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */,
+ 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */,
+ 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */,
+ 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */,
51BCEE4C1C84F52C0042C82E /* IndexedDBMultiProcess-1.html */,
51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */,
51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */,
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm (198910 => 198911)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm 2016-03-31 19:36:20 UTC (rev 198910)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm 2016-03-31 20:39:24 UTC (rev 198911)
@@ -265,5 +265,78 @@
TestWebKitAPI::Util::run(&isDone);
}
+@interface DownloadRequestOriginalURLDelegate : NSObject <_WKDownloadDelegate>
+- (instancetype)initWithExpectedOriginalURL:(NSURL *)expectOriginalURL;
+@end
+
+@implementation DownloadRequestOriginalURLDelegate {
+ NSURL *_expectedOriginalURL;
+}
+
+- (instancetype)initWithExpectedOriginalURL:(NSURL *)expectedOriginalURL
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _expectedOriginalURL = expectedOriginalURL;
+ return self;
+}
+
+- (void)_downloadDidStart:(_WKDownload *)download
+{
+ if ([_expectedOriginalURL isEqual:sourceURL])
+ EXPECT_TRUE(!download.request.mainDocumentURL);
+ else
+ EXPECT_TRUE([_expectedOriginalURL isEqual:download.request.mainDocumentURL]);
+ isDone = true;
+}
+
+@end
+
+@interface DownloadRequestOriginalURLNavigationDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation DownloadRequestOriginalURLNavigationDelegate
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
+{
+ if ([navigationAction.request.URL isEqual:sourceURL])
+ decisionHandler(_WKNavigationActionPolicyDownload);
+ else
+ decisionHandler(WKNavigationActionPolicyAllow);
+}
+@end
+
+TEST(_WKDownload, DownloadRequestOriginalURL)
+{
+ NSURL *originalURL = [[NSBundle mainBundle] URLForResource:@"DownloadRequestOriginalURL" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ runTest(adoptNS([[DownloadRequestOriginalURLNavigationDelegate alloc] init]).get(), adoptNS([[DownloadRequestOriginalURLDelegate alloc] initWithExpectedOriginalURL:originalURL]).get(), originalURL);
+}
+
+TEST(_WKDownload, DownloadRequestOriginalURLFrame)
+{
+ NSURL *originalURL = [[NSBundle mainBundle] URLForResource:@"DownloadRequestOriginalURL2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ runTest(adoptNS([[DownloadRequestOriginalURLNavigationDelegate alloc] init]).get(), adoptNS([[DownloadRequestOriginalURLDelegate alloc] initWithExpectedOriginalURL:originalURL]).get(), originalURL);
+}
+
+TEST(_WKDownload, DownloadRequestOriginalURLDirectDownload)
+{
+ runTest(adoptNS([[DownloadRequestOriginalURLNavigationDelegate alloc] init]).get(), adoptNS([[DownloadRequestOriginalURLDelegate alloc] initWithExpectedOriginalURL:sourceURL]).get(), sourceURL);
+}
+
+TEST(_WKDownload, DownloadRequestOriginalURLDirectDownloadWithLoadedContent)
+{
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+ [webView setNavigationDelegate:[[DownloadRequestOriginalURLNavigationDelegate alloc] init]];
+ [[[webView configuration] processPool] _setDownloadDelegate:[[DownloadRequestOriginalURLDelegate alloc] initWithExpectedOriginalURL:sourceURL]];
+
+ NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ // Here is to test if the original URL can be set correctly when the current document
+ // is completely unrelated to the download.
+ [webView loadRequest:[NSURLRequest requestWithURL:contentURL]];
+ [webView loadRequest:[NSURLRequest requestWithURL:sourceURL]];
+ isDone = false;
+ TestWebKitAPI::Util::run(&isDone);
+}
+
#endif
#endif
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL.html (0 => 198911)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL.html 2016-03-31 20:39:24 UTC (rev 198911)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body>
+<a id="href" href=""
+<script>
+ var element = document.getElementById("href");
+ element.click();
+</script>
+</body>
+</html>
\ No newline at end of file
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL2.html (0 => 198911)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL2.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURL2.html 2016-03-31 20:39:24 UTC (rev 198911)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<iframe src=""
+</body>
+</html>
\ No newline at end of file
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURLFrame.html (0 => 198911)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURLFrame.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DownloadRequestOriginalURLFrame.html 2016-03-31 20:39:24 UTC (rev 198911)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body>
+<a id="href" href=""
+<script>
+ var element = document.getElementById("href");
+ element.click();
+</script>
+</body>
+</html>
\ No newline at end of file