michael@0: var g = newGlobal(); michael@0: var dbg = Debugger(g); michael@0: var start, count; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: assertEq(start, undefined); michael@0: start = frame.script.startLine; michael@0: count = frame.script.lineCount; michael@0: assertEq(typeof frame.script.url, 'string'); michael@0: }; michael@0: michael@0: function test(f, manualCount) { michael@0: start = count = g.first = g.last = undefined; michael@0: f(); michael@0: if (manualCount) michael@0: g.last = g.first + manualCount - 1; michael@0: assertEq(start, g.first); michael@0: assertEq(count, g.last + 1 - g.first); michael@0: print(start, count); michael@0: } michael@0: michael@0: test(function () { michael@0: g.eval("first = Error().lineNumber;\n" + michael@0: "debugger;\n" + michael@0: "last = Error().lineNumber;\n"); michael@0: }); michael@0: michael@0: test(function () { michael@0: g.evaluate("first = Error().lineNumber;\n" + michael@0: "debugger;\n" + michael@0: Array(17000).join("\n") + michael@0: "last = Error().lineNumber;\n"); michael@0: }); michael@0: michael@0: test(function () { michael@0: g.eval("function f1() { first = Error().lineNumber\n" + michael@0: " debugger;\n" + michael@0: " last = Error().lineNumber; }\n" + michael@0: "f1();"); michael@0: }); michael@0: michael@0: g.eval("function f2() {\n" + michael@0: " eval('first = Error().lineNumber\\n\\ndebugger;\\n\\nlast = Error().lineNumber;');\n" + michael@0: "}\n"); michael@0: test(g.f2); michael@0: test(g.f2); michael@0: michael@0: // Having a last = Error().lineNumber forces a setline srcnote, so test a michael@0: // function that ends with newline srcnotes. michael@0: g.eval("/* Any copyright is dedicated to the Public Domain.\n" + michael@0: " http://creativecommons.org/publicdomain/zero/1.0/ */\n" + michael@0: "\n" + michael@0: "function secondCall() { first = Error().lineNumber;\n" + michael@0: " debugger;\n" + michael@0: " // Comment\n" + michael@0: " eval(\"42;\");\n" + michael@0: " function foo() {}\n" + michael@0: " if (true) {\n" + michael@0: " foo();\n" + // <- this is +6 and must be within the extent michael@0: " }\n" + michael@0: "}"); michael@0: test(g.secondCall, 7);