WorkerSession

A session created when attaching to a target of type Worker.

The subset of domains available for this target type is not strictly defined by the protocol. The subset provided in this interface is guaranteed to work on this target type. However, some domains might be missing in this interface while being effectively supported by the target. If this is the case, you can use the unsafe function to access all domains.

As a subinterface of WorkerTarget, it inherits the generated domain properties that match the latest Chrome DevToolsProtocol definitions. As such, it is not stable for inheritance, as new properties can be added without major version bump when the protocol changes. It is however safe to use all non-experimental and non-deprecated domains defined here. The experimental and deprecation cycles of the protocol are reflected in this interface with the same guarantees.

Properties

Link copied to clipboard
abstract val io: IODomain

Input/Output operations for streams produced by DevTools.

Link copied to clipboard

Info about this session and its underlying target.

Link copied to clipboard
abstract val network: NetworkDomain

Network domain allows tracking network activities of the page. It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc.

Link copied to clipboard
abstract val parent: BrowserSession

The parent browser session that created this target session.

Link copied to clipboard
abstract val target: TargetDomain

Supports additional targets discovery and allows to attach to them.

Functions

Link copied to clipboard

Adapts this ChildSession to a AuctionWorkletSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard

Adapts this ChildSession to a PageSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard

Adapts this ChildSession to a ServiceWorkerSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard

Adapts this ChildSession to a SharedStorageWorkletSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard

Adapts this ChildSession to a SharedWorkerSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard

Adapts this ChildSession to a WebContentsSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard

Adapts this ChildSession to a WorkerSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard

Adapts this ChildSession to a WorkletSession. If the attached target is not of a compatible type, this function throws an exception.

Link copied to clipboard
abstract suspend fun close(keepBrowserContext: Boolean = false)

Closes this session and its target. If the target is a page, the tab gets closed.

Link copied to clipboard
abstract suspend fun closeWebSocket()

Closes the underlying web socket connection, effectively closing every session based on the same web socket connection.

Link copied to clipboard
abstract suspend fun detach()

Detaches this session from its target, effectively closing this session and all its child sessions, but without closing the corresponding target (this leaves the tab open in the case of a page session).

Link copied to clipboard
abstract fun unsafe(): AllDomainsTarget

Gives access to all domains of the protocol, regardless of the type of this session.