chore: clean up the server cookie automation converters and various automation code#34248
Open
AtofStryker wants to merge 6 commits into
Open
chore: clean up the server cookie automation converters and various automation code#34248AtofStryker wants to merge 6 commits into
AtofStryker wants to merge 6 commits into
Conversation
cypress
|
||||||||||||||||||||||||||||
| Project |
cypress
|
| Branch Review |
refactor/automation_client_p3
|
| Run status |
|
| Run duration | 15m 57s |
| Commit |
|
| Committer | Bill Glesias |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
7
|
|
|
1113
|
|
|
0
|
|
|
24944
|
| View all changes introduced in this branch ↗︎ | |
Warning
No Report: Something went wrong and we could not generate a report for the Application Quality products.
ec4798a to
b1d8540
Compare
477ac31 to
740d5eb
Compare
MartinLVila
approved these changes
Jul 9, 2026
…ation
Firefox runs exclusively through WebDriver BiDi (upstream Firefox removed CDP
support entirely), so the Firefox-CDP accommodations in cdp_automation are
unreachable:
- the URL hash strip in onNetworkRequestWillBeSent existed for a Firefox CDP
bug (bugzilla 1715366); the remaining CDP consumers are all Chromium, which
strips fragments before the network layer per spec. Its pinned unit test is
removed with it.
- ffToStandardResourceTypeMap ('img'/'csp'/'webmanifest') and the redundant
'img' special case in normalizeResourceType map Firefox-CDP type names that
neither Chromium CDP (PascalCase enum) nor playwright (webkit-automation's
input, already lowercase) can produce. The validResourceTypes allowlist is
unchanged — its membership defines live cy.intercept resourceType behavior —
and new unit tests pin the full mapping for every CDP and playwright value.
Also in the same cleanup: clear:cookies no longer emits undefined placeholder
entries for cookies that don't exist at clear time. The entries were a
Bluebird.mapSeries artifact, survive to the driver unfiltered, and are only
producible via a race (the driver fetches existing cookies immediately before
clearing them), so the response now reports only cookies actually cleared.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…anslate
Renames the per-protocol cookie helpers in lib/automation/cookie/converters
to the convert{Dialect}CookieToCyCookie / convertCyCookieTo{Dialect}Cookie
convention bidi.ts already used, since each one translates between the
WebExtension-style CyCookie and a protocol's own cookie shape:
- cdp.ts: normalizeGetCookieProps -> convertCdpCookieToCyCookie,
normalizeGetCookies -> convertCdpCookiesToCyCookies,
normalizeSetCookieProps -> convertCyCookieToCdpCookie
- webkit.ts: normalizeGetCookieProps -> convertPlaywrightCookieToCyCookie,
normalizeSetCookieProps -> convertCyCookieToPlaywrightCookie, and
convertSameSiteExtensionToCypress -> convertSameSiteExtensionToPlaywright
(it returns playwright's sameSite vocabulary, not Cypress's)
The normalize* helpers in cookie/automation.ts keep their names — they
normalize within the automation cookie shape rather than crossing dialects.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The extension-dialect sameSite vocabulary was declared three times: an extensionMap const in converters/webkit.ts, an inline object literal in converters/cdp.ts, and a hand-written union on BidiCyCookie in converters/bidi.ts. cookie/util.ts now owns both pieces: - ExtensionSameSiteStatus (mirrors chrome.cookies.SameSiteStatus), which CyCookie.sameSite Excludes 'unspecified' from and BidiCyCookie widens back - sameSiteExtensionToProtocolMap, shared by the cdp and webkit converters (CDP's Network.CookieSameSite and playwright's sameSite are the same three PascalCase values) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Firefox versions 135-139 are no longer maintained by Mozilla (support is rolling, and ESR 140 is the oldest release line Mozilla currently ships), and their WebDriver BiDi implementations predate the 'default' sameSite cookie value Cypress relies on. With the floor at 140, the Firefox-version guard from 9ef239e comes out: convertSameSiteExtensionToBiDi no longer needs a majorFirefoxVersion to pick between 'none' and 'default' for unspecified cookies, so the parameter and the BidiAutomation.majorFirefoxVersion plumbing that fed it are removed, and 'unspecified'/undefined both map to 'default' unconditionally. The "Firefox 139 and under" unit test is deleted with the behavior; the launcher validator test and linux detection fixtures move to 140. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
convertCdpCookieToCyCookie built its result by mutating the incoming CDP cookie in place behind a pile of @ts-ignores; it now constructs a fresh CyCookie. The delete/reassign expiry dance becomes a ternary on the -1 session sentinel, and hostOnly is stamped conditionally as before. CDP-only fields (size, session, priority, ...) are no longer passed through — the automation layer already stripped them via _.pick before they reached the driver. convertCyCookieToCdpCookie loses its `delete cookie.hostOnly` input side effect, which never influenced the outgoing SetCookieRequest (there is no hostOnly field on it). CyCookie.hostOnly is now optional rather than inheriting chrome.cookies. Cookie's required field — every producer sets it conditionally, and the required type is what forced the @ts-ignores. convertSameSiteCdpToExtension is typed for what callers pass (sameSite is optional on CDP cookies) and returns CyCookie['sameSite'] instead of the ambient chrome type. The webkit and bidi converters already built fresh objects; with this, every converter in lib/automation/cookie/converters is pure. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The converters in lib/automation/cookie were only exercised transitively through the browser automation middleware specs, which left real gaps: the __Host- prefix handling in the CDP set path was untested anywhere, the playwright/webkit converters had no cookie-shape assertions at all, and isHostOnlyCookie's edge cases (dot-prefixed domains, localhost, IP addresses) had no direct pins. New specs mirror the lib layout under test/unit/automation/cookie/converters so they can move with the code when it is extracted from the server package, and they test only the exported surfaces: - cdp_spec: expires/expirationDate conversions incl. the -1 session sentinel, hostOnly stamping, sameSite both directions, dot-prefixing, __Host- domain-to-url swap, and purity pins (inputs untouched, CDP-only fields dropped) - bidi_spec: default/unspecified and no_restriction/none sameSite conversions, float and -Infinity expiry handling, hostOnly domain rules, and purity pins - webkit_spec: playwright cookie shape mapping, session sentinel, sameSite vocabulary, and purity pins - util_spec: isHostOnlyCookie edge cases Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
740d5eb to
3b14a28
Compare
mschile
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional details
Stacked on #34245 (
refactor/automation_client_p2), which stacks on #34244 — this PR targets the p2 branch.Unlike the earlier PRs in this stack, this one does contain behavior changes. The goal is no regressions — each change below is either provably unreachable code, or a deliberate contract cleanup with the reasoning spelled out. New direct unit tests pin all of it.
Behavior changes, each with its no-regression rationale:
Removed obsolete Firefox-CDP handling from
cdp_automation.ts. Firefox runs exclusively through WebDriver BiDi (and upstream Firefox removed CDP entirely), so two accommodations are unreachable: the URL hash strip inonNetworkRequestWillBeSent(Firefox CDP bug — Chromium strips fragments per spec before the network layer) and theffToStandardResourceTypeMap(img/csp/webmanifestare Firefox-CDP type names; I enumerated the possible inputs — Chromium CDP's PascalCaseResourceTypeenum and playwright's lowercase resource types — and neither can produce them). ThevalidResourceTypesallowlist itself is untouched since its membership defines livecy.interceptresourceType behavior, and new tests pin the full mapping for every CDP and playwright value.clear:cookies(CDP) no longer emitsundefinedplaceholder entries for cookies that don't exist at clear time. The placeholders were aBluebird.mapSeriesartifact that survived to the driver unfiltered — but they're only producible via a race, because the driver fetches existing cookies immediately before clearing them. The response now reports only cookies actually cleared.Minimum supported Firefox is now 140. Firefox support is rolling — versions 135–139 are no longer maintained by Mozilla, and ESR 140 is the oldest line Mozilla ships. Their BiDi implementations also predate the
defaultsameSite value Cypress relies on, which is what motivated this: with the floor at 140, the Firefox-version sameSite guard and all itsmajorFirefoxVersionparameter threading come out ofconvertSameSiteExtensionToBiDi,convertCyCookieToBiDiCookie, andBidiAutomation. No changelog entry: Cypress documents rolling support for the last 3 major versions of each browser, so moving the enforcement floor is housekeeping rather than a policy change.The CDP cookie converters are now pure functions.
convertCdpCookieToCyCookiepreviously mutated the incoming CDP cookie in place behind seven@ts-ignores and returned it — it now builds a freshCyCookie(which also stops passing through CDP-only fields likesize/session; the automation layer already stripped those via_.pickbefore they reached the driver).convertCyCookieToCdpCookieloses adelete cookie.hostOnlyinput side effect that never influenced the outgoingSetCookieRequest.CyCookie.hostOnlybecomes optional to reflect that every producer sets it conditionally — the required field inherited fromchrome.cookies.Cookiewas what forced the@ts-ignores. The existing middleware deep-equality specs pass unchanged, confirming identical output shapes.Behavior-neutral commits alongside:
convertCdpCookieToCyCookie/convertCyCookieToCdpCookie(formerlynormalizeGetCookieProps/normalizeSetCookiePropsin the cdp converter),convertPlaywrightCookieToCyCookie/convertCyCookieToPlaywrightCookie(formerly the samenormalize*names in the webkit converter), andconvertSameSiteExtensionToPlaywright(formerly...ToCypress, which misdescribed its output vocabulary).normalize*now exclusively means the within-dialect cleanup incookie/automation.ts.cookie/util.ts(ExtensionSameSiteStatus+sameSiteExtensionToProtocolMap), replacing three hand-written copies.test/unit/automation/cookie/converters/(48 tests) mirror the lib layout so they move with the code when it's eventually extracted from the server package. They cover previously-untested surfaces: the__Host-domain→url swap,isHostOnlyCookieedge cases (dot-prefix/localhost/IP), the playwright converters (no prior cookie-shape coverage at all), and purity pins on every converter.Steps to test
Firefox e2e/system jobs run against Firefox 141+ in CI, so the floor bump doesn't change what CI exercises.
How has the user experience changed?
Users launching Firefox 135–139 now see the unsupported-browser warning ("Cypress does not support running Firefox version NNN due to an incomplete WebDriver BiDi implementation. To use Firefox with Cypress, install version 140 or newer.") where those versions previously launched. No other user-visible change.
PR Tasks
cypress-documentation? — the documented minimum Firefox version needs updating to 140; will link the docs PR heretype definitions?Note
Medium Risk
Touches cookie get/set/clear across CDP and BiDi and changes supported Firefox versions (135–139 blocked); behavior is heavily unit-tested but cookie automation is user-facing.
Overview
Refactors server cookie automation so CDP, BiDi, and WebKit/Playwright converters are pure, renamed (
convert*), and sameSite mapping lives incookie/util.ts(ExtensionSameSiteStatus,sameSiteExtensionToProtocolMap) instead of three copies.Firefox 140+ is now required in the launcher validator (was 135); BiDi drops
majorFirefoxVersionsameSite workarounds because older Firefox BiDi lacked thedefaultsameSite value.CDP path: converters build fresh
CyCookieobjects (no in-place mutation / CDP-only fields leaking);clear:cookiesomitsundefinedentries for cookies already gone; Firefox-CDP-only URL hash stripping andffToStandardResourceTypeMapare removed fromcdp_automation(Firefox uses BiDi only).Adds unit specs under
test/unit/automation/cookie/converters/and updates launcher/driver tests for the new Firefox floor and e2e sameSite comment.Reviewed by Cursor Bugbot for commit 3b14a28. Bugbot is set up for automated code reviews on this repo. Configure here.