Skip to content

Commit d44ed9d

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[tests] Wait between long interactions in landing-page.test.ts
I think this may reduce flakiness. Bug: 415271011 Change-Id: I9f71520816551ef070a5804a38d8ec8de2977f1d Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7242641 Auto-Submit: Connor Clark <cjamcl@chromium.org> Commit-Queue: Connor Clark <cjamcl@chromium.org> Reviewed-by: Paul Irish <paulirish@chromium.org>
1 parent ba63516 commit d44ed9d

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

test/e2e/performance/landing-page.test.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
takeHeapSnapshot,
1515
waitForNonEmptyHeapSnapshotData,
1616
} from '../helpers/memory-helpers.js';
17-
import {navigateToPerformanceTab} from '../helpers/performance-helpers.js';
17+
import {increaseTimeoutForPerfPanel, navigateToPerformanceTab} from '../helpers/performance-helpers.js';
1818
import type {DevToolsPage} from '../shared/frontend-helper.js';
1919
import type {InspectedPage} from '../shared/target-helper.js';
2020

@@ -56,13 +56,11 @@ async function setCruxRawResponse(path: string, devToolsPage: DevToolsPage, insp
5656

5757
describe('The Performance panel landing page', function() {
5858
setup({dockingMode: 'undocked', panel: 'timeline'});
59-
if (this.timeout() > 0) {
60-
this.timeout(20000);
61-
}
59+
increaseTimeoutForPerfPanel(this);
6260

6361
async function doubleRaf(inspectedPage: InspectedPage): Promise<void> {
64-
await inspectedPage.evaluate(() => new Promise(r => requestAnimationFrame(r)));
65-
await inspectedPage.evaluate(() => new Promise(r => requestAnimationFrame(r)));
62+
await inspectedPage.raf();
63+
await inspectedPage.raf();
6664
}
6765

6866
async function prepare(devToolsPage: DevToolsPage, inspectedPage: InspectedPage): Promise<void> {
@@ -71,6 +69,14 @@ describe('The Performance panel landing page', function() {
7169
await doubleRaf(inspectedPage); // Without this, even an empty test can fail subsequent tests. Dunno why.
7270
}
7371

72+
async function makeTwoLongInteractions(inspectedPage: InspectedPage) {
73+
await inspectedPage.page.click('#long-interaction');
74+
await doubleRaf(inspectedPage);
75+
await doubleRaf(inspectedPage);
76+
await inspectedPage.page.click('#long-interaction');
77+
await doubleRaf(inspectedPage);
78+
}
79+
7480
it('displays live metrics', async ({devToolsPage, inspectedPage}) => {
7581
await prepare(devToolsPage, inspectedPage);
7682

@@ -79,9 +85,7 @@ describe('The Performance panel landing page', function() {
7985
const waitForLCP = await installLCPListener(inspectedPageSession);
8086
await inspectedPage.goToResource('performance/fake-website.html');
8187
await waitForLCP();
82-
await inspectedPage.page.click('#long-interaction');
83-
await inspectedPage.page.click('#long-interaction');
84-
await doubleRaf(inspectedPage);
88+
await makeTwoLongInteractions(inspectedPage);
8589
await devToolsPage.bringToFront();
8690

8791
const [lcpValueElem, clsValueElem, inpValueElem] = await devToolsPage.waitForMany(READY_LOCAL_METRIC_SELECTOR, 3);
@@ -122,9 +126,7 @@ describe('The Performance panel landing page', function() {
122126
const waitForLCP = await installLCPListener(inspectedPageSession);
123127
await inspectedPage.goToResource('performance/fake-website.html');
124128
await waitForLCP();
125-
await inspectedPage.page.click('#long-interaction');
126-
await inspectedPage.page.click('#long-interaction');
127-
await doubleRaf(inspectedPage);
129+
await makeTwoLongInteractions(inspectedPage);
128130

129131
await inspectedPageSession.send('Runtime.enable');
130132
const executionContextPromise = new Promise(r => inspectedPageSession.once('Runtime.executionContextCreated', r));
@@ -167,9 +169,7 @@ describe('The Performance panel landing page', function() {
167169
await inspectedPage.goToResource('performance/fake-website.html');
168170
await waitForLCP1();
169171

170-
await inspectedPage.page.click('#long-interaction');
171-
await inspectedPage.page.click('#long-interaction');
172-
await doubleRaf(inspectedPage);
172+
await makeTwoLongInteractions(inspectedPage);
173173

174174
await devToolsPage.bringToFront();
175175

@@ -424,8 +424,7 @@ describe('The Performance panel landing page', function() {
424424

425425
await inspectedPage.page.click('#long-click');
426426

427-
await inspectedPage.evaluate(() => new Promise(r => requestAnimationFrame(r)));
428-
await inspectedPage.evaluate(() => new Promise(r => requestAnimationFrame(r)));
427+
await doubleRaf(inspectedPage);
429428

430429
await devToolsPage.bringToFront();
431430

@@ -460,8 +459,7 @@ describe('The Performance panel landing page', function() {
460459
// be detected by the live metrics model in DevTools.
461460
//
462461
// If any unnecessary JS references to the node get created they will be created in this time period.
463-
await inspectedPage.evaluate(() => new Promise(requestAnimationFrame));
464-
await inspectedPage.evaluate(() => new Promise(requestAnimationFrame));
462+
await doubleRaf(inspectedPage);
465463
await devToolsPage.bringToFront();
466464
await devToolsPage.waitFor(INTERACTION_SELECTOR);
467465
await inspectedPage.bringToFront();

0 commit comments

Comments
 (0)