Closed Bug 181096 Opened 22 years ago Closed 12 years ago

document.isSupported('HTML', '2.0') returns true in XHTML document loaded as text/xml which doesn't support the HTML DOM

Categories

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

defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: martin.honnen, Assigned: caillon)

Details

Attachments

(2 files, 3 obsolete files)

Beside the document.implementation.hasFeature check for the complete DOM implementation the DOM Level 2 Core introduces the method isSupported for node objects. When Mozilla loads XHTML documents with Content-Type text/xml then the document object is not a HTML document meaning document.write or document.images is not supported. Therefore I think a check document.isSupported('HTML', '2.0') should return false as the document node doesn't support the HTML DOM. However with both Netscape 7 and Mozilla 1.2b the check returns true. I will attach a test case document demonstrating that document.write etc are not supported but the isSupported check returns true.
Yeah, we should fix this.
Severity: normal → major
OS: Windows XP → All
Hardware: PC → All
Attached file test case
The previous test case causes a JavaScript error (although it does nevertheless demonstrate the probelem). But I attach a new test case here that doesn't cause the script error while demonstrating the problem.
Attachment #106908 - Attachment is obsolete: true
Patch is coming soon...
Assignee: jst → mcsmurf
Attached patch Patch 1 (obsolete) — Splinter Review
Attachment #106932 - Flags: review?(peterv)
.
Status: NEW → ASSIGNED
ccing jst, who owns this shit and so has to see this stuff... ;)
Comment on attachment 106932 [details] [diff] [review] Patch 1 This is wrong for the following reasons: 1) We don't support DOM HTML 1.0 in XHTML as XML either. 2) We _do_ support them both in XHTML as HTML, and your change would say we do not. 3) You're changing nsIDOMNode::IsSupported, and non-document nodes in XHTML as XML fully support all DOM HTML 1 and 2 methods.
Attachment #106932 - Flags: review?(peterv) → review-
ok, sorry this is somewhat complicated to me Reassign to default owner
Assignee: mcsmurf → jst
Status: ASSIGNED → NEW
I have other changes in my tree right now which prevent me from making a patch here, but you want to modify nsDocument::IsSupported() to do something like this: NS_IMETHODIMP nsDocument::IsSupported(const nsAString& aFeature, const nsAString& aVersion, PRBool* aReturn) { NS_ENSURE_ARG_POINTER(aReturn); nsAutoString feature(aFeature); if (feature.EqualsIgnoreCase("HTML") && !mContentType.EqualsIgnoreCase("text/html")) { *aReturn = PR_FALSE; return NS_OK; } return nsGenericElement::InternalIsSupported(aFeature, aVersion, aReturn); }
hm, ok perhaps I'll try it again
Attached patch Patch 2 (obsolete) — Splinter Review
Here's patch 2, the code from Christopher (thanks!)
Attachment #106932 - Attachment is obsolete: true
Attachment #107153 - Flags: review?(bzbarsky)
Comment on attachment 107153 [details] [diff] [review] Patch 2 I'd prefer not to base this on the content-type like that (since we may fix our application/xhtml+xml bug at some point). How about returning PR_FALSE unconditionally for the "html" feature here and implementing "nsHTMLDocument::IsSupported" which returns PR_TRUE? Since nsHTMLDocument subclasses nsDocument, that would do the right thing, methinks...
Attachment #107153 - Flags: review?(bzbarsky) → review-
HTML is defined to be true if both HTML and XML return true. So the places that return true for HTML also return true for XHTML, since we always support XML.
Attachment #107153 - Attachment is obsolete: true
Attachment #108339 - Flags: review?(bzbarsky)
Comment on attachment 108339 [details] [diff] [review] Make this work, as well as support the XHTML feature + nsAutoString feature(aFeature); Don't do that. In fact, fix the other places doing it. ;) + // XXX we don't support the HTML DOM on HTMLDocuments yet. + *aReturn = PR_FALSE; This part is just confused.... ;)
Attachment #108339 - Flags: review?(bzbarsky) → review-
Brain fart, there. Okay this is an interesting bug, now. Currently hasFeature and isSupported share the same code path, which is similar, but they need to return different things. I can make them do the right thing (as long as I'm thinking clearly) but now I'm just trying to figure out the best way to do that with minimal duplication of code....
Assignee: jst → caillon
What about HTMLEvents?
What about HTMLEvents?
QA Contact: stummala → ian
Priority: -- → P4
Component: DOM: Core → DOM: Core & HTML
QA Contact: ian → general
No longer relevant with the current implementation of isSupported
Status: NEW → 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

Creator:
Created:
Updated:
Size: