Skip to content

feat(addInitScript): allow passing functions as init script arguments#41921

Merged
pavelfeldman merged 1 commit into
microsoft:mainfrom
pavelfeldman:feat-init-script-expose-functions
Jul 21, 2026
Merged

feat(addInitScript): allow passing functions as init script arguments#41921
pavelfeldman merged 1 commit into
microsoft:mainfrom
pavelfeldman:feat-init-script-expose-functions

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

Summary

  • page.addInitScript() and browserContext.addInitScript() now accept functions inside arg when called with the new { exposeFunctions: true } option, following feat(evaluate): allow passing functions as evaluate arguments #41801.
  • Functions are backed by noGlobal bindings that are re-installed in every new document, so unlike evaluate(), they survive navigations.
  • Disposing the returned disposable removes both the init script and the bindings backing the functions.

@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"

Warning

The triggering workflow run ended with status cancelled. Results below may be incomplete — blob reports from cancelled or timed-out shards are missing, so passing/failing counts do not reflect the full test suite.

5 flaky ⚠️ [chromium-library] › library/chromium/chromium.spec.ts:299 › should report intercepted service worker requests in HAR `@chromium-ubuntu-22.04-arm-node20`
⚠️ [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/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:664 › screencast › should capture full viewport `@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`

50106 passed, 1190 skipped


Merge workflow run.

@pavelfeldman
pavelfeldman merged commit f39623b into microsoft:main Jul 21, 2026
49 of 50 checks passed
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