CDPotion.Domain.Emulation (cdpotion v0.1.4)
Summary
Types
Enum of image types that can be disabled.
description not provided :(
description not provided :(
Screen orientation.
Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints Missing optional values will be filled in by the target with what it would normally use.
advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to allow the next delayed task (if any) to run; pause: The virtual time base may not advance; pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending resource fetches.
Functions
Tells whether emulation is supported.
Clears the overridden device metrics.
Clears the overridden Geolocation Position and Error.
Clears Idle state overrides.
Requests that page scale factor is reset to initial values.
Automatically render all web contents using a dark theme.
Allows overriding the automation flag.
Enables CPU throttling to emulate slow CPUs.
Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.
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:
- (Required)
image_types
: Image types to disable.
Parameters:
- (Required)
disabled
: Whether document.coookie API should be disabled.
Parameters:
- (Required)
enabled
: Whether touch emulation based on mouse input should be enabled. - (Optional)
configuration
: Touch/gesture events configuration. Default: current platform.
Emulates the given media type or media feature for CSS media queries.
Emulates the given vision deficiency.
Enables or disables simulating a focused and active page.
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
Parameters:
- (Required)
hardware_concurrency
: Hardware concurrency to report
Overrides the Idle state.
Overrides default host system locale with the specified one.
Overrides value returned by the javascript navigator object.
Sets a specified page scale factor.
Switches script execution in the page.
Parameters:
- (Required)
hidden
: Whether scrollbars should be always hidden.
Overrides default host system timezone with the specified one.
Enables touch on platforms which do not support them.
Allows overriding user agent with the given string.
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.
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.
Types
disabled_image_type()
@type disabled_image_type() :: :avif | :webp
Enum of image types that can be disabled.
display_feature()
@type display_feature() :: %{ maskLength: integer(), offset: integer(), orientation: :vertical | :horizontal }
description not provided :(
media_feature()
description not provided :(
screen_orientation()
@type screen_orientation() :: %{ angle: integer(), type: :portraitPrimary | :portraitSecondary | :landscapePrimary | :landscapeSecondary }
Screen orientation.
user_agent_brand_version()
Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
user_agent_metadata()
@type user_agent_metadata() :: %{ architecture: String.t(), bitness: String.t() | nil, brands: [user_agent_brand_version()] | nil, fullVersion: String.t() | nil, fullVersionList: [user_agent_brand_version()] | nil, mobile: boolean(), model: String.t(), platform: String.t(), platformVersion: String.t(), wow64: boolean() | nil }
Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints Missing optional values will be filled in by the target with what it would normally use.
virtual_time_policy()
@type virtual_time_policy() :: :advance | :pause | :pauseIfNetworkFetchesPending
advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to allow the next delayed task (if any) to run; pause: The virtual time base may not advance; pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending resource fetches.
Functions
can_emulate()
Tells whether emulation is supported.
clear_device_metrics_override()
Clears the overridden device metrics.
clear_geolocation_override()
Clears the overridden Geolocation Position and Error.
clear_idle_override()
Clears Idle state overrides.
reset_page_scale_factor()
Requests that page scale factor is reset to initial values.
set_auto_dark_mode_override(enabled \\ nil)
Automatically render all web contents using a dark theme.
Parameters:
- (Optional)
enabled
: Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
set_automation_override(enabled)
Allows overriding the automation flag.
Parameters:
- (Required)
enabled
: Whether the override should be enabled.
set_cpu_throttling_rate(rate)
Enables CPU throttling to emulate slow CPUs.
Parameters:
- (Required)
rate
: Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
set_default_background_color_override(color \\ nil)
@spec set_default_background_color_override(CDPotion.Domain.DOM.rgba()) :: {String.t(), map()}
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:
- (Optional)
color
: RGBA of the default background color. If not specified, any existing override will be cleared.
set_device_metrics_override(width, height, device_scale_factor, mobile, scale \\ nil, screen_width \\ nil, screen_height \\ nil, position_x \\ nil, position_y \\ nil, dont_set_visible_size \\ nil, screen_orientation \\ nil, viewport \\ nil, display_feature \\ nil)
@spec set_device_metrics_override( integer(), integer(), number(), boolean(), number(), integer(), integer(), integer(), integer(), boolean(), screen_orientation(), CDPotion.Domain.Page.viewport(), display_feature() ) :: {String.t(), map()}
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:
- (Required)
width
: Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. - (Required)
height
: Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. - (Required)
device_scale_factor
: Overriding device scale factor value. 0 disables the override. - (Required)
mobile
: Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. - (Optional)
scale
: Scale to apply to resulting view image. - (Optional)
screen_width
: Overriding screen width value in pixels (minimum 0, maximum 10000000). - (Optional)
screen_height
: Overriding screen height value in pixels (minimum 0, maximum 10000000). - (Optional)
position_x
: Overriding view X position on screen in pixels (minimum 0, maximum 10000000). - (Optional)
position_y
: Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). - (Optional)
dont_set_visible_size
: Do not set visible view size, rely upon explicit setVisibleSize call. - (Optional)
screen_orientation
: Screen orientation override. - (Optional)
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. - (Optional)
display_feature
: If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off.
set_disabled_image_types(image_types)
@spec set_disabled_image_types([disabled_image_type()]) :: {String.t(), map()}
Parameters:
- (Required)
image_types
: Image types to disable.
set_document_cookie_disabled(disabled)
Parameters:
- (Required)
disabled
: Whether document.coookie API should be disabled.
set_emit_touch_events_for_mouse(enabled, configuration \\ nil)
Parameters:
- (Required)
enabled
: Whether touch emulation based on mouse input should be enabled. - (Optional)
configuration
: Touch/gesture events configuration. Default: current platform.
set_emulated_media(media \\ nil, features \\ nil)
@spec set_emulated_media(String.t(), [media_feature()]) :: {String.t(), map()}
Emulates the given media type or media feature for CSS media queries.
Parameters:
- (Optional)
media
: Media type to emulate. Empty string disables the override. - (Optional)
features
: Media features to emulate.
set_emulated_vision_deficiency(type)
Emulates the given vision deficiency.
Parameters:
- (Required)
type
: Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
set_focus_emulation_enabled(enabled)
Enables or disables simulating a focused and active page.
Parameters:
- (Required)
enabled
: Whether to enable to disable focus emulation.
set_geolocation_override(latitude \\ nil, longitude \\ nil, accuracy \\ nil)
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
Parameters:
- (Optional)
latitude
: Mock latitude - (Optional)
longitude
: Mock longitude - (Optional)
accuracy
: Mock accuracy
set_hardware_concurrency_override(hardware_concurrency)
Parameters:
- (Required)
hardware_concurrency
: Hardware concurrency to report
set_idle_override(is_user_active, is_screen_unlocked)
Overrides the Idle state.
Parameters:
- (Required)
is_user_active
: Mock isUserActive - (Required)
is_screen_unlocked
: Mock isScreenUnlocked
set_locale_override(locale \\ nil)
Overrides default host system locale with the specified one.
Parameters:
- (Optional)
locale
: ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
set_page_scale_factor(page_scale_factor)
Sets a specified page scale factor.
Parameters:
- (Required)
page_scale_factor
: Page scale factor.
set_script_execution_disabled(value)
Switches script execution in the page.
Parameters:
- (Required)
value
: Whether script execution should be disabled in the page.
set_timezone_override(timezone_id)
Overrides default host system timezone with the specified one.
Parameters:
- (Required)
timezone_id
: The timezone identifier. If empty, disables the override and restores default host system timezone.
set_touch_emulation_enabled(enabled, max_touch_points \\ nil)
Enables touch on platforms which do not support them.
Parameters:
- (Required)
enabled
: Whether the touch event emulation should be enabled. - (Optional)
max_touch_points
: Maximum touch points supported. Defaults to one.
set_user_agent_override(user_agent, accept_language \\ nil, platform \\ nil, user_agent_metadata \\ nil)
@spec set_user_agent_override( String.t(), String.t(), String.t(), user_agent_metadata() ) :: {String.t(), map()}
Allows overriding user agent with the given string.
Parameters:
- (Required)
user_agent
: User agent to use. - (Optional)
accept_language
: Browser langugage to emulate. - (Optional)
platform
: The platform navigator.platform should return. - (Optional)
user_agent_metadata
: To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
set_virtual_time_policy(policy, budget \\ nil, max_virtual_time_task_starvation_count \\ nil, initial_virtual_time \\ nil)
@spec set_virtual_time_policy( virtual_time_policy(), number(), integer(), CDPotion.Domain.Network.time_since_epoch() ) :: {String.t(), map()}
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.
Parameters:
- (Required)
policy
: description not provided :( - (Optional)
budget
: If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent. - (Optional)
max_virtual_time_task_starvation_count
: If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock. - (Optional)
initial_virtual_time
: If set, base::Time::Now will be overridden to initially return this value.
set_visible_size(width, height)
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.
Parameters:
- (Required)
width
: Frame width (DIP). - (Required)
height
: Frame height (DIP).