Handle the browsers which don't support promises (eg. Edge)#43
Handle the browsers which don't support promises (eg. Edge)#43kai918 wants to merge 7 commits intomozilla:masterfrom
Conversation
|
What's up with this pull request? |
|
This change is dedicated to handling browsers (Edge) that offer a |
content scripts (JavaScript included with your extension, that you will inject into web pages)
| "use strict"; | ||
|
|
||
| if (typeof browser === "undefined") { | ||
| var _supportsPromises = false; |
| } | ||
|
|
||
| if (typeof browser === "undefined" || !_supportsPromises) { | ||
| var _browser = window.browser || window.msBrowser || window.chrome || browser; |
| return grunt.file.read(filename) | ||
| .replace(/\n$/, "") | ||
| .replace(/^[^{]/gm, " $&"); | ||
| return grunt.file.read(filename).replace(/\n$/, "").replace(/^[^{]/gm, " $&"); |
| .nyc_output/ | ||
| /.project | ||
| /dist/ | ||
| /node_modules/ |
| console.log("promises not supported."); | ||
| } | ||
|
|
||
| if (typeof browser === "undefined" || !_supportsPromises) { |
There was a problem hiding this comment.
A better option would be to change this line to:
if (typeof browser === "undefined" || !(() => {
let supportsPromises = false;
try {
supportsPromises = browser.runtime.getPlatformInfo() instanceof Promise;
} catch (e) {
console.log("promises not supported.");
}
return supportsPromises;
})()) {And remove the previous block.
|
Closing in favor of #114 (which is still exploring how we may allow the polyfill to work on Edge, and it is also taking advantage of the recently added integration tests to ensure that the additional changes needed are not going to break the polyfill behaviors expected on Chrome and Firefox). |
Compatibility with environments that have the browser namespace but do not support promises.
I was inspired by Snoak's answer in the following issue: #3