Bug 1473828 - Use weak message manager listener to have message data be in sandbox compartment. r=jryans
MozReview-Commit-ID: 4xWAZSv6FA2
--- a/devtools/shared/transport/child-transport.js
+++ b/devtools/shared/transport/child-transport.js
@@ -1,15 +1,16 @@
/* 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 { Cr } = require("chrome");
+const { Ci, Cr } = require("chrome");
+const ChromeUtils = require("ChromeUtils");
const flags = require("devtools/shared/flags");
/**
* A transport for the debugging protocol that uses nsIMessageManagers to
* exchange packets with servers running in child processes.
*
* In the parent process, |mm| should be the nsIMessageSender for the
* child process. In a child process, |mm| should be the child process
@@ -31,23 +32,25 @@ function ChildDebuggerTransport(mm, pref
* nsIMessageSender conveys, and 'packet' to mean a remote debugging
* protocol packet.
*/
ChildDebuggerTransport.prototype = {
constructor: ChildDebuggerTransport,
hooks: null,
+ QueryInterface: ChromeUtils.generateQI([Ci.nsISupportsWeakReference]),
+
_addListener() {
- this._mm.addMessageListener(this._messageName, this);
+ this._mm.addWeakMessageListener(this._messageName, this);
},
_removeListener() {
try {
- this._mm.removeMessageListener(this._messageName, this);
+ this._mm.removeWeakMessageListener(this._messageName, this);
} catch (e) {
if (e.result != Cr.NS_ERROR_NULL_POINTER) {
throw e;
}
// In some cases, especially when using messageManagers in non-e10s mode, we reach
// this point with a dead messageManager which only throws errors but does not
// seem to indicate in any other way that it is dead.
}
--- a/devtools/shared/worker/loader.js
+++ b/devtools/shared/worker/loader.js
@@ -564,16 +564,17 @@ this.worker = new WorkerDebuggerLoader({
"lazyRequireModule": lazyRequireModule,
"retrieveConsoleEvents": this.retrieveConsoleEvents,
"setConsoleEventHandler": this.setConsoleEventHandler,
},
loadSubScript: loadSubScript,
modules: {
"Debugger": Debugger,
"Services": Object.create(null),
+ "ChromeUtils": Object.create(null),
"chrome": chrome,
"xpcInspector": xpcInspector
},
paths: {
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"devtools": "resource://devtools",
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"promise": "resource://gre/modules/Promise-backend.js",