Home Reference Source
public class | source

EmulationManager

See:

Constructor Summary

Public Constructor
public

constructor(client: Chrome | CRIConnection | CDPSession | Object)

Member Summary

Private Members
private
private

What media type are we emulating

private

Are we emulating mobile?

private

Can we interact via touches

private

Is no script enabled

private
since chrome-remote-interface-extra

Method Summary

Public Methods
public

Clears the overridden device metrics

public

Clears the overridden Geolocation Position and Error

public
public
since chrome-remote-interface-extra
public
since chrome-remote-interface-extra
public
public

Sets or clears an override of the default background color of the frame.

since chrome-remote-interface-extra
public

async setDeviceMetricsOverride(options: Object): Promise<void>

Overrides the values of device screen dimensions

  • window.screen.width
  • window.screen.height
  • window.innerWidth
  • window.innerHeight
since chrome-remote-interface-extra
public

async setEmulatedMedia(media: string): Promise<void>

Emulates the given media for CSS media queries

since chrome-remote-interface-extra
public

async setGeolocation(options: {longitude: number, latitude: number, accuracy: number|undefined})

Overrides the Geolocation Position or Error.

since chrome-remote-interface-extra
public

async setScriptExecutionDisabled(disabled: boolean): Promise<void>

Switches script execution in the page.

public

async setTouchEmulationEnabled(enabled: boolean, maxTouchPoints: number): Promise<void>

Enables touch on platforms which do not support them

since chrome-remote-interface-extra

Public Constructors

public constructor(client: Chrome | CRIConnection | CDPSession | Object) source

Params:

NameTypeAttributeDescription
client Chrome | CRIConnection | CDPSession | Object

Private Members

private _client: Chrome | CRIConnection | CDPSession | Object source

private _emulatingMedia: string source

What media type are we emulating

private _emulatingMobile: boolean source

Are we emulating mobile?

private _hasTouch: boolean source

Can we interact via touches

private _scriptExecutionDisabled: boolean source

Is no script enabled

private _supportedMedia: Set<string> since chrome-remote-interface-extra source

Public Methods

public async clearDeviceMetricsOverride(): Promise<void> source

Clears the overridden device metrics

Return:

Promise<void>

public async clearGeolocationOverride(): Promise<void> source

Clears the overridden Geolocation Position and Error

Return:

Promise<void>

public async emulateViewport(viewport: Viewport): Promise<boolean> source

Params:

NameTypeAttributeDescription
viewport Viewport
  • nullable: false

Return:

Promise<boolean>

public isEmulatingHasTouch(): boolean since chrome-remote-interface-extra source

Return:

boolean

public isEmulatingMobile(): boolean since chrome-remote-interface-extra source

Return:

boolean

public isScriptExecutionDisabled(): boolean source

Return:

boolean

public async setDefaultBackgroundColorOverride(color: DOMRGBA): Promise<void> since chrome-remote-interface-extra source

Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.

Params:

NameTypeAttributeDescription
color DOMRGBA
  • optional

RGBA of the default background color. If not specified, any existing override will be cleared

Return:

Promise<void>

See:

public async setDeviceMetricsOverride(options: Object): Promise<void> since chrome-remote-interface-extra source

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).

Params:

NameTypeAttributeDescription
options Object

Return:

Promise<void>

See:

public async setEmulatedMedia(media: string): Promise<void> since chrome-remote-interface-extra source

Emulates the given media for CSS media queries

Params:

NameTypeAttributeDescription
media string

Media type to emulate. Empty string disables the override

Return:

Promise<void>

See:

public async setGeolocation(options: {longitude: number, latitude: number, accuracy: number|undefined}) since chrome-remote-interface-extra source

Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable

Params:

NameTypeAttributeDescription
options {longitude: number, latitude: number, accuracy: number|undefined}
  • nullable: false

See:

public async setScriptExecutionDisabled(disabled: boolean): Promise<void> source

Switches script execution in the page.

Params:

NameTypeAttributeDescription
disabled boolean

Whether script execution should be disabled in the page

Return:

Promise<void>

See:

public async setTouchEmulationEnabled(enabled: boolean, maxTouchPoints: number): Promise<void> since chrome-remote-interface-extra source

Enables touch on platforms which do not support them

Params:

NameTypeAttributeDescription
enabled boolean

Whether the touch event emulation should be enabled

maxTouchPoints number
  • optional
  • default: 1

Maximum touch points supported. Defaults to one

Return:

Promise<void>

See: