summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Debugger-dead-global.js
blob: abcb370be009fcefb53a74ec3662d2dc2db65665 (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
var g1 = newGlobal({newCompartment: true});

const dbg = new Debugger();

function assertThrowsDeadWrapper(f) {
  let caught = false;
  try {
    f();
  } catch (e) {
    assertEq(e.message, "can't access dead object");
    caught = true;
  }
  assertEq(caught, true);
}

nukeAllCCWs();

// Debugger methods should throw explicit error for dead global object.
assertThrowsDeadWrapper(() => dbg.addDebuggee(g1));
assertThrowsDeadWrapper(() => dbg.removeDebuggee(g1));
assertThrowsDeadWrapper(() => dbg.findScripts({global: g1}));
assertThrowsDeadWrapper(() => dbg.makeGlobalObjectReference(g1));
assertThrowsDeadWrapper(() => dbg.enableAsyncStack(g1));
assertThrowsDeadWrapper(() => dbg.disableAsyncStack(g1));
assertThrowsDeadWrapper(() => dbg.enableUnlimitedStacksCapturing(g1));
assertThrowsDeadWrapper(() => dbg.disableUnlimitedStacksCapturing(g1));