@@ -5,45 +5,27 @@ common.skipIfInspectorDisabled();
5
5
const assert = require ( 'assert' ) ;
6
6
const { NodeInstance } = require ( '../common/inspector-helper.js' ) ;
7
7
8
- const stderrMessages = [ ] ;
9
-
10
8
async function runTests ( ) {
11
9
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 ) } );` ) ;
31
16
const session = await child . connectInspectorSession ( ) ;
32
17
33
18
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 ) ;
47
29
}
48
30
49
31
common . crashOnUnhandledRejection ( ) ;
0 commit comments