Communicate page navigation state via notifications

In order to support click handling on anchors from JavaScript, we need some hook
from the page/session to the CDP instance. This first phase adds notifications
in page.navigate, as well as a primitive notification hook to the session.

CDP's existing Page.navigate uses this new notifiation system.
This commit is contained in:
Karl Seguin
2025-04-10 14:21:05 +08:00
parent 66bac32e33
commit 71c3d484a9
6 changed files with 168 additions and 104 deletions

View File

@@ -86,6 +86,7 @@ pub fn main() !void {
},
.fetch => |opts| {
log.debug("Fetch mode: url {s}, dump {any}", .{ opts.url, opts.dump });
const url = try @import("url.zig").URL.parse(opts.url, null);
var app = try App.init(alloc, .{
.run_mode = args.mode,
@@ -107,13 +108,13 @@ pub fn main() !void {
// page
const page = try session.createPage(null);
_ = page.navigate(opts.url, null) catch |err| switch (err) {
_ = page.navigate(url, null) catch |err| switch (err) {
error.UnsupportedUriScheme, error.UriMissingHost => {
log.err("'{s}' is not a valid URL ({any})\n", .{ opts.url, err });
log.err("'{s}' is not a valid URL ({any})\n", .{ url, err });
return args.printUsageAndExit(false);
},
else => {
log.err("'{s}' fetching error ({any})\n", .{ opts.url, err });
log.err("'{s}' fetching error ({any})\n", .{ url, err });
return err;
},
};