-
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
what happens if an initial about:blank inherits a controller, but its navigation request does not match any service worker? #1232
Comments
To clarify, what I'm proposing would result in both iframe console.log() statements printing |
@bzbarsky might have an opinion, but in principle this seems fine. (We could also associate the controller with a document... though then in Firefox |
I would prefer not to associate the controller with the document. Even if we did that, though, we still have the issues with the no other operation going from controlled to uncontrolled state. Its pretty much the same problem as just clearing the controller from the global. |
I suspect not reusing the global in this case should be OK. The other option would be to try to change the spec model of iframe loading such that the case above creates a document with the |
FWIW, here is the gecko bug to handle this: https://bugzilla.mozilla.org/show_bug.cgi?id=1419620
The initial about:blank stuff is already rife with interop problems. I really don't think I have time to take this sort of thing on. I'd like to proceed with disabling global re-use when going from controlled to uncontrolled for now. Its a somewhat niche case and seems the safest thing to do for now. |
I feel a bit unconfortable about making the SW matching affect the decision of the client reuse. I think they are orthogonal, and adding that behavior sounds like we make another edge case behavior.
I think this makes sense complying with the "navigation matching always wins" rule.
Firing a Another edge case is when an iframe navigates to a non-initial about:blank document. I think this is a normal cross-origin navigation case where the non-initial about:blank document lands on a newly created client with a SW set to null. But when it navigates from an initial about:blank to a non-initial about:blank, I'm not sure whether we should keep the normal behavior or special case it to use the inherited controller. |
Typically non-initial about:blank would not be cross-origin. |
I thought the initial about:blank document has the same-origin to the parent (as inherited), and the non-initial about:blank document created during the navigate has an opaque origin? |
That is not the case: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/5550. |
So, we have a compat issue for this too. @annevk, what's your expectation about the desired spec behavior? It currently says an opaque origin if I read it correctly. |
Per the HTML Standard it takes the origin of the document responsible for navigating it. So this matches my expectations. |
Right now when I think avoiding about:blank replacement would be less breaking because its unlikely many modern sites using service workers are actually relying on this feature. Can we at least agree that:
How we get from (1) to (2) is up for discussion. For now, though, I'm testing for these. I'm need to do something to make this happen. I'm leaning towards doing the new global for now, but willing to change to a different system if we can decide on a clean way to do it. Note, if we can spec a way to cleanly clear the controller we could also enable the case of immediate unregister() if the site opts into it. |
I think you mean https://html.spec.whatwg.org/#origin:document-12? That considered, the non-initial about:blank document has the same origin as the initial about:blank. And thus the initial client is getting reused. Sounds good. (not a special case.)
Agreed.
Interesting idea. This option can be discussed in #1204 as well. |
Until we settle on something I'm going to be doing the minimal amount of code changes to meet the sanity conditions of:
In this lame first version in gecko the controller will appear to get reset, the page will share its global, and the Clients API will see a different client ID for the final loaded page. This approach is not what I recommend as a spec solution, but I didn't want to write significant code until we agreed on a direction. Its a corner case that is only really observable under some very precise conditions, so I don't think this will be a problem in the short term. |
Consider the following situation.
This situation normally requires replacing the about:blank document with the final document so the global is shared. You can see this with the
foo
global being passed through the load.We also agreed to inherit the service worker to initial about:blank windows, though.
When the final load is not under a controlled scope, but the initial about:blank was controlled via parent inheritance, what should the final
navigator.serviceWorker.controller
be?The natural answer is "clear the controller" if the final load does not make a scope. This is somewhat unprecedented, though. Nowhere else in the system do we allow a client to go from controlled to uncontrolled. There is no event or anything that this is happening. We would also have to deal with the page stashing the controller reference in another global property, etc.
I'd like to suggest that we require a new global to be created in this situation. If the initial about:blank is controlled, but the final load should not be controlled, then we don't do the document replacement. Instead we treat it similar to other cases (cross-origin, etc) where a new global is created.
@jakearchibald @jungkees @annevk What do you think?
The text was updated successfully, but these errors were encountered: