fix(chromium): prevent TargetClosedException on main-frame cross-process navigation#41424
fix(chromium): prevent TargetClosedException on main-frame cross-process navigation#41424karimnabli wants to merge 1 commit into
Conversation
…ess navigation (microsoft#41348) Signed-off-by: Karim Nabli <karim.nabli.ie@gmail.com>
|
@microsoft-github-policy-service agree |
|
I’ve implemented a fix for #41348 Root cause: Fix: Test: Could you please review whether this approach aligns with the expected handling of cross-process navigations? |
Fixes #41348
Root Cause
In
crPage.ts, the_onDetachedFromTargetmethod assumes that a detached target implies either a swap or a true detach. However, Azure OAuth introduces a third case: a main-frame cross-process navigation.Due to the microtask delay in
Page.enable, the session mapping changes, and Playwright incorrectly callsframeDetached, throwing aTargetClosedExceptionimmediately after the "Stay signed in?" click.Fix
Added a guard in
_onDetachedFromTargetto verify if the session currently mapped to thetargetIdis still thechildFrameSessionthat triggered the detachment. If a new session has taken over (indicating a cross-process navigation), we skip theframeDetachedcall and simply dispose of the old session.Test
Added a regression test in
tests/library/chromium/oopif.spec.tsthat simulates a cross-origin redirect after a form submission to ensure the page survives the transition.