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

[EventTiming] Wrap lines better in event-timing-test-utils

This CL addresses a forgotten nit from
https://chromium-review.googlesource.com/c/chromium/src/+/2191238/2/third_party/blink/web_tests/external/wpt/event-timing/resources/event-timing-test-utils.js#125

Change-Id: Ibf5d168d912294b1a5df4099c4d8c269ae505a91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199689
Auto-Submit: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768514}
parent 689d984a
......@@ -122,9 +122,9 @@ async function testDuration(t, id, numEntries, dur, fastDur, slowDur) {
return Promise.all([observerPromise, clicksPromise]);
}
// Apply events that trigger an event of the given |eventType| to be dispatched to the |target|. Some
// of these assume that the target is not on the top left corner of the screen, which means that
// (0, 0) of the viewport is outside of the |target|.
// Apply events that trigger an event of the given |eventType| to be dispatched to the
// |target|. Some of these assume that the target is not on the top left corner of the
// screen, which means that (0, 0) of the viewport is outside of the |target|.
function applyAction(eventType, target) {
const actions = new test_driver.Actions();
if (eventType === 'auxclick') {
......@@ -167,16 +167,25 @@ function applyAction(eventType, target) {
}
function requiresListener(eventType) {
return ['mouseenter', 'mouseleave', 'pointerdown', 'pointerenter', 'pointerleave', 'pointerout', 'pointerover', 'pointerup'].includes(eventType);
return ['mouseenter',
'mouseleave',
'pointerdown',
'pointerenter',
'pointerleave',
'pointerout',
'pointerover',
'pointerup'
].includes(eventType);
}
function notCancelable(eventType) {
return ['mouseenter', 'mouseleave', 'pointerenter', 'pointerleave'].includes(eventType);
}
// 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 events for which
// events would occur for other elements besides the target, so the counts will be larger.
// 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.
async function testEventType(t, eventType, looseCount=false) {
assert_implements(window.EventCounts, "Event Counts isn't supported");
assert_equals(performance.eventCounts.get(eventType), 0);
......@@ -192,7 +201,8 @@ async function testEventType(t, eventType, looseCount=false) {
assert_greater_than_equal(performance.eventCounts.get(eventType), 2,
`Should have at least 2 ${eventType} events`)
} else {
assert_equals(performance.eventCounts.get(eventType), 2, `Should have 2 ${eventType} events`);
assert_equals(performance.eventCounts.get(eventType), 2,
`Should have 2 ${eventType} events`);
}
// The durationThreshold used by the observer. A slow events needs to be slower than that.
const durationThreshold = 16;
......@@ -211,7 +221,8 @@ async function testEventType(t, eventType, looseCount=false) {
entry = eventTypeEntries[0];
assert_equals(eventTypeEntries.length, 1);
} else {
// The other events could also be considered slow. Find the one with the correct target.
// The other events could also be considered slow. Find the one with the correct
// target.
eventTypeEntries.forEach(e => {
if (e.target === document.getElementById('target'))
entry = e;
......@@ -229,7 +240,8 @@ async function testEventType(t, eventType, looseCount=false) {
assert_greater_than_equal(performance.eventCounts.get(eventType), 3,
`Should have at least 3 ${eventType} events`)
} else {
assert_equals(performance.eventCounts.get(eventType), 3, `Should have 3 ${eventType} events`);
assert_equals(performance.eventCounts.get(eventType), 3,
`Should have 3 ${eventType} events`);
}
resolve();
})).observe({type: 'event', durationThreshold: durationThreshold});
......@@ -237,4 +249,4 @@ async function testEventType(t, eventType, looseCount=false) {
// Cause a slow event.
let actionPromise = applyAction(eventType, target);
return Promise.all([actionPromise, observerPromise]);
}
\ No newline at end of file
}
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