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)
Core
DOM: Core & HTML
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.
Comment 3•7 years ago
|
||
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)
Comment 4•7 years ago
|
||
"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.
Comment 5•7 years ago
|
||
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)
Comment 6•7 years ago
|
||
Here [1] is where we return NS_ERROR_FILE_NOT_FOUND, that's why in EndPageLoad() [2], we display the internal error page. [1] http://searchfox.org/mozilla-central/rev/2bcd258281da848311769281daf735601685de2d/uriloader/base/nsURILoader.cpp#554-565 [2] http://searchfox.org/mozilla-central/rev/2bcd258281da848311769281daf735601685de2d/docshell/base/nsDocShell.cpp#7741-7748
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.
Comment 8•7 years ago
|
||
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
Comment 9•7 years ago
|
||
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.
Comment 10•7 years ago
|
||
Or, perhaps we need a spec change. If there is an error, fire error event on the <a> element?
Comment 11•7 years ago
|
||
...and just don't download anything.
Updated•7 years ago
|
Priority: -- → P3
Comment 12•7 years ago
|
||
Filed https://github.com/whatwg/html/issues/2775.
Comment 13•3 years ago
|
||
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.
Description
•