summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Environment-find-01.js
blob: 497fceb2a681e313d815515f5143865d0042dbf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// find sees that vars are hoisted out of with statements.

var g = newGlobal();
var dbg = Debugger(g);
var hits = 0;
dbg.onDebuggerStatement = function (frame) {
    assertEq(frame.environment.find("x").type, "with");
    hits++;
};

assertEq(g.eval("(function () {\n" +
                "    function g() { x = 1; }\n" +
                "    with ({x: 2}) {\n" +
                "        var x;\n" +
                "        debugger;\n" +
                "        return x;\n" +
                "    }\n" +
                "})();"), 2);
assertEq(hits, 1);