Emulation

class Emulation(cdp: CDP) : Domain

This domain emulates different environments for the page.

Constructors

Link copied to clipboard
constructor(cdp: CDP)

Types

Link copied to clipboard
@Serializable
data class CanEmulateReturn(val result: Boolean)
Link copied to clipboard
@Serializable
data class DevicePosture(val type: String)
Link copied to clipboard

Enum of image types that can be disabled.

Link copied to clipboard
@Serializable
data class DisplayFeature(val orientation: String, val offset: Int, val maskLength: Int)
Link copied to clipboard
@Serializable
data class GetOverriddenSensorInformationReturn(val requestedSamplingFrequency: Double)
Link copied to clipboard
@Serializable
data class MediaFeature(val name: String, val value: String)
Link copied to clipboard
@Serializable
data class PressureMetadata(val available: Boolean? = null)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Serializable
data class SafeAreaInsets(val top: Int? = null, val topMax: Int? = null, val left: Int? = null, val leftMax: Int? = null, val bottom: Int? = null, val bottomMax: Int? = null, val right: Int? = null, val rightMax: Int? = null)
Link copied to clipboard
@Serializable
data class ScreenOrientation(val type: String, val angle: Int)

Screen orientation.

Link copied to clipboard
@Serializable
data class SensorMetadata(val available: Boolean? = null, val minimumFrequency: Double? = null, val maximumFrequency: Double? = null)
Link copied to clipboard
@Serializable
data class SensorReading(val single: Emulation.SensorReadingSingle? = null, val xyz: Emulation.SensorReadingXYZ? = null, val quaternion: Emulation.SensorReadingQuaternion? = null)
Link copied to clipboard
@Serializable
data class SensorReadingQuaternion(val x: Double, val y: Double, val z: Double, val w: Double)
Link copied to clipboard
@Serializable
data class SensorReadingSingle(val value: Double)
Link copied to clipboard
@Serializable
data class SensorReadingXYZ(val x: Double, val y: Double, val z: Double)
Link copied to clipboard
@Serializable
enum SensorType : Enum<Emulation.SensorType>

Used to specify sensor types to emulate. See https://w3c.github.io/sensors/#automation for more information.

Link copied to clipboard
@Serializable
data class SetAutoDarkModeOverrideParameter(val enabled: Boolean? = null)
Link copied to clipboard
@Serializable
data class SetAutomationOverrideParameter(val enabled: Boolean)
Link copied to clipboard
@Serializable
data class SetCPUThrottlingRateParameter(val rate: Double)
@Serializable
data class SetDefaultBackgroundColorOverrideParameter(val color: DOM.RGBA? = null)
Link copied to clipboard
@Serializable
data class SetDeviceMetricsOverrideParameter(val width: Int, val height: Int, val deviceScaleFactor: Double, val mobile: Boolean, val scale: Double? = null, val screenWidth: Int? = null, val screenHeight: Int? = null, val positionX: Int? = null, val positionY: Int? = null, val dontSetVisibleSize: Boolean? = null, val screenOrientation: Emulation.ScreenOrientation? = null, val viewport: Page.Viewport? = null, val displayFeature: Emulation.DisplayFeature? = null, val devicePosture: Emulation.DevicePosture? = null)
Link copied to clipboard
@Serializable
data class SetDevicePostureOverrideParameter(val posture: Emulation.DevicePosture)
Link copied to clipboard
@Serializable
data class SetDisabledImageTypesParameter(val imageTypes: List<Emulation.DisabledImageType>)
Link copied to clipboard
@Serializable
data class SetDisplayFeaturesOverrideParameter(val features: List<Emulation.DisplayFeature>)
Link copied to clipboard
@Serializable
data class SetDocumentCookieDisabledParameter(val disabled: Boolean)
Link copied to clipboard
@Serializable
data class SetEmitTouchEventsForMouseParameter(val enabled: Boolean, val configuration: String? = null)
Link copied to clipboard
@Serializable
data class SetEmulatedMediaParameter(val media: String? = null, val features: List<Emulation.MediaFeature>? = null)
Link copied to clipboard
@Serializable
data class SetEmulatedOSTextScaleParameter(val scale: Double? = null)
Link copied to clipboard
@Serializable
data class SetEmulatedVisionDeficiencyParameter(val type: String)
Link copied to clipboard
@Serializable
data class SetFocusEmulationEnabledParameter(val enabled: Boolean)
Link copied to clipboard
@Serializable
data class SetGeolocationOverrideParameter(val latitude: Double? = null, val longitude: Double? = null, val accuracy: Double? = null, val altitude: Double? = null, val altitudeAccuracy: Double? = null, val heading: Double? = null, val speed: Double? = null)
Link copied to clipboard
@Serializable
data class SetHardwareConcurrencyOverrideParameter(val hardwareConcurrency: Int)
Link copied to clipboard
@Serializable
data class SetIdleOverrideParameter(val isUserActive: Boolean, val isScreenUnlocked: Boolean)
Link copied to clipboard
@Serializable
data class SetLocaleOverrideParameter(val locale: String? = null)
Link copied to clipboard
@Serializable
data class SetNavigatorOverridesParameter(val platform: String)
Link copied to clipboard
@Serializable
data class SetPageScaleFactorParameter(val pageScaleFactor: Double)
Link copied to clipboard
@Serializable
data class SetPressureDataOverrideParameter(val source: Emulation.PressureSource, val state: Emulation.PressureState, val ownContributionEstimate: Double? = null)
@Serializable
data class SetPressureSourceOverrideEnabledParameter(val enabled: Boolean, val source: Emulation.PressureSource, val metadata: Emulation.PressureMetadata? = null)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Serializable
data class SetScriptExecutionDisabledParameter(val value: Boolean)
Link copied to clipboard
@Serializable
data class SetScrollbarsHiddenParameter(val hidden: Boolean)
Link copied to clipboard
@Serializable
data class SetSensorOverrideEnabledParameter(val enabled: Boolean, val type: Emulation.SensorType, val metadata: Emulation.SensorMetadata? = null)
Link copied to clipboard
@Serializable
data class SetSmallViewportHeightDifferenceOverrideParameter(val difference: Int)
Link copied to clipboard
@Serializable
data class SetTimezoneOverrideParameter(val timezoneId: String)
Link copied to clipboard
@Serializable
data class SetTouchEmulationEnabledParameter(val enabled: Boolean, val maxTouchPoints: Int? = null)
Link copied to clipboard
@Serializable
data class SetUserAgentOverrideParameter(val userAgent: String, val acceptLanguage: String? = null, val platform: String? = null, val userAgentMetadata: Emulation.UserAgentMetadata? = null)
Link copied to clipboard
@Serializable
data class SetVirtualTimePolicyParameter(val policy: Emulation.VirtualTimePolicy, val budget: Double? = null, val maxVirtualTimeTaskStarvationCount: Int? = null, val initialVirtualTime: Double? = null)
Link copied to clipboard
@Serializable
data class SetVirtualTimePolicyReturn(val virtualTimeTicksBase: Double)
Link copied to clipboard
@Serializable
data class SetVisibleSizeParameter(val width: Int, val height: Int)
Link copied to clipboard
@Serializable
data class UserAgentBrandVersion(val brand: String, val version: String)

Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints

