js/src/jit-test/tests/debug/Environment-find-01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // find sees that vars are hoisted out of with statements.
     3 var g = newGlobal();
     4 var dbg = Debugger(g);
     5 var hits = 0;
     6 dbg.onDebuggerStatement = function (frame) {
     7     assertEq(frame.environment.find("x").type, "with");
     8     hits++;
     9 };
    11 assertEq(g.eval("(function () {\n" +
    12                 "    function g() { x = 1; }\n" +
    13                 "    with ({x: 2}) {\n" +
    14                 "        var x;\n" +
    15                 "        debugger;\n" +
    16                 "        return x;\n" +
    17                 "    }\n" +
    18                 "})();"), 2);
    19 assertEq(hits, 1);

mercurial