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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/onExceptionUnwind-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +// |jit-test| debug
     1.5 +// The onExceptionUnwind hook is called multiple times as the stack unwinds.
     1.6 +
     1.7 +var g = newGlobal();
     1.8 +g.debuggeeGlobal = this;
     1.9 +g.dbg = null;
    1.10 +g.eval("(" + function () {
    1.11 +        dbg = new Debugger(debuggeeGlobal);
    1.12 +        dbg.onExceptionUnwind = function (frame, exc) {
    1.13 +            assertEq(frame instanceof Debugger.Frame, true);
    1.14 +            assertEq(exc instanceof Debugger.Object, true);
    1.15 +            var s = '!';
    1.16 +            for (var f = frame; f; f = f.older)
    1.17 +                if (f.type === "call")
    1.18 +                    s += f.callee.name;
    1.19 +            s += ', ';
    1.20 +            debuggeeGlobal.log += s;
    1.21 +        };
    1.22 +    } + ")();");
    1.23 +
    1.24 +var log;
    1.25 +
    1.26 +function k() {
    1.27 +    try {
    1.28 +        throw new Error("oops");  // hook call 1
    1.29 +    } finally {
    1.30 +        log += 'k-finally, ';
    1.31 +    } // hook call 2
    1.32 +}
    1.33 +
    1.34 +function j() {
    1.35 +    k();  // hook call 3
    1.36 +    log += 'j-unreached, ';
    1.37 +}
    1.38 +
    1.39 +function h() {
    1.40 +    try {
    1.41 +        j();  // hook call 4
    1.42 +        log += 'h-unreached, ';
    1.43 +    } catch (exc) {
    1.44 +        log += 'h-catch, ';
    1.45 +        throw exc; // hook call 5
    1.46 +    }
    1.47 +}
    1.48 +
    1.49 +function f() {
    1.50 +    try {
    1.51 +        h(); // hook call 6
    1.52 +    } catch (exc) {
    1.53 +        log += 'f-catch, ';
    1.54 +    }
    1.55 +    log += 'f-after, ';
    1.56 +}
    1.57 +
    1.58 +log = '';
    1.59 +f();
    1.60 +g.dbg.enabled = false;
    1.61 +assertEq(log, '!kjhf, k-finally, !kjhf, !jhf, !hf, h-catch, !hf, !f, f-catch, f-after, ');

mercurial