michael@0: // evalWithBindings code is debuggee code, so it can trip the debugger. It nests! michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger(g); michael@0: var f1; michael@0: var hits = 0; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: f1 = frame; michael@0: michael@0: // This trips the onExceptionUnwind hook. michael@0: var x = frame.evalWithBindings("wrongSpeling", {rightSpelling: 2}).throw; michael@0: michael@0: assertEq(frame.evalWithBindings("exc.name", {exc: x}).return, "ReferenceError"); michael@0: hits++; michael@0: }; michael@0: dbg.onExceptionUnwind = function (frame, exc) { michael@0: assertEq(frame !== f1, true); michael@0: michael@0: // f1's environment does not contain the binding for the first evalWithBindings call. michael@0: assertEq(f1.eval("rightSpelling").return, "dependent"); michael@0: assertEq(f1.evalWithBindings("n + rightSpelling", {n: "in"}).return, "independent"); michael@0: michael@0: // frame's environment does contain the binding. michael@0: assertEq(frame.eval("rightSpelling").return, 2); michael@0: assertEq(frame.evalWithBindings("rightSpelling + three", {three: 3}).return, 5); michael@0: hits++; michael@0: }; michael@0: g.eval("(function () { var rightSpelling = 'dependent'; debugger; })();");