Documentation ¶
Overview ¶
Package chromium is responsible for launching a Chrome browser process and managing its lifetime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChromeNotInstalled is returned when the Chrome executable is not found. ErrChromeNotInstalled = errors.New( "k6 couldn't detect google chrome or a chromium-supported browser on this system", ) // ErrChromeNotFoundAtPath is returned when the Chrome executable is not found at the given path. ErrChromeNotFoundAtPath = errors.New( "k6 couldn't detect google chrome or a chromium-supported browser on the given path", ) )
Functions ¶
This section is empty.
Types ¶
type BrowserType ¶
type BrowserType struct { // FIXME: This is only exported because testBrowser needs it. Contexts // shouldn't be stored on structs if we can avoid it. Ctx context.Context // contains filtered or unexported fields }
BrowserType provides methods to launch a Chrome browser instance or connect to an existing one. It's the entry point for interacting with the browser.
func NewBrowserType ¶
func NewBrowserType(vu k6modules.VU) *BrowserType
NewBrowserType registers our custom k6 metrics, creates method mappings on the sobek runtime, and returns a new Chrome browser type.
func (*BrowserType) Connect ¶
func (b *BrowserType) Connect(ctx, vuCtx context.Context, wsEndpoint string) (*common.Browser, error)
Connect attaches k6 browser to an existing browser instance.
vuCtx is the context coming from the VU itself. The k6 vu/iteration controls its lifecycle.
context.background() is used when connecting to an instance of chromium. The connection lifecycle should be handled by the k6 event system.
The separation is important to allow for the iteration to end when k6 requires the iteration to end (e.g. during a SIGTERM) and unblocks k6 to then fire off the events which allows the connection to close.
func (*BrowserType) Launch ¶
func (b *BrowserType) Launch(ctx, vuCtx context.Context) (_ *common.Browser, browserProcessID int, _ error)
Launch allocates a new Chrome browser process and returns a new Browser value, which can be used for controlling the Chrome browser.
vuCtx is the context coming from the VU itself. The k6 vu/iteration controls its lifecycle.
context.background() is used when launching an instance of chromium. The chromium lifecycle should be handled by the k6 event system.
The separation is important to allow for the iteration to end when k6 requires the iteration to end (e.g. during a SIGTERM) and unblocks k6 to then fire off the events which allows the chromium subprocess to shutdown.
func (*BrowserType) Name ¶
func (b *BrowserType) Name() string
Name returns the name of this browser type.