Closed Bug 456798 Opened 16 years ago Closed 13 years ago

queryCommandSupported throws errors in Firefox 3.0.1

Categories

(Core :: DOM: Editor, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla9

People

(Reporter: linda167, Assigned: kaze)

References

Details

(Keywords: dev-doc-complete)

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Build Identifier: Mozilla/5.0, Firefox 3.0.1, OS: Mac OS X 10.5 and Windows NT 5.2

queryCommandSupported(sCmd) throws errors on all commands in Firefox. This method works fine in IE7 and Safari 3.1.2.

I have not found a command that it will not throw an error on. Here's the list of commands that I've tested:

Bold
Italic
Underline
Strikethrough
JustifyLeft
JustifyCenter
JustifyRight
InsertUnorderedList
InsertOrderedList
Outdent
Indent
ForeColor
RemoveFormat
InsertHorizaontalRule
Undo
Redo
CreateLink
Unlink
Superscript
Subscript

Reproducible: Always

Steps to Reproduce:
1. Call queryCommandSupported(sCmd) on any command supported by Mozilla's execCommand


Actual Results:  
Error

Expected Results:  
No error

Function should return true or false.
queryCommandSupported() isn't implemented yet, it's throwing an NS_ERROR_NOT_IMPLEMENTED exception.
Blocks: 424615
Severity: normal → enhancement
Attached file Testcase
This enumerates return values/exceptions thrown in queryCommandSupported(). Based on similar testcase from bug 408231.
Reproducible for me (with Firefox 3.6 and Firefox 4b7).
Every other browser I tested (Safari, Chrome, Opera, IE6-9) supports it correctly.

Is there any known workaround to see whether a certain command is supported?
Bug confirmed with the latest trunk, `queryCommandSupported' is not implemented.

As Firefox raises an NS_ERROR_NOT_IMPLEMENTED exception on `queryCommandEnabled("foo")', an easy workaround would be to use a try…catch around a `queryCommandEnabled' call:

  var enabled, supported;
  try {
    enabled   = document.queryCommandEnabled(sCmd);
    supported = document.queryCommandSupported(sCmd);
  } catch(e) {}

Implementing `queryCommandSupported' would be neat. I’d suggest to fix both behaviors at the same time:
 • document.queryCommandSupported('foo') should return `false';
 • document.queryCommandEnabled('foo') should return `false' without raising any exception — FWIW, that’s what Chromium does.
Status: UNCONFIRMED → NEW
Ever confirmed: true
(In reply to Fabien Cazenave (:kazé) from comment #4)
> Implementing `queryCommandSupported' would be neat. I’d suggest to fix both
> behaviors at the same time:
>  • document.queryCommandSupported('foo') should return `false';
>  • document.queryCommandEnabled('foo') should return `false' without raising
> any exception — FWIW, that’s what Chromium does.

Please!  :-)
Assignee: nobody → kaze
Keywords: dev-doc-needed
Attached patch patch proposal (obsolete) — Splinter Review
Rationale: a command is supported if it can be converted to an internal Midas
command.

This gives us +43 points on the Browserscope tests (+3.3%) — we’re reaching 50%! OK, that’s still far from Chrome’s 80% and Safari’s 66%…

The browserscope status (currentStatus.js) has been updated accordingly. I don’t think we need more tests for this patch but I can write some if you wish.
Attachment #553448 - Flags: review?(ehsan)
Finally got the TryServer results. I’m afraid I have to submit another patch:

56355 ERROR TEST-UNEXPECTED-FAIL | /tests/content/html/content/test/test_bug408231.html | queryCommandEnabled(not-a-command) result=false expected=exception

Working on it. :-/
Status: NEW → ASSIGNED
Attached patch patch proposalSplinter Review
fixes content/html/content/test/test_bug408231.html so that `document.queryCommandSupported("not-a-command")' is expected to return `false' instead of raising an exception.
Attachment #553448 - Attachment is obsolete: true
Attachment #553525 - Flags: review?(ehsan)
Attachment #553448 - Flags: review?(ehsan)
Comment on attachment 553525 [details] [diff] [review]
patch proposal

Looks great, thanks!
Attachment #553525 - Flags: review?(ehsan) → review+
Pushed to inbound.
http://hg.mozilla.org/mozilla-central/rev/be37d0418129
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
Documented, other than needing an example. If someone would like to add one, that would be fantastic:

https://developer.mozilla.org/en/DOM/document.queryCommandSupported

Mentioned on Firefox 9 for developers.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: