playwright: [Bug]: WebKit 18.4: `document.cookie` returns empty string in iframe despite cookie being present in HTTP requests
Version
1.51.1
Steps to reproduce
- Clone the repository at https://github.com/jhogervorst/playwright-webkit-iframe-cookie-issue
- Run
npm install - Start the server:
npm run server - Run the tests:
npm test - The test will fail specifically for WebKit 18.4 on Linux, while passing for all other browsers and platforms
Expected behavior
When a cookie is set on the parent domain with SameSite=Lax and proper domain scoping, it should be accessible via document.cookie within an iframe on a subdomain. This is the behavior observed in Chromium and Firefox, as well as all browsers on macOS.
Actual behavior
In WebKit 18.4 on Linux:
- The cookie is successfully set on the parent domain (verified via
document.cookieon parent page) - The cookie is present in HTTP requests from the iframe (verified via API call)
- However,
document.cookiereturns an empty string within the iframe - This behavior is specific to WebKit 18.4 on Linux - all other browsers and platforms work as expected
The test results can be viewed in the GitHub Actions workflow run at: https://github.com/jhogervorst/playwright-webkit-iframe-cookie-issue/actions/runs/14195304583
Additional context
This issue appears to be related to WebKit 18.4’s handling of cookie access in iframes. The test demonstrates that while the cookie is properly sent in HTTP requests (indicating it’s present in the browser’s cookie store), it’s not accessible via JavaScript in the iframe context. This could be a regression in WebKit’s cookie handling or a change in security policies.
The issue was not present in WebKit 18.2 and its corresponding Playwright version, suggesting this is a regression introduced in WebKit 18.4.
Environment
System:
OS: Linux 6.8 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
CPU: (4) x64 AMD EPYC 7763 64-Core Processor
Memory: 14.55 GB / 15.62 GB
Container: Yes
Binaries:
Node: 20.19.0 - /opt/hostedtoolcache/node/20.19.0/x64/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.8.2 - /opt/hostedtoolcache/node/20.19.0/x64/bin/npm
Languages:
Bash: 5.2.21 - /usr/bin/bash
npmPackages:
@playwright/test: ^1.51.1 => 1.51.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (12 by maintainers)
This got fixed upstream in https://github.com/WebKit/WebKit/pull/43899, so this will be fixed once Playwright rolls there (couple weeks).
Should be fixed and available in Canary in 12-24h.
just to confirm that this also fixed the other issue I reported in https://github.com/microsoft/playwright/issues/35269 so it was actually the same cause in the end
Thanks everyone! We just confirmed (using version
1.53.0-alpha-2025-04-16) that the fix resolves the issue for us.Oh we have news! We can repro locally with
/etc/hostswhen we useexample.testas the domain, but it works fine forexample.com. Weird.Reported to Webkit: https://bugs.webkit.org/show_bug.cgi?id=291194
Here’s what it looks like in Epiphany Canary:
That’s yet another behaviour, where there’s no cookie in the iframe, but API requests from the iframe also don’t have that cookie. The behaviour is the same in Epiphany stable.
I can reproduce your findings @jhogervorst. Looks like this is issue is distinct from https://github.com/microsoft/playwright/issues/35269.
This means it’s most likely a regression in WebKit for Linux. Before we file a bug report with WebKit, i’ll check if I can repro this in Epiphany.