@@ -26,23 +26,23 @@ module.exports.describe = function({testRunner, expect, product, browserType, pl
2626 const { it, fit, xit, dit} = testRunner ;
2727 const { beforeAll, beforeEach, afterAll, afterEach} = testRunner ;
2828
29- async function testSignal ( action ) {
29+ async function testSignal ( action , exitOnClose ) {
3030 const options = Object . assign ( { } , defaultBrowserOptions , {
3131 // Disable DUMPIO to cleanly read stdout.
3232 dumpio : false ,
3333 handleSIGINT : true ,
3434 handleSIGTERM : true ,
3535 handleSIGHUP : true ,
3636 } ) ;
37- const res = spawn ( 'node' , [ path . join ( __dirname , 'fixtures' , 'closeme.js' ) , playwrightPath , product , JSON . stringify ( options ) ] ) ;
37+ const res = spawn ( 'node' , [ path . join ( __dirname , 'fixtures' , 'closeme.js' ) , playwrightPath , product , JSON . stringify ( options ) , exitOnClose ? 'true' : '' ] ) ;
3838 let wsEndPointCallback ;
3939 const wsEndPointPromise = new Promise ( x => wsEndPointCallback = x ) ;
4040 let output = '' ;
4141 let browserExitCode = 'none' ;
4242 let browserSignal = 'none' ;
4343 let browserPid ;
4444 res . stdout . on ( 'data' , data => {
45- output += data ;
45+ output += data . toString ( ) ;
4646 // Uncomment to debug these tests.
4747 // console.log(data.toString());
4848 let match = output . match ( / b r o w s e r W S : ( .+ ) : b r o w s e r W S / ) ;
@@ -94,23 +94,18 @@ module.exports.describe = function({testRunner, expect, product, browserType, pl
9494 // We might not get browser exitCode in time when killing the parent node process,
9595 // so we don't check it here.
9696 } ) ;
97- if ( ! WIN ) {
97+
98+ describe . skip ( WIN ) ( 'signals' , ( ) => {
9899 // Cannot reliably send signals on Windows.
99100 it . slow ( ) ( 'should report browser close signal' , async ( ) => {
100- const result = await testSignal ( ( child , browserPid ) => {
101- process . kill ( browserPid ) ;
102- process . kill ( child . pid , 'SIGINT' ) ;
103- } ) ;
104- expect ( result . exitCode ) . toBe ( 130 ) ;
101+ const result = await testSignal ( ( child , browserPid ) => process . kill ( browserPid ) , true ) ;
102+ expect ( result . exitCode ) . toBe ( 0 ) ;
105103 expect ( result . browserExitCode ) . toBe ( 'null' ) ;
106104 expect ( result . browserSignal ) . toBe ( 'SIGTERM' ) ;
107105 } ) ;
108- it . slow ( ) ( 'should report browser close signal 2' , async ( ) => {
109- const result = await testSignal ( ( child , browserPid ) => {
110- process . kill ( browserPid , 'SIGKILL' ) ;
111- process . kill ( child . pid , 'SIGINT' ) ;
112- } ) ;
113- expect ( result . exitCode ) . toBe ( 130 ) ;
106+ it . slow ( ) ( 'should report browser close signal 2' , async ( state , test ) => {
107+ const result = await testSignal ( ( child , browserPid ) => process . kill ( browserPid , 'SIGKILL' ) , true ) ;
108+ expect ( result . exitCode ) . toBe ( 0 ) ;
114109 expect ( result . browserExitCode ) . toBe ( 'null' ) ;
115110 expect ( result . browserSignal ) . toBe ( 'SIGKILL' ) ;
116111 } ) ;
@@ -159,6 +154,6 @@ module.exports.describe = function({testRunner, expect, product, browserType, pl
159154 // TODO: ideally, we would expect the SIGKILL on the browser from
160155 // force kill, but that's racy with sending two signals.
161156 } ) ;
162- }
157+ } ) ;
163158 } ) ;
164159} ;
0 commit comments