Link copied to clipboard
@Serializable
data class UserAgentMetadata(val brands: List<Emulation.UserAgentBrandVersion>? = null, val fullVersionList: List<Emulation.UserAgentBrandVersion>? = null, val fullVersion: String? = null, val platform: String, val platformVersion: String, val architecture: String, val model: String, val mobile: Boolean, val bitness: String? = null, val wow64: Boolean? = null, val formFactors: List<String>? = null)

Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints Missing optional values will be filled in by the target with what it would normally use.

Link copied to clipboard

advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to allow the next delayed task (if any) to run; pause: The virtual time base may not advance; pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending resource fetches.

Properties

Link copied to clipboard

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

Functions

Link copied to clipboard
suspend fun canEmulate(mode: CommandMode = CommandMode.DEFAULT): Emulation.CanEmulateReturn

Tells whether emulation is supported.

Link copied to clipboard
suspend fun clearDeviceMetricsOverride(mode: CommandMode = CommandMode.DEFAULT)

Clears the overridden device metrics.

Link copied to clipboard
suspend fun clearDevicePostureOverride(mode: CommandMode = CommandMode.DEFAULT)

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
suspend fun clearDisplayFeaturesOverride(mode: CommandMode = CommandMode.DEFAULT)

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
suspend fun clearGeolocationOverride(mode: CommandMode = CommandMode.DEFAULT)

Clears the overridden Geolocation Position and Error.

Link copied to clipboard
suspend fun clearIdleOverride(mode: CommandMode = CommandMode.DEFAULT)

Clears Idle state overrides.

Link copied to clipboard
suspend fun resetPageScaleFactor(mode: CommandMode = CommandMode.DEFAULT)

Requests that page scale factor is reset to initial values.

Link copied to clipboard
suspend fun setAutoDarkModeOverride(enabled: Boolean? = null)

Automatically render all web contents using a dark theme.

Link copied to clipboard
suspend fun setAutomationOverride(enabled: Boolean)
suspend fun setAutomationOverride(args: Emulation.SetAutomationOverrideParameter, mode: CommandMode = CommandMode.DEFAULT)

Allows overriding the automation flag.

Link copied to clipboard
suspend fun setCPUThrottlingRate(rate: Double)
suspend fun setCPUThrottlingRate(args: Emulation.SetCPUThrottlingRateParameter, mode: CommandMode = CommandMode.DEFAULT)

