Prevent assertions when a document that has had document.open called is closed
suddenly (without an intervening document.close call). bug 332896, r=bzbarsky, sr=sicking git-svn-id: svn://10.0.0.236/trunk@200375 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
b60bbf2624
commit
abc730764f
@ -966,6 +966,19 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLDocument::StopDocumentLoad()
|
||||
{
|
||||
// If we're writing (i.e., there's been a document.open call), then
|
||||
// nsDocument::StopDocumentLoad will do the wrong thing and simply terminate
|
||||
// our parser.
|
||||
if (mWriteState != eNotWriting) {
|
||||
Close();
|
||||
} else {
|
||||
nsDocument::StopDocumentLoad();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsHTMLDocument::DocumentWriteTerminationFunc(nsISupports *aRef)
|
||||
@ -2191,6 +2204,12 @@ nsHTMLDocument::Close()
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mParser && mWriteState == eDocumentOpened) {
|
||||
mPendingScripts.RemoveElement(GenerateParserKey());
|
||||
|
||||
mWriteState = mPendingScripts.Count() == 0
|
||||
? eDocumentClosed
|
||||
: ePendingClose;
|
||||
|
||||
++mWriteLevel;
|
||||
if (mContentType.EqualsLiteral("text/html")) {
|
||||
rv = mParser->Parse(NS_LITERAL_STRING("</HTML>"),
|
||||
@ -2202,12 +2221,6 @@ nsHTMLDocument::Close()
|
||||
}
|
||||
--mWriteLevel;
|
||||
|
||||
mPendingScripts.RemoveElement(GenerateParserKey());
|
||||
|
||||
mWriteState = mPendingScripts.Count() == 0
|
||||
? eDocumentClosed
|
||||
: ePendingClose;
|
||||
|
||||
// XXX Make sure that all the document.written content is
|
||||
// reflowed. We should remove this call once we change
|
||||
// nsHTMLDocument::OpenCommon() so that it completely destroys the
|
||||
|
||||
@ -98,6 +98,7 @@ public:
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE,
|
||||
nsIContentSink* aSink = nsnull);
|
||||
virtual void StopDocumentLoad();
|
||||
|
||||
virtual void EndLoad();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user