Home Reference Source
public class | since chrome-remote-interface-extra | source

WorkerManager

Extends:

eventemitter3~EventEmitter → WorkerManager

Combination manger that juggles both Web Workers and ServiceWorkers

See:

Constructor Summary

Public Constructor
public

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

Member Summary

Private Members
private
private
private
private
private
private
private
private

Method Summary

Public Methods
public

Disables receiving service worker events

public

Disables the monitoring of Worker creation and removal

public

Enables receiving service worker events

public

Enables the monitoring of Worker creation and removal

public

async makeServiceWorkerSkipWaiting(scopeURL: string): Promise<void>

Makes the ServiceWorker(s) under the supplied scope URL skip waiting

public

serviceWorker(registrationId: string): ServiceWorker

Retrieve the ServiceWorker associated with the supplied registration id

public
public

Returns all ServiceWorkers the manager knows about

public

async startServiceWorker(scopeURL: string): Promise<void>

Starts the ServiceWorker(s) under the supplied scope URL

public

async stopAllServiceWorker(): Promise<void>

public

async stopServiceWorker(versionId: string): Promise<void>

public

async swDeliverPushMessage(pushMessage: {origin: string, registrationId: string, data: string}): Promise<void>

Delivers a push message to the supplied origin from the ServiceWorker who's registrationId is the one supplied

public

async swDispatchSyncEvent(syncEvent: {origin: string, registrationId: string, tag: string, lastChance: boolean}): Promise<void>

Delivers a sync event to the supplied origin from the ServiceWorker who's registrationId is the one supplied

public

async swSetForceUpdateOnPageLoad(forceUpdateOnPageLoad: boolean): Promise<void>

public

toJSON(): {serviceWorkers: Array<ServiceWorker>}

public

async unregisterServiceWorker(scopeURL: string): Promise<void>

Un-registers the ServiceWorker(s) registered under the supplied scope URL

public

Updates the ServiceWorker(s) registrations under the supplied scope URL

public
public
Private Methods
private

_addWorkerConsoleMessage(event: Object, jsHandleFactory: function(arg: Object): JSHandle)

private

Clears the known service workers.

private
private
private
private

_handleException(exceptionDetails: Object)

private
private
private
private
private
private
private

_removeServiceWorker(registrationId: *)

private
private

Public Constructors

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

Params:

NameTypeAttributeDescription
client Chrome | CRIConnection | CDPSession | Object

Private Members

private _autoAttachEnabled: boolean source

private _client: Chrome | CRIConnection | CDPSession | Object source

private _forceUpdateState: * source

private _serviceWorkerTargets: Map<string, string> source

private _serviceWorkers: Map<string, ServiceWorker> source

private _serviceWorkersEnabled: boolean source

private _workers: Map<string, Worker> source

private _workersEnabled: boolean source

Public Methods

public async disableServiceWorkerDomain(): Promise<void> source

Disables receiving service worker events

Return:

Promise<void>

See:

public async disableWorkerMonitoring(): Promise<void> source

Disables the monitoring of Worker creation and removal

Return:

Promise<void>

public async enableServiceWorkerDomain(): Promise<void> source

Enables receiving service worker events

Return:

Promise<void>

See:

public async enableWorkerMonitoring(): Promise<void> source

Enables the monitoring of Worker creation and removal

Return:

Promise<void>

public async makeServiceWorkerSkipWaiting(scopeURL: string): Promise<void> source

Makes the ServiceWorker(s) under the supplied scope URL skip waiting

Params:

NameTypeAttributeDescription
scopeURL string

The scope URL for the ServiceWorker(s)

Return:

Promise<void>

See:

public serviceWorker(registrationId: string): ServiceWorker source

Retrieve the ServiceWorker associated with the supplied registration id

Params:

NameTypeAttributeDescription
registrationId string

The registration id of the desired ServiceWorker

Return:

ServiceWorker

public serviceWorkerDomainEnabled(): boolean source

Return:

boolean

public serviceWorkers(): Array<ServiceWorker> source

Returns all ServiceWorkers the manager knows about

Return:

Array<ServiceWorker>

public async startServiceWorker(scopeURL: string): Promise<void> source

Starts the ServiceWorker(s) under the supplied scope URL

Params:

NameTypeAttributeDescription
scopeURL string

The scope URL for the ServiceWorker(s) to be started

