1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Script-startLine.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +var g = newGlobal(); 1.5 +var dbg = Debugger(g); 1.6 +var start, count; 1.7 +dbg.onDebuggerStatement = function (frame) { 1.8 + assertEq(start, undefined); 1.9 + start = frame.script.startLine; 1.10 + count = frame.script.lineCount; 1.11 + assertEq(typeof frame.script.url, 'string'); 1.12 +}; 1.13 + 1.14 +function test(f, manualCount) { 1.15 + start = count = g.first = g.last = undefined; 1.16 + f(); 1.17 + if (manualCount) 1.18 + g.last = g.first + manualCount - 1; 1.19 + assertEq(start, g.first); 1.20 + assertEq(count, g.last + 1 - g.first); 1.21 + print(start, count); 1.22 +} 1.23 + 1.24 +test(function () { 1.25 + g.eval("first = Error().lineNumber;\n" + 1.26 + "debugger;\n" + 1.27 + "last = Error().lineNumber;\n"); 1.28 +}); 1.29 + 1.30 +test(function () { 1.31 + g.evaluate("first = Error().lineNumber;\n" + 1.32 + "debugger;\n" + 1.33 + Array(17000).join("\n") + 1.34 + "last = Error().lineNumber;\n"); 1.35 +}); 1.36 + 1.37 +test(function () { 1.38 + g.eval("function f1() { first = Error().lineNumber\n" + 1.39 + " debugger;\n" + 1.40 + " last = Error().lineNumber; }\n" + 1.41 + "f1();"); 1.42 +}); 1.43 + 1.44 +g.eval("function f2() {\n" + 1.45 + " eval('first = Error().lineNumber\\n\\ndebugger;\\n\\nlast = Error().lineNumber;');\n" + 1.46 + "}\n"); 1.47 +test(g.f2); 1.48 +test(g.f2); 1.49 + 1.50 +// Having a last = Error().lineNumber forces a setline srcnote, so test a 1.51 +// function that ends with newline srcnotes. 1.52 +g.eval("/* Any copyright is dedicated to the Public Domain.\n" + 1.53 + " http://creativecommons.org/publicdomain/zero/1.0/ */\n" + 1.54 + "\n" + 1.55 + "function secondCall() { first = Error().lineNumber;\n" + 1.56 + " debugger;\n" + 1.57 + " // Comment\n" + 1.58 + " eval(\"42;\");\n" + 1.59 + " function foo() {}\n" + 1.60 + " if (true) {\n" + 1.61 + " foo();\n" + // <- this is +6 and must be within the extent 1.62 + " }\n" + 1.63 + "}"); 1.64 +test(g.secondCall, 7);