Enables CPU throttling to emulate slow CPUs.

Link copied to clipboard
suspend fun setDefaultBackgroundColorOverride(color: DOM.RGBA? = null)

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
suspend fun setDeviceMetricsOverride(width: Int, height: Int, deviceScaleFactor: Double, mobile: Boolean, scale: Double? = null, screenWidth: Int? = null, screenHeight: Int? = null, positionX: Int? = null, positionY: Int? = null, dontSetVisibleSize: Boolean? = null, screenOrientation: Emulation.ScreenOrientation? = null, viewport: Page.Viewport? = null, displayFeature: Emulation.DisplayFeature? = null, devicePosture: Emulation.DevicePosture? = null)

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
Link copied to clipboard
suspend fun setEmitTouchEventsForMouse(enabled: Boolean, configuration: String? = null)
Link copied to clipboard
suspend fun setEmulatedMedia(args: Emulation.SetEmulatedMediaParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setEmulatedMedia(media: String? = null, features: List<Emulation.MediaFeature>? = null)

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

Link copied to clipboard
suspend fun setEmulatedOSTextScale(scale: Double? = null)
suspend fun setEmulatedOSTextScale(args: Emulation.SetEmulatedOSTextScaleParameter, mode: CommandMode = CommandMode.DEFAULT)

Emulates the given OS text scale.

Link copied to clipboard

Emulates the given vision deficiency.

Link copied to clipboard
suspend fun setFocusEmulationEnabled(enabled: Boolean)

Enables or disables simulating a focused and active page.

Link copied to clipboard
suspend fun setGeolocationOverride(args: Emulation.SetGeolocationOverrideParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setGeolocationOverride(latitude: Double? = null, longitude: Double? = null, accuracy: Double? = null, altitude: Double? = null, altitudeAccuracy: Double? = null, heading: Double? = null, speed: Double? = null)

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

Link copied to clipboard
suspend fun setHardwareConcurrencyOverride(hardwareConcurrency: Int)
Link copied to clipboard
suspend fun setIdleOverride(args: Emulation.SetIdleOverrideParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setIdleOverride(isUserActive: Boolean, isScreenUnlocked: Boolean)

Overrides the Idle state.

Link copied to clipboard
suspend fun setLocaleOverride(locale: String? = null)
suspend fun setLocaleOverride(args: Emulation.SetLocaleOverrideParameter, mode: CommandMode = CommandMode.DEFAULT)

Overrides default host system locale with the specified one.

Link copied to clipboard
suspend fun setNavigatorOverrides(platform: String)
suspend fun setNavigatorOverrides(args: Emulation.SetNavigatorOverridesParameter, mode: CommandMode = CommandMode.DEFAULT)

Overrides value returned by the javascript navigator object.

Link copied to clipboard
suspend fun setPageScaleFactor(pageScaleFactor: Double)
suspend fun setPageScaleFactor(args: Emulation.SetPageScaleFactorParameter, mode: CommandMode = CommandMode.DEFAULT)

Sets a specified page scale factor.

Link copied to clipboard
suspend fun setPressureDataOverride(source: Emulation.PressureSource, state: Emulation.PressureState, ownContributionEstimate: Double? = null)

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

Switches script execution in the page.

Link copied to clipboard
suspend fun setScrollbarsHidden(hidden: Boolean)
suspend fun setScrollbarsHidden(args: Emulation.SetScrollbarsHiddenParameter, mode: CommandMode = CommandMode.DEFAULT)
Link copied to clipboard
suspend fun setSensorOverrideEnabled(enabled: Boolean, type: Emulation.SensorType, metadata: Emulation.SensorMetadata? = null)

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
suspend fun setTimezoneOverride(timezoneId: String)
suspend fun setTimezoneOverride(args: Emulation.SetTimezoneOverrideParameter, mode: CommandMode = CommandMode.DEFAULT)

Overrides default host system timezone with the specified one.

Link copied to clipboard
suspend fun setTouchEmulationEnabled(enabled: Boolean, maxTouchPoints: Int? = null)

Enables touch on platforms which do not support them.

Link copied to clipboard
suspend fun setUserAgentOverride(args: Emulation.SetUserAgentOverrideParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setUserAgentOverride(userAgent: String, acceptLanguage: String? = null, platform: String? = null, userAgentMetadata: Emulation.UserAgentMetadata? = null)

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

Link copied to clipboard
suspend fun setVirtualTimePolicy(policy: Emulation.VirtualTimePolicy, budget: Double? = null, maxVirtualTimeTaskStarvationCount: Int? = null, initialVirtualTime: Double? = null): Emulation.SetVirtualTimePolicyReturn

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(args: Emulation.SetVisibleSizeParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setVisibleSize(width: Int, height: Int)

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.