<!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>[236987] 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/236987">236987</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2018-10-09 16:21:18 -0700 (Tue, 09 Oct 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Anchor target should be ignored on activation when the download attribute is set
https://bugs.webkit.org/show_bug.cgi?id=190408

Reviewed by Geoffrey Garen.

Source/WebCore:

Anchor target should be ignored on activation when the download attribute is set:
- https://html.spec.whatwg.org/#the-a-element:downloading-hyperlinks-2

When the download attribute is set, we should use the "download the hyperlink" algorithm [1]
instead of the "follow the hyperlink" [2] algorithm.

Note that the "download the hyperlink" triggers a download and ignores the target attribute
entirely.

This is important as an anchor element with target=_blank and the download attribute set may
fail because of Safari's popup blocker if we do not disregard the anchor target.

[1] https://html.spec.whatwg.org/#downloading-hyperlinks
[2] https://html.spec.whatwg.org/#following-hyperlinks-2

Tests: fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html
       fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):

Tools:

Update WebKitTestRunner to block popups by default and add support for testRunner.setCanOpenWindows()
for tests that need popups. This aligns WebKitTestRunner with DumpRenderTree and allows testing
popup blocking.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setCanOpenWindows):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createOtherPage):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/TestInvocation.h:

LayoutTests:

* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html: Added.
Add layout test coverage.

* http/tests/download/anchor-load-after-download.html:
* http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:
Update existing WK2-only layout tests to call testRunner.setCanOpenWindows() since they rely on
opening a new window. We failed to notice the issue because these tests are not run on WK1.

* platform/ios-wk2/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:
Skip new tests on WebKit1 since the download attribute is only supported on WebKit2.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsdownloadanchorloadafterdownloadhtml">trunk/LayoutTests/http/tests/download/anchor-load-after-download.html</a></li>
<li><a href="#trunkLayoutTestshttptestsworkersserviceresourcesregistrationtaskqueuescheduling1js">trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2TestExpectations">trunk/LayoutTests/platform/ios-wk2/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</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="#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="#trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblankbasetargetpopupnotallowedexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblankbasetargetpopupnotallowedhtml">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblanktargetpopupnotallowedexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblanktargetpopupnotallowedhtml">trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/ChangeLog 2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -1,5 +1,28 @@
</span><span class="cx"> 2018-10-09  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><ins>+        Anchor target should be ignored on activation when the download attribute is set
+        https://bugs.webkit.org/show_bug.cgi?id=190408
+
+        Reviewed by Geoffrey Garen.
+
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html: Added.
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html: Added.
+        Add layout test coverage.
+
+        * http/tests/download/anchor-load-after-download.html:
+        * http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:
+        Update existing WK2-only layout tests to call testRunner.setCanOpenWindows() since they rely on
+        opening a new window. We failed to notice the issue because these tests are not run on WK1.
+
+        * platform/ios-wk2/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+        Skip new tests on WebKit1 since the download attribute is only supported on WebKit2.
+
+2018-10-09  Chris Dumez  <cdumez@apple.com>
+
</ins><span class="cx">         Unreviewed, skip fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html on iOS.
</span><span class="cx"> 
</span><span class="cx">         The download attribute is not supported on iOS yet.
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblankbasetargetpopupnotallowedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt (0 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt                          (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt     2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Download started.
+Downloading URL with suggested filename "abe.png"
+Download completed.
+The suggested filename above should be "abe.png" and the download should succeed.
+
+File backed blob URL
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblankbasetargetpopupnotallowedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html (0 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html                          (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html     2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<base target="_blank">
+<script>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.setShouldLogDownloadCallbacks(true);
+  testRunner.waitUntilDownloadFinished();
+}
+</script>
+</head>
+<body>
+<p>The suggested filename above should be "abe.png" and the download should succeed.</p>
+<a id="blob-url" download="abe.png" target="_blank">File backed blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    file = internals.createFile("../resources/abe.png");
+    var link = document.getElementById("blob-url");
+    link.href = window.URL.createObjectURL(file);
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblanktargetpopupnotallowedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt (0 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt                               (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt  2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Download started.
+Downloading URL with suggested filename "abe.png"
+Download completed.
+The suggested filename above should be "abe.png" and the download should succeed.
+
+File backed blob URL
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementanchorfileblobdownloadblanktargetpopupnotallowedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html (0 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html                               (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html  2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.setShouldLogDownloadCallbacks(true);
+  testRunner.waitUntilDownloadFinished();
+}
+</script>
+</head>
+<body>
+<p>The suggested filename above should be "abe.png" and the download should succeed.</p>
+<a id="blob-url" download="abe.png" target="_blank">File backed blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    file = internals.createFile("../resources/abe.png");
+    var link = document.getElementById("blob-url");
+    link.href = window.URL.createObjectURL(file);
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsdownloadanchorloadafterdownloadhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/download/anchor-load-after-download.html (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/download/anchor-load-after-download.html    2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/http/tests/download/anchor-load-after-download.html       2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx"> <script>
</span><span class="cx"> if (window.testRunner) {
</span><span class="cx">   testRunner.dumpAsText();
</span><ins>+  testRunner.setCanOpenWindows();
</ins><span class="cx">   testRunner.waitUntilDone();
</span><span class="cx"> }
</span><span class="cx"> </script>
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsworkersserviceresourcesregistrationtaskqueuescheduling1js"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js   2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js      2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -1,6 +1,9 @@
</span><span class="cx"> // This test makes sure that two different windows from two different domains who spam SW registrations get responses intertwined with each other
</span><span class="cx"> // as each registration should operate on its own task queue.
</span><span class="cx"> 
</span><ins>+if (window.testRunner)
+    testRunner.setCanOpenWindows();
+
</ins><span class="cx"> if (location.hostname != "127.0.0.1")
</span><span class="cx">     alert("This test must be initiated from the hostname 127.0.0.1");
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/TestExpectations      2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -1067,7 +1067,9 @@
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download-async-delegate.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
</span><ins>+webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html [ Skip ]
</ins><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html [ Skip ]
</span><ins>+webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html [ Skip ]
</ins><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
</span><span class="cx"> webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations      2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -307,7 +307,9 @@
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
</span><ins>+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html [ Skip ]
</ins><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html [ Skip ]
</span><ins>+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html [ Skip ]
</ins><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
</span><span class="cx"> webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/TestExpectations  2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/platform/win/TestExpectations     2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -455,7 +455,9 @@
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
</span><ins>+fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html [ Skip ]
</ins><span class="cx"> fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html [ Skip ]
</span><ins>+fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html [ Skip ]
</ins><span class="cx"> fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
</span><span class="cx"> fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Source/WebCore/ChangeLog      2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2018-10-09  Chris Dumez  <cdumez@apple.com>
+
+        Anchor target should be ignored on activation when the download attribute is set
+        https://bugs.webkit.org/show_bug.cgi?id=190408
+
+        Reviewed by Geoffrey Garen.
+
+        Anchor target should be ignored on activation when the download attribute is set:
+        - https://html.spec.whatwg.org/#the-a-element:downloading-hyperlinks-2
+
+        When the download attribute is set, we should use the "download the hyperlink" algorithm [1]
+        instead of the "follow the hyperlink" [2] algorithm.
+
+        Note that the "download the hyperlink" triggers a download and ignores the target attribute
+        entirely.
+
+        This is important as an anchor element with target=_blank and the download attribute set may
+        fail because of Safari's popup blocker if we do not disregard the anchor target.
+
+        [1] https://html.spec.whatwg.org/#downloading-hyperlinks
+        [2] https://html.spec.whatwg.org/#following-hyperlinks-2
+
+        Tests: fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html
+               fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadURL):
+
</ins><span class="cx"> 2018-10-09  Michael Catanzaro  <mcatanzaro@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [WPE][GTK] Complex text crashes with harfbuzz 1.8.8
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp      2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -1322,7 +1322,8 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<Frame> protect(m_frame);
</span><span class="cx"> 
</span><del>-    String frameName = frameLoadRequest.frameName();
</del><ins>+    // Anchor target is ignored when the download attribute is set since it will download the hyperlink rather than follow it.
+    String effectiveFrameName = frameLoadRequest.downloadAttribute().isNull() ? frameLoadRequest.frameName() : String();
</ins><span class="cx">     AllowNavigationToInvalidURL allowNavigationToInvalidURL = frameLoadRequest.allowNavigationToInvalidURL();
</span><span class="cx">     NewFrameOpenerPolicy openerPolicy = frameLoadRequest.newFrameOpenerPolicy();
</span><span class="cx">     LockHistory lockHistory = frameLoadRequest.lockHistory();
</span><span class="lines">@@ -1345,7 +1346,7 @@
</span><span class="cx">     ASSERT(newLoadType != FrameLoadType::Same);
</span><span class="cx"> 
</span><span class="cx">     // The search for a target frame is done earlier in the case of form submission.
</span><del>-    Frame* targetFrame = isFormSubmission ? nullptr : findFrameForNavigation(frameName);
</del><ins>+    Frame* targetFrame = isFormSubmission ? nullptr : findFrameForNavigation(effectiveFrameName);
</ins><span class="cx">     if (targetFrame && targetFrame != &m_frame) {
</span><span class="cx">         frameLoadRequest.setFrameName("_self");
</span><span class="cx">         targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, WTFMove(formState), completionHandlerCaller.release());
</span><span class="lines">@@ -1360,9 +1361,9 @@
</span><span class="cx">         action.setOpenedViaWindowOpenWithOpener();
</span><span class="cx">     action.setHasOpenedFrames(!m_openedFrames.isEmpty());
</span><span class="cx"> 
</span><del>-    if (!targetFrame && !frameName.isEmpty()) {
</del><ins>+    if (!targetFrame && !effectiveFrameName.isEmpty()) {
</ins><span class="cx">         action = action.copyWithShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicyToApply(m_frame, frameLoadRequest));
</span><del>-        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request), WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable {
</del><ins>+        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request), WTFMove(formState), effectiveFrameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable {
</ins><span class="cx">             continueLoadAfterNewWindowPolicy(request, formState.get(), frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
</span><span class="cx">             completionHandler();
</span><span class="cx">         });
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/ChangeLog       2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2018-10-09  Chris Dumez  <cdumez@apple.com>
+
+        Anchor target should be ignored on activation when the download attribute is set
+        https://bugs.webkit.org/show_bug.cgi?id=190408
+
+        Reviewed by Geoffrey Garen.
+
+        Update WebKitTestRunner to block popups by default and add support for testRunner.setCanOpenWindows()
+        for tests that need popups. This aligns WebKitTestRunner with DumpRenderTree and allows testing
+        popup blocking.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setCanOpenWindows):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createOtherPage):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/TestInvocation.h:
+
</ins><span class="cx"> 2018-10-09  Jer Noble  <jer.noble@apple.com>
</span><span class="cx"> 
</span><span class="cx">         WebDriver: thrown ObjC exception under -[WKFullScreenWindowController windowDidFailToEnterFullScreen:] when session is terminated
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl      2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx">     // Special options.
</span><span class="cx">     void keepWebHistory();
</span><span class="cx">     void setAcceptsEditing(boolean value);
</span><del>-    void setCanOpenWindows(boolean value);
</del><ins>+    void setCanOpenWindows();
</ins><span class="cx">     void setCloseRemainingWindowsWhenComplete(boolean value);
</span><span class="cx">     void setXSSAuditorEnabled(boolean value);
</span><span class="cx">     void setAllowUniversalAccessFromFileURLs(boolean value);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp       2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp  2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -410,15 +410,11 @@
</span><span class="cx">     return WKBundlePageIsEditingCommandEnabled(InjectedBundle::singleton().page()->page(), toWK(name).get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TestRunner::setCanOpenWindows(bool)
</del><ins>+void TestRunner::setCanOpenWindows()
</ins><span class="cx"> {
</span><del>-    // The test plugins/get-url-with-blank-target.html requires that the embedding client forbid
-    // opening windows (by omitting a call to this function) so as to test that NPN_GetURL()
-    // with a blank target will return an error.
-    //
-    // It is not clear if we should implement this functionality or remove it and plugins/get-url-with-blank-target.html
-    // per the remark in <https://trac.webkit.org/changeset/64504/trunk/LayoutTests/platform/mac-wk2/Skipped>.
-    // For now, just ignore this setting.
</del><ins>+    WKRetainPtr<WKStringRef> messsageName(AdoptWK, WKStringCreateWithUTF8CString("SetCanOpenWindows"));
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(true));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messsageName.get(), messageBody.get(), nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TestRunner::setXSSAuditorEnabled(bool enabled)
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h    2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx">     // Special options.
</span><span class="cx">     void keepWebHistory();
</span><span class="cx">     void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
</span><del>-    void setCanOpenWindows(bool);
</del><ins>+    void setCanOpenWindows();
</ins><span class="cx">     void setCloseRemainingWindowsWhenComplete(bool value) { m_shouldCloseExtraWindows = value; }
</span><span class="cx">     void setXSSAuditorEnabled(bool);
</span><span class="cx">     void setModernMediaControlsEnabled(bool);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp  2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp     2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -242,10 +242,18 @@
</span><span class="cx">     WKPageDidAllowPointerLock(page);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
</del><ins>+WKPageRef TestController::createOtherPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
</ins><span class="cx"> {
</span><span class="cx">     PlatformWebView* parentView = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
</span><ins>+    return TestController::singleton().createOtherPage(parentView, configuration, navigationAction, windowFeatures);
+}
</ins><span class="cx"> 
</span><ins>+WKPageRef TestController::createOtherPage(PlatformWebView* parentView, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures)
+{
+    // The test needs to call testRunner.setCanOpenWindows() to open new windows.
+    if (!m_currentInvocation->canOpenWindows())
+        return nullptr;
+
</ins><span class="cx">     PlatformWebView* view = platformCreateOtherPage(parentView, configuration, parentView->options());
</span><span class="cx">     WKPageRef newPage = view->page();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.h (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.h    2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestController.h       2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -400,6 +400,7 @@
</span><span class="cx">     void didUpdateHistoryTitle(WKStringRef title, WKURLRef, WKFrameRef);
</span><span class="cx"> 
</span><span class="cx">     static WKPageRef createOtherPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void*);
</span><ins>+    WKPageRef createOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef);
</ins><span class="cx"> 
</span><span class="cx">     static void runModal(WKPageRef, const void* clientInfo);
</span><span class="cx">     static void runModal(PlatformWebView*);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp  2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp     2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -802,6 +802,12 @@
</span><span class="cx">     if (WKStringIsEqualToUTF8CString(messageName, "GetDumpFrameLoadCallbacks"))
</span><span class="cx">         return WKRetainPtr<WKTypeRef>(AdoptWK, WKBooleanCreate(m_dumpFrameLoadCallbacks));
</span><span class="cx"> 
</span><ins>+    if (WKStringIsEqualToUTF8CString(messageName, "SetCanOpenWindows")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        m_canOpenWindows = static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
+        return nullptr;
+    }
+
</ins><span class="cx">     if (WKStringIsEqualToUTF8CString(messageName, "SetWindowIsKey")) {
</span><span class="cx">         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
</span><span class="cx">         WKBooleanRef isKeyValue = static_cast<WKBooleanRef>(messageBody);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (236986 => 236987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestInvocation.h    2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h       2018-10-09 23:21:18 UTC (rev 236987)
</span><span class="lines">@@ -84,6 +84,8 @@
</span><span class="cx">     void didRemoveAllSessionCredentials();
</span><span class="cx">     
</span><span class="cx">     void dumpResourceLoadStatistics();
</span><ins>+
+    bool canOpenWindows() const { return m_canOpenWindows; }
</ins><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     WKRetainPtr<WKMutableDictionaryRef> createTestSettingsDictionary();
</span><span class="lines">@@ -132,6 +134,7 @@
</span><span class="cx">     bool m_dumpPixels { false };
</span><span class="cx">     bool m_pixelResultIsPending { false };
</span><span class="cx">     bool m_shouldDumpResourceLoadStatistics { false };
</span><ins>+    bool m_canOpenWindows { false };
</ins><span class="cx">     WhatToDump m_whatToDump { WhatToDump::RenderTree };
</span><span class="cx"> 
</span><span class="cx">     StringBuilder m_textOutput;
</span></span></pre>
</div>
</div>

</body>
</html>