You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 30, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 30, 2026. It is now read-only.
Compatibility with environments that have the browser namespace but don't support promises #3
This polyfill seems to be incompatible with Microsoft Edge, which doesn't support promises yet, but is using the browser instead of the chrome namespace.
Reacted by Noitidart, Val Packett, bencergazda, Perry Naseck, Kuba Niewiarowski, Pixievolt No. 1, Becca Royal-Gordon, fregante, ExE Boss, Constantine and 6 more
changed the title [-]Compatibility with environments that have the `browser` namespace but don't support promises[/-][+]Compatibility with environments that have the `browser` namespace but don't support promises (i.e. Microsoft Edge)[/+]on Oct 21, 2016
changed the title [-]Compatibility with environments that have the `browser` namespace but don't support promises (i.e. Microsoft Edge)[/-][+]Compatibility with environments that have the `browser` namespace but don't support promises[/+]on Oct 21, 2016
Well, I presume it will still take a while until Microsoft Edge will support promises, and when it does extension developers might not be able to drop support for older versions of Microsoft Edge right away. Also what if Chrome (or a new platform) will start to provide the browser namespace but doesn't support promises in the same step.
As for detecting the promise-based API, the best idea I have is just calling any asynchronous function and check whether it throws an exception (because a callback is expected) or whether a promise is returned.
Thank you for providing this information about the issue. A Microsoft Edge Extension does not support the Promise model; this is a documented difference between Mozilla and Edge’s platform. Currently, we do not plan to release a fix. Please update this case if you can provide new information for us to consider.
Considering Microsoft's track record of not following standards and their somewhat recent desire to not be like that anymore, it's really weird that they're so dismissive about this…
I guess supporting this in the polyfill would be the only solution for now :(
Reacted by fregante, Marcin Rataj, ExE Boss, Jordan Miner, NN and Collin Sauve
/* USAGE - sync apis */
extension.browserAction.onClicked.addListener(handleClick);
extension.tabs.create({ url:'blah' }); // if dont care about return
extension.browserAction.setTitle({ title:'rawr' })
/* USAGE - async/callback based api's are as promise */
async function() {
const info = await extensiona('runtime.getPlatformInfo');
const tabInfo = await extensiona('tabs.create', { url:'blah' });
const download = await extensiona('downloads.download', { filename:`filename.here`, url:`www.bing.com/blah` });
const winId = await extensiona('windows.update', windowid, { focused:true });
}
The only issue i see is in extensiona (the promise version), using deepAccessUsingString might disconnect the api call from the the this. I haven't had issues with it yet though.
To use this, just do extension.** instead of browser.* or chrome.*. If you want callback version.
Edge is also funky in that they have window.chrome, so that's a not good enough test, that's why I test window.chrome.runtime above to see if chrome trunk exists.
What a sad state of affairs. It looks like Chrome doesn't care about Mozilla's WebExtensions standardization effort and Edge just (barely) follows whatever Chrome does. On top of that, Chrome's original API is pretty ridiculous to begin with.
At this point I wish mozilla came up with a sound API and polyfilled that.
Reacted by Val Packett, i-give-up, Franklin Yu, Linus Unnebäck, ExE Boss and NN
Any ideas when this will be completed? I've seen multiple proposed pull requests and they always get shot down for some reason or another. It seems like a lot of "paralysis by over-analysis". It's been almost 2 years. Please implement something, even if it's temporary and not your ideal solution.
I think we Edge users would be happy enough if Edge is supported on a best-effort basis. We don’t need any guarantee about non-breaking release because we understand the difficulty.
Soon Edge will use Chromium inside so it's reasonable to expect Edge will have the classic chrome API for extensions, which would solve the polyfill compatibility problem too.
TBH Microsoft announced that too early. Now nobody would develop against the classic MS Edge no matter when the new Edge come out. This is not the only project; there is also some discussion at EFForg/https-everywhere#5101.
I already do the same using Webpack and currently don't need any Edge specific features.
Just added window.chrome=window.browser prior running any extension code.
Anyway thanks for the sample, maybe I find it useful in the future.
Activity
[-]Compatibility with environments that have the `browser` namespace but don't support promises[/-][+]Compatibility with environments that have the `browser` namespace but don't support promises (i.e. Microsoft Edge)[/+][-]Compatibility with environments that have the `browser` namespace but don't support promises (i.e. Microsoft Edge)[/-][+]Compatibility with environments that have the `browser` namespace but don't support promises[/+]kmaglione commentedon Nov 6, 2016
Edge is planning to add promise support, but yes, I've been thinking about ways to detect this and add support where it's not available.
snoack commentedon Nov 9, 2016
Well, I presume it will still take a while until Microsoft Edge will support promises, and when it does extension developers might not be able to drop support for older versions of Microsoft Edge right away. Also what if Chrome (or a new platform) will start to provide the
browsernamespace but doesn't support promises in the same step.As for detecting the promise-based API, the best idea I have is just calling any asynchronous function and check whether it throws an exception (because a callback is expected) or whether a promise is returned.
DaAwesomeP commentedon Apr 16, 2017
Here's the issue on the Microsoft end: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9421085/. Maybe they'll post an update if a decent amount of people click the "Me too" button.
valpackett commentedon Apr 22, 2017
:(
DaAwesomeP commentedon Apr 26, 2017
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9421085/
valpackett commentedon Apr 30, 2017
Considering Microsoft's track record of not following standards and their somewhat recent desire to not be like that anymore, it's really weird that they're so dismissive about this…
I guess supporting this in the polyfill would be the only solution for now :(
Noitidart commentedon Apr 30, 2017
Ideally I would like to use this polyfill but due to edge I was using this really short polyfill and it was working well:
@constfun I find this works for me across all browsers including edge:
Usage example:
The only issue i see is in
extensiona(the promise version), usingdeepAccessUsingStringmight disconnect the api call from the thethis. I haven't had issues with it yet though.To use this, just do
extension.**instead ofbrowser.*orchrome.*. If you want callback version.Edge is also funky in that they have
window.chrome, so that's a not good enough test, that's why I testwindow.chrome.runtimeabove to see ifchrometrunk exists.fregante commentedon Aug 20, 2017
What a sad state of affairs. It looks like Chrome doesn't care about Mozilla's WebExtensions standardization effort and Edge just (barely) follows whatever Chrome does. On top of that, Chrome's original API is pretty ridiculous to begin with.
At this point I wish mozilla came up with a sound API and polyfilled that.
valpackett commentedon Aug 20, 2017
@bfred-it uhh this repo is exactly the polyfill :)
fregante commentedon Aug 20, 2017
Yeah but mozilla's API still looks like
browser.runtime.onBrowserUpdateAvailable.addListener(fn)It could have looked more like a familiar
browser.runtime.on('BrowserUpdateAvailable', fn)valpackett commentedon Aug 20, 2017
that's pretty minor compared to using promises instead of callbacks
5 remaining items
NN--- commentedon Jun 17, 2018
@Rob--W Any estimations for including this functionality in webextension-polyfill ?
ExE-Boss commentedon Jun 17, 2018
@NN--- I’ve been working on a fix in #114.
vozeldr commentedon Aug 20, 2018
Any ideas when this will be completed? I've seen multiple proposed pull requests and they always get shot down for some reason or another. It seems like a lot of "paralysis by over-analysis". It's been almost 2 years. Please implement something, even if it's temporary and not your ideal solution.
Rob--W commentedon Aug 20, 2018
One of the big blockers is the ability to load an extension in Edge for automated testing (locally and on continuous integration, e.g. on AppVeyor).
If someone spends time on researching that, then I am willing to make the desired changes to the polyfill to support Edge.
mjethani commentedon Sep 22, 2018
In Adblock Plus we have written our own polyfill to wrap the async APIs on Chrome and Edge. It works for us.
dessant commentedon Sep 22, 2018
@Rob--W. the lack of automated testing isn't necessarily a blocker for releasing this feature.
FranklinYu commentedon Sep 22, 2018
@Rob--W Sadly AppVeyor won’t support Microsoft Edge testing. All tests on AppVeyor run on Windows Server 2012/2016, but MS Edge doesn’t support Windows Server at all. So far the only option that I know is BrowserStack, which has free plan for open-source projects, but I guess it would take some time to set up Selenium.
I think we Edge users would be happy enough if Edge is supported on a best-effort basis. We don’t need any guarantee about non-breaking release because we understand the difficulty.
tophf commentedon Dec 11, 2018
Soon Edge will use Chromium inside so it's reasonable to expect Edge will have the classic chrome API for extensions, which would solve the polyfill compatibility problem too.
NN--- commentedon Dec 11, 2018
There are many companies using Edge right now.
It will take time for MS to release a Chromium based version and more time for companies to upgrade.
FranklinYu commentedon Dec 11, 2018
TBH Microsoft announced that too early. Now nobody would develop against the classic MS Edge no matter when the new Edge come out. This is not the only project; there is also some discussion at EFForg/https-everywhere#5101.
NN--- commentedon Dec 11, 2018
Unfortunately, I do have to develop for current Edge.:(
rpl commentedon Jan 7, 2019
Closing as wontfix. See #114 (comment) for a rationale.
@NN--- @vozeldr you may give a try to the alternative approach described in the above comment (and in the example-msedge-extension-with-webextension-polyfill github repo).
NN--- commentedon Jan 7, 2019
I already do the same using Webpack and currently don't need any Edge specific features.
Just added window.chrome=window.browser prior running any extension code.
Anyway thanks for the sample, maybe I find it useful in the future.