Closed Bug 2017252 Opened 5 months ago Closed 2 months ago

Override download target folder with "browser.setDownloadBehavior" before temporary download file is created

Categories

(Remote Protocol :: WebDriver BiDi, task, P2)

task
Points:
3

Tracking

(firefox152 fixed)

RESOLVED FIXED
152 Branch
Tracking Status
firefox152 --- fixed

People

(Reporter: Sasha, Assigned: Sasha)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [webdriver:m20][webdriver:relnote])

Attachments

(3 files)

The implementation of browser.setDownloadBehavior on the bug 1989022 introduces a workaround to update the target folder for a download when the download is already started; as a consequence, this requires cleaning up all the partial data downloaded at that time.
Unfortunately, introducing an earlier hook at the JS level wouldn't be sufficient here because at the time the download is created in the JS layer (which is only serializing the platform data to a JS object), there is already a temporary file created.
So it looks like to really avoid the cleanup, we have to interfere much earlier in the platform layer. One idea could be to attach an override download folder to a browsing context object and access it when the decision about the download target folder has to be made (somewhere around here).

One of the limitations of the workaround is:
If you try to download file.txt and the "default" download folder already has a file with the same name, it will be downloaded to the new folder as file(1).txt, and subsequent downloads will then be called file(1)(1).txt, file(1)(2).txt, etc... Because the download logic already modified the filename by using DownloadPaths.createNiceUniqueFile.

Another limitation of the workaround is that the temporary file won't get cleaned up if the browser dies, so this Playwright test leaves file.txt in the user's Downloads folder (and subsequent tests trying to download file.txt will receive file(1).txt).

Priority: -- → P3
Whiteboard: [webdriver:m20]

Let's rereview the priority when we do the planning for M20.

Points: --- → 3
Priority: P3 → P2
Assignee: nobody → aborovova
Status: NEW → ASSIGNED
Blocks: 2034853
Pushed by aborovova@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/5643304a44b4 https://hg.mozilla.org/integration/autoland/rev/b84a84bbee6c Add "DownloadFolderOverride" field to BrowsingContext to override the default download folder per browsing context. r=dom-core,smaug https://github.com/mozilla-firefox/firefox/commit/4edba5c3dcf9 https://hg.mozilla.org/integration/autoland/rev/1c0fd54c623c [webdriver-bidi] Improve identification of global configuration. r=whimboo https://github.com/mozilla-firefox/firefox/commit/3853d1a7ce7e https://hg.mozilla.org/integration/autoland/rev/297d38e1c9be [webdriver-bidi] Use "downloadFolderOverride" property of BrowsingContext to set "destinationFolder" with "browser.setDownloadBehavior". r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch
Regressions: 2036774
Whiteboard: [webdriver:m20] → [webdriver:m20][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: