Created attachment 471715 [details] page lifecycle events test Summary: - Navigation via window.location.replace seems to not emit any page lifecycle events (pagehide, unload, visibilitychange) on iOS Safari - This behavior seems inconsistent with MacOS Safari and other browsers, and other navigation methods (window.location.assign, window.location.reload, window.location.href=, clicking links). Steps to reproduce: - Open attached test html in a new tab on iOS Safari. - Click the window.location.replace button. - Close tab (don't use the back button). - Open this page again in a new tab. - Check the event table to see the events emitted from the previous page load. Expected: - There should be a pagehide event after the window.location.replace. - There should be a visibilitychange event after the window.location.replace, and document.visibilityState === "hidden". - There should be a unload event after the window.location.replace. Observed: - There is no pagehide event after the window.location.replace. - There is no visibilitychange event after the window.location.replace, and no change to document.visiblityState. - There is no unload event after the window.location.replace. Further Notes: - Testing the same behavior in Safari (Desktop) emits pagehide+visibilitychange+unload. - Testing the same behavior in Chrome (Desktop & Mobile) emits beforeunload+pagehide+visibilitychange+unload. - Testing the same behavior in Firefox (Desktop) triggers beforeunload+pagehide+visibilitychange+blur+unload. - Testing other navigation methods in Safari (iPhone) (window.location.assign, window.location.reload, window.location.href=, clicking links) emits pagehide+visibilitychange+unload.
<rdar://problem/130238744>
macOS Safari STP 176 Page Load Page Event Sequence Type Visibility State Date 2 (current) 5 event: blur visible 2024-06-24T08:01:47.979Z 2 (current) 4 event: focus visible 2024-06-24T08:01:26.965Z 2 (current) 3 event: focus visible 2024-06-24T08:01:26.964Z 2 (current) 2 event: pageshow visible 2024-06-24T08:01:26.909Z 2 (current) 1 event: load visible 2024-06-24T08:01:26.909Z 1 (previous) 8 event: unload hidden 2024-06-24T08:01:14.209Z 1 (previous) 7 event: visibilitychange hidden 2024-06-24T08:01:14.208Z 1 (previous) 6 event: pagehide visible 2024-06-24T08:01:14.208Z 1 (previous) 5 triggered: window.location.replace visible 2024-06-24T08:01:13.882Z 1 (previous) 4 event: focus visible 2024-06-24T08:01:11.055Z 1 (previous) 3 event: focus visible 2024-06-24T08:01:11.055Z 1 (previous) 2 event: pageshow visible 2024-06-24T08:01:10.985Z 1 (previous) 1 event: load visible 2024-06-24T08:01:10.984Z macOS Firefox Nightly 129.0a1 (2024-06-23) (64-bit) Page Load Page Event Sequence Type Visibility State Date 2 (current) 5 event: focus visible 2024-06-24T08:06:27.442Z 2 (current) 4 event: blur visible 2024-06-24T08:03:59.339Z 2 (current) 3 event: focus visible 2024-06-24T08:03:24.931Z 2 (current) 2 event: pageshow visible 2024-06-24T08:03:24.929Z 2 (current) 1 event: load visible 2024-06-24T08:03:24.928Z 1 (previous) 9 event: unload hidden 2024-06-24T08:03:14.588Z 1 (previous) 8 event: blur hidden 2024-06-24T08:03:14.588Z 1 (previous) 7 event: visibilitychange hidden 2024-06-24T08:03:14.579Z 1 (previous) 5 event: beforeunload visible 2024-06-24T08:03:14.389Z 1 (previous) 4 triggered: window.location.replace visible 2024-06-24T08:03:14.388Z 1 (previous) 3 event: focus visible 2024-06-24T08:03:11.812Z 1 (previous) 2 event: pageshow visible 2024-06-24T08:03:11.811Z 1 (previous) 1 event: load visible 2024-06-24T08:03:11.811Z macOS Chrome Canary Version 128.0.6548.0 (Official Build) canary (arm64) Page Load Page Event Sequence Type Visibility State Date 2 (current) 8 event: focus visible 2024-06-24T08:05:27.084Z 2 (current) 7 event: visibilitychange visible 2024-06-24T08:05:27.082Z 2 (current) 6 event: visibilitychange hidden 2024-06-24T08:05:13.388Z 2 (current) 5 event: blur visible 2024-06-24T08:05:13.386Z 2 (current) 4 event: focus visible 2024-06-24T08:05:10.371Z 2 (current) 3 event: blur visible 2024-06-24T08:02:41.585Z 2 (current) 2 event: pageshow visible 2024-06-24T08:02:14.373Z 2 (current) 1 event: load visible 2024-06-24T08:02:14.373Z 1 (previous) 7 event: unload hidden 2024-06-24T08:02:09.141Z 1 (previous) 6 event: visibilitychange hidden 2024-06-24T08:02:09.141Z 1 (previous) 5 event: pagehide visible 2024-06-24T08:02:09.140Z 1 (previous) 4 event: beforeunload visible 2024-06-24T08:02:08.671Z 1 (previous) 3 triggered: window.location.replace visible 2024-06-24T08:02:08.670Z 1 (previous) 2 event: pageshow visible 2024-06-24T08:02:05.296Z 1 (previous) 1 event: load visible 2024-06-24T08:02:05.295Z iOS Safari 18 Page Load Page Event Sequence Type Visibility State Date 2 (current) 6 event: focus visible 2024-06-24T08:09:29.836Z 2 (current) 5 event: blur visible 2024-06-24T08:09:19.573Z 2 (current) 4 event: focus visible 2024-06-24T08:09:19.558Z 2 (current) 3 event: focus visible 2024-06-24T08:09:19.558Z 2 (current) 2 event: pageshow visible 2024-06-24T08:09:19.553Z 2 (current) 1 event: load visible 2024-06-24T08:09:19.553Z 1 (previous) 5 triggered: window.location.replace visible 2024-06-24T08:08:14.919Z 1 (previous) 4 event: focus visible 2024-06-24T08:08:04.975Z 1 (previous) 3 event: focus visible 2024-06-24T08:08:04.975Z 1 (previous) 2 event: pageshow visible 2024-06-24T08:08:04.959Z 1 (previous) 1 event: load visible 2024-06-24T08:08:04.959Z Android 14 Firefox Nightly 128.0a1 Page Load Page Event Sequence Type Visibility State Date 2 (current) 3 event: pageshow visible 2024-06-24T08:14:48.034Z 2 (current) 2 event: load visible 2024-06-24T08:14:48.031Z 2 (current) 1 event: focus visible 2024-06-24T08:14:48.020Z 1 (previous) 7 event: visibilitychange hidden 2024-06-24T08:14:32.916Z 1 (previous) 6 event: pagehide visible 2024-06-24T08:14:32.914Z 1 (previous) 5 event: beforeunload visible 2024-06-24T08:14:32.696Z 1 (previous) 4 triggered: window.location.replace visible 2024-06-24T08:14:32.691Z 1 (previous) 3 event: pageshow visible 2024-06-24T08:14:30.113Z 1 (previous) 2 event: load visible 2024-06-24T08:14:30.111Z 1 (previous) 1 event: focus visible 2024-06-24T08:14:30.095Z
To make it more visible and putting them on a horizontal scale. Event Start = window.location.replace ``` macOS STP 176 start → pagehide............... → visibilitychange ...... → unload → load → pageshow ...... → focus macOS Ffx 129 start → beforeunload........... → visibilitychange → blur → unload → load → pageshow ...... → focus macOS Chr 128 start → beforeunload → pagehide → visibilitychange ...... → unload → load → pageshow → blur → focus iOS Sfr 18 start ............................................................ → load → pageshow ...... → focus Android Ffx 128 start → beforeunload → pagehide → visibilitychange ...... → unload → load → pageshow → blur → focus ```