Emulation Domain
This domain emulates different environments for the page.
Methods
setDeviceMetricsOverride#
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
- integer Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
- height
- integer Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
- deviceScaleFactor
- number Overriding device scale factor value. 0 disables the override.
- mobile
- boolean Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
- fitWindow
- boolean Whether a view that exceeds the available browser window area should be scaled down to fit.
- scale
- number Scale to apply to resulting view image. Ignored in |fitWindow| mode.
- offsetX
- number X offset to shift resulting view image by. Ignored in |fitWindow| mode.
- offsetY
- number Y offset to shift resulting view image by. Ignored in |fitWindow| mode.
- screenWidth
- integer Overriding screen width value in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
- screenHeight
- integer Overriding screen height value in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
- positionX
- integer Overriding view X position on screen in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
- positionY
- integer Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
clearDeviceMetricsOverride#
Clears the overriden device metrics.
resetScrollAndPageScaleFactor#
Requests that scroll offsets and page scale factor are reset to initial values.
setPageScaleFactor#
Sets a specified page scale factor.
Parameters
- pageScaleFactor
- number Page scale factor.
setScriptExecutionDisabled#
Switches script execution in the page.
Parameters
- value
- boolean Whether script execution should be disabled in the page.
setGeolocationOverride#
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
Parameters
- latitude
- number Mock latitude
- longitude
- number Mock longitude
- accuracy
- number Mock accuracy
clearGeolocationOverride#
Clears the overriden Geolocation Position and Error.
setTouchEmulationEnabled#
Toggles mouse event-based touch event emulation.
Parameters
- enabled
- boolean Whether the touch event emulation should be enabled.
- configuration
- string Touch/gesture events configuration. Default: current platform. Allowed values: mobile, desktop.
setEmulatedMedia#
Emulates the given media for CSS media queries.
Parameters
- media
- string Media type to emulate. Empty string disables the override.
canEmulate#
Tells whether emulation is supported.
Return object
- result
- boolean True if emulation is supported.
Events
Types
Viewport#
Visible page viewport
Type: object
Properties
- scrollX
- number X scroll offset in CSS pixels.
- scrollY
- number Y scroll offset in CSS pixels.
- contentsWidth
- number Contents width in CSS pixels.
- contentsHeight
- number Contents height in CSS pixels.
- pageScaleFactor
- number Page scale factor.
- minimumPageScaleFactor
- number Minimum page scale factor.
- maximumPageScaleFactor
- number Maximum page scale factor.