Bug 191714 - Input element gains focus when a selectstart event listener on document prevents the default action
Summary: Input element gains focus when a selectstart event listener on document preve...
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 11
Hardware: Mac Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
Keywords: InRadar
Depends on:
Reported: 2018-11-15 14:19 PST by bugged.dev
Modified: 2019-02-06 09:18 PST (History)
7 users (show)

See Also:

Reduction (437 bytes, text/html)
2018-11-19 22:36 PST, Ryosuke Niwa
no flags Details
Fixes the bug (7.40 KB, patch)
2018-11-20 01:39 PST, Ryosuke Niwa
koivisto: review+
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews125 for ios-simulator-wk2 (2.54 MB, application/zip)
2018-11-20 12:01 PST, EWS Watchlist
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description bugged.dev 2018-11-15 14:19:03 PST
When using a preventDefault in a selectstart handler, input nodes on the page will receive focus while the pointer is down and the pointer hovers over the input node.

This behavior is reproducible here:

This behavior is not reproducible in Chrome, Firefox, or Edge

Comment 1 Radar WebKit Bug Importer 2018-11-19 15:10:18 PST
Comment 2 Ryosuke Niwa 2018-11-19 22:36:07 PST
Created attachment 355312 [details]
Comment 3 Ryosuke Niwa 2018-11-20 01:08:24 PST
The problem here is that we keep firing selectstart after the mouse drag had already started when selectstart had been canceled. No other browser does this so we just need to fire it once and set m_mouseDownMayStartSelect to false thereafter.
Comment 4 Ryosuke Niwa 2018-11-20 01:39:01 PST
Created attachment 355325 [details]
Fixes the bug
Comment 5 Antti Koivisto 2018-11-20 05:16:44 PST
Comment on attachment 355325 [details]
Fixes the bug

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

> Source/WebCore/ChangeLog:15
> +        Fixed the bug by not firing selectstart if the default action ahd been prevented by the initial firing

Comment 6 EWS Watchlist 2018-11-20 12:01:15 PST
Comment on attachment 355325 [details]
Fixes the bug

Attachment 355325 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: https://webkit-queues.webkit.org/results/10090007

New failing tests:
Comment 7 EWS Watchlist 2018-11-20 12:01:17 PST
Created attachment 355354 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.13.6
Comment 8 Ryosuke Niwa 2018-11-20 15:56:37 PST
I don't think the iOS test failure is related to my patch.
Comment 9 Ryosuke Niwa 2018-11-20 16:12:27 PST
Committed r238409: <https://trac.webkit.org/changeset/238409>
Comment 10 Lucas Forschler 2019-02-06 09:18:25 PST
Mass move bugs into the DOM component.