<!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>[198955] 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/198955">198955</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-04-01 14:10:41 -0700 (Fri, 01 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Confirm <a download> satisfies specification criteria
https://bugs.webkit.org/show_bug.cgi?id=156057
Reviewed by Andy Estes.
Source/WebKit2:
* WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp:
(WKBundleNavigationActionGetHasDownloadAttribute): Added.
* WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h:
* WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
(WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
* WebProcess/InjectedBundle/InjectedBundleNavigationAction.h:
(WebKit::InjectedBundleNavigationAction::hasDownloadAttribute): Added.
Tools:
Revise WebKitTestRunner:
(1) Provide a download client delegate.
(2) Teach WKTR to wait to finish a test until a download finishes.
(3) Allow WKTR to notify the current TestRunner that it can finish.
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage): Update to recognize a new
message "NotifyDownloadDone".
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::decidePolicyForNavigationAction): Handle 'download'
attribute case.
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::waitUntilDownload): Added.
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::shouldFinishAfterDownload): Added.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions): Set up the download client.
(WTR::TestController::downloadDidStart): Added.
(WTR::TestController::decideDestinationWithSuggestedFilename): Added.
(WTR::TestController::downloadDidFinish): Added.
(WTR::TestController::downloadDidFail): Added.
(WTR::TestController::downloadDidCancel): Added.
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::notifyDownloadDone): Added.
* WebKitTestRunner/TestInvocation.h:
LayoutTests:
Import <a download> tests from the Blink project.
Based on a Blink change (patch by <asanka@chromium.org>):
<https://src.chromium.org/viewvc/blink?revision=172767&view=revision>
* TestExpectations: Mark two expected failures with the new tests.
* fast/dom/HTMLAnchorElement/anchor-download-expected.txt: Updated for
expected output (blob URL currently not working).
* fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt: Ditto.
* http/tests/security/anchor-download-allow-blob-expected.txt: Added.
* http/tests/security/anchor-download-allow-blob.html: Added.
* http/tests/security/anchor-download-allow-data-expected.txt: Added.
* http/tests/security/anchor-download-allow-data.html: Added.
* http/tests/security/anchor-download-allow-sameorigin-expected.txt: Added.
* http/tests/security/anchor-download-allow-sameorigin.html: Added.
* http/tests/security/anchor-download-block-crossorigin-expected.txt: Added.
* http/tests/security/anchor-download-block-crossorigin.html: Added.
* http/tests/security/resources/attachment.php: Added.
* platform/ios-simulator-wk1/TestExpectations: Disable download tests until WK1 support
is implemented.
* platform/ios-simulator-wk2/TestExpectations: Disable download tests until
NETWORK_SESSION support exists.
* platform/mac/TestExpectations: Reactivate the HTMLAnchorElement tests.
* platform/mac-wk1/TestExpectations: Disable download tests until WK1 support
is implemented.</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="#trunkLayoutTestsplatformiossimulatorwk1TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk2/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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNavigationActioncpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNavigationActionPrivateh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleNavigationActioncpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleNavigationActionh">trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl">trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllerh">trunk/Tools/WebKitTestRunner/TestController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestInvocationcpp">trunk/Tools/WebKitTestRunner/TestInvocation.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestInvocationh">trunk/Tools/WebKitTestRunner/TestInvocation.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadallowblobexpectedtxt">trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadallowblobhtml">trunk/LayoutTests/http/tests/security/anchor-download-allow-blob.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadallowdataexpectedtxt">trunk/LayoutTests/http/tests/security/anchor-download-allow-data-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadallowdatahtml">trunk/LayoutTests/http/tests/security/anchor-download-allow-data.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadallowsameoriginexpectedtxt">trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadallowsameoriginhtml">trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginexpectedtxt">trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginhtml">trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityresourcesattachmentphp">trunk/LayoutTests/http/tests/security/resources/attachment.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/ChangeLog        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2016-04-01 Brent Fulgham <bfulgham@apple.com>
+
+ Confirm <a download> satisfies specification criteria
+ https://bugs.webkit.org/show_bug.cgi?id=156057
+
+ Reviewed by Andy Estes.
+
+ Import <a download> tests from the Blink project.
+
+ Based on a Blink change (patch by <asanka@chromium.org>):
+ <https://src.chromium.org/viewvc/blink?revision=172767&view=revision>
+
+ * TestExpectations: Mark two expected failures with the new tests.
+ * fast/dom/HTMLAnchorElement/anchor-download-expected.txt: Updated for
+ expected output (blob URL currently not working).
+ * fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt: Ditto.
+ * http/tests/security/anchor-download-allow-blob-expected.txt: Added.
+ * http/tests/security/anchor-download-allow-blob.html: Added.
+ * http/tests/security/anchor-download-allow-data-expected.txt: Added.
+ * http/tests/security/anchor-download-allow-data.html: Added.
+ * http/tests/security/anchor-download-allow-sameorigin-expected.txt: Added.
+ * http/tests/security/anchor-download-allow-sameorigin.html: Added.
+ * http/tests/security/anchor-download-block-crossorigin-expected.txt: Added.
+ * http/tests/security/anchor-download-block-crossorigin.html: Added.
+ * http/tests/security/resources/attachment.php: Added.
+ * platform/ios-simulator-wk1/TestExpectations: Disable download tests until WK1 support
+ is implemented.
+ * platform/ios-simulator-wk2/TestExpectations: Disable download tests until
+ NETWORK_SESSION support exists.
+ * platform/mac/TestExpectations: Reactivate the HTMLAnchorElement tests.
+ * platform/mac-wk1/TestExpectations: Disable download tests until WK1 support
+ is implemented.
+
</ins><span class="cx"> 2016-04-01 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Rebaseline tests added with r198951
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/TestExpectations        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1023,3 +1023,9 @@
</span><span class="cx"> fast/scrolling/rtl-scrollbars-listbox-select-right.html [ ImageOnlyFailure ]
</span><span class="cx"> fast/scrolling/rtl-scrollbars-listbox-simple.html [ ImageOnlyFailure ]
</span><span class="cx"> fast/scrolling/rtl-scrollbars-listbox.html [ ImageOnlyFailure ]
</span><ins>+
+# <a download> does not support Blobs
+webkit.org/b/156099 http/tests/security/anchor-download-allow-blob.html [ Failure ]
+
+# <a download> does not honor cross-origin restrictions
+webkit.org/b/156100 http/tests/security/anchor-download-block-crossorigin.html [ Failure ]
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchordownloadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1 +1,4 @@
</span><ins>+Download started.
+Download failed.
+Failed: NSURLErrorDomain, code=-1002, description=unsupported URL
</ins><span class="cx"> Blob URL
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchornodownloadsetexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1 +1,4 @@
</span><ins>+Download started.
+Download failed.
+Failed: NSURLErrorDomain, code=-1002, description=unsupported URL
</ins><span class="cx"> Blob URL
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadallowblobexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+Downloading URL with suggested filename "foo.pdf"
+Tests that a suggested filename on a download attribute is allowed if the link is a blob URL.
+
+The suggested filename at the top should be foo.pdf.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadallowblobhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-allow-blob.html (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-allow-blob.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-blob.html        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDownloadFinished();
+</script>
+</head>
+<body>
+<p>
+Tests that a suggested filename on a download attribute is allowed if
+<a id="dl" download="foo.pdf">the link</a> is a blob URL.
+<p>The suggested filename at the top should be foo.pdf.</p>
+<div id="console"></div>
+<script>
+ function click(elmt)
+ {
+ if (!window.eventSender)
+ return;
+
+ eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+
+ function runTest()
+ {
+ var blob = new Blob(["Hello world!"], {type: "application/octet-stream"});
+ var link = document.getElementById("dl");
+ link.href = window.URL.createObjectURL(blob);
+ click(link);
+ }
+ runTest();
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadallowdataexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-allow-data-expected.txt (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-allow-data-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-data-expected.txt        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+Download started.
+Downloading URL with suggested filename "foo.pdf"
+Download completed.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Tests that a suggested filename on a download attribute is allowed if the link is a data URL.
+
+The suggested filename at the top should be foo.pdf.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadallowdatahtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-allow-data.html (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-allow-data.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-data.html        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDownloadFinished();
+</script>
+</head>
+<body>
+<p>
+Tests that a suggested filename on a download attribute is allowed if
+<a id="dl" href="data:application/octet-stream,Hello" download="foo.pdf">the link</a> is a data URL.
+<p>The suggested filename at the top should be foo.pdf.</p>
+<script>
+ function click(elmt)
+ {
+ if (!window.eventSender)
+ return;
+
+ eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+
+ function runTest()
+ {
+ var link = document.getElementById("dl");
+ click(link);
+ }
+ runTest();
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadallowsameoriginexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin-expected.txt (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin-expected.txt        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Download started.
+Downloading URL with suggested filename "foo.pdf"
+Download completed.
+Tests that a suggested filename on a download attribute is allowed if the link is in the same origin.
+
+The suggested filename at the top should be foo.pdf.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadallowsameoriginhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDownloadFinished();
+</script>
+</head>
+<body>
+<p>
+Tests that a suggested filename on a download attribute is allowed if
+<a id="dl" href="/security/resources/attachment.php" download="foo.pdf">the link</a> is in the same origin.
+<p>
+The suggested filename at the top should be foo.pdf.
+<script>
+ function click(elmt)
+ {
+ if (!window.eventSender)
+ return;
+
+ eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+
+ function runTest()
+ {
+ var link = document.getElementById("dl");
+ click(link);
+ }
+ runTest();
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+Downloading URL with suggested filename ""
+Tests that a suggested filename on a download attribute is ignored if the link is cross origin.
+
+The suggested filename at the top should be empty.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html         (rev 0)
+++ trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDownloadFinished();
+</script>
+</head>
+<body>
+<p>
+Tests that a suggested filename on a download attribute is ignored if
+<a id="dl" href="http://localhost:8080/security/resources/attachment.php" download="foo.pdf">the link</a> is cross origin.
+<p>
+The suggested filename at the top should be empty.
+<script>
+ function click(elmt)
+ {
+ if (!window.eventSender)
+ return;
+
+ eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+
+ function runTest()
+ {
+ var link = document.getElementById("dl");
+ click(link);
+ }
+ runTest();
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityresourcesattachmentphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/resources/attachment.php (0 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/resources/attachment.php         (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/attachment.php        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+<?php
+header("Content-Disposition: attachment; filename=test file.txt");
+header("Content-Type: text/plain");
+?>
+
+Test file content.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1345,3 +1345,9 @@
</span><span class="cx"> imported/blink/fast/css-grid-layout/stale-grid-layout-2.html [ Failure Pass ]
</span><span class="cx">
</span><span class="cx"> webkit.org/b/155495 compositing/visible-rect/animated-from-none.html [ Failure ]
</span><ins>+
+# <a download> is not support in WK1 yet.
+webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
+webkit.org/b/156069 http/tests/security/anchor-download-allow-data.html [ Skip ]
+webkit.org/b/156069 http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
+webkit.org/b/156069 http/tests/security/anchor-download-block-crossorigin.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1955,3 +1955,9 @@
</span><span class="cx"> webkit.org/b/155947 [ Debug ] fast/loader/scroll-position-restored-on-back.html [ Pass Failure ]
</span><span class="cx">
</span><span class="cx"> webkit.org/b/155948 transitions/cancel-transition.html [ Pass Failure ]
</span><ins>+
+# <a download> is not supported with NETWORK_SESSION yet.
+webkit.org/b/156067 http/tests/security/anchor-download-allow-blob.html [ Skip ]
+webkit.org/b/156067 http/tests/security/anchor-download-allow-data.html [ Skip ]
+webkit.org/b/156067 http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
+webkit.org/b/156067 http/tests/security/anchor-download-block-crossorigin.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -260,12 +260,6 @@
</span><span class="cx"> storage/storagequota-request-quota.html
</span><span class="cx"> fast/workers/worker-storagequota-query-usage.html
</span><span class="cx">
</span><del>-# Tests that require ENABLE(DOWNLOAD_ATTRIBUTE).
-fast/dom/HTMLAnchorElement/anchor-nodownload.html
-fast/dom/HTMLAnchorElement/anchor-download.html
-fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
-fast/dom/HTMLAnchorElement/anchor-download-unset.html
-
</del><span class="cx"> # HTTP 204 (No Content) should be ignored
</span><span class="cx"> webkit.org/b/60206 http/tests/navigation/response204.html
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -201,3 +201,11 @@
</span><span class="cx">
</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><ins>+
+# <a download> is not support in WK1 yet.
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Failure ]
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download.html [ Failure ]
+webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
+webkit.org/b/156069 http/tests/security/anchor-download-allow-data.html [ Skip ]
+webkit.org/b/156069 http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
+webkit.org/b/156069 http/tests/security/anchor-download-block-crossorigin.html [ Skip ]
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-04-01 Brent Fulgham <bfulgham@apple.com>
+
+ Confirm <a download> satisfies specification criteria
+ https://bugs.webkit.org/show_bug.cgi?id=156057
+
+ Reviewed by Andy Estes.
+
+ * WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp:
+ (WKBundleNavigationActionGetHasDownloadAttribute): Added.
+ * WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h:
+ * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
+ (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
+ * WebProcess/InjectedBundle/InjectedBundleNavigationAction.h:
+ (WebKit::InjectedBundleNavigationAction::hasDownloadAttribute): Added.
+
</ins><span class="cx"> 2016-04-01 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> CMake build fix.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNavigationActioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -76,3 +76,8 @@
</span><span class="cx"> {
</span><span class="cx"> return toImpl(navigationActionRef)->shouldTryAppLinks();
</span><span class="cx"> }
</span><ins>+
+WKStringRef WKBundleNavigationActionCopyDownloadAttribute(WKBundleNavigationActionRef navigationActionRef)
+{
+ return toCopiedAPI(toImpl(navigationActionRef)->downloadAttribute());
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNavigationActionPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">
</span><span class="cx"> WK_EXPORT bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef);
</span><span class="cx"> WK_EXPORT bool WKBundleNavigationActionGetShouldTryAppLinks(WKBundleNavigationActionRef);
</span><ins>+WK_EXPORT WKStringRef WKBundleNavigationActionCopyDownloadAttribute(WKBundleNavigationActionRef);
</ins><span class="cx">
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleNavigationActioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2011-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -91,6 +91,7 @@
</span><span class="cx"> : m_navigationType(navigationAction.type())
</span><span class="cx"> , m_modifiers(modifiersForNavigationAction(navigationAction))
</span><span class="cx"> , m_mouseButton(WebMouseEvent::NoButton)
</span><ins>+ , m_downloadAttribute(navigationAction.downloadAttribute())
</ins><span class="cx"> , m_shouldOpenExternalURLs(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow || navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes)
</span><span class="cx"> , m_shouldTryAppLinks(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleInjectedBundleNavigationActionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx">
</span><span class="cx"> bool shouldOpenExternalURLs() const { return m_shouldOpenExternalURLs; }
</span><span class="cx"> bool shouldTryAppLinks() const { return m_shouldTryAppLinks; }
</span><ins>+ AtomicString downloadAttribute() const { return m_downloadAttribute; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> InjectedBundleNavigationAction(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>);
</span><span class="lines">@@ -67,6 +68,7 @@
</span><span class="cx"> WebMouseEvent::Button m_mouseButton;
</span><span class="cx"> RefPtr<InjectedBundleHitTestResult> m_hitTestResult;
</span><span class="cx"> RefPtr<InjectedBundleNodeHandle> m_formElement;
</span><ins>+ AtomicString m_downloadAttribute;
</ins><span class="cx"> bool m_shouldOpenExternalURLs;
</span><span class="cx"> bool m_shouldTryAppLinks;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/ChangeLog        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-04-01 Brent Fulgham <bfulgham@apple.com>
+
+ Confirm <a download> satisfies specification criteria
+ https://bugs.webkit.org/show_bug.cgi?id=156057
+
+ Reviewed by Andy Estes.
+
+ Revise WebKitTestRunner:
+ (1) Provide a download client delegate.
+ (2) Teach WKTR to wait to finish a test until a download finishes.
+ (3) Allow WKTR to notify the current TestRunner that it can finish.
+
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::didReceiveMessageToPage): Update to recognize a new
+ message "NotifyDownloadDone".
+ * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+ (WTR::InjectedBundlePage::decidePolicyForNavigationAction): Handle 'download'
+ attribute case.
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::waitUntilDownload): Added.
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ (WTR::TestRunner::shouldFinishAfterDownload): Added.
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::createWebViewWithOptions): Set up the download client.
+ (WTR::TestController::downloadDidStart): Added.
+ (WTR::TestController::decideDestinationWithSuggestedFilename): Added.
+ (WTR::TestController::downloadDidFinish): Added.
+ (WTR::TestController::downloadDidFail): Added.
+ (WTR::TestController::downloadDidCancel): Added.
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::notifyDownloadDone): Added.
+ * WebKitTestRunner/TestInvocation.h:
+
</ins><span class="cx"> 2016-04-01 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Compile DumpRenderTree with CMake on Mac
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> void dumpChildFramesAsText();
</span><span class="cx"> void waitForPolicyDelegate();
</span><span class="cx"> void waitUntilDone();
</span><ins>+ void waitUntilDownloadFinished();
</ins><span class="cx"> void notifyDone();
</span><span class="cx"> double preciseTime();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -236,6 +236,11 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (WKStringIsEqualToUTF8CString(messageName, "NotifyDownloadDone")) {
+ m_testRunner->notifyDone();
+ return;
+ }
+
</ins><span class="cx"> if (WKStringIsEqualToUTF8CString(messageName, "CallUISideScriptCallback")) {
</span><span class="cx"> WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -1317,8 +1317,11 @@
</span><span class="cx"> if (injectedBundle.testRunner()->shouldDecideNavigationPolicyAfterDelay())
</span><span class="cx"> return WKBundlePagePolicyActionPassThrough;
</span><span class="cx">
</span><del>- if (!injectedBundle.testRunner()->isPolicyDelegateEnabled())
- return WKBundlePagePolicyActionUse;
</del><ins>+ if (!injectedBundle.testRunner()->isPolicyDelegateEnabled()) {
+ WKRetainPtr<WKStringRef> downloadAttributeRef(AdoptWK, WKBundleNavigationActionCopyDownloadAttribute(navigationAction));
+ String downloadAttribute = toWTFString(downloadAttributeRef);
+ return downloadAttribute.isNull() ? WKBundlePagePolicyActionUse : WKBundlePagePolicyActionPassThrough;
+ }
</ins><span class="cx">
</span><span class="cx"> WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request));
</span><span class="cx"> WKRetainPtr<WKStringRef> urlScheme = adoptWK(WKURLCopyScheme(url.get()));
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -141,6 +141,12 @@
</span><span class="cx"> waitUntilDone();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void TestRunner::waitUntilDownloadFinished()
+{
+ m_shouldFinishAfterDownload = true;
+ waitUntilDone();
+}
+
</ins><span class="cx"> void TestRunner::waitUntilDone()
</span><span class="cx"> {
</span><span class="cx"> m_waitToDump = true;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx"> void dumpAsText(bool dumpPixels);
</span><span class="cx"> void waitForPolicyDelegate();
</span><span class="cx"> void dumpChildFramesAsText() { m_whatToDump = AllFramesText; }
</span><ins>+ void waitUntilDownloadFinished();
</ins><span class="cx"> void waitUntilDone();
</span><span class="cx"> void notifyDone();
</span><span class="cx"> double preciseTime();
</span><span class="lines">@@ -195,6 +196,7 @@
</span><span class="cx"> bool waitToDump() const { return m_waitToDump; }
</span><span class="cx"> void waitToDumpWatchdogTimerFired();
</span><span class="cx"> void invalidateWaitToDumpWatchdogTimer();
</span><ins>+ bool shouldFinishAfterDownload() const { return m_shouldFinishAfterDownload; }
</ins><span class="cx">
</span><span class="cx"> bool shouldAllowEditing() const { return m_shouldAllowEditing; }
</span><span class="cx">
</span><span class="lines">@@ -289,7 +291,7 @@
</span><span class="cx"> void queueNonLoadingScript(JSStringRef script);
</span><span class="cx">
</span><span class="cx"> bool secureEventInputIsEnabled() const;
</span><del>-
</del><ins>+
</ins><span class="cx"> JSValueRef failNextNewCodeBlock();
</span><span class="cx"> JSValueRef numberOfDFGCompiles(JSValueRef theFunction);
</span><span class="cx"> JSValueRef neverInlineFunction(JSValueRef theFunction);
</span><span class="lines">@@ -364,6 +366,7 @@
</span><span class="cx"> double m_databaseMaxQuota;
</span><span class="cx">
</span><span class="cx"> bool m_shouldDecideNavigationPolicyAfterDelay { false };
</span><ins>+ bool m_shouldFinishAfterDownload { false };
</ins><span class="cx">
</span><span class="cx"> bool m_userStyleSheetEnabled;
</span><span class="cx"> WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2014-2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010, 2014-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -585,7 +585,22 @@
</span><span class="cx"> };
</span><span class="cx"> WKPageSetPageNavigationClient(m_mainWebView->page(), &pageNavigationClient.base);
</span><span class="cx">
</span><del>-
</del><ins>+ WKContextDownloadClientV0 downloadClient = {
+ { 0, this },
+ downloadDidStart,
+ 0, // didReceiveAuthenticationChallenge
+ 0, // didReceiveResponse
+ 0, // didReceiveData
+ 0, // shouldDecodeSourceDataOfMIMEType
+ decideDestinationWithSuggestedFilename,
+ 0, // didCreateDestination
+ downloadDidFinish,
+ downloadDidFail,
+ downloadDidCancel,
+ 0 // processDidCrash;
+ };
+ WKContextSetDownloadClient(context(), &downloadClient.base);
+
</ins><span class="cx"> // this should just be done on the page?
</span><span class="cx"> WKPageInjectedBundleClientV0 injectedBundleClient = {
</span><span class="cx"> { 0, this },
</span><span class="lines">@@ -1628,6 +1643,85 @@
</span><span class="cx"> WKAuthenticationDecisionListenerUseCredential(decisionListener, credential.get());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+// WKContextDownloadClient
+
+void TestController::downloadDidStart(WKContextRef context, WKDownloadRef download, const void* clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->downloadDidStart(context, download);
+}
+
+WKStringRef TestController::decideDestinationWithSuggestedFilename(WKContextRef context, WKDownloadRef download, WKStringRef filename, bool* allowOverwrite, const void* clientInfo)
+{
+ return static_cast<TestController*>(const_cast<void*>(clientInfo))->decideDestinationWithSuggestedFilename(context, download, filename, allowOverwrite);
+}
+
+void TestController::downloadDidFinish(WKContextRef context, WKDownloadRef download, const void* clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->downloadDidFinish(context, download);
+}
+
+void TestController::downloadDidFail(WKContextRef context, WKDownloadRef download, WKErrorRef error, const void* clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->downloadDidFail(context, download, error);
+}
+
+void TestController::downloadDidCancel(WKContextRef context, WKDownloadRef download, const void* clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->downloadDidCancel(context, download);
+}
+
+void TestController::downloadDidStart(WKContextRef context, WKDownloadRef download)
+{
+ m_currentInvocation->outputText("Download started.\n");
+}
+
+WKStringRef TestController::decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool*& allowOverwrite)
+{
+ StringBuilder builder;
+ builder.append("Downloading URL with suggested filename \"");
+ builder.append(toWTFString(filename));
+ builder.append("\"\n");
+
+ m_currentInvocation->outputText(builder.toString());
+
+ return nullptr;
+}
+
+void TestController::downloadDidFinish(WKContextRef, WKDownloadRef)
+{
+ m_currentInvocation->outputText("Download completed.\n");
+ m_currentInvocation->notifyDownloadDone();
+}
+
+void TestController::downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef error)
+{
+ String message = String::format("Download failed.\n");
+ m_currentInvocation->outputText(message);
+
+ WKRetainPtr<WKStringRef> errorDomain = adoptWK(WKErrorCopyDomain(error));
+ WKRetainPtr<WKStringRef> errorDescription = adoptWK(WKErrorCopyLocalizedDescription(error));
+ int errorCode = WKErrorGetErrorCode(error);
+
+ StringBuilder errorBuilder;
+ errorBuilder.append("Failed: ");
+ errorBuilder.append(toWTFString(errorDomain));
+ errorBuilder.append(", code=");
+ errorBuilder.appendNumber(errorCode);
+ errorBuilder.append(", description=");
+ errorBuilder.append(toWTFString(errorDescription));
+ errorBuilder.append("\n");
+
+ m_currentInvocation->outputText(errorBuilder.toString());
+ m_currentInvocation->notifyDownloadDone();
+}
+
+void TestController::downloadDidCancel(WKContextRef, WKDownloadRef)
+{
+ m_currentInvocation->outputText("Download cancelled.\n");
+ m_currentInvocation->notifyDownloadDone();
+}
+
</ins><span class="cx"> void TestController::processDidCrash()
</span><span class="cx"> {
</span><span class="cx"> // This function can be called multiple times when crash logs are being saved on Windows, so
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.h (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.h        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/TestController.h        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -203,6 +203,19 @@
</span><span class="cx"> static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*);
</span><span class="cx"> void didFinishNavigation(WKPageRef, WKNavigationRef);
</span><span class="cx">
</span><ins>+
+ // WKContextDownloadClient
+ static void downloadDidStart(WKContextRef, WKDownloadRef, const void*);
+ void downloadDidStart(WKContextRef, WKDownloadRef);
+ static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool* allowOverwrite, const void *clientInfo);
+ WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool*& allowOverwrite);
+ static void downloadDidFinish(WKContextRef, WKDownloadRef, const void*);
+ void downloadDidFinish(WKContextRef, WKDownloadRef);
+ static void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef, const void*);
+ void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef);
+ static void downloadDidCancel(WKContextRef, WKDownloadRef, const void*);
+ void downloadDidCancel(WKContextRef, WKDownloadRef);
+
</ins><span class="cx"> static void processDidCrash(WKPageRef, const void* clientInfo);
</span><span class="cx"> void processDidCrash();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -762,4 +762,10 @@
</span><span class="cx"> WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void TestInvocation::notifyDownloadDone()
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("NotifyDownloadDone"));
+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
</ins><span class="cx"> } // namespace WTR
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (198954 => 198955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestInvocation.h        2016-04-01 20:58:11 UTC (rev 198954)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h        2016-04-01 21:10:41 UTC (rev 198955)
</span><span class="lines">@@ -65,6 +65,8 @@
</span><span class="cx"> void didEndSwipe();
</span><span class="cx"> void didRemoveSwipeSnapshot();
</span><span class="cx">
</span><ins>+ void notifyDownloadDone();
+
</ins><span class="cx"> private:
</span><span class="cx"> void dumpResults();
</span><span class="cx"> static void dump(const char* textToStdout, const char* textToStderr = 0, bool seenError = false);
</span></span></pre>
</div>
</div>
</body>
</html>