@@ -164,7 +164,7 @@ async function clickOidcStartIfNeeded(page: Page, targetHost: string): Promise<v
164164 let lastStartClick = 0 ;
165165
166166 while ( Date . now ( ) < deadline ) {
167- if ( await inputVisible ( page , USERNAME_INPUT_SELECTORS ) ) {
167+ if ( ( await inputVisible ( page , USERNAME_INPUT_SELECTORS ) ) && isIdentityLoginInputPage ( page . url ( ) , targetHost ) ) {
168168 return ;
169169 }
170170 const parsed = parseBrowserUrl ( page . url ( ) ) ;
@@ -232,7 +232,7 @@ async function clickOidcStartIfNeeded(page: Page, targetHost: string): Promise<v
232232async function waitForOidcStartHandoff ( page : Page , targetHost : string ) : Promise < void > {
233233 const deadline = Date . now ( ) + BROWSER_OIDC_HANDOFF_TIMEOUT_MS ;
234234 while ( Date . now ( ) < deadline ) {
235- if ( await inputVisible ( page , USERNAME_INPUT_SELECTORS ) ) {
235+ if ( ( await inputVisible ( page , USERNAME_INPUT_SELECTORS ) ) && isIdentityLoginInputPage ( page . url ( ) , targetHost ) ) {
236236 return ;
237237 }
238238
@@ -258,7 +258,7 @@ async function waitForIdentityLoginDocument(page: Page, targetHost: string): Pro
258258 }
259259
260260 await maybeWithTimeout ( page . waitForLoadState ( "domcontentloaded" , { timeout : 3000 } ) . catch ( ( ) => undefined ) , 4000 ) ;
261- if ( await inputVisible ( page , USERNAME_INPUT_SELECTORS ) ) {
261+ if ( ( await inputVisible ( page , USERNAME_INPUT_SELECTORS ) ) && isIdentityLoginInputPage ( currentUrl , targetHost ) ) {
262262 return ;
263263 }
264264
@@ -1175,6 +1175,11 @@ export function isTargetLoginOrOauthPlumbingPage(currentUrl: string, targetHost:
11751175 return Boolean ( parsed && parsed . host === targetHost && isLoginOrOauthCallbackPlumbingPath ( parsed . pathname ) ) ;
11761176}
11771177
1178+ export function isIdentityLoginInputPage ( currentUrl : string , targetHost : string ) : boolean {
1179+ const parsed = parseBrowserUrl ( currentUrl ) ;
1180+ return Boolean ( parsed && ! ( parsed . host === targetHost && isLoginOrOauthCallbackPlumbingPath ( parsed . pathname ) ) ) ;
1181+ }
1182+
11781183export function formatDeniedTargetRouteFailure ( finalUrl : string , body : string ) : string {
11791184 return [
11801185 "expected denied protected route to show a denial page, but the browser reached the target host without denial text" ,
0 commit comments