From b08f319a19ea1a0bd6b63d1022b92a4e7c8aa775 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 3 May 2006 21:19:26 +0000 Subject: [PATCH] Don't half-support document.write in XHTML. Bug 332848, r=mrbkap, jst, sr=dvediz, a=dvediz --- content/html/document/src/nsHTMLDocument.cpp | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 2bc76a41d47..fe84bf40cf1 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -1904,13 +1904,14 @@ nsHTMLDocument::SetCookie(const nsAString& aCookie) nsresult nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace) { + if (IsXHTML()) { + // No calling document.open() on XHTML + + return NS_ERROR_DOM_NOT_SUPPORTED_ERR; + } + // If we already have a parser we ignore the document.open call. if (mParser) { - if (IsXHTML()) { - // No calling document.open() while we're parsing XHTML - - return NS_ERROR_DOM_NOT_SUPPORTED_ERR; - } return NS_OK; } @@ -2179,6 +2180,12 @@ nsHTMLDocument::Clear() NS_IMETHODIMP nsHTMLDocument::Close() { + if (IsXHTML()) { + // No calling document.close() on XHTML! + + return NS_ERROR_DOM_NOT_SUPPORTED_ERR; + } + nsresult rv = NS_OK; if (mParser && mWriteState == eDocumentOpened) { @@ -2242,6 +2249,12 @@ nsresult nsHTMLDocument::WriteCommon(const nsAString& aText, PRBool aNewlineTerminate) { + if (IsXHTML()) { + // No calling document.write*() on XHTML! + + return NS_ERROR_DOM_NOT_SUPPORTED_ERR; + } + nsresult rv = NS_OK; void *key = GenerateParserKey(); @@ -2262,10 +2275,6 @@ nsHTMLDocument::WriteCommon(const nsAString& aText, if (NS_FAILED(rv) || !mParser) { return rv; } - } else if (IsXHTML()) { - // No calling document.write*() while parsing XHTML! - - return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } static NS_NAMED_LITERAL_STRING(new_line, "\n");