Skip to content

Commit 59a2cb5

Browse files
dgozmanMylesBorins
authored andcommitted
inspector: do not hardcode Debugger.CallFrameId in tests
Debugger.CallFrameId is defined as an opaque string [1]. Some tests currently hardcode the value, relying on undocumented internal details of V8. This makes it hard for V8 to change the internal representation. We should instead use the reported call frame id from the Debugger.paused event directly. This is how every inspector client does it. [1] https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#type-CallFrameId PR-URL: #35570 Reviewed-By: Aleksei Koziatinskii <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 4025fc8 commit 59a2cb5

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

‎test/common/inspector-helper.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class InspectorSession{
130130
this._unprocessedNotifications=[];
131131
this._notificationCallback=null;
132132
this._scriptsIdsByUrl=newMap();
133+
this._pausedDetails=null;
133134

134135
letbuffer=Buffer.alloc(0);
135136
socket.on('data',(data)=>{
@@ -179,6 +180,10 @@ class InspectorSession{
179180
this.mainScriptId=scriptId;
180181
}
181182
}
183+
if(message.method==='Debugger.paused')
184+
this._pausedDetails=message.params;
185+
if(message.method==='Debugger.resumed')
186+
this._pausedDetails=null;
182187

183188
if(this._notificationCallback){
184189
// In case callback needs to install another
@@ -267,6 +272,10 @@ class InspectorSession{
267272
`break on ${url}:${line}`);
268273
}
269274

275+
pausedDetails(){
276+
returnthis._pausedDetails;
277+
}
278+
270279
_matchesConsoleOutputNotification(notification,type,values){
271280
if(!Array.isArray(values))
272281
values=[values];

‎test/parallel/test-inspector-esm.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async function testBreakpoint(session){
7878

7979
let{ result }=awaitsession.send({
8080
'method': 'Debugger.evaluateOnCallFrame','params': {
81-
'callFrameId': '{"ordinal":0,"injectedScriptId":1}',
81+
'callFrameId': session.pausedDetails().callFrames[0].callFrameId,
8282
'expression': 'k + t',
8383
'objectGroup': 'console',
8484
'includeCommandLineAPI': true,

‎test/sequential/test-inspector.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async function testBreakpoint(session){
116116

117117
let{ result }=awaitsession.send({
118118
'method': 'Debugger.evaluateOnCallFrame','params': {
119-
'callFrameId': '{"ordinal":0,"injectedScriptId":1}',
119+
'callFrameId': session.pausedDetails().callFrames[0].callFrameId,
120120
'expression': 'k + t',
121121
'objectGroup': 'console',
122122
'includeCommandLineAPI': true,
@@ -150,7 +150,7 @@ async function testI18NCharacters(session){
150150
constchars='טֶ字и';
151151
session.send({
152152
'method': 'Debugger.evaluateOnCallFrame','params': {
153-
'callFrameId': '{"ordinal":0,"injectedScriptId":1}',
153+
'callFrameId': session.pausedDetails().callFrames[0].callFrameId,
154154
'expression': `console.log("${chars}")`,
155155
'objectGroup': 'console',
156156
'includeCommandLineAPI': true,
@@ -276,7 +276,7 @@ async function testCommandLineAPI(session){
276276
result=awaitsession.send(
277277
{
278278
'method': 'Debugger.evaluateOnCallFrame','params': {
279-
'callFrameId': '{"ordinal":0,"injectedScriptId":1}',
279+
'callFrameId': session.pausedDetails().callFrames[0].callFrameId,
280280
'expression': `(
281281
require(${printBModuleStr}),
282282
require.cache[${printBModuleStr}].parent.id

0 commit comments

Comments
(0)