Skip to content

Commit c6d1c81

Browse files
committed
Layout Test perf/clone-with-focus.html is a Flaky Failure
https://bugs.webkit.org/show_bug.cgi?id=201012 Reviewed by Antti Koivisto. The flakiness was observed when the time to clone elements without focus is 0ms but the time to clone elements with focus is 1ms or greater. The test tries to make sure the time to clone elements with foucs is less than 2x of the time to clone elements without focus. When the time to clone without focus is 0ms, any difference is always more than 2x larger. Fixed the test by increasing the number of elements until the time to clone without focus takes at least 5ms. * perf/clone-with-focus.html: Canonical link: https://commits.webkit.org/214734@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 5110efe commit c6d1c81

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2019-08-21 Ryosuke Niwa <rniwa@webkit.org>
2+
3+
Layout Test perf/clone-with-focus.html is a Flaky Failure
4+
https://bugs.webkit.org/show_bug.cgi?id=201012
5+
6+
Reviewed by Antti Koivisto.
7+
8+
The flakiness was observed when the time to clone elements without focus is 0ms
9+
but the time to clone elements with focus is 1ms or greater.
10+
11+
The test tries to make sure the time to clone elements with foucs is less than 2x
12+
of the time to clone elements without focus. When the time to clone without focus
13+
is 0ms, any difference is always more than 2x larger.
14+
15+
Fixed the test by increasing the number of elements until the time to clone without
16+
focus takes at least 5ms.
17+
18+
* perf/clone-with-focus.html:
19+
120
2019-08-21 Myles C. Maxfield <mmaxfield@apple.com>
221

322
[WHLSL] Vertex shader and fragment shader need to be able to come from two different programs

LayoutTests/perf/clone-with-focus.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@
1717
{
1818
if (focusInput)
1919
inputElement.focus();
20-
21-
var startTime = Date.now();
20+
21+
var startTime = performance.now();
2222
for (var i = 0; i < numberOfElements; i++) {
2323
var clone = templateElement.cloneNode(true);
2424
clone.childNodes[0].textContent = i;
2525
listElement.appendChild(clone);
2626
}
27-
var endTime = Date.now();
28-
27+
var endTime = performance.now();
28+
2929
if (focusInput)
3030
inputElement.blur();
31-
32-
while (listElement.firstChild != listElement.lastChild)
33-
listElement.removeChild(listElement.lastChild);
34-
31+
32+
const originalItem = listElement.firstChild;
33+
listElement.textContent = '';
34+
listElement.appendChild(originalItem);
35+
3536
return endTime - startTime;
3637
}
3738

@@ -42,8 +43,13 @@
4243
document.getElementById('console').appendChild(element);
4344
}
4445

45-
var timeWithoutFocus = test(1000, false);
46-
var timeWithFocus = test(1000, true);
46+
const start = performance.now();
47+
let factor = 0;
48+
while (test(1000 * factor, false) < 5)
49+
factor++;
50+
51+
var timeWithoutFocus = test(1000 * factor, false);
52+
var timeWithFocus = test(1000 * factor, true);
4753

4854
if (Math.abs(timeWithFocus - timeWithoutFocus) <= timeWithoutFocus) {
4955
log('PASS. Cloning elements takes roughly as long with as without focus.');

0 commit comments

Comments
 (0)