EmulationApi class
This domain emulates different environments for the page.
Constructors
- EmulationApi(Client _client)
Properties
- 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
Methods
-
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.
-
clearDisplayFeaturesOverride(
) → Future< void> - 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.
-
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.
inherited
-
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.
enabledWhether 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.
enabledWhether the override should be enabled. -
setCPUThrottlingRate(
num rate) → Future< void> -
Enables CPU throttling to emulate slow CPUs.
rateThrottling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). -
setDataSaverOverride(
{bool? dataSaverEnabled}) → Future< void> -
Override the value of navigator.connection.saveData
dataSaverEnabledOverride value. Omitting the parameter disables the override. -
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.
colorRGBA 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).
widthOverriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.heightOverriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.deviceScaleFactorOverriding device scale factor value. 0 disables the override.mobileWhether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.scaleScale to apply to resulting view image.screenWidthOverriding screen width value in pixels (minimum 0, maximum 10000000).screenHeightOverriding screen height value in pixels (minimum 0, maximum 10000000).positionXOverriding view X position on screen in pixels (minimum 0, maximum 10000000).positionYOverriding view Y position on screen in pixels (minimum 0, maximum 10000000).dontSetVisibleSizeDo not set visible view size, rely upon explicit setVisibleSize call.screenOrientationScreen orientation override.viewportIf 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. -
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> -
imageTypesImage types to disable. -
setDisplayFeaturesOverride(
List< DisplayFeature> features) → Future<void> - Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().
-
setDocumentCookieDisabled(
bool disabled) → Future< void> -
disabledWhether document.coookie API should be disabled. -
setEmitTouchEventsForMouse(
bool enabled, {String? configuration}) → Future< void> -
enabledWhether touch emulation based on mouse input should be enabled.configurationTouch/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.
mediaMedia type to emulate. Empty string disables the override.featuresMedia features to emulate. -
setEmulatedOSTextScale(
{num? scale}) → Future< void> - Emulates the given OS text scale.
-
setEmulatedVisionDeficiency(
String type) → Future< void> -
Emulates the given vision deficiency.
typeVision 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.
enabledWhether to enable to disable focus emulation. -
setGeolocationOverride(
{num? latitude, num? longitude, num? accuracy, num? altitude, num? altitudeAccuracy, num? heading, num? speed}) → Future< void> -
Overrides the Geolocation Position or Error. Omitting latitude, longitude or
accuracy emulates position unavailable.
latitudeMock latitudelongitudeMock longitudeaccuracyMock accuracyaltitudeMock altitudealtitudeAccuracyMock altitudeAccuracyheadingMock headingspeedMock speed -
setHardwareConcurrencyOverride(
int hardwareConcurrency) → Future< void> -
hardwareConcurrencyHardware concurrency to report -
setIdleOverride(
bool isUserActive, bool isScreenUnlocked) → Future< void> -
Overrides the Idle state.
isUserActiveMock isUserActiveisScreenUnlockedMock isScreenUnlocked -
setLocaleOverride(
{String? locale}) → Future< void> -
Overrides default host system locale with the specified one.
localeICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale. -
Overrides value returned by the javascript navigator object.
platformThe platform navigator.platform should return. -
setPageScaleFactor(
num pageScaleFactor) → Future< void> -
Sets a specified page scale factor.
pageScaleFactorPage scale factor. -
setPressureDataOverride(
PressureSource source, PressureState state, {num? ownContributionEstimate}) → Future< void> - 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.
-
setPressureSourceOverrideEnabled(
bool enabled, PressureSource source, {PressureMetadata? metadata}) → Future< void> - 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.
-
setPressureStateOverride(
PressureSource source, PressureState state) → Future< void> - 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.
-
setSafeAreaInsetsOverride(
SafeAreaInsets insets) → Future< void> - 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.
-
setScriptExecutionDisabled(
bool value) → Future< void> -
Switches script execution in the page.
valueWhether script execution should be disabled in the page. -
setScrollbarsHidden(
) → Future< void> -
hiddenWhether 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.
-
setSmallViewportHeightDifferenceOverride(
int difference) → Future< void> -
Allows overriding the difference between the small and large viewport sizes, which determine the
value of the
svhandlvhunit, respectively. Only supported for top-level frames.differenceThis will cause an element of size 100svh to bedifferencepixels smaller than an element of size 100lvh. -
setTimezoneOverride(
String timezoneId) → Future< void> -
Overrides default host system timezone with the specified one.
timezoneIdThe 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.
enabledWhether the touch event emulation should be enabled.maxTouchPointsMaximum 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.
userAgentMetadatamust be set for Client Hint headers to be sent.userAgentUser agent to use.acceptLanguageBrowser language to emulate.platformThe platform navigator.platform should return.userAgentMetadataTo 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.
budgetIf set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.maxVirtualTimeTaskStarvationCountIf set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.initialVirtualTimeIf 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.
widthFrame width (DIP).heightFrame height (DIP). -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited