Bug 814104: Create the function in the right compartment. r=dcamp

This commit is contained in:
Kyle Huey 2012-11-26 08:56:56 -08:00
parent 439a5889fa
commit d91ef531e3

View File

@ -17,18 +17,20 @@ const Cu = Components.utils;
this.EXPORTED_SYMBOLS = ["DebuggerServer"];
function loadSubScript(aURL)
{
try {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript(aURL, this);
} catch(e) {
dump("Error loading: " + aURL + ": " + e + " - " + e.stack + "\n");
throw e;
}
}
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" +
"}";
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
@ -37,7 +39,7 @@ var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
.createInstance(Ci.nsIPrincipal);
var gGlobal = Cu.Sandbox(systemPrincipal);
gGlobal.importFunction(loadSubScript);
Cu.evalInSandbox(loadSubScript, gGlobal, "1.8");
gGlobal.loadSubScript("chrome://global/content/devtools/dbg-server.js");
this.DebuggerServer = gGlobal.DebuggerServer;