js/src/jit-test/tests/debug/Frame-eval-08.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-eval-08.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +// The arguments can escape from a function via a debugging hook.
     1.5 +
     1.6 +var g = newGlobal();
     1.7 +var dbg = new Debugger(g);
     1.8 +
     1.9 +// capture arguments object and test function
    1.10 +var args, testfn;
    1.11 +dbg.onDebuggerStatement = function (frame) {
    1.12 +    args = frame.eval("arguments").return;
    1.13 +    testfn = frame.eval("test").return;
    1.14 +};
    1.15 +g.eval("function f() { debugger; }");
    1.16 +g.eval("var test = " + function test(args) {
    1.17 +        assertEq(args.length, 3);
    1.18 +        assertEq(args[0], this);
    1.19 +        assertEq(args[1], f);
    1.20 +        assertEq(args[2].toString(), "[object Object]");
    1.21 +        return 42;
    1.22 +    } + ";");
    1.23 +g.eval("f(this, f, {});");
    1.24 +
    1.25 +var cv = testfn.apply(null, [args]);
    1.26 +assertEq(cv.return, 42);

mercurial