1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Frame-evalWithBindings-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +// evalWithBindings basics 1.5 + 1.6 +var g = newGlobal(); 1.7 +var dbg = new Debugger(g); 1.8 +var hits = 0; 1.9 +dbg.onDebuggerStatement = function (frame) { 1.10 + assertEq(frame.evalWithBindings("x", {x: 2}).return, 2); 1.11 + assertEq(frame.evalWithBindings("x + y", {x: 2}).return, 5); 1.12 + hits++; 1.13 +}; 1.14 + 1.15 +// in global code 1.16 +g.y = 3; 1.17 +g.eval("debugger;"); 1.18 + 1.19 +// in function code 1.20 +g.y = "fail"; 1.21 +g.eval("function f(y) { debugger; }"); 1.22 +g.f(3); 1.23 + 1.24 +// in direct eval code 1.25 +g.eval("function f() { var y = 3; eval('debugger;'); }"); 1.26 +g.f(); 1.27 + 1.28 +// in strict eval code with var 1.29 +g.eval("function f() { 'use strict'; eval('var y = 3; debugger;'); }"); 1.30 +g.f(); 1.31 + 1.32 +// in a with block 1.33 +g.eval("with ({y: 3}) { debugger; }"); 1.34 + 1.35 +// shadowing 1.36 +g.eval("let (x = 50, y = 3) { debugger; }"); 1.37 + 1.38 +assertEq(hits, 6);