Open Bug 900644 Opened 11 years ago Updated 2 years ago

`Document.execCommand` does not work with clicking button without managing `Selection` because clicking button moves `Selection` outside the editing host

Categories

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

22 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: regis.gaughan, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:22.0) Gecko/20100101 Firefox/22.0 (Beta/Release) Build ID: 20130618035212 Steps to reproduce: In a contenteditable, if you try to execCommand('insertOrderedList') or 'insertUnorderedList' in these cases I get a [NS_ERROR_FAILURE: 2147500037]: 1. Try to exec with one line of text cursor anywhere 2. try to exec with all text selected (even if multiple lines) If multiple lines are present, and the execCommand is issued w/o all text selected, it seems to work. I've created jsFiddle: http://jsfiddle.net/rgthree/PMP4j/ Actual results: The browser does nothing an we get a [NS_ERROR_FAILURE: 2147500037] Expected results: An un/ordered list should have been inserted
In old FF17: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLDocument.execCommand] @ http://fiddle.jshell.net/rgthree/PMP4j/show/:27 Did you check that? http://helpful.knobs-dials.com/index.php/0x80004005_%28NS_ERROR_FAILURE%29_and_other_firefox_errors
Component: Untriaged → Editor
Flags: needinfo?(regis.gaughan)
Product: Firefox → Core
In FF 19.0.2 (Win) I get the "0x80004005" as well, but no further details except for [nsIDOMHTMLDocument.execCommand]. Regardless though, it's not an error in the example code. If you type one line of text and put the cursor anywhere in that line and hit the "OL" / "UL" button, it fails. Press enter for a newline and enter some text and put your cursor back to the first line and try again, it works.
Flags: needinfo?(regis.gaughan)

Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5

Currently, Document.execCommand never throws exceptions if it's an HTML/XHTML document. However, the testcase sill won't work because the testcase does not manage Selection by itself. Gecko moves Selection when user clicks a button, but Blink does not. And Blink tries to update somewhere if Selection is not in the editing host. E.g., you can check it with adding 2 lines, putting caret into the second line, and clicking outside the editing host before clicking a button. Then, you see the first line is always updated rather than last selected line in the editing host.

Once Gecko's selection handling is changed, the testcase will work in some cases, but it's not always expected result for users.

Component: DOM: Editor → DOM: Selection
OS: macOS → All
Hardware: x86 → All
Summary: [NS_ERROR_FAILURE: 2147500037] execCommand insertOrderedList / insertUnorderedList on single line or all selected → `Document.execCommand` does not work with clicking button without managing `Selection` because clicking button moves `Selection` outside the editing host
You need to log in before you can comment on or make changes to this bug.