Closed Bug 271237 Opened 20 years ago Closed 20 years ago

Document served through application/xhtml+xml generates uncaught exception if document.write is used

Categories

(SeaMonkey :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 68193

People

(Reporter: k.r.hughes, Unassigned)

References

()

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0 When a page is served with application/xhtml+xml as mime-type, and document.write is used, an uncaught exception will show up in your JS console. It's logical that document.write doesn't work in this case, but shouldn't there be a proper error or something? Reproducible: Always Steps to Reproduce: 1. Visit a site using document.write and being served with application/xhtml+xml 2. Observe JS console Actual Results: Error: uncaught exception: [Exception... "Object cannot be created in this context" code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)" location: "http://juicystudio.com/mimetest/docwrite.js Line: 1"] Expected Results: Return a proper error.
Assignee: bugs → general
Component: Web Site → Browser-General
Product: Firefox → Browser
QA Contact: general
Version: unspecified → Trunk
seems like a perfectly reasonable error. do you want a pretty message telling users that it doesn't make sense to use document.write with xml and that they should use dom apis to create nodes and append them?
(In reply to comment #1) > seems like a perfectly reasonable error. do you want a pretty message telling > users that it doesn't make sense to use document.write with xml and that they > should use dom apis to create nodes and append them? Well, why not?
Product: Browser → Seamonkey
(In reply to comment #0) > When a page is served with application/xhtml+xml as mime-type, and > document.write is used, an uncaught exception will show up in your JS console. > It's logical that document.write doesn't work in this case, [...] No, it is not. ,-<http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-5353782642> | | 1.3. XHTML and the HTML DOM | | [...] | Note: The interfaces provided in this document are only for [HTML 4.01] and | [XHTML 1.0] documents and are not guaranteed to work with any future version | of XHTML. ,-http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-26809268 | | 1.5. Objects related to HTML documents | | Interface HTMLDocument | [...] | interface HTMLDocument : Document { | [...] | void write(in DOMString text); | void writeln(in DOMString text); | [...] | } | | write | Write a string of text to a document stream opened by open(). Note that the | function will produce a document which is not necessarily driven by a DTD | and therefore might be produce an invalid result in the context of the | document. | | Parameters | | text of type DOMString | The string to be parsed into some structure in the document structure | model. | | No Return Value | No Exceptions | | writeln | Write a string of text followed by a newline character to a document stream | opened by open(). Note that the function will produce a document which is | not necessarily driven by a DTD and therefore might be produce an invalid | result in the context of the document | | Parameters | | text of type DOMString | The string to be parsed into some structure in the document structure | model. | | No Return Value | No Exceptions (see also: <http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/ecma-script-binding.html>) AIUI, the Specification refers to both HTML 4.01 and XHTML 1.0 documents when referring to "HTML documents" and so document.write(ln) applies to XHTML 1.0 documents as well (as it would be reasonable, taking into account that other HTML DOM methods work for XHTML 1.0 documents). There is no restriction to XHTML 1.0 documents that are served as text/html (although such appears to be nonsensical on closer inspection of the markup language's features, it is to be noted that document.write(ln) works then in Mozilla). It is stated that using the document.write(ln) method "might be produce an invalid result", however it does not forbid that the method is used in XHTML context at all. And it does not state in any way that the method may throw exceptions. PointedEars
*** This bug has been marked as a duplicate of 68193 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
I don't see how this is a dupe of 68193. I filed this bug about the error generated if document.write is used, not the fact document.write doesn't work.
Hmm, I just discovered that the testcase in 68193 (https://bugzilla.mozilla.org/attachment.cgi?id=24778&action=view) generates a 'document.write is not a function'. Why is there a difference between application/xhtml+xml and text/xml?
You need to log in before you can comment on or make changes to this bug.