v135 ยท service worker

Fetch Intercept Demo

Chrome 135 makes a srcdoc iframe a Service Worker client that inherits its parent's controller. Register the scoped worker, run the three fetch probes, and compare the real x-sw-intercepted response header from the parent page, an iframe srcdoc, and a regular iframe src.

checking Service Worker API checking controller srcdoc fetch not run
The worker in this folder handles only ./sw-echo. A successful probe is not inferred from page script: the worker returns JSON and the x-sw-intercepted: true header, then records the source client it saw. In older browsers where srcdoc does not inherit the controller, the srcdoc fetch falls through to the network and the header is missing.

Live interception status

Parent document

Fetches ./sw-echo?source=parent from the controlled top-level page.

Not run yet.

iframe srcdoc

Fetches the same scoped URL from inline srcdoc content.

Not run yet.

iframe src

Uses a normal same-origin frame as the long-supported comparison case.

Not run yet.

Frame surfaces

srcdoc frame

Injected inline content checks navigator.serviceWorker.controller, fetches ./sw-echo, and posts the response headers back to this page.

src frame

A regular same-origin frame loads frame.html and runs the same fetch probe for comparison.

Worker intercept log

Register the worker, then run probes to collect intercepted requests.

Before vs after Chrome 135

Scenario Before Chrome 135 Chrome 135+
srcdoc iframe has a Service Worker controller No. The inline document was not a Service Worker client. Yes. It inherits the parent's controller.
fetch() from srcdoc reaches the worker No. Requests bypassed interception even though Resource Timing could report them. Yes. The worker sees the request and can respond, cache, or annotate it.
Regular same-origin iframe src Already controlled when in scope. Still controlled; used here as the comparison path.

Actual worker contract

self.addEventListener("fetch", (event) => { const url = new URL(event.request.url); if (!url.pathname.endsWith("/sw-echo")) return; event.respondWith(new Response(JSON.stringify({ intercepted: true, clientId: event.clientId, source: url.searchParams.get("source") }), { headers: { "content-type": "application/json; charset=utf-8", "x-sw-intercepted": "true", "cache-control": "no-store" } })); });

references