js/src/jit-test/tests/debug/Script-startLine.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial