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 |
+ // API call. |
+ const noFulfillmentErrors = new Set([ |
+ "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.has(error.message)) |
reject(error); |
else |
resolve(result); |
}); |
}); |
}; |
} |