load aboutblank doc

This commit is contained in:
sjorsdonkers
2025-05-20 11:49:42 +02:00
committed by Sjors
parent fc0281b563
commit 0929bd217d
3 changed files with 30 additions and 16 deletions

View File

@@ -125,6 +125,9 @@ fn createTarget(cmd: anytype) !void {
bc.target_id = target_id;
var page = try bc.session.createPage();
// Navigate to about:blank such that the window.document are created and set
const url = @import("../../url.zig").URL.about_blank;
try page.navigate(url, .{});
{
const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":true,\"type\":\"default\",\"frameId\":\"{s}\"}}", .{target_id});
bc.inspector.contextCreated(
@@ -501,6 +504,10 @@ test "cdp.target: createTarget" {
// should create a browser context
const bc = ctx.cdp().browser_context.?;
try ctx.expectSentEvent("Target.targetCreated", .{ .targetInfo = .{ .url = "about:blank", .title = "about:blank", .attached = false, .type = "page", .canAccessOpener = false, .browserContextId = bc.id, .targetId = bc.target_id.? } }, .{});
// Even about:blank should set the window.document
const page = ctx.cdp().browser_context.?.session.page.?;
try testing.expect(page.window.document != null);
}
{