Bug 688580, run deferred scripts before DOMContentLoaded, r=hsivonen

This commit is contained in:
Olli Pettay
2014-04-10 01:49:17 +03:00
parent dca99e78f0
commit c4bdd6bd4f
12 changed files with 209 additions and 13 deletions

View File

@@ -95,14 +95,14 @@ nsHtml5TreeOpExecutor::WillParse()
NS_IMETHODIMP
nsHtml5TreeOpExecutor::WillBuildModel(nsDTDMode aDTDMode)
{
mDocument->AddObserver(this);
WillBuildModelImpl();
GetDocument()->BeginLoad();
if (mDocShell && !GetDocument()->GetWindow() &&
!IsExternalViewSource()) {
// Not loading as data but script global object not ready
return MarkAsBroken(NS_ERROR_DOM_INVALID_STATE_ERR);
}
mDocument->AddObserver(this);
WillBuildModelImpl();
GetDocument()->BeginLoad();
return NS_OK;
}
@@ -111,8 +111,6 @@ nsHtml5TreeOpExecutor::WillBuildModel(nsDTDMode aDTDMode)
NS_IMETHODIMP
nsHtml5TreeOpExecutor::DidBuildModel(bool aTerminated)
{
NS_PRECONDITION(mStarted, "Bad life cycle.");
if (!aTerminated) {
// This is needed to avoid unblocking loads too many times on one hand
// and on the other hand to avoid destroying the frame constructor from
@@ -162,7 +160,12 @@ nsHtml5TreeOpExecutor::DidBuildModel(bool aTerminated)
// Return early to avoid unblocking the onload event too many times.
return NS_OK;
}
mDocument->EndLoad();
// We may not have called BeginLoad() if loading is terminated before
// OnStartRequest call.
if (mStarted) {
mDocument->EndLoad();
}
DropParserAndPerfHint();
#ifdef GATHER_DOCWRITE_STATISTICS
printf("UNSAFE SCRIPTS: %d\n", sUnsafeDocWrites);