Home Reference Source
public class | source

NetworkManager

Extends:

eventemitter3~EventEmitter → NetworkManager

Constructor Summary

Public Constructor
public

constructor(client: Chrome | CRIConnection | CDPSession | Object, timeoutSettings: TimeoutSettings)

Member Summary

Private Members
private
private
private
private

_credentials: {username: string, password: string}

private
private
private
private
private
private
private
private
private
private

Method Summary

Public Methods
public

async authenticate(credentials: {username: string, password: string})

public

async bypassServiceWorker(bypass: boolean): Promise<void>

Toggles ignoring of service worker for each request.

since chrome-remote-interface-extra
public

async clearBrowserCache(): Promise<void>

since chrome-remote-interface-extra
public

async clearBrowserCookies(): Promise<void>

Clears browser cookies

since chrome-remote-interface-extra
public

async deleteCookie(cookie: CDPCookie | CookieToBeDeleted | string | Cookie, forURL: string): Promise<void>

Deletes the specified browser cookies with matching name and url or domain/path pair.

since chrome-remote-interface-extra
public

Deletes browser cookies with matching name and url or domain/path pair.

since chrome-remote-interface-extra
public

async disableCache(): Promise<void>

since chrome-remote-interface-extra
public

async emulateNetworkConditions(networkConditions: NetworkConditions): Promise<void>

Activates emulation of network conditions

since chrome-remote-interface-extra
public

async enableCache(): Promise<void>

since chrome-remote-interface-extra
public
public

Returns all browser cookies.

since chrome-remote-interface-extra
public

Returns the DER-encoded certificate.

since chrome-remote-interface-extra
public

Returns all browser cookies for the current URL.

since chrome-remote-interface-extra
public

Returns a promise that resolves once the network has become idle.

since chrome-remote-interface-extra
public

async setAcceptLanguage(acceptLanguage: string)

since chrome-remote-interface-extra
public

async setBlockedURLs(urls: ...string): Promise<void>

Blocks URLs from loading.

since chrome-remote-interface-extra
public

Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist

since chrome-remote-interface-extra
public

async setCookies(cookies: ...(CDPCookie|CookieParam|string)): Promise<void>

Sets given cookies

since chrome-remote-interface-extra
public

async setExtraHTTPHeaders(extraHTTPHeaders: Object<string, string>)

public

setFrameManager(frameManager: FrameManager)

public

async setNavigatorPlatform(platform: string)

since chrome-remote-interface-extra
public

async setOfflineMode(offline: boolean)

public
public
since chrome-remote-interface-extra
public

async setUserAgent(userAgent: string)

public

Allows overriding user agent with the given string.

public

toJSON(): {"extraHTTPHeaders": *, "ignoreHTTPSErrors": *, "defaultViewport": *, "offline": *, "cacheEnabledState": *, "credentials": *, "userRequestInterceptionEnabled": *, "protocolRequestInterceptionEnabled": *}

public

waitForRequest(urlOrPredicate: string | Function, options: {timeout?: number}): Promise<Request>

public

waitForResponse(urlOrPredicate: string | Function, options: {timeout?: number}): Promise<Response>

Private Methods
private
private
private
private

_onRequest(event: Object, interceptionId: string)

private
private
private
private
private

_setCacheDisabled(cacheDisabled: boolean): Promise<*>

private

Public Constructors

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

Params:

NameTypeAttributeDescription
client Chrome | CRIConnection | CDPSession | Object
timeoutSettings TimeoutSettings
  • optional

Private Members

private _attemptedAuthentications: Set<string> source

private _cacheEnabledState: boolean source

private _client: Chrome | CRIConnection | CDPSession | Object source

private _credentials: {username: string, password: string} source

private _extraHTTPHeaders: Object<string, string> source

private _frameManager: FrameManager source

private _offline: boolean source

private _protocolRequestInterceptionEnabled: boolean source

private _requestHashToInterceptionIds: Multimap<string, string> source

