<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212041] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212041">212041</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-02-09 20:00:52 -0800 (Thu, 09 Feb 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Mac][WK2] Use MIME type to add file extension to downloads' suggested filenames when missing
https://bugs.webkit.org/show_bug.cgi?id=168077
<rdar://problem/30412595>
Reviewed by Alex Christensen.
Source/WebCore:
Add utility function to MIMETypeRegistry that appends an extension to
a filename if necessary, based on a provided MIME type.
Tests: fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html
http/tests/download/anchor-download-no-extension.html
* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary):
* platform/MIMETypeRegistry.h:
* platform/cocoa/MIMETypeRegistryCocoa.mm:
(WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary):
Source/WebKit2:
Use MIME type to add file extension to downloads' suggested filenames when missing:
- https://html.spec.whatwg.org/#as-a-download (step 19)
This new behavior matches Chrome.
* NetworkProcess/Downloads/BlobDownloadClient.cpp:
(WebKit::BlobDownloadClient::didReceiveResponseAsync):
* NetworkProcess/Downloads/Download.cpp:
(WebKit::Download::didReceiveResponse):
(WebKit::Download::decideDestinationWithSuggestedFilename):
* NetworkProcess/Downloads/Download.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::findPendingDownloadLocation):
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didStart):
(WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
* UIProcess/Downloads/DownloadProxy.h:
* UIProcess/Downloads/DownloadProxy.messages.in:
LayoutTests:
Rebaseline a couple of download tests where suggested filenames now have an extension
and extend test coverage.
* fast/dom/HTMLAnchorElement/anchor-download-expected.txt:
* fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt:
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension-expected.txt: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html: Added.
* fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt:
* http/tests/download/anchor-download-no-extension-expected.txt: Added.
* http/tests/download/anchor-download-no-extension.html: Added.
* platform/ios-simulator-wk2/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadusertriggeredsyntheticclickexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchornodownloadsetexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistrycpp">trunk/Source/WebCore/platform/MIMETypeRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistryh">trunk/Source/WebCore/platform/MIMETypeRegistry.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaMIMETypeRegistryCocoamm">trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadsBlobDownloadClientcpp">trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadsDownloadcpp">trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadsDownloadh">trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessDownloadsDownloadProxycpp">trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessDownloadsDownloadProxyh">trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessDownloadsDownloadProxymessagesin">trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadnoextensionexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadnoextensionhtml">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html</a></li>
<li><a href="#trunkLayoutTestshttptestsdownloadanchordownloadnoextensionexpectedtxt">trunk/LayoutTests/http/tests/download/anchor-download-no-extension-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsdownloadanchordownloadnoextensionhtml">trunk/LayoutTests/http/tests/download/anchor-download-no-extension.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/LayoutTests/ChangeLog        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-02-09 Chris Dumez <cdumez@apple.com>
+
+ [Mac][WK2] Use MIME type to add file extension to downloads' suggested filenames when missing
+ https://bugs.webkit.org/show_bug.cgi?id=168077
+ <rdar://problem/30412595>
+
+ Reviewed by Alex Christensen.
+
+ Rebaseline a couple of download tests where suggested filenames now have an extension
+ and extend test coverage.
+
+ * fast/dom/HTMLAnchorElement/anchor-download-expected.txt:
+ * fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt:
+ * fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension-expected.txt: Added.
+ * fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html: Added.
+ * fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt:
+ * http/tests/download/anchor-download-no-extension-expected.txt: Added.
+ * http/tests/download/anchor-download-no-extension.html: Added.
+ * platform/ios-simulator-wk2/TestExpectations:
+ * platform/mac-wk1/TestExpectations:
+ * platform/win/TestExpectations:
+
</ins><span class="cx"> 2017-02-09 Philip Rogers <pdr@google.com>
</span><span class="cx">
</span><span class="cx"> SVG clip-path references can clip out later content
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><span class="cx"> Download started.
</span><del>-Downloading URL with suggested filename "unknown"
</del><ins>+Downloading URL with suggested filename "unknown.html"
</ins><span class="cx"> Download completed.
</span><span class="cx"> Blob URL
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadusertriggeredsyntheticclickexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> Download started.
</span><del>-Downloading URL with suggested filename "unknown"
</del><ins>+Downloading URL with suggested filename "unknown.html"
</ins><span class="cx"> Download completed.
</span><span class="cx"> Test that user triggered synthetic clicks on an anchor with a download attribute are not ignored.
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadnoextensionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension-expected.txt (0 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension-expected.txt        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Download started.
+Downloading URL with suggested filename "abe.png"
+Download completed.
+The suggested filename above should be "abe.png" and the download should succeed.
+
+File backed blob URL
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadnoextensionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html (0 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html         (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/javascript'>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>The suggested filename above should be "abe.png" and the download should succeed.</p>
+<a id="blob-url" download="abe">File backed blob URL</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()
+{
+ file = internals.createFile("../resources/abe.png");
+ var link = document.getElementById("blob-url");
+ link.href = window.URL.createObjectURL(file);
+ click(link);
+}
+runTest();
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchornodownloadsetexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><span class="cx"> Download started.
</span><del>-Downloading URL with suggested filename "unknown"
</del><ins>+Downloading URL with suggested filename "unknown.html"
</ins><span class="cx"> Download completed.
</span><span class="cx"> Blob URL
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsdownloadanchordownloadnoextensionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/download/anchor-download-no-extension-expected.txt (0 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/download/anchor-download-no-extension-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/download/anchor-download-no-extension-expected.txt        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Download started.
+Downloading URL with suggested filename "image.png"
+Download completed.
+The suggested filename above should be "image.png" and the download should succeed.
+
+Link with download attribute.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsdownloadanchordownloadnoextensionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/download/anchor-download-no-extension.html (0 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/download/anchor-download-no-extension.html         (rev 0)
+++ trunk/LayoutTests/http/tests/download/anchor-download-no-extension.html        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/javascript'>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>The suggested filename above should be "image.png" and the download should succeed.</p>
+<a id="download-url" href="/css/resources/abe.png" download="image">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>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -1814,10 +1814,12 @@
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
</span><ins>+webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html [ Skip ]
</ins><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-nodownload.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
</span><ins>+webkit.org/b/156067 http/tests/download/anchor-download-no-extension.html [ Skip ]
</ins><span class="cx"> webkit.org/b/156067 http/tests/download/area-download.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 http/tests/security/anchor-download-allow-blob.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 http/tests/security/anchor-download-allow-data.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -210,6 +210,8 @@
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
</span><ins>+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html [ Skip ]
+webkit.org/b/156069 http/tests/download/anchor-download-no-extension.html [ Skip ]
</ins><span class="cx"> webkit.org/b/156069 http/tests/download/area-download.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 http/tests/security/anchor-download-allow-data.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/TestExpectations        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/LayoutTests/platform/win/TestExpectations        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -445,6 +445,8 @@
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
</span><ins>+fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html [ Skip ]
+http/tests/download/anchor-download-no-extension.html [ Skip ]
</ins><span class="cx"> http/tests/download/area-download.html [ Skip ]
</span><span class="cx"> http/tests/security/anchor-download-allow-data.html [ Skip ]
</span><span class="cx"> http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebCore/ChangeLog        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2017-02-09 Chris Dumez <cdumez@apple.com>
+
+ [Mac][WK2] Use MIME type to add file extension to downloads' suggested filenames when missing
+ https://bugs.webkit.org/show_bug.cgi?id=168077
+ <rdar://problem/30412595>
+
+ Reviewed by Alex Christensen.
+
+ Add utility function to MIMETypeRegistry that appends an extension to
+ a filename if necessary, based on a provided MIME type.
+
+ Tests: fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html
+ http/tests/download/anchor-download-no-extension.html
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary):
+ * platform/MIMETypeRegistry.h:
+ * platform/cocoa/MIMETypeRegistryCocoa.mm:
+ (WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary):
+
</ins><span class="cx"> 2017-02-09 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><span class="cx"> [WebRTC][Mac] Activate libwebrtc
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -788,4 +788,13 @@
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if !PLATFORM(COCOA)
+
+String MIMETypeRegistry::appendFileExtensionIfNecessary(const String& filename, const String&)
+{
+ return filename;
+}
+
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.h        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -105,6 +105,8 @@
</span><span class="cx"> // FIXME: Unclear what the concept of a normalized MIME type is; currently it's a platform-specific notion.
</span><span class="cx"> static String getNormalizedMIMEType(const String&);
</span><span class="cx">
</span><ins>+ WEBCORE_EXPORT static String appendFileExtensionIfNecessary(const String& filename, const String& mimeType);
+
</ins><span class="cx"> private:
</span><span class="cx"> // Check to see if the MIME type is not suitable for being loaded as a text
</span><span class="cx"> // document in a frame. Only valid for MIME types begining with "text/".
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaMIMETypeRegistryCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -71,4 +71,19 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+String MIMETypeRegistry::appendFileExtensionIfNecessary(const String& filename, const String& mimeType)
+{
+ if (filename.isEmpty())
+ return emptyString();
+
+ if (filename.reverseFind('.') != notFound)
+ return filename;
+
+ String preferredExtension = getPreferredExtensionForMIMEType(mimeType);
+ if (preferredExtension.isEmpty())
+ return filename;
+
+ return filename + "." + preferredExtension;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/ChangeLog        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2017-02-09 Chris Dumez <cdumez@apple.com>
+
+ [Mac][WK2] Use MIME type to add file extension to downloads' suggested filenames when missing
+ https://bugs.webkit.org/show_bug.cgi?id=168077
+ <rdar://problem/30412595>
+
+ Reviewed by Alex Christensen.
+
+ Use MIME type to add file extension to downloads' suggested filenames when missing:
+ - https://html.spec.whatwg.org/#as-a-download (step 19)
+
+ This new behavior matches Chrome.
+
+ * NetworkProcess/Downloads/BlobDownloadClient.cpp:
+ (WebKit::BlobDownloadClient::didReceiveResponseAsync):
+ * NetworkProcess/Downloads/Download.cpp:
+ (WebKit::Download::didReceiveResponse):
+ (WebKit::Download::decideDestinationWithSuggestedFilename):
+ * NetworkProcess/Downloads/Download.h:
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::findPendingDownloadLocation):
+ * UIProcess/Downloads/DownloadProxy.cpp:
+ (WebKit::DownloadProxy::didStart):
+ (WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
+ * UIProcess/Downloads/DownloadProxy.h:
+ * UIProcess/Downloads/DownloadProxy.messages.in:
+
</ins><span class="cx"> 2017-02-09 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><span class="cx"> [WebRTC][Mac] Activate libwebrtc
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsBlobDownloadClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -31,7 +31,9 @@
</span><span class="cx"> #include "DataReference.h"
</span><span class="cx"> #include "Download.h"
</span><span class="cx"> #include "WebErrors.h"
</span><ins>+#include <WebCore/MIMETypeRegistry.h>
</ins><span class="cx"> #include <WebCore/ResourceError.h>
</span><ins>+#include <WebCore/ResourceResponse.h>
</ins><span class="cx"> #include <WebCore/SharedBuffer.h>
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -46,7 +48,8 @@
</span><span class="cx"> void BlobDownloadClient::didReceiveResponseAsync(ResourceHandle*, ResourceResponse&& response)
</span><span class="cx"> {
</span><span class="cx"> m_download.didReceiveResponse(WTFMove(response));
</span><del>- m_download.decideDestinationWithSuggestedFilenameAsync(m_download.suggestedName().isEmpty() ? "unknown" : m_download.suggestedName());
</del><ins>+ String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(m_download.suggestedName().isEmpty() ? ASCIILiteral("unknown") : m_download.suggestedName(), response.mimeType());
+ m_download.decideDestinationWithSuggestedFilenameAsync(suggestedFilename);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void BlobDownloadClient::didDecideDownloadDestination(const String& destinationPath, bool allowOverwrite)
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsDownloadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -161,6 +161,7 @@
</span><span class="cx"> {
</span><span class="cx"> RELEASE_LOG_IF_ALLOWED("didReceiveResponse: Created (id = %" PRIu64 ")", downloadID().downloadID());
</span><span class="cx">
</span><ins>+ m_responseMIMEType = response.mimeType();
</ins><span class="cx"> send(Messages::DownloadProxy::DidReceiveResponse(response));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -177,7 +178,7 @@
</span><span class="cx"> {
</span><span class="cx"> String destination;
</span><span class="cx"> SandboxExtension::Handle sandboxExtensionHandle;
</span><del>- if (!sendSync(Messages::DownloadProxy::DecideDestinationWithSuggestedFilename(filename), Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::Reply(destination, allowOverwrite, sandboxExtensionHandle)))
</del><ins>+ if (!sendSync(Messages::DownloadProxy::DecideDestinationWithSuggestedFilename(filename, m_responseMIMEType), Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::Reply(destination, allowOverwrite, sandboxExtensionHandle)))
</ins><span class="cx"> return String();
</span><span class="cx">
</span><span class="cx"> m_sandboxExtension = SandboxExtension::create(sandboxExtensionHandle);
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsDownloadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -146,6 +146,7 @@
</span><span class="cx"> WebCore::SessionID m_sessionID;
</span><span class="cx"> #else // USE(NETWORK_SESSION)
</span><span class="cx"> WebCore::ResourceRequest m_request;
</span><ins>+ String m_responseMIMEType;
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> RetainPtr<NSURLDownload> m_nsURLDownload;
</span><span class="cx"> RetainPtr<WKDownloadAsDelegate> m_delegate;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> #include <WebCore/DNS.h>
</span><span class="cx"> #include <WebCore/DiagnosticLoggingClient.h>
</span><span class="cx"> #include <WebCore/LogInitialization.h>
</span><ins>+#include <WebCore/MIMETypeRegistry.h>
</ins><span class="cx"> #include <WebCore/NetworkStorageSession.h>
</span><span class="cx"> #include <WebCore/PlatformCookieJar.h>
</span><span class="cx"> #include <WebCore/ResourceRequest.h>
</span><span class="lines">@@ -512,7 +513,8 @@
</span><span class="cx"> downloadProxyConnection()->send(Messages::DownloadProxy::DidReceiveResponse(response), destinationID);
</span><span class="cx">
</span><span class="cx"> downloadManager().willDecidePendingDownloadDestination(networkDataTask, WTFMove(completionHandler));
</span><del>- downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), networkDataTask.suggestedFilename()), destinationID);
</del><ins>+ String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(networkDataTask.suggestedFilename(), response.mimeType());
+ downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), suggestedFilename), destinationID);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDownloadsDownloadProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include "WebProcessPool.h"
</span><span class="cx"> #include "WebProtectionSpace.h"
</span><span class="cx"> #include <WebCore/FileSystem.h>
</span><ins>+#include <WebCore/MIMETypeRegistry.h>
</ins><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><span class="lines">@@ -91,7 +92,7 @@
</span><span class="cx"> m_processPool->downloadClient().processDidCrash(m_processPool.get(), this);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void DownloadProxy::didStart(const ResourceRequest& request, const AtomicString& suggestedFilename)
</del><ins>+void DownloadProxy::didStart(const ResourceRequest& request, const String& suggestedFilename)
</ins><span class="cx"> {
</span><span class="cx"> m_request = request;
</span><span class="cx"> m_suggestedFilename = suggestedFilename;
</span><span class="lines">@@ -193,7 +194,7 @@
</span><span class="cx">
</span><span class="cx"> #if !USE(NETWORK_SESSION)
</span><span class="cx">
</span><del>-void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle)
</del><ins>+void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle)
</ins><span class="cx"> {
</span><span class="cx"> allowOverwrite = false;
</span><span class="cx">
</span><span class="lines">@@ -200,10 +201,7 @@
</span><span class="cx"> if (!m_processPool)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- String suggestedFilename = filename;
- if (!m_suggestedFilename.isNull())
- suggestedFilename = m_suggestedFilename;
-
</del><ins>+ String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(m_suggestedFilename.isNull() ? filename : m_suggestedFilename, mimeType);
</ins><span class="cx"> destination = m_processPool->downloadClient().decideDestinationWithSuggestedFilename(m_processPool.get(), this, suggestedFilename, allowOverwrite);
</span><span class="cx">
</span><span class="cx"> if (!destination.isNull())
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDownloadsDownloadProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx"> void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
</span><span class="cx">
</span><span class="cx"> // Message handlers.
</span><del>- void didStart(const WebCore::ResourceRequest&, const AtomicString& suggestedFilename);
</del><ins>+ void didStart(const WebCore::ResourceRequest&, const String& suggestedFilename);
</ins><span class="cx"> void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&, uint64_t challengeID);
</span><span class="cx"> void didReceiveResponse(const WebCore::ResourceResponse&);
</span><span class="cx"> void didReceiveData(uint64_t length);
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> void willSendRequest(const WebCore::ResourceRequest& redirectRequest, const WebCore::ResourceResponse& redirectResponse);
</span><span class="cx"> #else
</span><del>- void decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle);
</del><ins>+ void decideDestinationWithSuggestedFilename(const String& filename, const String& mimeType, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle);
</ins><span class="cx"> #endif
</span><span class="cx"> void decideDestinationWithSuggestedFilenameAsync(DownloadID, const String& suggestedFilename);
</span><span class="cx">
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<API::Data> m_resumeData;
</span><span class="cx"> WebCore::ResourceRequest m_request;
</span><del>- AtomicString m_suggestedFilename;
</del><ins>+ String m_suggestedFilename;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDownloadsDownloadProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in (212040 => 212041)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in        2017-02-10 03:39:17 UTC (rev 212040)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in        2017-02-10 04:00:52 UTC (rev 212041)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> DidReceiveData(uint64_t length)
</span><span class="cx"> ShouldDecodeSourceDataOfMIMEType(String mimeType) -> (bool result)
</span><span class="cx"> #if !USE(NETWORK_SESSION)
</span><del>- DecideDestinationWithSuggestedFilename(String filename) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
</del><ins>+ DecideDestinationWithSuggestedFilename(String filename, String mimeType) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
</ins><span class="cx"> #endif
</span><span class="cx"> DidCreateDestination(String path)
</span><span class="cx"> DidFinish()
</span></span></pre>
</div>
</div>
</body>
</html>