Commit 6d23f8b3 authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Commit Bot

[EventTiming] More flakiness fixes

This CL applies fixes similar to a previous: we do not assume that the
first callback to the PerformanceObserver will include the mousedown
entry and instead abort and wait until a further callback which does
include it.

Bug: 1074048
Change-Id: Ifdf01b0abae025fa67f3ff355324d4b6204111a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2204618
Auto-Submit: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769577}
parent 23a26a4e
...@@ -24,6 +24,8 @@ promise_test(async t => { ...@@ -24,6 +24,8 @@ promise_test(async t => {
const afterFirstClick = performance.now(); const afterFirstClick = performance.now();
new PerformanceObserver(t.step_func(list => { new PerformanceObserver(t.step_func(list => {
const mouseDowns = list.getEntriesByName('mousedown'); const mouseDowns = list.getEntriesByName('mousedown');
if (mouseDowns.length === 0)
return;
assert_equals(mouseDowns.length, 1, 'Should only observe 1 click!'); assert_equals(mouseDowns.length, 1, 'Should only observe 1 click!');
assert_greater_than(mouseDowns[0].processingStart, afterFirstClick, assert_greater_than(mouseDowns[0].processingStart, afterFirstClick,
'The entry should not be the first click!!'); 'The entry should not be the first click!!');
......
...@@ -15,6 +15,8 @@ async_test(function(t) { ...@@ -15,6 +15,8 @@ async_test(function(t) {
assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.'); assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
const observer = new PerformanceObserver(t.step_func_done((entryList) => { const observer = new PerformanceObserver(t.step_func_done((entryList) => {
const entries = entryList.getEntries().filter(e => e.name === 'mousedown'); const entries = entryList.getEntries().filter(e => e.name === 'mousedown');
if (entries.length === 0)
return;
// There must only be one click entry. // There must only be one click entry.
assert_equals(entries.length, 1); assert_equals(entries.length, 1);
const entry = entries[0]; const entry = entries[0];
......
...@@ -8,7 +8,10 @@ ...@@ -8,7 +8,10 @@
const clickTimeMin = performance.now(); const clickTimeMin = performance.now();
const observerPromise = new Promise(resolve => { const observerPromise = new Promise(resolve => {
new PerformanceObserver(entryList => { new PerformanceObserver(entryList => {
resolve(entryList.getEntries().filter(entry => entry.name === 'mousedown')); const mouseDowns = entryList.getEntriesByName('mousedown');
if (mouseDowns.length === 0)
return;
resolve(mouseDowns);
}).observe({ type:'event' }); }).observe({ type:'event' });
}); });
const entries = await observerPromise; const entries = await observerPromise;
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
async_test(function(t) { async_test(function(t) {
assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.'); assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
new PerformanceObserver(t.step_func(entryList => { new PerformanceObserver(t.step_func(entryList => {
if (entryList.getEntriesByName('mousedown')) { if (entryList.getEntriesByName('mousedown').length > 0) {
validateEntries(); validateEntries();
t.done(); t.done();
} }
......
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