private _requestHashToRequestIds: Multimap<string, string> source

private _requestIdToRequest: Map<string, Request> source

private _requestIdToRequestWillBeSentEvent: Map<string, Object> source

private _timeoutSettings: TimeoutSettings source

private _userRequestInterceptionEnabled: boolean source

Public Methods

public async authenticate(credentials: {username: string, password: string}) source

Params:

NameTypeAttributeDescription
credentials {username: string, password: string}
  • nullable: true

public async bypassServiceWorker(bypass: boolean): Promise<void> since chrome-remote-interface-extra source

Toggles ignoring of service worker for each request. EXPERIMENTAL

Params:

NameTypeAttributeDescription
bypass boolean

Bypass service worker and load from network

Return:

Promise<void>

See:

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

Return:

Promise<void>

See:

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

Clears browser cookies

Return:

Promise<void>

See:

public async deleteCookie(cookie: CDPCookie | CookieToBeDeleted | string | Cookie, forURL: string): Promise<void> since chrome-remote-interface-extra source

Deletes the specified browser cookies with matching name and url or domain/path pair.

Params:

NameTypeAttributeDescription
cookie CDPCookie | CookieToBeDeleted | string | Cookie

The cookie to be deleted

forURL string
  • optional

Return:

Promise<void>

See:

public async deleteCookies(cookies: ...(CDPCookie|CookieToBeDeleted|string|Cookie)): Promise<void> since chrome-remote-interface-extra source

Deletes browser cookies with matching name and url or domain/path pair.

Params:

NameTypeAttributeDescription
cookies ...(CDPCookie|CookieToBeDeleted|string|Cookie)

The cookies to be deleted

Return:

Promise<void>

See:

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

Return:

Promise<void>

See:

public async emulateNetworkConditions(networkConditions: NetworkConditions): Promise<void> since chrome-remote-interface-extra source

Activates emulation of network conditions

Params:

NameTypeAttributeDescription
networkConditions NetworkConditions

The new network conditions

Return:

Promise<void>

See:

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

Return:

Promise<void>

See:

public extraHTTPHeaders(): Object<string, string> source

Return:

Object<string, string> (nullable: false)

public async getAllCookies(): Promise<Array<Cookie>> since chrome-remote-interface-extra source

Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field.

Return:

Promise<Array<Cookie>>

See:

public async getCertificate(origin: string): Promise<Array<string>> since chrome-remote-interface-extra source

Returns the DER-encoded certificate. EXPERIMENTAL

Params:

NameTypeAttributeDescription
origin string

Origin to get certificate for

Return:

Promise<Array<string>>

See:

public async getCookies(urls: Array<string>): Promise<Array<Cookie>> since chrome-remote-interface-extra source

Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.

Params:

NameTypeAttributeDescription
urls Array<string>

The list of URLs for which applicable cookies will be fetched

Return:

Promise<Array<Cookie>>

See:

public networkIdlePromise(options: NetIdleOptions): Promise<void> since chrome-remote-interface-extra source

Returns a promise that resolves once the network has become idle. Detection of network idle considers only the number of in-flight HTTP requests for the Page connected to

Params:

NameTypeAttributeDescription
options NetIdleOptions
  • optional

Return:

Promise<void>

public async setAcceptLanguage(acceptLanguage: string) since chrome-remote-interface-extra source

Params:

NameTypeAttributeDescription
acceptLanguage string

Browser langugage to emulate

See:

public async setBlockedURLs(urls: ...string): Promise<void> since chrome-remote-interface-extra source

Blocks URLs from loading. EXPERIMENTAL

Params:

NameTypeAttributeDescription
urls ...string

URL patterns to block. Wildcards ('*') are allowed

Return:

Promise<void>

See:

public async setCookie(cookie: CDPCookie | CookieParam | string): Promise<boolean> since chrome-remote-interface-extra source

Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist

Params:

NameTypeAttributeDescription
cookie CDPCookie | CookieParam | string

The new cookie to be set

Return:

