Bug 1287007 - Do not neuter error messages from the same principal draft
authorRob Wu <rob@robwu.nl>
Mon, 05 Sep 2016 17:04:28 -0700
changeset 428425 df56da06ad5af935c8c014ad1c4159cb19831d9a
parent 428424 380ffd2ca43754d6acbe29ed3c551657db9d8ea1
child 428426 3e1ff77c2b8dd907eed9f11c026ac84d408a2fb3
push id33305
push userbmo:rob@robwu.nl
push dateSun, 23 Oct 2016 20:56:25 +0000
bugs1287007
milestone52.0a1
Bug 1287007 - Do not neuter error messages from the same principal With an upcoming change that introduces another ProxyContext, errors from a different scope may bubble up. These messages should be reported, not replaced with "An unexpected error occurred". MozReview-Commit-ID: ByUktVkhDyx
toolkit/components/extensions/ExtensionUtils.jsm
--- a/toolkit/components/extensions/ExtensionUtils.jsm
+++ b/toolkit/components/extensions/ExtensionUtils.jsm
@@ -360,21 +360,27 @@ class BaseContext {
    *
    * @param {Error|object} error
    * @returns {Error}
    */
   normalizeError(error) {
     if (error instanceof this.cloneScope.Error) {
       return error;
     }
-    if (!instanceOf(error, "Object")) {
+    let message;
+    if (instanceOf(error, "Object")) {
+      message = error.message;
+    } else if (typeof error == "object" &&
+        this.principal.subsumes(Cu.getObjectPrincipal(error))) {
+      message = error.message;
+    } else {
       Cu.reportError(error);
-      error = {message: "An unexpected error occurred"};
     }
-    return new this.cloneScope.Error(error.message);
+    message = message || "An unexpected error occurred";
+    return new this.cloneScope.Error(message);
   }
 
   /**
    * Sets the value of `.lastError` to `error`, calls the given
    * callback, and reports an error if the value has not been checked
    * when the callback returns.
    *
    * @param {object} error An object with a `message` property. May