[w3c/ServiceWorker] if a worker script redirects from an in-scope URL to an out-of-scope URL, what is the worker's final controller? (#1239)

Consider this situation:

```javascript
// window code with SW controlling `/in/`
var w = new Worker('/in/worker.js');

// sw.js script
addEventListener('fetch' evt => {
  if (evt.request.url.includes('/in/worker.js')) {
    return;
  }
});

// Server redirects `/in/worker.js` to `/out/worker.js` which is not covered
```

What should the final worker's `self.navigator.serviceWorker.controller` be set to?

My read of the spec is that it should be set to the `/in/` scope service worker, even though the final script load is out-of-scope:

1. Handle Fetch step 12.6 sets the active service worker
2. HTTP Fetch step 4.2 sets the service-worker mode to `none` because worker scripts use `follow` redirect mode.

Also consider the case where it redirects to a scope controlled by a different service worker.  It would still be controlled by the first service worker.

This seems weird and unexpected to me.  Should we fix it?  Or am I just confused?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1239

Received on Friday, 1 December 2017 19:46:00 UTC