1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Environment-identity-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +// The value of frame.environment is the same Environment object at different 1.5 +// times within a single visit to a scope. 1.6 + 1.7 +var g = newGlobal(); 1.8 +var dbg = Debugger(g); 1.9 +g.eval("function h() { debugger; }"); 1.10 +var hits, env; 1.11 +dbg.onDebuggerStatement = function (hframe) { 1.12 + var frame = hframe.older; 1.13 + var e = frame.environment; 1.14 + 1.15 + // frame.environment is at least cached from one moment to the next. 1.16 + assertEq(e, frame.environment); 1.17 + 1.18 + // frame.environment is cached from statement to statement within a call frame. 1.19 + if (env === undefined) 1.20 + env = e; 1.21 + else 1.22 + assertEq(e, env); 1.23 + 1.24 + hits++; 1.25 +}; 1.26 + 1.27 +hits = 0; 1.28 +env = undefined; 1.29 +g.eval("function f() { (function () { var i = 0; h(); var j = 2; h(); })(); }"); 1.30 +g.f(); 1.31 +assertEq(hits, 2); 1.32 + 1.33 +hits = 0; 1.34 +env = undefined; 1.35 +g.eval("function f2() { { let i = 0; h(); let j = 2; h(); } }"); 1.36 +g.f2(); 1.37 +assertEq(hits, 2); 1.38 + 1.39 +hits = 0; 1.40 +env = undefined; 1.41 +g.eval("function f3() { { let i; for (i = 0; i < 2; i++) h(); } }"); 1.42 +g.f3(); 1.43 +assertEq(hits, 2);