Title: [107228] branches/chromium/1025
Revision
107228
Author
[email protected]
Date
2012-02-09 05:46:45 -0800 (Thu, 09 Feb 2012)

Log Message

Merge 106468 - Web Inspector: debugger reports wrong sources when paused in inline script on page reload
https://bugs.webkit.org/show_bug.cgi?id=77548

Source/WebCore:

V8 returns treats each script source as ending with \n, now we take
this into account when reporting script line count to the inspector
front-end.

Reviewed by Vsevolod Vlasov.

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

* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::dispatchDidParseSource):
* bindings/v8/DebuggerScript.js:

LayoutTests:

Reviewed by Vsevolod Vlasov.

* inspector/debugger/debugger-scripts-expected.txt:
* inspector/debugger/pause-in-inline-script-expected.txt: Added.
* inspector/debugger/pause-in-inline-script.html: Added.
* platform/chromium/inspector/debugger/debugger-scripts-expected.txt:

[email protected]
Review URL: https://chromiumcodereview.appspot.com/9371015

Modified Paths

Added Paths

Diff

Modified: branches/chromium/1025/LayoutTests/inspector/debugger/debugger-scripts-expected.txt (107227 => 107228)


--- branches/chromium/1025/LayoutTests/inspector/debugger/debugger-scripts-expected.txt	2012-02-09 13:39:46 UTC (rev 107227)
+++ branches/chromium/1025/LayoutTests/inspector/debugger/debugger-scripts-expected.txt	2012-02-09 13:46:45 UTC (rev 107228)
@@ -3,19 +3,19 @@
 Debugger was enabled.
 script 1:
     start: 5:8
-    end: 37:2
+    end: 38:0
 script 2:
     start: 38:21
-    end: 41:2
+    end: 42:0
 script 3:
     start: 43:11
     end: 43:32
 script 4:
     start: 44:11
-    end: 44:28
+    end: 45:0
 script 5:
     start: 46:11
-    end: 47:20
+    end: 48:0
 script 6:
     start: 51:56
     end: 52:2

Copied: branches/chromium/1025/LayoutTests/inspector/debugger/pause-in-inline-script-expected.txt (from rev 106468, trunk/LayoutTests/inspector/debugger/pause-in-inline-script-expected.txt) (0 => 107228)


--- branches/chromium/1025/LayoutTests/inspector/debugger/pause-in-inline-script-expected.txt	                        (rev 0)
+++ branches/chromium/1025/LayoutTests/inspector/debugger/pause-in-inline-script-expected.txt	2012-02-09 13:46:45 UTC (rev 107228)
@@ -0,0 +1,19 @@
+Tests that main resource script text is correct when paused in inline script on reload. Bug 77548.
+
+Debugger was enabled.
+Did load front-end
+Paused: false
+didPauseAfterReload
+Script execution paused.
+didShowScript
+Source strings corresponding to the call stack:
+Frame 0) line 6, content: </script><script>function f1() { debugger; }</script> (must be part of function 'f1')
+Frame 1) line 8, content: function f2() { return f1(); } (must be part of function 'f2')
+Frame 2) line 14, content:     return f2(); (must be part of function 'f3')
+Frame 3) line 16, content: f3(); (must be part of function '')
+Script execution resumed.
+didResume
+Page reloaded.
+didReload
+Debugger was disabled.
+

Copied: branches/chromium/1025/LayoutTests/inspector/debugger/pause-in-inline-script.html (from rev 106468, trunk/LayoutTests/inspector/debugger/pause-in-inline-script.html) (0 => 107228)


