fix(extension): hop into iframes selected by attribute predicates
why
Deep XPaths that select an iframe by an attribute predicate never crossed the frame boundary. parseXPath stripped only a trailing positional predicate when computing the step name, so IFRAME_STEP_RE recognized iframe[2] but not iframe[@name='main'] — planDeepXPathTarget("//iframe[@name='main']//button") kept the iframe step in the final selector and resolved it as an element in the parent frame, failing even though the target exists inside the iframe. Positional form (//iframe[1]//button) worked.
Closes #3416
what changed
parseXPath(understudy/deepLocator.ts) andparseXPathToSteps(understudy/a11y/snapshot/focusSelectors.ts) now strip all bracketed predicates when computing the step name, so anyiframe/framestep is recognized as a hop regardless of how it is selected.IFRAME_STEP_REsimplified to/^i?frame$/i— both call sites feed it predicate-stripped names.- Hop selectors are unchanged in output:
buildXPathFromStepsstill uses the raw step text, so predicates stay in the hop selector and the correct iframe element is still selected. - The same fix applies to the a11y snapshot focus-frame walker, which had the identical positional-only assumption, so focus resolution is consistent with deep-locator resolution.
test plan
- Extended
packages/extension/tests/deep-locator.test.ts: attribute-predicate hop (//iframe[@name='main']//button), mixed positional+attribute hop (//iframe[2][@title='content']//button), and a predicate-free hop regression case. All hop selectors preserve their raw predicates. pnpm --filter ./packages/extension test:unit→ 73 files / 1191 tests passing, extension typecheck clean.
Summary by cubic
Deep XPaths selecting an iframe by attribute predicate (e.g. //iframe[@name='main']//button) now cross the frame boundary; previously only positional predicates like //iframe[1] worked, and attribute-selected iframes resolved against the parent frame and failed. Closes #3416.
- Strips all bracketed predicates when computing step names in both
deepLocator.tsandfocusSelectors.ts, so anyiframe/framestep is recognized as a hop. - Hop selectors keep their raw predicates, so the correct iframe element is still selected.
- Applies the same fix to the a11y snapshot focus-frame walker for consistent focus resolution.