Skip to content

Conversation

@karlseguin
Copy link
Collaborator

When the inspector returns a RemoteObject, the proper subType must be returned in order for the driver (i.e. puppeteer) to know what methods are available.

For example, on any page.$eval, the first thing puppeteer does is request the document object via a Runtime.callFunctionOn which simply does

return document;

If the description of the document that we return (a "RemoteObject") doesn't include the "node" subtype, the puppeteer will fail.

This PR provides the hooks for an implementation to provide its own valueSubtype implementation. However, in order for v8 to include the node field, we must always also include a "description" field, which is why this PR also allows implementations to provide its own descriptionForValueSubtype.

When the inspector returns a RemoteObject, the proper subType must be returned
in order for the driver (i.e. puppeteer) to know what methods are available.

For example, on any page.$eval, the first  thing puppeteer does is request the
document object via a Runtime.callFunctionOn which simply does

   return document;

If the description of the document that we return (a "RemoteObject") doesn't
include the "node" subtype, the puppeteer will fail.

This PR provides the hooks for an implementation to provide its own valueSubtype
implementation. However, in order for v8 to include the `node` field, we must
always also include a "description" field, which is why this PR also allows
implementations to provide its own `descriptionForValueSubtype`.
const t = std.testing;

const c = @cImport({
pub const c = @cImport({
Copy link
Member

Choose a reason for hiding this comment

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

You need to expose c?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When the implementation is written in zig-js-runtime (or maybe browser), they'll receive the raw C++ objects (c.Context and c.Value instead of v8.Context and v8.Value).

The only way I figured out how to provide a wrapper, is to do something like StdOptions, but that requires defining these things in main.zig (i.e. root), which, maybe it's just me, but I don't love.

Copy link
Member

Choose a reason for hiding this comment

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

I'm ok it's better to keep it ilke this.

@krichprollsch krichprollsch merged commit ac2f707 into lightpanda-io:fork Mar 25, 2025
@karlseguin karlseguin deleted the valueSubtype branch April 3, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants