Closed
Bug 434998
Opened 16 years ago
Closed 13 years ago
contentDocument.execCommand gives error in <editor> FF3 RC1 (NS_ERROR_FAILURE)
Categories
(Core :: DOM: Editor, defect)
Core
DOM: Editor
Tracking
()
RESOLVED
FIXED
mozilla8
People
(Reporter: pk, Assigned: ehsan.akhgari)
References
Details
(Keywords: dev-doc-complete)
Attachments
(3 files)
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; nb-NO; rv:1.9) Gecko/2008051202 Firefox/3.0 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; nb-NO; rv:1.9) Gecko/2008051202 Firefox/3.0 I'm updating my extension for Firefox 3, and I have a XUL editor, where xulEditor.contentDocument.queryCommandState('bold') now fails and gives the following error: Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLDocument.queryCommandState]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" Worked fine in Firefox 2. Can't seem to get around this. Any ideas? Reproducible: Always Steps to Reproduce: 1. Set up a XUL editor field in chrome. 2. Try to query the commandstate within the editing document using xulEditor.contentDocument.queryCommandState('bold')
Updated•16 years ago
|
Component: General → Editor
Product: Firefox → Core
QA Contact: general → editor
Reporter | ||
Comment 1•16 years ago
|
||
Reporter | ||
Updated•16 years ago
|
Severity: normal → critical
Reporter | ||
Updated•16 years ago
|
Summary: queryCommandState crashes in regard to XUL editor (NS_ERROR_FAILURE) → contentDocument.queryCommandState and execCommand crashes in regard to XUL editor in chrome (NS_ERROR_FAILURE)
Comment 2•16 years ago
|
||
I can confirm that this worked in 1.9b2pre, but does not work in latest 1.9pre
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 3•16 years ago
|
||
Per-Kristian - a narrowed regress range would be helpful. See if you can find the Firefox nightly that started throwing exceptions.
Reporter | ||
Comment 4•16 years ago
|
||
Thank you for the confirmation mfinkle, I'll see if I can find it.
Summary: contentDocument.queryCommandState and execCommand crashes in regard to XUL editor in chrome (NS_ERROR_FAILURE) → contentDocument.execCommand gives error in FF3 RC1 (NS_ERROR_FAILURE)
Reporter | ||
Comment 5•16 years ago
|
||
It happened in https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2008/04/2008-04-18-04-trunk/
Reporter | ||
Comment 6•16 years ago
|
||
mfinkle found out that <browser> doesn't have these problems, so a temporary workaround is to user browser instead of editor. Then in order to get <editor> stuff: var myBrowser = document.getElementById('myBrowser'); var editingSession = myBrowser.webNavigation.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIEditingSession); myBrowser.contentDocument.designMode = 'on'; var editor = editingSession.getEditorForWindow(myBrowser.contentWindow); var commandManager = myBrowser.webNavigation.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsICommandManager); var htmlEditor = editor.QueryInterface(Components.interfaces.nsIHTMLEditor); Works for now, until this bug is fixed.
Summary: contentDocument.execCommand gives error in FF3 RC1 (NS_ERROR_FAILURE) → contentDocument.execCommand gives error in <editor> FF3 RC1 (NS_ERROR_FAILURE)
Comment 7•16 years ago
|
||
For some reason the mEditingState is set to eOff when checked here: http://mxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp#4450 I'm not sure why yet.
Comment 8•16 years ago
|
||
Maybe this was caused by Bug 428844, which was checked in on 2008-04-17? That changed how we tore down the editor. The old editor is tore down before the new one is setup, maybe that's failing...
Comment 9•16 years ago
|
||
mEditingState is eOff because SetDesignMode considers setting designMode='on' to be redundant for a document that is already editable, see http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/content/html/document/src/nsHTMLDocument.cpp&rev=3.785&mark=4139-4140#4121 Fixing this will probably require quite a bit of changes. What does using an editor element with designMode="on" give that a simple editor element or a browser element with designMode="on" doesn't? Unless there's an important advantage I don't think this is a high priority bug.
Reporter | ||
Comment 10•16 years ago
|
||
It has property commandManager, and methods getHTMLEditor and getEditor for instance. But the critical point is that the editor element simply doesn't work for what it is designed for, to edit stuff. So all extensions and such using a <editor> will not work, and break stuff when it comes down to executing commands like bold, italic, link, etc. I can't see how that can not be critical?
Comment 11•16 years ago
|
||
Executing commands like cmd_bold, ... with the commandManager is broken?
Comment 12•16 years ago
|
||
Using the commandManager works fine for me?
Reporter | ||
Comment 13•16 years ago
|
||
Using commandManager like that works here too. But not contentDocument.execCommand (and similar calls) as it did before 2004-04-18. Quote from http://developer.mozilla.org/en/docs/XUL:editor <blockquote> Once editable, the document can have special formatting and other HTML pieces added to it using the document.execCommand method: var editor = document.getElementById("myEditor"); // toggle bold for the current selection editor.contentDocument.execCommand("bold", false, null); </blockquote> I suppse it's not only my code that will suffer from this bug.
Comment 14•16 years ago
|
||
I have a similar problem in FF3 when trying to use execCommand on an iframe editor see https://bugzilla.mozilla.org/show_bug.cgi?id=457332. This bug did not exist in FF1 or 2 and works in other browsers.
Comment 15•15 years ago
|
||
Same error with Fx 3.1 on linux. But I have fixed the problem by adding contenteditable="true" in a HTML element of the content document.
Assignee | ||
Comment 17•13 years ago
|
||
For <xul:editor>, the HTML document's mEditingState ended up being eOff, which effectively disables the execCommand API. This patch is a simple fix for that.
Comment on attachment 546023 [details] [diff] [review] Patch (v1) Review of attachment 546023 [details] [diff] [review]: -----------------------------------------------------------------
Attachment #546023 -
Flags: review?(roc) → review+
Assignee | ||
Comment 19•13 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/901d098a58c6
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Flags: in-testsuite+
Keywords: dev-doc-needed
OS: Mac OS X → All
Hardware: PowerPC → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
Version: unspecified → Trunk
Comment 20•13 years ago
|
||
Try run for fe3b8f619f5c is complete. Detailed breakdown of the results available here: http://tbpl.mozilla.org/?tree=Try&rev=fe3b8f619f5c Results: success: 148 warnings: 13 failure: 2 Total buildrequests: 163
Comment 21•13 years ago
|
||
This bug fix is noted here: https://developer.mozilla.org/en/Firefox_8_for_developers#XUL
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•