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

Unified Diff: third_party/WebKit/Source/core/dom/ScriptRunner.cpp

Issue 1526293003: Gracefully discharge a failed script load in disposed documents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « third_party/WebKit/Source/core/dom/ScriptRunner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/ScriptRunner.cpp
diff --git a/third_party/WebKit/Source/core/dom/ScriptRunner.cpp b/third_party/WebKit/Source/core/dom/ScriptRunner.cpp
index 1629e39120af7e36432d41915bb47701a3453b4d..67f31e34a7d276a3788323719e7c824ebb77754f 100644
--- a/third_party/WebKit/Source/core/dom/ScriptRunner.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptRunner.cpp
@@ -43,6 +43,7 @@ ScriptRunner::ScriptRunner(Document* document)
, m_numberOfInOrderScriptsWithPendingNotification(0)
, m_isSuspended(false)
#if !ENABLE(OILPAN)
+ , m_isDisposed(false)
, m_weakPointerFactoryForTasks(this)
#endif
{
@@ -98,6 +99,7 @@ void ScriptRunner::dispose()
m_pendingAsyncScripts.clear();
m_inOrderScriptsToExecuteSoon.clear();
m_asyncScriptsToExecuteSoon.clear();
+ m_isDisposed = true;
}
#endif
@@ -193,15 +195,21 @@ void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType e
void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionType executionType)
{
switch (executionType) {
- case ASYNC_EXECUTION:
+ case ASYNC_EXECUTION: {
+ bool foundLoader = m_pendingAsyncScripts.contains(scriptLoader);
+#if !ENABLE(OILPAN)
+ // If the document and ScriptRunner has been disposed of, there's
+ // no bookkeeping to be done here.
+ foundLoader = foundLoader || m_isDisposed;
+#endif
// RELEASE_ASSERT makes us crash in a controlled way in error cases
// where the ScriptLoader is associated with the wrong ScriptRunner
// (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries
// to detach).
- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(scriptLoader));
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader);
m_pendingAsyncScripts.remove(scriptLoader);
break;
-
+ }
case IN_ORDER_EXECUTION:
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPendingNotification > 0);
m_numberOfInOrderScriptsWithPendingNotification--;
@@ -214,6 +222,9 @@ void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
break;
}
}
+#if !ENABLE(OILPAN)
+ foundPendingScript = foundPendingScript || m_isDisposed;
+#endif
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundPendingScript);
break;
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/ScriptRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698