| Index: third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| index cf68d9d95c3a6e7632bd32b298ac6a5ded7121f8..5e680a685cc2a2ac94f617930dcaa8bad463c60a 100644
|
| --- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| +++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
| @@ -37,9 +37,11 @@
|
| #include "bindings/core/v8/DOMWrapperWorld.h"
|
| #include "bindings/core/v8/ScriptController.h"
|
| #include "bindings/core/v8/SerializedScriptValue.h"
|
| +#include "bindings/core/v8/V8PerIsolateData.h"
|
| #include "core/HTMLNames.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/Element.h"
|
| +#include "core/dom/Microtask.h"
|
| #include "core/dom/ViewportDescription.h"
|
| #include "core/editing/Editor.h"
|
| #include "core/editing/commands/UndoStack.h"
|
| @@ -488,8 +490,12 @@ void FrameLoader::finishedParsing()
|
|
|
| m_progressTracker->finishedParsing();
|
|
|
| - if (client())
|
| + if (client()) {
|
| client()->dispatchDidFinishDocumentLoad(m_documentLoader ? m_documentLoader->isCommittedButEmpty() : true);
|
| + Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
|
| + if (!m_frame->view())
|
| + return;
|
| + }
|
|
|
| checkCompleted();
|
|
|
| @@ -1485,7 +1491,16 @@ bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const
|
|
|
| void FrameLoader::dispatchDocumentElementAvailable()
|
| {
|
| + // TODO(robwu): Use ScriptForbiddenScope to prevent scripts from being run
|
| + // synchronously in documentElementAvailable.
|
| client()->documentElementAvailable();
|
| +
|
| + // Run queued microtasks (scheduled by clients of documentElementAvailable),
|
| + // to make sure that the scripts run before the parser continues. This may
|
| + // result in a detached frame.
|
| + // If this method is called re-entrantly, then the microtask is deferred to
|
| + // the next microtask checkpoint.
|
| + Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
|
| }
|
|
|
| void FrameLoader::dispatchDidClearDocumentOfWindowObject()
|
|
|