Skip to content

Commit a7c3bad

Browse files
committed
cdp: implement url parameter on createTarget
1 parent fb6fbff commit a7c3bad

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/browser/page.zig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,19 @@ pub const Page = struct {
556556

557557
// We do not processHTMLDoc here as we know we don't have any scripts
558558
// This assumption may be false when CDP Page.addScriptToEvaluateOnNewDocument is implemented
559-
try HTMLDocument.documentIsComplete(self.window.document, self);
559+
self.documentIsComplete();
560+
561+
self.session.browser.notification.dispatch(.page_navigate, &.{
562+
.opts = opts,
563+
.url = request_url,
564+
.timestamp = timestamp(),
565+
});
566+
567+
self.session.browser.notification.dispatch(.page_navigated, &.{
568+
.url = request_url,
569+
.timestamp = timestamp(),
570+
});
571+
560572
return;
561573
}
562574

src/cdp/domains/target.zig

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn disposeBrowserContext(cmd: anytype) !void {
109109

110110
fn createTarget(cmd: anytype) !void {
111111
const params = (try cmd.params(struct {
112-
// url: []const u8,
112+
url: []const u8 = "about:blank",
113113
// width: ?u64 = null,
114114
// height: ?u64 = null,
115115
browserContextId: ?[]const u8 = null,
@@ -167,7 +167,7 @@ fn createTarget(cmd: anytype) !void {
167167
.targetInfo = TargetInfo{
168168
.attached = false,
169169
.targetId = target_id,
170-
.title = "about:blank",
170+
.title = params.url,
171171
.browserContextId = bc.id,
172172
.url = "about:blank",
173173
},
@@ -178,6 +178,11 @@ fn createTarget(cmd: anytype) !void {
178178
try doAttachtoTarget(cmd, target_id);
179179
}
180180

181+
try page.navigate(params.url, .{
182+
.reason = .address_bar,
183+
.cdp_id = cmd.input.id,
184+
});
185+
181186
try cmd.sendResult(.{
182187
.targetId = target_id,
183188
}, .{});
@@ -517,7 +522,7 @@ test "cdp.target: createTarget" {
517522
{
518523
var ctx = testing.context();
519524
defer ctx.deinit();
520-
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about/blank" } });
525+
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about:blank" } });
521526

522527
// should create a browser context
523528
const bc = ctx.cdp().browser_context.?;
@@ -529,7 +534,7 @@ test "cdp.target: createTarget" {
529534
defer ctx.deinit();
530535
// active auto attach to get the Target.attachedToTarget event.
531536
try ctx.processMessage(.{ .id = 9, .method = "Target.setAutoAttach", .params = .{ .autoAttach = true, .waitForDebuggerOnStart = false } });
532-
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about/blank" } });
537+
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about:blank" } });
533538

534539
// should create a browser context
535540
const bc = ctx.cdp().browser_context.?;

0 commit comments

Comments
 (0)