js/src/jit-test/tests/debug/Environment-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/Environment-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +// A live Environment can observe the new variables introduced by ES5 non-strict direct eval.
     1.5 +
     1.6 +var g = newGlobal();
     1.7 +g.eval("var x = 'global'; function f(s) { h(); eval(s); h(); }");
     1.8 +g.eval("function h() { debugger; }");
     1.9 +var dbg = Debugger(g);
    1.10 +var env = undefined;
    1.11 +var hits = 0;
    1.12 +dbg.onDebuggerStatement = function (hframe) {
    1.13 +    if (env === undefined) {
    1.14 +        // First debugger statement.
    1.15 +        env = hframe.older.environment;
    1.16 +        assertEq(env.find("x") !== env, true);
    1.17 +        assertEq(env.names().indexOf("x"), -1);
    1.18 +    } else {
    1.19 +        // Second debugger statement, post-eval.
    1.20 +        assertEq(env.find("x"), env);
    1.21 +        assertEq(env.names().indexOf("x") >= 0, true);
    1.22 +    }
    1.23 +    hits++;
    1.24 +};
    1.25 +g.f("var x = 'local';");
    1.26 +assertEq(hits, 2);

mercurial