mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1280347 - Normalize local ExtensionErrors r=mixedpuppy
Normalize errors thrown by extension API implementations in content processes to ensure that extension code can read the error message if the error is an instance of ExtensionUtils.ExtensionError. This code path is triggered in browser_ext_menus_replace.js and browser_ext_menus_replace_menu_permissions.js. Depends on D6625 Differential Revision: https://phabricator.services.mozilla.com/D6626 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
444c304d8b
commit
a69fd162a2
@ -939,11 +939,19 @@ class LocalAPIImplementation extends SchemaAPIInterface {
|
||||
}
|
||||
|
||||
callFunction(args) {
|
||||
return this.pathObj[this.name](...args);
|
||||
try {
|
||||
return this.pathObj[this.name](...args);
|
||||
} catch (e) {
|
||||
throw this.context.normalizeError(e);
|
||||
}
|
||||
}
|
||||
|
||||
callFunctionNoReturn(args) {
|
||||
this.pathObj[this.name](...args);
|
||||
try {
|
||||
this.pathObj[this.name](...args);
|
||||
} catch (e) {
|
||||
throw this.context.normalizeError(e);
|
||||
}
|
||||
}
|
||||
|
||||
callAsyncFunction(args, callback, requireUserInput) {
|
||||
|
@ -19,6 +19,11 @@
|
||||
* True if the error matches the expected error.
|
||||
*/
|
||||
const errorMatches = (error, expectedError, context) => {
|
||||
if (typeof error === "object" && error !== null &&
|
||||
!context.principal.subsumes(Cu.getObjectPrincipal(error))) {
|
||||
Cu.reportError("Error object belongs to the wrong scope.");
|
||||
return false;
|
||||
}
|
||||
if (expectedError === null) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user