queryCommandSupported throws errors in Firefox 3.0.1

RESOLVED FIXED in mozilla9

Status

()

Core
Editor
--
enhancement
RESOLVED FIXED
9 years ago
6 years ago

People

(Reporter: linda167, Assigned: kaze)

Tracking

({dev-doc-complete})

unspecified
mozilla9
dev-doc-complete
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

9 years ago
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
Created attachment 340231 [details]
Testcase

This enumerates return values/exceptions thrown in queryCommandSupported(). Based on similar testcase from bug 408231.

Comment 3

6 years ago
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?
(Assignee)

Comment 4

6 years ago
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
(Assignee)

Comment 6

6 years ago
Created attachment 553448 [details] [diff] [review]
patch proposal

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)
(Assignee)

Comment 7

6 years ago
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
(Assignee)

Comment 8

6 years ago
Created attachment 553525 [details] [diff] [review]
patch proposal

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
Last Resolved: 6 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.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.