navigator.userAgent in service workers does not reflect customUserAgent set by client.
Created attachment 357857 [details] API test
If you fix this, can you fix navigator.platform simultaneously?
Created attachment 357971 [details] Patch
I have some worries about trying to reuse a service worker with different user agents. Here are some suggestions if we want to go down that path. Instead of tieing the user agent with fetch, I would pass it as part of registering a service worker client (see DocumentLoader::registerTemporaryServiceWorkerClient). Whenever a new service worker client is registered, it would update the user agent of the corresponding SWServerWorker. That should work well if the corresponding service worker is not running. For an existing running service worker, I am not sure what is the best option. A message to the service worker instance could be sent to notify the user agent has changed and update its value. Or we could notify the given client to bypass the service worker. I wonder whether adding some logging might help future debugging in breakage caused by user agent changes. To properly detect all these cases, we would need to persist the user agent in the database, probably overkill.
Created attachment 357994 [details] Patch
Comment on attachment 357994 [details] Patch I wonder whether we should release_log the case of a client registered to a running service worker with a different user agent. Maybe we could store the user agent in the SWServerWorker and when registering a client, check the user agent of the active worker if any? View in context: https://bugs.webkit.org/attachment.cgi?id=357994&action=review > Source/WebCore/workers/service/server/SWServer.cpp:743 > +void SWServer::registerServiceWorkerClient(ClientOrigin&& clientOrigin, ServiceWorkerClientData&& data, const Optional<ServiceWorkerRegistrationIdentifier>& controllingServiceWorkerRegistrationIdentifier, const String& userAgent) String&& > Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp:138 > +void WebSWContextManagerConnection::installServiceWorker(const ServiceWorkerContextData& data, SessionID sessionID, const String& userAgent) String&&
Created attachment 358012 [details] Patch
Comment on attachment 358012 [details] Patch Clearing flags on attachment: 358012 Committed r239534: <https://trac.webkit.org/changeset/239534>
All reviewed patches have been landed. Closing bug.
<rdar://problem/46914755>