summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/gc/bug-1749298.js
blob: 7fa184501f306474fc794c230b16e60000b218de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Test that a finalization registry target that is reachable from its global
// does not keep the global alive indefinitely.

let global = newGlobal({newCompartment: true});
global.eval(`
  this.target = {};  // Target is reachable from global.
  this.registry = new FinalizationRegistry(() => assertEq(0, 1));
  registry.register(target, 'held');
  this.finalizeObserver = makeFinalizeObserver();
`);

assertEq(finalizeCount(), 0);

global = undefined;
gc();

assertEq(finalizeCount(), 1);