Bug 220243 - [selectors] :focus should match inside the focus event
Summary: [selectors] :focus should match inside the focus event
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Manuel Rego Casasnovas
URL:
Keywords: BrowserCompat, InRadar, WebExposed
Depends on:
Blocks: 220312
  Show dependency treegraph
 
Reported: 2021-01-04 08:32 PST by Manuel Rego Casasnovas
Modified: 2021-01-05 05:41 PST (History)
9 users (show)

See Also:


Attachments
Patch (4.73 KB, patch)
2021-01-04 08:35 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (6.62 KB, patch)
2021-01-04 08:48 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (10.72 KB, patch)
2021-01-04 14:29 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (10.98 KB, patch)
2021-01-05 02:00 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (11.08 KB, patch)
2021-01-05 04:27 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Rego Casasnovas 2021-01-04 08:32:33 PST
The specs seem clear about the expected behavior for this:
- From https://drafts.csswg.org/selectors-4/#the-focus-pseudo:
  "The :focus pseudo-class applies while an element has the focus"
- From https://w3c.github.io/uievents/#event-type-focus:
  "The focus MUST be given to the element before the dispatch of this event type"

Also Chromium and Firefox already does this.
Comment 1 Manuel Rego Casasnovas 2021-01-04 08:35:56 PST
Created attachment 416944 [details]
Patch
Comment 2 EWS Watchlist 2021-01-04 08:36:50 PST
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 3 Manuel Rego Casasnovas 2021-01-04 08:48:21 PST
(In reply to EWS Watchlist from comment #2)
> This patch modifies the imported WPT tests. Please ensure that any changes
> on the tests (not coming from a WPT import) are exported to WPT. Please see
> https://trac.webkit.org/wiki/WPTExportProcess

The test is not yet in WPT, but it's going to be there before merging this change in WebKit.
The test was originally a Chromium internal test and it's being moved upstream in the following Chromium patch: https://chromium-review.googlesource.com/c/chromium/src/+/2610084
Comment 4 Manuel Rego Casasnovas 2021-01-04 08:48:50 PST
Created attachment 416945 [details]
Patch
Comment 5 Sergio Villar Senin 2021-01-04 09:42:16 PST
The patch seems correct but it's causing failures in several tests so please do address them.
Comment 6 Manuel Rego Casasnovas 2021-01-04 14:29:26 PST
Created attachment 416965 [details]
Patch
Comment 7 Manuel Rego Casasnovas 2021-01-04 21:37:52 PST
The WPT test has been already merged upstream, and the EWSs are green now.
Comment 8 Manuel Rego Casasnovas 2021-01-05 02:00:22 PST
Created attachment 416977 [details]
Patch
Comment 9 Frédéric Wang (:fredw) 2021-01-05 04:12:00 PST
Comment on attachment 416977 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=416977&action=review

LGTM, but I'd rather tweak the WPT tests first and reimport all in preliminary patch.

> Source/WebCore/ChangeLog:9
> +        The specs seem clear about the expected behavior for this:

nit: s/is/seem/ ?

> Source/WebCore/ChangeLog:15
> +        A similar fix has been done on Blink in r201118 by <kochi@chromium.org>.

maybe add a reference to https://src.chromium.org/viewvc/blink?revision=201118&view=revision ?

> LayoutTests/ChangeLog:11
> +        and these tests will be re-imported and unskipped in a follow-up patch.

Maybe it would be better to import all sync changes in a preliminary patch, and then just changes the expectation in this patch.

> LayoutTests/imported/w3c/ChangeLog:11
> +        - focus-visible-005.html now fails, but it was passing because it was checking anything due to this bug.

was not

> LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-in-focus-event-001-expected.txt:3
> +PASS Checks that ':focus' pseudo-class matches inside 'focus' evente handler

event handler

> LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-in-focus-event-001.html:17
> +  }, "Checks that ':focus' pseudo-class matches inside 'focus' evente handler");

event handler
Comment 10 Manuel Rego Casasnovas 2021-01-05 04:26:36 PST
(In reply to Frédéric Wang (:fredw) from comment #9)
> Comment on attachment 416977 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=416977&action=review
> 
> LGTM, but I'd rather tweak the WPT tests first and reimport all in
> preliminary patch.

Thanks for the review, I believe I prefer the current order, as the modified tests won't do anything useful without this patch. And this patch is about fixing a clear issue with its own WPT test, so I prefer not to mix it too much with the :focus-visible tests, skipping them sounds fine so far as we don't have any implementation. And also I already have the patch in the related but to update them.

> 
> > Source/WebCore/ChangeLog:9
> > +        The specs seem clear about the expected behavior for this:
> 
> nit: s/is/seem/ ?

Fixed.

> 
> > Source/WebCore/ChangeLog:15
> > +        A similar fix has been done on Blink in r201118 by <kochi@chromium.org>.
> 
> maybe add a reference to
> https://src.chromium.org/viewvc/blink?revision=201118&view=revision ?

Done.

> 
> > LayoutTests/ChangeLog:11
> > +        and these tests will be re-imported and unskipped in a follow-up patch.
> 
> Maybe it would be better to import all sync changes in a preliminary patch,
> and then just changes the expectation in this patch.

As mentioned earlier, I'll do it the other way around.

> 
> > LayoutTests/imported/w3c/ChangeLog:11
> > +        - focus-visible-005.html now fails, but it was passing because it was checking anything due to this bug.
> 
> was not

Nice catch, fixed too.

> 
> > LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-in-focus-event-001-expected.txt:3
> > +PASS Checks that ':focus' pseudo-class matches inside 'focus' evente handler
> 
> event handler

Ack.

> 
> > LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-in-focus-event-001.html:17
> > +  }, "Checks that ':focus' pseudo-class matches inside 'focus' evente handler");
> 
> event handler

Fixed upstream: https://github.com/web-platform-tests/wpt/pull/27042
Comment 11 Manuel Rego Casasnovas 2021-01-05 04:27:55 PST
Created attachment 416990 [details]
Patch
Comment 12 EWS 2021-01-05 05:40:20 PST
Committed r271146: <https://trac.webkit.org/changeset/271146>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 416990 [details].
Comment 13 Radar WebKit Bug Importer 2021-01-05 05:41:15 PST
<rdar://problem/72810530>