Package io.webfolder.cdp.command
Interface Emulation
-
public interface Emulation
This domain emulates different environments for the page
-
-
Method Summary
Modifier and Type Method Description java.lang.Boolean
canEmulate()
Tells whether emulation is supported.void
clearDeviceMetricsOverride()
Clears the overriden device metrics.void
clearGeolocationOverride()
Clears the overriden Geolocation Position and Error.void
resetPageScaleFactor()
Requests that page scale factor is reset to initial values.void
setCPUThrottlingRate(java.lang.Double rate)
Enables CPU throttling to emulate slow CPUs.void
setDefaultBackgroundColorOverride()
Sets or clears an override of the default background color of the frame.void
setDefaultBackgroundColorOverride(RGBA color)
Sets or clears an override of the default background color of the frame.void
setDeviceMetricsOverride(java.lang.Integer width, java.lang.Integer height, java.lang.Double deviceScaleFactor, java.lang.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(java.lang.Integer width, java.lang.Integer height, java.lang.Double deviceScaleFactor, java.lang.Boolean mobile, java.lang.Double scale, java.lang.Integer screenWidth, java.lang.Integer screenHeight, java.lang.Integer positionX, java.lang.Integer positionY, java.lang.Boolean dontSetVisibleSize, ScreenOrientation screenOrientation, Viewport viewport)
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
setDocumentCookieDisabled(java.lang.Boolean disabled)
void
setEmitTouchEventsForMouse(java.lang.Boolean enabled)
void
setEmitTouchEventsForMouse(java.lang.Boolean enabled, Platform configuration)
void
setEmulatedMedia(java.lang.String media)
Emulates the given media for CSS media queries.void
setFocusEmulationEnabled(java.lang.Boolean enabled)
Enables or disables simulating a focused and active page.void
setGeolocationOverride()
Overrides the Geolocation Position or Error.void
setGeolocationOverride(java.lang.Double latitude, java.lang.Double longitude, java.lang.Double accuracy)
Overrides the Geolocation Position or Error.void
setNavigatorOverrides(java.lang.String platform)
Overrides value returned by the javascript navigator object.void
setPageScaleFactor(java.lang.Double pageScaleFactor)
Sets a specified page scale factor.void
setScriptExecutionDisabled(java.lang.Boolean value)
Switches script execution in the page.void
setScrollbarsHidden(java.lang.Boolean hidden)
void
setTouchEmulationEnabled(java.lang.Boolean enabled)
Enables touch on platforms which do not support them.void
setTouchEmulationEnabled(java.lang.Boolean enabled, java.lang.Integer maxTouchPoints)
Enables touch on platforms which do not support them.void
setUserAgentOverride(java.lang.String userAgent)
Allows overriding user agent with the given string.void
setUserAgentOverride(java.lang.String userAgent, java.lang.String acceptLanguage, java.lang.String platform)
Allows overriding user agent with the given string.java.lang.Double
setVirtualTimePolicy(VirtualTimePolicy policy)
Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets the current virtual time policy.java.lang.Double
setVirtualTimePolicy(VirtualTimePolicy policy, java.lang.Double budget, java.lang.Integer maxVirtualTimeTaskStarvationCount, java.lang.Boolean waitForNavigation, java.lang.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(java.lang.Integer width, java.lang.Integer height)
Resizes the frame/viewport of the page.
-
-
-
Method Detail
-
canEmulate
java.lang.Boolean canEmulate()
Tells whether emulation is supported.- Returns:
- True if emulation is supported.
-
clearDeviceMetricsOverride
void clearDeviceMetricsOverride()
Clears the overriden device metrics.
-
clearGeolocationOverride
void clearGeolocationOverride()
Clears the overriden Geolocation Position and Error.
-
resetPageScaleFactor
void resetPageScaleFactor()
Requests that page scale factor is reset to initial values.
-
setFocusEmulationEnabled
void setFocusEmulationEnabled(java.lang.Boolean enabled)
Enables or disables simulating a focused and active page.- Parameters:
enabled
- Whether to enable to disable focus emulation.
-
setCPUThrottlingRate
void setCPUThrottlingRate(java.lang.Double rate)
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(RGBA color)
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(java.lang.Integer width, java.lang.Integer height, java.lang.Double deviceScaleFactor, java.lang.Boolean mobile, java.lang.Double scale, java.lang.Integer screenWidth, java.lang.Integer screenHeight, java.lang.Integer positionX, java.lang.Integer positionY, java.lang.Boolean dontSetVisibleSize, ScreenOrientation screenOrientation, Viewport viewport)
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.
-
setScrollbarsHidden
void setScrollbarsHidden(java.lang.Boolean hidden)
-
setDocumentCookieDisabled
void setDocumentCookieDisabled(java.lang.Boolean disabled)
-
setEmitTouchEventsForMouse
void setEmitTouchEventsForMouse(java.lang.Boolean enabled, Platform configuration)
-
setEmulatedMedia
void setEmulatedMedia(java.lang.String media)
Emulates the given media for CSS media queries.- Parameters:
media
- Media type to emulate. Empty string disables the override.
-
setGeolocationOverride
void setGeolocationOverride(java.lang.Double latitude, java.lang.Double longitude, java.lang.Double accuracy)
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.- Parameters:
latitude
- Mock latitudelongitude
- Mock longitudeaccuracy
- Mock accuracy
-
setNavigatorOverrides
void setNavigatorOverrides(java.lang.String platform)
Overrides value returned by the javascript navigator object.- Parameters:
platform
- The platform navigator.platform should return.
-
setPageScaleFactor
void setPageScaleFactor(java.lang.Double pageScaleFactor)
Sets a specified page scale factor.- Parameters:
pageScaleFactor
- Page scale factor.
-
setScriptExecutionDisabled
void setScriptExecutionDisabled(java.lang.Boolean value)
Switches script execution in the page.- Parameters:
value
- Whether script execution should be disabled in the page.
-
setTouchEmulationEnabled
void setTouchEmulationEnabled(java.lang.Boolean enabled, java.lang.Integer maxTouchPoints)
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.
-
setVirtualTimePolicy
java.lang.Double setVirtualTimePolicy(VirtualTimePolicy policy, java.lang.Double budget, java.lang.Integer maxVirtualTimeTaskStarvationCount, java.lang.Boolean waitForNavigation, java.lang.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.waitForNavigation
- If set the virtual time policy change should be deferred until any frame starts navigating. Note any previous deferred policy change is superseded.initialVirtualTime
- If set, base::Time::Now will be overriden to initially return this value.- Returns:
- Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
-
setVisibleSize
void setVisibleSize(java.lang.Integer width, java.lang.Integer 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:
width
- Frame width (DIP).height
- Frame height (DIP).
-
setUserAgentOverride
void setUserAgentOverride(java.lang.String userAgent, java.lang.String acceptLanguage, java.lang.String platform)
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.
-
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.
-
setDeviceMetricsOverride
void setDeviceMetricsOverride(java.lang.Integer width, java.lang.Integer height, java.lang.Double deviceScaleFactor, java.lang.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.
-
setEmitTouchEventsForMouse
void setEmitTouchEventsForMouse(java.lang.Boolean enabled)
-
setGeolocationOverride
void setGeolocationOverride()
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
-
setTouchEmulationEnabled
void setTouchEmulationEnabled(java.lang.Boolean enabled)
Enables touch on platforms which do not support them.- Parameters:
enabled
- Whether the touch event emulation should be enabled.
-
setVirtualTimePolicy
java.lang.Double setVirtualTimePolicy(VirtualTimePolicy policy)
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).
-
setUserAgentOverride
void setUserAgentOverride(java.lang.String userAgent)
Allows overriding user agent with the given string.- Parameters:
userAgent
- User agent to use.
-
-