v135 · service worker
Service Worker client URL ignore history.pushState changes
Modify the service worker Client.url property to ignore document URL changes via history.pushState() and other similar history APIs. The Client.url property is intended to be the creation URL of the HTML document which ignores such changes.
concepts
-
SW client URL
Live probe: push a new state from the page and check what the SW now reports.
-
Why your SPA route used to confuse clients.openWindow
The motivating SPA scenario:
clients.openWindowused to focus a stale tab matching a pushState URL. The fix makesClient.urlstay at the document's creation URL. -
Route mismatch detective
Buttons trigger pushState, hash changes, and reload. The two panels show
document.location.hrefand the simulatedClient.url— with green / red highlighting whenever they diverge. -
SW scope audit
Configure a SW scope and a list of pushState routes. The audit shows what
Client.urlthe SW sees in Chrome 135 (creation URL) vs pre-135 (latest pushState URL), and which routes would previously have caused scope-mismatch bugs inclients.matchAll().
why it shipped
Match the spec described behavior implemented by Firefox and Safari to improve compatibility.