Inconsistency: chrome.downloads.open() return value
bershanskiy opened this issue · comments
Update: Firefox and Chromium 123+ now both return Promise<void>
, Safari does not support this API, but is willing to match.
Summary
Chromium treats chrome.downloads.open()
as a sync operation, while Firefox returns Promise<void>
.
Details
In Chromium, has the following signature (from docs, from source):
void chrome.downloads.open(downloadId: number)
In Firefox, it returns a Promise (from MDN):
Promise<void> browser.downloads.open(downloadId: number)
Safari does not support downloads
API, but is willing to use promise.
I believe that the function should return Promise<void>
since opening a file is inherently an async operation. Chromium handles it async (code), but the declaration is sync (code). It is sync only if there is an error which is known right away like lack of proper permissions or user activation.
(Updated Feb 15, 2024)
Safari does not currently support the downloads API. But I agree a promise makes sense here.
@patrickkettner Would you be interested in resolving this difference?
Thanks for opening https://chromium-review.googlesource.com/c/chromium/src/+/5274756 ! Checking the existing extension usage, the change seems safe. I pinged a reviewer to get the change merged.
The relevant change was merged (commit), Chromium 123+ will return Promise<void>
.
Since the inconsistency is resolved, I'm closing this issue.
We might want to change labels: remove "supportive: chrome" and add "implemented: chrome", "implemented: firefox", "implemented: edge".