EmulationDomain

This domain emulates different environments for the page.

Official doc

Functions

Link copied to clipboard
inline suspend fun addScreen(left: Int, top: Int, width: Int, height: Int, optionalArgs: AddScreenRequest.Builder.() -> Unit = {}): AddScreenResponse

Add a new screen to the device. Only supported in headless mode.

Link copied to clipboard

Tells whether emulation is supported.

Link copied to clipboard

Clears the overridden device metrics.

Link copied to clipboard

Clears a device posture override set with either setDeviceMetricsOverride() or setDevicePostureOverride() and starts using posture information from the platform again. Does nothing if no override is set.

Link copied to clipboard

Clears the display features override set with either setDeviceMetricsOverride() or setDisplayFeaturesOverride() and starts using display features from the platform again. Does nothing if no override is set.

Link copied to clipboard

Clears the overridden Geolocation Position and Error.

Link copied to clipboard

Clears Idle state overrides.

Link copied to clipboard
fun events(): Flow<EmulationEvent>

Subscribes to all events related to this domain.

Link copied to clipboard

Returns device's screen configuration.

Link copied to clipboard

Remove screen from the device. Only supported in headless mode.

Link copied to clipboard

Requests that page scale factor is reset to initial values.

Link copied to clipboard

Automatically render all web contents using a dark theme.

Link copied to clipboard
Link copied to clipboard

Enables CPU throttling to emulate slow CPUs.

Link copied to clipboard

Override the value of navigator.connection.saveData

Link copied to clipboard

Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.

Link copied to clipboard
inline suspend fun setDeviceMetricsOverride(width: Int, height: Int, deviceScaleFactor: Double, mobile: Boolean, optionalArgs: SetDeviceMetricsOverrideRequest.Builder.() -> Unit = {}): SetDeviceMetricsOverrideResponse

Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media query results).

Link copied to clipboard

Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().

Link copied to clipboard
Link copied to clipboard

Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().

Link copied to clipboard

Emulates the given media type or media feature for CSS media queries.

Link copied to clipboard

Enables or disables simulating a focused and active page.

Link copied to clipboard

Overrides the Geolocation Position or Error. Omitting latitude, longitude or accuracy emulates position unavailable.

Link copied to clipboard
suspend fun setIdleOverride(isUserActive: Boolean, isScreenUnlocked: Boolean): SetIdleOverrideResponse

Overrides the Idle state.

Link copied to clipboard

Overrides default host system locale with the specified one.

Link copied to clipboard

Overrides value returned by the javascript navigator object.

Link copied to clipboard

Sets a specified page scale factor.

Link copied to clipboard

Provides a given pressure data set that will be processed and eventually be delivered to PressureObserver users. |source| must have been previously overridden by setPressureSourceOverrideEnabled.

Link copied to clipboard

Overrides a pressure source of a given type, as used by the Compute Pressure API, so that updates to PressureObserver.observe() are provided via setPressureStateOverride instead of being retrieved from platform-provided telemetry data.

Link copied to clipboard

TODO: OBSOLETE: To remove when setPressureDataOverride is merged. Provides a given pressure state that will be processed and eventually be delivered to PressureObserver users. |source| must have been previously overridden by setPressureSourceOverrideEnabled.

Link copied to clipboard

Overrides the values for env(safe-area-inset-) and env(safe-area-max-inset-). Unset values will cause the respective variables to be undefined, even if previously overridden.

Link copied to clipboard

(undocumented in the protocol definition)

Link copied to clipboard

Overrides a platform sensor of a given type. If |enabled| is true, calls to Sensor.start() will use a virtual sensor as backend rather than fetching data from a real hardware sensor. Otherwise, existing virtual sensor-backend Sensor objects will fire an error event and new calls to Sensor.start() will attempt to use a real sensor instead.

Link copied to clipboard

Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.

Link copied to clipboard

Allows overriding the difference between the small and large viewport sizes, which determine the value of the svh and lvh unit, respectively. Only supported for top-level frames.

Link copied to clipboard

Overrides default host system timezone with the specified one.

Link copied to clipboard

Enables touch on platforms which do not support them.

Link copied to clipboard

Allows overriding user agent with the given string. userAgentMetadata must be set for Client Hint headers to be sent.

Link copied to clipboard

Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets the current virtual time policy. Note this supersedes any previous time budget.

Link copied to clipboard
suspend fun setVisibleSize(width: Int, height: Int): SetVisibleSizeResponse

Resizes the frame/viewport of the page. Note that this does not affect the frame's container (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported on Android.

Link copied to clipboard

Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.