ladybird/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.idl
Andreas Kling 1835d739f5 LibWeb: Implement ServiceWorkerContainer getRegistrations
Expose ServiceWorkerContainer.getRegistrations() and implement the
Service Workers algorithm for collecting registrations matching the
current client's storage key. Resolve the promise with a frozen array
of ServiceWorkerRegistration objects, matching the Web-exposed return
type.

Use OrderedHashMap for the temporary LibWeb registration map, since the
Service Workers spec defines the registration map as ordered and
getRegistrations() exposes that iteration order.

Add text coverage for the no-registration case used by TradingView's
startup path. Without this method, the page threw while calling
navigator.serviceWorker.getRegistrations() and aborted before rendering
its chart.
2026-05-23 19:11:01 +02:00

24 lines
1 KiB
Text

// https://w3c.github.io/ServiceWorker/#serviceworkercontainer-interface
[SecureContext, Exposed=(Window,Worker)]
interface ServiceWorkerContainer : EventTarget {
[FIXME] readonly attribute ServiceWorker? controller;
readonly attribute Promise<ServiceWorkerRegistration> ready;
[NewObject, ImplementedAs=register_] Promise<ServiceWorkerRegistration> register((TrustedScriptURL or Utf16USVString) scriptURL, optional RegistrationOptions options = {});
[NewObject] Promise<(ServiceWorkerRegistration or undefined)> getRegistration(optional USVString clientURL = "");
[NewObject] Promise<FrozenArray<ServiceWorkerRegistration>> getRegistrations();
[FIXME] undefined startMessages();
// events
attribute EventHandler oncontrollerchange;
attribute EventHandler onmessage; // event.source of message events is ServiceWorker object
attribute EventHandler onmessageerror;
};
dictionary RegistrationOptions {
USVString scope;
WorkerType type = "classic";
ServiceWorkerUpdateViaCache updateViaCache = "imports";
};