Open Bug 1149491 Opened 10 years ago Updated 2 years ago

window.getSelection() gives high rangeCounts

Categories

(Core :: DOM: Selection, defect)

36 Branch
x86_64
Linux
defect

Tracking

()

UNCONFIRMED

People

(Reporter: net, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0 Build ID: 20150321212544 Steps to reproduce: 1. Visit http://en.wikipedia.org/wiki/Rattlesnakes_%28album%29 (for example) 2. From the menu, select all. 3. In Scratchpad, run alert(window.getSelection().rangeCount); Actual results: I see 14 ranges. Expected results: The docs say | Before the user has clicked a freshly loaded page, the rangeCount is | 0. A user can normally only select one range at a time, so the | rangeCount will usually be 1. https://developer.mozilla.org/en-US/docs/Web/API/Selection/ rangeCount and this was the behaviour of earlier Fx versions. Multiple ranges make it more difficult to extract the HTML source of a user selection in, e.g., bookmarklets.
Component: Untriaged → Selection
Product: Firefox → Core
Here's reduced case - https://jsfiddle.net/qjnu2wpf/ I spotted this interesting behavior when checking GitLab bug (https://gitlab.com/gitlab-org/gitlab-ce/issues/31193#note_27816376) Can somebody recheck this 2+ year old bug? It reliably happens on latest Nightly
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.