Bug 199211

Summary: Selection highlight not shown on programmatic focus after initial load
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, ews-watchlist, megan_gardner, rniwa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: iPhone / iPad   
OS: Unspecified   
URL: data:text/html,<p>Hello World</p><script>let p = document.querySelector("p"); window.getSelection().setBaseAndExtent(p.firstChild, 0, p.firstChild, 2)</script>
See Also: https://bugs.webkit.org/show_bug.cgi?id=199204
Attachments:
Description Flags
First stab
ews-watchlist: commit-queue-
Archive of layout-test-results from ews121 for ios-simulator-wk2
none
Simpler fix, let's see what happens
ews-watchlist: commit-queue-
Archive of layout-test-results from ews126 for ios-simulator-wk2 none

Description Daniel Bates 2019-06-25 16:38:34 PDT
Steps to reproduce:

Visit <data:text/html,<p>Hello World</p><script>let p = document.querySelector("p"); window.getSelection().setBaseAndExtent(p.firstChild, 0, p.firstChild, 2)</script>>
Comment 1 Daniel Bates 2019-06-25 16:39:24 PDT
Created attachment 372874 [details]
First stab
Comment 2 EWS Watchlist 2019-06-25 18:39:46 PDT
Comment on attachment 372874 [details]
First stab

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

New failing tests:
editing/selection/selection-across-shadow-boundaries-readonly-2.html
imported/mozilla/svg/text/selectSubString-3.svg
fast/flexbox/flexbox-fail-to-select-same-line.html
editing/selection/update-selection-by-style-change.html
fast/text/international/hebrew-selection.html
fast/dynamic/selection-gets-cleared-when-part-of-it-gets-removed.html
svg/masking/mask-should-not-paint-selection.html
imported/blink/editing/selection/deleteFromDocument-crash.html
imported/mozilla/svg/text/multiple-chunks-selection.svg
fast/dynamic/remove-invisible-node-inside-selection.html
imported/mozilla/svg/text/selectSubString.svg
fast/dynamic/remove-node-inside-selection.html
Comment 3 EWS Watchlist 2019-06-25 18:39:48 PDT
Created attachment 372890 [details]
Archive of layout-test-results from ews121 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews121  Port: ios-simulator-wk2  Platform: Mac OS X 10.14.5
Comment 4 Daniel Bates 2019-06-26 10:49:07 PDT
(In reply to Build Bot from comment #2)
> Comment on attachment 372874 [details]
> First stab
> 
> Attachment 372874 [details] did not pass ios-sim-ews (ios-simulator-wk2):
> Output: https://webkit-queues.webkit.org/results/12575966
> 
> New failing tests:
> editing/selection/selection-across-shadow-boundaries-readonly-2.html
> imported/mozilla/svg/text/selectSubString-3.svg
> fast/flexbox/flexbox-fail-to-select-same-line.html
> editing/selection/update-selection-by-style-change.html
> fast/text/international/hebrew-selection.html
> fast/dynamic/selection-gets-cleared-when-part-of-it-gets-removed.html
> svg/masking/mask-should-not-paint-selection.html
> imported/blink/editing/selection/deleteFromDocument-crash.html
> imported/mozilla/svg/text/multiple-chunks-selection.svg
> fast/dynamic/remove-invisible-node-inside-selection.html
> imported/mozilla/svg/text/selectSubString.svg
> fast/dynamic/remove-node-inside-selection.html

These "failures" reveal various bugs in our code! Only one of the failures may indicate the patch is not quite right: svg/masking/mask-should-not-paint-selection.html, but quick glance at this test makes me think the mechanism to prevent selection is not enabled on iOS and the only reason we've been passing this test is because we do not paint selection on first load.

^^^ that last part is the reason for other failures in this list like fast/text/international/hebrew-selection.html. That is, we've been passing this test because both sides of the comparison have been broken. I fixed the -expected.html side, which uses programmatic selection API. The non-expected side used window.eventSender, which is known to be broken in WebKit2 on iOS. Haha
Comment 5 Daniel Bates 2019-06-26 10:49:30 PDT
Forgot to mention, other failure indicate a timing difference when we snapshot.
Comment 6 Daniel Bates 2019-06-26 11:51:41 PDT
Created attachment 372939 [details]
Simpler fix, let's see what happens
Comment 7 EWS Watchlist 2019-06-26 13:36:49 PDT
Comment on attachment 372939 [details]
Simpler fix, let's see what happens

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

New failing tests:
editing/selection/selection-across-shadow-boundaries-readonly-2.html
editing/selection/selection-across-shadow-boundaries-readonly-3.html
imported/mozilla/svg/text/selectSubString-3.svg
fast/flexbox/flexbox-fail-to-select-same-line.html
fast/text/international/hebrew-selection.html
editing/selection/update-selection-by-style-change.html
editing/selection/selection-across-shadow-boundaries-readonly-1.html
fast/dynamic/selection-gets-cleared-when-part-of-it-gets-removed.html
imported/blink/fast/text/international/repaint-glyph-bounds.html
svg/masking/mask-should-not-paint-selection.html
imported/mozilla/svg/text/multiple-chunks-selection.svg
imported/blink/editing/style/justify-left-crash.html
fast/dynamic/remove-invisible-node-inside-selection.html
imported/mozilla/svg/text/selectSubString.svg
svg/foreignObject/viewport-foreignobject-crash.html
fast/dynamic/remove-node-inside-selection.html
Comment 8 EWS Watchlist 2019-06-26 13:36:51 PDT
Created attachment 372945 [details]
Archive of layout-test-results from ews126 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews126  Port: ios-simulator-wk2  Platform: Mac OS X 10.14.5
Comment 9 Radar WebKit Bug Importer 2019-06-26 16:29:23 PDT
<rdar://problem/52217858>
Comment 10 Ahmad Saleem 2023-05-11 14:29:52 PDT
Using Comment 0:

Chrome Canary 115:

'He'llo World <--- He is selected.

Safari 16.4:

'He'llo World <--- He is selected.

WebKit ToT (Mini-Browser):

'He'llo World <--- He is selected.

Firefox Nightly 115:

'He'llo World <--- He is selected.

__________

All browsers are matching..

The platform mention is iOS / iPadOS. Is it for it or due to Selection API, it now works?

CCing - Ryosuke.
Comment 11 Ryosuke Niwa 2023-05-12 15:27:27 PDT
The issue still reproduces on iOS 16.4.1 (a)