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

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, false, true))
dgozman 2016/03/17 19:16:12 true -> false
kozy 2016/03/17 20:48:56 Done.
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 InjectedScriptManager::InjectScopeExtensionByName scopeExtension(errorString , injectedScript, true, includeCommandLineAPI.fromMaybe(false) ? "commandLineAPI " : String16());
943 if (scopeExtension.hasError())
944 return;
945
946 v8::TryCatch tryCatch(injectedScript->isolate());
947
948 v8::Local<v8::Value> resultValue;
949 bool success = javaScriptCallFrame->evaluateWithExceptionDetails(toV8String( injectedScript->isolate(), expression)).ToLocal(&resultValue);
dgozman 2016/03/17 19:16:12 Let's pass Maybe further and forget about ToLocal
kozy 2016/03/17 20:48:56 Done.
950 ALLOW_UNUSED_LOCAL(success);
951
952 injectedScript = m_injectedScriptManager->findInjectedScript(errorString, re moteId.get());
dgozman 2016/03/17 19:16:12 // InjectedScript may be gone after any evaluate c
kozy 2016/03/17 20:48:56 Done.
953 if (!injectedScript)
954 return;
955
956 V8RuntimeAgentImpl::wrapEvaluateResult(errorString,
dgozman 2016/03/17 19:16:12 Let's make this an instance method on InjectedScri
kozy 2016/03/17 20:48:56 Done.
957 m_debugger,
958 injectedScript,
959 resultValue,
960 tryCatch,
961 objectGroup.fromMaybe(""),
962 returnByValue.fromMaybe(false),
963 generatePreview.fromMaybe(false),
964 result,
965 wasThrown,
966 exceptionDetails);
934 } 967 }
935 968
936 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, 969 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString,
937 int scopeNumber, 970 int scopeNumber,
938 const String16& variableName, 971 const String16& variableName,
939 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, 972 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument,
940 const String16& callFrameId) 973 const String16& callFrameId)
941 { 974 {
942 if (!checkEnabled(errorString)) 975 if (!checkEnabled(errorString))
943 return; 976 return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 *errorString = "Promise tracking is disabled"; 1038 *errorString = "Promise tracking is disabled";
1006 return; 1039 return;
1007 } 1040 }
1008 v8::HandleScope handles(m_isolate); 1041 v8::HandleScope handles(m_isolate);
1009 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId); 1042 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId);
1010 if (value.IsEmpty()) { 1043 if (value.IsEmpty()) {
1011 *errorString = "Promise with specified ID not found."; 1044 *errorString = "Promise with specified ID not found.";
1012 return; 1045 return;
1013 } 1046 }
1014 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( value->CreationContext()); 1047 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( value->CreationContext());
1015 *promise = injectedScript->wrapObject(value, objectGroup.fromMaybe("")); 1048 OwnPtr<RemoteObject> promiseObject = injectedScript->wrapObject(errorString, value, objectGroup.fromMaybe(""));
dgozman 2016/03/17 19:16:12 Revert.
kozy 2016/03/17 20:48:56 Done.
1049 if (!promiseObject)
1050 return;
1051 *promise = promiseObject.release();
1016 } 1052 }
1017 1053
1018 void V8DebuggerAgentImpl::didUpdatePromise(const String16& eventType, PassOwnPtr <protocol::Debugger::PromiseDetails> promise) 1054 void V8DebuggerAgentImpl::didUpdatePromise(const String16& eventType, PassOwnPtr <protocol::Debugger::PromiseDetails> promise)
1019 { 1055 {
1020 if (m_frontend) 1056 if (m_frontend)
1021 m_frontend->promiseUpdated(eventType, promise); 1057 m_frontend->promiseUpdated(eventType, promise);
1022 } 1058 }
1023 1059
1024 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String16& description ) 1060 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String16& description )
1025 { 1061 {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 1451
1416 ASSERT(m_pausedContext.IsEmpty()); 1452 ASSERT(m_pausedContext.IsEmpty());
1417 m_pausedContext.Reset(m_isolate, context); 1453 m_pausedContext.Reset(m_isolate, context);
1418 m_currentCallStack.Reset(m_isolate, callFrames); 1454 m_currentCallStack.Reset(m_isolate, callFrames);
1419 v8::HandleScope handles(m_isolate); 1455 v8::HandleScope handles(m_isolate);
1420 1456
1421 if (!exception.IsEmpty()) { 1457 if (!exception.IsEmpty()) {
1422 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context); 1458 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context);
1423 if (injectedScript) { 1459 if (injectedScript) {
1424 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; 1460 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception;
1425 auto obj = injectedScript->wrapObject(exception, V8DebuggerAgentImpl ::backtraceObjectGroup); 1461 ErrorString errorString;
1462 auto obj = injectedScript->wrapObject(&errorString, exception, V8Deb uggerAgentImpl::backtraceObjectGroup);
1426 m_breakAuxData = obj ? obj->serialize() : nullptr; 1463 m_breakAuxData = obj ? obj->serialize() : nullptr;
1427 // m_breakAuxData might be null after this. 1464 // m_breakAuxData might be null after this.
1428 } 1465 }
1429 } else if (m_pausingOnAsyncOperation) { 1466 } else if (m_pausingOnAsyncOperation) {
1430 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation; 1467 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation;
1431 m_breakAuxData = protocol::DictionaryValue::create(); 1468 m_breakAuxData = protocol::DictionaryValue::create();
1432 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId); 1469 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId);
1433 } 1470 }
1434 1471
1435 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create(); 1472 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 m_scripts.clear(); 1576 m_scripts.clear();
1540 m_blackboxedPositions.clear(); 1577 m_blackboxedPositions.clear();
1541 m_breakpointIdToDebuggerBreakpointIds.clear(); 1578 m_breakpointIdToDebuggerBreakpointIds.clear();
1542 resetAsyncCallTracker(); 1579 resetAsyncCallTracker();
1543 m_promiseTracker->clear(); 1580 m_promiseTracker->clear();
1544 if (m_frontend) 1581 if (m_frontend)
1545 m_frontend->globalObjectCleared(); 1582 m_frontend->globalObjectCleared();
1546 } 1583 }
1547 1584
1548 } // namespace blink 1585 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698