support promises on chrome namespace
Categories
(WebExtensions :: General, enhancement, P3)
Tracking
(firefox106 fixed)
Tracking | Status | |
---|---|---|
firefox106 | --- | fixed |
People
(Reporter: mixedpuppy, Assigned: mixedpuppy)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-needed, Whiteboard: mv3:m3 [mv3-m3] )
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
chrome namespace should support promises just like browser namespace
Comment 1•3 years ago
|
||
In content scripts, chrome === browser
: https://searchfox.org/mozilla-central/rev/0e8b28fb355afd2fcc69d34e8ed66bbabf59a59a/toolkit/components/extensions/ExtensionContent.jsm#878-879
So this issue could be addressed by having a similar implementation at https://searchfox.org/mozilla-central/rev/0e8b28fb355afd2fcc69d34e8ed66bbabf59a59a/toolkit/components/extensions/ExtensionPageChild.jsm#201-214 and simplifying the logic at https://searchfox.org/mozilla-central/rev/0e8b28fb355afd2fcc69d34e8ed66bbabf59a59a/toolkit/components/extensions/Schemas.jsm#2763-2787 (and adjusting unit tests accordingly).
Comment 2•3 years ago
|
||
We should not only check whether APIs return a Promise, but also check whether the behavior is consistent when a callback is used.
This unit test here is particularly interesting: https://searchfox.org/mozilla-central/rev/0e8b28fb355afd2fcc69d34e8ed66bbabf59a59a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html#55-68
- The comment + TODO can be removed since we now wish for
chrome.
to return a Promise. - The second part of the test verifies that the
chrome.runtime.sendMessage(msg, callback)
signature doesn't return anything. If we want to unconditionally return a Promise, then the test should be adjusted.
Updated•3 years ago
|
Comment 3•3 years ago
|
||
In part6 of bug 1688040, browser
and chrome
are aliases of each other, so if we move to that, this bug will be resolved almost for free (after fixing up tests like the one I mentioned before).
Assignee | ||
Comment 4•3 years ago
|
||
(In reply to Rob Wu [:robwu] from comment #2)
- The second part of the test verifies that the
chrome.runtime.sendMessage(msg, callback)
signature doesn't return anything. If we want to unconditionally return a Promise, then the test should be adjusted.
My understanding was that with chrome, if a callback is used, promises were not returned. I'm not sure it matters that much if we did unconditionally return a promise, in that case a chrome extension should still port to firefox just fine.
Comment 5•3 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #4)
(In reply to Rob Wu [:robwu] from comment #2)
- The second part of the test verifies that the
chrome.runtime.sendMessage(msg, callback)
signature doesn't return anything. If we want to unconditionally return a Promise, then the test should be adjusted.My understanding was that with chrome, if a callback is used, promises were not returned.
I just checked in Chromium 90; when a callback is passed, no promise is returned. This is consistent with how Firefox already behaves in the browser.
namespace. This only works in manifest v3, in manifest v2 promises are not supported.
I'm not sure it matters that much if we did unconditionally return a promise, in that case a chrome extension should still port to firefox just fine.
Whether to return a promise even if a callback is passed does matter, because it's an observable difference that can result in a difference in behavior.
Assignee | ||
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 6•2 years ago
|
||
Updated•2 years ago
|
Pushed by scaraveo@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/caff3cab943c allow promises with chrome namespace in mv3 r=robwu
Comment 8•2 years ago
|
||
bugherder |
Updated•1 year ago
|
Comment 9•1 year ago
|
||
The MDN documentation doesn't clearly express the difference between MV2 and MV3 in the level of promise support in the chrome
namespace.
See bug 1848346 for an example of the resulting confusion, and https://bugzilla.mozilla.org/show_bug.cgi?id=1848346#c4 for the explanation.
This should be documented at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities
Comment 10•1 year ago
|
||
See "promise support in Chrome clarification" #28643
Description
•