Closed Bug 921444 Opened 11 years ago Closed 7 years ago

extending selection (using Selection.extend()) on text in <p> fails with an error if focus is on other focusable element

Categories

(Core :: DOM: Editor, defect)

24 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1318312

People

(Reporter: ldd, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0 (Beta/Release) Build ID: 20130911155223 Steps to reproduce: 1. Load this fiddle: http://jsfiddle.net/lddubeau/DyKBd/ 2. Click the "Backwards" button. Actual results: No text is selected. The console will show something like: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsISelection.extend] @ http://fiddle.jshell.net/lddubeau/DyKBd/show/:51 Expected results: Roughly the same thing that happens when the "Backwards Workaround" button is clicked: 1. The letter "x" should be selected. 2. No error. The one thing I'm unsure of is where the focus should be. It seems this document does not say: https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html ** Observations ** 1. Clicking "Forwards" works without error. 2. The workaround consists solely in focusing the parent element of the text just before calling extend(). 3. Chrome generates no error. And clicking "Forward" or "Backwards" changes the focus to the parent of the text node. (Basically, changing the selection changes the element being focused to one of the end points of the range.)
Component: Untriaged → Selection
Product: Firefox → Core
If I modify the fiddle to make the <input> element a <p contenteditable="true"> element, I get the same error.
Summary: extending selection (using Selection.extend()) on text in <p> fails with an error if focus is on <input> → extending selection (using Selection.extend()) on text in <p> fails with an error if focus is on other focusable element
Extend fails because IsValidSelectionPoint returns false: http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsSelection.cpp#4623 IsValidSelectionPoint returns false because the mAncestorLimiter is the <input> element on the *document* selection. It seems the culprit SetAncestorLimiter call comes from editor (note: 'this' in frame #19 == 'aLimiter' in frame #0): #0 nsFrameSelection::SetAncestorLimiter (this=0x7fffb0ee9d60, aLimiter=0x7fffb1eb3bc0) #1 mozilla::Selection::SetAncestorLimiter (this=0x7fffb1c08900, aContent=0x7fffb1eb3bc0) #2 nsEditor::InitializeSelection (this=0x7fffbea04800, aFocusEventTarget=0x7fffb1eb3bc0) #3 nsEditor::OnFocus (this=0x7fffbea04800, aFocusEventTarget=0x7fffb1eb3bc0) #4 nsEditorEventListener::Focus (this=0x7fffb4760d60, aEvent=0x7fffb1ca1240) #5 nsEditorEventListener::HandleEvent (this=0x7fffb4760d60, aEvent=0x7fffb1ca1240) #6 nsEventListenerManager::HandleEventSubType #7 nsEventListenerManager::HandleEventInternal #8 nsEventListenerManager::HandleEvent #9 nsEventTargetChainItem::HandleEvent #10 nsEventTargetChainItem::HandleEventTargetChain #11 nsEventDispatcher::Dispatch #12 FocusBlurEvent::Run (this=0x7fffb1cfd100) #13 nsContentUtils::AddScriptRunner (aRunnable=0x7fffb1cfd100) #14 nsFocusManager::SendFocusOrBlurEvent #15 nsFocusManager::Focus #16 nsFocusManager::SetFocusInner #17 nsFocusManager::SetFocus #18 nsGenericHTMLElement::Focus (this=0x7fffb1eb3bc0, aError=...) #19 mozilla::dom::HTMLInputElement::Focus (this=0x7fffb1eb3bc0, aError=...)
Status: UNCONFIRMED → NEW
Component: Selection → Editor
Ever confirmed: true
OS: Linux → All
Hardware: x86_64 → All
This is still happening in Firefox 37. Since it's easy to reproduce and Mats already diagnosed the general problem, maybe someone could take a look?
Blocks: 1379415
Any idea what's going here Ehsan? Facebook is seeing a reproducible error breaking the status editor in Firefox only via this non descriptive NS_ERROR_FAILURE, STR in bug 1379415. At the very least it would be nice to get a more descriptive error since even looking at the nsFrameSelection code it's not clear what the user code is doing wrong.
Flags: needinfo?(ehsan)
I cannot reproduce comment #0 on the latest Nightly. This might be fixed by bug 1318312
I confirmed that this was fixed by bug 1318312
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
(In reply to Benoit Girard (:BenWa) from comment #4) > Any idea what's going here Ehsan? Facebook is seeing a reproducible error > breaking the status editor in Firefox only via this non descriptive > NS_ERROR_FAILURE, STR in bug 1379415. > > At the very least it would be nice to get a more descriptive error since > even looking at the nsFrameSelection code it's not clear what the user code > is doing wrong. Sorry for the delay, I was away on vacation! This was marked as a dupe of bug 1318312. Can you please verify that this has been fixed on your end? Thanks!
Flags: needinfo?(ehsan) → needinfo?(b56girard)
Facebook is definitely still hitting this error with React. We're trying to get better information from a custom build. It would really help if Firefox threw a more descriptive JS error since it's particularly hard to debug. I've emailed :ehsan directly for feedback. If the custom build is able to produce something more actionable I'll update with more information in a new bug.
Flags: needinfo?(b56girard)
You need to log in before you can comment on or make changes to this bug.