cdp: serve /json target list and create the target for flat-protocol clients - #3352
cdp: serve /json target list and create the target for flat-protocol clients#3352arrufat wants to merge 7 commits into
Conversation
|
Converting this to a draft because it is really a "do we want this surface?" question rather than a bug fix, and I would rather have your call on it. @karlseguin @krichprollsch what do you think? Demand: honestly, none on record. No issue mentions pychrome or chrome-remote-interface, and nobody has reported the Cost: the Both or neither: the two halves are coupled. Shipping only the If no, I will close this and leave |
…clients /json and /json/list returned an empty array and /json/new did not exist, so target-listing clients (chrome-remote-interface, pychrome, Selenium 4) found nothing to connect to. Return a one-element list; add /json/new (GET+PUT), /json/activate/* and /json/close/*. Listing alone is not enough: those clients connect to the advertised webSocketDebuggerUrl and drive Page/Runtime directly, without the Target.createBrowserContext/createTarget/attachToTarget handshake, and every command failed with BrowserContextNotLoaded. The dispatcher now runs Target.createTarget's setup (extracted into setupTarget) plus an attach on the first sessionless command to a page-scoped domain. Browser-level domains never trigger it, so session-based drivers keep creating their context explicitly.
fb0e64a to
3ed58da
Compare
# Conflicts: # src/cdp/Connection.zig # src/server/Server.zig # src/server/cdp/CDP.zig # src/server/cdp/domains/network.zig # src/server/cdp/testing.zig
What
/jsonand/json/listreturn a one-element target list instead of[]; new/json/new(GET+PUT),/json/activate/*and/json/close/*endpoints. The listed target is synthetic (built at server init, before any browser context exists);/json/new?urland/json/closeare accepted no-ops that lognot_implemented./json, connect to thewebSocketDebuggerUrl, and sendPage.*/Runtime.*directly with noTargethandshake. Previously every such command failed withBrowserContextNotLoaded. Page-scoped handlers now obtain their context throughCommand.requireBrowserContext, which for a sessionless command creates the browser context, target and attached session — reusingTarget.createTarget's setup, extracted intosetupTarget. Attaching is required because page events (including thePage.navigateresponse) are only emitted to an attached session.X.disable,Page.close) on a connection with no context succeed as no-ops viaCommand.teardownBrowserContextinstead of creating a page. Handlers that resolve ids minted by an earlier command keep returningBrowserContextNotLoaded, since a fresh context can never satisfy them.Handshake.handleHttpRequestignores the query string and one trailing slash (as Chrome does) and doesn't wait on a PUT body. HTTP responses shareHandshake.buildResponse.Why
Target-listing drivers could not connect at all. Session-based drivers (Puppeteer, Playwright, chromedp) are unaffected: their commands either carry a session id or go through the
Target/Browserdomains, neither of which creates a page implicitly. Handlers that never needed a context (Page.enable,Page.getFrameTree) are unchanged.Three tests that asserted
BrowserContextNotLoadedfor sessionless page commands were updated to the new behavior.