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

Unified Diff: Source/core/html/parser/HTMLScriptRunner.cpp

Issue 710933003: Handle parser-blocking script cancellations while nested. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Generalize cancellation Created 6 years, 1 month 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 | « Source/core/html/parser/HTMLScriptRunner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLScriptRunner.cpp
diff --git a/Source/core/html/parser/HTMLScriptRunner.cpp b/Source/core/html/parser/HTMLScriptRunner.cpp
index ec2442f8a305c2f3ac57b8de2ce1792a554a64c1..c65af170be7d3dccf1612b73165e6d468e485148 100644
--- a/Source/core/html/parser/HTMLScriptRunner.cpp
+++ b/Source/core/html/parser/HTMLScriptRunner.cpp
@@ -165,8 +165,34 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
ASSERT(!isExecutingScript());
}
+void HTMLScriptRunner::stopWatchingResourceForLoad(Resource* resource)
+{
+ if (m_parserBlockingScript.resource() == resource) {
+ m_parserBlockingScript.stopWatchingForLoad(this);
+ m_parserBlockingScript.releaseElementAndClear();
+ return;
+ }
+ for (PendingScript& script : m_scriptsToExecuteAfterParsing) {
+ if (script.resource() == resource) {
+ script.stopWatchingForLoad(this);
+ script.releaseElementAndClear();
+ return;
+ }
+ }
+}
+
void HTMLScriptRunner::notifyFinished(Resource* cachedResource)
{
+ // Handle cancellations of parser-blocking script loads without
+ // notifying the host (i.e., parser) if these were initiated by nested
+ // document.write()s. The cancellation may have been triggered by
+ // script execution to signal an abrupt stop (e.g., window.close().)
+ //
+ // The parser is unprepared to be told, and doesn't need to be.
+ if (isExecutingScript() && cachedResource->wasCanceled()) {
+ stopWatchingResourceForLoad(cachedResource);
+ return;
+ }
m_host->notifyScriptLoaded(cachedResource);
}
« no previous file with comments | « Source/core/html/parser/HTMLScriptRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698