public interface Emulation
| Modifier and Type | Method and Description |
|---|---|
Boolean |
canEmulate()
Tells whether emulation is supported.
|
void |
clearDeviceMetricsOverride()
Clears the overriden device metrics.
|
void |
clearGeolocationOverride()
Clears the overriden Geolocation Position and Error.
|
EventListener |
onVirtualTimeBudgetExpired(EventHandler<VirtualTimeBudgetExpired> eventListener)
Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
|
void |
resetPageScaleFactor()
Requests that page scale factor is reset to initial values.
|
void |
setCPUThrottlingRate(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(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)
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(Boolean disabled) |
void |
setEmitTouchEventsForMouse(Boolean enabled) |
void |
setEmitTouchEventsForMouse(Boolean enabled,
SetEmitTouchEventsForMouseConfiguration configuration) |
void |
setEmulatedMedia(String media)
Emulates the given media for CSS media queries.
|
void |
setFocusEmulationEnabled(Boolean enabled)
Enables or disables simulating a focused and active page.
|
void |
setGeolocationOverride()
Overrides the Geolocation Position or Error.
|
void |
setGeolocationOverride(Double latitude,
Double longitude,
Double accuracy)
Overrides the Geolocation Position or Error.
|
void |
setNavigatorOverrides(String platform)
Deprecated.
|
void |
setPageScaleFactor(Double pageScaleFactor)
Sets a specified page scale factor.
|
void |
setScriptExecutionDisabled(Boolean value)
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)
Allows overriding user agent with the given string.
|
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.
|
Double |
setVirtualTimePolicy(VirtualTimePolicy policy,
Double budget,
Integer maxVirtualTimeTaskStarvationCount,
Boolean waitForNavigation,
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.
|
Boolean canEmulate()
void clearDeviceMetricsOverride()
void clearGeolocationOverride()
void resetPageScaleFactor()
void setFocusEmulationEnabled(Boolean enabled)
enabled - Whether to enable to disable focus emulation.void setCPUThrottlingRate(Double rate)
rate - Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).void setDefaultBackgroundColorOverride()
void setDefaultBackgroundColorOverride(RGBA color)
color - RGBA of the default background color. If not specified, any existing override will
be cleared.void setDeviceMetricsOverride(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile)
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.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)
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.void setScrollbarsHidden(Boolean hidden)
hidden - Whether scrollbars should be always hidden.void setDocumentCookieDisabled(Boolean disabled)
disabled - Whether document.coookie API should be disabled.void setEmitTouchEventsForMouse(Boolean enabled)
enabled - Whether touch emulation based on mouse input should be enabled.void setEmitTouchEventsForMouse(Boolean enabled, SetEmitTouchEventsForMouseConfiguration configuration)
enabled - Whether touch emulation based on mouse input should be enabled.configuration - Touch/gesture events configuration. Default: current platform.void setEmulatedMedia(String media)
media - Media type to emulate. Empty string disables the override.void setGeolocationOverride()
void setGeolocationOverride(Double latitude, Double longitude, Double accuracy)
latitude - Mock latitudelongitude - Mock longitudeaccuracy - Mock accuracy@Deprecated void setNavigatorOverrides(String platform)
platform - The platform navigator.platform should return.void setPageScaleFactor(Double pageScaleFactor)
pageScaleFactor - Page scale factor.void setScriptExecutionDisabled(Boolean value)
value - Whether script execution should be disabled in the page.void setTouchEmulationEnabled(Boolean enabled)
enabled - Whether the touch event emulation should be enabled.void setTouchEmulationEnabled(Boolean enabled, Integer maxTouchPoints)
enabled - Whether the touch event emulation should be enabled.maxTouchPoints - Maximum touch points supported. Defaults to one.Double setVirtualTimePolicy(VirtualTimePolicy policy)
policy - Double setVirtualTimePolicy(VirtualTimePolicy policy, Double budget, Integer maxVirtualTimeTaskStarvationCount, Boolean waitForNavigation, Double initialVirtualTime)
policy - 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.void setTimezoneOverride(String timezoneId)
timezoneId - The timezone identifier. If empty, disables the override and restores default
host system timezone.@Deprecated void setVisibleSize(Integer width, Integer height)
width - Frame width (DIP).height - Frame height (DIP).void setUserAgentOverride(String userAgent)
userAgent - User agent to use.void setUserAgentOverride(String userAgent, String acceptLanguage, String platform)
userAgent - User agent to use.acceptLanguage - Browser langugage to emulate.platform - The platform navigator.platform should return.EventListener onVirtualTimeBudgetExpired(EventHandler<VirtualTimeBudgetExpired> eventListener)
Copyright © 2020. All rights reserved.