mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 14:43:28 +00:00
cdp: implement url parameter on createTarget
This commit is contained in:
@@ -556,7 +556,19 @@ pub const Page = struct {
|
|||||||
|
|
||||||
// We do not processHTMLDoc here as we know we don't have any scripts
|
// We do not processHTMLDoc here as we know we don't have any scripts
|
||||||
// This assumption may be false when CDP Page.addScriptToEvaluateOnNewDocument is implemented
|
// This assumption may be false when CDP Page.addScriptToEvaluateOnNewDocument is implemented
|
||||||
try HTMLDocument.documentIsComplete(self.window.document, self);
|
self.documentIsComplete();
|
||||||
|
|
||||||
|
self.session.browser.notification.dispatch(.page_navigate, &.{
|
||||||
|
.opts = opts,
|
||||||
|
.url = request_url,
|
||||||
|
.timestamp = timestamp(),
|
||||||
|
});
|
||||||
|
|
||||||
|
self.session.browser.notification.dispatch(.page_navigated, &.{
|
||||||
|
.url = request_url,
|
||||||
|
.timestamp = timestamp(),
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ fn disposeBrowserContext(cmd: anytype) !void {
|
|||||||
|
|
||||||
fn createTarget(cmd: anytype) !void {
|
fn createTarget(cmd: anytype) !void {
|
||||||
const params = (try cmd.params(struct {
|
const params = (try cmd.params(struct {
|
||||||
// url: []const u8,
|
url: []const u8 = "about:blank",
|
||||||
// width: ?u64 = null,
|
// width: ?u64 = null,
|
||||||
// height: ?u64 = null,
|
// height: ?u64 = null,
|
||||||
browserContextId: ?[]const u8 = null,
|
browserContextId: ?[]const u8 = null,
|
||||||
@@ -167,7 +167,7 @@ fn createTarget(cmd: anytype) !void {
|
|||||||
.targetInfo = TargetInfo{
|
.targetInfo = TargetInfo{
|
||||||
.attached = false,
|
.attached = false,
|
||||||
.targetId = target_id,
|
.targetId = target_id,
|
||||||
.title = "about:blank",
|
.title = params.url,
|
||||||
.browserContextId = bc.id,
|
.browserContextId = bc.id,
|
||||||
.url = "about:blank",
|
.url = "about:blank",
|
||||||
},
|
},
|
||||||
@@ -178,6 +178,11 @@ fn createTarget(cmd: anytype) !void {
|
|||||||
try doAttachtoTarget(cmd, target_id);
|
try doAttachtoTarget(cmd, target_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try page.navigate(params.url, .{
|
||||||
|
.reason = .address_bar,
|
||||||
|
.cdp_id = cmd.input.id,
|
||||||
|
});
|
||||||
|
|
||||||
try cmd.sendResult(.{
|
try cmd.sendResult(.{
|
||||||
.targetId = target_id,
|
.targetId = target_id,
|
||||||
}, .{});
|
}, .{});
|
||||||
@@ -517,7 +522,7 @@ test "cdp.target: createTarget" {
|
|||||||
{
|
{
|
||||||
var ctx = testing.context();
|
var ctx = testing.context();
|
||||||
defer ctx.deinit();
|
defer ctx.deinit();
|
||||||
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about/blank" } });
|
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about:blank" } });
|
||||||
|
|
||||||
// should create a browser context
|
// should create a browser context
|
||||||
const bc = ctx.cdp().browser_context.?;
|
const bc = ctx.cdp().browser_context.?;
|
||||||
@@ -529,7 +534,7 @@ test "cdp.target: createTarget" {
|
|||||||
defer ctx.deinit();
|
defer ctx.deinit();
|
||||||
// active auto attach to get the Target.attachedToTarget event.
|
// active auto attach to get the Target.attachedToTarget event.
|
||||||
try ctx.processMessage(.{ .id = 9, .method = "Target.setAutoAttach", .params = .{ .autoAttach = true, .waitForDebuggerOnStart = false } });
|
try ctx.processMessage(.{ .id = 9, .method = "Target.setAutoAttach", .params = .{ .autoAttach = true, .waitForDebuggerOnStart = false } });
|
||||||
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about/blank" } });
|
try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .url = "about:blank" } });
|
||||||
|
|
||||||
// should create a browser context
|
// should create a browser context
|
||||||
const bc = ctx.cdp().browser_context.?;
|
const bc = ctx.cdp().browser_context.?;
|
||||||
|
|||||||
Reference in New Issue
Block a user