@@ -459,8 +459,9 @@ describe('The Performance panel landing page', () => {
459459 }
460460 } ) ;
461461
462- it ( 'does not retain interaction nodes in memory' , async ( ) => {
463- const { target, frontend} = await getBrowserAndPages ( ) ;
462+ // Flaking.
463+ it . skip ( '[crbug.com/405356930]: does not retain interaction nodes in memory' , async ( ) => {
464+ const { target, frontend} = getBrowserAndPages ( ) ;
464465
465466 await target . bringToFront ( ) ;
466467
@@ -489,8 +490,11 @@ describe('The Performance panel landing page', () => {
489490 await button ! . dispose ( ) ;
490491
491492 // Ensure the node is not preserved in a detached state
492- const { detachedNodes} = await targetSession . send ( 'DOM.getDetachedDomNodes' ) ;
493- assert . lengthOf ( detachedNodes , 0 ) ;
493+ const hasNoDetachedNodes = await retryUntilExpected ( async ( ) => {
494+ const { detachedNodes} = await targetSession . send ( 'DOM.getDetachedDomNodes' ) ;
495+ return detachedNodes . length === 0 ;
496+ } ) ;
497+ assert . isTrue ( hasNoDetachedNodes , 'detached nodes were found after retries' ) ;
494498
495499 await frontend . bringToFront ( ) ;
496500
@@ -506,3 +510,40 @@ describe('The Performance panel landing page', () => {
506510 }
507511 } ) ;
508512} ) ;
513+
514+ /**
515+ * Retries the function a number of times until it returns true, or hits the max retries.
516+ * Note that this is different to our waitForFunction helpers which run the
517+ * function in the context of the target page. This runs in the execution of the
518+ * test file itself.
519+ */
520+ async function retryUntilExpected ( asyncFunction : ( ) => Promise < boolean > , maxRetries = 5 ) : Promise < boolean > {
521+ let retries = 0 ;
522+
523+ async function attempt ( ) : Promise < boolean > {
524+ try {
525+ const result = await asyncFunction ( ) ;
526+ if ( result === true ) {
527+ return true ;
528+ }
529+ // Silently retry
530+ if ( retries < maxRetries ) {
531+ retries ++ ;
532+ await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
533+ return await attempt ( ) ;
534+ }
535+ return false ; // Max retries exceeded
536+
537+ } catch {
538+ // Silently retry even if there is an error
539+ if ( retries < maxRetries ) {
540+ retries ++ ;
541+ await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
542+ return await attempt ( ) ;
543+ }
544+ return false ; // Max retries exceeded
545+ }
546+ }
547+
548+ return await attempt ( ) ;
549+ }
0 commit comments