Bug 245269 - setBaseAndExtent not setting focus as requested
Summary: setBaseAndExtent not setting focus as requested
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari Technology Preview
Hardware: Mac (Apple Silicon) macOS 12
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2022-09-16 01:36 PDT by Jamie Birch
Modified: 2023-03-14 21:49 PDT (History)
7 users (show)

See Also:


Attachments
HTML file reproducing the issue. (2.76 KB, text/html)
2022-09-16 01:36 PDT, Jamie Birch
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Birch 2022-09-16 01:36:29 PDT
Created attachment 462386 [details]
HTML file reproducing the issue.

STR:

1: Open attachment: setbaseandextent_not_setting_focus_as_requested_repro.html

2. Click the "Generate selection" button.

Expected results:
On-screen logger should report the resulting selection, which reflects the focusNode and focusOffset passed as parameters in the call to Selection.setBaseTextAndExtent():

{
    "focusNode": "#text:Text outside:",
    "focusOffset": 13,
    "anchorNode": "#text:_",
    "anchorOffset": 1
}

Actual results:
On-screen logger reports a different focusNode and focusOffset (the start of the text node from the neighbouring element):
{
    "focusNode": "#text:_",
    "focusOffset": 0,
    "anchorNode": "#text:_",
    "anchorOffset": 1
}

Firefox and Chrome produce the expected results.
Comment 1 Radar WebKit Bug Importer 2022-09-21 20:44:54 PDT
<rdar://problem/100254222>
Comment 2 Karl Dubost 2022-09-21 21:08:54 PDT
Spec: https://w3c.github.io/selection-api/#dom-selection-setbaseandextent
Tests: https://wpt.fyi/results/selection/setBaseAndExtent.html?label=experimental&label=master&aligned

I wonder how reliable the tests are with regards to the current spec.
Comment 3 Ahmad Saleem 2023-03-14 16:58:48 PDT
I think Selection API ‘Live Range’ fixed it since now we are passing all WPT tests cases mentioned by Comment 02 and also in the attached, I am gettign “Expected Result” using WebKit ToT and Safari Technology Preview 165.

{
    "focusNode": "#text:Text outside:",
    "focusOffset": 13,
    "anchorNode": "#text:_",
    "anchorOffset": 1
}
Comment 4 Ryosuke Niwa 2023-03-14 21:49:28 PDT
Nice