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

Unified Diff: Source/core/dom/Document.cpp

Issue 774033002: Run Microtasks before dispatching onload (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add rebaseline Created 5 years, 11 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
« no previous file with comments | « LayoutTests/http/tests/inspector/network/network-initiator-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 170bd8ed07e092c6d043f440aad3382d4289cce8..5bb1b1a00bb08b1c29dc4bba49364b48849f5975 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -77,6 +77,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContextTask.h"
#include "core/dom/MainThreadTaskRunner.h"
+#include "core/dom/Microtask.h"
#include "core/dom/MutationObserver.h"
#include "core/dom/NodeChildRemovalTracker.h"
#include "core/dom/NodeFilter.h"
@@ -4620,6 +4621,9 @@ void Document::finishedParsing()
ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
setParsingState(InDOMContentLoaded);
+
+ // FIXME: DOMContentLoaded is dispatched synchronously, but this should be dispatched in a queued task,
+ // See https://crbug.com/425790
if (!m_documentTiming.domContentLoadedEventStart)
m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTime();
dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
@@ -4627,11 +4631,16 @@ void Document::finishedParsing()
m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime();
setParsingState(FinishedParsing);
- // The loader's finishedParsing() method may invoke script that causes this object to
+ // The microtask checkpoint or the loader's finishedParsing() method may invoke script that causes this object to
// be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
// Keep it alive until we are done.
RefPtrWillBeRawPtr<Document> protect(this);
+ // Ensure Custom Element callbacks are drained before DOMContentLoaded.
+ // FIXME: Remove this ad-hoc checkpoint when DOMContentLoaded is dispatched in a
+ // queued task, which will do a checkpoint anyway. https://crbug.com/425790
+ Microtask::performCheckpoint();
+
if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) {
// Don't update the render tree if we haven't requested the main resource yet to avoid
// adding extra latency. Note that the first render tree update can be expensive since it
« no previous file with comments | « LayoutTests/http/tests/inspector/network/network-initiator-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698