Skip to content

Commit ab91490

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
Try to deflake RPP landing page test
This has flaked a few times. Trying to see if this retry function will improve its stability, as we have quite a few rAFs to try to make this test work. Bug: 405356930 No-Presubmit: True No-Tree-Checks: True No-Try: True Change-Id: Ib9864aef67413ef1d3fa36d99359e8756b6626cb Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6381858 Reviewed-by: Andres Olivares <[email protected]> Auto-Submit: Jack Franklin <[email protected]> Commit-Queue: Jack Franklin <[email protected]>
1 parent df4d71f commit ab91490

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

test/e2e/performance/landing-page_test.ts

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)