From 8f1f4946bffbf67c3d074f30fbacc22a9ceee479 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 2 Sep 2022 20:00:55 +0200 Subject: [PATCH] test: send cookies via an embedded iframe (#17036) --- tests/library/browsercontext-cookies.spec.ts | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/library/browsercontext-cookies.spec.ts b/tests/library/browsercontext-cookies.spec.ts index e1d139a768..56a2bdfc90 100644 --- a/tests/library/browsercontext-cookies.spec.ts +++ b/tests/library/browsercontext-cookies.spec.ts @@ -320,3 +320,32 @@ it('should add cookies with an expiration', async ({ context }) => { expires: -42, }])).rejects.toThrow(/Cookie should have a valid expires/); }); + +it('should be able to send third party cookies via an iframe', async ({ browser, httpsServer, browserName }) => { + it.fixme(browserName === 'firefox' || browserName === 'webkit'); + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/16937' }); + + const context = await browser.newContext({ + ignoreHTTPSErrors: true, + }); + try { + const page = await context.newPage(); + await page.goto(httpsServer.EMPTY_PAGE); + await context.addCookies([{ + domain: new URL(httpsServer.CROSS_PROCESS_PREFIX).hostname, + path: '/', + name: 'cookie1', + value: 'yes', + httpOnly: true, + secure: true, + sameSite: 'None' + }]); + const [response] = await Promise.all([ + httpsServer.waitForRequest('/grid.html'), + page.setContent(``) + ]); + expect(response.headers['cookie']).toBe('cookie1=yes'); + } finally { + await context.close(); + } +});