Closed Bug 1948647 Opened 1 year ago Closed 1 year ago

"first-input" event timing "event name" is decided incorrectly compared to the web platform tests

Categories

(Core :: DOM: Performance APIs, defect)

defect

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: canova, Assigned: canova)

References

Details

Attachments

(1 file)

I was looking at the wpt failures and saw a pattern, that usually says !EQ("pointerdown", "mousedown").

That is interesting because we have first-input implemented, but apparently we were getting the first input event name incorrectly and this check was failing when we were comparing the event with the first input event.

This is where we dispatch the first-input event timing in the spec: https://w3c.github.io/event-timing/#sec-dispatch-pending (in step 6).

I was comparing it with our implementation and it seems like it matches it. But then I looked at Chrome's implementation and it looks like it's slightly different than the spec (step 6.2.2). And wpt tests follow that implementation instead of the spec

Chrome's implementation shows:

else if ((event_timing_entry->name() == event_type_names::kMousedown ||
            event_timing_entry->name() == event_type_names::kClick ||
            event_timing_entry->name() == event_type_names::kKeydown) &&
           !first_pointer_down_event_timing_) {
  (dispatch the event..)
}

And in Firefox:

case ePointerClick:
case eKeyDown:
case eMouseDown: {
  (dispatch the event..)
  break;
}

Notice the missing !mPendingPointerDown check there (or the extra first_pointer_down_event_timing_ check in Chromium).

I will file a spec bug shortly. But I guess it means that we need to update our implementation + the spec.

The spec for dispatching the first-input event can be found here:
https://w3c.github.io/event-timing/#sec-dispatch-pending

Specifically step 6.2.2 handles this part of the code change.

The old code was following the spec, but some web-platform-tests were failing
because of it. After looking at the Chromium's codebase, I noticed that it
doesn't match the spec and it has this additional check. After adding it to our
code, it passes the tests as well. So it's clear that the spec doesn't match
the web platform tests or the Chromium implementation. It's more likely that
the spec needs to be updated.

Filed a spec bug here:
https://github.com/w3c/event-timing/issues/142

Discussed the issue with a spec author, in the bug I filed. It looks like we want to always take the first input event that is part of an interaction. It means that if a pointercancel comes, we should invalidate it. Otherwise always use the pointerdown event for the first-input. I'm updating the patch to match that behavior as well.

Attachment #9466611 - Attachment description: WIP: Bug 1948647 - Do not dispatch the first-input event if there is a pending pointer down r?sefeng → Bug 1948647 - Do not dispatch the first-input event if there is a pending pointer down r?sefeng
Attachment #9466611 - Attachment description: Bug 1948647 - Do not dispatch the first-input event if there is a pending pointer down r?sefeng → WIP: Bug 1948647 - Do not dispatch the first-input event if there is a pending pointer down r?sefeng
Attachment #9466611 - Attachment description: WIP: Bug 1948647 - Do not dispatch the first-input event if there is a pending pointer down r?sefeng → Bug 1948647 - Do not dispatch the first-input event if there is a pending pointer down r?sefeng

The severity field is not set for this bug.
:bas.schouten, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(bas)
Severity: -- → S2
Flags: needinfo?(bas)
Pushed by canaltinova@gmail.com: https://hg.mozilla.org/integration/autoland/rev/a54d2326fdca Do not dispatch the first-input event if there is a pending pointer down r=sefeng
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: