Backed out 2 changesets (bug 941012, bug 931921) for suspicion of breaking Mn on...
[gecko.git] / toolkit / devtools / server / dbg-server.jsm
blob44d88f3c3195aae3306aa33ca0623ef42ce50637
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/. */
7 "use strict";
8 /**
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.
12  */
14 const Ci = Components.interfaces;
15 const Cc = Components.classes;
16 const Cu = Components.utils;
18 this.EXPORTED_SYMBOLS = ["DebuggerServer", "ActorPool"];
20 var loadSubScript =
21   "function loadSubScript(aURL)\n" +
22   "{\n" +
23   "const Ci = Components.interfaces;\n" +
24   "const Cc = Components.classes;\n" +
25   "  try {\n" +
26   "    let loader = Cc[\"@mozilla.org/moz/jssubscript-loader;1\"]\n" +
27   "      .getService(Ci.mozIJSSubScriptLoader);\n" +
28   "    loader.loadSubScript(aURL, this);\n" +
29   "  } catch(e) {\n" +
30   "    dump(\"Error loading: \" + aURL + \": \" + e + \" - \" + e.stack + \"\\n\");\n" +
31   "    throw e;\n" +
32   "  }\n" +
33   "}";
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;