| Differences between
and this patch
- a/Source/WebCore/ChangeLog +21 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-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 NOBODY (OOPS!).
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
1
2016-09-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
22
2016-09-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
23
3
        Change the MemoryCache and CachedResource adjustSize functions to take a long argument
24
        Change the MemoryCache and CachedResource adjustSize functions to take a long argument
- a/Source/WebCore/html/HTMLAnchorElement.cpp -2 / +3 lines
Lines 44-49 a/Source/WebCore/html/HTMLAnchorElement.cpp_sec1
44
#include "ResourceRequest.h"
44
#include "ResourceRequest.h"
45
#include "RuntimeEnabledFeatures.h"
45
#include "RuntimeEnabledFeatures.h"
46
#include "SVGImage.h"
46
#include "SVGImage.h"
47
#include "ScriptController.h"
47
#include "SecurityOrigin.h"
48
#include "SecurityOrigin.h"
48
#include "SecurityPolicy.h"
49
#include "SecurityPolicy.h"
49
#include "Settings.h"
50
#include "Settings.h"
Lines 380-388 void HTMLAnchorElement::handleClick(Event& event) a/Source/WebCore/html/HTMLAnchorElement.cpp_sec2
380
        // If the a element has a download attribute and the algorithm is not triggered by user activation
381
        // If the a element has a download attribute and the algorithm is not triggered by user activation
381
        // then abort these steps.
382
        // then abort these steps.
382
        // https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
383
        // 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()) {
384
            // The specification says to throw an InvalidAccessError but other browsers do not.
385
            // 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.");
386
            return;
387
            return;
387
        }
388
        }
388
    }
389
    }
- a/LayoutTests/ChangeLog +13 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2016-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 NOBODY (OOPS!).
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
1
2016-09-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
14
2016-09-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
15
3
        Change the MemoryCache and CachedResource adjustSize functions to take a long argument
16
        Change the MemoryCache and CachedResource adjustSize functions to take a long argument
- a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt -1 / +1 lines
Lines 1-4 a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt_sec1
1
CONSOLE MESSAGE: line 22: Synthetic clicks on anchors that have a download attribute are ignored.
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.
2
Test that synthetic clicks on an anchor with a download attribute are ignored.
3
3
4
This test passes if you do not see any 'Download started' message above.
4
This test passes if you do not see any 'Download started' message above.
- a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt +8 lines
Line 0 a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click-expected.txt_sec1
1
Download started.
2
Downloading URL with suggested filename "unknown"
3
Download completed.
4
Test that user triggered synthetic clicks on an anchor with a download attribute are not ignored.
5
6
This test passes if you see a 'Download started' message above.
7
8
- a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html +46 lines
Line 0 a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script type='text/javascript'>
5
if (window.testRunner) {
6
  testRunner.dumpAsText();
7
  testRunner.waitUntilDone();
8
}
9
</script>
10
</head>
11
<body>
12
<p>Test that user triggered 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.</p>
14
<a style="display:none" id="blob-url" download>Blob URL</a>
15
<input type="button" id="testButton" value="Download">
16
<script>
17
function userClick(element)
18
{
19
    if (!window.eventSender) {
20
        alert('Click the button to run the test.');
21
        return;
22
    }
23
    eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
24
    eventSender.mouseDown();
25
    eventSender.mouseUp();
26
}
27
28
function runTest()
29
{
30
    var string = "test";
31
    var blob = new Blob([string], {type: "text/html"});
32
    var link = document.getElementById("blob-url");
33
    link.href = window.URL.createObjectURL(blob);
34
    var button = document.getElementById("testButton");
35
    button.onclick = function() {
36
        link.click();
37
    }
38
    userClick(button);
39
    setTimeout(function() {
40
        testRunner.notifyDone();
41
    }, 100);
42
}
43
runTest();
44
</script>
45
</body>
46
</html>

Return to Bug 162788