Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add repro for broken cookies in frames in webkit on linux (#35510)

Simon Knott265e73375232
diff --git a/tests/library/browsercontext-cookies.spec.ts b/tests/library/browsercontext-cookies.spec.ts
index 996230047a..05604561d1 100644
--- a/tests/library/browsercontext-cookies.spec.ts
+++ b/tests/library/browsercontext-cookies.spec.ts
@@ -429,3 +429,34 @@ it('should parse cookie with large Max-Age correctly', async ({ server, page, de
},
]);
});
+
+it('iframe should inherit cookies from parent', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/35439' } }, async ({ page, isLinux, browserName }) => {
+ it.fixme(browserName === 'webkit' && isLinux, 'https://bugs.webkit.org/show_bug.cgi?id=291194');
+
+ await page.route('**/*', async (route, request) => {
+ if (request.url().includes('sub.example.test')) {
+ await route.fulfill({
+ body: `
+ <p id="result"></p>
+ <script>document.getElementById('result').textContent = document.cookie || 'no cookies';</script>
+ `,
+ contentType: 'text/html',
+ });
+ return;
+ }
+ await route.fulfill({
+ headers: { 'set-cookie': 'testCookie=value; SameSite=Lax; Domain=example.test' },
+ contentType: 'text/html',
+ body: `
+ <p id="result"></p>
+ <script>document.getElementById('result').textContent = document.cookie || 'no cookies';</script>
+ <iframe src="http://sub.example.test"></iframe>
+ `
+ });
+ });
+
+ await page.goto('http://example.test');
+
+ await expect(page.locator('body')).toContainText('testCookie=value');
+ await expect(page.frameLocator('iframe').locator('body')).toContainText('testCookie=value');
+});