js/src/jit-test/tests/debug/Environment-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/Environment-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,20 @@
     1.4 +// The last Environment on the environment chain always has .type == "object" and .object === the global object.
     1.5 +
     1.6 +var g = newGlobal();
     1.7 +var dbg = new Debugger;
     1.8 +var gw = dbg.addDebuggee(g);
     1.9 +g.eval("function h() { debugger; }");
    1.10 +var hits = 0;
    1.11 +dbg.onDebuggerStatement = function (hframe) {
    1.12 +    var env = hframe.older.environment;
    1.13 +    while (env.parent)
    1.14 +        env = env.parent;
    1.15 +    assertEq(env.type, "object");
    1.16 +    assertEq(env.object, gw);
    1.17 +    hits++;
    1.18 +};
    1.19 +
    1.20 +g.eval("h();");
    1.21 +g.eval("(function () { h(); return []; })();");
    1.22 +g.eval("with (Math) { h(-2 * PI); }");
    1.23 +assertEq(hits, 3);

mercurial