Bug 1020609 - Fix up mozApps for Array Xrays. r=mccr8, a=lmandel
authorBobby Holley <bobbyholley@gmail.com>
Wed, 11 Jun 2014 15:16:06 -0700
changeset 208218 d3a95ceb20df6efba5d79c6d69e2638b851e11ff
parent 208217 e3022e313a054d6eb522eb9df09c6800ac05325d
child 208219 2e56e197cdbfc0d28a2b6772a0c28897491e9646
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, lmandel
bugs1020609
milestone32.0a2
Bug 1020609 - Fix up mozApps for Array Xrays. r=mccr8, a=lmandel
dom/apps/src/Webapps.js
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -16,17 +16,24 @@ Cu.import("resource://gre/modules/Browse
 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
                                    "@mozilla.org/childprocessmessagemanager;1",
                                    "nsIMessageSender");
 
 function convertAppsArray(aApps, aWindow) {
   let apps = new aWindow.Array();
   for (let i = 0; i < aApps.length; i++) {
     let app = aApps[i];
-    apps.push(createApplicationObject(aWindow, app));
+    // Our application objects are JS-implemented XPCOM objects with DOM_OBJECT
+    // set in classinfo. These objects are reflector-per-scope, so as soon as we
+    // pass them to content, we'll end up with a new object in content. But from
+    // this code, they _appear_ to be chrome objects, and so the Array Xray code
+    // vetos the attempt to define a chrome-privileged object on a content Array.
+    // Very carefully waive Xrays so that this can keep working until we convert
+    // mozApps to WebIDL in bug 899322.
+    Cu.waiveXrays(apps)[i] = createApplicationObject(aWindow, app);
   }
 
   return apps;
 }
 
 function WebappsRegistry() {
 }