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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial