1 var {addDebuggerToGlobal, addSandboxedDebuggerToGlobal} = ChromeUtils.importESModule("resource://gre/modules/jsdebugger.sys.mjs");
3 const testingFunctions = Cu.getJSTestingFunctions();
4 const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
6 function addTestingFunctionsToGlobal(global) {
7 for (let k in testingFunctions) {
8 global[k] = testingFunctions[k];
11 global.newGlobal = newGlobal;
12 addDebuggerToGlobal(global);
15 function newGlobal() {
16 const global = new Cu.Sandbox(systemPrincipal, { freshZone: true });
17 addTestingFunctionsToGlobal(global);
21 addTestingFunctionsToGlobal(this);
23 function executeSoon(f) {
24 Services.tm.dispatchToMainThread({ run: f });
27 // The onGarbageCollection tests don't play well gczeal settings and lead to
29 if (typeof gczeal == "function") {
33 // Make sure to GC before we start the test, so that no zones are scheduled for
34 // GC before we start testing onGarbageCollection hooks.