Bug 254283 - No fetching of service worker script loaded via importScripts when updateViaCache is none on update()
Summary: No fetching of service worker script loaded via importScripts when updateViaC...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: Safari 15
Hardware: Mac (Intel) Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-03-22 13:11 PDT by Dmytro
Modified: 2023-03-29 13:12 PDT (History)
3 users (show)

See Also:


Attachments
comparison of traffic between Safari and Chrome when doing update() (39.40 KB, image/png)
2023-03-22 13:11 PDT, Dmytro
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmytro 2023-03-22 13:11:31 PDT
Created attachment 465546 [details]
comparison of traffic between Safari and Chrome when doing update()

Suppose I have a simple web page that loads service worker with script
```
navigator.serviceWorker.register('sw.js', { scope: './', updateViaCache: 'none' });
```
and file sw.js contains this code
```
importScripts('https://dmytro-savochkin.github.io/debug-no-update-of-sw-in-safari/imported-sw.js');
```
and file imported-sw.js contains some additional code (seems to not matter what code exactly it is).


In this scenario after loading the page and waiting until service worker is installed I later call this code in the browser console (client console, not service worker console):
```
navigator.serviceWorker.ready.then(function(r) { r.update(); });
```
Then I can see in some traffic sniffer (I used Charles) that Safari only makes a single request to fetch sw.js file without making a request to fetch imported-sw.js file.
I was under the assumption that it should make two requests (one for sw.js, one for imported-sw.js) because I specified `updateViaCache: 'none'` during registration of service worker.
For example Chrome in this scenario makes two requests for these two files separately.


I uploaded the code here to check: https://dmytro-savochkin.github.io/debug-no-update-of-sw-in-safari/ 
Also I am attaching an image showing two merged screenshots from traffic sniffer for Safari and Chrome, the screenshots were made after I had called `navigator.serviceWorker.ready.then(function(r) { r.update(); });` five times in browser console.


To reproduce it I used Safari (15.6.1 (15613.3.9.1.16, 15613)), Chrome (111.0.5563.64 (Official Build) (x86_64)), and macOS (10.15.7).
(I haven't try it in newer Safari because it seems it's the newest available for my rather old Mac).
Comment 1 Radar WebKit Bug Importer 2023-03-29 13:12:19 PDT
<rdar://problem/107382589>