Repository navigation
feat: register adopted contexts from what Node reports - #5372
Merged
Merged
Conversation
Node writes a report on the response stream of the extension call as soon as adoptContext resolves: the context id, its trace file, the options the extension passed as contextOptions and the video of its active page. call_js_keyword registers each report the way New Context registers its own contexts: keyword trace groups, cached video size, embedded video. Every extension call goes through call_js_keyword, so a plain jsextension keyword now gets this too, where before only a library built on Browser could. The video size comes from the reported recordVideo, then the viewport, then 1280x720, so a context adopted without its options still embeds its video. register_adopted_context is removed. It was never released; a library built on Browser no longer passes the options twice nor returns the video path. ADR 0010 records the decision, and Browser/CONTEXT.md names the adopted context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adoptContext(context, { activePage }) makes that page the active page, and
Browser reports its id and the video of it. Without the option the page that
Playwright saw first stays active, as before.
An Electron application that shows a WebContentsView or a <webview> first
makes the view the first page, while the library wants the window. A WebView
page of an Android app is the same case. The page must belong to the adopted
context; otherwise adoptContext fails and adopts nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Browser registers an adopted context itself, the way
New Contextregisters its own: thekeyword calls become trace groups, the video size is cached, the log embeds the video. Until now
a library built on Browser had to call
register_adopted_contextafter the extension call, anda plain
jsextensionkeyword could not do it at all. Decision and rejected options: ADR 0010.sequenceDiagram participant Python as call_js_keyword participant Node as extensionKeywordCall participant Ext as extension function Python->>Node: CallExtensionKeyword Node->>Ext: fn(..., adoptContext) Ext->>Node: adoptContext(context, {tracing, contextOptions}) Node-->>Python: Json{adoptedContext: {id, traceFile, contextOptions, video}} Note over Python: registers it while reading the stream Ext-->>Node: result (or throws) Node-->>Python: Json{bodyPart} (or the error)The report goes out as soon as
adoptContextresolves, so a context adopted before the functionthrows is registered too. Node is the source of truth: the trace file it started, the options
the extension passed, the video it got. The video size comes from the reported
recordVideo,then the viewport, then 1280x720.
What a library built on Browser no longer does:
options = self.adopted_context_options(tracing=tracing, recordVideo=record_video) adopted = self.call_js_keyword("openApplication", **options) -return self.register_adopted_context(adopted["contextId"], options, adopted["videoPath"]) +return adopted["videoPath"]message Json { string log = 1; string json = 2; string bodyPart = 3; + string adoptedContext = 4; }register_adopted_contextis removed. It came with #5326 and was never released.adoptContext(context, { activePage })makes that page the active page, and Browser reports itsid and its video. An Electron app that shows a WebContentsView or
<webview>first makes the viewthe first page, while the library wants the window; a WebView page of an Android app is the same
case. The page must belong to the adopted context, otherwise
adoptContextadopts nothing.Evidence
jsextensionkeyword adopts a traced context; the trace has no keywordgroups (
[ ] does not contain match for pattern 'Browser.Open Adopted Persistent Context ...').After:
An Adopted Context Is Traced With Keyword Groups And Accepts Downloadspasses.call_js_keywordseam: trace groups, tracing group modes, several contextsin one call, video embedding and its size, a context adopted without pages or without its
options, and a report sent before the extension function fails.
Get Urlisabout:blank. After:The Creator Of An Adopted Context Chooses Its Active Pagepasses.pass on macOS, the two failures are unrelated (
/private/varpath, a.vsixnot built).inv utest,inv utest-node,inv lint,inv atestpass locally, apart from three Firefoxtests whose browser does not launch on my machine.
Merge Danger
Door: two-way
The proto field is new; nothing else reads it.
Blast Radius: extensions
Only extension calls that adopt a context behave differently, and
adoptContextis unreleased.The Electron library (robotcodedev/robotframework-electron-vscode) calls
register_adopted_contextand must drop that call before it runs on the next release.🤖 Generated with Claude Code