You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
changed the title [-][Shadow]: Figure out how session history should work for <iframe>s in shadow DOM (bugzilla: 27325)[/-][+]<iframe> and the History API[/+]on Feb 16, 2016
@smaug---- so I guess the problem is all the state exposed on History? If we did not expose that, would we have to expose it somehow on ShadowRoot? That each gets its own history? Presumably defaulting to no history at all for v1?
That kind of approach makes sense if you don't want to influence your container, but if you're a simple layout component that breaks expectations. Not sure if there's a good answer here. (We could make it depend on open vs closed...)
For open case I could possibly live with normal nested browsing context handling.
And for closed...no session history at all? I think that is the easiest for now. history.pushState/replaceState would do what? and what about history.go(x)? Throw?
I think throw is the only sane option, except perhaps for go(0)
How should the UI work? If shadow-iframe loads page X and then Y is loaded there, what should back button do? I guess nothing. That shouldn't be too bad. The shadow-iframe container component could manually call push/replaceState when needed, or shadow-iframe.src = "some new page"
Given the recent example, bug in Google Ads where their scripts caused the container page to go back, I'd prefer to never expose history state even in open case, but at least in closed case the state shouldn't be shared.
I'm not sure if throwing would be best by the way. It depends on what kind of things end up being embedded. If you throw a bunch of existing pages will likely break when embedded in this way.
but if the page called go(<not_zero>), it sure would expect something to happen, and if we wouldn't throw, the page would be broken in some other way.
Or pushState(). After that one would expect history.state to be the thing passed to pushState.
This is tricky, but I'm not sure we have any other good option to effectively disable all history API in shadow-iframes.
Hmmm, crazy idea. Could we actually hide History interface and .history propery in the browsing contexts under shadow-iframes?
iframes in a shadow tree does not have any affect on window.history. Thus, states of iframes in a shadow trees is not exposed to window.history. In other words, window.history is owned exclusively by a document tree.
go() should work as usual.
We might want to have another APIs, such as DocumentOrShadowRoot.history, if we want to make that work somehow later.
go() works in a history of a document tree. So I guess calling window.history.go() from a (developer of) shadow tree is a bad practice and does not bring a desired behavior in most cases.
To be a tad more precise, go() works in browsing context tree.
Not putting shadow dom iframe loads to session history, but having go() to work would lead to very surprising behavior. The browsing context in iframe could expect its page loads are in session history, but go() wouldn't actually know about those loads so it would always affect to some ancestor or sibling browsing context, never the browsing context in iframe.
This was discussed at TPAC 2016, and the approach we agreed to try out was going to be implemented in webkit, IIRC, to get more experience on this issue before spec'ing it.
Yeah, sorry, I haven't had a time to implement it. If Gecko or some other engine is interested in implementing the proposed approach, please move ahead & give us any feedback.
Yeah, I don't know what blink and webkit do now. Probably something somewhat random, which exposes the existence of shadow DOM to the outside world by using the same session history.
Did anyone take pictures of the plan we draw 2016?
It was separate session history for shadow iframes, since otherwise iframes in different shadow DOMs could end up affecting each others.
In the global navigation history, look for the history item where the navigated frame is the new (destination) state.
Rewrite the history items between the current history item and the item found in (1) so that the navigated frame's state is of the destination state.
Insert new history items where all the frames except the navigated frame are identical to that of the current history item, and the navigated frame is of states between the current frame's state and the destination state.
Navigate back to the new state created in (3) which matches the destination state.
Activity
annevk commentedon Feb 16, 2016
@rniwa what is Apple doing here?
[-][Shadow]: Figure out how session history should work for <iframe>s in shadow DOM (bugzilla: 27325)[/-][+]<iframe> and the History API[/+]annevk commentedon Feb 16, 2016
@smaug---- so I guess the problem is all the state exposed on
History? If we did not expose that, would we have to expose it somehow onShadowRoot? That each gets its own history? Presumably defaulting to no history at all for v1?That kind of approach makes sense if you don't want to influence your container, but if you're a simple layout component that breaks expectations. Not sure if there's a good answer here. (We could make it depend on open vs closed...)
smaug---- commentedon Feb 16, 2016
For open case I could possibly live with normal nested browsing context handling.
And for closed...no session history at all? I think that is the easiest for now. history.pushState/replaceState would do what? and what about history.go(x)? Throw?
I think throw is the only sane option, except perhaps for go(0)
How should the UI work? If shadow-iframe loads page X and then Y is loaded there, what should back button do? I guess nothing. That shouldn't be too bad. The shadow-iframe container component could manually call push/replaceState when needed, or shadow-iframe.src = "some new page"
Given the recent example, bug in Google Ads where their scripts caused the container page to go back, I'd prefer to never expose history state even in open case, but at least in closed case the state shouldn't be shared.
annevk commentedon Feb 17, 2016
I would be okay with blocking history from "shadow-iframe" by default. And then later figuring out if we want to make that work. @hayatoito @rniwa?
annevk commentedon Feb 17, 2016
I'm not sure if throwing would be best by the way. It depends on what kind of things end up being embedded. If you throw a bunch of existing pages will likely break when embedded in this way.
smaug---- commentedon Feb 17, 2016
but if the page called go(<not_zero>), it sure would expect something to happen, and if we wouldn't throw, the page would be broken in some other way.
Or pushState(). After that one would expect history.state to be the thing passed to pushState.
This is tricky, but I'm not sure we have any other good option to effectively disable all history API in shadow-iframes.
Hmmm, crazy idea. Could we actually hide History interface and .history propery in the browsing contexts under shadow-iframes?
hayatoito commentedon Mar 15, 2016
I am okay with this. Blocking history from "shadow-iframe" by default should be a safe option.
[Updated] On the second thought, go() should work, IMO. Let me think further.
hayatoito commentedon Mar 15, 2016
My opinion is:
We might want to have another APIs, such as DocumentOrShadowRoot.history, if we want to make that work somehow later.
annevk commentedon Mar 15, 2016
How can
go()work if such<iframe>s don't have an effect on the history?hayatoito commentedon Mar 15, 2016
go()works in a history of a document tree. So I guess calling window.history.go() from a (developer of) shadow tree is a bad practice and does not bring a desired behavior in most cases.smaug---- commentedon Mar 15, 2016
To be a tad more precise, go() works in browsing context tree.
Not putting shadow dom iframe loads to session history, but having go() to work would lead to very surprising behavior. The browsing context in iframe could expect its page loads are in session history, but go() wouldn't actually know about those loads so it would always affect to some ancestor or sibling browsing context, never the browsing context in iframe.
(go() is super error prone API to use :/ )
hayatoito commentedon Apr 1, 2016
Yeah, I think we can not have a perfect solution here. We have to compromise for window.history because it's globally accessible.
75 remaining items
rniwa commentedon Dec 3, 2017
We didn't have a time to discuss it at TPAC 2017.
smaug---- commentedon Dec 6, 2017
This was discussed at TPAC 2016, and the approach we agreed to try out was going to be implemented in webkit, IIRC, to get more experience on this issue before spec'ing it.
rniwa commentedon Dec 6, 2017
Yeah, sorry, I haven't had a time to implement it. If Gecko or some other engine is interested in implementing the proposed approach, please move ahead & give us any feedback.
annevk commentedon Dec 7, 2017
So do you disable
<iframe>altogether or are we going to run into compatibility issues?smaug---- commentedon Dec 7, 2017
Yeah, I don't know what blink and webkit do now. Probably something somewhat random, which exposes the existence of shadow DOM to the outside world by using the same session history.
Did anyone take pictures of the plan we draw 2016?
It was separate session history for shadow iframes, since otherwise iframes in different shadow DOMs could end up affecting each others.
smaug---- commentedon Dec 7, 2017
But, if there are two iframe in a shadow DOM, should those use the same session history?
rniwa commentedon Feb 19, 2018
We're willing to make backwards incompatible changes on our end to match the new spec if any.
rniwa commentedon Oct 25, 2018
Here's a strawman proposal:
marcoscaceres commentedon Oct 25, 2018
rniwa commentedon Oct 25, 2018
TPAC F2F Consensus / action item: Take back the above proposal and see each browser engine can implement it or not.
raegen commentedon Apr 6, 2023
Fix WICG#477, Fix WICG#391, Fix WICG#184. Clarify the current consensus