Preserve focus across BFCache

#40199280 Assigned P4 BFCache focus preservation sampler

Summary

Focus / BFCache

This sampler demonstrates the bug from issue 40199280: a page should keep its focused element when it enters and restores from the back-forward cache.

Expected behavior: document.activeElement stays on the same focused input before pagehide, during persisted pagehide, and after BFCache restore.

How to use

  1. Open the sampler page.
  2. Click "Run sampler".
  3. The page focuses an input, navigates away, then comes back with history.back().
  4. Read the recorded result on the restored page.

Sampler

Open sampler

What this CL changes

Preserve focus when entering the back-forward cache

Keep DOM focus intact on persisted pagehide so BFCache restores
preserve document.activeElement.

Notes

Related issue

Issue 40656738 is broader. This fix addresses the BFCache-specific focus loss overlap.