Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency: chrome.downloads.open() return value #528

Closed
bershanskiy opened this issue Jan 23, 2024 · 6 comments
Closed

Inconsistency: chrome.downloads.open() return value #528

bershanskiy opened this issue Jan 23, 2024 · 6 comments
Labels
inconsistency Inconsistent behavior across browsers supportive: chrome Supportive from Chrome supportive: safari Supportive from Safari

Comments

@bershanskiy
Copy link
Member

bershanskiy commented Jan 23, 2024

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>.

Chromium bug

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)

@xeenon
Copy link
Collaborator

xeenon commented Jan 23, 2024

Safari does not currently support the downloads API. But I agree a promise makes sense here.

@xeenon xeenon added inconsistency Inconsistent behavior across browsers supportive: safari Supportive from Safari and removed needs-triage labels Jan 23, 2024
@bershanskiy
Copy link
Member Author

@patrickkettner Would you be interested in resolving this difference?

@patrickkettner
Copy link
Contributor

patrickkettner commented Feb 10, 2024 via email

@patrickkettner patrickkettner added the supportive: chrome Supportive from Chrome label Feb 12, 2024
@patrickkettner
Copy link
Contributor

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.

@bershanskiy
Copy link
Member Author

The relevant change was merged (commit), Chromium 123+ will return Promise<void>.

@bershanskiy
Copy link
Member Author

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inconsistency Inconsistent behavior across browsers supportive: chrome Supportive from Chrome supportive: safari Supportive from Safari
Projects
None yet
Development

No branches or pull requests

3 participants