<!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>[206356] 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/206356">206356</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-09-24 19:39:38 -0700 (Sat, 24 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>&lt;a download&gt; does not support Blob URLs
https://bugs.webkit.org/show_bug.cgi?id=156099
&lt;rdar://problem/25535520&gt;

Reviewed by Darin Adler.

Source/WebCore:

Only allow trusted events to trigger downloads for &lt;a download&gt;, as per:
- https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation

Without this, a script could download a file to the user's disk without
any user gesture or consent, simply by calling a.click(). I have confirmed
that Firefox also ignores the click for &lt;a download&gt; if it is synthetic.
Chrome allows synthetic clicks to trigger downloads but I filed a bug
about it.

Test: fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::handleClick):

Source/WebKit2:

Add support for downloading Blob URLs to WebKit2. This should work for
all WebKit2 port. This also works in combination with the download
attribute on anchor elements. Note that the download attribute is only
enabled at runtime in the context of the layout tests for now. I'll
enable the download attribute on WK2 once I have fixed Bug 162531.

* CMakeLists.txt:
* NetworkProcess/Downloads/BlobDownloadClient.cpp: Added.
(WebKit::BlobDownloadClient::BlobDownloadClient):
(WebKit::BlobDownloadClient::didReceiveResponse):
(WebKit::BlobDownloadClient::didReceiveBuffer):
(WebKit::BlobDownloadClient::didFinishLoading):
(WebKit::BlobDownloadClient::didFail):
* NetworkProcess/Downloads/BlobDownloadClient.h: Added.
* NetworkProcess/Downloads/Download.cpp:
(WebKit::Download::Download):
(WebKit::Download::start):
(WebKit::Download::didStart):
(WebKit::Download::didReceiveResponse):
(WebKit::Download::decideDestinationWithSuggestedFilename):
(WebKit::Download::~Download): Deleted.
(WebKit::Download::didReceiveData): Deleted.
(WebKit::Download::shouldDecodeSourceDataOfMIMEType): Deleted.
* NetworkProcess/Downloads/Download.h:
(WebKit::Download::Download):
(WebKit::Download::suggestedName):
(WebKit::Download::request):
* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
* NetworkProcess/Downloads/ios/DownloadIOS.mm:
(WebKit::Download::startNetworkLoad):
* NetworkProcess/Downloads/mac/DownloadMac.mm:
(WebKit::Download::startNetworkLoad):
* NetworkProcess/Downloads/soup/DownloadSoup.cpp:
(WebKit::Download::startNetworkLoad):
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
* UIProcess/Downloads/DownloadProxy.h:
* UIProcess/Downloads/DownloadProxy.messages.in:
* WebKit2.xcodeproj/project.pbxproj:

LayoutTests:

Unskip / rebaseline existing tests now that &lt;a download&gt; supports Blob URLs.

* TestExpectations:
* fast/dom/HTMLAnchorElement/anchor-download-expected.txt:
* fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt: Added.
* fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html: Added.
* fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt:
* http/tests/security/anchor-download-allow-blob-expected.txt:
* platform/ios-simulator-wk1/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/mac/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchornodownloadsetexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadallowblobexpectedtxt">trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk1TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAnchorElementcpp">trunk/Source/WebCore/html/HTMLAnchorElement.cpp</a></li>
<li><a href="#trunkSourceWebKit2CMakeListstxt">trunk/Source/WebKit2/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</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="#trunkSourceWebKit2NetworkProcessDownloadsDownloadManagercpp">trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadsiosDownloadIOSmm">trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadsmacDownloadMacmm">trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadssoupDownloadSoupcpp">trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.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>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadsyntheticclickexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadsyntheticclickhtml">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadsBlobDownloadClientcpp">trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessDownloadsBlobDownloadClienth">trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/ChangeLog        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1,5 +1,25 @@
</span><span class="cx"> 2016-09-24  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        &lt;a download&gt; does not support Blob URLs
+        https://bugs.webkit.org/show_bug.cgi?id=156099
+        &lt;rdar://problem/25535520&gt;
+
+        Reviewed by Darin Adler.
+
+        Unskip / rebaseline existing tests now that &lt;a download&gt; supports Blob URLs.
+
+        * TestExpectations:
+        * fast/dom/HTMLAnchorElement/anchor-download-expected.txt:
+        * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html: Added.
+        * fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt:
+        * http/tests/security/anchor-download-allow-blob-expected.txt:
+        * platform/ios-simulator-wk1/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/mac/TestExpectations:
+
+2016-09-24  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         [WK2] anchor.download attribute value is ignored by NETWORK_SESSION code path
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=162531
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/TestExpectations        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -894,9 +894,6 @@
</span><span class="cx"> fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html [ ImageOnlyFailure ]
</span><span class="cx"> fast/scrolling/rtl-scrollbars-animation-property.html [ Failure ]
</span><span class="cx"> 
</span><del>-# &lt;a download&gt; does not support Blobs
-webkit.org/b/156099 http/tests/security/anchor-download-allow-blob.html [ Failure ]
-
</del><span class="cx"> # &lt;a download&gt; does not honor cross-origin restrictions
</span><span class="cx"> webkit.org/b/156100 http/tests/security/anchor-download-block-crossorigin.html [ Failure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><ins>+Downloading URL with suggested filename &quot;&quot;
</ins><span class="cx"> Download started.
</span><del>-Download failed.
-Failed: NSURLErrorDomain, code=-1002, description=unsupported URL
</del><ins>+Download completed.
</ins><span class="cx"> Blob URL
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadsyntheticclickexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt (0 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+Test that synthetic clicks on an anchor with a download attribute are ignored.
+
+This test passes if you do not see any 'Download started' message above.
+
+Blob URL
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadsyntheticclickhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html (0 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script type='text/javascript'&gt;
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.waitUntilDone();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;Test that synthetic clicks on an anchor with a download attribute are ignored.&lt;/p&gt;
+&lt;p&gt; This test passes if you do not see any 'Download started' message above.&lt;/p&gt;
+&lt;a id=&quot;blob-url&quot; download&gt;Blob URL&lt;/a&gt;
+&lt;script&gt;
+function runTest()
+{
+    var string = &quot;test&quot;;
+    var blob = new Blob([string], {type: &quot;text/html&quot;});
+    var link = document.getElementById(&quot;blob-url&quot;);
+    link.href = window.URL.createObjectURL(blob);
+    link.click();
+    setTimeout(function() {
+        testRunner.notifyDone();
+    }, 100);
+}
+runTest();
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchornodownloadsetexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><ins>+Downloading URL with suggested filename &quot;&quot;
</ins><span class="cx"> Download started.
</span><del>-Download failed.
-Failed: NSURLErrorDomain, code=-1002, description=unsupported URL
</del><ins>+Download completed.
</ins><span class="cx"> Blob URL
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadallowblobexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1,4 +1,11 @@
</span><span class="cx"> Downloading URL with suggested filename &quot;foo.pdf&quot;
</span><ins>+Download started.
+Download completed.
</ins><span class="cx"> Tests that a suggested filename on a download attribute is allowed if the link is a blob URL.
</span><span class="cx"> 
</span><span class="cx"> The suggested filename at the top should be foo.pdf.
</span><ins>+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1312,7 +1312,8 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/155495 compositing/visible-rect/animated-from-none.html [ Failure Pass ]
</span><span class="cx"> 
</span><del>-# &lt;a download&gt; is not support in WK1 yet.
</del><ins>+# &lt;a download&gt; is not supported in WK1 yet.
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
</ins><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 class="cx"> webkit.org/b/156069 http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1380,11 +1380,6 @@
</span><span class="cx"> # &lt;rdar://problem/25279189&gt; LayoutTest http/tests/security/mixedContent/insecure-audio-video-in-main-frame.html is flaky
</span><span class="cx"> [ Sierra+ ] http/tests/security/mixedContent/insecure-audio-video-in-main-frame.html [ Pass Failure ]
</span><span class="cx"> 
</span><del>-# &lt;rdar://problem/25536266&gt; [Mac][iOS][NETWORK_SESSION] Unable to download BLOB URLs (156180)
-[ Sierra+ ] fast/dom/HTMLAnchorElement/anchor-download.html [ Skip ]
-[ Sierra+ ] fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Skip ]
-[ Sierra+ ] http/tests/security/anchor-download-allow-blob.html [ Skip ]
-
</del><span class="cx"> # &lt;rdar://problem/25780035&gt; CSP does not ignore paths for media redirects
</span><span class="cx"> [ Sierra+ ] http/tests/security/contentSecurityPolicy/audio-redirect-allowed2.html [ Skip ]
</span><span class="cx"> [ Sierra+ ] http/tests/security/contentSecurityPolicy/video-redirect-allowed2.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -187,9 +187,10 @@
</span><span class="cx"> # This hit-test test doesn't work on DRT
</span><span class="cx"> webkit.org/b/156084 accessibility/mac/video-tag-hit-test.html [ Skip ]
</span><span class="cx"> 
</span><del>-# &lt;a download&gt; is not support in WK1 yet.
</del><ins>+# &lt;a download&gt; is not supported in WK1 yet.
</ins><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Failure ]
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download.html [ Failure ]
</span><ins>+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
</ins><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 class="cx"> webkit.org/b/156069 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 (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebCore/ChangeLog        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-09-24  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        &lt;a download&gt; does not support Blob URLs
+        https://bugs.webkit.org/show_bug.cgi?id=156099
+        &lt;rdar://problem/25535520&gt;
+
+        Reviewed by Darin Adler.
+
+        Only allow trusted events to trigger downloads for &lt;a download&gt;, as per:
+        - https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
+
+        Without this, a script could download a file to the user's disk without
+        any user gesture or consent, simply by calling a.click(). I have confirmed
+        that Firefox also ignores the click for &lt;a download&gt; if it is synthetic.
+        Chrome allows synthetic clicks to trigger downloads but I filed a bug
+        about it.
+
+        Test: fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::handleClick):
+
</ins><span class="cx"> 2016-09-24  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Binding] setDOMException should be inlined and fall to the slow path if exception occurs
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLAnchorElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -367,8 +367,14 @@
</span><span class="cx"> 
</span><span class="cx">     auto downloadAttribute = nullAtom;
</span><span class="cx"> #if ENABLE(DOWNLOAD_ATTRIBUTE)
</span><del>-    if (RuntimeEnabledFeatures::sharedFeatures().downloadAttributeEnabled())
</del><ins>+    if (RuntimeEnabledFeatures::sharedFeatures().downloadAttributeEnabled()) {
</ins><span class="cx">         downloadAttribute = attributeWithoutSynchronization(downloadAttr);
</span><ins>+        // If the a element has a download attribute and the algorithm is not triggered by user activation
+        // then abort these steps.
+        // https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
+        if (!downloadAttribute.isNull() &amp;&amp; !event.isTrusted())
+            return;
+    }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     frame-&gt;loader().urlSelected(kurl, target(), &amp;event, LockHistory::No, LockBackForwardList::No, hasRel(RelationNoReferrer) ? NeverSendReferrer : MaybeSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), downloadAttribute);
</span></span></pre></div>
<a id="trunkSourceWebKit2CMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/CMakeLists.txt (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/CMakeLists.txt        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/CMakeLists.txt        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -213,6 +213,7 @@
</span><span class="cx">     NetworkProcess/NetworkProcessCreationParameters.cpp
</span><span class="cx">     NetworkProcess/NetworkResourceLoadParameters.cpp
</span><span class="cx"> 
</span><ins>+    NetworkProcess/Downloads/BlobDownloadClient.cpp
</ins><span class="cx">     NetworkProcess/Downloads/Download.cpp
</span><span class="cx">     NetworkProcess/Downloads/DownloadManager.cpp
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/ChangeLog        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1,5 +1,54 @@
</span><span class="cx"> 2016-09-24  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        &lt;a download&gt; does not support Blob URLs
+        https://bugs.webkit.org/show_bug.cgi?id=156099
+        &lt;rdar://problem/25535520&gt;
+
+        Reviewed by Darin Adler.
+
+        Add support for downloading Blob URLs to WebKit2. This should work for
+        all WebKit2 port. This also works in combination with the download
+        attribute on anchor elements. Note that the download attribute is only
+        enabled at runtime in the context of the layout tests for now. I'll
+        enable the download attribute on WK2 once I have fixed Bug 162531.
+
+        * CMakeLists.txt:
+        * NetworkProcess/Downloads/BlobDownloadClient.cpp: Added.
+        (WebKit::BlobDownloadClient::BlobDownloadClient):
+        (WebKit::BlobDownloadClient::didReceiveResponse):
+        (WebKit::BlobDownloadClient::didReceiveBuffer):
+        (WebKit::BlobDownloadClient::didFinishLoading):
+        (WebKit::BlobDownloadClient::didFail):
+        * NetworkProcess/Downloads/BlobDownloadClient.h: Added.
+        * NetworkProcess/Downloads/Download.cpp:
+        (WebKit::Download::Download):
+        (WebKit::Download::start):
+        (WebKit::Download::didStart):
+        (WebKit::Download::didReceiveResponse):
+        (WebKit::Download::decideDestinationWithSuggestedFilename):
+        (WebKit::Download::~Download): Deleted.
+        (WebKit::Download::didReceiveData): Deleted.
+        (WebKit::Download::shouldDecodeSourceDataOfMIMEType): Deleted.
+        * NetworkProcess/Downloads/Download.h:
+        (WebKit::Download::Download):
+        (WebKit::Download::suggestedName):
+        (WebKit::Download::request):
+        * NetworkProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::startDownload):
+        * NetworkProcess/Downloads/ios/DownloadIOS.mm:
+        (WebKit::Download::startNetworkLoad):
+        * NetworkProcess/Downloads/mac/DownloadMac.mm:
+        (WebKit::Download::startNetworkLoad):
+        * NetworkProcess/Downloads/soup/DownloadSoup.cpp:
+        (WebKit::Download::startNetworkLoad):
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
+        * UIProcess/Downloads/DownloadProxy.h:
+        * UIProcess/Downloads/DownloadProxy.messages.in:
+        * WebKit2.xcodeproj/project.pbxproj:
+
+2016-09-24  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         [WK2] anchor.download attribute value is ignored by NETWORK_SESSION code path
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=162531
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsBlobDownloadClientcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp (0 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp                                (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;BlobDownloadClient.h&quot;
+
+#include &quot;DataReference.h&quot;
+#include &quot;Download.h&quot;
+#include &quot;WebErrors.h&quot;
+#include &lt;WebCore/ResourceError.h&gt;
+#include &lt;WebCore/SharedBuffer.h&gt;
+
+namespace WebKit {
+
+using namespace WebCore;
+
+BlobDownloadClient::BlobDownloadClient(Download&amp; download)
+    : m_download(download)
+{
+}
+
+void BlobDownloadClient::didReceiveResponse(ResourceHandle*, ResourceResponse&amp;&amp; response)
+{
+    m_download.didReceiveResponse(WTFMove(response));
+
+    bool allowOverwrite = false;
+    m_destinationPath = m_download.decideDestinationWithSuggestedFilename(m_download.suggestedName(), allowOverwrite);
+    if (m_destinationPath.isEmpty()) {
+        didFail(nullptr, cancelledError(m_download.request()));
+        return;
+    }
+    if (fileExists(m_destinationPath)) {
+        if (!allowOverwrite) {
+            m_destinationPath = emptyString();
+            didFail(nullptr, cancelledError(m_download.request()));
+            return;
+        }
+        deleteFile(m_destinationPath);
+    }
+
+    m_destinationFile = openFile(m_destinationPath, OpenForWrite);
+    m_download.didCreateDestination(m_destinationPath);
+}
+
+void BlobDownloadClient::didReceiveBuffer(ResourceHandle*, Ref&lt;SharedBuffer&gt;&amp;&amp; buffer, int)
+{
+    writeToFile(m_destinationFile, buffer-&gt;data(), buffer-&gt;size());
+    m_download.didReceiveData(buffer-&gt;size());
+}
+
+void BlobDownloadClient::didFinishLoading(ResourceHandle*, double)
+{
+    closeFile(m_destinationFile);
+    m_download.didFinish();
+}
+
+void BlobDownloadClient::didFail(ResourceHandle*, const ResourceError&amp; error)
+{
+    closeFile(m_destinationFile);
+    if (!m_destinationPath.isEmpty())
+        deleteFile(m_destinationPath);
+
+    m_download.didFail(error, IPC::DataReference());
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsBlobDownloadClienth"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.h (0 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.h                                (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.h        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &lt;WebCore/FileSystem.h&gt;
+#include &lt;WebCore/ResourceHandleClient.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+namespace WebKit {
+
+class Download;
+class NetworkLoadParameters;
+
+class BlobDownloadClient final : public WebCore::ResourceHandleClient {
+public:
+    explicit BlobDownloadClient(Download&amp;);
+
+private:
+    // ResourceHandleClient
+    void didReceiveResponse(WebCore::ResourceHandle*, WebCore::ResourceResponse&amp;&amp;) final;
+    void didReceiveBuffer(WebCore::ResourceHandle*, Ref&lt;WebCore::SharedBuffer&gt;&amp;&amp;, int reportedEncodedDataLength) final;
+    void didFinishLoading(WebCore::ResourceHandle*, double finishTime) final;
+    void didFail(WebCore::ResourceHandle*, const WebCore::ResourceError&amp;) final;
+
+    Download&amp; m_download;
+    String m_destinationPath;
+    WebCore::PlatformFileHandle m_destinationFile { WebCore::invalidPlatformFileHandle };
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsDownloadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;Download.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AuthenticationManager.h&quot;
</span><ins>+#include &quot;BlobDownloadClient.h&quot;
</ins><span class="cx"> #include &quot;Connection.h&quot;
</span><span class="cx"> #include &quot;DataReference.h&quot;
</span><span class="cx"> #include &quot;DownloadManager.h&quot;
</span><span class="lines">@@ -44,18 +45,21 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(NETWORK_SESSION) &amp;&amp; PLATFORM(COCOA)
</span><span class="cx"> Download::Download(DownloadManager&amp; downloadManager, DownloadID downloadID, NSURLSessionDownloadTask* download, const WebCore::SessionID&amp; sessionID, const String&amp; suggestedName)
</span><del>-#else
</del><ins>+    : m_downloadManager(downloadManager)
+    , m_downloadID(downloadID)
+    , m_download(download)
+    , m_suggestedName(suggestedName)
+{
+    ASSERT(m_downloadID.downloadID());
+
+    m_downloadManager.didCreateDownload();
+}
+#endif
+
</ins><span class="cx"> Download::Download(DownloadManager&amp; downloadManager, DownloadID downloadID, const ResourceRequest&amp; request, const String&amp; suggestedName)
</span><del>-#endif
</del><span class="cx">     : m_downloadManager(downloadManager)
</span><span class="cx">     , m_downloadID(downloadID)
</span><del>-#if !USE(NETWORK_SESSION)
</del><span class="cx">     , m_request(request)
</span><del>-#endif
-#if USE(NETWORK_SESSION) &amp;&amp; PLATFORM(COCOA)
-    , m_download(download)
-    , m_sessionID(sessionID)
-#endif
</del><span class="cx">     , m_suggestedName(suggestedName)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_downloadID.downloadID());
</span><span class="lines">@@ -70,12 +74,26 @@
</span><span class="cx">     m_downloadManager.didDestroyDownload();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !USE(NETWORK_SESSION)
</del><ins>+void Download::start()
+{
+    if (m_request.url().protocolIsBlob()) {
+        m_downloadClient = std::make_unique&lt;BlobDownloadClient&gt;(*this);
+        m_resourceHandle = ResourceHandle::create(nullptr, m_request, m_downloadClient.get(), false, false);
+        didStart();
+        return;
+    }
+
+#if USE(NETWORK_SESSION)
+    ASSERT_NOT_REACHED();
+#else
+    startNetworkLoad();
+#endif
+}
+
</ins><span class="cx"> void Download::didStart()
</span><span class="cx"> {
</span><span class="cx">     send(Messages::DownloadProxy::DidStart(m_request, m_suggestedName));
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> #if !USE(NETWORK_SESSION)
</span><span class="cx"> void Download::didReceiveAuthenticationChallenge(const AuthenticationChallenge&amp; authenticationChallenge)
</span><span class="lines">@@ -82,6 +100,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_downloadManager.downloadsAuthenticationManager().didReceiveAuthenticationChallenge(*this, authenticationChallenge);
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> void Download::didReceiveResponse(const ResourceResponse&amp; response)
</span><span class="cx"> {
</span><span class="lines">@@ -89,7 +108,6 @@
</span><span class="cx"> 
</span><span class="cx">     send(Messages::DownloadProxy::DidReceiveResponse(response));
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> void Download::didReceiveData(uint64_t length)
</span><span class="cx"> {
</span><span class="lines">@@ -110,7 +128,6 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !USE(NETWORK_SESSION)
</del><span class="cx"> String Download::decideDestinationWithSuggestedFilename(const String&amp; filename, bool&amp; allowOverwrite)
</span><span class="cx"> {
</span><span class="cx">     String destination;
</span><span class="lines">@@ -124,7 +141,6 @@
</span><span class="cx"> 
</span><span class="cx">     return destination;
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> void Download::didCreateDestination(const String&amp; path)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsDownloadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -29,8 +29,11 @@
</span><span class="cx"> #include &quot;DownloadID.h&quot;
</span><span class="cx"> #include &quot;MessageSender.h&quot;
</span><span class="cx"> #include &quot;SandboxExtension.h&quot;
</span><ins>+#include &lt;WebCore/ResourceHandle.h&gt;
+#include &lt;WebCore/ResourceHandleClient.h&gt;
</ins><span class="cx"> #include &lt;WebCore/ResourceRequest.h&gt;
</span><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><ins>+#include &lt;memory&gt;
</ins><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="lines">@@ -44,12 +47,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(GTK) || PLATFORM(EFL)
-#include &lt;WebCore/ResourceHandle.h&gt;
-#include &lt;WebCore/ResourceHandleClient.h&gt;
-#include &lt;memory&gt;
-#endif
-
</del><span class="cx"> #if USE(CFNETWORK)
</span><span class="cx"> #include &lt;CFNetwork/CFURLDownloadPriv.h&gt;
</span><span class="cx"> #endif
</span><span class="lines">@@ -77,13 +74,14 @@
</span><span class="cx"> public:
</span><span class="cx"> #if USE(NETWORK_SESSION) &amp;&amp; PLATFORM(COCOA)
</span><span class="cx">     Download(DownloadManager&amp;, DownloadID, NSURLSessionDownloadTask*, const WebCore::SessionID&amp; sessionID, const String&amp; suggestedFilename = { });
</span><del>-#else
</del><ins>+#endif
</ins><span class="cx">     Download(DownloadManager&amp;, DownloadID, const WebCore::ResourceRequest&amp;, const String&amp; suggestedFilename = { });
</span><del>-#endif
</del><ins>+
</ins><span class="cx">     ~Download();
</span><span class="cx"> 
</span><ins>+    void start();
+
</ins><span class="cx"> #if !USE(NETWORK_SESSION)
</span><del>-    void start();
</del><span class="cx">     void startWithHandle(WebCore::ResourceHandle*, const WebCore::ResourceResponse&amp;);
</span><span class="cx"> #endif
</span><span class="cx">     void resume(const IPC::DataReference&amp; resumeData, const String&amp; path, const SandboxExtension::Handle&amp;);
</span><span class="lines">@@ -90,19 +88,19 @@
</span><span class="cx">     void cancel();
</span><span class="cx"> 
</span><span class="cx">     DownloadID downloadID() const { return m_downloadID; }
</span><ins>+    const String&amp; suggestedName() const { return m_suggestedName; }
+    const WebCore::ResourceRequest&amp; request() const { return m_request; }
</ins><span class="cx"> 
</span><span class="cx"> #if USE(NETWORK_SESSION)
</span><span class="cx">     void setSandboxExtension(RefPtr&lt;SandboxExtension&gt;&amp;&amp; sandboxExtension) { m_sandboxExtension = WTFMove(sandboxExtension); }
</span><span class="cx"> #else
</span><ins>+    void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&amp;);
+#endif
</ins><span class="cx">     void didStart();
</span><del>-    void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&amp;);
</del><span class="cx">     void didReceiveResponse(const WebCore::ResourceResponse&amp;);
</span><del>-#endif
</del><span class="cx">     void didReceiveData(uint64_t length);
</span><span class="cx">     bool shouldDecodeSourceDataOfMIMEType(const String&amp; mimeType);
</span><del>-#if !USE(NETWORK_SESSION)
</del><span class="cx">     String decideDestinationWithSuggestedFilename(const String&amp; filename, bool&amp; allowOverwrite);
</span><del>-#endif
</del><span class="cx">     void didCreateDestination(const String&amp; path);
</span><span class="cx">     void didFinish();
</span><span class="cx">     void platformDidFinish();
</span><span class="lines">@@ -114,6 +112,10 @@
</span><span class="cx">     IPC::Connection* messageSenderConnection() override;
</span><span class="cx">     uint64_t messageSenderDestinationID() override;
</span><span class="cx"> 
</span><ins>+#if !USE(NETWORK_SESSION)
+    void startNetworkLoad();
+#endif
+
</ins><span class="cx">     void platformInvalidate();
</span><span class="cx"> 
</span><span class="cx">     bool isAlwaysOnLoggingAllowed() const;
</span><span class="lines">@@ -120,9 +122,7 @@
</span><span class="cx"> 
</span><span class="cx">     DownloadManager&amp; m_downloadManager;
</span><span class="cx">     DownloadID m_downloadID;
</span><del>-#if !USE(NETWORK_SESSION)
</del><span class="cx">     WebCore::ResourceRequest m_request;
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     RefPtr&lt;SandboxExtension&gt; m_sandboxExtension;
</span><span class="cx"> 
</span><span class="lines">@@ -138,10 +138,8 @@
</span><span class="cx"> #if USE(CFNETWORK)
</span><span class="cx">     RetainPtr&lt;CFURLDownloadRef&gt; m_download;
</span><span class="cx"> #endif
</span><del>-#if PLATFORM(GTK) || PLATFORM(EFL)
</del><span class="cx">     std::unique_ptr&lt;WebCore::ResourceHandleClient&gt; m_downloadClient;
</span><span class="cx">     RefPtr&lt;WebCore::ResourceHandle&gt; m_resourceHandle;
</span><del>-#endif
</del><span class="cx">     String m_suggestedName;
</span><span class="cx">     bool m_hasReceivedData { false };
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsDownloadManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -47,21 +47,23 @@
</span><span class="cx"> void DownloadManager::startDownload(SessionID sessionID, DownloadID downloadID, const ResourceRequest&amp; request, const String&amp; suggestedName)
</span><span class="cx"> {
</span><span class="cx"> #if USE(NETWORK_SESSION)
</span><del>-    auto* networkSession = SessionTracker::networkSession(sessionID);
-    if (!networkSession)
</del><ins>+    if (!request.url().protocolIsBlob()) {
+        auto* networkSession = SessionTracker::networkSession(sessionID);
+        if (!networkSession)
+            return;
+        NetworkLoadParameters parameters;
+        parameters.sessionID = sessionID;
+        parameters.request = request;
+        parameters.clientCredentialPolicy = ClientCredentialPolicy::MayAskClientForCredentials;
+        m_pendingDownloads.add(downloadID, std::make_unique&lt;PendingDownload&gt;(WTFMove(parameters), downloadID, *networkSession, suggestedName));
</ins><span class="cx">         return;
</span><del>-    NetworkLoadParameters parameters;
-    parameters.sessionID = sessionID;
-    parameters.request = request;
-    parameters.clientCredentialPolicy = ClientCredentialPolicy::MayAskClientForCredentials;
-    m_pendingDownloads.add(downloadID, std::make_unique&lt;PendingDownload&gt;(WTFMove(parameters), downloadID, *networkSession, suggestedName));
-#else
</del><ins>+    }
+#endif
</ins><span class="cx">     auto download = std::make_unique&lt;Download&gt;(*this, downloadID, request, suggestedName);
</span><span class="cx">     download-&gt;start();
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!m_downloads.contains(downloadID));
</span><span class="cx">     m_downloads.add(downloadID, WTFMove(download));
</span><del>-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(NETWORK_SESSION)
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsiosDownloadIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx">     };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Download::start()
</del><ins>+void Download::startNetworkLoad()
</ins><span class="cx"> {
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadsmacDownloadMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-void Download::start()
</del><ins>+void Download::startNetworkLoad()
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_nsURLDownload);
</span><span class="cx">     ASSERT(!m_delegate);
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessDownloadssoupDownloadSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx">     bool m_allowOverwrite;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-void Download::start()
</del><ins>+void Download::startNetworkLoad()
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_downloadClient);
</span><span class="cx">     ASSERT(!m_resourceHandle);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDownloadsDownloadProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -189,7 +189,8 @@
</span><span class="cx">     if (NetworkProcessProxy* networkProcess = m_processPool-&gt;networkProcess())
</span><span class="cx">         networkProcess-&gt;connection()-&gt;send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite), 0);
</span><span class="cx"> }
</span><del>-#else
</del><ins>+#endif
+
</ins><span class="cx"> void DownloadProxy::decideDestinationWithSuggestedFilename(const String&amp; filename, String&amp; destination, bool&amp; allowOverwrite, SandboxExtension::Handle&amp; sandboxExtensionHandle)
</span><span class="cx"> {
</span><span class="cx">     allowOverwrite = false;
</span><span class="lines">@@ -206,7 +207,6 @@
</span><span class="cx">     if (!destination.isNull())
</span><span class="cx">         SandboxExtension::createHandle(destination, SandboxExtension::ReadWrite, sandboxExtensionHandle);
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> void DownloadProxy::didCreateDestination(const String&amp; path)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDownloadsDownloadProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -82,9 +82,7 @@
</span><span class="cx">     void didReceiveResponse(const WebCore::ResourceResponse&amp;);
</span><span class="cx">     void didReceiveData(uint64_t length);
</span><span class="cx">     void shouldDecodeSourceDataOfMIMEType(const String&amp; mimeType, bool&amp; result);
</span><del>-#if !USE(NETWORK_SESSION)
</del><span class="cx">     void decideDestinationWithSuggestedFilename(const String&amp; filename, String&amp; destination, bool&amp; allowOverwrite, SandboxExtension::Handle&amp; sandboxExtensionHandle);
</span><del>-#endif
</del><span class="cx">     void didCreateDestination(const String&amp; path);
</span><span class="cx">     void didFinish();
</span><span class="cx">     void didFail(const WebCore::ResourceError&amp;, const IPC::DataReference&amp; resumeData);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessDownloadsDownloadProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -32,9 +32,7 @@
</span><span class="cx">     DidReceiveResponse(WebCore::ResourceResponse response)
</span><span class="cx">     DidReceiveData(uint64_t length)
</span><span class="cx">     ShouldDecodeSourceDataOfMIMEType(String mimeType) -&gt; (bool result)
</span><del>-#if !USE(NETWORK_SESSION)
</del><span class="cx">     DecideDestinationWithSuggestedFilename(String filename) -&gt; (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
</span><del>-#endif
</del><span class="cx">     DidCreateDestination(String path)
</span><span class="cx">     DidFinish()
</span><span class="cx">     DidFail(WebCore::ResourceError error, IPC::DataReference resumeData)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (206355 => 206356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-09-25 02:39:38 UTC (rev 206356)
</span><span class="lines">@@ -1213,6 +1213,8 @@
</span><span class="cx">                 839902021BE9A02B000F3653 /* NetworkLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839901FF1BE9A01B000F3653 /* NetworkLoad.cpp */; };
</span><span class="cx">                 839902031BE9A02B000F3653 /* NetworkLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 839901FE1BE9A01B000F3653 /* NetworkLoad.h */; };
</span><span class="cx">                 83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */; };
</span><ins>+                83BFAC421D96137C00433490 /* BlobDownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BFAC401D96136000433490 /* BlobDownloadClient.h */; };
+                83BFAC431D96137C00433490 /* BlobDownloadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BFAC411D96136000433490 /* BlobDownloadClient.cpp */; };
</ins><span class="cx">                 83D454D71BE9D3C4006C93BD /* NetworkLoadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D454D61BE9D3C4006C93BD /* NetworkLoadClient.h */; };
</span><span class="cx">                 84477853176FCC0800CDC7BB /* InjectedBundleHitTestResultMediaType.h in Headers */ = {isa = PBXBuildFile; fileRef = 84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */; };
</span><span class="cx">                 868160D0187645570021E79D /* WindowServerConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 868160CF187645370021E79D /* WindowServerConnection.mm */; };
</span><span class="lines">@@ -3308,6 +3310,8 @@
</span><span class="cx">                 839901FE1BE9A01B000F3653 /* NetworkLoad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkLoad.h; path = NetworkProcess/NetworkLoad.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 839901FF1BE9A01B000F3653 /* NetworkLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkLoad.cpp; path = NetworkProcess/NetworkLoad.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheStatistics.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                83BFAC401D96136000433490 /* BlobDownloadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobDownloadClient.h; path = NetworkProcess/Downloads/BlobDownloadClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                83BFAC411D96136000433490 /* BlobDownloadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobDownloadClient.cpp; path = NetworkProcess/Downloads/BlobDownloadClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 83D454D61BE9D3C4006C93BD /* NetworkLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkLoadClient.h; path = NetworkProcess/NetworkLoadClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleHitTestResultMediaType.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 868160CD18763D4B0021E79D /* WindowServerConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowServerConnection.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5738,6 +5742,8 @@
</span><span class="cx">                                 5C1427081C23F85200D41183 /* cocoa */,
</span><span class="cx">                                 5C14270C1C23F87700D41183 /* ios */,
</span><span class="cx">                                 5C14270B1C23F87100D41183 /* mac */,
</span><ins>+                                83BFAC401D96136000433490 /* BlobDownloadClient.h */,
+                                83BFAC411D96136000433490 /* BlobDownloadClient.cpp */,
</ins><span class="cx">                                 5C1426F31C23F84300D41183 /* Download.cpp */,
</span><span class="cx">                                 5C1426F41C23F84300D41183 /* Download.h */,
</span><span class="cx">                                 5C1426F71C23F84300D41183 /* DownloadID.h */,
</span><span class="lines">@@ -7612,6 +7618,7 @@
</span><span class="cx">                                 2984F57D164B915F004BC0C6 /* CustomProtocolManagerProxyMessages.h in Headers */,
</span><span class="cx">                                 515E772C184008B90007203F /* DatabaseProcessCreationParameters.h in Headers */,
</span><span class="cx">                                 512A9761180E031D0039A149 /* DatabaseProcessMessages.h in Headers */,
</span><ins>+                                83BFAC421D96137C00433490 /* BlobDownloadClient.h in Headers */,
</ins><span class="cx">                                 517DD5BF180DA7D30081660B /* DatabaseProcessProxy.h in Headers */,
</span><span class="cx">                                 512A976A180E09B80039A149 /* DatabaseProcessProxyMessages.h in Headers */,
</span><span class="cx">                                 51032F1E180F791700961BB7 /* DatabaseToWebProcessConnectionMessages.h in Headers */,
</span><span class="lines">@@ -9149,6 +9156,7 @@
</span><span class="cx">                                 0F0C365E18C110A500F607D7 /* LayerRepresentation.mm in Sources */,
</span><span class="cx">                                 1A92DC1312F8BAB90017AF65 /* LayerTreeContext.cpp in Sources */,
</span><span class="cx">                                 1AFDE64519510B5500C48FFA /* LegacyBundleForClass.mm in Sources */,
</span><ins>+                                83BFAC431D96137C00433490 /* BlobDownloadClient.cpp in Sources */,
</ins><span class="cx">                                 1AFDE65D1954E8D500C48FFA /* LegacySessionStateCoding.cpp in Sources */,
</span><span class="cx">                                 2D1087601D2C573E00B85F82 /* LoadParameters.cpp in Sources */,
</span><span class="cx">                                 2D1087631D2C641B00B85F82 /* LoadParametersCocoa.mm in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>