Bug 936143 - Part 1: Add Debugger.Script.lineCount test where the script's source notes end in newline notes. (r=jimb, a=lsblakk)
authorShu-yu Guo <shu@rfrn.org>
Mon, 18 Nov 2013 20:38:52 -0800
changeset 166673 155f0791ac678c324839d1b151396090b1f3cc3d
parent 166672 1a29647ca0a62512e9649c5894090436216da568
child 166674 455f7d22d2fac9533c868278f6541b31ba0ed2ba
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb, lsblakk
bugs936143
milestone27.0a2
Bug 936143 - Part 1: Add Debugger.Script.lineCount test where the script's source notes end in newline notes. (r=jimb, a=lsblakk)
js/src/jit-test/tests/debug/Script-startLine.js
--- a/js/src/jit-test/tests/debug/Script-startLine.js
+++ b/js/src/jit-test/tests/debug/Script-startLine.js
@@ -3,19 +3,21 @@ var dbg = Debugger(g);
 var start, count;
 dbg.onDebuggerStatement = function (frame) {
     assertEq(start, undefined);
     start = frame.script.startLine;
     count = frame.script.lineCount;
     assertEq(typeof frame.script.url, 'string');
 };
 
-function test(f) {
+function test(f, manualCount) {
     start = count = g.first = g.last = undefined;
     f();
+    if (manualCount)
+        g.last = g.first + manualCount - 1;
     assertEq(start, g.first);
     assertEq(count, g.last + 1 - g.first);
     print(start, count);
 }
 
 test(function () {
     g.eval("first = Error().lineNumber;\n" +
            "debugger;\n" +
@@ -36,8 +38,24 @@ test(function () {
            "f1();");
 });
 
 g.eval("function f2() {\n" +
        "    eval('first = Error().lineNumber\\n\\ndebugger;\\n\\nlast = Error().lineNumber;');\n" +
        "}\n");
 test(g.f2);
 test(g.f2);
+
+// Having a last = Error().lineNumber forces a setline srcnote, so test a
+// function that ends with newline srcnotes.
+g.eval("/* Any copyright is dedicated to the Public Domain.\n" +
+       " http://creativecommons.org/publicdomain/zero/1.0/ */\n" +
+       "\n" +
+       "function secondCall() { first = Error().lineNumber;\n" +
+       "    debugger;\n" +
+       "    // Comment\n" +
+       "    eval(\"42;\");\n" +
+       "    function foo() {}\n" +
+       "    if (true) {\n" +
+       "        foo();\n" +  // <- this is +6 and must be within the extent
+       "    }\n" +
+       "}");
+test(g.secondCall, 7);