@@ -5,45 +5,27 @@ common.skipIfInspectorDisabled();
55const assert = require ( 'assert' ) ;
66const { NodeInstance } = require ( '../common/inspector-helper.js' ) ;
77
8- const stderrMessages = [ ] ;
9-
108async function runTests ( ) {
119 const child = new NodeInstance ( [ '--inspect-brk=0' ] ,
12- `const interval = setInterval(() => {
13- console.log(new Object());
14- }, 200);
15- process.stdin.on('data', (msg) => {
16- if (msg.toString() === 'fhqwhgads') {
17- clearInterval(interval);
18- process.exit();
19- }
20- });` ) ;
21-
22- child . _process . stderr . on ( 'data' , async ( data ) => {
23- const message = data . toString ( ) ;
24- stderrMessages . push ( message ) ;
25- if ( message . trim ( ) === 'Waiting for the debugger to disconnect...' ) {
26- await session . send ( { 'method' : 'Profiler.stop' } ) ;
27- session . disconnect ( ) ;
28- assert . strictEqual ( 0 , ( await child . expectShutdown ( ) ) . exitCode ) ;
29- }
30- } )
10+ `let c = 0;
11+ const interval = setInterval(() => {
12+ console.log(new Object());
13+ if (c++ === 10)
14+ clearInterval(interval);
15+ }, ${ common . platformTimeout ( 30 ) } );` ) ;
3116 const session = await child . connectInspectorSession ( ) ;
3217
3318 session . send ( [
34- { 'method' : 'Profiler.setSamplingInterval' , 'params' : { 'interval' : 2000 } } ,
35- { 'method' : 'Profiler.enable' } ,
36- { 'method' : 'Runtime.runIfWaitingForDebugger' }
37- ] ) ;
38-
39- await child . nextStderrString ( ) ;
40- await child . nextStderrString ( ) ;
41- await child . nextStderrString ( ) ;
42- const stderrString = await child . nextStderrString ( ) ;
43- assert . strictEqual ( stderrString , 'Debugger attached.' ) ;
44-
45- session . send ( { 'method' : 'Profiler.start' } )
46- setTimeout ( ( ) => { child . _process . stdin . write ( 'fhqwhgads' ) ; } , 4000 ) ;
19+ { method : 'Profiler.setSamplingInterval' ,
20+ params : { interval : common . platformTimeout ( 300 ) } } ,
21+ { method : 'Profiler.enable' } ,
22+ { method : 'Runtime.runIfWaitingForDebugger' } ,
23+ { method : 'Profiler.start' } ] ) ;
24+ while ( await child . nextStderrString ( ) !==
25+ 'Waiting for the debugger to disconnect...' ) ;
26+ await session . send ( { method : 'Profiler.stop' } ) ;
27+ session . disconnect ( ) ;
28+ assert . strictEqual ( 0 , ( await child . expectShutdown ( ) ) . exitCode ) ;
4729}
4830
4931common . crashOnUnhandledRejection ( ) ;
0 commit comments