Lightpanda: the headless browser designed for AI and automation
serve: trim cookie-jar help, comment and test
Adrià Arrufatc65200922b47
diff --git a/src/cookies.zig b/src/cookies.zigindex 8e8bad1aa..2237336de 100644--- a/src/cookies.zig+++ b/src/cookies.zig@@ -91,8 +91,8 @@ pub fn saveToFile(jar: *Cookie.Jar, path: []const u8) void {fn _saveToFile(jar: *Cookie.Jar, path: []const u8) !void {jar.removeExpired(null);- // temp+rename: `serve` saves once per CDP connection, so several- // connections may write the same jar; a reader never sees a torn file.+ // Concurrent serve connections may save the same path: the last rename+ // wins, but no reader sees a torn file.var af = try std.Io.Dir.cwd().createFileAtomic(lp.io, path, .{ .replace = true });defer af.deinit(lp.io);diff --git a/src/help.zon b/src/help.zonindex 1dc2ce44f..9e20811da 100644--- a/src/help.zon+++ b/src/help.zon@@ -47,10 +47,8 @@\\ detected from the file's contents.\\ Defaults to no cookie loading.\\ --cookie-jar <PATH>- \\ Path to a JSON file to save cookies to (write-only). Written when- \\ a CDP browser context is disposed: on disconnect, on- \\ Target.disposeBrowserContext and on shutdown. Pass the same path- \\ to --cookie to keep logins across restarts.+ \\ Path to a JSON file to save cookies to when a CDP browser context+ \\ closes (write-only). With several clients, the last to close wins.\\ Defaults to no cookie saving.\\ --disable-metrics\\ Disables the /metrics endpoint (Prometheus text format).diff --git a/src/server/cdp/CDP.zig b/src/server/cdp/CDP.zigindex 4e0fb9a62..25a0ef2bc 100644--- a/src/server/cdp/CDP.zig+++ b/src/server/cdp/CDP.zig@@ -1805,13 +1805,9 @@ test "cdp: --cookie-jar saves on dispose and --cookie loads it back" {ctx.cdp().disposeBrowserContext();}- const written = try std.Io.Dir.cwd().readFileAlloc(lp.io, path, testing.arena_allocator, .limited(4096));- try testing.expect(std.mem.find(u8, written, "\"name\":\"sid\",\"value\":\"abc\"") != null);-// a new context (a reconnect, or a restart) starts logged inconst bc = try ctx.loadBrowserContext(.{});const cookies = bc.session.cookie_jar.cookies.items;try testing.expectEqual(1, cookies.len);try testing.expectEqualSlices(u8, "abc", cookies[0].value);- try testing.expectEqual(true, cookies[0].http_only);}