2012-02-07 09:22:30 -08:00
|
|
|
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2012-02-07 09:22:30 -08:00
|
|
|
|
2012-02-14 11:45:36 -08:00
|
|
|
"use strict";
|
|
|
|
/**
|
2012-04-22 02:59:09 -07:00
|
|
|
* Loads the remote debugging protocol code into a sandbox, in order to
|
|
|
|
* shield it from the debuggee. This way, when debugging chrome globals,
|
|
|
|
* debugger and debuggee will be in separate compartments.
|
2012-02-14 11:45:36 -08:00
|
|
|
*/
|
|
|
|
|
2012-02-07 09:22:30 -08:00
|
|
|
const Ci = Components.interfaces;
|
2012-02-14 11:45:36 -08:00
|
|
|
const Cc = Components.classes;
|
2012-02-07 09:22:30 -08:00
|
|
|
const Cu = Components.utils;
|
|
|
|
|
2012-10-31 09:13:28 -07:00
|
|
|
this.EXPORTED_SYMBOLS = ["DebuggerServer"];
|
2012-02-07 09:22:30 -08:00
|
|
|
|
2012-11-26 08:56:56 -08:00
|
|
|
var loadSubScript =
|
|
|
|
"function loadSubScript(aURL)\n" +
|
|
|
|
"{\n" +
|
|
|
|
"const Ci = Components.interfaces;\n" +
|
|
|
|
"const Cc = Components.classes;\n" +
|
|
|
|
" try {\n" +
|
|
|
|
" let loader = Cc[\"@mozilla.org/moz/jssubscript-loader;1\"]\n" +
|
|
|
|
" .getService(Ci.mozIJSSubScriptLoader);\n" +
|
|
|
|
" loader.loadSubScript(aURL, this);\n" +
|
|
|
|
" } catch(e) {\n" +
|
|
|
|
" dump(\"Error loading: \" + aURL + \": \" + e + \" - \" + e.stack + \"\\n\");\n" +
|
|
|
|
" throw e;\n" +
|
|
|
|
" }\n" +
|
|
|
|
"}";
|
2012-02-07 09:22:30 -08:00
|
|
|
|
2012-04-22 02:59:09 -07:00
|
|
|
// Load the debugging server in a sandbox with its own compartment.
|
|
|
|
var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
|
|
|
|
.createInstance(Ci.nsIPrincipal);
|
2012-02-14 11:45:36 -08:00
|
|
|
|
2012-04-22 02:59:09 -07:00
|
|
|
var gGlobal = Cu.Sandbox(systemPrincipal);
|
2012-11-26 08:56:56 -08:00
|
|
|
Cu.evalInSandbox(loadSubScript, gGlobal, "1.8");
|
2013-05-21 16:39:13 -07:00
|
|
|
gGlobal.loadSubScript("resource://gre/modules/devtools/server/main.js");
|
2012-02-14 11:45:36 -08:00
|
|
|
|
2012-10-31 09:13:28 -07:00
|
|
|
this.DebuggerServer = gGlobal.DebuggerServer;
|