Commit abaaee14 authored by Wanming Lin's avatar Wanming Lin Committed by Chromium LUCI CQ

[WebUI] Make some webUI related tests use setTimeout 1

Currently SetTimeout(..., 0) is clamped up to 1ms while which is
not supposed to be in the spec. The Speedometer2 performance can boost
~1% on Windows without it based on Pinpoint perf. This CL is intended
to fix the devtool tests that become flaky with

https://chromium-review.googlesource.com/c/chromium/src/+/2578703

Flaky tests list:

* chrome/test/data/webui/new_tab_page/utils_test.js
* chrome/test/data/webui/test_util.js

Bug: 402694
Change-Id: I98d385cd8089e713040ab2969083bfbc16372c48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600274Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: Wanming Lin <wanming.lin@intel.com>
Cr-Commit-Position: refs/heads/master@{#839309}
parent 4a7ca9c8
......@@ -6,7 +6,7 @@
import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
import {createScrollBorders, decodeString16, mojoString16} from 'chrome://new-tab-page/new_tab_page.js';
import {waitAfterNextRender} from 'chrome://test/test_util.m.js';
import {flushTasks, waitAfterNextRender} from 'chrome://test/test_util.m.js';
suite('scroll borders', () => {
/** @type {!HTMLElement} */
......@@ -44,6 +44,7 @@ suite('scroll borders', () => {
bottom = document.body.lastElementChild;
observer = createScrollBorders(container, top, bottom, 'show');
await waitAfterNextRender();
await flushTasks();
});
teardown(() => {
......@@ -58,6 +59,7 @@ suite('scroll borders', () => {
test('borders shown when content available above and below', async () => {
container.scrollTop = 10;
await waitAfterNextRender();
await flushTasks();
assertShown(top);
assertShown(bottom);
});
......@@ -65,6 +67,7 @@ suite('scroll borders', () => {
test('bottom border hidden when no content available below', async () => {
container.scrollTop = 200;
await waitAfterNextRender();
await flushTasks();
assertShown(top);
assertHidden(bottom);
});
......@@ -72,6 +75,7 @@ suite('scroll borders', () => {
test('borders hidden when all content is shown', async () => {
content.style.height = '100px';
await waitAfterNextRender();
await flushTasks();
assertHidden(top);
assertHidden(bottom);
});
......
......@@ -132,7 +132,7 @@ cr.define('test_util', function() {
// Promises have microtask timing, so we use setTimeout to explicitly force
// a new task.
return new Promise(function(resolve, reject) {
window.setTimeout(resolve, 0);
window.setTimeout(resolve, 1);
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment