js/src/jit-test/tests/debug/onExceptionUnwind-01.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-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,24 @@
     1.4 +// Basic onExceptionUnwind hook test.
     1.5 +
     1.6 +load(libdir + "asserts.js");
     1.7 +
     1.8 +var g = newGlobal();
     1.9 +var dbg = Debugger(g);
    1.10 +var hit = false;
    1.11 +dbg.onExceptionUnwind = function (frame, exc) {
    1.12 +    // onExceptionUnwind is called multiple times as the stack is unwound.
    1.13 +    // Only check the first hit.
    1.14 +    assertEq(arguments.length, 2);
    1.15 +    assertEq(frame instanceof Debugger.Frame, true);
    1.16 +    if (!hit) {
    1.17 +        assertEq(exc, 101);
    1.18 +        assertEq(frame.type, "call");
    1.19 +        assertEq(frame.callee.name, "f");
    1.20 +        assertEq(frame.older.type, "eval");
    1.21 +        hit = true;
    1.22 +    }
    1.23 +};
    1.24 +
    1.25 +g.eval("function f() { throw 101; }");
    1.26 +assertThrowsValue(function () { g.eval("f();"); }, 101);
    1.27 +assertEq(hit, true);

mercurial