Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Schedule microtask for document_end scripts Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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()

Powered by Google App Engine
This is Rietveld 408576698