Skip to content

Commit

Permalink
Fix detecting "page load" after internal navigation
Browse files Browse the repository at this point in the history
If you click (or do) anything that causes the URL to change
either with e.g. history.replaceState or by clicking a link
to #wherever on the same doc, Chrome sends:
 - Page.frameStartedLoading
 - Page.navigatedWithinDocument
 - Page.frameStoppedLoading

But obviously there is no new Page.loadEventFired. So, for
the moment we need to treat Page.navigatedWithinDocument
as being the equivalent to loadEventFired.

It may actually be better to use Page.frameStoppedLoading
if we always get that, then there's a simple startedLoading
 / stoppedLoading pair?
  • Loading branch information
acoulton committed Sep 15, 2022
1 parent 2a1d451 commit 5cda60d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/ChromePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,22 @@ protected function processResponse(array $data): void
}
break;
case 'Page.navigatedWithinDocument':
// Can't see this doing anything if we're only starting the pageload on the networky events
// On a same-page navigation in at least some instances - e.g. in the flickr photoset page where it
// uses history.replaceState - you get:
// - potentially some animationy stuff
// - Page.frameStartedLoading
// - Page.navigatedWithinDocument
// - Page.frameStoppedLoading

// But no Page.loadEventFired.
// At the moment I'm marking page_ready = False on Page.frameStartedLoading, so need to clear it
// here. If I used Page.frameStoppedLoading instead of Page.loadEventFired this would maybe not
// be necessary.
// This is another example where we want click-> to wait a bit to see if something happens, but
// it can't just wait for readyState to change because that may not change (it doesn't in this case).
if ($data['params']['frameId'] === $this->window_id) {
$this->setPageReady(TRUE, $data['method']);
}
break;

case 'Page.loadEventFired':
Expand Down

0 comments on commit 5cda60d

Please sign in to comment.