diff --git a/package.json b/package.json index 31d4976d0a..fabddff3cb 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "main": "index.js", "playwright": { - "chromium_revision": "751710", + "chromium_revision": "754895", "firefox_revision": "1062", "webkit_revision": "1184" }, diff --git a/src/chromium/crBrowser.ts b/src/chromium/crBrowser.ts index 5c47067fed..21d1b52622 100644 --- a/src/chromium/crBrowser.ts +++ b/src/chromium/crBrowser.ts @@ -317,6 +317,13 @@ export class CRBrowserContext extends BrowserContextBase { } async addCookies(cookies: network.SetNetworkCookieParam[]) { + cookies = cookies.map(c => { + const copy = { ...c }; + // Working around setter issue in Chrome. Cookies are now None by default. + if (copy.sameSite === 'None') + delete copy.sameSite; + return copy; + }); await this._browser._session.send('Storage.setCookies', { cookies: network.rewriteCookies(cookies), browserContextId: this._browserContextId || undefined }); } diff --git a/test/cookies.spec.js b/test/cookies.spec.js index d088c6f057..deeb4a529a 100644 --- a/test/cookies.spec.js +++ b/test/cookies.spec.js @@ -421,11 +421,10 @@ module.exports.describe = function({testRunner, expect, browserType, defaultBrow sameSite: 'None', }]); }); - it('should set cookies from a frame', async({context, page, server}) => { - await page.goto(server.PREFIX + '/grid.html'); + it('should set cookies for a frame', async({context, page, server}) => { + await page.goto(server.EMPTY_PAGE); await context.addCookies([ - {url: server.PREFIX, name: 'localhost-cookie', value: 'best'}, - {url: server.CROSS_PROCESS_PREFIX, name: '127-cookie', value: 'worst'} + {url: server.PREFIX, name: 'frame-cookie', value: 'value'} ]); await page.evaluate(src => { let fulfill; @@ -435,32 +434,9 @@ module.exports.describe = function({testRunner, expect, browserType, defaultBrow iframe.onload = fulfill; iframe.src = src; return promise; - }, server.CROSS_PROCESS_PREFIX); + }, server.PREFIX + '/grid.html'); - expect(await page.evaluate('document.cookie')).toBe('localhost-cookie=best'); - expect(await page.frames()[1].evaluate('document.cookie')).toBe('127-cookie=worst'); - - expect(await context.cookies(server.PREFIX)).toEqual([{ - name: 'localhost-cookie', - value: 'best', - domain: 'localhost', - path: '/', - expires: -1, - httpOnly: false, - secure: false, - sameSite: 'None', - }]); - - expect(await context.cookies(server.CROSS_PROCESS_PREFIX)).toEqual([{ - name: '127-cookie', - value: 'worst', - domain: '127.0.0.1', - path: '/', - expires: -1, - httpOnly: false, - secure: false, - sameSite: 'None', - }]); + expect(await page.frames()[1].evaluate('document.cookie')).toBe('frame-cookie=value'); }); });