Skip to content

Commit 996f659

Browse files
committed
Web Inspector: use zero-based Debugger.Location for InjectedScript.CallFrameProxy
https://bugs.webkit.org/show_bug.cgi?id=327972 Reviewed by Timothy Hatcher. `SymbolTable` keeps one-based locations which are later used for `Debugger.Location` which expects zero-based coordinates. Look at uses of `ScriptExecutable::firstLine` and `ScriptExecutable::startColumn` for how `SymbolTable` is populated. * Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp: (Inspector::valueForScopeLocation): * LayoutTests/inspector/debugger/getFunctionDetails.html: * LayoutTests/inspector/debugger/getFunctionDetails-expected.txt: * LayoutTests/inspector/debugger/paused-scopes-expected.txt: Canonical link: https://commits.webkit.org/324170@main
1 parent 6247349 commit 996f659

4 files changed

Lines changed: 129 additions & 87 deletions

File tree

‎LayoutTests/inspector/debugger/getFunctionDetails-expected.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Tests for Debugger.getFunctionDetails command.
22

3+
3
34

45
== Running test suite: Debugger.getFunctionDetails
56
-- Running test case: Debugger.getFunctionDetails.Regular
@@ -38,3 +39,10 @@ PASS: Should have source code column.
3839
PASS: Should have name.
3940
PASS: Should not have displayName.
4041

42+
-- Running test case: Debugger.getFunctionDetails.ScopeLocation
43+
PASS: Scope and function details should identify the same script.
44+
PASS: Scope and function details should use the same zero-based line.
45+
PASS: Scope and function details should use the same zero-based column.
46+
PASS: The actual paused scope should contain the initialized page value.
47+
PASS: Resuming should finish the page operation.
48+

‎LayoutTests/inspector/debugger/getFunctionDetails.html‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
let arrowBoundTwice = arrowBoundOnce.bind();
2121

22+
function scopeLocationProbe(parameter)
23+
{
24+
let local = parameter + 1;
25+
debugger;
26+
return local;
27+
}
28+
2229
function test()
2330
{
2431
let suite = InspectorTest.createAsyncSuite("Debugger.getFunctionDetails");
@@ -101,11 +108,37 @@
101108
},
102109
});
103110

111+
suite.addTestCase({
112+
name: "Debugger.getFunctionDetails.ScopeLocation",
113+
async test() {
114+
let remoteObject = await InspectorTest.evaluateInPage("scopeLocationProbe", {remoteObjectOnly: true});
115+
let {details} = await DebuggerAgent.getFunctionDetails(remoteObject.objectId);
116+
let paused = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
117+
let evaluated = InspectorTest.evaluateInPage("document.querySelector('output').textContent = scopeLocationProbe(2)");
118+
await paused;
119+
120+
let scope = WI.debuggerManager.activeCallFrame.scopeChain.find((scope) => scope.name === "scopeLocationProbe" && scope.location);
121+
InspectorTest.assert(scope, "The paused function should report a scope location.");
122+
InspectorTest.expectEqual(scope.location.scriptId, details.location.scriptId, "Scope and function details should identify the same script.");
123+
InspectorTest.expectEqual(scope.location.lineNumber, details.location.lineNumber, "Scope and function details should use the same zero-based line.");
124+
InspectorTest.expectEqual(scope.location.columnNumber, details.location.columnNumber, "Scope and function details should use the same zero-based column.");
125+
let callFrame = WI.debuggerManager.activeCallFrame;
126+
let {result: local} = await callFrame.target.DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: callFrame.id, expression: "local", returnByValue: true});
127+
InspectorTest.expectEqual(local.value, 3, "The actual paused scope should contain the initialized page value.");
128+
129+
await WI.debuggerManager.resume();
130+
await evaluated;
131+
let {result: output} = await RuntimeAgent.evaluate("document.querySelector('output').textContent");
132+
InspectorTest.expectEqual(output.value, "3", "Resuming should finish the page operation.");
133+
},
134+
});
135+
104136
suite.runTestCasesAndFinish();
105137
}
106138
</script>
107139
</head>
108140
<body onload="runTest()">
109141
<p>Tests for Debugger.getFunctionDetails command.</p>
142+
<output>0</output>
110143
</body>
111144
</html>

0 commit comments

Comments
 (0)