@@ -47,37 +47,33 @@ check('process', () => {
4747
4848function check ( backend , start ) {
4949 const { runner, stop } = start ( ) ;
50- let sawResult = false ;
5150
5251 const timeout = setTimeout ( ( ) => {
5352 stop ( ) ;
5453 assert . fail ( `WPT worker error was not reported on the ${ backend } backend` ) ;
5554 } , common . platformTimeout ( 1000 ) ) ;
5655
56+ const onCompletion = common . mustCall ( ( status ) => {
57+ clearTimeout ( timeout ) ;
58+ assert . strictEqual ( status . status , 1 ) ;
59+ assert . strictEqual ( status . message , 'probe error after first result' ) ;
60+ stop ( ) ;
61+ } ) ;
62+
5763 runner . on ( 'error' , common . mustNotCall ( ) ) ;
58- runner . on ( 'message' , common . mustCall ( ( message ) => {
64+ // The error reaches the runner straight from the Web Worker while results
65+ // travel through the harness, so it can arrive before them.
66+ runner . on ( 'message' , common . mustCallAtLeast ( ( message ) => {
5967 switch ( message . type ) {
6068 case 'result' :
6169 assert . strictEqual ( message . result . name , 'reported before error' ) ;
6270 assert . strictEqual ( message . result . status , 0 ) ;
63- sawResult = true ;
6471 break ;
6572 case 'completion' :
66- clearTimeout ( timeout ) ;
67- assert . strictEqual ( message . status . status , 1 ) ;
68- assert . strictEqual (
69- message . status . message ,
70- 'probe error after first result' ,
71- ) ;
72- stop ( ) ;
73+ onCompletion ( message . status ) ;
7374 break ;
7475 default :
7576 assert . fail ( `Unexpected message type: ${ message . type } ` ) ;
7677 }
77- } , 2 ) ) ;
78-
79- process . on ( 'exit' , ( ) => {
80- assert . ok ( sawResult ,
81- `the result reported before the error was not forwarded on the ${ backend } backend` ) ;
82- } ) ;
78+ } , 1 ) ) ;
8379}
0 commit comments