Debian Codegraph @

js/src/jit-test/tests/debug/onExceptionUnwind-02.js

raw
1 // The onExceptionUnwind hook is called multiple times as the stack unwinds.
2
3 var g = newGlobal({newCompartment: true});
4 g.debuggeeGlobal = this;
5 g.dbg = null;
6 g.eval("(" + function () {
7 dbg = new Debugger(debuggeeGlobal);
8 dbg.onExceptionUnwind = function (frame, exc) {
9 assertEq(frame instanceof Debugger.Frame, true);
10 assertEq(exc instanceof Debugger.Object, true);
11 var s = '!';
12 for (var f = frame; f; f = f.older)
13 if (f.type === "call")
14 s += f.callee.name;
15 s += ', ';
16 debuggeeGlobal.log += s;
17 };
18 } + ")();");
19
20 var log;
21
22 function k() {
23 throw new Error("oops"); // hook call 1
24 }
25
26 function j() {
27 k(); // hook call 2
28 log += 'j-unreached, ';
29 }
30
31 function h() {
32 j(); // hook call 3
33 log += 'h-unreached, ';
34 }
35
36 function f() {
37 try {
38 h(); // hook call 4
39 } catch (exc) {
40 log += 'f-catch';
41 }
42 }
43
44 log = '';
45 f();
46 g.dbg.enabled = false;
47 assertEq(log, '!kjhf, !jhf, !hf, !f, f-catch');