michael@0: // evalWithBindings basics michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger(g); michael@0: var hits = 0; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: assertEq(frame.evalWithBindings("x", {x: 2}).return, 2); michael@0: assertEq(frame.evalWithBindings("x + y", {x: 2}).return, 5); michael@0: hits++; michael@0: }; michael@0: michael@0: // in global code michael@0: g.y = 3; michael@0: g.eval("debugger;"); michael@0: michael@0: // in function code michael@0: g.y = "fail"; michael@0: g.eval("function f(y) { debugger; }"); michael@0: g.f(3); michael@0: michael@0: // in direct eval code michael@0: g.eval("function f() { var y = 3; eval('debugger;'); }"); michael@0: g.f(); michael@0: michael@0: // in strict eval code with var michael@0: g.eval("function f() { 'use strict'; eval('var y = 3; debugger;'); }"); michael@0: g.f(); michael@0: michael@0: // in a with block michael@0: g.eval("with ({y: 3}) { debugger; }"); michael@0: michael@0: // shadowing michael@0: g.eval("let (x = 50, y = 3) { debugger; }"); michael@0: michael@0: assertEq(hits, 6);