summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/gc-10.js
blob: 9a3fb00b3de21480945a2e083b904ab72055a1f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Debugger.Frame objects should not be GC'd when doing so would have observable
// effects.

var g = newGlobal({ newCompartment: true });

var log = '';
var saved;

new Debugger(g).onDebuggerStatement = function (frame) {

  // Having a live onDebuggerStatement hook will (correctly) cause a Debugger to
  // be retained, even if it is otherwise unreachable.
  this.onDebuggerStatement = undefined;

  // Give this Debugger.Frame an observable effect. It should not be GC'd.
  frame.onPop = function () {
    log += 'p';
  }
}

g.parent = this;

g.eval(`
  debugger;
  gc();
`);

assertEq(log, 'p');