Skip to content
Permalink
Browse files
Web Inspector: debugger reports wrong sources when paused in inline s…
…cript 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:

Canonical link: https://commits.webkit.org/94422@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
yury-s committed Feb 1, 2012
1 parent 738f8ce commit 3bee60d3fe07ebc0d540bda59fd4b43a3bb7194e
Showing 8 changed files with 156 additions and 13 deletions.
@@ -1,3 +1,15 @@
2012-02-01 Yury Semikhatsky <yurys@chromium.org>

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

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:

2012-02-01 Shinya Kawanaka <shinyak@google.com>

Content element should be able to be dynamically added/removed/replaced in a shadow tree.
@@ -3,19 +3,19 @@ Tests that valid parsed script notifications are received by front-end. Bug 5272
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
@@ -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.

@@ -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="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>

<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="https://bugs.webkit.org/show_bug.cgi?id=77548">Bug 77548.</a>
</p>

</body>
</html>
@@ -3,19 +3,19 @@ Tests that valid parsed script notifications are received by front-end. Bug 5272
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
@@ -1,3 +1,20 @@
2012-02-01 Yury Semikhatsky <yurys@chromium.org>

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

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:

2012-02-01 Shinya Kawanaka <shinyak@google.com>

Content element should be able to be dynamically added/removed/replaced in a shadow tree.
@@ -242,7 +242,7 @@ void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, Sou
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;
@@ -90,10 +90,16 @@ DebuggerScript._formatScript = function(script)
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,

0 comments on commit 3bee60d

Please sign in to comment.