Package io.webfolder.cdp.command
Interface Emulation
public interface Emulation
This domain emulates different environments for the page.
-
Method Summary
Modifier and TypeMethodDescriptionTells whether emulation is supported.void
Clears the overridden device metrics.void
Clears the overridden Geolocation Position and Error.void
Clears Idle state overrides.void
Requests that page scale factor is reset to initial values.void
Automatically render all web contents using a dark theme.void
setAutoDarkModeOverride
(Boolean enabled) Automatically render all web contents using a dark theme.void
setAutomationOverride
(Boolean enabled) Allows overriding the automation flag.void
setCPUThrottlingRate
(Double rate) Enables CPU throttling to emulate slow CPUs.void
Sets or clears an override of the default background color of the frame.void
Sets or clears an override of the default background color of the frame.void
setDeviceMetricsOverride
(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile) 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).void
setDeviceMetricsOverride
(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile, Double scale, Integer screenWidth, Integer screenHeight, Integer positionX, Integer positionY, Boolean dontSetVisibleSize, ScreenOrientation screenOrientation, Viewport viewport, DisplayFeature displayFeature) 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).void
setDisabledImageTypes
(DisabledImageType imageTypes) void
setDocumentCookieDisabled
(Boolean disabled) void
setEmitTouchEventsForMouse
(Boolean enabled) void
setEmitTouchEventsForMouse
(Boolean enabled, Platform configuration) void
Emulates the given media type or media feature for CSS media queries.void
setEmulatedMedia
(String media, List<MediaFeature> features) Emulates the given media type or media feature for CSS media queries.void
Emulates the given vision deficiency.void
setFocusEmulationEnabled
(Boolean enabled) Enables or disables simulating a focused and active page.void
Overrides the Geolocation Position or Error.void
setGeolocationOverride
(Double latitude, Double longitude, Double accuracy) Overrides the Geolocation Position or Error.void
setHardwareConcurrencyOverride
(Integer hardwareConcurrency) void
setIdleOverride
(Boolean isUserActive, Boolean isScreenUnlocked) Overrides the Idle state.void
Overrides default host system locale with the specified one.void
setLocaleOverride
(String locale) Overrides default host system locale with the specified one.void
setNavigatorOverrides
(String platform) Deprecated.void
setPageScaleFactor
(Double pageScaleFactor) Sets a specified page scale factor.void
Switches script execution in the page.void
setScrollbarsHidden
(Boolean hidden) void
setTimezoneOverride
(String timezoneId) Overrides default host system timezone with the specified one.void
setTouchEmulationEnabled
(Boolean enabled) Enables touch on platforms which do not support them.void
setTouchEmulationEnabled
(Boolean enabled, Integer maxTouchPoints) Enables touch on platforms which do not support them.void
setUserAgentOverride
(String userAgent) Allows overriding user agent with the given string.void
setUserAgentOverride
(String userAgent, String acceptLanguage, String platform, UserAgentMetadata userAgentMetadata) 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.setVirtualTimePolicy
(VirtualTimePolicy policy, Double budget, Integer maxVirtualTimeTaskStarvationCount, Double initialVirtualTime) Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets the current virtual time policy.void
setVisibleSize
(Integer width, Integer height) Deprecated.
-
Method Details
-
canEmulate
Boolean canEmulate()Tells whether emulation is supported.- Returns:
- True if emulation is supported.
-
clearDeviceMetricsOverride
void clearDeviceMetricsOverride()Clears the overridden device metrics. -
clearGeolocationOverride
void clearGeolocationOverride()Clears the overridden Geolocation Position and Error. -
clearIdleOverride
void clearIdleOverride()Clears Idle state overrides. -
resetPageScaleFactor
void resetPageScaleFactor()Requests that page scale factor is reset to initial values. -
setAutoDarkModeOverride
void setAutoDarkModeOverride()Automatically render all web contents using a dark theme. -
setAutoDarkModeOverride
Automatically render all web contents using a dark theme.- Parameters:
enabled
- Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
-
setAutomationOverride
Allows overriding the automation flag.- Parameters:
enabled
- Whether the override should be enabled.
-
setCPUThrottlingRate
Enables CPU throttling to emulate slow CPUs.- Parameters:
rate
- Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
-
setDefaultBackgroundColorOverride
void setDefaultBackgroundColorOverride()Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one. -
setDefaultBackgroundColorOverride
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.
-
setDeviceMetricsOverride
void setDeviceMetricsOverride(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile) 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.deviceScaleFactor
- 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.
-
setDeviceMetricsOverride
void setDeviceMetricsOverride(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile, Double scale, Integer screenWidth, Integer screenHeight, Integer positionX, Integer positionY, Boolean dontSetVisibleSize, ScreenOrientation screenOrientation, Viewport viewport, DisplayFeature displayFeature) 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.deviceScaleFactor
- 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.scale
- Scale to apply to resulting view image.screenWidth
- Overriding screen width value in pixels (minimum 0, maximum 10000000).screenHeight
- Overriding screen height value in pixels (minimum 0, maximum 10000000).positionX
- Overriding view X position on screen in pixels (minimum 0, maximum 10000000).positionY
- Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).dontSetVisibleSize
- Do not set visible view size, rely upon explicit setVisibleSize call.screenOrientation
- Screen orientation override.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.displayFeature
- If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off.
-
setDisabledImageTypes
-
setDocumentCookieDisabled
-
setEmitTouchEventsForMouse
-
setEmitTouchEventsForMouse
-
setEmulatedMedia
void setEmulatedMedia()Emulates the given media type or media feature for CSS media queries. -
setEmulatedMedia
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.
-
setEmulatedVisionDeficiency
Emulates the given vision deficiency.- Parameters:
type
- Vision deficiency to emulate.
-
setFocusEmulationEnabled
Enables or disables simulating a focused and active page.- Parameters:
enabled
- Whether to enable to disable focus emulation.
-
setGeolocationOverride
void setGeolocationOverride()Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable. -
setGeolocationOverride
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.- Parameters:
latitude
- Mock latitudelongitude
- Mock longitudeaccuracy
- Mock accuracy
-
setHardwareConcurrencyOverride
-
setIdleOverride
Overrides the Idle state.- Parameters:
isUserActive
- Mock isUserActiveisScreenUnlocked
- Mock isScreenUnlocked
-
setLocaleOverride
void setLocaleOverride()Overrides default host system locale with the specified one. -
setLocaleOverride
Overrides default host system locale with the specified one.- Parameters:
locale
- ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
-
setPageScaleFactor
Sets a specified page scale factor.- Parameters:
pageScaleFactor
- Page scale factor.
-
setScriptExecutionDisabled
Switches script execution in the page.- Parameters:
value
- Whether script execution should be disabled in the page.
-
setScrollbarsHidden
-
setTimezoneOverride
Overrides default host system timezone with the specified one.- Parameters:
timezoneId
- The timezone identifier. If empty, disables the override and restores default host system timezone.
-
setTouchEmulationEnabled
Enables touch on platforms which do not support them.- Parameters:
enabled
- Whether the touch event emulation should be enabled.
-
setTouchEmulationEnabled
Enables touch on platforms which do not support them.- Parameters:
enabled
- Whether the touch event emulation should be enabled.maxTouchPoints
- Maximum touch points supported. Defaults to one.
-
setUserAgentOverride
Allows overriding user agent with the given string.- Parameters:
userAgent
- User agent to use.
-
setUserAgentOverride
void setUserAgentOverride(String userAgent, String acceptLanguage, String platform, UserAgentMetadata userAgentMetadata) Allows overriding user agent with the given string.- Parameters:
userAgent
- User agent to use.acceptLanguage
- Browser langugage to emulate.platform
- The platform navigator.platform should return.userAgentMetadata
- To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
-
setVirtualTimePolicy
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.- Returns:
- Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
-
setVirtualTimePolicy
Double setVirtualTimePolicy(VirtualTimePolicy policy, Double budget, Integer maxVirtualTimeTaskStarvationCount, Double initialVirtualTime) 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:
budget
- If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.maxVirtualTimeTaskStarvationCount
- If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.initialVirtualTime
- If 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
Deprecated.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:
width
- Frame width (DIP).height
- Frame height (DIP).
-