Open Bug 787305 Opened 13 years ago Updated 3 years ago

nslSelection.collapse causes error when contenteditable container not active

Categories

(Core :: DOM: Selection, defect, P5)

x86_64
macOS
defect

Tracking

()

UNCONFIRMED

People

(Reporter: testing9999, Unassigned)

Details

(Keywords: testcase)

Attachments

(2 files)

Attached file index.html
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.82 Safari/537.1 Steps to reproduce: Open the following page in FF, click on the contentEditable div, press a key, and wait two seconds. <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <script> $(function() { var r; $("#mydiv").keypress(function() { r = document.getSelection().getRangeAt(0); $("#mytext").focus(); setTimeout(function() { var sel = window.getSelection(); var div = $("#mydiv")[0]; var c = r.endContainer; var o = r.endOffset; // Uncomment this line to fix the error //$("#mydiv")[0].focus(); if (r.collapsed) { sel.collapse(c, o); } $("#mydiv")[0].focus(); }, 2000); }); }); </script> </head> <body> <div contenteditable="true" id="mydiv" style="border: 1px solid black; width: 200px;"> <br/> </div> <input type="text" id="mytext"></input> </body> </html> Actual results: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsISelection.collapse] [Break On This Error] sel.collapse(c, o); Expected results: No errors. Note that if the line to focus the div is uncommented, then the error doesn't happen.
Hardware: x86 → x86_64
The error is copied from Firebug console ("[break on this error]" was from the button beside the error). (I am trying to attach a screenshot, but can't seem to be able to do so when adding this comment?)
Attachment #657131 - Attachment mime type: text/plain → text/html
Reproduced with: Fx 15.0: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0 20120824154833 Nightly: Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/18.0 Firefox/18.0 20120903030551
bug 773137 has similar symptoms.
Component: Untriaged → DOM
Keywords: testcase
Product: Firefox → Core
Version: 15 Branch → Trunk
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → Selection
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: