EmulationApi class

This domain emulates different environments for the page.


EmulationApi(Client _client)


hashCode int
The hash code for this object.
no setterinherited
onVirtualTimeBudgetExpired Stream<void>
Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


canEmulate() Future<bool>
Tells whether emulation is supported. Returns: True if emulation is supported.
clearDeviceMetricsOverride() Future<void>
Clears the overridden device metrics.
clearDevicePostureOverride() Future<void>
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.
clearGeolocationOverride() Future<void>
Clears the overridden Geolocation Position and Error.
clearIdleOverride() Future<void>
Clears Idle state overrides.
getOverriddenSensorInformation(SensorType type) Future<num>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
resetPageScaleFactor() Future<void>
Requests that page scale factor is reset to initial values.
setAutoDarkModeOverride({bool? enabled}) Future<void>
Automatically render all web contents using a dark theme. enabled Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
setAutomationOverride(bool enabled) Future<void>
Allows overriding the automation flag. enabled Whether the override should be enabled.
setCPUThrottlingRate(num rate) Future<void>
Enables CPU throttling to emulate slow CPUs. rate Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
setDefaultBackgroundColorOverride({RGBA? color}) Future<void>
Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one. color RGBA of the default background color. If not specified, any existing override will be cleared.
setDeviceMetricsOverride(int width, int height, num deviceScaleFactor, bool mobile, {num? scale, int? screenWidth, int? screenHeight, int? positionX, int? positionY, bool? dontSetVisibleSize, ScreenOrientation? screenOrientation, Viewport? viewport, DisplayFeature? displayFeature, DevicePosture? devicePosture}) Future<void>
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). width Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. height Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. deviceScaleFactor Overriding device scale factor value. 0 disables the override. mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. scale Scale to apply to resulting view image. screenWidth Overriding screen width value in pixels (minimum 0, maximum 10000000). screenHeight Overriding screen height value in pixels (minimum 0, maximum 10000000). positionX Overriding view X position on screen in pixels (minimum 0, maximum 10000000). positionY Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). dontSetVisibleSize Do not set visible view size, rely upon explicit setVisibleSize call. screenOrientation Screen orientation override. viewport 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 If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off.
setDevicePostureOverride(DevicePosture posture) Future<void>
Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().
setDisabledImageTypes(List<DisabledImageType> imageTypes) Future<void>
imageTypes Image types to disable.
setDocumentCookieDisabled(bool disabled) Future<void>
disabled Whether document.coookie API should be disabled.
setEmitTouchEventsForMouse(bool enabled, {String? configuration}) Future<void>
enabled Whether touch emulation based on mouse input should be enabled. configuration Touch/gesture events configuration. Default: current platform.
setEmulatedMedia({String? media, List<MediaFeature>? features}) Future<void>
Emulates the given media type or media feature for CSS media queries. media Media type to emulate. Empty string disables the override. features Media features to emulate.
setEmulatedVisionDeficiency(String type) Future<void>
Emulates the given vision deficiency. type Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
setFocusEmulationEnabled(bool enabled) Future<void>
Enables or disables simulating a focused and active page. enabled Whether to enable to disable focus emulation.
setGeolocationOverride({num? latitude, num? longitude, num? accuracy}) Future<void>
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable. latitude Mock latitude longitude Mock longitude accuracy Mock accuracy
setHardwareConcurrencyOverride(int hardwareConcurrency) Future<void>
hardwareConcurrency Hardware concurrency to report
setIdleOverride(bool isUserActive, bool isScreenUnlocked) Future<void>
Overrides the Idle state. isUserActive Mock isUserActive isScreenUnlocked Mock isScreenUnlocked
setLocaleOverride({String? locale}) Future<void>
Overrides default host system locale with the specified one. locale ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
setNavigatorOverrides(String platform) Future<void>
Overrides value returned by the javascript navigator object. platform The platform navigator.platform should return.
setPageScaleFactor(num pageScaleFactor) Future<void>
Sets a specified page scale factor. pageScaleFactor Page scale factor.
setScriptExecutionDisabled(bool value) Future<void>
Switches script execution in the page. value Whether script execution should be disabled in the page.
setScrollbarsHidden(bool hidden) Future<void>
hidden Whether scrollbars should be always hidden.
setSensorOverrideEnabled(bool enabled, SensorType type, {SensorMetadata? metadata}) Future<void>
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.
setSensorOverrideReadings(SensorType type, SensorReading reading) Future<void>
Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.
setTimezoneOverride(String timezoneId) Future<void>
Overrides default host system timezone with the specified one. timezoneId 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.
setTouchEmulationEnabled(bool enabled, {int? maxTouchPoints}) Future<void>
Enables touch on platforms which do not support them. enabled Whether the touch event emulation should be enabled. maxTouchPoints Maximum touch points supported. Defaults to one.
setUserAgentOverride(String userAgent, {String? acceptLanguage, String? platform, UserAgentMetadata? userAgentMetadata}) Future<void>
Allows overriding user agent with the given string. userAgentMetadata must be set for Client Hint headers to be sent. userAgent User agent to use. acceptLanguage Browser language to emulate. platform The platform navigator.platform should return. userAgentMetadata To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
setVirtualTimePolicy(VirtualTimePolicy policy, {num? budget, int? maxVirtualTimeTaskStarvationCount, TimeSinceEpoch? initialVirtualTime}) Future<num>
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. budget If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent. maxVirtualTimeTaskStarvationCount If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock. initialVirtualTime If set, base::Time::Now will be overridden to initially return this value. Returns: Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
setVisibleSize(int width, int height) Future<void>
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. width Frame width (DIP). height Frame height (DIP).
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.