-
Notifications
You must be signed in to change notification settings - Fork 312
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
Add an API to take over uncontrolled pages (or pages controlled by another service worker) #586
Comments
We've got feedback from web developers that this ability would be useful. Was there any further discussion elsewhere? Regarding step 1. did you have time to think about it? Rejecting feels like the most malleable option. |
Specified |
Thanks! On top of rejecting for non-active SW, let me note that you opted for returning undefined cc/ @jakearchibald @slightlyoff in case there has been any discussion on those 2 aspects. |
Tracked via http://crbug.com/450106 for Blink |
There's a question raised by @michael-nordman in Blink .claim() impl code review: Should the step |
What's the alternative?
Can you give me a situation that would produce a different result? If the returned registration is unequal to the calling SW's registration, it'll be discarded in the next step. If the returned registration is equal to the calling SW's registration, but there's no active worker, wouldn't we have already failed in step 1? Or, is the issue that states may have changed between step 1 and 3.1.3? We should probably ensure that the calling worker is still active once we get to 3.1.3, and reject if it isn't. |
The situation happens when a registration which only has a installing worker is a longer matched registration than the calling SW's registration. The calling SW will not claim in this situation. Currently in Blink impl, navigation fetch will choose the longest matched registration which has a active/waiting worker(seems different from sepc [[Handle Fetch]] 12.2 & 12.3, if the longest matched registration only has a installing worker it will not be used). Not sure whether the .claim() should behave the same? |
Right. The returned registrations without an active worker are ignored in step 3.1.2.
Getting to 3.1.3 already ensures the calling service worker is still an active worker. The only chance an active worker becomes not active would be to be terminated by the user agent, which effectively aborts the script currently running in the worker. |
This sounds a bit tricky, but to me the currently specified behavior seems more reasonable. The fact that a client is matched to a certain registration means the client will be controlled by the registration's worker when it becomes active. (rather than making it to use the shorter matched registration already effective.) |
@jakearchibald I might have misunderstood but I think the alternatives were mentioned in your first post:
and
|
Tracked in gecko here: |
@KenjiBaheux oh, yes, sorry! Yeah, I'm happy with rejecting if not active & resolving undefined. |
Closing. |
This used to be part of
installEvent.replace()
, but we've separated out the skip-waiting part intoself.skipWaiting
, but we still need the other part.Loosely, this would:
controllerchange
eventNeed to have a think about step 1. Also, maybe it should resolve true/false depending on if anything actually changed.
@slightlyoff suggested
clients.claim()
as a API name/location, which works for me.The text was updated successfully, but these errors were encountered: