File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 33
44const common = require ( '../common' ) ;
55const assert = require ( 'assert' ) ;
6+ const util = require ( 'util' ) ;
67const { MessageChannel } = require ( 'worker_threads' ) ;
78
89const { port1, port2 } = new MessageChannel ( ) ;
@@ -25,9 +26,22 @@ assert.throws(common.mustCall(() => {
2526// The failed transfer should not affect the ports in anyway.
2627port2 . onmessage = common . mustCall ( ( message ) => {
2728 assert . strictEqual ( message , 2 ) ;
29+
30+ assert ( util . inspect ( port1 ) . includes ( 'active: true' ) , util . inspect ( port1 ) ) ;
31+ assert ( util . inspect ( port2 ) . includes ( 'active: true' ) , util . inspect ( port2 ) ) ;
32+
2833 port1 . close ( ) ;
2934
30- setTimeout ( common . mustNotCall ( 'The communication channel is still open' ) ,
31- common . platformTimeout ( 1000 ) ) . unref ( ) ;
35+ tick ( 10 , ( ) => {
36+ assert ( util . inspect ( port1 ) . includes ( 'active: false' ) , util . inspect ( port1 ) ) ;
37+ assert ( util . inspect ( port2 ) . includes ( 'active: false' ) , util . inspect ( port2 ) ) ;
38+ } ) ;
3239} ) ;
3340port1 . postMessage ( 2 ) ;
41+
42+ function tick ( n , cb ) {
43+ if ( n > 0 )
44+ setImmediate ( ( ) => tick ( n - 1 , cb ) ) ;
45+ else
46+ cb ( ) ;
47+ }
You can’t perform that action at this time.
0 commit comments