tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_onGarbageCollection-03.js (794B)


      1 // Test that the onGarbageCollection hook is not reentrant.
      2 
      3 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
      4 registerCleanupFunction(() => {
      5  Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
      6 });
      7 
      8 function run_test() {
      9  do_test_pending();
     10 
     11  const root = newGlobal();
     12  const dbg = new Debugger();
     13  const wrappedRoot = dbg.addDebuggee(root)
     14 
     15  let fired = true;
     16  let depth = 0;
     17 
     18  dbg.memory.onGarbageCollection = _ => {
     19    fired = true;
     20 
     21    equal(depth, 0);
     22    depth++;
     23    try {
     24      root.eval(`gc()`);
     25    } finally {
     26      equal(depth, 1);
     27      depth--;
     28    }
     29  }
     30 
     31  root.eval(`gc()`);
     32 
     33  executeSoon(() => {
     34    ok(fired);
     35    equal(depth, 0);
     36    dbg.memory.onGarbageCollection = undefined;
     37    do_test_finished();
     38  });
     39 }