Home Reference Source
public class | source

LifecycleWatcher

An utility class that watches the supplied frame and its children (if any) to determine if they reach the specified lifecycle(s)

Lifecycle mapping in the form of supplied to CDP value:

  • load: load
  • domcontentloaded: DOMContentLoaded
  • networkIdle: networkIdle
  • networkAlmostIdle: networkAlmostIdle
  • networkidle0: networkIdle
  • networkidle2: networkAlmostIdle

Constructor Summary

Public Constructor
public

constructor(frameManager: FrameManager, frame: Frame, waitUntil: string | Array<string>, timeout: number)

Member Summary

Private Members
private

_eventListeners: {emitter: !EventEmitter, eventName: (string|symbol), handler: (function(*))}[]

private
private
private
private
private
private
private

A Promise that resolves if the frame being navigated reached the expected lifecycle

private
private
private
private
private

A Promise that resolves if the frame being navigated navigated to a new page

private
private

A Promise that resolves if the frame navigated within the same document (History.pushState etc)

private
private

A Promise that resolves if the the watcher is terminated

private
private

A Promise that resolves if the frame being navigated did not navigate within the supplied timeout if any

Method Summary

Public Methods
public

Dispose of the LifecycleWatcher (i.e.

public
public
public
public
public
Private Methods
private

Checks the frame being navigated and all its child frames for the expected lifecycle(s)

private
private
private
private
private

_onRequest(request: Request)

private

_terminate(error: Error)

Public Constructors

public constructor(frameManager: FrameManager, frame: Frame, waitUntil: string | Array<string>, timeout: number) source

Params:

NameTypeAttributeDescription
frameManager FrameManager
  • nullable: false

The frame manager for the page containing the frame being navigated

frame Frame
  • nullable: false

The frame being navigated

waitUntil string | Array<string>

The lifecycle(s) desired to be obtained by the frame and its children

timeout number
  • optional

An optional timeout value

Private Members

private _eventListeners: {emitter: !EventEmitter, eventName: (string|symbol), handler: (function(*))}[] source

private _expectedLifecycle: Array<string> source

private _frame: Frame source

private _frameManager: FrameManager source

private _hasSameDocumentNavigation: boolean source

private _initialLoaderId: string source

private _lifecycleCallback: * source

private _lifecyclePromise: Promise<*> source

A Promise that resolves if the frame being navigated reached the expected lifecycle

private _maximumTimer: * source

private _navigationRequest: Request source

private _networkManager: NetworkManager source

private _newDocumentNavigationCompleteCallback: * source

private _newDocumentNavigationPromise: Promise<*> source

A Promise that resolves if the frame being navigated navigated to a new page

private _sameDocumentNavigationCompleteCallback: * source

private _sameDocumentNavigationPromise: Promise<*> source

A Promise that resolves if the frame navigated within the same document (History.pushState etc)

private _terminationCallback: * source

private _terminationPromise: Promise<*> source

A Promise that resolves if the the watcher is terminated

private _timeout: number source

private _timeoutPromise: Promise<*> source

A Promise that resolves if the frame being navigated did not navigate within the supplied timeout if any

Public Methods

public dispose() source

Dispose of the LifecycleWatcher (i.e. clean up)

public lifecyclePromise(): Promise<*> source

Return:

Promise<*>

public navigationResponse(): Response source

Return:

Response (nullable: true)

public newDocumentNavigationPromise(): Promise<Error|undefined> source

public sameDocumentNavigationPromise(): Promise<Error|undefined> source

public timeoutOrTerminationPromise(): Promise<Error|undefined> source

Private Methods

private _checkLifecycleComplete() source

Checks the frame being navigated and all its child frames for the expected lifecycle(s)

private _createTimeoutPromise(): Promise<Error|undefined> source

private _navigatedWithinDocument(frame: Frame) source

Params:

NameTypeAttributeDescription
frame Frame
  • nullable: false

private _onConnectionDisconnected() source

private _onFrameDetached(frame: Frame) source

Params:

NameTypeAttributeDescription
frame Frame
  • nullable: false

private _onRequest(request: Request) source

Params:

NameTypeAttributeDescription
request Request
  • nullable: false

private _terminate(error: Error) source

Params:

NameTypeAttributeDescription
error Error
  • nullable: false