Closed Bug 495081 Opened 16 years ago Closed 12 years ago

DOM hasFeature() inaccurate -- eg., says "MutationEvents" not supported when they are

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
minor

Tracking

()

RESOLVED WONTFIX

People

(Reporter: cchittleborough, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.9) Gecko/2009040820 Firefox/3.0.9 XPCOMViewer/1.0a1
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.9) Gecko/2009040820 Firefox/3.0.9 XPCOMViewer/1.0a1

The JS code
  document.implementation.hasFeature("MutationEvents", "2.0")
returns false, even though Firefox 3.0.x _does_ support DOMAttrModified and the other DOM Mutation events.

The fix is to add a line or two to content/base/src/nsGenericElement.cpp, near line 1360. I'd be glad to supply a patch, except that someone more knowledgable needs to check whether any other features are wrongly reported. (For instance, I understand that Firefox 3.5 will support the "Traversal" module of DOM Level 2.)

Reproducible: Always

Steps to Reproduce:
Execute the Javascript code
  document.implementation.hasFeature("MutationEvents", "2.0")
and note the result.

Actual Results:  
The expression returns false.

Expected Results:  
The expression should return true.

If my understanding is correct, this is a bug in Gecko.
Rough-draft, untested patch for discussion.

Changes gecko to report support for version "2.0" of "Traversal" and "MutationEvents".

Question: are there any other supported-but-not-reported features?
Component: General → DOM: Events
Product: Firefox → Core
QA Contact: general → events
Component: DOM: Events → DOM: Core & HTML
QA Contact: events → general
OS: Linux → All
Hardware: x86 → All
We don't like hasFeature.  The spec says to only return true for a fixed set of strings, for compat:

http://dvcs.w3.org/hg/domcore/raw-file/tip/dom-core.html#dom-domimplementation-hasfeature

<http://wiki.whatwg.org/wiki/DOM_features> suggests that only WebKit returns true for "MutationEvents" or "Traversal"; IE and Gecko do not.  So I'd say WebKit should change to match the majority, and make this bug WONTFIX.  Authors should be using actual feature-detection to determine support here.
Yes, please close this bug as WONTFIX.

One more reason to do so: DOM4 will provide a replacement for MutationEvents (see Goal #3 at http://www.w3.org/TR/2012/WD-dom-20120405/#goals) because "the old model was problematic".

But the main reason is that "hasFeature" is a bad design, just as Aryeh Gregor said. Testing for the existence of functions and methods is a much better approach.
Bug 801425 would fix this, by just making hasFeature() return true for everything.
Depends on: 801425
Bug 801425 has fixed this (by making hasFeature() always return true).
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: