Bug 560256 - Ignore document.write() from external scripts when there is no proper insertion point. r=jonas.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user