Skip to content

fix(bidi): return domain cookies for the domain itself in page.cookies() - #15689

Merged
wolfib merged 1 commit into
puppeteer:mainfrom
b84330808:fix-bidi-cookie-domain-self-match
Oct 29, 2026
Merged

wolfib merged 1 commit into
puppeteer:mainfrom
b84330808:fix-bidi-cookie-domain-self-match

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

Did you add tests for your changes?

Yes, a case in test/src/cookies.test.ts.

If relevant, did you update the documentation?

Not needed.

Summary

With WebDriver BiDi (Firefox, or Chrome with protocol: 'webDriverBiDi'), page.cookies(url) drops domain cookies for the domain they belong to. A cookie set with Domain=example.com is reported as .example.com, and per RFC 6265 section 5.1.3 it applies to example.com itself as well as its subdomains. testUrlMatchCookieHostname only checked hostname.endsWith('.example.com'), so page.cookies('https://example.com') returned nothing while CDP returned the cookie. The fix matches against .${hostname} instead.

Does this PR introduce a breaking change?

No.

Other information

The new test fails on main with chrome-bidi and firefox-headless (expected length 1, received 0) and passes with the fix. It already passed on chrome-headless (CDP).

I used Claude Code to write this change.

A cookie whose domain has a leading dot (for example one set with
`Domain=example.com`) applies to `example.com` as well as its
subdomains (RFC 6265, section 5.1.3). The BiDi `page.cookies()` filter
only checked `hostname.endsWith('.example.com')`, so such cookies were
dropped for `https://example.com` while CDP returned them.

@wolfib wolfib left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wolfib
wolfib merged commit 884a8c3 into puppeteer:main Oct 29, 2026
42 checks passed
dadezzz pushed a commit to dadezzz/events-cash-register that referenced this pull request Nov 14, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [puppeteer-core](https://github.com/puppeteer/puppeteer/tree/main#readme) ([source](https://github.com/puppeteer/puppeteer)) | [`25.16.0` → `25.17.0`](https://renovatebot.com/diffs/npm/puppeteer-core/25.16.0/25.17.0) | ![age](https://developer.mend.io/api/mc/badges/age/npm/puppeteer-core/25.17.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/puppeteer-core/25.16.0/25.17.0?slim=true) |

---

### Release Notes

<details>
<summary>puppeteer/puppeteer (puppeteer-core)</summary>

### [`v25.17.0`](https://github.com/puppeteer/puppeteer/releases/tag/puppeteer-core-v25.17.0): puppeteer-core: v25.17.0

[Compare Source](puppeteer/puppeteer@puppeteer-core-v25.16.0...puppeteer-core-v25.17.0)

##### 🎉 Features

- add console events to Browser and BrowserContext ([#&#8203;15710](puppeteer/puppeteer#15710)) ([e9894e3](puppeteer/puppeteer@e9894e3))
- add HTTPResponse.stream() ([#&#8203;15717](puppeteer/puppeteer#15717)) ([8fab4dc](puppeteer/puppeteer@8fab4dc))
- add page and worker methods on HTTPRequest ([#&#8203;15514](puppeteer/puppeteer#15514)) ([9b2fe5e](puppeteer/puppeteer@9b2fe5e))
- add request events to Browser and BrowserContext ([#&#8203;15539](puppeteer/puppeteer#15539)) ([b99132a](puppeteer/puppeteer@b99132a))
- add scriptId to ConsoleMessageLocation ([#&#8203;15537](puppeteer/puppeteer#15537)) ([f3511d8](puppeteer/puppeteer@f3511d8))
- **cdp:** expose DomContentLoaded and NavigationStart in page.metrics() ([#&#8203;15676](puppeteer/puppeteer#15676)) ([5862b81](puppeteer/puppeteer@5862b81))
- expose HTTPResponse.encodedDataLength() ([#&#8203;15678](puppeteer/puppeteer#15678)) ([9abca26](puppeteer/puppeteer@9abca26))
- introduce other network event on browser and browserContext ([#&#8203;15726](puppeteer/puppeteer#15726)) ([9319ada](puppeteer/puppeteer@9319ada))
- **locators:** support passing arguments to Locator.filter and Locator.map ([#&#8203;15684](puppeteer/puppeteer#15684)) ([a0b2b8d](puppeteer/puppeteer@a0b2b8d))
- report dedicated worker console messages on Browser and BrowserContext ([#&#8203;15711](puppeteer/puppeteer#15711)) ([092e6e6](puppeteer/puppeteer@092e6e6))
- roll to Chrome 157.0.8103.38 ([#&#8203;15716](puppeteer/puppeteer#15716)) ([591d736](puppeteer/puppeteer@591d736))
- roll to Firefox 159.0 ([#&#8203;15685](puppeteer/puppeteer#15685)) ([de2e9f9](puppeteer/puppeteer@de2e9f9))

##### 🛠️ Fixes

- **bidi:** apply downloadBehavior from launch and connect options ([#&#8203;15687](puppeteer/puppeteer#15687)) ([d8cc590](puppeteer/puppeteer@d8cc590))
- **bidi:** deliver console messages replayed while connecting ([#&#8203;15712](puppeteer/puppeteer#15712)) ([5115e5c](puppeteer/puppeteer@5115e5c))
- **bidi:** enforce exhaustive switch in getBidiKeyValue and support Abort/NumpadEnter ([#&#8203;15654](puppeteer/puppeteer#15654)) ([7cb1c0b](puppeteer/puppeteer@7cb1c0b))
- **bidi:** keep the plain GMT timezone ID in page.emulateTimezone() ([#&#8203;15728](puppeteer/puppeteer#15728)) ([026b426](puppeteer/puppeteer@026b426))
- **bidi:** let contentType replace a content-type header in respond() ([#&#8203;15653](puppeteer/puppeteer#15653)) ([7cb283c](puppeteer/puppeteer@7cb283c))
- **bidi:** make page.setCacheEnabled() enable the cache by default ([#&#8203;15698](puppeteer/puppeteer#15698)) ([4b211de](puppeteer/puppeteer@4b211de))
- **bidi:** respect waitForFonts in page.pdf() ([#&#8203;15714](puppeteer/puppeteer#15714)) ([0814ac1](puppeteer/puppeteer@0814ac1))
- **bidi:** return domain cookies for the domain itself in page.cookies() ([#&#8203;15689](puppeteer/puppeteer#15689)) ([884a8c3](puppeteer/puppeteer@884a8c3))
- **bidi:** send the default accuracy in page.setGeolocation() ([#&#8203;15704](puppeteer/puppeteer#15704)) ([8dfe2ff](puppeteer/puppeteer@8dfe2ff))
- **bidi:** send the Enter code for the Enter key ([#&#8203;15743](puppeteer/puppeteer#15743)) ([27e017c](puppeteer/puppeteer@27e017c))
- **bidi:** tolerate respond() and abort() failures for gone requests ([#&#8203;15697](puppeteer/puppeteer#15697)) ([1c4e4ad](puppeteer/puppeteer@1c4e4ad))
- **bidi:** update Request.isBlocked on network lifecycle events ([#&#8203;15677](puppeteer/puppeteer#15677)) ([a0d910a](puppeteer/puppeteer@a0d910a))
- **cdp:** allow calling exposed functions after deleting from globalThis ([#&#8203;15683](puppeteer/puppeteer#15683)) ([5c11065](puppeteer/puppeteer@5c11065))
- **cdp:** handle internal redirects not paused by Fetch.requestPaused ([#&#8203;15644](puppeteer/puppeteer#15644)) ([176afa2](puppeteer/puppeteer@176afa2))
- **cdp:** include null and undefined in ConsoleMessage.text() ([#&#8203;15693](puppeteer/puppeteer#15693)) ([e54f1db](puppeteer/puppeteer@e54f1db))
- deflake BiDi navigation and flaky tests from main CI ([#&#8203;15638](puppeteer/puppeteer#15638)) ([d8ef67a](puppeteer/puppeteer@d8ef67a))
- do not mutate options.args in defaultArgs ([#&#8203;15664](puppeteer/puppeteer#15664)) ([1581677](puppeteer/puppeteer@1581677))
- do not throw in evaluate when the caller stack frame is missing ([#&#8203;15666](puppeteer/puppeteer#15666)) ([28782a2](puppeteer/puppeteer@28782a2))
- **extensions:** support Target.attachToTarget in ExtensionTransport ([#&#8203;15647](puppeteer/puppeteer#15647)) ([c615311](puppeteer/puppeteer@c615311))
- fail pending worker requests on worker termination ([#&#8203;15538](puppeteer/puppeteer#15538)) ([7231774](puppeteer/puppeteer@7231774))
- **network:** emit requestfailed when loadingFailed precedes requestPaused ([#&#8203;15576](puppeteer/puppeteer#15576)) ([5b0c34a](puppeteer/puppeteer@5b0c34a))
- roll to Chrome 156.0.8078.73 ([#&#8203;15686](puppeteer/puppeteer#15686)) ([33f2ad6](puppeteer/puppeteer@33f2ad6))
- roll to Chrome 156.0.8078.80 ([#&#8203;15696](puppeteer/puppeteer#15696)) ([715534b](puppeteer/puppeteer@715534b))
- roll to Chrome 157.0.8103.50 ([#&#8203;15747](puppeteer/puppeteer#15747)) ([5a0d6de](puppeteer/puppeteer@5a0d6de))
- roll to Firefox 159.0.1 ([#&#8203;15715](puppeteer/puppeteer#15715)) ([62d357a](puppeteer/puppeteer@62d357a))
- type wildcard event emitter handlers correctly ([#&#8203;15643](puppeteer/puppeteer#15643)) ([08e7b1a](puppeteer/puppeteer@08e7b1a))
- validate CRLF in input HTTPRequest headers ([#&#8203;15601](puppeteer/puppeteer#15601)) ([d830850](puppeteer/puppeteer@d830850))
- **webdriver:** dispose requests that complete with a 3xx status but are not redirected ([#&#8203;15631](puppeteer/puppeteer#15631)) ([fac3a5b](puppeteer/puppeteer@fac3a5b))
- **webdriver:** support the Space key over WebDriver BiDi ([#&#8203;15650](puppeteer/puppeteer#15650)) ([346bace](puppeteer/puppeteer@346bace))

##### 📄 Documentation

- **pdf:** clarify emulateMediaType('screen') behavior with page.pdf() ([#&#8203;15636](puppeteer/puppeteer#15636)) ([a1149f3](puppeteer/puppeteer@a1149f3))

##### ⚡ Performance

- count in-flight requests in linear time ([#&#8203;15668](puppeteer/puppeteer#15668)) ([394e92d](puppeteer/puppeteer@394e92d))

##### Dependencies

- The following workspace dependencies were updated
  - dependencies
    - [@&#8203;puppeteer/browsers](https://github.com/puppeteer/browsers) bumped from 3.2.6 to 3.2.7

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yMzguMCIsInVwZGF0ZWRJblZlciI6IjQ0LjIzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants