Web Inspector: fix exception when paused in internal script.
authorpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jul 2011 15:29:06 +0000 (15:29 +0000)
committerpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jul 2011 15:29:06 +0000 (15:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=64995

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/debugger/pause-in-internal-script.html

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.PresenationCallFrame.prototype.sourceLine):

LayoutTests:

* http/tests/inspector/debugger-test.js:
(initialize_DebuggerTest):
* inspector/debugger/pause-in-internal-script-expected.txt: Added.
* inspector/debugger/pause-in-internal-script.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91568 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/debugger-test.js
LayoutTests/inspector/debugger/pause-in-internal-script-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger/pause-in-internal-script.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

index 1c7c8a9..39ff2c7 100644 (file)
@@ -1,3 +1,15 @@
+2011-07-22  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: fix exception when paused in internal script.
+        https://bugs.webkit.org/show_bug.cgi?id=64995
+
+        Reviewed by Yury Semikhatsky.
+
+        * http/tests/inspector/debugger-test.js:
+        (initialize_DebuggerTest):
+        * inspector/debugger/pause-in-internal-script-expected.txt: Added.
+        * inspector/debugger/pause-in-internal-script.html: Added.
+
 2011-07-22  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: sometimes ReceiveResponse event is attached to wrong parent.
index dca8a33..105eea1 100644 (file)
@@ -109,11 +109,15 @@ InspectorTest.captureStackTrace = function(callFrames)
         var frame = callFrames[i];
         var script = WebInspector.debuggerModel.scriptForSourceID(frame.location.sourceId);
         var url;
-        if (script)
+        var lineNumber;
+        if (script) {
             url = WebInspector.displayNameForURL(script.sourceURL);
-        else
-            url = "(internal script)"
-        var s = "    " + i + ") " + frame.functionName + " (" + url + ":" + (frame.location.lineNumber + 1) + ")";
+            lineNumber = frame.location.lineNumber + 1;
+        } else {
+            url = "(internal script)";
+            lineNumber = "(line number)";
+        }
+        var s = "    " + i + ") " + frame.functionName + " (" + url + ":" + lineNumber + ")";
         InspectorTest.addResult(s);
     }
 };
diff --git a/LayoutTests/inspector/debugger/pause-in-internal-script-expected.txt b/LayoutTests/inspector/debugger/pause-in-internal-script-expected.txt
new file mode 100644 (file)
index 0000000..bc1100a
--- /dev/null
@@ -0,0 +1,16 @@
+Tests that internal scripts unknown to front-end are processed correctly when appear in debugger call frames. Bug 64995
+
+Debugger was enabled.
+
+Running: testSetBreakpoint
+Script source was shown.
+Set timer for test function.
+Script execution paused.
+Call stack:
+    0)  (pause-in-internal-script.html:14)
+    1) forEach ((internal script):(line number))
+    2) testFunction (pause-in-internal-script.html:12)
+Script execution resumed.
+Script execution paused.
+Debugger was disabled.
+
diff --git a/LayoutTests/inspector/debugger/pause-in-internal-script.html b/LayoutTests/inspector/debugger/pause-in-internal-script.html
new file mode 100644 (file)
index 0000000..c6fb507
--- /dev/null
@@ -0,0 +1,52 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/debugger-test.js"></script>
+
+<script>
+
+function testFunction()
+{
+    var array = [2, 5, 7];
+    var sum = 0;
+    array.forEach(function(key)
+    {
+        sum += array[key];
+    });
+    return sum;
+}
+
+function test()
+{
+    InspectorTest.runDebuggerTestSuite([
+        function testSetBreakpoint(next)
+        {
+            InspectorTest.showScriptSource("pause-in-internal-script.html", didShowScriptSource);
+
+            function didShowScriptSource(sourceFrame)
+            {
+                InspectorTest.addResult("Script source was shown.");
+                InspectorTest.setBreakpoint(sourceFrame, 13, "", true);
+                InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
+            }
+
+            function didPause(callFrames)
+            {
+                InspectorTest.captureStackTrace(callFrames);
+                next();
+            }
+        }
+    ]);
+};
+
+</script>
+
+</head>
+
+<body onload="runTest()">
+<p>Tests that internal scripts unknown to front-end are processed correctly when appear in debugger call frames.
+<a href="https://bugs.webkit.org/show_bug.cgi?id=64995">Bug 64995</a>
+</p>
+
+</body>
+</html>
index a9e38b2..6e005f3 100644 (file)
@@ -1,3 +1,15 @@
+2011-07-22  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: fix exception when paused in internal script.
+        https://bugs.webkit.org/show_bug.cgi?id=64995
+
+        Reviewed by Yury Semikhatsky.
+
+        Test: inspector/debugger/pause-in-internal-script.html
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.PresenationCallFrame.prototype.sourceLine):
+
 2011-07-22  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: sometimes ReceiveResponse event is attached to wrong parent.
index 65aaffa..5b9ac69 100644 (file)
@@ -781,7 +781,10 @@ WebInspector.PresenationCallFrame.prototype = {
     sourceLine: function(callback)
     {
         var location = this._callFrame.location;
-        this._model._scriptLocationToUILocation(null, location.sourceId, location.lineNumber, location.columnNumber, callback);
+        if (!this.isInternalScript)
+            this._model._scriptLocationToUILocation(null, location.sourceId, location.lineNumber, location.columnNumber, callback);
+        else
+            callback(undefined, location.lineNumber);
     }
 }