|
1 var g = newGlobal(); |
|
2 var dbg = Debugger(g); |
|
3 var start, count; |
|
4 dbg.onDebuggerStatement = function (frame) { |
|
5 assertEq(start, undefined); |
|
6 start = frame.script.startLine; |
|
7 count = frame.script.lineCount; |
|
8 assertEq(typeof frame.script.url, 'string'); |
|
9 }; |
|
10 |
|
11 function test(f, manualCount) { |
|
12 start = count = g.first = g.last = undefined; |
|
13 f(); |
|
14 if (manualCount) |
|
15 g.last = g.first + manualCount - 1; |
|
16 assertEq(start, g.first); |
|
17 assertEq(count, g.last + 1 - g.first); |
|
18 print(start, count); |
|
19 } |
|
20 |
|
21 test(function () { |
|
22 g.eval("first = Error().lineNumber;\n" + |
|
23 "debugger;\n" + |
|
24 "last = Error().lineNumber;\n"); |
|
25 }); |
|
26 |
|
27 test(function () { |
|
28 g.evaluate("first = Error().lineNumber;\n" + |
|
29 "debugger;\n" + |
|
30 Array(17000).join("\n") + |
|
31 "last = Error().lineNumber;\n"); |
|
32 }); |
|
33 |
|
34 test(function () { |
|
35 g.eval("function f1() { first = Error().lineNumber\n" + |
|
36 " debugger;\n" + |
|
37 " last = Error().lineNumber; }\n" + |
|
38 "f1();"); |
|
39 }); |
|
40 |
|
41 g.eval("function f2() {\n" + |
|
42 " eval('first = Error().lineNumber\\n\\ndebugger;\\n\\nlast = Error().lineNumber;');\n" + |
|
43 "}\n"); |
|
44 test(g.f2); |
|
45 test(g.f2); |
|
46 |
|
47 // Having a last = Error().lineNumber forces a setline srcnote, so test a |
|
48 // function that ends with newline srcnotes. |
|
49 g.eval("/* Any copyright is dedicated to the Public Domain.\n" + |
|
50 " http://creativecommons.org/publicdomain/zero/1.0/ */\n" + |
|
51 "\n" + |
|
52 "function secondCall() { first = Error().lineNumber;\n" + |
|
53 " debugger;\n" + |
|
54 " // Comment\n" + |
|
55 " eval(\"42;\");\n" + |
|
56 " function foo() {}\n" + |
|
57 " if (true) {\n" + |
|
58 " foo();\n" + // <- this is +6 and must be within the extent |
|
59 " }\n" + |
|
60 "}"); |
|
61 test(g.secondCall, 7); |