Bug 1076967: fix Error object data propagation to Loop content pages. r=bholley a=lmandel
authorMike de Boer <mdeboer@mozilla.com>
Tue, 14 Oct 2014 12:14:09 +0200
changeset 225731 880cfb4ef6f8
parent 225730 ada526904539
child 225732 5ad9f4e96214
push id3995
push userrjesup@wgate.com
push date2014-10-20 00:58 +0000
treeherdermozilla-beta@8c42ccaf8aa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, lmandel
bugs1076967
milestone34.0
Bug 1076967: fix Error object data propagation to Loop content pages. r=bholley a=lmandel
browser/components/loop/MozLoopAPI.jsm
--- a/browser/components/loop/MozLoopAPI.jsm
+++ b/browser/components/loop/MozLoopAPI.jsm
@@ -38,17 +38,27 @@ this.EXPORTED_SYMBOLS = ["injectLoopAPI"
  * object.
  *
  * @param {Error}        error        Error object to copy
  * @param {nsIDOMWindow} targetWindow The content window to attach the API
  */
 const cloneErrorObject = function(error, targetWindow) {
   let obj = new targetWindow.Error();
   for (let prop of Object.getOwnPropertyNames(error)) {
-    obj[prop] = String(error[prop]);
+    let value = error[prop];
+    if (typeof value != "string" && typeof value != "number") {
+      value = String(value);
+    }
+
+    Object.defineProperty(Cu.waiveXrays(obj), prop, {
+      configurable: false,
+      enumerable: true,
+      value: value,
+      writable: false
+    });
   }
   return obj;
 };
 
 /**
  * Makes an object or value available to an unprivileged target window.
  *
  * Primitives are returned as they are, while objects are cloned into the