Skip to content

fix(webview): route exposeFunctions callbacks to the originating frame#41919

Merged
dcrousso merged 1 commit into
microsoft:mainfrom
dcrousso:fix-webview-frame-binding
Jul 23, 2026
Merged

fix(webview): route exposeFunctions callbacks to the originating frame#41919
dcrousso merged 1 commit into
microsoft:mainfrom
dcrousso:fix-webview-frame-binding

Conversation

@dcrousso

Copy link
Copy Markdown
Contributor

WebKit has no Runtime.addBinding, so the webview delegate has to handle bindings through console.debug(BINDING_CALL_TAG, payload) instead

the console message carries no execution context id, so every call was dispatched against the main frame, meaning a callback fired from a child frame (e.g. frame.evaluate(..., { exposeFunctions: true })) reached the wrong BindingsController and never resolved the calling frame's pending promise, hanging until the 30s timeout tore the page down

tag each call with an empty object created in the calling context, as an objectId carries the injected script id, meaning that the host can route the call to the frame it came from and release the marker afterwards

@dcrousso
dcrousso requested review from pavelfeldman and yury-s July 21, 2026 20:46
@pavelfeldman

Copy link
Copy Markdown
Member

Please add a test

WebKit has no `Runtime.addBinding`, so the webview delegate has to handle bindings through `console.debug(BINDING_CALL_TAG, payload)` instead

the console message carries no execution context id, so every call was dispatched against the main frame, meaning a callback fired from a child frame (e.g. `frame.evaluate(..., { exposeFunctions: true })`) reached the wrong `BindingsController` and never resolved the calling frame's pending promise, hanging until the 30s timeout tore the page down

tag each call with an empty object created in the calling context, as an `objectId` carries the injected script id, meaning that the host can route the call to the frame it came from and release the marker afterwards
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@dcrousso
dcrousso force-pushed the fix-webview-frame-binding branch from 16e259c to 401d6fc Compare July 21, 2026 21:36
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7792 passed, 1269 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

3 flaky ⚠️ [chromium-library] › library/chromium/chromium.spec.ts:371 › should produce network events, routing, and annotations for Service Worker `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/har-websocket.spec.ts:235 › should attach websocket messages `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`

50053 passed, 1190 skipped


Merge workflow run.

@dcrousso
dcrousso merged commit fd9395d into microsoft:main Jul 23, 2026
51 of 54 checks passed
@dcrousso
dcrousso deleted the fix-webview-frame-binding branch July 23, 2026 17:35
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