File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,9 +15,11 @@ interface Fiber {
1515 * holds its dehydrated markup. A press or pointer move on markup React has not hydrated reaches
1616 * no handler and is lost, and Playwright's actionability checks cannot see the difference: on a
1717 * production build the live suite lost a tab click this way. The app exposes no hydration signal
18- * of its own, so this reads React's.
18+ * of its own, so this reads React's. Given the app's origin, a document that has since left it,
19+ * such as one a redirect to another site replaced after the load returned, has nothing to wait for.
1920 */
20- function isHydrated ( ) {
21+ function isHydrated ( appOrigin : string | undefined ) {
22+ if ( appOrigin !== undefined && location . origin !== appOrigin ) return true
2123 const key = Object . keys ( document ) . find ( ( name ) => name . startsWith ( '__reactContainer$' ) )
2224 if ( ! key ) return false
2325 const container : { stateNode : { current : Fiber } } | undefined = Reflect . get ( document , key )
@@ -50,7 +52,7 @@ export async function waitUntilHydrated(page: Page, timeout?: number) {
5052
5153async function waitForHydration ( page : Page , appOrigin : string ) {
5254 if ( new URL ( page . url ( ) ) . origin !== appOrigin ) return
53- await waitUntilHydrated ( page )
55+ await page . waitForFunction ( isHydrated , appOrigin , { polling : 100 } )
5456}
5557
5658/**
You can’t perform that action at this time.
0 commit comments