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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp

Issue 2191543002: binding: Disallows to run a function if its context is detached. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp b/third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp
index 12020f5dd76b45e30df9fcd5fa8246b3fae3cc36..d15d33854db091528255bd208724c641a4569ff5 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScheduledAction.cpp
@@ -114,9 +114,15 @@ void ScheduledAction::execute(LocalFrame* frame)
ScriptState::Scope scope(m_scriptState.get());
if (!m_function.isEmpty()) {
DVLOG(1) << "ScheduledAction::execute " << this << ": have function";
+ v8::Local<v8::Function> function = m_function.newLocal(m_scriptState->isolate());
+ ScriptState* scriptStateForFunc = ScriptState::from(function->CreationContext());
+ if (!scriptStateForFunc->contextIsValid()) {
+ DVLOG(1) << "ScheduledAction::execute " << this << ": function's context is empty";
+ return;
+ }
Vector<v8::Local<v8::Value>> info;
createLocalHandlesForArgs(&info);
- V8ScriptRunner::callFunction(m_function.newLocal(m_scriptState->isolate()), frame->document(), m_scriptState->context()->Global(), info.size(), info.data(), m_scriptState->isolate());
+ V8ScriptRunner::callFunction(function, frame->document(), m_scriptState->context()->Global(), info.size(), info.data(), m_scriptState->isolate());
} else {
DVLOG(1) << "ScheduledAction::execute " << this << ": executing from source";
frame->script().executeScriptAndReturnValue(m_scriptState->context(), ScriptSourceCode(m_code));
@@ -128,12 +134,23 @@ void ScheduledAction::execute(LocalFrame* frame)
void ScheduledAction::execute(WorkerGlobalScope* worker)
{
ASSERT(worker->thread()->isCurrentThread());
- ASSERT(m_scriptState->contextIsValid());
+
+ if (!m_scriptState->contextIsValid()) {
+ DVLOG(1) << "ScheduledAction::execute " << this << ": context is empty";
+ return;
+ }
+
if (!m_function.isEmpty()) {
ScriptState::Scope scope(m_scriptState.get());
+ v8::Local<v8::Function> function = m_function.newLocal(m_scriptState->isolate());
+ ScriptState* scriptStateForFunc = ScriptState::from(function->CreationContext());
+ if (!scriptStateForFunc->contextIsValid()) {
+ DVLOG(1) << "ScheduledAction::execute " << this << ": function's context is empty";
+ return;
+ }
Vector<v8::Local<v8::Value>> info;
createLocalHandlesForArgs(&info);
- V8ScriptRunner::callFunction(m_function.newLocal(m_scriptState->isolate()), worker, m_scriptState->context()->Global(), info.size(), info.data(), m_scriptState->isolate());
+ V8ScriptRunner::callFunction(function, worker, m_scriptState->context()->Global(), info.size(), info.data(), m_scriptState->isolate());
} else {
worker->scriptController()->evaluate(m_code);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698