Files
Nayrosk 93a6474ca1 fix(cookies): map a session expiry onto -1 for addCookies()
Netscape cookie files use `0` in the expiry field to mean "session cookie".
That is the only convention the format has for it, and it is what browser
exports actually contain. `parseNetscapeCookieFile()` read that field with a
bare `Number(parts[4])` and handed it straight to Playwright's
`context.addCookies()`, which does not read `0` as "session": it wants `-1`,
and treats `0` as a Unix timestamp, so 1970-01-01. The cookie is expired the
moment it is added and Playwright drops it.

Nothing surfaces that. The import still reports every cookie as imported and
the caller sees a success; the cookie is simply never attached to any later
request. Because session cookies are the common case in exported files, this
hits ordinary usage rather than an edge case.

Anything that is not a positive finite number now maps to -1. That also covers
an unparsable expiry, which used to yield NaN and be rejected by addCookies()
outright.

The tests no longer reimplement the parser. They carried a second copy of it
with a comment asking that any change be mirrored by hand, which is exactly
how a parser and its tests can agree perfectly while both being wrong: the old
suite asserted `expires: 0` and a NaN, so it passed on the broken behaviour.
They now import the shipped parser through `lib/cookies.js`, and three cases
cover session, negative and unparsable expiries.
2026-09-08 23:18:19 -07:00
..