@@ -300,7 +300,7 @@ it('should set cookie with reasonable defaults', async ({ context, server, defau
300300 expect ( cookies . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ) . toEqual ( [ {
301301 name : 'defaults' ,
302302 value : '123456' ,
303- domain : 'localhost' ,
303+ domain : new URL ( server . EMPTY_PAGE ) . hostname ,
304304 path : '/' ,
305305 expires : - 1 ,
306306 httpOnly : false ,
@@ -312,7 +312,7 @@ it('should set cookie with reasonable defaults', async ({ context, server, defau
312312it ( 'should set a cookie with a path' , async ( { context, page, server, browserName, isWindows, channel } ) => {
313313 await page . goto ( server . PREFIX + '/grid.html' ) ;
314314 await context . addCookies ( [ {
315- domain : 'localhost' ,
315+ domain : new URL ( server . EMPTY_PAGE ) . hostname ,
316316 path : '/grid.html' ,
317317 name : 'gridcookie' ,
318318 value : 'GRID' ,
@@ -321,7 +321,7 @@ it('should set a cookie with a path', async ({ context, page, server, browserNam
321321 expect ( await context . cookies ( ) ) . toEqual ( [ {
322322 name : 'gridcookie' ,
323323 value : 'GRID' ,
324- domain : 'localhost' ,
324+ domain : new URL ( server . EMPTY_PAGE ) . hostname ,
325325 path : '/grid.html' ,
326326 expires : - 1 ,
327327 httpOnly : false ,
@@ -459,8 +459,8 @@ it('should set secure cookies on secure WebSocket', async ({ contextFactory, htt
459459 const context = await contextFactory ( { ignoreHTTPSErrors : true } ) ;
460460 const page = await context . newPage ( ) ;
461461 await page . goto ( httpsServer . EMPTY_PAGE ) ;
462- await context . addCookies ( [ { domain : 'localhost' , path : '/' , name : 'foo' , value : 'bar' , secure : true } ] ) ;
463- await page . evaluate ( port => new WebSocket ( `wss://localhost :${ port } /ws` ) , httpsServer . PORT ) ;
462+ await context . addCookies ( [ { domain : new URL ( httpsServer . PREFIX ) . hostname , path : '/' , name : 'foo' , value : 'bar' , secure : true } ] ) ;
463+ await page . evaluate ( ( { hostname , port } ) => new WebSocket ( `wss://${ hostname } :${ port } /ws` ) , { hostname : new URL ( httpsServer . PREFIX ) . hostname , port : httpsServer . PORT } ) ;
464464 const headers = await receivedWebSocketHeaders ;
465465 expect ( headers . cookie ) . toBe ( 'foo=bar' ) ;
466466} ) ;
0 commit comments