Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Issues with file downloads using webkit-1423 #5396

Closed
jevgenijusmarinuskinas opened this issue Feb 10, 2021 · 5 comments · Fixed by #5538
Closed

[Question] Issues with file downloads using webkit-1423 #5396

jevgenijusmarinuskinas opened this issue Feb 10, 2021 · 5 comments · Fixed by #5538
Assignees

Comments

@jevgenijusmarinuskinas
Copy link

jevgenijusmarinuskinas commented Feb 10, 2021

Hello,

I've came across an issue with Webkit. I am unable to get any kind of file download - it is just getting opened in the browser window itself. The same applies to ZIP, PDF, JSON, etc.

Question: Is there any way to force Webkit to download a file? Using the html download attribute does not help. With Firefox and Chrome it is working just fine.

image

My own simple HTML, which is not working:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Download example page</title>
</head>
<body>
    <h1>File download example</h1>
    </br>
    <a href="files/example.zip" id="downloadLink" download="example.zip">example.zip</a>
</body>
</html>


@pavelfeldman
Copy link
Member

Could you confirm that it does not works in headless mode too?

@jevgenijusmarinuskinas
Copy link
Author

jevgenijusmarinuskinas commented Feb 10, 2021

It does not, and in headless I am getting this error: WAR The download attribute on anchor was ignored because its href URL has a different security origin.

For Chrome and Firefox, the test is passing and file is downloaded. As I've mentioned, I am just executing the test against my local machine, with

page.goto(file:///${localPath}/example/examplePages/download.html)

And then downloading the file

aslushnikov added a commit to aslushnikov/playwright that referenced this issue Feb 16, 2021
aslushnikov added a commit that referenced this issue Feb 16, 2021
@aslushnikov aslushnikov self-assigned this Feb 19, 2021
aslushnikov added a commit to aslushnikov/playwright that referenced this issue Feb 20, 2021
aslushnikov added a commit to aslushnikov/playwright that referenced this issue Feb 20, 2021
aslushnikov added a commit to aslushnikov/playwright that referenced this issue Feb 20, 2021
@aslushnikov
Copy link
Collaborator

@jevgenijusmarinuskinas So this is a twofold issue:

  1. different file URLs are considered different in Safari/WebKit. So this is why you get this The download attribute on anchor was ignored because its href URL has a different security origin. error. in order to avoid this, you'll have to setup a simple web server for testing.
  2. On mac, headful webkit indeed did not download files marked with download attribute. This is fixed on tip-of-tree and will be released in v1.9.0

@jevgenijusmarinuskinas
Copy link
Author

@jevgenijusmarinuskinas So this is a twofold issue:

  1. different file URLs are considered different in Safari/WebKit. So this is why you get this The download attribute on anchor was ignored because its href URL has a different security origin. error. in order to avoid this, you'll have to setup a simple web server for testing.

@aslushnikov Does this mean, that on webkit we would be unable to use local file:/// like in Chrome and Firefox?

@aslushnikov
Copy link
Collaborator

@jevgenijusmarinuskinas yeah, that's how safari works 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants