Bug 140596

Summary: UI Events: Focus event sequence incorrect
Product: WebKit Reporter: Rodney Rehm <mail>
Component: UI EventsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, ap, rniwa, webkit
Priority: P2 Keywords: HasReduction, W3CTest
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
URL: https://w3c.github.io/uievents/#events-focusevent-event-order
See Also: http://code.google.com/p/chromium/issues/detail?id=449857
Attachments:
Description Flags
focus-event-sequence.html none

Description Rodney Rehm 2015-01-18 11:46:02 PST
Created attachment 244864 [details]
focus-event-sequence.html

# Steps to reproduce the problem:
1. register event listeners for focusout, blur, focusin, focus
2. observe sequence of dispatched events upon shifting focus

Live test-case: http://medialize.github.io/ally.js/tests/browser-bugs/focus-event-order.html


# What is the expected behavior?
The sequence per DOM Level 3 [1] should be: focusout, focusin, blur, focus

[1] https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-event-order


# What went wrong?
sequence is blur, focusout, focus, focusing


With the currently provided sequence the focusout and focusin events cannot be safely used to alter focus before it was given. The only "benefit" the current implementation brings with focusin over focus is that the former bubbles, the latter does not.

Gecko doesn't support focusin/focusout at all. WebKit suffers the same bug. IE11 dispatches focus events asynchronously thereby accidentally getting the sequence right, IE12 Win10 Tec Preview fixed the ansynchronous-bug and thereby messed up the sequence as well.

Chromium bug for reference: https://code.google.com/p/chromium/issues/detail?id=449857
Comment 1 Chris Rebert 2016-05-26 13:17:32 PDT
Another testcase: http://w3c-test.org/uievents/order-of-events/focus-events/focus-manual.html
Comment 2 Ahmad Saleem 2022-08-06 15:15:36 PDT
We pass following WPT tests - https://wpt.fyi/results/uievents/order-of-events/focus-events/focus-automated-blink-webkit.html?label=master&label=experimental&aligned&view=subtest&q=focus-event

Which are in relation to "order of event" similar to Comment 01.

I am going to mark this as "RESOLVED CONFIGURATION CHANGED", since we are passing related WPT tests. Please reopen, if I am wrong. Thanks!