diff options
Diffstat (limited to 'deps/v8/src/inspector/v8-runtime-agent-impl.cc')
-rw-r--r-- | deps/v8/src/inspector/v8-runtime-agent-impl.cc | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/deps/v8/src/inspector/v8-runtime-agent-impl.cc b/deps/v8/src/inspector/v8-runtime-agent-impl.cc index 6975f35e71..bb3198e0bf 100644 --- a/deps/v8/src/inspector/v8-runtime-agent-impl.cc +++ b/deps/v8/src/inspector/v8-runtime-agent-impl.cc @@ -30,6 +30,8 @@ #include "src/inspector/v8-runtime-agent-impl.h" +#include <inttypes.h> + #include "src/debug/debug-interface.h" #include "src/inspector/injected-script.h" #include "src/inspector/inspected-context.h" @@ -134,6 +136,9 @@ void innerCallFunctionOn( if (silent) scope.ignoreExceptionsAndMuteConsole(); if (userGesture) scope.pretendUserGesture(); + // Temporarily enable allow evals for inspector. + scope.allowCodeGenerationFromStrings(); + v8::MaybeLocal<v8::Value> maybeFunctionValue; v8::Local<v8::Script> functionScript; if (inspector @@ -227,7 +232,8 @@ void V8RuntimeAgentImpl::evaluate( Maybe<bool> includeCommandLineAPI, Maybe<bool> silent, Maybe<int> executionContextId, Maybe<bool> returnByValue, Maybe<bool> generatePreview, Maybe<bool> userGesture, - Maybe<bool> awaitPromise, std::unique_ptr<EvaluateCallback> callback) { + Maybe<bool> awaitPromise, Maybe<bool> throwOnSideEffect, + std::unique_ptr<EvaluateCallback> callback) { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EvaluateScript"); int contextId = 0; @@ -250,20 +256,18 @@ void V8RuntimeAgentImpl::evaluate( if (includeCommandLineAPI.fromMaybe(false)) scope.installCommandLineAPI(); - bool evalIsDisabled = !scope.context()->IsCodeGenerationFromStringsAllowed(); // Temporarily enable allow evals for inspector. - if (evalIsDisabled) scope.context()->AllowCodeGenerationFromStrings(true); + scope.allowCodeGenerationFromStrings(); v8::MaybeLocal<v8::Value> maybeResultValue; { v8::MicrotasksScope microtasksScope(m_inspector->isolate(), v8::MicrotasksScope::kRunMicrotasks); maybeResultValue = v8::debug::EvaluateGlobal( - m_inspector->isolate(), toV8String(m_inspector->isolate(), expression)); + m_inspector->isolate(), toV8String(m_inspector->isolate(), expression), + throwOnSideEffect.fromMaybe(false)); } // Run microtasks before returning result. - if (evalIsDisabled) scope.context()->AllowCodeGenerationFromStrings(false); - // Re-initialize after running client's code, as it could have destroyed // context or session. response = scope.initialize(); @@ -571,7 +575,7 @@ void V8RuntimeAgentImpl::runScript( } Response V8RuntimeAgentImpl::queryObjects( - const String16& prototypeObjectId, + const String16& prototypeObjectId, Maybe<String16> objectGroup, std::unique_ptr<protocol::Runtime::RemoteObject>* objects) { InjectedScript::ObjectScope scope(m_session, prototypeObjectId); Response response = scope.initialize(); @@ -582,7 +586,8 @@ Response V8RuntimeAgentImpl::queryObjects( v8::Local<v8::Array> resultArray = m_inspector->debugger()->queryObjects( scope.context(), v8::Local<v8::Object>::Cast(scope.object())); return scope.injectedScript()->wrapObject( - resultArray, scope.objectGroupName(), false, false, objects); + resultArray, objectGroup.fromMaybe(scope.objectGroupName()), false, false, + objects); } Response V8RuntimeAgentImpl::globalLexicalScopeNames( @@ -606,6 +611,27 @@ Response V8RuntimeAgentImpl::globalLexicalScopeNames( return Response::OK(); } +Response V8RuntimeAgentImpl::getIsolateId(String16* outIsolateId) { + char buf[40]; + std::snprintf(buf, sizeof(buf), "%" PRIx64, m_inspector->isolateId()); + *outIsolateId = buf; + return Response::OK(); +} + +Response V8RuntimeAgentImpl::getHeapUsage(double* out_usedSize, + double* out_totalSize) { + v8::HeapStatistics stats; + m_inspector->isolate()->GetHeapStatistics(&stats); + *out_usedSize = stats.used_heap_size(); + *out_totalSize = stats.total_heap_size(); + return Response::OK(); +} + +void V8RuntimeAgentImpl::terminateExecution( + std::unique_ptr<TerminateExecutionCallback> callback) { + m_inspector->debugger()->terminateExecution(std::move(callback)); +} + void V8RuntimeAgentImpl::restore() { if (!m_state->booleanProperty(V8RuntimeAgentImplState::runtimeEnabled, false)) return; |