Changeset 206659 in webkit


Ignore:
Timestamp:
Sep 30, 2016, 1:08:27 PM (9 years ago)
Author:
Chris Dumez
Message:

FileSaver.js does not work in WebKit
https://bugs.webkit.org/show_bug.cgi?id=162788

Reviewed by Sam Weinig.

Source/WebCore:

FileSaver.js does not work in WebKit:

It works in Firefox and Chrome, but in WebKit, we were getting a
"Synthetic clicks on anchors that have a download attribute are
ignored." warning. We were too strict in restricting synthetic clicks.
We now allow synthetic clicks as long as they are triggered by a user
gesture.

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

  • html/HTMLAnchorElement.cpp:

(WebCore::HTMLAnchorElement::handleClick):

LayoutTests:

Add layout test coverage.

  • fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt:
  • fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt: Added.
  • fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206657 r206659  
     12016-09-30  Chris Dumez  <cdumez@apple.com>
     2
     3        FileSaver.js does not work in WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=162788
     5
     6        Reviewed by Sam Weinig.
     7
     8        Add layout test coverage.
     9
     10        * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt:
     11        * fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt: Added.
     12        * fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html: Added.
     13
    1142016-09-30  Ryan Haddad  <ryanhaddad@apple.com>
    215
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt

    r206562 r206659  
    1 CONSOLE MESSAGE: line 22: Synthetic clicks on anchors that have a download attribute are ignored.
     1CONSOLE MESSAGE: line 22: Non user-triggered activations of anchors that have a download attribute are ignored.
    22Test that synthetic clicks on an anchor with a download attribute are ignored.
    33
  • trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations

    r206657 r206659  
    13151315# <a download> is not supported in WK1 yet.
    13161316webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
     1317webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
    13171318webkit.org/b/156069 http/tests/download/area-download.html [ Skip ]
    13181319webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
  • trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations

    r206630 r206659  
    18081808webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Skip ]
    18091809webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-nodownload.html [ Skip ]
     1810webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
     1811webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
    18101812webkit.org/b/156067 http/tests/download/area-download.html [ Skip ]
    18111813webkit.org/b/156067 http/tests/security/anchor-download-allow-blob.html [ Skip ]
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r206656 r206659  
    192192webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download.html [ Failure ]
    193193webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
     194webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
    194195webkit.org/b/156069 http/tests/download/area-download.html [ Skip ]
    195196webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r206630 r206659  
    443443fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Skip ]
    444444fast/dom/HTMLAnchorElement/anchor-download-unset.html [ Skip ]
     445fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
     446fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
    445447http/tests/download/area-download.html [ Skip ]
    446448http/tests/security/anchor-download-allow-data.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r206653 r206659  
     12016-09-30  Chris Dumez  <cdumez@apple.com>
     2
     3        FileSaver.js does not work in WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=162788
     5
     6        Reviewed by Sam Weinig.
     7
     8        FileSaver.js does not work in WebKit:
     9        - https://eligrey.com/demos/FileSaver.js/
     10
     11        It works in Firefox and Chrome, but in WebKit, we were getting a
     12        "Synthetic clicks on anchors that have a download attribute are
     13        ignored." warning. We were too strict in restricting synthetic clicks.
     14        We now allow synthetic clicks as long as they are triggered by a user
     15        gesture.
     16
     17        Test: fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html
     18
     19        * html/HTMLAnchorElement.cpp:
     20        (WebCore::HTMLAnchorElement::handleClick):
     21
    1222016-09-30  Joseph Pecoraro  <pecoraro@apple.com>
    223
  • trunk/Source/WebCore/html/HTMLAnchorElement.cpp

    r206616 r206659  
    4545#include "RuntimeEnabledFeatures.h"
    4646#include "SVGImage.h"
     47#include "ScriptController.h"
    4748#include "SecurityOrigin.h"
    4849#include "SecurityPolicy.h"
     
    381382        // then abort these steps.
    382383        // https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
    383         if (!downloadAttribute.isNull() && !event.isTrusted()) {
     384        if (!downloadAttribute.isNull() && !event.isTrusted() && !ScriptController::processingUserGesture()) {
    384385            // The specification says to throw an InvalidAccessError but other browsers do not.
    385             document().addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "Synthetic clicks on anchors that have a download attribute are ignored.");
     386            document().addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "Non user-triggered activations of anchors that have a download attribute are ignored.");
    386387            return;
    387388        }
Note: See TracChangeset for help on using the changeset viewer.