[fix]: support <frame> elements in XPath frame detection

Merged
SH
9mo ago
+59-6

Summary

  • IFRAME_STEP_RE regex only matched iframe steps, causing act() to fail on legacy <frameset> pages where observe() returns XPaths containing frame[N] (e.g. /html[1]/frameset[1]/frame[4]/html[1]/body[1]/...)
  • Changed regex from /^iframe(?:\[\d+])?$/i to /^i?frame(?:\[\d+])?$/i so both <iframe> and <frame> are recognized as frame boundaries
  • Consolidated the duplicate IFRAME_STEP_RE constant (was defined in both deepLocator.ts and focusSelectors.ts) into a single shared export

Test plan

  • Scratchpad repro confirms current regex misses frame, frame[4], FRAME — all pass with fix
  • 10 new unit tests added to snapshot-focus-selectors-utils.test.ts covering:
    • Regex matches iframe, iframe[N], frame, frame[N] (case-insensitive)
    • Regex rejects frameset, frameset[N], div, body, html
    • Full XPath parse + walk for frameset page XPaths detects correct frame boundary
    • Standard iframe XPaths still detected correctly
    • frameset is not false-positive detected as a frame boundary
  • All 15 tests pass, build + typecheck pass

šŸ¤– Generated with Claude Code


Summary by cubic

Adds support for in XPath frame boundary detection so navigation works on legacy pages. iframe and frame steps are treated as frame boundaries.

  • Bug Fixes

    • Updated regex from /^iframe(?:[\d+])?$/i to /^i?frame(?:[\d+])?$/i to match iframe and frame (case-insensitive) without matching frameset.
    • Added focused tests for iframe/frame and frameset XPaths, including parse + boundary detection; trimmed low-value cases.
    • Added a changeset for a patch release.
  • Refactors

    • Consolidated IFRAME_STEP_RE into a shared export from focusSelectors and used it in deepLocator.