ServiceWorkerContainer
The ServiceWorkerContainer interface of the ServiceWorker API exposes the ServiceWorkerContainer. register(scriptURL, scope[, base]) method used to register service workers, and the ServiceWorkerContainer. controller property used to determine whether or not the current page is actively controlled.
Value members
Concrete methods
The ServiceWorkerContainer.controller read-only property of the ServiceWorkerContainer interface returns the ServiceWorker whose state is activated (the same object returned by ServiceWorkerRegistration.active). This property returns null if the request is a force refresh (Shift + refresh) or if there is no active worker.
The ServiceWorkerContainer.controller read-only property of the ServiceWorkerContainer interface returns the ServiceWorker whose state is activated (the same object returned by ServiceWorkerRegistration.active). This property returns null if the request is a force refresh (Shift + refresh) or if there is no active worker.
Gets a ServiceWorkerRegistration object whose scope URL matches the document URL. If the method can't return a ServiceWorkerRegistration, it returns a Promise.
Gets a ServiceWorkerRegistration object whose scope URL matches the document URL. If the method can't return a ServiceWorkerRegistration, it returns a Promise.
The getRegistrations() method of the ServiceWorkerContainer interface returns all ServiceWorkerRegistrations associated with a ServiceWorkerContainer in an array. If the method can't return ServiceWorkerRegistrations, it returns a Promise.
The getRegistrations() method of the ServiceWorkerContainer interface returns all ServiceWorkerRegistrations associated with a ServiceWorkerContainer in an array. If the method can't return ServiceWorkerRegistrations, it returns a Promise.
The ready read-only property of the ServiceWorkerContainer interface defines whether a service worker is ready to control a page or not. It returns a Promise that will never reject, which resolves to a ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker.
The ready read-only property of the ServiceWorkerContainer interface defines whether a service worker is ready to control a page or not. It returns a Promise that will never reject, which resolves to a ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker.
Creates or updates a ServiceWorkerRegistration for the given scriptURL. If successful, a service worker registration ties the provided script URL to a scope, which is subsequently used for navigation matching. If the method can't return a ServiceWorkerRegistration, it returns a Promise. You can call this method unconditionally from the controlled page, i.e., you don't need to first check whether there's an active registration.
Creates or updates a ServiceWorkerRegistration for the given scriptURL. If successful, a service worker registration ties the provided script URL to a scope, which is subsequently used for navigation matching. If the method can't return a ServiceWorkerRegistration, it returns a Promise. You can call this method unconditionally from the controlled page, i.e., you don't need to first check whether there's an active registration.
Inherited methods
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).
This implementation accepts a settings object of type EventListenerOptions.
- Inherited from:
- EventTarget
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).
- Inherited from:
- EventTarget
Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().
Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().
- Inherited from:
- EventTarget
Removes the event listener previously registered with EventTarget.addEventListener.
Removes the event listener previously registered with EventTarget.addEventListener.
This implementation accepts a settings object of type EventListenerOptions.
- Inherited from:
- EventTarget
Removes the event listener previously registered with EventTarget.addEventListener.
Removes the event listener previously registered with EventTarget.addEventListener.
- Inherited from:
- EventTarget
Concrete fields
The oncontrollerchange property of the ServiceWorkerContainer interface is an event handler fired whenever a controllerchange event occurs — when the document's associated ServiceWorkerRegistratin acquires a new ServiceWorkerRegistration.active worker.
The oncontrollerchange property of the ServiceWorkerContainer interface is an event handler fired whenever a controllerchange event occurs — when the document's associated ServiceWorkerRegistratin acquires a new ServiceWorkerRegistration.active worker.
The onmessage property of the ServiceWorkerContainer interface is an event handler fired whenever a message event occurs — when incoming messages are received to the ServiceWorkerContainer object (e.g., via a MessagePort.postMessage() call).
The onmessage property of the ServiceWorkerContainer interface is an event handler fired whenever a message event occurs — when incoming messages are received to the ServiceWorkerContainer object (e.g., via a MessagePort.postMessage() call).