Skip to content

feat(node): add BrowserContext shim and page default timeouts#108

Open
Ralkage wants to merge 1 commit into
Skyvern-AI:mainfrom
Ralkage:feat/node-context-and-default-timeouts
Open

feat(node): add BrowserContext shim and page default timeouts#108
Ralkage wants to merge 1 commit into
Skyvern-AI:mainfrom
Ralkage:feat/node-context-and-default-timeouts

Conversation

@Ralkage

@Ralkage Ralkage commented Jul 20, 2026

Copy link
Copy Markdown

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 with browser.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)BrowserContext with newPage(), pages(), browser(), setDefaultTimeout(), setDefaultNavigationTimeout(), close(); plus browser.contexts().
  • page.setDefaultTimeout() / page.setDefaultNavigationTimeout().

Design notes / honest caveats

  • 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 the pages it creates. Documented in code comments and the type declarations.
  • ignoreHTTPSErrors is 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-time console.warn pointing to launch({ args: ['--ignore-certificate-errors'] }).
  • Timeout precedence matches Playwright: explicit per-call timeout wins; otherwise the page default; otherwise undefined is passed through so the native layer applies its own default. Navigation falls back navigation-default → default.

Testing

  • Extended node/smoke.mjs to run the full newContext → setDefaultTimeout → newPage → setDefaultNavigationTimeout → goto/fill/click/textContent/evaluate/screenshot → context.close() flow; passes against the prebuilt binary.
  • Verified against the published rustwright@0.1.1 native binary by overlaying this wrapper: an independent API-coverage probe went from 10/12 to 12/12, with newContext and setDefaultTimeout now passing and existing methods unaffected.

Notes

Types in node/index.d.ts are regenerated via node/scripts/generate-types.mjs (the source of truth), which is updated in the same commit.

🤖 Generated with Claude Code

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>
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.

1 participant