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

[EventTiming] Allow spurious inputs when looseCount is true

This CL is a tentative fix for some flaky tests. An assert_equals to 0
is sometimes failing, presumably because the test itself may cause some
inputs to occur. Hence, we only check that eventCounts is 0 when the
|looseCount| variable is set to false.

Bug: 1074048
Change-Id: I989ccdb7cb469ff24132bf17a3da9a43264ae6ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225293
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774650}
parent 0d8cf3b7
......@@ -204,21 +204,23 @@ function testCounts(t, resolve, looseCount, eventType, expectedCount) {
// Tests the given |eventType| by creating events whose target are the element with id
// 'target'. The test assumes that such element already exists. |looseCount| is set for
// eventTypes for which events would occur for other elements besides the target, so the
// counts will be larger.
// eventTypes for which events would occur for other interactions other than the ones being
// specified for the target, so the counts could be larger.
async function testEventType(t, eventType, looseCount=false) {
assert_implements(window.EventCounts, "Event Counts isn't supported");
assert_equals(performance.eventCounts.get(eventType), 0);
const target = document.getElementById('target');
if (requiresListener(eventType)) {
target.addEventListener(eventType, () =>{});
}
assert_equals(performance.eventCounts.get(eventType), 0, 'No events yet.');
const initialCount = performance.eventCounts.get(eventType);
if (!looseCount) {
assert_equals(initialCount, 0, 'No events yet.');
}
// Trigger two 'fast' events of the type.
await applyAction(eventType, target);
await applyAction(eventType, target);
await new Promise(t.step_func(resolve => {
testCounts(t, resolve, looseCount, eventType, 2);
testCounts(t, resolve, looseCount, eventType, initialCount + 2);
}));
// The durationThreshold used by the observer. A slow events needs to be slower than that.
const durationThreshold = 16;
......@@ -254,7 +256,7 @@ async function testEventType(t, eventType, looseCount=false) {
notCancelable(eventType));
// Shouldn't need async testing here since we already got the observer entry, but might as
// well reuse the method.
testCounts(t, resolve, looseCount, eventType, 3);
testCounts(t, resolve, looseCount, eventType, initialCount + 3);
})).observe({type: 'event', durationThreshold: durationThreshold});
});
// Cause a slow event.
......
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