fix: map Secure field in cookie conversions and add per-cookie error handling
The Secure field was dropped in both Playwright<->internal cookie conversion functions, causing cookies with __Secure-/__Host- prefixes to be rejected by Chromium. Additionally, batch AddCookies meant one invalid cookie would fail browser creation entirely. Changes: - Map Secure field in cookieToPlaywrightOptionalCookie and playwrightCookieToCookie - Add cookies one-by-one with slog.Warn on failure instead of failing the entire batch - Add unit tests for both conversion functions Closes #75 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -128,6 +128,7 @@ func cookieToPlaywrightOptionalCookie(cookie Cookie) playwright.OptionalCookie {
|
||||
Domain: playwright.String(cookie.Host),
|
||||
Path: playwright.String(cookie.Path),
|
||||
Expires: playwright.Float(float64(cookie.Expires.Unix())),
|
||||
Secure: playwright.Bool(cookie.Secure),
|
||||
HttpOnly: playwright.Bool(cookie.HttpOnly),
|
||||
}
|
||||
if cookie.SameSite != "" {
|
||||
@@ -143,6 +144,7 @@ func playwrightCookieToCookie(cookie playwright.Cookie) Cookie {
|
||||
Host: cookie.Domain,
|
||||
Path: cookie.Path,
|
||||
Expires: time.Unix(int64(cookie.Expires), 0),
|
||||
Secure: cookie.Secure,
|
||||
HttpOnly: cookie.HttpOnly,
|
||||
SameSite: playwrightSameSiteToSameSite(cookie.SameSite),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user