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

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

mercurial