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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 #include "platform/v8_inspector/InjectedScript.h" 9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InspectedContext.h" 10 #include "platform/v8_inspector/InspectedContext.h"
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 m_skipNextDebuggerStepOut = true; 980 m_skipNextDebuggerStepOut = true;
981 } 981 }
982 } 982 }
983 } 983 }
984 984
985 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt ring* errorString) 985 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt ring* errorString)
986 { 986 {
987 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) 987 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size())
988 return Array<CallFrame>::create(); 988 return Array<CallFrame>::create();
989 ErrorString ignored; 989 ErrorString ignored;
990 InjectedScript* topFrameInjectedScript = m_session->findInjectedScript(&igno red, V8DebuggerImpl::contextId(m_pausedContext.Get(m_isolate)));
991 if (!topFrameInjectedScript) {
992 // Context has been reported as removed while on pause.
993 return Array<CallFrame>::create();
994 }
995
996 v8::HandleScope handles(m_isolate); 990 v8::HandleScope handles(m_isolate);
997 v8::Local<v8::Context> context = topFrameInjectedScript->context()->context( ); 991 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(m_isolat e);
998 v8::Context::Scope contextScope(context); 992 v8::Context::Scope contextScope(debuggerContext);
999 993
1000 v8::Local<v8::Array> objects = v8::Array::New(m_isolate); 994 v8::Local<v8::Array> objects = v8::Array::New(m_isolate);
1001 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++fr ameOrdinal) { 995 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++fr ameOrdinal) {
1002 const std::unique_ptr<JavaScriptCallFrame>& currentCallFrame = m_pausedC allFrames[frameOrdinal]; 996 const std::unique_ptr<JavaScriptCallFrame>& currentCallFrame = m_pausedC allFrames[frameOrdinal];
1003 997
1004 v8::Local<v8::Object> details = currentCallFrame->details(); 998 v8::Local<v8::Object> details = currentCallFrame->details();
1005 if (hasInternalError(errorString, details.IsEmpty())) 999 if (hasInternalError(errorString, details.IsEmpty()))
1006 return Array<CallFrame>::create(); 1000 return Array<CallFrame>::create();
1007 1001
1008 int contextId = currentCallFrame->contextId(); 1002 int contextId = currentCallFrame->contextId();
1009 InjectedScript* injectedScript = contextId ? m_session->findInjectedScri pt(&ignored, contextId) : nullptr; 1003 InjectedScript* injectedScript = contextId ? m_session->findInjectedScri pt(&ignored, contextId) : nullptr;
1010 if (!injectedScript)
1011 injectedScript = topFrameInjectedScript;
1012 1004
1013 String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->cont ext()->contextId(), frameOrdinal); 1005 String16 callFrameId = RemoteCallFrameId::serialize(contextId, frameOrdi nal);
1014 if (hasInternalError(errorString, !details->Set(context, toV8StringInter nalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe (false))) 1006 if (hasInternalError(errorString, !details->Set(debuggerContext, toV8Str ingInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).F romMaybe(false)))
1015 return Array<CallFrame>::create(); 1007 return Array<CallFrame>::create();
1016 1008
1017 v8::Local<v8::Value> scopeChain; 1009 if (injectedScript) {
1018 if (hasInternalError(errorString, !details->Get(context, toV8StringInter nalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray() )) 1010 v8::Local<v8::Value> scopeChain;
1019 return Array<CallFrame>::create(); 1011 if (hasInternalError(errorString, !details->Get(debuggerContext, toV 8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChai n->IsArray()))
1020 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>(); 1012 return Array<CallFrame>::create();
1021 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, t oV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectG roup))
1022 return Array<CallFrame>::create();
1023 1013
1024 if (!injectedScript->wrapObjectProperty(errorString, details, toV8String Internalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) 1014 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>();
1025 return Array<CallFrame>::create(); 1015 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArra y, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObj ectGroup))
1026 1016 return Array<CallFrame>::create();
1027 if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue ")).FromMaybe(false)) { 1017 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup))
1028 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectG roup)) 1018 return Array<CallFrame>::create();
1019 if (details->Has(debuggerContext, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false)) {
1020 if (!injectedScript->wrapObjectProperty(errorString, details, to V8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObj ectGroup))
1021 return Array<CallFrame>::create();
1022 }
1023 } else {
1024 if (hasInternalError(errorString, !details->Set(debuggerContext, toV 8StringInternalized(m_isolate, "scopeChain"), v8::Undefined(m_isolate)).FromMayb e(false)))
1025 return Array<CallFrame>::create();
1026 if (hasInternalError(errorString, !details->Set(debuggerContext, toV 8StringInternalized(m_isolate, "this"), v8::Undefined(m_isolate)).FromMaybe(fals e)))
1027 return Array<CallFrame>::create();
1028 if (hasInternalError(errorString, !details->Set(debuggerContext, toV 8StringInternalized(m_isolate, "returnValue"), v8::Undefined(m_isolate)).FromMay be(false)))
1029 return Array<CallFrame>::create(); 1029 return Array<CallFrame>::create();
1030 } 1030 }
1031 1031
1032 if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, d etails).FromMaybe(false))) 1032 if (hasInternalError(errorString, !objects->Set(debuggerContext, frameOr dinal, details).FromMaybe(false)))
1033 return Array<CallFrame>::create(); 1033 return Array<CallFrame>::create();
1034 } 1034 }
1035 1035
1036 protocol::ErrorSupport errorSupport; 1036 protocol::ErrorSupport errorSupport;
1037 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro tocolValue(context, objects).get(), &errorSupport); 1037 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro tocolValue(debuggerContext, objects).get(), &errorSupport);
1038 if (hasInternalError(errorString, !callFrames)) 1038 if (hasInternalError(errorString, !callFrames))
1039 return Array<CallFrame>::create(); 1039 return Array<CallFrame>::create();
1040 return callFrames; 1040 return callFrames;
1041 } 1041 }
1042 1042
1043 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() 1043 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace()
1044 { 1044 {
1045 if (m_pausedContext.IsEmpty()) 1045 if (m_pausedContext.IsEmpty())
1046 return nullptr; 1046 return nullptr;
1047 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); 1047 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 { 1242 {
1243 if (!enabled()) 1243 if (!enabled())
1244 return; 1244 return;
1245 m_scheduledDebuggerStep = NoStep; 1245 m_scheduledDebuggerStep = NoStep;
1246 m_scripts.clear(); 1246 m_scripts.clear();
1247 m_blackboxedPositions.clear(); 1247 m_blackboxedPositions.clear();
1248 m_breakpointIdToDebuggerBreakpointIds.clear(); 1248 m_breakpointIdToDebuggerBreakpointIds.clear();
1249 } 1249 }
1250 1250
1251 } // namespace blink 1251 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698