Skip to content

Lightpanda: the headless browser designed for AI and automation

fix test running

Muki Kiboigo8a8bb3814fce
diff --git a/src/browser/ScriptManagerBase.zig b/src/browser/ScriptManagerBase.zig
index bc8e34e35..af05602cd 100644
--- a/src/browser/ScriptManagerBase.zig
+++ b/src/browser/ScriptManagerBase.zig
@@ -55,6 +55,12 @@ pub const Owner = union(enum) {
};
}
+ pub fn origin(self: Owner) ?[]const u8 {
+ return switch (self) {
+ inline else => |g| g.origin,
+ };
+ }
+
pub fn jsContext(self: Owner) *js.Context {
return switch (self) {
inline else => |g| g.js,
diff --git a/src/network/CorsGate.zig b/src/network/CorsGate.zig
index 06d519d2a..f268ab91e 100644
--- a/src/network/CorsGate.zig
+++ b/src/network/CorsGate.zig
@@ -512,8 +512,6 @@ fn fetchThenResume(self: *CorsGate, transfer: *Transfer) !void {
.document_frame_id = transfer.req.document_frame_id,
.loader_id = transfer.req.loader_id,
.notification = transfer.req.notification,
- .cookie_jar = null,
- .cookie_origin = transfer.req.cookie_origin,
.origin = transfer.req.origin,
.credentials_mode = .omit,
.request_mode = .no_cors,
diff --git a/src/network/HttpClient.zig b/src/network/HttpClient.zig
index ba367ca56..923a078b8 100644
--- a/src/network/HttpClient.zig
+++ b/src/network/HttpClient.zig
@@ -4228,6 +4228,7 @@ fn testTransfer(arena: *lp.Arena) Transfer {
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
@@ -4458,6 +4459,7 @@ test "HttpClient: fulfillIntercepted survives a done_callback that tears down th
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
@@ -4540,6 +4542,7 @@ test "HttpClient: kill during done_callback does not also fire shutdown_callback
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .xhr,
@@ -4623,6 +4626,7 @@ test "HttpClient: kill during a non-terminal callback defers shutdown_callback"
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .xhr,
@@ -4681,6 +4685,7 @@ test "HttpClient: aborting a robots-parked transfer unlinks it from the gate" {
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
@@ -4745,6 +4750,7 @@ test "HttpClient: fulfillIntercepted follows a 3xx redirect" {
.req = .{
.method = .POST,
.url = "http://example.com/start",
+ .origin = null,
.body = "payload",
.credentials_mode = .omit,
.request_mode = .no_cors,
@@ -4786,6 +4792,7 @@ test "HttpClient: fulfillIntercepted follows a 3xx redirect" {
.req = .{
.method = .POST,
.url = "http://example.com/start",
+ .origin = null,
.body = "payload",
.credentials_mode = .omit,
.request_mode = .no_cors,
@@ -4852,6 +4859,7 @@ test "HttpClient: fulfillIntercepted delivers a 3xx without a Location as the re
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
@@ -4917,7 +4925,7 @@ test "HttpClient: abortParked survives an error_callback that tears down the own
.req = .{
.method = .GET,
.url = "http://example.com/",
- .origin = "",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
@@ -4993,6 +5001,7 @@ test "HttpClient: abort survives an error_callback that tears down the owner" {
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .xhr,
@@ -5027,6 +5036,7 @@ test "HttpClient: abort survives an error_callback that tears down the owner" {
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .xhr,
@@ -5088,6 +5098,7 @@ test "HttpClient: throttled navigations wait for their per-host slot" {
.req = .{
.method = .GET,
.url = url,
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
diff --git a/src/network/SingleFlight.zig b/src/network/SingleFlight.zig
index d6befa9ec..6952c040d 100644
--- a/src/network/SingleFlight.zig
+++ b/src/network/SingleFlight.zig
@@ -106,6 +106,7 @@ fn makeTestTransfer(arena: *lp.Arena, client: *HttpClient, id: u32) !*Transfer {
.req = .{
.method = .GET,
.url = "http://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
diff --git a/src/network/WebBotAuth.zig b/src/network/WebBotAuth.zig
index 8114efdb3..79e2245a0 100644
--- a/src/network/WebBotAuth.zig
+++ b/src/network/WebBotAuth.zig
@@ -244,6 +244,7 @@ test "signRequest: adds headers with correct names" {
.req = .{
.method = .GET,
.url = "https://example.com/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .document,
diff --git a/src/server/cdp/CDP.zig b/src/server/cdp/CDP.zig
index 03759c378..6960946b6 100644
--- a/src/server/cdp/CDP.zig
+++ b/src/server/cdp/CDP.zig
@@ -1516,6 +1516,7 @@ test "cdp: syncRequest short-circuits after disconnect" {
const transfer = try client.newRequest(.{
.method = .GET,
.url = "http://127.0.0.1:9582/",
+ .origin = null,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .fetch,
diff --git a/src/server/cdp/domains/network.zig b/src/server/cdp/domains/network.zig
index 1256fdfb5..beee2fc9c 100644
--- a/src/server/cdp/domains/network.zig
+++ b/src/server/cdp/domains/network.zig
@@ -1177,6 +1177,7 @@ test "cdp.Network: setBlockedURLs blocks requests with inspector reason" {
.loader_id = 1,
.method = .GET,
.url = "https://blocked.test/script.js",
+ .origin = bc.security_origin,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .script,
@@ -1203,6 +1204,7 @@ test "cdp.Network: setBlockedURLs blocks requests with inspector reason" {
.loader_id = 1,
.method = .GET,
.url = "http://127.0.0.1:9582/redirect-no-fragment",
+ .origin = bc.security_origin,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .script,
@@ -1243,6 +1245,7 @@ test "cdp.Network: POST body exposed as postData" {
.loader_id = 1,
.method = .POST,
.url = "http://127.0.0.1:9582/echo_body",
+ .origin = bc.security_origin,
.body = body,
.credentials_mode = .omit,
.request_mode = .no_cors,
@@ -1510,6 +1513,7 @@ test "cdp.Network: redirect hop precedes Fetch pause and carries redirectRespons
.loader_id = 7,
.method = .GET,
.url = start_url,
+ .origin = bc.security_origin,
.credentials_mode = .omit,
.request_mode = .no_cors,
.resource_type = .script,