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.setEmulatedOSTextScale
- Emulation.setEmulatedVisionDeficiency
- Emulation.setGeolocationOverride
- Emulation.setIdleOverride
- Emulation.setScriptExecutionDisabled
- Emulation.setTimezoneOverride
- Emulation.setTouchEmulationEnabled
- Emulation.setUserAgentOverride
- Emulation.canEmulate Deprecated
- Emulation.addScreen Experimental
- Emulation.clearDevicePostureOverride Experimental
- Emulation.clearDisplayFeaturesOverride Experimental
- Emulation.getOverriddenSensorInformation Experimental
- Emulation.getScreenInfos Experimental
- Emulation.removeScreen Experimental
- Emulation.resetPageScaleFactor Experimental
- Emulation.setAutoDarkModeOverride Experimental
- Emulation.setAutomationOverride Experimental
- Emulation.setDataSaverOverride Experimental
- Emulation.setDevicePostureOverride Experimental
- Emulation.setDisabledImageTypes Experimental
- Emulation.setDisplayFeaturesOverride Experimental
- Emulation.setDocumentCookieDisabled Experimental
- Emulation.setEmitTouchEventsForMouse Experimental
- Emulation.setFocusEmulationEnabled Experimental
- Emulation.setHardwareConcurrencyOverride Experimental
- Emulation.setLocaleOverride Experimental
- Emulation.setPageScaleFactor Experimental
- Emulation.setPressureDataOverride Experimental
- Emulation.setPressureSourceOverrideEnabled Experimental
- Emulation.setPressureStateOverride Experimental
- Emulation.setSafeAreaInsetsOverride Experimental
- Emulation.setScrollbarsHidden Experimental
- Emulation.setSensorOverrideEnabled Experimental
- Emulation.setSensorOverrideReadings Experimental
- Emulation.setSmallViewportHeightDifferenceOverride 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.PressureMetadata Experimental
- Emulation.PressureSource Experimental
- Emulation.PressureState Experimental
- Emulation.SafeAreaInsets Experimental
- Emulation.ScreenId Experimental
- Emulation.ScreenInfo 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
- Emulation.WorkAreaInsets Experimental
Methods
Emulation.setCPUThrottlingRate #
Enables CPU throttling to emulate slow CPUs.
Parameters
rate numberThrottling 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
colorOptional
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 integerOverriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
height integerOverriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
deviceScaleFactor numberOverriding device scale factor value. 0 disables the override.
mobile booleanWhether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
scaleOptional
numberScale to apply to resulting view image.
screenWidthOptional
integerOverriding screen width value in pixels (minimum 0, maximum 10000000).
screenHeightOptional
integerOverriding screen height value in pixels (minimum 0, maximum 10000000).
positionXOptional
integerOverriding view X position on screen in pixels (minimum 0, maximum 10000000).
positionYOptional
integerOverriding view Y position on screen in pixels (minimum 0, maximum 10000000).
dontSetVisibleSizeOptional
booleanDo not set visible view size, rely upon explicit setVisibleSize call.
screenOrientationOptional
Screen orientation override.
viewportOptional
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.
displayFeatureOptional
If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off. Deprecated, use Emulation.setDisplayFeaturesOverride.
devicePostureOptional
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
mediaOptional
stringMedia type to emulate. Empty string disables the override.
featuresOptional
array[ MediaFeature ]Media features to emulate.
Emulation.setEmulatedVisionDeficiency #
Emulates the given vision deficiency.
Parameters
type stringVision 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 latitude, longitude or accuracy emulates position unavailable.
Parameters
latitudeOptional
numberMock latitude
longitudeOptional
numberMock longitude
accuracyOptional
numberMock accuracy
altitudeOptional
numberMock altitude
altitudeAccuracyOptional
numberMock altitudeAccuracy
headingOptional
numberMock heading
speedOptional
numberMock speed
Emulation.setIdleOverride #
Overrides the Idle state.
Parameters
isUserActive booleanMock isUserActive
isScreenUnlocked booleanMock isScreenUnlocked
Emulation.setScriptExecutionDisabled #
Switches script execution in the page.
Parameters
value booleanWhether script execution should be disabled in the page.
Emulation.setTimezoneOverride #
Overrides default host system timezone with the specified one.
Parameters
timezoneId stringThe 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 booleanWhether the touch event emulation should be enabled.
maxTouchPointsOptional
integerMaximum 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 stringUser agent to use.
acceptLanguageOptional
stringBrowser language to emulate.
platformOptional
stringThe platform navigator.platform should return.
userAgentMetadataOptional
To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
Emulation.canEmulate Deprecated#
Tells whether emulation is supported.
Return object
result booleanTrue if emulation is supported.
Emulation.addScreen Experimental#
Add a new screen to the device. Only supported in headless mode.
Parameters
left integerOffset of the left edge of the screen in pixels.
top integerOffset of the top edge of the screen in pixels.
width integerThe width of the screen in pixels.
height integerThe height of the screen in pixels.
workAreaInsetsOptional
Specifies the screen's work area. Default is entire screen.
devicePixelRatioOptional
numberSpecifies the screen's device pixel ratio. Default is 1.
rotationOptional
integerSpecifies the screen's rotation angle. Available values are 0, 90, 180 and 270. Default is 0.
colorDepthOptional
integerSpecifies the screen's color depth in bits. Default is 24.
labelOptional
stringSpecifies the descriptive label for the screen. Default is none.
isInternalOptional
booleanIndicates whether the screen is internal to the device or external, attached to the device. Default is false.
Return object
screenInfo 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.clearDisplayFeaturesOverride Experimental#
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.
Emulation.getOverriddenSensorInformation Experimental#
Parameters
type Return object
requestedSamplingFrequency numberEmulation.getScreenInfos Experimental#
Returns device's screen configuration.
Return object
screenInfos array[ ScreenInfo ]Emulation.removeScreen Experimental#
Remove screen from the device. Only supported in headless mode.
Parameters
screenId 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
enabledOptional
booleanWhether 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 booleanWhether the override should be enabled.
Emulation.setDataSaverOverride Experimental#
Override the value of navigator.connection.saveData
Parameters
dataSaverEnabledOptional
booleanOverride value. Omitting the parameter disables the override.
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.setDisplayFeaturesOverride Experimental#
Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().
Parameters
features array[ DisplayFeature ]Emulation.setDocumentCookieDisabled Experimental#
Parameters
disabled booleanWhether document.coookie API should be disabled.
Emulation.setEmitTouchEventsForMouse Experimental#
Parameters
enabled booleanWhether touch emulation based on mouse input should be enabled.
configurationOptional
stringTouch/gesture events configuration. Default: current platform.
Allowed values: mobile, desktop
Emulation.setFocusEmulationEnabled Experimental#
Enables or disables simulating a focused and active page.
Parameters
enabled booleanWhether to enable to disable focus emulation.
Emulation.setHardwareConcurrencyOverride Experimental#
Parameters
hardwareConcurrency integerHardware concurrency to report
Emulation.setLocaleOverride Experimental#
Overrides default host system locale with the specified one.
Parameters
localeOptional
stringICU 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 numberPage scale factor.
Emulation.setPressureDataOverride Experimental#
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.
Parameters
source state ownContributionEstimateOptional
numberEmulation.setPressureSourceOverrideEnabled Experimental#
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.
Parameters
enabled booleansource metadataOptional
Emulation.setPressureStateOverride Experimental#
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.
Parameters
source state Emulation.setSafeAreaInsetsOverride Experimental#
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.
Parameters
insets Emulation.setScrollbarsHidden Experimental#
Parameters
hidden booleanWhether 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 booleantype metadataOptional
Emulation.setSensorOverrideReadings Experimental#
Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.
Parameters
type reading Emulation.setSmallViewportHeightDifferenceOverride Experimental#
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.
Parameters
difference integerThis will cause an element of size 100svh to be difference pixels smaller than an element
of size 100lvh.
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 budgetOptional
numberIf set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
maxVirtualTimeTaskStarvationCountOptional
integerIf set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
initialVirtualTimeOptional
If set, base::Time::Now will be overridden to initially return this value.
Return object
virtualTimeTicksBase numberAbsolute 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 stringThe 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 integerFrame width (DIP).
height integerFrame 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 stringCurrent posture of the device
Allowed values: continuous, folded
Emulation.DisplayFeature #
Type: object
Properties
orientation stringOrientation of a display feature in relation to screen
Allowed values: vertical, horizontal
offset integerThe offset from the screen origin in either the x (for vertical orientation) or y (for horizontal orientation) direction.
maskLength integerA 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 stringOrientation type.
Allowed values: portraitPrimary, portraitSecondary, landscapePrimary, landscapeSecondary
angle integerOrientation angle.
Emulation.DisabledImageType Experimental#
Enum of image types that can be disabled.
Type: string
Allowed values: avif, webp
Emulation.SafeAreaInsets Experimental#
Type: object
Properties
topOptional
integerOverrides safe-area-inset-top.
topMaxOptional
integerOverrides safe-area-max-inset-top.
leftOptional
integerOverrides safe-area-inset-left.
leftMaxOptional
integerOverrides safe-area-max-inset-left.
bottomOptional
integerOverrides safe-area-inset-bottom.
bottomMaxOptional
integerOverrides safe-area-max-inset-bottom.
rightOptional
integerOverrides safe-area-inset-right.
rightMaxOptional
integerOverrides safe-area-max-inset-right.
Emulation.ScreenInfo Experimental#
Screen information similar to the one returned by window.getScreenDetails() method, see https://w3c.github.io/window-management/#screendetailed.
Type: object
Properties
left integerOffset of the left edge of the screen.
top integerOffset of the top edge of the screen.
width integerWidth of the screen.
height integerHeight of the screen.
availLeft integerOffset of the left edge of the available screen area.
availTop integerOffset of the top edge of the available screen area.
availWidth integerWidth of the available screen area.
availHeight integerHeight of the available screen area.
devicePixelRatio numberSpecifies the screen's device pixel ratio.
orientation Specifies the screen's orientation.
colorDepth integerSpecifies the screen's color depth in bits.
isExtended booleanIndicates whether the device has multiple screens.
isInternal booleanIndicates whether the screen is internal to the device or external, attached to the device.
isPrimary booleanIndicates whether the screen is set as the the operating system primary screen.
label stringSpecifies the descriptive label for the screen.
id Specifies the unique identifier of the screen.
Emulation.SensorMetadata Experimental#
Type: object
Properties
availableOptional
booleanminimumFrequencyOptional
numbermaximumFrequencyOptional
numberEmulation.SensorReading Experimental#
Type: object
Properties
singleOptional
xyzOptional
quaternionOptional
Emulation.SensorReadingQuaternion Experimental#
Type: object
Properties
x numbery numberz numberw numberEmulation.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, 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 stringversion stringEmulation.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
brandsOptional
array[ UserAgentBrandVersion ]Brands appearing in Sec-CH-UA.
fullVersionListOptional
array[ UserAgentBrandVersion ]Brands appearing in Sec-CH-UA-Full-Version-List.
fullVersionOptional
stringDeprecatedplatform stringplatformVersion stringarchitecture stringmodel stringmobile booleanbitnessOptional
stringwow64Optional
booleanformFactorsOptional
array[ string ]Used to specify User Agent form-factor values. See https://wicg.github.io/ua-client-hints/#sec-ch-ua-form-factors
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
Emulation.WorkAreaInsets Experimental#
Type: object
Properties
topOptional
integerWork area top inset in pixels. Default is 0;
leftOptional
integerWork area left inset in pixels. Default is 0;
bottomOptional
integerWork area bottom inset in pixels. Default is 0;
rightOptional
integerWork area right inset in pixels. Default is 0;