Debian Codegraph @

js/src/jit-test/tests/debug/noExecute-07.js

raw
1 // Tests provenance of Debugger.DebuggeeWouldRun errors.
2
3 load(libdir + "asserts.js");
4 load(libdir + "debuggerNXHelper.js");
5
6 var g1 = newGlobal({newCompartment: true});
7 var g2 = newGlobal({newCompartment: true});
8 var g3 = newGlobal({newCompartment: true});
9 var dbg = new Debugger(g1);
10
11 g3.eval(`var dbg = new Debugger`);
12 var g1w = g3.dbg.addDebuggee(g1);
13 g3.dbg.addDebuggee(g2);
14
15 g1.eval(`function f() {}`);
16
17 function testHook(hookName) {
18 // The stack is like so:
19 // g1 -> dbg (locks g1) -> g2 -> g3.dbg (locks g1 and g2)
20 //
21 // The DebuggeeWouldRun error is always allocated in the topmost locked
22 // Debugger's compartment.
23
24 // If we try to run script in g1 without going through one of g3.dbg's
25 // invocation functions, we should get an error allocated in
26 // g3.Debugger.DebuggeeWouldRun.
27 assertThrowsInstanceOf(() => { g1.eval(`f()`); }, g3.Debugger.DebuggeeWouldRun);
28
29 // If we try to run script in g1 via one of g3.dbg's invocation functions,
30 // we should get an error allocated in Debugger.DebuggeeWouldRun.
31 assertEq(g1w.executeInGlobal(`f()`).throw.unsafeDereference() instanceof Debugger.DebuggeeWouldRun, true);
32 }
33
34 testDebuggerHooksNX(dbg, g1, () => {
35 testDebuggerHooksNX(g3.dbg, g2, testHook);
36 });