Index: Source/web/WebSharedWorkerImpl.cpp |
diff --git a/Source/web/WebSharedWorkerImpl.cpp b/Source/web/WebSharedWorkerImpl.cpp |
index d155a87534669214a9f599f73696ac27a1af1db2..1d7d6881361626e888c845e4315715faa8fb596a 100644 |
--- a/Source/web/WebSharedWorkerImpl.cpp |
+++ b/Source/web/WebSharedWorkerImpl.cpp |
@@ -181,9 +181,6 @@ |
if (m_mainScriptLoader) { |
m_mainScriptLoader->cancel(); |
m_mainScriptLoader.clear(); |
- if (client()) |
- client()->workerScriptLoadFailed(); |
- delete this; |
} |
if (m_workerThread) |
m_workerThread->stop(); |
@@ -349,16 +346,17 @@ |
{ |
ASSERT(m_loadingDocument); |
ASSERT(m_mainScriptLoader); |
- if (m_askedToTerminate) |
- return; |
- if (m_mainScriptLoader->failed()) { |
+ if (m_mainScriptLoader->failed() || m_askedToTerminate) { |
m_mainScriptLoader->cancel(); |
if (client()) |
client()->workerScriptLoadFailed(); |
// The SharedWorker was unable to load the initial script, so |
- // shut it down right here. |
- delete this; |
+ // 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; |