feat(node): add BrowserContext shim and page default timeouts#108
Open
Ralkage wants to merge 1 commit into
Open
feat(node): add BrowserContext shim and page default timeouts#108Ralkage wants to merge 1 commit into
Ralkage wants to merge 1 commit into
Conversation
The Node binding exposed launch/newPage/goto/click/fill/title/textContent/
evaluate/screenshot/close but was missing two commonly-used Playwright entry
points, which made drop-in scripts fail early:
- browser.newContext(...) / context.newPage() / context.close()
- page.setDefaultTimeout() / page.setDefaultNavigationTimeout()
Both are implemented in the JS wrapper only; the native engine and prebuilt
binary are unchanged.
BrowserContext is a compatibility shim: the alpha Node engine drives a single
Chromium process, so it does NOT provide the storage/cookie isolation of a real
Playwright context. It exists to keep the familiar newContext().newPage() shape
working and to propagate default timeouts to pages it creates.
ignoreHTTPSErrors is accepted for API compatibility but cannot be toggled per
context after launch, so it emits a one-time warning pointing users to
launch({ args: ['--ignore-certificate-errors'] }) rather than silently
no-opping a security-relevant flag.
Page default timeouts follow Playwright precedence: an explicit per-call
timeout wins, otherwise the page default is used, otherwise undefined is passed
through so the native layer applies its own default.
Types are regenerated via scripts/generate-types.mjs and the smoke test now
exercises the context + default-timeout flow.
Co-Authored-By: Claude Opus 4.8 (1M context) <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
The Node binding bridges
launch/newPage/goto/click/fill/title/textContent/evaluate/screenshot/close, but two commonly-used Playwright entry points were missing, so drop-in scripts fail early withbrowser.newContext is not a function/page.setDefaultTimeout is not a function. This adds them in the JS wrapper only — the native engine and prebuilt binary are unchanged.Added:
browser.newContext(options)→BrowserContextwithnewPage(),pages(),browser(),setDefaultTimeout(),setDefaultNavigationTimeout(),close(); plusbrowser.contexts().page.setDefaultTimeout()/page.setDefaultNavigationTimeout().Design notes / honest caveats
BrowserContextis a compatibility shim. The alpha Node engine drives a single Chromium process, so it does not provide the storage/cookie isolation of a real Playwright context. It exists to keep the familiarnewContext().newPage()shape working and to propagate default timeouts to the pages it creates. Documented in code comments and the type declarations.ignoreHTTPSErrorsis accepted but not enforced. Certificate handling is a launch-time concern for the current engine and can't be toggled per-context after the browser is running. Rather than silently no-op a security-relevant flag, the shim emits a one-timeconsole.warnpointing tolaunch({ args: ['--ignore-certificate-errors'] }).timeoutwins; otherwise the page default; otherwiseundefinedis passed through so the native layer applies its own default. Navigation falls back navigation-default → default.Testing
node/smoke.mjsto run the fullnewContext → setDefaultTimeout → newPage → setDefaultNavigationTimeout → goto/fill/click/textContent/evaluate/screenshot → context.close()flow; passes against the prebuilt binary.rustwright@0.1.1native binary by overlaying this wrapper: an independent API-coverage probe went from 10/12 to 12/12, withnewContextandsetDefaultTimeoutnow passing and existing methods unaffected.Notes
Types in
node/index.d.tsare regenerated vianode/scripts/generate-types.mjs(the source of truth), which is updated in the same commit.🤖 Generated with Claude Code