Stale hover state after keyboard tab switch (Ctrl+Tab)

#548314090 Filed 2026-08-18 Accepted / P4 / S3 CL 8309055

What this tests

On macOS, when a tab is switched away via keyboard shortcut (Ctrl+Tab / Cmd+Opt+Arrow), the page does not receive a mouse-leave event. An element that was hovered keeps its :hover styling when you later click the tab to reactivate it.

The fix (CL 8309055) clears hover/active state in Document::DidChangeVisibilityState() when the page becomes hidden.

Repro steps

  1. Open this page in tab A and any other page in tab B.
  2. Hover one of the boxes below with the mouse. It turns amber and says HOVERED.
  3. Without moving the mouse, press Ctrl+Tab to switch to tab B.
  4. Move the mouse away (e.g. onto the tab strip), then click tab A to come back.

Broken the box is still amber / HOVERED even though the mouse is elsewhere.

Fixed the box is back to not hovered.

Hover targets

Box A
Box B
Box C
Hover a box, Ctrl+Tab away, then click this tab again. The check runs automatically on return.

Event log

How the check works

Hover is tracked with mouseenter/mouseleave listeners, not by querying :hover at hidden-time. The fix clears hover state before dispatching visibilitychange, so on a patched build matches(':hover') is already false inside the hidden handler; mouse-event tracking is immune to that ordering.

After the tab becomes visible again, each previously hovered box is checked two ways:

FAIL internal still hovered (unpatched behavior). MIXED internal cleared but style still applied (hover flag cleared without effective style invalidation - fix incomplete). PASS both cleared.

Note: if you switch back with Ctrl+Tab and the mouse happens to rest over a box, that box is legitimately hovered again -- use the tab-strip click from the repro steps for a clean result.