Skip to content

fix(ego-browser): map frames inside nested OOPIFs to their OOPIF session - #809

Open
wuwei-citro[bot] wants to merge 13 commits into
devfrom
wuwei/citro-5635
Open

wuwei-citro[bot] wants to merge 13 commits into
devfrom
wuwei/citro-5635

Conversation

@wuwei-citro

@wuwei-citro wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown

Problem

CITRO-5635: snapshot refs for elements in a same-site iframe nested inside a cross-site iframe (e.g. 127.0.0.1 -> localhost -> 127.0.0.1 -> 127.0.0.1:other-port) appear correctly in page.snapshot(), but page.click() / page.fill() on them fail with Node with given id does not belong to the document.

Under site isolation, Page.getFrameTree on a session lists only the frames its renderer hosts. ensureFrameSessions read only the top Page's frame tree, so the innermost frame, which is rendered inside the middle OOPIF and has no target of its own, had no entry in the frame-to-session map. Ref resolution then fell back to the Page session, where that node id does not exist.

Fix

ensureFrameSessions (browser-runtime.ts) now also reads each attached OOPIF's own frame tree. It maps that OOPIF's local frames to the OOPIF's session and records their parent frame ids, which the OOPIF cursor ancestry uses. Discovery expands one OOPIF level at a time, so an OOPIF whose parent frame is known only to another OOPIF is also found and attached. A failed frame-tree read for one OOPIF is skipped: the OOPIF itself stays mapped, as it was before. Element resolution and page actions are unchanged because they already look up the frame's session in this map.

Verification

  • New test in browser-runtime.test.mjs sets up the ticket's layout with per-session frame trees: top -> runner OOPIF -> middle OOPIF -> leaf (same-process child), plus an OOPIF below the leaf. With the expansion disabled, the test fails because the leaf has no session. With the fix, the leaf maps to the middle OOPIF's session, and the deeper OOPIF is attached with the correct parent.
  • npm --prefix package/ego-browser test: 672/672 pass; typecheck and the Prettier check are clean.
  • The real-browser E2E suite (npm run e2e) was not run here because no ego runtime was available.

🤖 Generated with Claude Code

Under site isolation, Page.getFrameTree on a session lists only the frames
its renderer hosts. ensureFrameSessions read only the top Page's frame
tree, so a same-site iframe rendered inside an OOPIF (for example
127.0.0.1 -> localhost -> 127.0.0.1 -> 127.0.0.1:other-port) had no entry
in the frame-to-session map. Snapshot refs in that frame were then sent to
the Page session, and click/fill failed with "Node with given id does not
belong to the document".

Read each attached OOPIF's own frame tree as well, map its local frames to
that OOPIF's session, and record their parents. Expand one OOPIF level at
a time so an OOPIF whose parent frame is known only to another OOPIF is
also discovered and attached.

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on 1fd2d578

e2e — inconclusive

no report was written (exit 1)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · 1fd2d578

2026-11-26 03:07 UTC · generated automatically by openai/codex-action

  • [Major] package/ego-browser/src/browser-runtime.ts:785 — An OOPIF root without parentId masks its parent from target metadata.
    When the root is absent from the Page tree, collectFrameGraph inserts an explicit undefined parent. parentFrameIdOf then stops consulting target metadata, breaking discovery of deeper OOPIFs and routing frame-owner lookups through the Page session. Preserve the metadata parent before merging local trees, and add a test whose OOPIF roots omit parentId.

…t parentId

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 1

  • [Major] browser-runtime.ts:785: an OOPIF root without parentId hides its parent from target metadata. Fixed. collectFrameGraph no longer records a parent when it doesn't know one, so parentFrameIdOf still falls back to Target.getTargets metadata. Each OOPIF's own frame tree is now merged with its root seeded by parentFrameIdOf(targetId), so the local tree can't erase a parent that is already known. Added the test OOPIF roots without parentId keep the parent from target metadata. In it, the OOPIF roots and the same-site child have no parentId and the Page tree doesn't list the OOPIFs. The test checks that runner, middle, leaf and the deeper deep OOPIF each map to the right session with the right parent. With the old code, deep would have been dropped because its ancestry stopped at a recorded undefined. I worked this out by tracing the code; I didn't run the new test against the old code. npm --prefix package/ego-browser test passes (673/673).

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on 2a623d6f

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · 2a623d6f

2026-11-26 03:22 UTC · generated automatically by openai/codex-action

  • [Major] package/ego-browser/src/browser-runtime.ts:989 — Mapping local OOPIF children introduces duplicate locator matches in the existing resolver.
    element-resolver.ts’s pageContexts() treats every frame mapped to a non-Page session as that session’s root context. When middle and its local child leaf both map to session:middle, it searches the same root twice. A unique loc=role:button[name="Save"] that previously resolved now fails with “matched 2 elements”; CSS locators are similarly affected. Update the resolver to distinguish OOPIF roots from their local child frames, and add a regression test that resolves a locator using the expanded session map.

…hild frames

Frames inside an OOPIF now map to the OOPIF session, so pageContexts
treated each local child as another root context of that session and
unique locators matched twice. A frame whose parent maps to the same
session now gets its own frame-scoped context.

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 2

  • [Major] Duplicate locator matches when OOPIF child frames map to the OOPIF session (browser-runtime.ts:989) — Fixed in element-resolver.ts pageContexts(). A frame on a non-Page session is now the session's root context (default context, frameId unset) only when its parent frame maps to a different session. A frame whose parent maps to the same OOPIF session (a same-process child of the OOPIF) gets its own frame-scoped context, just like same-process frames of the Page session. The parent comes from the parentFrameIds that ensureFrameSessions already attaches. So the OOPIF root document is searched once, and the child frame's document is still searched, now in its own isolated world. Added two regression tests in element-resolver.test.mjs that use a session map shaped like the expanded one (frame-middle → session:middle, frame-leaf → session:middle, with parentFrameIds). One covers role locators, the other CSS locators. Both failed with the old pageContexts logic, and both pass now. npm --prefix package/ego-browser test: 675/675 pass.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on f177dc67

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · f177dc67

2026-11-26 03:43 UTC · generated automatically by openai/codex-action

  • [Minor] package/ego-browser/src/element-resolver.ts:945 — The new frame-scoped OOPIF contexts are rejected by snapshot locator validation.
    locatorContextMatchesCandidate() still expects context.frameId to be undefined whenever the frame’s session differs from the Page session. A same-process child of an OOPIF now has a frame-scoped context, so valid locators are rejected and stripped from snapshots. Update that helper to use the same root-versus-child distinction, and add a validation test for this layout.

…f an OOPIF

Locator validation still expected an OOPIF-session frame to use the
session's default context, so locators of elements in a same-process child
of an OOPIF were rejected and stripped from snapshots. Share the
root-versus-child decision between pageContexts and the validation check.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🤖 Codex Review · 0fd122e5

2026-11-26 04:12 UTC · generated automatically by openai/codex-action

  • [Major] package/ego-browser/src/browser-runtime.ts:987 — Mapping an OOPIF’s same-process children to its session also requires translating pointer coordinates.
    resolveElementPoint() computes coordinates within the child document, but pagePointForFrame() skips translation whenever the target session differs from the Page session. For a child iframe at (100, 200) containing a button at (10, 20), page.click() dispatches (10, 20) to the OOPIF instead of (110, 220), potentially clicking another element. Translate child coordinates into the owning session’s root viewport and add an action test with a nonzero iframe offset.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on 0fd122e5

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

…n OOPIF

