@@ -13,6 +13,7 @@ const fs = require('fs');
1313const resourceUrl = 'http://localhost:3000/app.js' ;
1414const resourcePath = path . join ( __dirname , '../fixtures/inspector-network-resource/app.js.map' ) ;
1515
16+ const resourceText = fs . readFileSync ( resourcePath , 'utf8' ) ;
1617const script = `
1718 const { NetworkResources } = require('node:inspector');
1819 const fs = require('fs');
@@ -55,8 +56,7 @@ test('should load and stream a static network resource using loadNetworkResource
5556 eof = result . eof ;
5657 }
5758 content += data ;
58- const expected = fs . readFileSync ( resourcePath , 'utf8' ) ;
59- assert . strictEqual ( content , expected ) ;
59+ assert . strictEqual ( content , resourceText ) ;
6060 await session . send ( { method : 'IO.close' , params : { handle : resource . stream } } ) ;
6161 await session . send ( { method : 'Debugger.resume' } ) ;
6262 await session . waitForDisconnect ( ) ;
@@ -98,13 +98,12 @@ test('should support IO.read with size and offset', async () => {
9898 } ) ;
9999 assert ( resource . success ) ;
100100 assert ( resource . stream ) ;
101- const expected = fs . readFileSync ( resourcePath , 'utf8' ) ;
102101 let result = await session . send ( { method : 'IO.read' , params : { handle : resource . stream , size : 5 } } ) ;
103- assert . strictEqual ( result . data , expected . slice ( 0 , 5 ) ) ;
102+ assert . strictEqual ( result . data , resourceText . slice ( 0 , 5 ) ) ;
104103 result = await session . send ( { method : 'IO.read' , params : { handle : resource . stream , offset : 5 , size : 5 } } ) ;
105- assert . strictEqual ( result . data , expected . slice ( 5 , 10 ) ) ;
104+ assert . strictEqual ( result . data , resourceText . slice ( 5 , 10 ) ) ;
106105 result = await session . send ( { method : 'IO.read' , params : { handle : resource . stream , offset : 10 } } ) ;
107- assert . strictEqual ( result . data , expected . slice ( 10 ) ) ;
106+ assert . strictEqual ( result . data , resourceText . slice ( 10 ) ) ;
108107 await session . send ( { method : 'IO.close' , params : { handle : resource . stream } } ) ;
109108 await session . send ( { method : 'Debugger.resume' } ) ;
110109 await session . waitForDisconnect ( ) ;
@@ -131,12 +130,16 @@ test('should load resource put from another thread', async () => {
131130 await setupInspector ( session ) ;
132131 await session . waitForNotification ( 'Debugger.paused' ) ;
133132 await session . send ( { method : 'Debugger.resume' } ) ;
134- const sessionId = '1' ;
135133 await session . waitForNotification ( 'Target.targetCreated' ) ;
136134 await session . send ( { method : 'Target.setAutoAttach' , params : { autoAttach : true , waitForDebuggerOnStart : true } } ) ;
135+ let sessionId ;
137136 await session . waitForNotification ( ( notification ) => {
138- return notification . method === 'Target.attachedToTarget' &&
139- notification . params . sessionId === sessionId ;
137+ if ( notification . method === 'Target.attachedToTarget' ) {
138+ sessionId = notification . params . sessionId ;
139+ return true ;
140+ }
141+ return false ;
142+
140143 } ) ;
141144 await setupInspector ( session , sessionId ) ;
142145
@@ -160,8 +163,7 @@ test('should load resource put from another thread', async () => {
160163 eof = result . eof ;
161164 }
162165 content += data ;
163- const expected = fs . readFileSync ( resourcePath , 'utf8' ) ;
164- assert . strictEqual ( content , expected ) ;
166+ assert . strictEqual ( content , resourceText ) ;
165167 await session . send ( { method : 'IO.close' , params : { handle : resource . stream , sessionId } } ) ;
166168
167169 await session . send ( { method : 'Debugger.resume' , sessionId } ) ;
0 commit comments