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
--- 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,
});
}