Chromium Code Reviews| Index: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp |
| diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp |
| index dfe9817cd5ed84a783f61720c3f5cda937b24293..2d1162bbc4e07b7b055676b4237066734a207232 100644 |
| --- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp |
| @@ -649,9 +649,25 @@ void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, |
| } |
| v8::HandleScope scope(m_isolate); |
| - v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); |
| - injectedScript->restartFrame(errorString, callStack, callFrameId); |
| + v8::Local<v8::Context> localContext = injectedScript->context(); |
| + v8::Context::Scope contextScope(localContext); |
|
pfeldman
2016/03/15 19:12:22
Why do you have to enter context here?
kozy
2016/03/16 02:15:15
Removed!
|
| + |
| + v8::TryCatch tryCatch(m_isolate); |
| + |
| + OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScopes(remoteId->frameOrdinal()); |
| + if (!javaScriptCallFrame) { |
| + *errorString = "Could not find call frame with given id"; |
| + return; |
| + } |
| + v8::Local<v8::Value> resultValue; |
| + v8::Local<v8::Boolean> result; |
| + if (!javaScriptCallFrame->restart().ToLocal(&resultValue) || tryCatch.HasCaught() || !resultValue->ToBoolean(localContext).ToLocal(&result) || !result->Value()) { |
| + *errorString = "Internal error"; |
| + return; |
| + } |
| + |
| m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); |
| + |
| *newCallFrames = currentCallFrames(); |
| *asyncStackTrace = currentAsyncStackTrace(); |
| } |
| @@ -914,47 +930,46 @@ void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, |
| void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, |
| int scopeNumber, |
| const String16& variableName, |
| - PassOwnPtr<protocol::Runtime::CallArgument> newValue, |
| - const Maybe<String16>& callFrameId, |
| - const Maybe<String16>& functionObjectId) |
| + PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, |
| + const String16& callFrameId) |
| { |
| if (!checkEnabled(errorString)) |
| return; |
| - InjectedScript* injectedScript = nullptr; |
| - if (callFrameId.isJust()) { |
| - if (!isPaused() || m_currentCallStack.IsEmpty()) { |
| - *errorString = "Attempt to access callframe when debugger is not on pause"; |
| - return; |
| - } |
| - OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId.fromJust()); |
| - if (!remoteId) { |
| - *errorString = "Invalid call frame id"; |
| - return; |
| - } |
| - injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get()); |
| - if (!injectedScript) { |
| - *errorString = "Inspected frame has gone"; |
| - return; |
| - } |
| - } else if (functionObjectId.isJust()) { |
| - OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionObjectId.fromJust()); |
| - if (!remoteId) { |
| - *errorString = "Invalid object id"; |
| - return; |
| - } |
| - injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get()); |
| - if (!injectedScript) { |
| - *errorString = "Function object id cannot be resolved"; |
| - return; |
| - } |
| - } else { |
| - *errorString = "Either call frame or function object must be specified"; |
| + if (!isPaused() || m_currentCallStack.IsEmpty()) { |
| + *errorString = "Attempt to access callframe when debugger is not on pause"; |
| + return; |
| + } |
| + OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); |
| + if (!remoteId) { |
| + *errorString = "Invalid call frame id"; |
| + return; |
| + } |
| + InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.get()); |
| + if (!injectedScript) { |
| + *errorString = "Inspected frame has gone"; |
| return; |
| } |
| - String16 newValueString = protocol::toValue(newValue.get())->toJSONString(); |
| + |
| v8::HandleScope scope(m_isolate); |
| - v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); |
| - injectedScript->setVariableValue(errorString, currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString); |
| + v8::Local<v8::Context> localContext = injectedScript->context(); |
| + v8::Context::Scope contextScope(localContext); |
|
pfeldman
2016/03/15 19:12:22
ditto
kozy
2016/03/16 02:15:15
Nice catch! Removed!
|
| + |
| + v8::TryCatch tryCatch(m_isolate); |
| + |
| + v8::Local<v8::Value> newValue; |
| + if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get()).ToLocal(&newValue)) |
| + return; |
| + |
| + OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScopes(remoteId->frameOrdinal()); |
| + if (!javaScriptCallFrame) { |
| + *errorString = "Could not find call frame with given id"; |
| + return; |
| + } |
| + v8::MaybeLocal<v8::Value> result = javaScriptCallFrame->setVariableValue(scopeNumber, toV8String(m_isolate, variableName), newValue); |
| + if (tryCatch.HasCaught() || result.IsEmpty()) { |
| + *errorString = "Internal error"; |
| + return; |
| + } |
| } |
| void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int depth) |