Skip to content

script: Fire focusin/focusout - #46980

Merged
yezhizhen merged 4 commits into
servo:mainfrom
RichardTjokroutomo:focusin-out
Aug 5, 2026
Merged

yezhizhen merged 4 commits into
servo:mainfrom
RichardTjokroutomo:focusin-out

Conversation

@RichardTjokroutomo

@RichardTjokroutomo RichardTjokroutomo commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Add basic support for focusin/focusout FocusEvent type.
The code fires focusin/focusout unconditionally alongside focus/blur. Same-document scenarios work correctly, but cross-document cases (e.g. across iframes) have known gaps because FocusEvent's impl is not complete yet:

// TODO: Integrate this into the "focus update steps."
. Cross-document support will be addressed in a follow-up (subtask 2 of #46979).

Also fix a minor issue, to set composed flag for https://html.spec.whatwg.org/multipage/interaction.html#fire-a-focus-event

Testing: Existing WPT tests. There are some new passing & failling tests. For detail, see #46980 (comment)
Fixes: part of #46979

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 4, 2026
@RichardTjokroutomo

RichardTjokroutomo commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor Author

recent try run

10 new passing subtests; 4 new failling subtests.

New failling subtests:

  • /css/selectors/focus-in-focusin-event-001.html -> focus-visible & focus-within are not supported, so previous pass is false positive.
  • /focus/activeelement-after-nested-loses-focus.html -> This is a cross document scenario, where the test involved two iframes nested together. This test previously passes because focusin/focusout aren't supported yet; so it was a false positive.
  • /uievents/order-of-events/focus-events/focus-automated-blink-webkit.html -> The subtest that involves different document owner fails. Specifically, the subtest fails because servo didn't fire blur & focusout events, so it is a problem of the FocusEvent impl itself.

@RichardTjokroutomo
RichardTjokroutomo marked this pull request as draft August 4, 2026 09:59
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Comment thread components/script/dom/document/focus.rs
@RichardTjokroutomo
RichardTjokroutomo marked this pull request as ready for review August 5, 2026 06:25
@yezhizhen
yezhizhen self-requested a review August 5, 2026 09:16
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>

@yezhizhen yezhizhen left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have

  • refactored comment. Earlier it was too verbose, and casing is wrong. It should be lower case instead of "FocusOut" etc.
  • updated pr description. It used to say "only the case where all DOM nodes belong to the same document are considered,". But your code do fire focusout/focusin unconditionally.
  • updated wpt.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Aug 5, 2026
@yezhizhen
yezhizhen enabled auto-merge August 5, 2026 09:57
@yezhizhen
yezhizhen disabled auto-merge August 5, 2026 09:58
@yezhizhen yezhizhen changed the title script: add basic support for focusin/focusout script: Fire focusin/focusout Aug 5, 2026
@yezhizhen
yezhizhen enabled auto-merge August 5, 2026 10:00
@yezhizhen
yezhizhen added this pull request to the merge queue Aug 5, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 5, 2026
Merged via the queue into servo:main with commit c17ddb2 Aug 5, 2026
36 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 5, 2026
@RichardTjokroutomo
RichardTjokroutomo deleted the focusin-out branch August 6, 2026 03:31
RichardTjokroutomo added a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
Add basic support for `focusin`/`focusout` `FocusEvent` type.
The code fires focusin/focusout **unconditionally** alongside
focus/blur. Same-document scenarios work correctly, but cross-document
cases (e.g. across iframes) have known gaps because FocusEvent's impl is
not complete yet:

https://github.com/servo/servo/blob/49fa5106cac95620e985ede1c0ddf744709e6c62/components/script/dom/document/focus.rs#L273.
Cross-document support will be addressed in a follow-up (subtask 2 of
servo#46979).

Also fix a minor issue, to set composed flag for
https://html.spec.whatwg.org/multipage/interaction.html#fire-a-focus-event

Testing: Existing WPT tests. There are some new passing & failling
tests. For detail, see
servo#46980 (comment)
Fixes: part of servo#46979

---------

Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants