Re: [w3c/ServiceWorker] SharedWorker script interception after redirects (#1289)

Interesting, yes I think you're right. https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-script doesn't mention anything about redirect mode.

Stepping back, there are two issues:
1) Request interception and redirects: does each redirect get intercepted by the service worker matching the redirect URL? Or does only the initial request get intercepted?

2) Controller and redirects: does the resulting service worker client get controlled by the service worker matching the final response URL or the initial request URL?   

If I'm understanding correctly, it looks like the current spec is saying:
1) Only the initial request gets intercepted (since the HTML spec uses redirect mode 'follow').
2) The initial request URL is used for matching to a controller (since the SW spec uses "creation URL", which is set before fetching).

Chrome's behavior is:
1) Each redirect gets intercepted.
2) The final response URL is used for matching to a controller.

Firefox's behavior is:
1) Only the initial request gets intercepted.
2) The final response URL is used for matching to a controller.

Regarding desirable behavior, it seems intuitive if non-subresource requests like new SharedWorker()  have the same interception and matching behavior as navigation requests. Particularly, it seems a bit weird if a service worker doesn't get a fetch event for the request that results in its controlled client.

To change the spec to make worker scripts behave like navigations, would seem to require:
1) Give worker scripts a manual redirect mode. This way redirects are intercepted.
2) Set the worker's creation URL after fetching is complete (as wanderview proposed above). This way the controller matches on the final response URL. 

But I'm not sure what the implications would be of doing this, e.g., giving worker scripts a manual redirect mode. cc @annevk @domenic : do you know if this is a deliberate difference between navigations and other non-subresource requests (i.e., redirects are intercepted by service worker for navigations but not for worker scripts)?

-- 
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/1289#issuecomment-374611147

Received on Tuesday, 20 March 2018 14:10:13 UTC