Skip to main content

EmulationClient

Struct EmulationClient 

Source
pub struct EmulationClient { /* private fields */ }
Expand description

Client for Emulation domain commands.

Implementations§

Source§

impl EmulationClient

Source

pub async fn can_emulate( &self, session_id: Option<&str>, ) -> Result<CanEmulateReturns, CdpError>

Tells whether emulation is supported.

Source

pub async fn clear_device_metrics_override( &self, session_id: Option<&str>, ) -> Result<Value, CdpError>

Clears the overridden device metrics.

Source

pub async fn clear_geolocation_override( &self, session_id: Option<&str>, ) -> Result<Value, CdpError>

Clears the overridden Geolocation Position and Error.

Source

pub async fn reset_page_scale_factor( &self, session_id: Option<&str>, ) -> Result<Value, CdpError>

Requests that page scale factor is reset to initial values.

Source

pub async fn set_focus_emulation_enabled( &self, params: SetFocusEmulationEnabledParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Enables or disables simulating a focused and active page.

Source

pub async fn set_auto_dark_mode_override( &self, params: SetAutoDarkModeOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Automatically render all web contents using a dark theme.

Source

pub async fn set_cpu_throttling_rate( &self, params: SetCpuThrottlingRateParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Enables CPU throttling to emulate slow CPUs.

Source

pub async fn set_default_background_color_override( &self, params: SetDefaultBackgroundColorOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.

Source

pub async fn set_safe_area_insets_override( &self, params: SetSafeAreaInsetsOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_device_metrics_override( &self, params: SetDeviceMetricsOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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).

Source

pub async fn set_device_posture_override( &self, params: SetDevicePostureOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().

Source

pub async fn clear_device_posture_override( &self, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_display_features_override( &self, params: SetDisplayFeaturesOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().

Source

pub async fn clear_display_features_override( &self, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_scrollbars_hidden( &self, params: SetScrollbarsHiddenParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Source

pub async fn set_emit_touch_events_for_mouse( &self, params: SetEmitTouchEventsForMouseParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Source

pub async fn set_emulated_media( &self, params: SetEmulatedMediaParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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

Source

pub async fn set_emulated_vision_deficiency( &self, params: SetEmulatedVisionDeficiencyParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Emulates the given vision deficiency.

Source

pub async fn set_emulated_os_text_scale( &self, params: SetEmulatedOsTextScaleParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Emulates the given OS text scale.

Source

pub async fn set_geolocation_override( &self, params: SetGeolocationOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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

Source

pub async fn get_overridden_sensor_information( &self, params: GetOverriddenSensorInformationParams, session_id: Option<&str>, ) -> Result<GetOverriddenSensorInformationReturns, CdpError>

Source

pub async fn set_sensor_override_enabled( &self, params: SetSensorOverrideEnabledParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_sensor_override_readings( &self, params: SetSensorOverrideReadingsParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.

Source

pub async fn set_pressure_source_override_enabled( &self, params: SetPressureSourceOverrideEnabledParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_pressure_state_override( &self, params: SetPressureStateOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_pressure_data_override( &self, params: SetPressureDataOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_idle_override( &self, params: SetIdleOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Overrides the Idle state.

Source

pub async fn clear_idle_override( &self, session_id: Option<&str>, ) -> Result<Value, CdpError>

Clears Idle state overrides.

Source

pub async fn set_navigator_overrides( &self, params: SetNavigatorOverridesParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Overrides value returned by the javascript navigator object.

Source

pub async fn set_page_scale_factor( &self, params: SetPageScaleFactorParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Sets a specified page scale factor.

Source

pub async fn set_script_execution_disabled( &self, params: SetScriptExecutionDisabledParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Switches script execution in the page.

Source

pub async fn set_touch_emulation_enabled( &self, params: SetTouchEmulationEnabledParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Enables touch on platforms which do not support them.

Source

pub async fn set_virtual_time_policy( &self, params: SetVirtualTimePolicyParams, session_id: Option<&str>, ) -> Result<SetVirtualTimePolicyReturns, CdpError>

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.

Source

pub async fn set_locale_override( &self, params: SetLocaleOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Overrides default host system locale with the specified one.

Source

pub async fn set_timezone_override( &self, params: SetTimezoneOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Overrides default host system timezone with the specified one.

Source

pub async fn set_visible_size( &self, params: SetVisibleSizeParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn set_disabled_image_types( &self, params: SetDisabledImageTypesParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Source

pub async fn set_data_saver_override( &self, params: SetDataSaverOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Override the value of navigator.connection.saveData

Source

pub async fn set_hardware_concurrency_override( &self, params: SetHardwareConcurrencyOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Source

pub async fn set_user_agent_override( &self, params: SetUserAgentOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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

Source

pub async fn set_automation_override( &self, params: SetAutomationOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Allows overriding the automation flag.

Source

pub async fn set_small_viewport_height_difference_override( &self, params: SetSmallViewportHeightDifferenceOverrideParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

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.

Source

pub async fn get_screen_infos( &self, session_id: Option<&str>, ) -> Result<GetScreenInfosReturns, CdpError>

Returns device’s screen configuration.

Source

pub async fn add_screen( &self, params: AddScreenParams, session_id: Option<&str>, ) -> Result<AddScreenReturns, CdpError>

Add a new screen to the device. Only supported in headless mode.

Source

pub async fn remove_screen( &self, params: RemoveScreenParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Remove screen from the device. Only supported in headless mode.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more