Description
The current ordering of events for visible in the unload process (that will be put into bfcache) is as follows:
beforeunload
pagehide
visibilitychange
And when coming out of bfcache there's just a single event:
pageshow
Assuming that bfcache-supporting browsers are going to also fire the freeze
and resume
events when pages go into and out of the bfcache, what should the order be?
My proposal would be this for the unload case:
beforeunload
pagehide
visibilitychange
freeze
And this for the resume case:
resume
pageshow
Having freeze
fire after visibilitychange
is consistent with our model that the FROZEN state follows the HIDDEN state.
NOTE: one catch here is that currently pagehide
fires before visibilitychange
in the unload flow, which isn't consistent with our state progression.
If we have to keep the current ordering of pagehide
and visibilitychange
for historical/compat reasons, then I think the above proposed ordering makes the most sense. On the other hand, if we can change the current ordering to better match our state progression, then I'd suggest this order:
beforeunload
visibilitychange
pagehide
freeze
And this for the resume case:
resume
pageshow