Title: [209091] trunk
Revision
209091
Author
[email protected]
Date
2016-11-29 14:38:26 -0800 (Tue, 29 Nov 2016)

Log Message

Can't download move.simple.com direct deposit transition PDF: Non user-triggered activations of anchors that have a download attribute are ignored
https://bugs.webkit.org/show_bug.cgi?id=165148
<rdar://problem/29421771>

Reviewed by Daniel Bates.

Source/WebCore:

We were ignoring non user-triggered activations of anchors that have a
download attribute which is stricter than Chrome and Firefox and breaks
downloads on move.simple.com. This patch relaxes our policy to allow
simulated clicks on such links, similarly to other browsers.

Web authors can anyway already trigger downloads using script by setting
window.location to a specific URL and serving to right HTTP headers to
trigger a download.

Note that our previous behavior matches the current version of the
specification so I also filed a bug against the HTML specification to
see if we can get it changed to match the behavior of browsers:
- https://github.com/whatwg/html/issues/2116

No new tests, updated existing test.

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

LayoutTests:

Update existing test to reflect behavior change.

* fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt:
* fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209090 => 209091)


--- trunk/LayoutTests/ChangeLog	2016-11-29 22:15:52 UTC (rev 209090)
+++ trunk/LayoutTests/ChangeLog	2016-11-29 22:38:26 UTC (rev 209091)
@@ -1,3 +1,16 @@
+2016-11-29  Chris Dumez  <[email protected]>
+
+        Can't download move.simple.com direct deposit transition PDF: Non user-triggered activations of anchors that have a download attribute are ignored
+        https://bugs.webkit.org/show_bug.cgi?id=165148
+        <rdar://problem/29421771>
+
+        Reviewed by Daniel Bates.
+
+        Update existing test to reflect behavior change.
+
+        * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt:
+        * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html:
+
 2016-11-29  Eric Carlson  <[email protected]>
 
         [MediaStream] Don't request user permission for a device if it has already been granted in the current browsing context

Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt (209090 => 209091)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt	2016-11-29 22:15:52 UTC (rev 209090)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt	2016-11-29 22:38:26 UTC (rev 209091)
@@ -1,6 +1,8 @@
-CONSOLE MESSAGE: line 22: Non user-triggered activations of anchors that have a download attribute are ignored.
-Test that synthetic clicks on an anchor with a download attribute are ignored.
+Download started.
+Downloading URL with suggested filename "foo.pdf"
+Download completed.
+Test that synthetic clicks on an anchor with a download attribute are not ignored.
 
-This test passes if you do not see any 'Download started' message above.
+This test passes if you see a 'Download started' message above and if the suggested filename is foo.pdf.
 
 Blob URL

Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html (209090 => 209091)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html	2016-11-29 22:15:52 UTC (rev 209090)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html	2016-11-29 22:38:26 UTC (rev 209091)
@@ -9,9 +9,9 @@
 </script>
 </head>
 <body>
-<p>Test that synthetic clicks on an anchor with a download attribute are ignored.</p>
-<p> This test passes if you do not see any 'Download started' message above.</p>
-<a id="blob-url" download>Blob URL</a>
+<p>Test that synthetic clicks on an anchor with a download attribute are not ignored.</p>
+<p> This test passes if you see a 'Download started' message above and if the suggested filename is foo.pdf.</p>
+<a id="blob-url" download="foo.pdf">Blob URL</a>
 <script>
 function runTest()
 {

Modified: trunk/Source/WebCore/ChangeLog (209090 => 209091)


--- trunk/Source/WebCore/ChangeLog	2016-11-29 22:15:52 UTC (rev 209090)
+++ trunk/Source/WebCore/ChangeLog	2016-11-29 22:38:26 UTC (rev 209091)
@@ -1,3 +1,30 @@
+2016-11-29  Chris Dumez  <[email protected]>
+
+        Can't download move.simple.com direct deposit transition PDF: Non user-triggered activations of anchors that have a download attribute are ignored
+        https://bugs.webkit.org/show_bug.cgi?id=165148
+        <rdar://problem/29421771>
+
+        Reviewed by Daniel Bates.
+
+        We were ignoring non user-triggered activations of anchors that have a
+        download attribute which is stricter than Chrome and Firefox and breaks
+        downloads on move.simple.com. This patch relaxes our policy to allow
+        simulated clicks on such links, similarly to other browsers.
+
+        Web authors can anyway already trigger downloads using script by setting
+        window.location to a specific URL and serving to right HTTP headers to
+        trigger a download.
+
+        Note that our previous behavior matches the current version of the
+        specification so I also filed a bug against the HTML specification to
+        see if we can get it changed to match the behavior of browsers:
+        - https://github.com/whatwg/html/issues/2116
+
+        No new tests, updated existing test.
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::handleClick):
+
 2016-11-29  Andy Estes  <[email protected]>
 
         [Cocoa] Enable two clang warnings recommended by Xcode

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (209090 => 209091)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2016-11-29 22:15:52 UTC (rev 209090)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2016-11-29 22:38:26 UTC (rev 209091)
@@ -383,14 +383,6 @@
             downloadAttribute = attributeWithoutSynchronization(downloadAttr);
         else if (hasAttributeWithoutSynchronization(downloadAttr))
             document().addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "The download attribute on anchor was ignored because its href URL has a different security origin.");
-        // If the a element has a download attribute and the algorithm is not triggered by user activation
-        // then abort these steps.
-        // https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
-        if (!downloadAttribute.isNull() && !event.isTrusted() && !ScriptController::processingUserGesture()) {
-            // The specification says to throw an InvalidAccessError but other browsers do not.
-            document().addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "Non user-triggered activations of anchors that have a download attribute are ignored.");
-            return;
-        }
     }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to