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
{{ message }}
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
On desktop Safari, when closing a tab by clicking the (X) on the tab UI itself, no visibilitychange or pagehide event is dispatched, so the page becomes terminated but the reported state never transitions away from active.
In order to at least provide a guarantee of hidden, we should listen for the beforeunload event and report a change to hidden if no event handlers set a returnValue or call preventDefault().
The following code achieves this:
addEventListener('beforeunload',(evt)=>{setTimeout(()=>{if(!(evt.defaultPrevented||evt.returnValue)){// The state is now going to either FROZEN or TERMINATED.}},0);});
On desktop Safari, when closing a tab by clicking the (X) on the tab UI itself, no
visibilitychange
orpagehide
event is dispatched, so the page becomes terminated but the reported state never transitions away from active.In order to at least provide a guarantee of hidden, we should listen for the
beforeunload
event and report a change to hidden if no event handlers set areturnValue
or callpreventDefault()
.The following code achieves this:
But since adding an unconditional
beforeunloaded
handler will break the page navigation cache in Firefox, we should only add this logic in Safari.The text was updated successfully, but these errors were encountered: