Changeset 209091 in webkit


Ignore:
Timestamp:
Nov 29, 2016 2:38:26 PM (7 years ago)
Author:
Chris Dumez
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:

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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r209082 r209091  
     12016-11-29  Chris Dumez  <cdumez@apple.com>
     2
     3        Can't download move.simple.com direct deposit transition PDF: Non user-triggered activations of anchors that have a download attribute are ignored
     4        https://bugs.webkit.org/show_bug.cgi?id=165148
     5        <rdar://problem/29421771>
     6
     7        Reviewed by Daniel Bates.
     8
     9        Update existing test to reflect behavior change.
     10
     11        * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt:
     12        * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html:
     13
    1142016-11-29  Eric Carlson  <eric.carlson@apple.com>
    215
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt

    r206659 r209091  
    1 CONSOLE MESSAGE: line 22: Non user-triggered activations of anchors that have a download attribute are ignored.
    2 Test that synthetic clicks on an anchor with a download attribute are ignored.
     1Download started.
     2Downloading URL with suggested filename "foo.pdf"
     3Download completed.
     4Test that synthetic clicks on an anchor with a download attribute are not ignored.
    35
    4 This test passes if you do not see any 'Download started' message above.
     6This test passes if you see a 'Download started' message above and if the suggested filename is foo.pdf.
    57
    68Blob URL
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html

    r206356 r209091  
    1010</head>
    1111<body>
    12 <p>Test that synthetic clicks on an anchor with a download attribute are ignored.</p>
    13 <p> This test passes if you do not see any 'Download started' message above.</p>
    14 <a id="blob-url" download>Blob URL</a>
     12<p>Test that synthetic clicks on an anchor with a download attribute are not ignored.</p>
     13<p> This test passes if you see a 'Download started' message above and if the suggested filename is foo.pdf.</p>
     14<a id="blob-url" download="foo.pdf">Blob URL</a>
    1515<script>
    1616function runTest()
  • trunk/Source/WebCore/ChangeLog

    r209088 r209091  
     12016-11-29  Chris Dumez  <cdumez@apple.com>
     2
     3        Can't download move.simple.com direct deposit transition PDF: Non user-triggered activations of anchors that have a download attribute are ignored
     4        https://bugs.webkit.org/show_bug.cgi?id=165148
     5        <rdar://problem/29421771>
     6
     7        Reviewed by Daniel Bates.
     8
     9        We were ignoring non user-triggered activations of anchors that have a
     10        download attribute which is stricter than Chrome and Firefox and breaks
     11        downloads on move.simple.com. This patch relaxes our policy to allow
     12        simulated clicks on such links, similarly to other browsers.
     13
     14        Web authors can anyway already trigger downloads using script by setting
     15        window.location to a specific URL and serving to right HTTP headers to
     16        trigger a download.
     17
     18        Note that our previous behavior matches the current version of the
     19        specification so I also filed a bug against the HTML specification to
     20        see if we can get it changed to match the behavior of browsers:
     21        - https://github.com/whatwg/html/issues/2116
     22
     23        No new tests, updated existing test.
     24
     25        * html/HTMLAnchorElement.cpp:
     26        (WebCore::HTMLAnchorElement::handleClick):
     27
    1282016-11-29  Andy Estes  <aestes@apple.com>
    229
  • trunk/Source/WebCore/html/HTMLAnchorElement.cpp

    r208985 r209091  
    384384        else if (hasAttributeWithoutSynchronization(downloadAttr))
    385385            document().addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "The download attribute on anchor was ignored because its href URL has a different security origin.");
    386         // If the a element has a download attribute and the algorithm is not triggered by user activation
    387         // then abort these steps.
    388         // https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
    389         if (!downloadAttribute.isNull() && !event.isTrusted() && !ScriptController::processingUserGesture()) {
    390             // The specification says to throw an InvalidAccessError but other browsers do not.
    391             document().addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "Non user-triggered activations of anchors that have a download attribute are ignored.");
    392             return;
    393         }
    394386    }
    395387#endif
Note: See TracChangeset for help on using the changeset viewer.