Files
cypress/packages/server/lib/automation/util.ts
Bill Glesias 34fe1ae8e2 misc: update playwright-webkit from 1.24.2 to 1.56.1 and base-internal image from Debian Bullseye to Debian Trixie (#32852)
* chore: update playwright-webkit from 1.24.2 to 1.56.1

* chore: fix cookies.cy.js tests in webkit by checking for strict domain
match first when calling getCookie and falling back to apex domain

* misc: add changelog item
2025-10-30 12:05:00 -04:00

31 lines
1020 B
TypeScript

import type playwright from 'playwright-webkit'
import { domainMatch, pathMatch } from 'tough-cookie'
// @ts-ignore
export type CyCookie = Pick<chrome.cookies.Cookie, 'name' | 'value' | 'expirationDate' | 'hostOnly' | 'domain' | 'path' | 'secure' | 'httpOnly'> & {
// use `undefined` instead of `unspecified`
sameSite?: 'no_restriction' | 'lax' | 'strict'
}
// Cypress uses the webextension-style filtering
// https://developer.chrome.com/extensions/cookies#method-getAll
// @ts-ignore
export type CyCookieFilter = chrome.cookies.GetAllDetails
export const cookieMatches = (cookie: CyCookie | playwright.Cookie, filter?: CyCookieFilter, options?: { strictDomain: boolean }) => {
if (filter?.domain) {
if (options?.strictDomain ? filter?.domain !== cookie.domain : !domainMatch(filter?.domain, cookie.domain))
return false
}
if (filter?.path && !pathMatch(filter.path, cookie.path)) {
return false
}
if (filter?.name && filter?.name !== cookie.name) {
return false
}
return true
}