mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Ignore partitionKey in cookie operations to support Puppeteer page.setCookie()
Puppeteer's page.setCookie() internally calls Network.deleteCookies twice before setting a cookie. The second call includes a partitionKey field for CHIPS (partitioned cookies), which caused Lightpanda to return NotImplemented. Since Lightpanda doesn't support partitioned cookies, we now silently ignore the partitionKey parameter and proceed with the cookie operation based on name/domain/path matching. This change affects: - Network.deleteCookies: no longer rejects requests with partitionKey - Network.setCookie (via setCdpCookie): no longer rejects cookies with partitionKey Fixes #1818 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -117,7 +117,12 @@ fn deleteCookies(cmd: anytype) !void {
|
|||||||
path: ?[]const u8 = null,
|
path: ?[]const u8 = null,
|
||||||
partitionKey: ?CdpStorage.CookiePartitionKey = null,
|
partitionKey: ?CdpStorage.CookiePartitionKey = null,
|
||||||
})) orelse return error.InvalidParams;
|
})) orelse return error.InvalidParams;
|
||||||
if (params.partitionKey != null) return error.NotImplemented;
|
// Silently ignore partitionKey since we don't support partitioned cookies (CHIPS).
|
||||||
|
// This allows Puppeteer's page.setCookie() to work, which sends deleteCookies
|
||||||
|
// with partitionKey as part of its cookie-setting workflow.
|
||||||
|
if (params.partitionKey != null) {
|
||||||
|
log.debug(.network, "partitionKey ignored in deleteCookies", .{});
|
||||||
|
}
|
||||||
|
|
||||||
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||||
const cookies = &bc.session.cookie_jar.cookies;
|
const cookies = &bc.session.cookie_jar.cookies;
|
||||||
|
|||||||
@@ -128,7 +128,15 @@ pub const CdpCookie = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn setCdpCookie(cookie_jar: *CookieJar, param: CdpCookie) !void {
|
pub fn setCdpCookie(cookie_jar: *CookieJar, param: CdpCookie) !void {
|
||||||
if (param.priority != .Medium or param.sameParty != null or param.sourceScheme != null or param.partitionKey != null) {
|
// Silently ignore partitionKey since we don't support partitioned cookies (CHIPS).
|
||||||
|
// This allows Puppeteer's page.setCookie() to work, which may send cookies with
|
||||||
|
// partitionKey as part of its cookie-setting workflow.
|
||||||
|
if (param.partitionKey != null) {
|
||||||
|
const log = @import("../../log.zig");
|
||||||
|
log.debug(.storage, "partitionKey ignored in setCdpCookie", .{});
|
||||||
|
}
|
||||||
|
// Still reject unsupported features
|
||||||
|
if (param.priority != .Medium or param.sameParty != null or param.sourceScheme != null) {
|
||||||
return error.NotImplemented;
|
return error.NotImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user