Lightpanda: the headless browser designed for AI and automation
update tests
Halil Durak835cf8917b72
diff --git a/src/Config.zig b/src/Config.zigindex 44849ef05..dc1597f8d 100644--- a/src/Config.zig+++ b/src/Config.zig@@ -1006,6 +1006,18 @@ pub fn parseArgs(allocator: Allocator, proc_args: std.process.Args) !Config {return config;}+test "Config: adblockLists splits comma-separated paths" {+ var config = try Config.init(std.testing.allocator, "test", .{ .serve = .{+ .adblock_lists = "easylist.txt,easyprivacy.txt",+ } });+ defer config.deinit(std.testing.allocator);++ var paths = config.adblockLists().?;+ try std.testing.expectEqualStrings("easylist.txt", paths.next().?);+ try std.testing.expectEqualStrings("easyprivacy.txt", paths.next().?);+ try std.testing.expectEqual(null, paths.next());+}+test "Config: blockedUrlPatterns splits comma-separated patterns" {var config = try Config.init(std.testing.allocator, "test", .{ .serve = .{.block_urls = "*doubleclick*,*://*/*.png",diff --git a/src/network/HttpClient.zig b/src/network/HttpClient.zigindex dfc2b23c8..29346cf18 100644--- a/src/network/HttpClient.zig+++ b/src/network/HttpClient.zig@@ -3472,6 +3472,30 @@ test "HttpClient: setBlockedUrls owns, replaces, and clears patterns" {try testing.expectEqual(null, client.url_blocklist);}+test "HttpClient: adblock verdicts apply per request hostname" {+ var pool = ArenaPool.init(testing.allocator, .{});+ defer pool.deinit();++ var client: Client = undefined;+ initTestClient(&client, &pool);++ client.adblocker = try AdBlocker.init(testing.allocator);+ defer if (client.adblocker) |*blocker| blocker.deinit();+ var list: std.Io.Reader = .fixed(+ \\||ads.example.com^+ \\@@||good.ads.example.com^+ );+ _ = try client.adblocker.?.parse(&list);++ try testing.expect(client.isHostAdblocked("https://ads.example.com/pixel.gif", false));+ // Hostnames are matched case-insensitively and without the port.+ try testing.expect(client.isHostAdblocked("https://SUB.ADS.EXAMPLE.COM:8443/x", false));+ try testing.expect(!client.isHostAdblocked("https://good.ads.example.com/app.js", false));+ try testing.expect(!client.isHostAdblocked("https://example.com/", false));+ // Internal transfers (robots.txt, ...) are never adblocked.+ try testing.expect(!client.isHostAdblocked("https://ads.example.com/", true));+}+test "HttpClient: URL blocking exempts internal transfers" {var pool = ArenaPool.init(testing.allocator, .{});defer pool.deinit();