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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

Issue 2135443002: DevTools: explicitly use debugger context when processing objects from DebuggerScript.js. (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
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 e1dbb812edeeb0a5910f9ece19d30c70c2fdb9ab..be593b0914d8e9bba39eed70627cdb89fd5cf072 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp
@@ -987,15 +987,9 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size())
return Array<CallFrame>::create();
ErrorString ignored;
- InjectedScript* topFrameInjectedScript = m_session->findInjectedScript(&ignored, V8DebuggerImpl::contextId(m_pausedContext.Get(m_isolate)));
- if (!topFrameInjectedScript) {
- // Context has been reported as removed while on pause.
- return Array<CallFrame>::create();
- }
-
v8::HandleScope handles(m_isolate);
- v8::Local<v8::Context> context = topFrameInjectedScript->context()->context();
- v8::Context::Scope contextScope(context);
+ v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(m_isolate);
+ v8::Context::Scope contextScope(debuggerContext);
v8::Local<v8::Array> objects = v8::Array::New(m_isolate);
for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++frameOrdinal) {
@@ -1007,34 +1001,40 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
int contextId = currentCallFrame->contextId();
InjectedScript* injectedScript = contextId ? m_session->findInjectedScript(&ignored, contextId) : nullptr;
- if (!injectedScript)
- injectedScript = topFrameInjectedScript;
- String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->context()->contextId(), frameOrdinal);
- if (hasInternalError(errorString, !details->Set(context, toV8StringInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe(false)))
+ String16 callFrameId = RemoteCallFrameId::serialize(contextId, frameOrdinal);
+ if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe(false)))
return Array<CallFrame>::create();
- v8::Local<v8::Value> scopeChain;
- if (hasInternalError(errorString, !details->Get(context, toV8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray()))
- return Array<CallFrame>::create();
- v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>();
- if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectGroup))
- return Array<CallFrame>::create();
-
- if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup))
- return Array<CallFrame>::create();
+ if (injectedScript) {
+ v8::Local<v8::Value> scopeChain;
+ if (hasInternalError(errorString, !details->Get(debuggerContext, toV8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray()))
+ return Array<CallFrame>::create();
- if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false)) {
- if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectGroup))
+ v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>();
+ if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectGroup))
+ return Array<CallFrame>::create();
+ if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup))
+ return Array<CallFrame>::create();
+ if (details->Has(debuggerContext, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false)) {
+ if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectGroup))
+ return Array<CallFrame>::create();
+ }
+ } else {
+ if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "scopeChain"), v8::Undefined(m_isolate)).FromMaybe(false)))
+ return Array<CallFrame>::create();
+ if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "this"), v8::Undefined(m_isolate)).FromMaybe(false)))
+ return Array<CallFrame>::create();
+ if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "returnValue"), v8::Undefined(m_isolate)).FromMaybe(false)))
return Array<CallFrame>::create();
}
- if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, details).FromMaybe(false)))
+ if (hasInternalError(errorString, !objects->Set(debuggerContext, frameOrdinal, details).FromMaybe(false)))
return Array<CallFrame>::create();
}
protocol::ErrorSupport errorSupport;
- std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValue(context, objects).get(), &errorSupport);
+ std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValue(debuggerContext, objects).get(), &errorSupport);
if (hasInternalError(errorString, !callFrames))
return Array<CallFrame>::create();
return callFrames;

Powered by Google App Engine
This is Rietveld 408576698