Promise<boolean>

T/F indicating if the cookie was set

See:

public async setCookies(cookies: ...(CDPCookie|CookieParam|string)): Promise<void> since chrome-remote-interface-extra source

Sets given cookies

Params:

NameTypeAttributeDescription
cookies ...(CDPCookie|CookieParam|string)

Return:

Promise<void>

See:

public async setExtraHTTPHeaders(extraHTTPHeaders: Object<string, string>) source

Params:

NameTypeAttributeDescription
extraHTTPHeaders Object<string, string>
  • nullable: false

public setFrameManager(frameManager: FrameManager) source

Params:

NameTypeAttributeDescription
frameManager FrameManager
  • nullable: false

public async setNavigatorPlatform(platform: string) since chrome-remote-interface-extra source

Params:

NameTypeAttributeDescription
platform string

The platform navigator.platform should return

See:

public async setOfflineMode(offline: boolean) source

Params:

NameTypeAttributeDescription
offline boolean

T/F indicating offline status

See:

public async setRequestInterception(value: boolean) source

Params:

NameTypeAttributeDescription
value boolean

public setTimeoutSettings(toSettings: TimeoutSettings) since chrome-remote-interface-extra source

Params:

NameTypeAttributeDescription
toSettings TimeoutSettings

public async setUserAgent(userAgent: string) source

Params:

NameTypeAttributeDescription
userAgent string

User agent to use

See:

public async setUserAgentOverride(overrides: UserAgentOverride): Promise<void> source

Allows overriding user agent with the given string.

Params:

NameTypeAttributeDescription
overrides UserAgentOverride

Return:

Promise<void>

See:

public toJSON(): {"extraHTTPHeaders": *, "ignoreHTTPSErrors": *, "defaultViewport": *, "offline": *, "cacheEnabledState": *, "credentials": *, "userRequestInterceptionEnabled": *, "protocolRequestInterceptionEnabled": *} source

Return:

{"extraHTTPHeaders": *, "ignoreHTTPSErrors": *, "defaultViewport": *, "offline": *, "cacheEnabledState": *, "credentials": *, "userRequestInterceptionEnabled": *, "protocolRequestInterceptionEnabled": *}

public waitForRequest(urlOrPredicate: string | Function, options: {timeout?: number}): Promise<Request> source

Params:

NameTypeAttributeDescription
urlOrPredicate string | Function
options {timeout?: number}
  • optional

Return:

Promise<Request>

public waitForResponse(urlOrPredicate: string | Function, options: {timeout?: number}): Promise<Response> source

Params:

NameTypeAttributeDescription
urlOrPredicate string | Function
options {timeout?: number}
  • optional

Return:

Promise<Response>

Private Methods

private _handleRequestRedirect(request: Request, event: Object) source

Params:

NameTypeAttributeDescription
request Request
  • nullable: false
event Object
  • nullable: false

private _onLoadingFailed(event: Object) source

Params:

NameTypeAttributeDescription
event Object
  • nullable: false

private _onLoadingFinished(event: Object) source

Params:

NameTypeAttributeDescription
event Object
  • nullable: false

private _onRequest(event: Object, interceptionId: string) source

Params:

NameTypeAttributeDescription
event Object
  • nullable: false
interceptionId string
  • nullable: true

private _onRequestIntercepted(event: Object) source

Params:

NameTypeAttributeDescription
event Object
  • nullable: false

private _onRequestServedFromCache(event: Object) source

Params:

NameTypeAttributeDescription
event Object
  • nullable: false

private _onRequestWillBeSent(event: Object) source

Params:

NameTypeAttributeDescription
event Object
  • nullable: false

private _onResponseReceived(event: Object) source

Params:

NameTypeAttributeDescription
event Object
  • nullable: false

private _setCacheDisabled(cacheDisabled: boolean): Promise<*> source

Params:

NameTypeAttributeDescription
cacheDisabled boolean

Return:

Promise<*>

private async _updateProtocolRequestInterception() source