Home Reference Source
public class | source

Target

See:

Constructor Summary

Public Constructor
public

constructor(targetInit: TargetInit)

Member Summary

Private Members
private
private
private
private
private
private
private
private
private
private

Method Summary

Public Methods
public
public
public

Closes the target.

public
public

async exposeDevToolsProtocol(bindingName: string): Promise<void>

Inject object to the target's main frame that provides a communication channel with browser target.

Injected object will be available as window[bindingName].

The object has the following API:

  • binding.send(json) - a method to send messages over the remote debugging protocol
  • binding.onmessage = json => handleMessage(json) - a callback that will be called for the protocol notifications and command responses.

EXPERIMENTAL

public

getWindowBounds(): Promise<{bounds: WindowBounds, windowId: number}>

Get the browser window id and bounds for this target

public

id(): string

public

Returns T/F indicating if the target is for a background page

public

Returns T/F indicating if the target is for a browser

public

Returns T/F indicating if the target is for a page

public

Returns T/F indicating if the target is for a service worker

public
public
public
public

async setWindowBounds(windowId: number, bounds: WindowBounds): Promise<void>

Set position and/or size of the browser window.

public
public

type(): "page" | "background_page" | "service_worker" | "other" | "browser"

public

url(): string

Private Methods
private

_targetInfoChanged(targetInfo: Object)

Public Constructors

public constructor(targetInit: TargetInit) source

Params:

NameTypeAttributeDescription
targetInit TargetInit
  • nullable: false

Private Members

private _browserContext: BrowserContext source

private _client: Chrome | CDPSession | CRIConnection | undefined source

private _initializedPromise: Promise<boolean> source

private _isClosedPromise: Promise<*> source

private _isInitialized: boolean source

private _pageOpts: PageInitOptions source

private _pagePromise: Promise<Page> source

private _sessionFactory: function(): Promise<CDPSession> source

private _targetId: string source

private _targetInfo: Object source

Public Methods

public browser(): Browser source

Return:

Browser (nullable: true)

public browserContext(): BrowserContext source

Return:

BrowserContext (nullable: true)

public close(): Promise<boolean> source

Closes the target. If the target is a page that gets closed too.

Return:

Promise<boolean>

public createCDPSession(): Promise<CDPSession> source

Return:

Promise<CDPSession>

public async exposeDevToolsProtocol(bindingName: string): Promise<void> source

Inject object to the target's main frame that provides a communication channel with browser target.

Injected object will be available as window[bindingName].

The object has the following API:

  • binding.send(json) - a method to send messages over the remote debugging protocol
  • binding.onmessage = json => handleMessage(json) - a callback that will be called for the protocol notifications and command responses.

EXPERIMENTAL

Params:

NameTypeAttributeDescription
bindingName string
  • optional

Binding name, 'cdp' if not specified

Return:

Promise<void>

See:

public getWindowBounds(): Promise<{bounds: WindowBounds, windowId: number}> source

Get the browser window id and bounds for this target

Return:

Promise<{bounds: WindowBounds, windowId: number}>

public id(): string source

Return:

string

public isBackgroundPageTarget(): boolean source

Returns T/F indicating if the target is for a background page

Return:

boolean

public isBrowserTarget(): boolean source

Returns T/F indicating if the target is for a browser

Return:

boolean

public isPageTarget(): boolean source

Returns T/F indicating if the target is for a page

Return:

boolean

public isServiceWorkerTarget(): boolean source

Returns T/F indicating if the target is for a service worker

Return:

boolean

public opener(): Target source

Return:

Target (nullable: true)

public openerId(): string source

Return:

string (nullable: true)

public page(): Promise<Page|undefined> source

public async setWindowBounds(windowId: number, bounds: WindowBounds): Promise<void> source

Set position and/or size of the browser window. EXPERIMENTAL

Params:

NameTypeAttributeDescription
windowId number

An browser window id

bounds WindowBounds

New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.

Return:

Promise<void>

See:

public toJSON(): Object source

Return:

Object

public type(): "page" | "background_page" | "service_worker" | "other" | "browser" source

Return:

"page" | "background_page" | "service_worker" | "other" | "browser"

public url(): string source

Return:

string

Private Methods

private _targetInfoChanged(targetInfo: Object) source

Params:

NameTypeAttributeDescription
targetInfo Object
  • nullable: false