Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // evalWithBindings basics
3 var g = newGlobal();
4 var dbg = new Debugger(g);
5 var hits = 0;
6 dbg.onDebuggerStatement = function (frame) {
7 assertEq(frame.evalWithBindings("x", {x: 2}).return, 2);
8 assertEq(frame.evalWithBindings("x + y", {x: 2}).return, 5);
9 hits++;
10 };
12 // in global code
13 g.y = 3;
14 g.eval("debugger;");
16 // in function code
17 g.y = "fail";
18 g.eval("function f(y) { debugger; }");
19 g.f(3);
21 // in direct eval code
22 g.eval("function f() { var y = 3; eval('debugger;'); }");
23 g.f();
25 // in strict eval code with var
26 g.eval("function f() { 'use strict'; eval('var y = 3; debugger;'); }");
27 g.f();
29 // in a with block
30 g.eval("with ({y: 3}) { debugger; }");
32 // shadowing
33 g.eval("let (x = 50, y = 3) { debugger; }");
35 assertEq(hits, 6);