Bug 560256 - Ignore document.write() from external scripts when there is no proper insertion point. r=jonas.

This commit is contained in:
Henri Sivonen
2010-06-19 09:38:41 +03:00
parent adbf79f53d
commit c259bec434
6 changed files with 54 additions and 2 deletions

View File

@@ -2169,12 +2169,34 @@ nsHTMLDocument::WriteCommon(const nsAString& aText,
(mWriteState == ePendingClose &&
!mPendingScripts.Contains(key)) ||
(mParser && !mParser->IsInsertionPointDefined())) {
if (mExternalScriptsBeingEvaluated) {
// Instead of implying a call to document.open(), ignore the call.
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"DocumentWriteIgnored",
nsnull, 0,
mDocumentURI,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM Events");
return NS_OK;
}
mWriteState = eDocumentClosed;
mParser->Terminate();
NS_ASSERTION(!mParser, "mParser should have been null'd out");
}
if (!mParser) {
if (mExternalScriptsBeingEvaluated) {
// Instead of implying a call to document.open(), ignore the call.
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"DocumentWriteIgnored",
nsnull, 0,
mDocumentURI,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM Events");
return NS_OK;
}
rv = Open();
// If Open() fails, or if it didn't create a parser (as it won't