js/src/jit-test/tests/debug/onExceptionUnwind-02.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-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     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 +    throw new Error("oops");  // hook call 1
    1.28 +}
    1.29 +
    1.30 +function j() {
    1.31 +    k();  // hook call 2
    1.32 +    log += 'j-unreached, ';
    1.33 +}
    1.34 +
    1.35 +function h() {
    1.36 +    j();  // hook call 3
    1.37 +    log += 'h-unreached, ';
    1.38 +}
    1.39 +
    1.40 +function f() {
    1.41 +    try {
    1.42 +        h(); // hook call 4
    1.43 +    } catch (exc) {
    1.44 +        log += 'f-catch';
    1.45 +    }
    1.46 +}
    1.47 +
    1.48 +log = '';
    1.49 +f();
    1.50 +g.dbg.enabled = false;
    1.51 +assertEq(log, '!kjhf, !jhf, !hf, !f, f-catch');

mercurial