--- branches/chromium/1025/LayoutTests/inspector/debugger/pause-in-inline-script.html	                        (rev 0)
+++ branches/chromium/1025/LayoutTests/inspector/debugger/pause-in-inline-script.html	2012-02-09 13:46:45 UTC (rev 107228)
@@ -0,0 +1,89 @@
+<html>
+<head>
+<script>function foo() { };
+</script>
+<script>
+function bar() { };
+</script><script>function f1() { debugger; }</script>
+<script>
+function f2() { return f1(); }
+</script>
+
+<script>
+function f3()
+{
+    return f2();
+}
+f3();
+</script>
+
+<script src=""
+<script src=""
+
+<script>
+
+var test = function()
+{
+    var testName = WebInspector.inspectedPageURL;
+    testName = testName.substring(testName.lastIndexOf('/') + 1);
+
+    InspectorTest.startDebuggerTest(step1);
+
+    function step1()
+    {
+        InspectorTest.addResult("Did load front-end");
+        InspectorTest.addResult("Paused: " + !!WebInspector.debuggerModel.debuggerPausedDetails);
+        InspectorTest.reloadPage(didReload.bind(this));
+        WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, didPauseAfterReload, this); 
+
+    }
+
+    function didReload()
+    {
+        InspectorTest.addResult("didReload");
+        InspectorTest.completeDebuggerTest();
+    }
+
+    function didPauseAfterReload(details)
+    {
+        InspectorTest.addResult("didPauseAfterReload");
+        InspectorTest.showScriptSource(testName, didShowScript.bind(this));
+    }
+
+    function didShowScript(sourceFrame)
+    {
+        InspectorTest.addResult("didShowScript");
+        var resourceText = sourceFrame._textModel.text;
+        var lines = resourceText.split("\n");
+        var callFrames = WebInspector.debuggerModel.callFrames;
+        InspectorTest.addResult("Source strings corresponding to the call stack:");
+        for (var i = 0; i < callFrames.length; i++) {
+            var frame = callFrames[i];
+            var lineNumber = frame.location.lineNumber;
+            InspectorTest.addResult("Frame " + i + ") line " + lineNumber + ", content: " + lines[lineNumber] + " (must be part of function '" + frame.functionName + "')");
+        }
+        InspectorTest.resumeExecution(didResume);
+    }
+
+    function uiSourceCodeAdded(uiSourceCode)
+    {
+        InspectorTest.addResult("uiSourceCodeAdded");
+    }
+
+    function didResume()
+    {
+        InspectorTest.addResult("didResume");
+    }
+};
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that main resource script text is correct when paused in inline script on reload.
+<a href="" 77548.</a>
+</p>
+
+</body>
+</html>

Modified: branches/chromium/1025/LayoutTests/platform/chromium/inspector/debugger/debugger-scripts-expected.txt (107227 => 107228)


--- branches/chromium/1025/LayoutTests/platform/chromium/inspector/debugger/debugger-scripts-expected.txt	2012-02-09 13:39:46 UTC (rev 107227)
+++ branches/chromium/1025/LayoutTests/platform/chromium/inspector/debugger/debugger-scripts-expected.txt	2012-02-09 13:46:45 UTC (rev 107228)
@@ -3,19 +3,19 @@
 Debugger was enabled.
 script 1:
     start: 5:8
-    end: 37:2
+    end: 38:0
 script 2:
     start: 38:21
-    end: 41:2
+    end: 42:0
 script 3:
     start: 43:11
     end: 43:32
 script 4:
     start: 44:11
-    end: 44:28
+    end: 45:0
 script 5:
     start: 46:11
-    end: 47:20
+    end: 48:0
 script 6:
     start: 51:56
     end: 52:24

Modified: branches/chromium/1025/Source/WebCore/bindings/js/ScriptDebugServer.cpp (107227 => 107228)


--- branches/chromium/1025/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-02-09 13:39:46 UTC (rev 107227)
+++ branches/chromium/1025/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-02-09 13:46:45 UTC (rev 107228)
@@ -242,7 +242,7 @@
     int sourceLength = script.source.length();
     int lineCount = 1;
     int lastLineStart = 0;
-    for (int i = 0; i < sourceLength - 1; ++i) {
+    for (int i = 0; i < sourceLength; ++i) {
         if (script.source[i] == '\n') {
             lineCount += 1;
             lastLineStart = i + 1;

Modified: branches/chromium/1025/Source/WebCore/bindings/v8/DebuggerScript.js (107227 => 107228)


--- branches/chromium/1025/Source/WebCore/bindings/v8/DebuggerScript.js	2012-02-09 13:39:46 UTC (rev 107227)
+++ branches/chromium/1025/Source/WebCore/bindings/v8/DebuggerScript.js	2012-02-09 13:46:45 UTC (rev 107228)
@@ -90,10 +90,16 @@
     var lineCount = lineEnds.length;
     var endLine = script.line_offset + lineCount - 1;
     var endColumn;
-    if (lineCount === 1)
-        endColumn = script.source.length + script.column_offset;
-    else
-        endColumn = script.source.length - (script.line_ends[lineCount - 2] + 1);
+    // V8 will not count last line if script source ends with \n.
+    if (script.source[script.source.length - 1] === '\n') {
+        endLine += 1;
+        endColumn = 0;
+    } else {
+        if (lineCount === 1)
+            endColumn = script.source.length + script.column_offset;
+        else
+            endColumn = script.source.length - (lineEnds[lineCount - 2] + 1);
+    }
 
     return {
         id: script.id,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to