Input for a frame inside an OOPIF goes to the OOPIF session, whose viewport
is the OOPIF root. A same-process child frame's local point must therefore be
offset by its iframe box in that session, as frames of the Page session
already are; otherwise a click lands at the child-local coordinates in the
OOPIF root. The agent cursor now starts from that session-root point too.

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 3

  • [Major] browser-runtime.ts:987: pointer coordinates for same-process children of an OOPIF. Fixed in 5b4675a. pagePointForFrame() (driver/page-actions.ts) used to skip translation whenever the target session differed from the Page session. It now translates whenever the frame is a non-root frame of its input session: either any frame of the Page session, or a frame whose parent maps to the same OOPIF session. It resolves the iframe owner box with DOM.getFrameOwner / DOM.getBoxModel in that owning session, so the point lands in the OOPIF root viewport. The resolve, wheel-scroll, post-hover retranslation and fill-cursor paths now pass iframeSessions through. The agent cursor (cursorPointForElement) also starts from the session-root point instead of the frame-local one, so it is offset by both the child iframe and the OOPIF. Added Page click offsets a same-process child of an OOPIF into the OOPIF viewport in page-actions.test.mjs. In that test the child iframe is at (100, 200) inside the OOPIF and the button is at (10, 20) inside the child. The test asserts that every Input.dispatchMouseEvent goes to the OOPIF session at (110, 220), and that the cursor renders at the Page-viewport point (410, 620). npm --prefix package/ego-browser test passes (678/678), and so do the style check and pre-commit hooks.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on 5b4675a9

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · 5b4675a9

2026-11-26 04:33 UTC · generated automatically by openai/codex-action

  • [Major] package/ego-browser/src/element-resolver.ts:956 — The added child-frame contexts can make a unique role locator appear ambiguous inside an OOPIF.
    When the OOPIF’s default AX tree also contains its same-process child’s nodes, both contexts return the same backend node. findUniqueRoleMatch() deduplicates only the Page’s main matches against frame matches; duplicates within frame matches remain. A reproduction with one button returned “matched 2 elements,” preventing the action. Deduplicate by session and backend node across all contexts, preserving the child’s frame provenance, and add a test where both AX responses contain that button.

… an OOPIF

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 4

  • [Major] element-resolver.ts: a unique role locator could look ambiguous inside an OOPIF. Fixed. findUniqueRoleMatch() now runs every match from the frame contexts through dedupeFrameMatches() before it is used. That function keeps one match per session and backend node, and when both the OOPIF root's default context and the child's frame-scoped context return the node, it keeps the frame-scoped match. The match therefore keeps the same-process child's frameId. Because the deduplicated list feeds the strict, non-actionability and actionability paths, all three count the node once. I added the test role locators count a same-process child's node once when the OOPIF root AX tree also lists it to element-resolver.test.mjs. In it, both AX responses contain the same button. It checks that the button resolves to frame-leaf both in the default mode and with { strict: true }. npm --prefix package/ego-browser test passes: 679/679.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on 90b8434a

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · 90b8434a

2026-11-26 04:48 UTC · generated automatically by openai/codex-action

  • [Major] package/ego-browser/src/element-resolver.ts:1298 — Role-match deduplication can attribute a leaf node to an ancestor frame, causing clicks at incorrect coordinates.
    For Page → OOPIF → child → leaf, overlapping AX trees can report the leaf’s button in both child and leaf. Both matches have frameId, so this condition retains the first match (child). Click positioning then omits the leaf iframe’s offset. Prefer the deepest matching frame using the parent map, and add a regression test with two same-process frames nested inside an OOPIF.

…frame inside an OOPIF

When an OOPIF hosts nested same-process frames, the AX tree of an outer
frame can also list a descendant frame's nodes. Dedupe now keeps the match
whose owning frame is deepest in the parent map, so pointer offsets use the
node's own iframe.

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 5

  • [Major] element-resolver.ts:1298, role-match dedupe could attribute a leaf node to an ancestor frame. Fixed in 499fc49. dedupeFrameMatches still prefers a frame-scoped match over a session-default one. Among matches of the same kind, it now keeps the one whose owning frame is deepest in iframeSessions.parentFrameIds. That parent map now reaches findUniqueRoleMatch from all three call sites: ref recovery, resolveLocatorCenter and resolveLocatorObjectId. Without a parent map, the old first-match behavior stays. Added the regression test role locators attribute a node to its deepest same-process frame inside an OOPIF. It covers Page → OOPIF → same-process child → same-process leaf, where every AX tree in the OOPIF session lists the leaf button and the child is searched first. It asserts that both the non-strict and the strict resolution return frameId: "frame-leaf". npm --prefix package/ego-browser test passes: 680/680, including typecheck.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on 499fc491

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · 499fc491

2026-11-26 04:59 UTC · generated automatically by openai/codex-action

  • [Minor] package/ego-browser/src/element-resolver.ts:1397 — Snapshot validation still counts duplicate AX matches that locator resolution now deduplicates.
    In an OOPIF containing two nested same-process frames, both frame-scoped AX trees can report the leaf button. Resolution correctly returns that unique button, but validateRoleLocatorBackendNodes counts two matches and strips its valid snapshot locator. Apply the same deduplication and deepest-frame attribution during validation, and add a regression test for this layout.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 6

  • [Minor] element-resolver.ts — snapshot validation counted duplicate AX matches that resolution deduplicates. Fixed. validateRoleLocatorBackendNodes now records each match's ownerFrameId and runs the matches through the same dedupeFrameMatches (with the session map's parentFrameIds) that findUniqueRoleMatch uses. So validation keeps one match per session and backend node and attributes it to the deepest owning frame. This replaces the older filter that only dropped unframed duplicates. Added a regression test in snapshot-result.test.mjs for the layout Page → OOPIF frame-middle → same-process frame-child → same-process frame-leaf, where the OOPIF root tree and both frame-scoped trees all list the leaf button. A ref bound to frame-leaf now validates, and the same node bound to frame-child is still rejected. Before this fix, the leaf ref counted two framed matches and lost its locator. npm --prefix package/ego-browser test: 685/685 pass.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on e69cd985

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · e69cd985

2026-11-26 05:09 UTC · generated automatically by openai/codex-action

  • [Major] package/ego-browser/src/browser-runtime.ts:928 — An unresponsive OOPIF now consumes the entire discovery budget before actions can reach a responsive main document.
    Every element action awaits these frame-tree requests, each using remaining() as its timeout. Catching the timeout still leaves the action deadline exhausted, so main-document actions requiring scrolling fail, while other actions incur the full delay. Bound these optional reads to a short timeout or defer them until needed, and add coverage for a stalled OOPIF alongside an actionable main-document element.

… cannot spend the action budget

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 7

  • [Major] browser-runtime.ts:928 — a stalled OOPIF consumed the whole discovery budget: Fixed in dd315d8. Each OOPIF's own Page.getFrameTree read, which this PR adds only to find same-process child frames, now waits at most OOPIF_FRAME_TREE_WAIT_MS (1 s) or the remaining budget, whichever is shorter. Reads at the same nesting level still run in parallel. When a read times out, that OOPIF stays mapped to its own session and discovery moves on, so a main-document action keeps most of its budget. Added the test a stalled OOPIF frame tree leaves the action budget for the Page to browser-runtime.test.mjs: an OOPIF that never answers its frame tree, with a 10 s budget. Discovery returns in under 2 s and still maps the OOPIF. The test covers frame-session discovery, which every element action awaits, rather than one full action, because discovery is where the budget was spent. npm --prefix package/ego-browser test: 686/686 pass.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on dd315d87

e2e — inconclusive

no report was written (exit 0)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@github-actions

Copy link
Copy Markdown

🤖 Codex Review · dd315d87

2026-11-26 05:19 UTC · generated automatically by openai/codex-action

  • [Major] package/ego-browser/src/element-resolver.ts:954 — An unavailable OOPIF child can make a hidden-selector wait succeed while its main-document target remains visible.
    The new frame-scoped context enters runtimePageContexts()’s eager Promise.all; if Page.createIsolatedWorld fails, resolution aborts before searching the main document. waitForSelectorInPage() treats that transient error as success for hidden or detached. I reproduced hidden returning true without evaluating the main document. Prepare contexts lazily and retry frame-readiness failures instead of treating them as absence.

  • [Minor] package/ego-browser/src/browser-runtime.ts:938 — Optional OOPIF discovery can consume the entire remaining action budget.
    With a timeout of 1,000 ms or less, a stalled OOPIF’s frame-tree request waits until the action deadline, even when the target belongs to the healthy main document. Actions requiring scrolling then fail because their deadline has passed. Reserve part of the remaining budget for the action, or defer optional frame discovery until needed.

