Restore focus on non-BFCache back navigation

#40656738 Open History navigation / focus restore

Summary

Non-BFCache focus restore

This sampler demonstrates issue 40656738: when a focused link is clicked, navigates to a second page, and then the browser goes back without BFCache, the original page should restore document.activeElement to the clicked link.

Expected behavior: after back navigation, the focused link with id target is active again.

On an unpatched browser this sampler is expected to report FAIL with activeElementAfterRestore: "". That means the bug was reproduced successfully.

How to use

  1. Open the sampler page.
  2. Click Run sampler.
  3. The page focuses the first link, clicks it, navigates to step B, then returns with history.back().
  4. Read the recorded result on the restored page.

Sampler

Open sampler

Fix direction

Current approach

The investigated fix persists a minimal focused-element identity in session history for non-BFCache restores and re-applies focus when the document is recreated. This static sampler cannot apply that engine fix, so stock browsers will normally continue to show the failing result.

Notes

Related issue

This is separate from 40199280, which is a BFCache-specific focus preservation issue.