Closed Bug 1373620 Opened 7 years ago Closed 3 years ago

<a href="leading-to-error-404" download> navigates

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: phistuck, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36

Steps to reproduce:

Go to http://w3c-test.org/submissions/6211/html/semantics/text-level-semantics/the-a-element/a-download-click-404.html


Actual results:

Fails


Expected results:

Succeeds

Basically, I would never expect <a href="leading-to-error-404" download> to navigate.
But if leading-to-error-404 return HTTP status code 404 and its content type is text/html, Firefox navigates to an internal error page.

The other browsers download (and either fail, or download the 404 response).
Note - not only does it navigate, it navigates to an internal error page even if the server returns a real HTML error response.
Sec. 4.6.5 Downloading resources[1] says "When a user agent is to handle a resource obtained from a fetch as a download, it should provide the user with a way to save the resource for later use, if a resource is successfully obtained; or otherwise should report any problems downloading the file to the user."

According to this, the current firefox behaviour seems do nothing wrong. Did I miss anything?


[1] https://html.spec.whatwg.org/#downloading-resources
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jjong)
"report any problems" is different from "navigate to an error page". The spec currently allows navigating to an error page if the URL fails to parse.
Well, "report any problems" is a little vague. In Safari and Chrome, the file is still downloaded without any warning to the user, although in Chrome the file says: "Failed - No file".

I agree that "report any problems" is different from "navigate to an error page", but what is the expected behavior? I mean, how should the error be reported and should the file still be downloaded?
Flags: needinfo?(jjong)
I think navigation can cause user data loss in a case that website did not intend to handle because it never expected a navigation (it expected a download). The way to report is up to you (and I agree that the Chrome way is unclear) and is a user interface issue.
I actually prefer the Safari way of downloading regardless of error. While it might be unintended, it might also be intended. The web developer has elected to make it a download operation. If that does not work as well as they intended, they will need to fix that.
I don't disagree that the spec can be clearer about expected behavior. Can you file an issue, please? https://github.com/whatwg/html/issues/new
Safari and Chrome behavior sounds horrible, but not sure Gecko behavior is much better.
What kind of error do we normally show if download fails? Though, this is a bit different since the
download never really begins.
I guess we need some UI folks here to say what to do.
Or, perhaps we need a spec change. If there is an error, fire error event on the <a> element?
...and just don't download anything.
Priority: -- → P3

Firefox is no longer navigating so closing this. Specification issue still seems reasonable to address at some point though.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.