client.url doesn't update on URL change
Categories
(Core :: DOM: Service Workers, defect)
Tracking
()
People
(Reporter: kolesker, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
Steps to reproduce:
Pre-requisite: Install a Service Worker.
- Open a tab of your web app
- Change the URL by history.push() or history.replace().
- From the Service Worker, run (I'm actually running it on 'notificationclick' event):
a. const clients = self.clients.matchAll({ type: 'window', includeUncontrolled: true });
Actual results:
You will find a client and "clients[0].url" will have a stale URL, which is the one when you landed on the tab, but it will never update when you navigate with history.push() or history.replace().
Expected results:
clients[0].url should update when navigating on the web app which is a Service Worker WindowClient. So client.url should be up to date when requesting self.clients.matchAll().
This is used to focus to existing tab or open a new one on notification click.
Updated•3 years ago
|
Comment 1•3 years ago
|
||
The client URL is specified to be the creation URL as defined in the HTML spec, noting that there are implementation consistency issues as documented at https://github.com/w3c/ServiceWorker/issues/1515 and that the general use-case you're describing for being able to reuse open tabs also has some discussion at https://github.com/w3c/ServiceWorker/issues/1475 as once can imagine there's also potentially relevant state that may not be fully represented in the URI.
Description
•