Bug 156356 - pageshow only fires the first time the back button is pressed
Summary: pageshow only fires the first time the back button is pressed
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 9
Hardware: Macintosh OS X 10.11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-04-07 13:09 PDT by Jeff Carlsen
Modified: 2019-02-06 09:18 PST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Carlsen 2016-04-07 13:09:18 PDT
Repro steps:

1. Go to page A
2. Click a link to page B
3. Click the back button (pageshow fires as expected)
4. Click a link to page B again (or any other page)
5. Click the back button (pageshow does not fire)

I discovered this because on the page I'm working on, I want to fetch some fresh data when they return to a page through the back button. I do this by listening for pageshow and checking the event.persisted property.
Comment 1 Alexey Proskuryakov 2016-04-07 18:27:18 PDT
Could you please provide a test case, or a link to a test page? I'm pretty sure that I tested this some time before, and it worked as expected, so it may be tricky to reproduce from a description alone.
Comment 2 Paulo Pereira 2016-09-16 04:30:21 PDT
Hi, I don't know if it's the exact same situation that is happening to Jeff Carlsen. But I am having the exact same behavior and I noticed this is also happening to "pagehide" event.

After some heavy debugging I figured out why this is happening and I created this test case example reproducing it: 

1. Go to http://paulovpereira.github.io/pageshow-webkit/ in an IOS device (I tested in ios 9 and 10)
2. Click in the navigate link
3. press back button
4. press forward button
5. keep going back and forth and check the events being triggered and logged in the body

The only difference between the pages is the existence of an iframe element and this is causing the event not to be fired. I hope this help figuring out how to fix the bug.
Comment 3 Georgii Ivankin 2016-11-14 14:35:23 PST
Second this. Just having 2 pages, both with 

window.addEventListener("pageshow", function(event) {
    console.info('pageshow. persisted: ' + event.persisted);
});

and navigating back-forward between them, is enough to reproduce. 

People has been reporting this on SO as well: http://stackoverflow.com/q/10106457/697388 
http://stackoverflow.com/q/33804292/697388
http://stackoverflow.com/questions/11979156/mobile-safari-back-button#comment44257718_12652160


Version 10.0.1 (12602.2.14.0.7) on MacOS Sierra.
Comment 4 Radar WebKit Bug Importer 2016-11-14 15:39:58 PST
<rdar://problem/29256489>
Comment 5 Lucas Forschler 2019-02-06 09:18:40 PST
Mass move bugs into the DOM component.