js/src/jit-test/tests/debug/Frame-onPop-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/Frame-onPop-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,32 @@
     1.4 +// When an exception is propagated out of multiple frames, their onPop
     1.5 +// and onExceptionUnwind handlers are called in the correct order.
     1.6 +var g = newGlobal();
     1.7 +g.eval("function f() { throw 'mud'; }");
     1.8 +g.eval("function g() { f(); }");
     1.9 +g.eval("function h() { g(); }");
    1.10 +g.eval("function i() { h(); }");
    1.11 +
    1.12 +var dbg = new Debugger(g);
    1.13 +var log;
    1.14 +function makePopHandler(label) {
    1.15 +    return function handlePop(completion) { 
    1.16 +        log += label;
    1.17 +        assertEq(completion.throw, "mud");
    1.18 +    };
    1.19 +}
    1.20 +dbg.onEnterFrame = function handleEnter(f) {
    1.21 +    log += "(" + f.callee.name;
    1.22 +    f.onPop = makePopHandler(")" + f.callee.name);  
    1.23 +};
    1.24 +dbg.onExceptionUnwind = function handleExceptionUnwind(f, x) {
    1.25 +    assertEq(x, 'mud');
    1.26 +    log += "u" + f.callee.name;
    1.27 +};
    1.28 +log = '';
    1.29 +try {
    1.30 +    g.i();
    1.31 +} catch (x) {
    1.32 +    log += 'c';
    1.33 +    assertEq(x, "mud");
    1.34 +}
    1.35 +assertEq(log, "(i(h(g(fuf)fug)guh)hui)ic");

mercurial