js/src/jit-test/tests/debug/Environment-identity-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.

michael@0 1 // The value of frame.environment is the same Environment object at different
michael@0 2 // times within a single visit to a scope.
michael@0 3
michael@0 4 var g = newGlobal();
michael@0 5 var dbg = Debugger(g);
michael@0 6 g.eval("function h() { debugger; }");
michael@0 7 var hits, env;
michael@0 8 dbg.onDebuggerStatement = function (hframe) {
michael@0 9 var frame = hframe.older;
michael@0 10 var e = frame.environment;
michael@0 11
michael@0 12 // frame.environment is at least cached from one moment to the next.
michael@0 13 assertEq(e, frame.environment);
michael@0 14
michael@0 15 // frame.environment is cached from statement to statement within a call frame.
michael@0 16 if (env === undefined)
michael@0 17 env = e;
michael@0 18 else
michael@0 19 assertEq(e, env);
michael@0 20
michael@0 21 hits++;
michael@0 22 };
michael@0 23
michael@0 24 hits = 0;
michael@0 25 env = undefined;
michael@0 26 g.eval("function f() { (function () { var i = 0; h(); var j = 2; h(); })(); }");
michael@0 27 g.f();
michael@0 28 assertEq(hits, 2);
michael@0 29
michael@0 30 hits = 0;
michael@0 31 env = undefined;
michael@0 32 g.eval("function f2() { { let i = 0; h(); let j = 2; h(); } }");
michael@0 33 g.f2();
michael@0 34 assertEq(hits, 2);
michael@0 35
michael@0 36 hits = 0;
michael@0 37 env = undefined;
michael@0 38 g.eval("function f3() { { let i; for (i = 0; i < 2; i++) h(); } }");
michael@0 39 g.f3();
michael@0 40 assertEq(hits, 2);

mercurial