Index: polyfill.js |
=================================================================== |
--- a/polyfill.js |
+++ b/polyfill.js |
@@ -38,16 +38,22 @@ |
"tabs.sendMessage", |
"tabs.update", |
"webNavigation.getAllFrames", |
"webRequest.handlerBehaviorChanged", |
"windows.create", |
"windows.update" |
]; |
+ // Errors that occur only when we show an interest in the response from an |
Manish Jethani
2017/10/19 10:13:23
We should keep this array because there are more s
kzar
2017/10/19 10:17:49
Maybe a Set would be a better data structure to us
Manish Jethani
2017/10/19 10:24:46
Regarding the error message itself, I should go ba
Manish Jethani
2017/10/19 10:30:32
Good point, done.
Sebastian Noack
2017/10/19 18:30:18
We can easily turn it into an array, set or regexp
kzar
2017/10/19 18:37:39
Yea I'm pretty sure we all agree there, if we can
Sebastian Noack
2017/10/19 22:08:31
Ollie just confirmed, that on Microsoft Edge no er
|
+ // API call. |
+ const noFulfillmentErrors = [ |
+ "The message port closed before a response was received." |
+ ]; |
+ |
function wrapAPI(api) |
{ |
let object = browser; |
let path = api.split("."); |
let name = path.pop(); |
for (let node of path) |
{ |
@@ -71,17 +77,17 @@ |
if (typeof args[args.length - 1] == "undefined") |
args.pop(); |
return new Promise((resolve, reject) => |
{ |
func.call(object, ...args, result => |
{ |
let error = browser.runtime.lastError; |
- if (error) |
+ if (error && !noFulfillmentErrors.includes(error.message)) |
reject(error); |
else |
resolve(result); |
}); |
}); |
}; |
} |