class: ChromiumBrowserContext
- extends: BrowserContext
Chromium-specific features including background pages, service worker support, etc.
const backgroundPage = await context.waitForEvent('backgroundpage');
- event: ‘backgroundpage’
- event: ‘serviceworker’
- chromiumBrowserContext.backgroundPages()
- chromiumBrowserContext.newCDPSession(page)
- event: ‘page’
- browserContext.addCookies(cookies)
- browserContext.addInitScript(script[, arg])
- browserContext.clearCookies()
- browserContext.clearPermissions()
- browserContext.close()
- browserContext.cookies([urls])
- browserContext.exposeBinding(name, playwrightBinding)
- browserContext.exposeFunction(name, playwrightFunction)
- browserContext.grantPermissions(permissions[][, options])
- browserContext.newPage()
- browserContext.pages()
- browserContext.route(url, handler)
- browserContext.setDefaultNavigationTimeout(timeout)
- browserContext.setDefaultTimeout(timeout)
- browserContext.setExtraHTTPHeaders(headers)
- browserContext.setGeolocation(geolocation)
- browserContext.setHTTPCredentials(httpCredentials)
- browserContext.setOffline(offline)
- browserContext.unroute(url[, handler])
- browserContext.waitForEvent(event[, optionsOrPredicate])
event: ‘backgroundpage’
- <Page>
Emitted when new background page is created in the context.
NOTE Only works with persistent context.
event: ‘serviceworker’
- <Worker>
Emitted when new service worker is created in the context.
chromiumBrowserContext.backgroundPages()
chromiumBrowserContext.newCDPSession(page)
page
<Page> Page to create new session for.- returns: <Promise<CDPSession>> Promise that resolves to the newly created session.