xk6-browser
xk6-browser copied to clipboard
Implement `BrowserContext.addInitScript(script[, arg])`
Add support for BrowserContext.addInitScript(script[, arg]), to set script to run on every new page creation or navigation nd every new frame attachment in browser context.
Relevant links:
- Playwright docs: https://playwright.dev/docs/api/class-browsercontext#browser-context-add-init-script
- xk6-browser code starting point: https://github.com/grafana/xk6-browser/blob/main/common/browser_context.go#L81 (the actual execution of the code on page creation/navigation or frame attachement is not implemented)
- Playwright code: https://github.com/microsoft/playwright/blob/master/packages/playwright-core/src/server/chromium/crBrowser.ts#L447
- Playwright tests: https://github.com/microsoft/playwright/blob/master/tests/browsercontext-add-init-script.spec.ts