1 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 * Loads the remote debugging protocol code into a sandbox, in order to
10 * shield it from the debuggee. This way, when debugging chrome globals,
11 * debugger and debuggee will be in separate compartments.
14 const Ci = Components.interfaces;
15 const Cc = Components.classes;
16 const Cu = Components.utils;
18 this.EXPORTED_SYMBOLS = ["DebuggerServer", "ActorPool"];
21 "function loadSubScript(aURL)\n" +
23 "const Ci = Components.interfaces;\n" +
24 "const Cc = Components.classes;\n" +
26 " let loader = Cc[\"@mozilla.org/moz/jssubscript-loader;1\"]\n" +
27 " .getService(Ci.mozIJSSubScriptLoader);\n" +
28 " loader.loadSubScript(aURL, this);\n" +
30 " dump(\"Error loading: \" + aURL + \": \" + e + \" - \" + e.stack + \"\\n\");\n" +
35 // Load the debugging server in a sandbox with its own compartment.
36 var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
37 .createInstance(Ci.nsIPrincipal);
39 var gGlobal = Cu.Sandbox(systemPrincipal);
40 gGlobal.ChromeWorker = ChromeWorker;
41 Cu.evalInSandbox(loadSubScript, gGlobal, "1.8");
42 gGlobal.loadSubScript("resource://gre/modules/devtools/server/main.js");
44 this.DebuggerServer = gGlobal.DebuggerServer;
45 this.ActorPool = gGlobal.ActorPool;