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 2 commits 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? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Test results for "MCP"3 failed 7458 passed, 1132 skipped Merge workflow run. |
Test results for "tests 1"2 failed 7 flaky49170 passed, 1163 skipped Merge workflow run. |
|
Hi, @pavelfeldman @dgozman |
|
Hi, @pavelfeldman @dgozman @Skn0tt – I wanted to flag that the failing MCP test ( Evidence:
My PR changes:
The MCP job failure should not block this PR. If needed, I'm happy to see if this test flakiness can be addressed in a separate issue. |
Signed-off-by: Karim Nabli <karim.nabli.ie@gmail.com>
1c03e8f to
8a6a13d
Compare
|
I tried to run pretty much your exact test on the bots, without a fix, to see what's going wrong: #41930. Turns out, it passes on every bot. Now I am not sure we are fixing the right problem at all. We need some easy-ish repro that we can turn into a test to make sure we are fixing the actual issue. |
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.