Closed Bug 1660636 Opened 4 years ago Closed 4 years ago

download attribute HTMLAnchorElement not used for file name download

Categories

(Core :: DOM: File, defect, P3)

Firefox 81
defect

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox-esr68 --- unaffected
firefox-esr78 --- unaffected
firefox79 --- unaffected
firefox80 --- unaffected
firefox81 --- wontfix
firefox82 --- fixed

People

(Reporter: github.christian, Assigned: evilpie)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

Attached file index.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0

Steps to reproduce:

I try to save a text string in a txt file, using window.URL.createObjectURL , then passing the ObjectURL to an HTMLAnchorElement with the attribute download set to the desired file name ( see the attached index.html file )

Actual results:

With Firefox 79 everything is fine.
With Nightly 81.0a1 (2020-08-22) (64 bits), the code works also but the file name is '[object Object]'

Expected results:

The file name must be the name set in the download attribute of the HTMLAnchorElement.

Status: UNCONFIRMED → NEW
Has Regression Range: --- → yes
Has STR: --- → yes
Component: Untriaged → DOM: File
Ever confirmed: true
Keywords: regression
Product: Firefox → Core
Regressed by: 1619953

Baku, could you take a look at this?

Severity: -- → S2
Flags: needinfo?(amarchesini)
Priority: -- → P3

I guess the filename specified by the download attribute should be preferred over File.name ? We get this funny behavior because new File ( [ 'This is a sample of text file' ], { type : 'text/plain' } ) in the tescase is basically wrong. The second argument should be the filename.

Yes, I agree. The filename is missing in the parameters of the File constructor and when I add it, everything is fine.
But the filename is missing in my JS code since at least 3 years and this works without problems till this FF release 81. It's also working on browsers based on chrome (Brave, Vivaldi...).
I have added the filename in my JS code, so for me you can close, except, if you are expecting problems from others.

Severity: S2 → S3
See Also: → 1658877

I think I know a fix for this. Before https://hg.mozilla.org/integration/autoland/rev/67ea7d621ba6232179f9b8c1949ddcf03f429f33 we used to call SetContentDispositionFilename during channel creation. But now we call it later in BlobURLInputStream::StoreBlobImplStream, which probably overwrites the name set by nsDocShell::CreateAndConfigureRealChannelForLoadState.

I think we could just not overwrite an existing name.

Assignee: nobody → evilpies
Status: NEW → ASSIGNED
Flags: needinfo?(amarchesini)
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/2bfe670b275d
Use download attribute filename instead of File.name. r=baku
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: