fix(extension): prune descendant frameOwnerPage entries on frame detach and page close
FE
13h ago+199+199+012345678901234567890123456789-6-6-0123456789
Summary
Closing pages with nested frames left stale frameOwnerPage entries: Page.frameDetached deleted only the detached frame id and did not prune descendants still mapped to the same owner.
This PR prunes the detached frame and every descendant still owned by the same page on detach (unless reason === \"swap\"), and applies the same prune on page close before clearing remaining entries for the closed page.
Fixes https://github.com/browserbase/stagehand/issues/3240
Test plan
- OOPIF context fixture failed on unmodified upstream
main(NESTED_FRAME/ same-origin grandchildren stayed in the map) and passes with this change - Extension unit tests otherwise green (extension-build checks need a built
dist/not produced by this change)
Summary by cubic
Fixes stale frameOwnerPage entries left behind when frames detach or pages close, so a reused browser context no longer retains ownership of closed pages.
- Prunes the detached frame and all descendants still owned by the same page on frame detach, unless the reason is
swap. - Applies the same prune on page close and keeps frames owned by other pages intact.