1 // Test that the onGarbageCollection reentrancy guard is on a per Debugger
2 // basis. That is if our first Debugger is observing our second Debugger's
3 // compartment, and this second Debugger triggers a GC inside its
4 // onGarbageCollection hook, the first Debugger's onGarbageCollection hook is
7 // This is the scenario we are setting up: top level debugging the `debuggeree`
8 // global, which is debugging the `debuggee` global. Then, we trigger the
14 // debuggeree's onGarbageCollection
20 // top level onGarbageCollection
22 // Note that the top level's onGarbageCollection hook should be fired, at the
23 // same time that we are preventing reentrancy into debuggeree's
24 // onGarbageCollection hook.
26 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
27 registerCleanupFunction(() => {
28 Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
34 const debuggeree = newGlobal();
35 const debuggee = debuggeree.debuggee = newGlobal();
39 var dbg = new Debugger(this.debuggee);
41 dbg.memory.onGarbageCollection = _ => {
48 const dbg = new Debugger(debuggeree);
50 dbg.memory.onGarbageCollection = _ => {
54 debuggee.eval(`gc(this)`);
56 // Let first onGarbageCollection runnable get run.
59 // Let second onGarbageCollection runnable get run.
62 // Even though we request GC'ing a single zone, we can't rely on that
63 // behavior and both zones could have been scheduled for gc for both
65 ok(debuggeree.fired >= 1);
68 debuggeree.dbg.removeAllDebuggees();