Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 };
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 }
21 test(function () {
22 g.eval("first = Error().lineNumber;\n" +
23 "debugger;\n" +
24 "last = Error().lineNumber;\n");
25 });
27 test(function () {
28 g.evaluate("first = Error().lineNumber;\n" +
29 "debugger;\n" +
30 Array(17000).join("\n") +
31 "last = Error().lineNumber;\n");
32 });
34 test(function () {
35 g.eval("function f1() { first = Error().lineNumber\n" +
36 " debugger;\n" +
37 " last = Error().lineNumber; }\n" +
38 "f1();");
39 });
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);
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);