Package io.webfolder.cdp.command
Interface EmulationAsync
public interface EmulationAsync
This domain emulates different environments for the page.
-
Method Summary
Modifier and TypeMethodDescriptionTells 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.setAutoDarkModeOverride
(Boolean enabled) Automatically render all web contents using a dark theme.setAutomationOverride
(Boolean enabled) Allows overriding the automation flag.setCPUThrottlingRate
(Double rate) Enables CPU throttling to emulate slow CPUs.Sets or clears an override of the default background color of the frame.Sets or clears an override of the default background color of the frame.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).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).setDisabledImageTypes
(DisabledImageType imageTypes) setDocumentCookieDisabled
(Boolean disabled) setEmitTouchEventsForMouse
(Boolean enabled) setEmitTouchEventsForMouse
(Boolean enabled, Platform configuration) Emulates the given media type or media feature for CSS media queries.setEmulatedMedia
(String media, List<MediaFeature> features) Emulates the given media type or media feature for CSS media queries.Emulates the given vision deficiency.setFocusEmulationEnabled
(Boolean enabled) Enables or disables simulating a focused and active page.Overrides the Geolocation Position or Error.setGeolocationOverride
(Double latitude, Double longitude, Double accuracy) Overrides the Geolocation Position or Error.setHardwareConcurrencyOverride
(Integer hardwareConcurrency) setIdleOverride
(Boolean isUserActive, Boolean isScreenUnlocked) Overrides the Idle state.Overrides default host system locale with the specified one.setLocaleOverride
(String locale) Overrides default host system locale with the specified one.setNavigatorOverrides
(String platform) Deprecated.setPageScaleFactor
(Double pageScaleFactor) Sets a specified page scale factor.Switches script execution in the page.setScrollbarsHidden
(Boolean hidden) setTimezoneOverride
(String timezoneId) Overrides default host system timezone with the specified one.setTouchEmulationEnabled
(Boolean enabled) Enables touch on platforms which do not support them.setTouchEmulationEnabled
(Boolean enabled, Integer maxTouchPoints) Enables touch on platforms which do not support them.setUserAgentOverride
(String userAgent) Allows overriding user agent with the given string.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.setVisibleSize
(Integer width, Integer height) Deprecated.
-
Method Details
-
canEmulate
CompletableFuture<Boolean> canEmulate()Tells whether emulation is supported.- Returns:
- True if emulation is supported.
-
clearDeviceMetricsOverride
CompletableFuture<Void> clearDeviceMetricsOverride()Clears the overridden device metrics. -
clearGeolocationOverride
CompletableFuture<Void> clearGeolocationOverride()Clears the overridden Geolocation Position and Error. -
clearIdleOverride
CompletableFuture<Void> clearIdleOverride()Clears Idle state overrides. -
resetPageScaleFactor
CompletableFuture<Void> resetPageScaleFactor()Requests that page scale factor is reset to initial values. -
setAutoDarkModeOverride
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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
CompletableFuture<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).
-