Bug 45686 - Document in design mode should always have a selection range
Summary: Document in design mode should always have a selection range
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2010-09-13 10:50 PDT by webkit
Modified: 2022-07-26 21:52 PDT (History)
5 users (show)

See Also:

TC (1.48 KB, text/html)
2010-09-13 10:53 PDT, webkit
no flags Details
TC 2 (1.70 KB, text/html)
2010-09-13 11:21 PDT, webkit
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description webkit 2010-09-13 10:50:26 PDT
window.getSelection().rangeCount returns "0" (zero) for documents that have never been focused.

Other browsers (FF and Opera) return "1", having an empty range available at the very start of the <body> contents.

I'll include a simple TC to confirm it.
Comment 1 webkit 2010-09-13 10:53:17 PDT
Created attachment 67430 [details]
Comment 2 webkit 2010-09-13 11:21:25 PDT
Created attachment 67436 [details]
TC 2

Adding a new TC to debug better the behavior on other browsers. It looks like in this case, they return the range that represents the selection when the browser will have the first focus (with the TAB key, for example).
Comment 3 Ahmad Saleem 2022-07-26 12:52:49 PDT
I am not clear on web-spec and what is expected but Safari 15.6 on macOS 12.5 and Chrome Canary 106 have same behavior across both test case while Firefox Nightly 104 differ.

Safari 15.6 and Chrome Canary 106 show 'Number of ranges: 0' for both test cases. Although, Firefox Nightly shows 'Number of ranges: 1' for both test case but with different offset of 0 and 3 respectively in test cases.

Just wanted to share updated results. Thanks!