Index: polyfill.js |
=================================================================== |
--- a/polyfill.js |
+++ b/polyfill.js |
@@ -120,24 +120,40 @@ |
{ |
} |
return true; |
} |
if (shouldWrapAPIs()) |
{ |
- // Unlike Firefox and Microsoft Edge, Chrome doesn't have a "browser" object, |
- // but provides the extension API through the "chrome" namespace |
+ // Unlike Firefox and Microsoft Edge, Chrome doesn't have a "browser" |
Manish Jethani
2017/10/23 02:32:45
Unrelated, but there's an ESLint error here becaus
|
+ // object, but provides the extension API through the "chrome" namespace |
// (non-standard). |
if (typeof browser == "undefined") |
window.browser = chrome; |
for (let api of asyncAPIs) |
wrapAPI(api); |
+ |
+ let {addListener} = browser.runtime.onMessage; |
+ browser.runtime.onMessage.addListener = function(listener) |
+ { |
+ addListener.call(browser.runtime.onMessage, ( |
+ message, sender, sendResponse |
+ ) => |
+ { |
+ let wait = listener(message, sender, sendResponse); |
+ |
+ if (wait instanceof Promise) |
Manish Jethani
2017/10/23 02:32:45
There's no need to add a catch handler, Chrome (an
Wladimir Palant
2017/10/23 08:53:26
Not really, the message clearly says that not hand
Manish Jethani
2017/10/23 12:21:04
Did you mean that Chrome will no longer do this au
|
+ wait.then(sendResponse); |
+ |
+ return !!wait; |
+ }); |
+ }; |
Wladimir Palant
2017/10/23 08:53:26
You have a problem here, removeListener will no lo
Manish Jethani
2017/10/23 12:21:04
Done.
|
} |
// Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList |
// didn't have iterator support before Chrome 51. |
// https://bugs.chromium.org/p/chromium/issues/detail?id=401699 |
for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) |
{ |
if (!(Symbol.iterator in object.prototype)) |