Skip to content

Conversation

@karlseguin
Copy link
Collaborator

#516 needs a way for the page/session to communicate with CDP (i.e. the client). This adds a very simple mechanism for the page/session to callback into CDP.

The Page.navigate CDP message has been changed to use the new notification appraoch. Page.navigate just signals the navigation request, and it's only via notifications from the page/session that page lifecycle events are sent back to the client.

I know this isn't the holistic event system that we want. This isn't something that the HTTP client can use to emit events nor is it something that telemetry can register listeners with. My goal is to get clicks working (from mouse events and javascript), then add some type of integration testing. Most of our recent additions don't have great code coverage, and events are hard to unit test. So I think this is the right time to add something to help increase our coverage around these more complicated cases.

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.
const NoopContext = struct {
pub fn onInspectorResponse(_: *anyopaque, _: u32, _: []const u8) void {}
pub fn onInspectorEvent(_: *anyopaque, _: []const u8) void {}
pub fn notify(_: *anyopaque, _: *const Notification) !void {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could eventually use notifications to send also inspector's events...

@krichprollsch krichprollsch merged commit f034065 into main Apr 10, 2025
12 checks passed
@krichprollsch krichprollsch deleted the navigate_notifications branch April 10, 2025 11:42
@github-actions github-actions bot locked and limited conversation to collaborators Apr 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants