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

Unified Diff: Source/web/SuspendableScriptExecutor.cpp

Issue 869513004: SuspendableScriptExecutor executes code once (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months 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/web/SuspendableScriptExecutor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/web/SuspendableScriptExecutor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698