Return:

Promise<void>

See:

public async stopServiceWorker(versionId: string): Promise<void> source

Params:

NameTypeAttributeDescription
versionId string

Return:

Promise<void>

See:

public async swDeliverPushMessage(pushMessage: {origin: string, registrationId: string, data: string}): Promise<void> source

Delivers a push message to the supplied origin from the ServiceWorker who's registrationId is the one supplied

Params:

NameTypeAttributeDescription
pushMessage {origin: string, registrationId: string, data: string}

Return:

Promise<void>

See:

public async swDispatchSyncEvent(syncEvent: {origin: string, registrationId: string, tag: string, lastChance: boolean}): Promise<void> source

Delivers a sync event to the supplied origin from the ServiceWorker who's registrationId is the one supplied

Params:

NameTypeAttributeDescription
syncEvent {origin: string, registrationId: string, tag: string, lastChance: boolean}

Return:

Promise<void>

See:

public async swSetForceUpdateOnPageLoad(forceUpdateOnPageLoad: boolean): Promise<void> source

Params:

NameTypeAttributeDescription
forceUpdateOnPageLoad boolean

Return:

Promise<void>

See:

public toJSON(): {serviceWorkers: Array<ServiceWorker>} source

Return:

{serviceWorkers: Array<ServiceWorker>}

public async unregisterServiceWorker(scopeURL: string): Promise<void> source

Un-registers the ServiceWorker(s) registered under the supplied scope URL

Params:

NameTypeAttributeDescription
scopeURL string

The scope URL to unregister the ServiceWorker(s) for

Return:

Promise<void>

See:

public async updateServiceWorkerRegistration(scopeURL: string): Promise<void> source

Updates the ServiceWorker(s) registrations under the supplied scope URL

Params:

NameTypeAttributeDescription
scopeURL string

The scope URL for the ServiceWorker(s) to update their registrations

Return:

Promise<void>

See:

public workerMonitoringEnabled(): boolean source

Return:

boolean

public workers(): Array<Worker> source

Return:

Array<Worker>

Private Methods

private _addWorkerConsoleMessage(event: Object, jsHandleFactory: function(arg: Object): JSHandle) source

Params:

NameTypeAttributeDescription
event Object
jsHandleFactory function(arg: Object): JSHandle

private _clearKnownWorkers() source

Clears the known service workers. Page uses this method to get rid of them when navigating

private async _disableAutoAttach() source

private async _enableAutoAttach() source

private _ensureServiceWorkerSwapped(swappedSW: ServiceWorker, prevRegId: string) source

Params:

NameTypeAttributeDescription
swappedSW ServiceWorker
prevRegId string

private _handleException(exceptionDetails: Object) source

Params:

NameTypeAttributeDescription
exceptionDetails Object
  • nullable: false

private _isActiveServiceWorkerTarget(targetId: *): boolean source

Params:

NameTypeAttributeDescription
targetId *

Return:

boolean

private _onAttachedToTarget(event: *) source

Params:

NameTypeAttributeDescription
event *

private _onDetachedFromTarget(event: *) source

Params:

NameTypeAttributeDescription
event *

private _onWorkerErrorReported(errorMessage: CDPServiceWorkerErrorMessage) source

Params:

NameTypeAttributeDescription
errorMessage CDPServiceWorkerErrorMessage

private _onWorkerRegistrationUpdated(event: {registrations: Array<CDPServiceWorkerRegistration>}) source

Params:

NameTypeAttributeDescription
event {registrations: Array<CDPServiceWorkerRegistration>}

private _onWorkerVersionUpdated(event: {versions: Array<CDPServiceWorkerVersion>}) source

Params:

NameTypeAttributeDescription
event {versions: Array<CDPServiceWorkerVersion>}

private _removeServiceWorker(registrationId: *) source

Params:

NameTypeAttributeDescription
registrationId *

private _updateSW(updateHow: CDPServiceWorkerRegistration | CDPServiceWorkerVersion, isVersion: boolean) source

Params:

NameTypeAttributeDescription
updateHow CDPServiceWorkerRegistration | CDPServiceWorkerVersion
isVersion boolean
  • optional
  • default: false

private _workerSession(targetId: string): CDPSession source

Params:

NameTypeAttributeDescription
targetId string

Return:

CDPSession (nullable: true)