demo · v135

srcdoc iframe is a real Service Worker client

Chrome 135 makes srcdoc documents inherit their parent page's Service Worker controller. Register the scoped worker, mount a normal same-origin iframe and an inline srcdoc iframe, then ask the worker for the measured clients.matchAll() list and broadcast a worker message into both frames.

Measured client tree

Service Worker: checking parent controller: checking srcdoc controller: not mounted

iframe with src=

iframe with srcdoc=

clients.matchAll()

  • Register the worker, mount frames, then ask for clients.

SW-to-frame postMessage

  • No worker broadcast has run yet.

event log

    the change

    self.addEventListener("message", (event) => { if (event.data.type === "list-clients") { const clients = await self.clients.matchAll({ includeUncontrolled: true, type: "window" }); event.source.postMessage(clients.map((client) => ({ id: client.id, type: client.type, url: client.url }))); } }); // Before Chrome 135: srcdoc documents were skipped and the worker could not // message them. Chrome 135+: srcdoc documents inherit the parent's controller, // count as Service Worker clients, and receive worker postMessage events.

    see also