protocol/emulation

⚙️ This module was generated from the Chrome DevTools Protocol version 1.3

Emulation Domain

This domain emulates different environments for the page.

📖 View this domain on the DevTools Protocol API Docs

Types

pub type DevicePosture {
  DevicePosture(type_: DevicePostureType)
}

Constructors

  • DevicePosture(type_: DevicePostureType)

    Arguments

    • type_

      Current posture of the device

This type is not part of the protocol spec, it has been generated dynamically to represent the possible values of the enum property type of DevicePosture

pub type DevicePostureType {
  DevicePostureTypeContinuous
  DevicePostureTypeFolded
}

Constructors

  • DevicePostureTypeContinuous
  • DevicePostureTypeFolded
pub type DisplayFeature {
  DisplayFeature(
    orientation: DisplayFeatureOrientation,
    offset: Int,
    mask_length: Int,
  )
}

Constructors

  • DisplayFeature(
      orientation: DisplayFeatureOrientation,
      offset: Int,
      mask_length: Int,
    )

    Arguments

    • orientation

      Orientation of a display feature in relation to screen

    • offset

      The offset from the screen origin in either the x (for vertical orientation) or y (for horizontal orientation) direction.

    • mask_length

      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.

This type is not part of the protocol spec, it has been generated dynamically to represent the possible values of the enum property orientation of DisplayFeature

pub type DisplayFeatureOrientation {
  DisplayFeatureOrientationVertical
  DisplayFeatureOrientationHorizontal
}

Constructors

  • DisplayFeatureOrientationVertical
  • DisplayFeatureOrientationHorizontal
pub type MediaFeature {
  MediaFeature(name: String, value: String)
}

Constructors

  • MediaFeature(name: String, value: String)

Screen orientation.

pub type ScreenOrientation {
  ScreenOrientation(type_: ScreenOrientationType, angle: Int)
}

Constructors

  • ScreenOrientation(type_: ScreenOrientationType, angle: Int)

    Arguments

    • type_

      Orientation type.

    • angle

      Orientation angle.

This type is not part of the protocol spec, it has been generated dynamically to represent the possible values of the enum property type of ScreenOrientation

pub type ScreenOrientationType {
  ScreenOrientationTypePortraitPrimary
  ScreenOrientationTypePortraitSecondary
  ScreenOrientationTypeLandscapePrimary
  ScreenOrientationTypeLandscapeSecondary
}

Constructors

  • ScreenOrientationTypePortraitPrimary
  • ScreenOrientationTypePortraitSecondary
  • ScreenOrientationTypeLandscapePrimary
  • ScreenOrientationTypeLandscapeSecondary

This type is not part of the protocol spec, it has been generated dynamically to represent the possible values of the enum property type of setEmulatedVisionDeficiency

pub type SetEmulatedVisionDeficiencyType {
  SetEmulatedVisionDeficiencyTypeNone
  SetEmulatedVisionDeficiencyTypeBlurredVision
  SetEmulatedVisionDeficiencyTypeReducedContrast
  SetEmulatedVisionDeficiencyTypeAchromatopsia
  SetEmulatedVisionDeficiencyTypeDeuteranopia
  SetEmulatedVisionDeficiencyTypeProtanopia
  SetEmulatedVisionDeficiencyTypeTritanopia
}

Constructors

  • SetEmulatedVisionDeficiencyTypeNone
  • SetEmulatedVisionDeficiencyTypeBlurredVision
  • SetEmulatedVisionDeficiencyTypeReducedContrast
  • SetEmulatedVisionDeficiencyTypeAchromatopsia
  • SetEmulatedVisionDeficiencyTypeDeuteranopia
  • SetEmulatedVisionDeficiencyTypeProtanopia
  • SetEmulatedVisionDeficiencyTypeTritanopia

Functions

pub fn clear_device_metrics_override(
  callback__: fn(String, Option(a)) -> b,
) -> b

Clears the overridden device metrics.

pub fn clear_geolocation_override(
  callback__: fn(String, Option(a)) -> b,
) -> b

Clears the overridden Geolocation Position and Error.

pub fn clear_idle_override(
  callback__: fn(String, Option(a)) -> b,
) -> b

Clears Idle state overrides.

pub fn set_cpu_throttling_rate(
  callback__: fn(String, Option(Json)) -> a,
  rate rate: Float,
) -> a

Enables CPU throttling to emulate slow CPUs.

Parameters:

  • rate : Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).

Returns:

pub fn set_default_background_color_override(
  callback__: fn(String, Option(Json)) -> a,
  color color: Option(RGBA),
) -> a

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 : RGBA of the default background color. If not specified, any existing override will be cleared.

Returns:

pub fn set_device_metrics_override(
  callback__: fn(String, Option(Json)) -> a,
  width width: Int,
  height height: Int,
  device_scale_factor device_scale_factor: Float,
  mobile mobile: Bool,
  screen_orientation screen_orientation: Option(ScreenOrientation),
) -> a

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 : 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.
  • device_scale_factor : 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.
  • screen_orientation : Screen orientation override.

Returns:

pub fn set_emulated_media(
  callback__: fn(String, Option(Json)) -> a,
  media media: Option(String),
  features features: Option(List(MediaFeature)),
) -> a

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

Parameters:

  • media : Media type to emulate. Empty string disables the override.
  • features : Media features to emulate.

Returns:

pub fn set_emulated_vision_deficiency(
  callback__: fn(String, Option(Json)) -> a,
  type_ type_: SetEmulatedVisionDeficiencyType,
) -> a

Emulates the given vision deficiency.

Parameters:

  • type_ : Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.

Returns:

pub fn set_geolocation_override(
  callback__: fn(String, Option(Json)) -> a,
  latitude latitude: Option(Float),
  longitude longitude: Option(Float),
  accuracy accuracy: Option(Float),
) -> a

Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.

Parameters:

  • latitude : Mock latitude
  • longitude : Mock longitude
  • accuracy : Mock accuracy

Returns:

pub fn set_idle_override(
  callback__: fn(String, Option(Json)) -> a,
  is_user_active is_user_active: Bool,
  is_screen_unlocked is_screen_unlocked: Bool,
) -> a

Overrides the Idle state.

Parameters:

  • is_user_active : Mock isUserActive
  • is_screen_unlocked : Mock isScreenUnlocked

Returns:

pub fn set_script_execution_disabled(
  callback__: fn(String, Option(Json)) -> a,
  value value: Bool,
) -> a

Switches script execution in the page.

Parameters:

  • value : Whether script execution should be disabled in the page.

Returns:

pub fn set_timezone_override(
  callback__: fn(String, Option(Json)) -> a,
  timezone_id timezone_id: String,
) -> a

Overrides default host system timezone with the specified one.

Parameters:

  • timezone_id : 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.

Returns:

pub fn set_touch_emulation_enabled(
  callback__: fn(String, Option(Json)) -> a,
  enabled enabled: Bool,
  max_touch_points max_touch_points: Option(Int),
) -> a

Enables touch on platforms which do not support them.

Parameters:

  • enabled : Whether the touch event emulation should be enabled.
  • max_touch_points : Maximum touch points supported. Defaults to one.

Returns:

pub fn set_user_agent_override(
  callback__: fn(String, Option(Json)) -> a,
  user_agent user_agent: String,
  accept_language accept_language: Option(String),
  platform platform: Option(String),
) -> a

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

Parameters:

  • user_agent : User agent to use.
  • accept_language : Browser language to emulate.
  • platform : The platform navigator.platform should return.

Returns:

Search Document