Diff
Modified: trunk/LayoutTests/ChangeLog (215735 => 215736)
--- trunk/LayoutTests/ChangeLog 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/LayoutTests/ChangeLog 2017-04-25 16:29:25 UTC (rev 215736)
@@ -1,3 +1,26 @@
+2017-04-25 Chris Dumez <cdu...@apple.com>
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
+ https://bugs.webkit.org/show_bug.cgi?id=171239
+ <rdar://problem/31789855>
+
+ Reviewed by Alex Christensen.
+
+ * http/tests/security/anchor-download-allow-sameorigin.html:
+ Stop using attachment.php as resource for this download attribute test because attachment.php
+ returns a Content-Disposition header with a filename. Given the behavior change in this patch,
+ this resource is no longer suitable for testing the download attribute.
+
+ * http/tests/download/anchor-download-attribute-content-disposition-expected.txt: Added.
+ * http/tests/download/anchor-download-attribute-content-disposition.html: Added.
+ * http/tests/download/resources/content-disposition-pass.php: Added.
+ Add layout test coverage.
+
+ * platform/ios-wk2/TestExpectations:
+ * platform/mac-wk1/TestExpectations:
+ * platform/win/TestExpectations:
+ Skip new test on platforms where the download attribute is not supported.
+
2017-04-25 Ryan Haddad <ryanhad...@apple.com>
Rebaseline fast/canvas/canvas-crash.html for ios-simulator.
Added: trunk/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition-expected.txt (0 => 215736)
--- trunk/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition-expected.txt 2017-04-25 16:29:25 UTC (rev 215736)
@@ -0,0 +1,8 @@
+Download started.
+Downloading URL with suggested filename "PASS.txt"
+Download completed.
+Tests that the filename from the Content-Disposition header is used even if a download attribute is specified in HTML.
+
+The suggested filename above should be "PASS.txt" and the download should succeed.
+
+Link with download attribute.
Added: trunk/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition.html (0 => 215736)
--- trunk/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition.html (rev 0)
+++ trunk/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition.html 2017-04-25 16:29:25 UTC (rev 215736)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/_javascript_'>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>Tests that the filename from the Content-Disposition header is used even if a download attribute is specified in HTML.</p>
+<p>The suggested filename above should be "PASS.txt" and the download should succeed.</p>
+<a id="download-url" href="" download="FAIL.txt">Link with download attribute.</a>
+<script>
+function click(elmt)
+{
+ if (!window.eventSender) {
+ alert('Click the link to run the test.');
+ return;
+ }
+ eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+function runTest()
+{
+ var link = document.getElementById("download-url");
+ click(link);
+}
+runTest();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/download/resources/content-disposition-pass.php (0 => 215736)
--- trunk/LayoutTests/http/tests/download/resources/content-disposition-pass.php (rev 0)
+++ trunk/LayoutTests/http/tests/download/resources/content-disposition-pass.php 2017-04-25 16:29:25 UTC (rev 215736)
@@ -0,0 +1,6 @@
+<?php
+header("Content-Disposition: Attachment; filename=PASS.txt");
+header("Content-Type: text/plain");
+?>
+
+Test file content.
Modified: trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html (215735 => 215736)
--- trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html 2017-04-25 16:29:25 UTC (rev 215736)
@@ -10,7 +10,7 @@
<body>
<p>
Tests that a suggested filename on a download attribute is allowed if
-<a id="dl" href="" download="foo.pdf">the link</a> is in the same origin.
+<a id="dl" href="" download="foo.pdf">the link</a> is in the same origin.
<p>
The suggested filename at the top should be foo.pdf.
<script>
Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (215735 => 215736)
--- trunk/LayoutTests/platform/ios-wk2/TestExpectations 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2017-04-25 16:29:25 UTC (rev 215736)
@@ -1823,6 +1823,7 @@
webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-nodownload.html [ Skip ]
webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
+webkit.org/b/156067 http/tests/download/anchor-download-attribute-content-disposition.html [ Skip ]
webkit.org/b/156067 http/tests/download/anchor-download-no-extension.html [ Skip ]
webkit.org/b/156067 http/tests/download/area-download.html [ Skip ]
webkit.org/b/156067 http/tests/security/anchor-download-allow-blob.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (215735 => 215736)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2017-04-25 16:29:25 UTC (rev 215736)
@@ -227,6 +227,7 @@
webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-unicode.html [ Skip ]
webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html [ Skip ]
+webkit.org/b/156069 http/tests/download/anchor-download-attribute-content-disposition.html [ Skip ]
webkit.org/b/156069 http/tests/download/anchor-download-no-extension.html [ Skip ]
webkit.org/b/156069 http/tests/download/area-download.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
Modified: trunk/LayoutTests/platform/win/TestExpectations (215735 => 215736)
--- trunk/LayoutTests/platform/win/TestExpectations 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/LayoutTests/platform/win/TestExpectations 2017-04-25 16:29:25 UTC (rev 215736)
@@ -450,6 +450,7 @@
fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-unicode.html [ Skip ]
fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html [ Skip ]
+http/tests/download/anchor-download-attribute-content-disposition.html [ Skip ]
http/tests/download/anchor-download-no-extension.html [ Skip ]
http/tests/download/area-download.html [ Skip ]
http/tests/security/anchor-download-allow-data.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (215735 => 215736)
--- trunk/Source/WebCore/ChangeLog 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/Source/WebCore/ChangeLog 2017-04-25 16:29:25 UTC (rev 215736)
@@ -1,3 +1,20 @@
+2017-04-25 Chris Dumez <cdu...@apple.com>
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
+ https://bugs.webkit.org/show_bug.cgi?id=171239
+ <rdar://problem/31789855>
+
+ Reviewed by Alex Christensen.
+
+ Add isAttachmentWithFilename() utility method to ResourceResponse to implement:
+ - https://html.spec.whatwg.org/#as-a-download (Step 2)
+
+ Test: http/tests/download/anchor-download-attribute-content-disposition.html
+
+ * platform/network/ResourceResponseBase.cpp:
+ (WebCore::ResourceResponseBase::isAttachmentWithFilename):
+ * platform/network/ResourceResponseBase.h:
+
2017-04-25 Antti Koivisto <an...@apple.com>
Enable expired-only reload policy on Mac and iOS
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (215735 => 215736)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2017-04-25 16:29:25 UTC (rev 215736)
@@ -558,6 +558,21 @@
return equalLettersIgnoringASCIICase(value.left(value.find(';')).stripWhiteSpace(), "attachment");
}
+bool ResourceResponseBase::isAttachmentWithFilename() const
+{
+ lazyInit(AllFields);
+
+ String contentDisposition = m_httpHeaderFields.get(HTTPHeaderName::ContentDisposition);
+ if (contentDisposition.isNull())
+ return false;
+
+ if (!equalLettersIgnoringASCIICase(contentDisposition.left(contentDisposition.find(';')).stripWhiteSpace(), "attachment"))
+ return false;
+
+ String filename = filenameFromHTTPContentDisposition(contentDisposition);
+ return !filename.isNull();
+}
+
ResourceResponseBase::Source ResourceResponseBase::source() const
{
lazyInit(AllFields);
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (215735 => 215736)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2017-04-25 16:29:25 UTC (rev 215736)
@@ -113,6 +113,7 @@
bool isMultipart() const { return mimeType() == "multipart/x-mixed-replace"; }
WEBCORE_EXPORT bool isAttachment() const;
+ WEBCORE_EXPORT bool isAttachmentWithFilename() const;
WEBCORE_EXPORT String suggestedFilename() const;
WEBCORE_EXPORT static String sanitizeSuggestedFilename(const String&);
Modified: trunk/Source/WebKit2/ChangeLog (215735 => 215736)
--- trunk/Source/WebKit2/ChangeLog 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/Source/WebKit2/ChangeLog 2017-04-25 16:29:25 UTC (rev 215736)
@@ -1,3 +1,24 @@
+2017-04-25 Chris Dumez <cdu...@apple.com>
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
+ https://bugs.webkit.org/show_bug.cgi?id=171239
+ <rdar://problem/31789855>
+
+ Reviewed by Alex Christensen.
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML.
+ This is not as per HTML specification:
+ - https://html.spec.whatwg.org/#as-a-download (Step 2)
+
+ Content-Disposition header filename is supposed to override the value of the download attribute.
+
+ Firefox and Chrome follow the specification.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::findPendingDownloadLocation):
+ * UIProcess/Downloads/DownloadProxy.cpp:
+ (WebKit::DownloadProxy::didReceiveResponse):
+
2017-04-25 Carlos Garcia Campos <cgar...@igalia.com>
[GTK] Add WebKitInspectorWindow to create inspector windows from local and remote inspector
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (215735 => 215736)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-04-25 16:29:25 UTC (rev 215736)
@@ -519,7 +519,12 @@
downloadProxyConnection()->send(Messages::DownloadProxy::DidReceiveResponse(response), destinationID);
downloadManager().willDecidePendingDownloadDestination(networkDataTask, WTFMove(completionHandler));
- String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(networkDataTask.suggestedFilename(), response.mimeType());
+
+ // As per https://html.spec.whatwg.org/#as-a-download (step 2), the filename from the Content-Disposition header
+ // should override the suggested filename from the download attribute.
+ String suggestedFilename = response.isAttachmentWithFilename() ? response.suggestedFilename() : networkDataTask.suggestedFilename();
+ suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(suggestedFilename, response.mimeType());
+
downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), suggestedFilename), destinationID);
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (215735 => 215736)
--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2017-04-25 16:10:03 UTC (rev 215735)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2017-04-25 16:29:25 UTC (rev 215736)
@@ -154,6 +154,13 @@
if (!m_processPool)
return;
+#if !USE(NETWORK_SESSION)
+ // As per https://html.spec.whatwg.org/#as-a-download (step 2), the filename from the Content-Disposition header
+ // should override the suggested filename from the download attribute.
+ if (!m_suggestedFilename.isNull() && response.isAttachmentWithFilename())
+ m_suggestedFilename = String();
+#endif
+
m_processPool->downloadClient().didReceiveResponse(m_processPool.get(), this, response);
}