Chromium Code Reviews| Index: Source/web/SuspendableScriptExecutor.cpp |
| diff --git a/Source/web/SuspendableScriptExecutor.cpp b/Source/web/SuspendableScriptExecutor.cpp |
| index 13118aac8071be0c0ce566063326d75baf742a6c..92ee7d4a614d3292a49c40f8350c21ed0d7803e7 100644 |
| --- a/Source/web/SuspendableScriptExecutor.cpp |
| +++ b/Source/web/SuspendableScriptExecutor.cpp |
| @@ -24,7 +24,8 @@ void SuspendableScriptExecutor::createAndRun(LocalFrame* frame, int worldID, con |
| void SuspendableScriptExecutor::resume() |
| { |
| - executeAndDestroySelf(); |
| + if (!m_isStarted) |
|
pfeldman
2015/02/04 12:45:20
This implies that the code containing alert will a
kozy
2015/02/04 13:12:33
Fixed.
|
| + executeAndDestroySelf(); |
| } |
| void SuspendableScriptExecutor::contextDestroyed() |
| @@ -32,8 +33,10 @@ void SuspendableScriptExecutor::contextDestroyed() |
| // this method can only be called if the script was not called in run() |
| // and context remained suspend (method resume has never called) |
| ActiveDOMObject::contextDestroyed(); |
| - m_callback->completed(Vector<v8::Local<v8::Value>>()); |
| - deref(); |
| + if (!m_isStarted) { |
| + m_callback->completed(Vector<v8::Local<v8::Value>>()); |
| + deref(); |
| + } |
| } |
| SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worldID, const WillBeHeapVector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCallback* callback) |
| @@ -43,6 +46,7 @@ SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worl |
| , m_sources(sources) |
| , m_extensionGroup(extensionGroup) |
| , m_userGesture(userGesture) |
| + , m_isStarted(false) |
| , m_callback(callback) |
| { |
| } |
| @@ -56,12 +60,13 @@ void SuspendableScriptExecutor::run() |
| suspendIfNeeded(); |
| ExecutionContext* context = executionContext(); |
| ASSERT(context); |
| - if (context && !context->activeDOMObjectsAreSuspended()) |
| + if (!m_isStarted && context && !context->activeDOMObjectsAreSuspended()) |
| executeAndDestroySelf(); |
| } |
| void SuspendableScriptExecutor::executeAndDestroySelf() |
| { |
| + m_isStarted = true; |
| // after calling the destructor of object - object will be unsubscribed from |
| // resumed and contextDestroyed LifecycleObserver methods |
| OwnPtr<UserGestureIndicator> indicator; |