Bug 1404088 - Waive Xrays when exposing properties for RDM. r=ochameau draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Fri, 29 Sep 2017 12:29:06 -0500
changeset 672989 b0b571bc0343ab71a937ff7c8a12afee799759ea
parent 672988 b26e85d5944ed32fcf9867f40163f19bb42dddb6
child 672990 a9c775388c7a1af72ec0fdf92955640211f77c63
push id82424
push userbmo:jryans@gmail.com
push dateFri, 29 Sep 2017 22:45:11 +0000
reviewersochameau
bugs1404088
milestone58.0a1
Bug 1404088 - Waive Xrays when exposing properties for RDM. r=ochameau When exposing properties from the browser window, we need to waive xrays on the inner `ownerGlobal` (RDM's tool window) so that they are visible to other scripts, like the WebExtension APIs. MozReview-Commit-ID: CgL5B6OtoDj
devtools/client/responsive.html/browser/tunnel.js
--- a/devtools/client/responsive.html/browser/tunnel.js
+++ b/devtools/client/responsive.html/browser/tunnel.js
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const { Ci } = require("chrome");
+const { Ci, Cu } = require("chrome");
 const Services = require("Services");
 const { Task } = require("devtools/shared/task");
 const { BrowserElementWebNavigation } = require("./web-navigation");
 const { getStack } = require("devtools/shared/platform/stack");
 
 // A symbol used to hold onto the frame loader from the outer browser while tunneling.
 const FRAME_LOADER = Symbol("devtools/responsive/frame-loader");
 // Export for use in tests.
@@ -217,18 +217,19 @@ function tunnelToInnerBrowser(outer, inn
       // this state up to the outer browser.
       for (let property of SWAPPED_BROWSER_STATE) {
         outer[property] = inner[property];
       }
 
       // Expose various properties from the browser window on the RDM tool's global.  This
       // aids various bits of code that expect to find a browser window, such as event
       // handlers that reach for the window via the event's target.
+      let innerGlobal = Cu.waiveXrays(inner.ownerGlobal);
       for (let property of PROPERTIES_FROM_BROWSER_WINDOW) {
-        Object.defineProperty(inner.ownerGlobal, property, {
+        Object.defineProperty(innerGlobal, property, {
           get() {
             return outer.ownerGlobal[property];
           },
           configurable: true,
           enumerable: true,
         });
       }