From 510c61cc20a989a0f9753589d659ec25d19e8748 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 21 Oct 2025 14:08:26 +0200 Subject: [PATCH] cdp: add test for setIgnoreCertificateErrors --- src/cdp/domains/security.zig | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/cdp/domains/security.zig b/src/cdp/domains/security.zig index 88655f8b..830cd591 100644 --- a/src/cdp/domains/security.zig +++ b/src/cdp/domains/security.zig @@ -35,15 +35,34 @@ fn setIgnoreCertificateErrors(cmd: anytype) !void { ignore: bool, })) orelse return error.InvalidParams; - const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded; - if (params.ignore) { try cmd.cdp.browser.http_client.disableTlsVerify(); } else { try cmd.cdp.browser.http_client.enableTlsVerify(); } - return cmd.sendResult(.{ - .browserContextId = bc.id, - }, .{}); + return cmd.sendResult(null, .{}); +} + +const testing = @import("../testing.zig"); + +test "cdp.Security: setIgnoreCertificateErrors" { + var ctx = testing.context(); + defer ctx.deinit(); + + _ = try ctx.loadBrowserContext(.{ .id = "BID-9" }); + + try ctx.processMessage(.{ + .id = 8, + .method = "Security.setIgnoreCertificateErrors", + .params = .{ .ignore = true }, + }); + try ctx.expectSentResult(null, .{ .id = 8 }); + + try ctx.processMessage(.{ + .id = 9, + .method = "Security.setIgnoreCertificateErrors", + .params = .{ .ignore = false }, + }); + try ctx.expectSentResult(null, .{ .id = 9 }); }