@@ -130,7 +130,7 @@ it('should include websocket handshake headers and status', async ({ contextFact
130130 expect ( responseHeaderNames ) . toContain ( 'sec-websocket-accept' ) ;
131131} ) ;
132132
133- async function testWebSocketMessages ( contextFactory , server , testInfo , content ) {
133+ async function testWebSocketMessages ( contextFactory , server , testInfo , content , channel ? ) {
134134 const incomingText = [ 'x' . repeat ( 125 ) , 'x' . repeat ( 126 ) , 'x' . repeat ( 2 ** 16 ) ] ;
135135 const incomingBinary = [ ( new Array ( 125 ) ) . fill ( 0x01 ) , ( new Array ( 126 ) ) . fill ( 0x01 ) , ( new Array ( 2 ** 16 ) ) . fill ( 0x01 ) ] ;
136136 const outgoingText = [ 'y' . repeat ( 125 ) , 'y' . repeat ( 126 ) , 'y' . repeat ( 2 ** 16 ) ] ;
@@ -198,23 +198,27 @@ async function testWebSocketMessages(contextFactory, server, testInfo, content)
198198 ...outgoingText . map ( m => ( { type : 'send' , opcode : 1 , data : m } ) ) ,
199199 ...outgoingBinary . map ( m => ( { type : 'send' , opcode : 2 , data : m } ) ) ,
200200 ] ) ;
201- for ( const m of messages ) {
202- expect ( m . time ) . toBeGreaterThanOrEqual ( beforeMs - 1 ) ;
203- expect ( m . time ) . toBeLessThanOrEqual ( afterMs + 1 ) ;
201+ // The WSL VM clock drifts relative to the Windows host clock, so the browser-reported
202+ // message times cannot be compared against the host wall clock.
203+ if ( channel !== 'webkit-wsl' ) {
204+ for ( const m of messages ) {
205+ expect ( m . time ) . toBeGreaterThanOrEqual ( beforeMs - 1 ) ;
206+ expect ( m . time ) . toBeLessThanOrEqual ( afterMs + 1 ) ;
207+ }
204208 }
205209 expect ( messages [ 0 ] . time ) . toBeLessThanOrEqual ( messages [ 1 ] . time ) ;
206210 expect ( wsEntry . time ) . toBeGreaterThanOrEqual ( messages [ messages . length - 1 ] . time - messages [ 0 ] . time ) ;
207211}
208212
209- it ( 'should embed websocket messages' , async ( { contextFactory, server } , testInfo ) => {
210- await testWebSocketMessages ( contextFactory , server , testInfo , 'embed' ) ;
213+ it ( 'should embed websocket messages' , async ( { contextFactory, server, channel } , testInfo ) => {
214+ await testWebSocketMessages ( contextFactory , server , testInfo , 'embed' , channel ) ;
211215} ) ;
212216
213- it ( 'should attach websocket messages' , async ( { contextFactory, server } , testInfo ) => {
214- await testWebSocketMessages ( contextFactory , server , testInfo , 'attach' ) ;
217+ it ( 'should attach websocket messages' , async ( { contextFactory, server, channel } , testInfo ) => {
218+ await testWebSocketMessages ( contextFactory , server , testInfo , 'attach' , channel ) ;
215219} ) ;
216220
217- it ( 'should attach websocket messages for a still open websocket after stopping' , async ( { contextFactory, server } , testInfo ) => {
221+ it ( 'should attach websocket messages for a still open websocket after stopping' , async ( { contextFactory, server, channel } , testInfo ) => {
218222 const incomingText = 'incoming' ;
219223 const incomingBinary = [ 0x01 , 0x02 , 0x03 , 0x04 ] ;
220224 const outgoingText = 'outgoing' ;
@@ -271,9 +275,13 @@ it('should attach websocket messages for a still open websocket after stopping',
271275 { type : 'send' , opcode : 2 , data : outgoingBinary } ,
272276 { type : 'receive' , opcode : 2 , data : incomingBinary } ,
273277 ] ) ;
274- for ( const m of messages ) {
275- expect ( m . time ) . toBeGreaterThanOrEqual ( beforeMs - 1 ) ;
276- expect ( m . time ) . toBeLessThanOrEqual ( afterMs + 1 ) ;
278+ // The WSL VM clock drifts relative to the Windows host clock, so the browser-reported
279+ // message times cannot be compared against the host wall clock.
280+ if ( channel !== 'webkit-wsl' ) {
281+ for ( const m of messages ) {
282+ expect ( m . time ) . toBeGreaterThanOrEqual ( beforeMs - 1 ) ;
283+ expect ( m . time ) . toBeLessThanOrEqual ( afterMs + 1 ) ;
284+ }
277285 }
278286 expect ( messages [ 0 ] . time ) . toBeLessThanOrEqual ( messages [ 1 ] . time ) ;
279287 expect ( wsEntry . time ) . toBeGreaterThanOrEqual ( messages [ messages . length - 1 ] . time - messages [ 0 ] . time ) ;
@@ -283,7 +291,8 @@ it('should omit websocket messages', async ({ contextFactory, server }, testInfo
283291 await testWebSocketMessages ( contextFactory , server , testInfo , 'omit' ) ;
284292} ) ;
285293
286- it ( 'should record websocket connection failure' , async ( { contextFactory, server } , testInfo ) => {
294+ it ( 'should record websocket connection failure' , async ( { contextFactory, server, channel } , testInfo ) => {
295+ it . skip ( channel === 'webkit-wsl' , 'Connection to an unbound localhost port from WSL is not refused in mirrored networking mode' ) ;
287296 // Reserve a port and immediately release it so the WebSocket connect attempt is refused.
288297 const portReservation = net . createServer ( ) ;
289298 await new Promise < void > ( resolve => portReservation . listen ( 0 , '127.0.0.1' , ( ) => resolve ( ) ) ) ;
0 commit comments