Emulation Domain
This domain emulates different environments for the page.
Methods
- Emulation.clearDeviceMetricsOverride
- Emulation.clearGeolocationOverride
- Emulation.clearIdleOverride
- Emulation.setCPUThrottlingRate
- Emulation.setDefaultBackgroundColorOverride
- Emulation.setDeviceMetricsOverride
- Emulation.setEmulatedMedia
- Emulation.setEmulatedVisionDeficiency
- Emulation.setGeolocationOverride
- Emulation.setIdleOverride
- Emulation.setScriptExecutionDisabled
- Emulation.setTimezoneOverride
- Emulation.setTouchEmulationEnabled
- Emulation.setUserAgentOverride
- Emulation.canEmulate Deprecated
- Emulation.clearDevicePostureOverride Experimental
- Emulation.getOverriddenSensorInformation Experimental
- Emulation.resetPageScaleFactor Experimental
- Emulation.setAutoDarkModeOverride Experimental
- Emulation.setAutomationOverride Experimental
- Emulation.setDevicePostureOverride Experimental
- Emulation.setDisabledImageTypes Experimental
- Emulation.setDocumentCookieDisabled Experimental
- Emulation.setEmitTouchEventsForMouse Experimental
- Emulation.setFocusEmulationEnabled Experimental
- Emulation.setHardwareConcurrencyOverride Experimental
- Emulation.setLocaleOverride Experimental
- Emulation.setPageScaleFactor Experimental
- Emulation.setScrollbarsHidden Experimental
- Emulation.setSensorOverrideEnabled Experimental
- Emulation.setSensorOverrideReadings Experimental
- Emulation.setVirtualTimePolicy Experimental
- Emulation.setNavigatorOverrides ExperimentalDeprecated
- Emulation.setVisibleSize ExperimentalDeprecated
Events
- Emulation.virtualTimeBudgetExpired Experimental
Types
- Emulation.DevicePosture
- Emulation.DisplayFeature
- Emulation.MediaFeature
- Emulation.ScreenOrientation
- Emulation.DisabledImageType Experimental
- Emulation.SensorMetadata Experimental
- Emulation.SensorReading Experimental
- Emulation.SensorReadingQuaternion Experimental
- Emulation.SensorReadingSingle Experimental
- Emulation.SensorReadingXYZ Experimental
- Emulation.SensorType Experimental
- Emulation.UserAgentBrandVersion Experimental
- Emulation.UserAgentMetadata Experimental
- Emulation.VirtualTimePolicy Experimental
Methods
Emulation.setCPUThrottlingRate #
Enables CPU throttling to emulate slow CPUs.
Parameters
rate
number
Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
Emulation.setDefaultBackgroundColorOverride #
Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.
Parameters
color
Optional
RGBA of the default background color. If not specified, any existing override will be cleared.
Emulation.setDeviceMetricsOverride #
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).
Parameters
width
integer
Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
height
integer
Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
deviceScaleFactor
number
Overriding device scale factor value. 0 disables the override.
mobile
boolean
Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
scale
Optional
number
Scale to apply to resulting view image.
screenWidth
Optional
integer
Overriding screen width value in pixels (minimum 0, maximum 10000000).
screenHeight
Optional
integer
Overriding screen height value in pixels (minimum 0, maximum 10000000).
positionX
Optional
integer
Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
positionY
Optional
integer
Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
dontSetVisibleSize
Optional
boolean
Do not set visible view size, rely upon explicit setVisibleSize call.
screenOrientation
Optional
Screen orientation override.
viewport
Optional
If set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions.
displayFeature
Optional
If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off.
devicePosture
Optional
If set, the posture of a foldable device. If not set the posture is set to continuous. Deprecated, use Emulation.setDevicePostureOverride.
Emulation.setEmulatedMedia #
Emulates the given media type or media feature for CSS media queries.
Parameters
media
Optional
string
Media type to emulate. Empty string disables the override.
features
Optional
array[ MediaFeature ]
Media features to emulate.
Emulation.setEmulatedVisionDeficiency #
Emulates the given vision deficiency.
Parameters
type
string
Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
Allowed values: none
, blurredVision
, reducedContrast
, achromatopsia
, deuteranopia
, protanopia
, tritanopia
Emulation.setGeolocationOverride #
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
Parameters
latitude
Optional
number
Mock latitude
longitude
Optional
number
Mock longitude
accuracy
Optional
number
Mock accuracy
Emulation.setIdleOverride #
Overrides the Idle state.
Parameters
isUserActive
boolean
Mock isUserActive
isScreenUnlocked
boolean
Mock isScreenUnlocked
Emulation.setScriptExecutionDisabled #
Switches script execution in the page.
Parameters
value
boolean
Whether script execution should be disabled in the page.
Emulation.setTimezoneOverride #
Overrides default host system timezone with the specified one.
Parameters
timezoneId
string
The timezone identifier. List of supported timezones: https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt If empty, disables the override and restores default host system timezone.
Emulation.setTouchEmulationEnabled #
Enables touch on platforms which do not support them.
Parameters
enabled
boolean
Whether the touch event emulation should be enabled.
maxTouchPoints
Optional
integer
Maximum touch points supported. Defaults to one.
Emulation.setUserAgentOverride #
Allows overriding user agent with the given string.
userAgentMetadata
must be set for Client Hint headers to be sent.
Parameters
userAgent
string
User agent to use.
acceptLanguage
Optional
string
Browser language to emulate.
platform
Optional
string
The platform navigator.platform should return.
userAgentMetadata
Optional
To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
Emulation.canEmulate Deprecated#
Tells whether emulation is supported.
Return object
result
boolean
True if emulation is supported.
Emulation.clearDevicePostureOverride Experimental#
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.
Emulation.getOverriddenSensorInformation Experimental#
Parameters
type
Return object
requestedSamplingFrequency
number
Emulation.resetPageScaleFactor Experimental#
Requests that page scale factor is reset to initial values.
Emulation.setAutoDarkModeOverride Experimental#
Automatically render all web contents using a dark theme.
Parameters
enabled
Optional
boolean
Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
Emulation.setAutomationOverride Experimental#
Allows overriding the automation flag.
Parameters
enabled
boolean
Whether the override should be enabled.
Emulation.setDevicePostureOverride Experimental#
Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().
Parameters
posture
Emulation.setDisabledImageTypes Experimental#
Parameters
imageTypes
array[ DisabledImageType ]
Image types to disable.
Emulation.setDocumentCookieDisabled Experimental#
Parameters
disabled
boolean
Whether document.coookie API should be disabled.
Emulation.setEmitTouchEventsForMouse Experimental#
Parameters
enabled
boolean
Whether touch emulation based on mouse input should be enabled.
configuration
Optional
string
Touch/gesture events configuration. Default: current platform.
Allowed values: mobile
, desktop
Emulation.setFocusEmulationEnabled Experimental#
Enables or disables simulating a focused and active page.
Parameters
enabled
boolean
Whether to enable to disable focus emulation.
Emulation.setHardwareConcurrencyOverride Experimental#
Parameters
hardwareConcurrency
integer
Hardware concurrency to report
Emulation.setLocaleOverride Experimental#
Overrides default host system locale with the specified one.
Parameters
locale
Optional
string
ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
Emulation.setPageScaleFactor Experimental#
Sets a specified page scale factor.
Parameters
pageScaleFactor
number
Page scale factor.
Emulation.setScrollbarsHidden Experimental#
Parameters
hidden
boolean
Whether scrollbars should be always hidden.
Emulation.setSensorOverrideEnabled Experimental#
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.
Parameters
enabled
boolean
type
metadata
Optional
Emulation.setSensorOverrideReadings Experimental#
Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.
Parameters
type
reading
Emulation.setVirtualTimePolicy Experimental#
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.
Parameters
policy
budget
Optional
number
If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
maxVirtualTimeTaskStarvationCount
Optional
integer
If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
initialVirtualTime
Optional
If set, base::Time::Now will be overridden to initially return this value.
Return object
virtualTimeTicksBase
number
Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
Emulation.setNavigatorOverrides ExperimentalDeprecated#
Overrides value returned by the javascript navigator object.
Parameters
platform
string
The platform navigator.platform should return.
Emulation.setVisibleSize ExperimentalDeprecated#
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.
Parameters
width
integer
Frame width (DIP).
height
integer
Frame height (DIP).
Events
Emulation.virtualTimeBudgetExpired Experimental#
Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
Types
Emulation.DevicePosture #
Type: object
Properties
type
string
Current posture of the device
Allowed values: continuous
, folded
Emulation.DisplayFeature #
Type: object
Properties
orientation
string
Orientation of a display feature in relation to screen
Allowed values: vertical
, horizontal
offset
integer
The offset from the screen origin in either the x (for vertical orientation) or y (for horizontal orientation) direction.
maskLength
integer
A display feature may mask content such that it is not physically displayed - this length along with the offset describes this area. A display feature that only splits content will have a 0 mask_length.
Emulation.ScreenOrientation #
Screen orientation.
Type: object
Properties
type
string
Orientation type.
Allowed values: portraitPrimary
, portraitSecondary
, landscapePrimary
, landscapeSecondary
angle
integer
Orientation angle.
Emulation.DisabledImageType Experimental#
Enum of image types that can be disabled.
Type: string
Allowed values: avif
, webp
Emulation.SensorMetadata Experimental#
Type: object
Properties
available
Optional
boolean
minimumFrequency
Optional
number
maximumFrequency
Optional
number
Emulation.SensorReading Experimental#
Type: object
Properties
single
Optional
xyz
Optional
quaternion
Optional
Emulation.SensorReadingQuaternion Experimental#
Type: object
Properties
x
number
y
number
z
number
w
number
Emulation.SensorType Experimental#
Used to specify sensor types to emulate. See https://w3c.github.io/sensors/#automation for more information.
Type: string
Allowed values: absolute-orientation
, accelerometer
, ambient-light
, gravity
, gyroscope
, linear-acceleration
, magnetometer
, proximity
, relative-orientation
Emulation.UserAgentBrandVersion Experimental#
Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints
Type: object
Properties
brand
string
version
string
Emulation.UserAgentMetadata Experimental#
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.
Type: object
Properties
brands
Optional
array[ UserAgentBrandVersion ]
Brands appearing in Sec-CH-UA.
fullVersionList
Optional
array[ UserAgentBrandVersion ]
Brands appearing in Sec-CH-UA-Full-Version-List.
fullVersion
Optional
string
Deprecatedplatform
string
platformVersion
string
architecture
string
model
string
mobile
boolean
bitness
Optional
string
wow64
Optional
boolean
Emulation.VirtualTimePolicy Experimental#
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.
Type: string
Allowed values: advance
, pause
, pauseIfNetworkFetchesPending