A WebContext is a browser-data profile that controls what cookies, cache, local storage, and IndexedDB data a group of webviews can see. By passing the same context to multiple webviews you make them share a single data store — they behave like tabs in the same browser session. By giving each user or session its own context (pointing to its own directory on disk) you achieve complete isolation between them.
Creating a Context
Always create a WebContext through the application. Calling new WebContext() directly is not supported.
Creation options
Sharing Data Between Webviews
Pass the same WebContext instance to multiple createWebview() calls to give those webviews a common cookie jar, cache, and local storage.
Isolated Profiles
Create a separate context for each user or workspace to prevent any data from leaking across profiles:
Default context (no explicit directory)
Omit dataDirectory to use the platform backend’s default context location. This is not an in-memory guarantee. For a predictable persistent profile, provide an explicit directory; for a private session, use incognito: true on the webview.
Properties and Methods
The explicitly configured data directory, or null when no directory was
passed to the factory. A null value does not mean that the backend uses only
memory.
Returns true if the given URL scheme has been registered as a custom protocol on this context’s native registry.
Enable or disable WebDriver automation support at runtime. See Automation below.
Automation
Setting allowsAutomation: true (or calling context.setAllowsAutomation(true)) enables WebDriver/CDP-based automated testing for webviews that use this context.
Automation is currently enforced only on Linux. The Linux WebKitGTK
backend permits at most one automatable context at a time; the backend
controls how a conflicting context is reported. Enable automation only for
controlled testing environments — never in production builds.
Lifetime and Disposal
Keep a context alive for at least as long as every webview that uses it. Dispose the webviews before disposing their context.
Do not use webviews after disposing their context. Always dispose webviews before
their context, or rely on app.exit() to clean everything up in the correct
order.
app.exit() disposes all contexts created through that application automatically, in the correct order. For manual cleanup:
Disposal is idempotent — calling dispose() more than once is safe.