Index: Source/web/WebSharedWorkerImpl.cpp |
diff --git a/Source/web/WebSharedWorkerImpl.cpp b/Source/web/WebSharedWorkerImpl.cpp |
index ac6d7069f343c3175685570f64621c55804083a7..b36029b4be8659ac126feb7ecafe6085d614ab0c 100644 |
--- a/Source/web/WebSharedWorkerImpl.cpp |
+++ b/Source/web/WebSharedWorkerImpl.cpp |
@@ -177,8 +177,10 @@ void WebSharedWorkerImpl::stopWorkerThread() |
if (m_askedToTerminate) |
return; |
m_askedToTerminate = true; |
- if (m_mainScriptLoader) |
+ if (m_mainScriptLoader) { |
m_mainScriptLoader->cancel(); |
+ m_mainScriptLoader.clear(); |
+ } |
if (m_workerThread) |
m_workerThread->stop(); |
} |
@@ -344,9 +346,16 @@ void WebSharedWorkerImpl::onScriptLoaderFinished() |
ASSERT(m_loadingDocument); |
ASSERT(m_mainScriptLoader); |
if (m_mainScriptLoader->failed() || m_askedToTerminate) { |
- m_mainScriptLoader.clear(); |
+ m_mainScriptLoader->cancel(); |
if (client()) |
client()->workerScriptLoadFailed(); |
+ |
+ // The SharedWorker was unable to load the initial script, so |
+ // shut it down right here unless we're here handling a load |
+ // cancellation failure triggered by an explicit shared worker |
+ // termination call (via terminateWorkerContext().) |
+ if (!m_askedToTerminate) |
+ delete this; |
return; |
} |
WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; |