glendam/protocol/emulation

This module is generated from the Chrome DevTools Protocol schema.

Do not edit this file manually. Generator: dev/codegen/generate_bindings.gleam Regenerate with:

gleam run -m codegen/generate_bindings

Protocol version: 1.3

Emulation Domain

This domain emulates different environments for the page.

📖 View this domain on the DevTools Protocol API Docs

Types

Represents the Chrome DevTools Protocol DevicePosture value.

pub type DevicePosture {
  DevicePosture(type_: DevicePostureType)
}

Constructors

  • DevicePosture(type_: DevicePostureType)

    Represents the DevicePosture protocol value.

    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

    Represents the continuous protocol value.

  • DevicePostureTypeFolded

    Represents the folded protocol value.

Represents the Chrome DevTools Protocol DisplayFeature value.

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

Constructors

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

    Represents the DisplayFeature protocol value.

    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

    Represents the vertical protocol value.

  • DisplayFeatureOrientationHorizontal

    Represents the horizontal protocol value.

Represents the Chrome DevTools Protocol MediaFeature value.

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

Constructors

  • MediaFeature(name: String, value: String)

    Represents the MediaFeature protocol value.

Screen orientation.

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

Constructors

  • ScreenOrientation(type_: ScreenOrientationType, angle: Int)

    Represents the ScreenOrientation protocol value.

    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

    Represents the portraitPrimary protocol value.

  • ScreenOrientationTypePortraitSecondary

    Represents the portraitSecondary protocol value.

  • ScreenOrientationTypeLandscapePrimary

    Represents the landscapePrimary protocol value.

  • ScreenOrientationTypeLandscapeSecondary

    Represents the landscapeSecondary protocol value.

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

    Represents the none protocol value.

  • SetEmulatedVisionDeficiencyTypeBlurredVision

    Represents the blurredVision protocol value.

  • SetEmulatedVisionDeficiencyTypeReducedContrast

    Represents the reducedContrast protocol value.

  • SetEmulatedVisionDeficiencyTypeAchromatopsia

    Represents the achromatopsia protocol value.

  • SetEmulatedVisionDeficiencyTypeDeuteranopia

    Represents the deuteranopia protocol value.

  • SetEmulatedVisionDeficiencyTypeProtanopia

    Represents the protanopia protocol value.

  • SetEmulatedVisionDeficiencyTypeTritanopia

    Represents the tritanopia protocol value.

Values

pub fn clear_device_metrics_override(
  callback callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
) -> Result(dynamic.Dynamic, chrome.RequestError)

Clears the overridden device metrics.

pub fn clear_geolocation_override(
  callback callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
) -> Result(dynamic.Dynamic, chrome.RequestError)

Clears the overridden Geolocation Position and Error.

pub fn clear_idle_override(
  callback callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
) -> Result(dynamic.Dynamic, chrome.RequestError)

Clears Idle state overrides.

pub fn set_cpu_throttling_rate(
  callback callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  rate rate: Float,
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  color color: option.Option(dom.RGBA),
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  width width: Int,
  height height: Int,
  device_scale_factor device_scale_factor: Float,
  mobile mobile: protocol_support.BooleanSetting,
  screen_orientation screen_orientation: option.Option(
    ScreenOrientation,
  ),
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  media media: option.Option(String),
  features features: option.Option(List(MediaFeature)),
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  type_ type_: SetEmulatedVisionDeficiencyType,
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  latitude latitude: option.Option(Float),
  longitude longitude: option.Option(Float),
  accuracy accuracy: option.Option(Float),
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  is_user_active is_user_active: protocol_support.BooleanSetting,
  is_screen_unlocked is_screen_unlocked: protocol_support.BooleanSetting,
) -> Result(dynamic.Dynamic, chrome.RequestError)

Overrides the Idle state.

Parameters:

  • is_user_active : Mock isUserActive
  • is_screen_unlocked : Mock isScreenUnlocked

Returns:

pub fn set_script_execution_disabled(
  callback callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  value value: protocol_support.BooleanSetting,
) -> Result(dynamic.Dynamic, chrome.RequestError)

Switches script execution in the page.

Parameters:

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

Returns:

pub fn set_timezone_override(
  callback callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  timezone_id timezone_id: String,
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  enabled enabled: protocol_support.BooleanSetting,
  max_touch_points max_touch_points: option.Option(Int),
) -> Result(dynamic.Dynamic, chrome.RequestError)

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 callback__: fn(String, option.Option(json.Json)) -> Result(
    dynamic.Dynamic,
    chrome.RequestError,
  ),
  user_agent user_agent: String,
  accept_language accept_language: option.Option(String),
  platform platform: option.Option(String),
) -> Result(dynamic.Dynamic, chrome.RequestError)

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