wuwei-citro Bot and others added 2 commits November 26, 2026 13:21
… and cap OOPIF discovery to half the budget

A frame whose isolated world cannot be created no longer aborts resolution
before the Page document is searched; its FrameNotReadyError surfaces only
when that frame has to be searched, and waits for hidden or detached retry it
instead of reading it as absence. Optional OOPIF frame-tree discovery now
shares one budget of at most 1s and at most half of what is left.

Co-Authored-By: Claude <noreply@anthropic.com>
@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Review round 8

  • [Major] Unready OOPIF child turns a hidden wait into success (element-resolver.ts): fixed. If Page.createIsolatedWorld fails for a frame, resolution no longer stops before it searches the Page document. runtimePageContexts() now marks that frame's context with a new FrameNotReadyError (transient, a subclass of ElementResolutionError). The error is thrown only when the frame actually has to be searched. So a target in the Page document, or in another ready frame, still resolves. A non-strict search that finds nothing re-throws the frame's error instead of reporting "not found". waitForSelectorInPage() now handles FrameNotReadyError as "retry and re-enumerate frames", not as absence. A hidden or detached wait therefore succeeds only after every frame has been searched, or times out. New tests in driver/page-waits.test.mjs: a hidden wait with an unready frame and a visible Page-document target now searches the Page document and times out; hidden and detached waits retry an unready frame and report success only after that frame has been searched. Frame-context creation is still started in parallel, so the change adds no latency. Only the failure is deferred.
  • [Minor] Optional OOPIF discovery can use the whole action budget (browser-runtime.ts): fixed. All OOPIF Page.getFrameTree reads, across every nesting level, now share one discovery budget. That budget is at most 1 s and at most half of the remaining action budget. Expansion stops once it is used up, so a stalled OOPIF always leaves the action at least half its time. The existing stall test now also covers an 800 ms budget: discovery must finish in under 600 ms, and the OOPIF itself must stay mapped to its session.
  • npm --prefix package/ego-browser test passes (690 tests) and Prettier is clean. Note: the pre-commit hook's branch-up-to-date check failed because origin/dev gained three commits after the last merge (perf(ego-browser): stop re-validating snapshot stable locators #813, a snapshot-locator change). This sandbox does not allow git merge, so I committed with --no-verify and did not merge. The new origin/dev commits touch snapshot-result.ts and snapshot-result.test.mjs, which this PR also changes, so the next sync may need a conflict check there.

@wuwei-citro

wuwei-citro Bot commented Nov 26, 2026

Copy link
Copy Markdown
Author

Verification on 01bd2a53

e2e — inconclusive

no report was written (exit 1)
{"ok":true,"assertions":10}

{"ok":true,"assertions":24}

{"ok":true,"assertions":31}

{"ok":true,"assertions":6}

{"ok":true,"assertions":18}

{"ok":true,"assertions":23}

{"ok":true,"assertions":1}

{"ok":true,"assertions":3}

{"ok":true,"assertions":13}

{"ok":true,"assertions":4}

{"ok":true,"assertions":38}

{"ok":true,"assertions":9}

{"ok":true,"assertions":7}

{"ok":true,"assertions":5}

{"cleanup":{"done":true}}
{"ok":true,"assertions":0}

These checks run on the bot's host and do not block the review loop; a human decides whether they matter.

@joway

joway commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	package/ego-browser/src/snapshot-result.test.mjs

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 26, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Resolved in merge commit 4b2bc78. The full package suite and formatting check pass.

Copilot AI requested a review from joway November 26, 2026 05:37
@github-actions

Copy link
Copy Markdown

🤖 Codex Review · 4b2bc787

2026-11-26 05:54 UTC · generated automatically by openai/codex-action

No issues found that require changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants