Skip to content

Commit b287d00

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
Reland "Enable DeferRendererTasksAfterInput"
This is a reland of commit d658fd5 but modifies shared helpers to reduce the amount of flaky tests discovered in CI. Original change's description: > Enable DeferRendererTasksAfterInput > > With DeferRendererTasksAfterInput shipping in Chrome by default, there > is no guarantee that that all triggered by the CDP input (for example, > Input.dispatchMouseEvent) will be processed before the next task (for > example, Runtime.evaluate) runs. This makes the tests that do not wait > for the expected page state to become more flaky if the input task was > delayed. > > Tests like these should be treated as other flaky tests and either fixed > or disabled for investigation. > > Bug: 361078921 > Change-Id: I4002b9014e0af1576d5d319c67663b2087a86007 > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6226408 > Commit-Queue: Alex Rudenko <[email protected]> > Reviewed-by: Benedikt Meurer <[email protected]> Bug: 361078921 Change-Id: I900a45a2543df44b34be5717830edb6f439a8936 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6252829 Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent d884ae7 commit b287d00

File tree

9 files changed

+52
-5
lines changed

9 files changed

+52
-5
lines changed

test/conductor/hooks.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ function launchChrome() {
7575
];
7676

7777
const disabledFeatures = [
78-
'DeferRendererTasksAfterInput', // crbug.com/361078921
7978
'PMProcessPriorityPolicy', // crbug.com/361252079
8079
'MojoChannelAssociatedSendUsesRunOrPostTask', // crbug.com/376228320
8180
'RasterInducingScroll', // crbug.com/381055647

test/e2e/console/console-eval-global_test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import {assert} from 'chai';
66

7-
import {click, getBrowserAndPages, pasteText, step} from '../../shared/helper.js';
7+
import {click, drainFrontendTaskQueue, getBrowserAndPages, pasteText, step} from '../../shared/helper.js';
88
import {CONSOLE_TAB_SELECTOR, focusConsolePrompt, getCurrentConsoleMessages} from '../helpers/console-helpers.js';
99

1010
describe('The Console Tab', () => {
@@ -24,14 +24,16 @@ describe('The Console Tab', () => {
2424
};
2525
`);
2626
await frontend.keyboard.press('Enter');
27-
2827
// Wait for the console to be usable again.
2928
await frontend.waitForFunction(() => {
3029
return document.querySelectorAll('.console-user-command-result').length === 1;
3130
});
3231
});
3332

3433
await step('enter code that references the created bindings', async () => {
34+
// TODO: it should actually wait for rendering to finish.
35+
await drainFrontendTaskQueue();
36+
3537
await pasteText('foo;');
3638
await frontend.keyboard.press('Enter');
3739

@@ -40,11 +42,16 @@ describe('The Console Tab', () => {
4042
return document.querySelectorAll('.console-user-command-result').length === 1;
4143
});
4244

45+
// TODO: it should actually wait for rendering to finish.
46+
await drainFrontendTaskQueue();
47+
4348
await pasteText('bar;');
4449
await frontend.keyboard.press('Enter');
4550
});
4651

4752
await step('check that the expected output is logged', async () => {
53+
// TODO: it should actually wait for rendering to finish.
54+
await drainFrontendTaskQueue();
4855
const messages = await getCurrentConsoleMessages();
4956
assert.deepEqual(messages, [
5057
'undefined',

test/e2e/helpers/elements-helpers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
click,
1212
clickElement,
1313
clickMoreTabsButton,
14+
drainFrontendTaskQueue,
1415
getBrowserAndPages,
1516
getTextContent,
1617
goToResource,
@@ -755,6 +756,8 @@ export async function editCSSProperty(selector: string, propertyName: string, ne
755756
// Edit a media or container query rule text for the given styles section
756757
export async function editQueryRuleText(queryStylesSections: puppeteer.ElementHandle<Element>, newQueryText: string) {
757758
await click(STYLE_QUERY_RULE_TEXT_SELECTOR, {root: queryStylesSections});
759+
// TODO: it should actually wait for rendering to finish.
760+
await drainFrontendTaskQueue();
758761
await waitForFunction(async () => {
759762
// Wait until the value element has been marked as a text-prompt.
760763
const queryText = await $(STYLE_QUERY_RULE_TEXT_SELECTOR, queryStylesSections);
@@ -769,6 +772,9 @@ export async function editQueryRuleText(queryStylesSections: puppeteer.ElementHa
769772
await typeText(newQueryText);
770773
await pressKey('Enter');
771774

775+
// TODO: it should actually wait for rendering to finish.
776+
await drainFrontendTaskQueue();
777+
772778
await waitForFunction(async () => {
773779
// Wait until the value element is not a text-prompt anymore.
774780
const queryText = await $(STYLE_QUERY_RULE_TEXT_SELECTOR, queryStylesSections);

test/e2e/helpers/performance-helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {getBrowserAndPages} from '../../conductor/puppeteer-state.js';
88
import {
99
$,
1010
click,
11+
drainFrontendTaskQueue,
1112
goToResource,
1213
summonSearchBox,
1314
waitFor,
@@ -86,9 +87,15 @@ export async function openCaptureSettings(sectionClassName: string) {
8687
export async function searchForComponent(frontend: puppeteer.Page, searchEntry: string) {
8788
await waitFor('devtools-performance-timeline-summary');
8889
await summonSearchBox();
90+
// TODO: it should actually wait for rendering to finish.
91+
await drainFrontendTaskQueue();
8992
await waitFor('.search-bar');
93+
// TODO: it should actually wait for rendering to finish.
94+
await drainFrontendTaskQueue();
9095
await frontend.keyboard.type(searchEntry);
9196
await frontend.keyboard.press('Tab');
97+
// TODO: it should actually wait for rendering to finish.
98+
await drainFrontendTaskQueue();
9299
await expectVeEvents([
93100
veKeyDown(''),
94101
veImpressionsUnder('Panel: timeline', [veImpression(

test/e2e/helpers/sources-helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
click,
1616
clickElement,
1717
clickMoreTabsButton,
18+
drainFrontendTaskQueue,
1819
getBrowserAndPages,
1920
getPendingEvents,
2021
getTestServerPort,
@@ -723,6 +724,12 @@ export async function evaluateSelectedTextInConsole() {
723724
await frontend.keyboard.press('E');
724725
await frontend.keyboard.up(modifierKey);
725726
await frontend.keyboard.up('Shift');
727+
// TODO: it should actually wait for rendering to finish. Note: it is
728+
// drained three times because rendering currently takes 3 dependent
729+
// tasks to finish.
730+
await drainFrontendTaskQueue();
731+
await drainFrontendTaskQueue();
732+
await drainFrontendTaskQueue();
726733
}
727734

728735
export async function addSelectedTextToWatches() {

test/e2e/memory/memory_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,8 @@ describe('The Memory Panel', function() {
576576
assert.isTrue(!(await getCategoryRow('{a, b, c, d, p, q, r}', /* wait:*/ false)));
577577
});
578578

579-
it('Groups objects by constructor location', async () => {
579+
// Failing with crbug.com/361078921
580+
it.skip('[crbug.com/361078921]: Groups objects by constructor location', async () => {
580581
await goToResource('memory/duplicated-names.html');
581582
await navigateToMemoryTab();
582583
await takeHeapSnapshot();

test/e2e/snippets/snippets_test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import {assert} from 'chai';
66

7-
import {getBrowserAndPages, typeText, waitFor, waitForFunction} from '../../shared/helper.js';
7+
import {drainFrontendTaskQueue, getBrowserAndPages, typeText, waitFor, waitForFunction} from '../../shared/helper.js';
88
import {maybeGetCurrentConsoleMessages} from '../helpers/console-helpers.js';
99
import {getAvailableSnippets, openCommandMenu, showSnippetsAutocompletion} from '../helpers/quick_open-helpers.js';
1010
import {
@@ -41,6 +41,8 @@ describe('Snippet creation', () => {
4141
assert.deepEqual(await getAvailableSnippets(), []);
4242

4343
await frontend.keyboard.press('Backspace');
44+
// TODO: it should actually wait for rendering to finish.
45+
await drainFrontendTaskQueue();
4446
assert.deepEqual(await getAvailableSnippets(), [
4547
'New snippet\u200B',
4648
]);

test/e2e/sources/debug-raw-wasm_test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {assert} from 'chai';
77
import {
88
$,
99
click,
10+
drainFrontendTaskQueue,
1011
enableExperiment,
1112
getBrowserAndPages,
1213
goToResource,
@@ -502,6 +503,8 @@ describe('Sources Tab', function() {
502503
await waitFor(PAUSE_BUTTON);
503504
});
504505

506+
// TODO: it should actually wait for rendering to finish.
507+
await drainFrontendTaskQueue();
505508
await checkBreakpointDidNotActivate();
506509
});
507510
});

test/shared/helper.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ async function performActionOnSelector(
8484
const element = await waitFor(selector, options?.root, undefined, queryHandler);
8585
try {
8686
await action(element);
87+
await drainFrontendTaskQueue();
8788
return element;
8889
} catch {
8990
// A bit of delay to not retry too often.
@@ -93,6 +94,17 @@ async function performActionOnSelector(
9394
});
9495
}
9596

97+
/**
98+
* Schedules a task in the frontend page that ensures that previously
99+
* handled tasks have been handled.
100+
*/
101+
export async function drainFrontendTaskQueue(): Promise<void> {
102+
const {frontend} = getBrowserAndPages();
103+
await frontend.evaluate(async () => {
104+
await new Promise(resolve => setTimeout(resolve, 0));
105+
});
106+
}
107+
96108
/**
97109
* @deprecated This method is not able to recover from unstable DOM. Use click(selector) instead.
98110
*/
@@ -101,6 +113,7 @@ export async function clickElement(element: puppeteer.ElementHandle, options?: C
101113
await waitForFunction(async () => {
102114
try {
103115
await element.click(options?.clickOptions);
116+
await drainFrontendTaskQueue();
104117
return true;
105118
} catch {
106119
return false;
@@ -116,6 +129,7 @@ export async function hoverElement(element: puppeteer.ElementHandle): Promise<vo
116129
await waitForFunction(async () => {
117130
try {
118131
await element.hover();
132+
await drainFrontendTaskQueue();
119133
return true;
120134
} catch {
121135
return false;
@@ -139,6 +153,7 @@ export const doubleClick =
139153
export const typeText = async (text: string) => {
140154
const {frontend} = getBrowserAndPages();
141155
await frontend.keyboard.type(text);
156+
await drainFrontendTaskQueue();
142157
};
143158

144159
export const pressKey =

0 commit comments

Comments
 (0)