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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

Issue 1811853002: [DevTools] Move evaluateOnCallFrame to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/IgnoreExceptionsScope.h" 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h"
10 #include "platform/v8_inspector/InjectedScript.h" 10 #include "platform/v8_inspector/InjectedScript.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 713 }
714 714
715 v8::Local<v8::Object> detailsObject; 715 v8::Local<v8::Object> detailsObject;
716 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object ); 716 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object );
717 if (!detailsValue->IsObject() || !detailsValue->ToObject(context).ToLocal(&d etailsObject)) { 717 if (!detailsValue->IsObject() || !detailsValue->ToObject(context).ToLocal(&d etailsObject)) {
718 *errorString = "Internal error"; 718 *errorString = "Internal error";
719 return; 719 return;
720 } 720 }
721 721
722 String16 groupName = injectedScript->objectGroupName(*remoteId); 722 String16 groupName = injectedScript->objectGroupName(*remoteId);
723 if (!injectedScript->wrapObjectProperty(errorString, detailsObject, toV8Stri ng(m_isolate, "function"), groupName, false)) 723 if (!injectedScript->wrapObjectProperty(errorString, detailsObject, toV8Stri ng(m_isolate, "function"), groupName))
724 return; 724 return;
725 725
726 protocol::ErrorSupport errors; 726 protocol::ErrorSupport errors;
727 OwnPtr<GeneratorObjectDetails> protocolDetails = GeneratorObjectDetails::par se(toProtocolValue(context, detailsObject).get(), &errors); 727 OwnPtr<GeneratorObjectDetails> protocolDetails = GeneratorObjectDetails::par se(toProtocolValue(context, detailsObject).get(), &errors);
728 if (!protocolDetails) { 728 if (!protocolDetails) {
729 *errorString = "Internal error"; 729 *errorString = "Internal error";
730 return; 730 return;
731 } 731 }
732 *outDetails = protocolDetails.release(); 732 *outDetails = protocolDetails.release();
733 } 733 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 *errorString = "Attempt to access callframe when debugger is not on paus e"; 919 *errorString = "Attempt to access callframe when debugger is not on paus e";
920 return; 920 return;
921 } 921 }
922 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId); 922 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId);
923 if (!remoteId) 923 if (!remoteId)
924 return; 924 return;
925 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 925 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
926 if (!injectedScript) 926 if (!injectedScript)
927 return; 927 return;
928 928
929 v8::HandleScope scope(m_isolate); 929 v8::HandleScope scope(injectedScript->isolate());
930 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate);
931 930
932 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon sole.fromMaybe(false) ? m_debugger : nullptr); 931 if (!injectedScript->canAccessInspectedWindow()) {
933 injectedScript->evaluateOnCallFrame(errorString, callStack, callFrameId, exp ression, objectGroup.fromMaybe(""), includeCommandLineAPI.fromMaybe(false), retu rnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, wasThrown, exceptionDetails); 932 *errorString = "Can not access given context";
933 return;
934 }
935
936 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop es(remoteId->frameOrdinal());
937 if (!javaScriptCallFrame) {
938 *errorString = "Could not find call frame with given id";
939 return;
940 }
941
942 v8::Local<v8::Object> commandLineAPI;
dgozman 2016/03/17 20:56:11 Maybe
kozy 2016/03/17 21:05:22 Done.
943 if (includeCommandLineAPI.fromMaybe(false) && !injectedScript->commandLineAP I(errorString).ToLocal(&commandLineAPI))
944 return;
945
946 InjectedScriptManager::ScopedGlobalObjectExtension scopeExtension(injectedSc ript, m_injectedScriptManager, commandLineAPI);
947
948 v8::TryCatch tryCatch(injectedScript->isolate());
949
950 v8::MaybeLocal<v8::Value> maybeResultValue = javaScriptCallFrame->evaluate(t oV8String(injectedScript->isolate(), expression));
951
952 // InjectedScript may be gone after any evaluate call - find it again.
953 injectedScript = m_injectedScriptManager->findInjectedScript(errorString, re moteId.get());
954 if (!injectedScript)
955 return;
956
957 injectedScript->wrapEvaluateResult(errorString,
958 maybeResultValue,
959 tryCatch,
960 objectGroup.fromMaybe(""),
961 returnByValue.fromMaybe(false),
962 generatePreview.fromMaybe(false),
963 result,
964 wasThrown,
965 exceptionDetails);
934 } 966 }
935 967
936 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, 968 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString,
937 int scopeNumber, 969 int scopeNumber,
938 const String16& variableName, 970 const String16& variableName,
939 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, 971 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument,
940 const String16& callFrameId) 972 const String16& callFrameId)
941 { 973 {
942 if (!checkEnabled(errorString)) 974 if (!checkEnabled(errorString))
943 return; 975 return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 *errorString = "Promise tracking is disabled"; 1037 *errorString = "Promise tracking is disabled";
1006 return; 1038 return;
1007 } 1039 }
1008 v8::HandleScope handles(m_isolate); 1040 v8::HandleScope handles(m_isolate);
1009 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId); 1041 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId);
1010 if (value.IsEmpty()) { 1042 if (value.IsEmpty()) {
1011 *errorString = "Promise with specified ID not found."; 1043 *errorString = "Promise with specified ID not found.";
1012 return; 1044 return;
1013 } 1045 }
1014 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( value->CreationContext()); 1046 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( value->CreationContext());
1015 *promise = injectedScript->wrapObject(value, objectGroup.fromMaybe("")); 1047 *promise = injectedScript->wrapObject(errorString, value, objectGroup.fromMa ybe(""));
1016 } 1048 }
1017 1049
1018 void V8DebuggerAgentImpl::didUpdatePromise(const String16& eventType, PassOwnPtr <protocol::Debugger::PromiseDetails> promise) 1050 void V8DebuggerAgentImpl::didUpdatePromise(const String16& eventType, PassOwnPtr <protocol::Debugger::PromiseDetails> promise)
1019 { 1051 {
1020 if (m_frontend) 1052 if (m_frontend)
1021 m_frontend->promiseUpdated(eventType, promise); 1053 m_frontend->promiseUpdated(eventType, promise);
1022 } 1054 }
1023 1055
1024 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String16& description ) 1056 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String16& description )
1025 { 1057 {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 1447
1416 ASSERT(m_pausedContext.IsEmpty()); 1448 ASSERT(m_pausedContext.IsEmpty());
1417 m_pausedContext.Reset(m_isolate, context); 1449 m_pausedContext.Reset(m_isolate, context);
1418 m_currentCallStack.Reset(m_isolate, callFrames); 1450 m_currentCallStack.Reset(m_isolate, callFrames);
1419 v8::HandleScope handles(m_isolate); 1451 v8::HandleScope handles(m_isolate);
1420 1452
1421 if (!exception.IsEmpty()) { 1453 if (!exception.IsEmpty()) {
1422 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context); 1454 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context);
1423 if (injectedScript) { 1455 if (injectedScript) {
1424 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; 1456 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception;
1425 auto obj = injectedScript->wrapObject(exception, V8DebuggerAgentImpl ::backtraceObjectGroup); 1457 ErrorString errorString;
1458 auto obj = injectedScript->wrapObject(&errorString, exception, V8Deb uggerAgentImpl::backtraceObjectGroup);
1426 m_breakAuxData = obj ? obj->serialize() : nullptr; 1459 m_breakAuxData = obj ? obj->serialize() : nullptr;
1427 // m_breakAuxData might be null after this. 1460 // m_breakAuxData might be null after this.
1428 } 1461 }
1429 } else if (m_pausingOnAsyncOperation) { 1462 } else if (m_pausingOnAsyncOperation) {
1430 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation; 1463 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation;
1431 m_breakAuxData = protocol::DictionaryValue::create(); 1464 m_breakAuxData = protocol::DictionaryValue::create();
1432 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId); 1465 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId);
1433 } 1466 }
1434 1467
1435 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create(); 1468 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 m_scripts.clear(); 1572 m_scripts.clear();
1540 m_blackboxedPositions.clear(); 1573 m_blackboxedPositions.clear();
1541 m_breakpointIdToDebuggerBreakpointIds.clear(); 1574 m_breakpointIdToDebuggerBreakpointIds.clear();
1542 resetAsyncCallTracker(); 1575 resetAsyncCallTracker();
1543 m_promiseTracker->clear(); 1576 m_promiseTracker->clear();
1544 if (m_frontend) 1577 if (m_frontend)
1545 m_frontend->globalObjectCleared(); 1578 m_frontend->globalObjectCleared();
1546 } 1579 }
1547 1580
1548 } // namespace blink 1581 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698