Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if a worker script redirects from an in-scope URL to an out-of-scope URL, what is the worker's final controller? #1239

Closed
wanderview opened this issue Dec 1, 2017 · 2 comments

Comments

@wanderview
Copy link
Member

Consider this situation:

// 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?

@wanderview
Copy link
Member Author

Note, the same-origin redirect also means the reserved client is preserved across the redirect. So we don't get the active service worker cleared that way.

@wanderview
Copy link
Member Author

Superseded by #1289.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant