@@ -300,7 +300,7 @@ it('should set cookie with reasonable defaults', async ({ context, server, defau
300
300
expect ( cookies . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ) . toEqual ( [ {
301
301
name : 'defaults' ,
302
302
value : '123456' ,
303
- domain : 'localhost' ,
303
+ domain : new URL ( server . EMPTY_PAGE ) . hostname ,
304
304
path : '/' ,
305
305
expires : - 1 ,
306
306
httpOnly : false ,
@@ -312,7 +312,7 @@ it('should set cookie with reasonable defaults', async ({ context, server, defau
312
312
it ( 'should set a cookie with a path' , async ( { context, page, server, browserName, isWindows, channel } ) => {
313
313
await page . goto ( server . PREFIX + '/grid.html' ) ;
314
314
await context . addCookies ( [ {
315
- domain : 'localhost' ,
315
+ domain : new URL ( server . EMPTY_PAGE ) . hostname ,
316
316
path : '/grid.html' ,
317
317
name : 'gridcookie' ,
318
318
value : 'GRID' ,
@@ -321,7 +321,7 @@ it('should set a cookie with a path', async ({ context, page, server, browserNam
321
321
expect ( await context . cookies ( ) ) . toEqual ( [ {
322
322
name : 'gridcookie' ,
323
323
value : 'GRID' ,
324
- domain : 'localhost' ,
324
+ domain : new URL ( server . EMPTY_PAGE ) . hostname ,
325
325
path : '/grid.html' ,
326
326
expires : - 1 ,
327
327
httpOnly : false ,
@@ -459,8 +459,8 @@ it('should set secure cookies on secure WebSocket', async ({ contextFactory, htt
459
459
const context = await contextFactory ( { ignoreHTTPSErrors : true } ) ;
460
460
const page = await context . newPage ( ) ;
461
461
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 } ) ;
464
464
const headers = await receivedWebSocketHeaders ;
465
465
expect ( headers . cookie ) . toBe ( 'foo=bar' ) ;
466
466
} ) ;
0 commit comments