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 | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/deps/v8/src/inspector/v8-runtime-agent-impl.cc b/deps/v8/src/inspector/v8-runtime-agent-impl.cc index 1a3ee11ba1..9a1a845487 100644 --- a/deps/v8/src/inspector/v8-runtime-agent-impl.cc +++ b/deps/v8/src/inspector/v8-runtime-agent-impl.cc @@ -241,11 +241,13 @@ Response ensureContext(V8InspectorImpl* inspector, int contextGroupId, V8RuntimeAgentImpl::V8RuntimeAgentImpl( V8InspectorSessionImpl* session, protocol::FrontendChannel* FrontendChannel, - protocol::DictionaryValue* state) + protocol::DictionaryValue* state, + std::shared_ptr<V8DebuggerBarrier> debuggerBarrier) : m_session(session), m_state(state), m_frontend(FrontendChannel), m_inspector(session->inspector()), + m_debuggerBarrier(debuggerBarrier), m_enabled(false) {} V8RuntimeAgentImpl::~V8RuntimeAgentImpl() = default; @@ -373,16 +375,22 @@ void V8RuntimeAgentImpl::callFunctionOn( Maybe<bool> silent, Maybe<bool> returnByValue, Maybe<bool> generatePreview, Maybe<bool> userGesture, Maybe<bool> awaitPromise, Maybe<int> executionContextId, Maybe<String16> objectGroup, - Maybe<bool> throwOnSideEffect, Maybe<bool> generateWebDriverValue, + Maybe<bool> throwOnSideEffect, Maybe<String16> uniqueContextId, + Maybe<bool> generateWebDriverValue, std::unique_ptr<CallFunctionOnCallback> callback) { - if (objectId.isJust() && executionContextId.isJust()) { - callback->sendFailure(Response::ServerError( - "ObjectId must not be specified together with executionContextId")); + int justCount = (objectId.isJust() ? 1 : 0) + + (executionContextId.isJust() ? 1 : 0) + + (uniqueContextId.isJust() ? 1 : 0); + if (justCount > 1) { + callback->sendFailure(Response::InvalidParams( + "ObjectId, executionContextId and uniqueContextId must mutually " + "exclude each other")); return; } - if (!objectId.isJust() && !executionContextId.isJust()) { - callback->sendFailure(Response::ServerError( - "Either ObjectId or executionContextId must be specified")); + if (justCount < 1) { + callback->sendFailure( + Response::InvalidParams("Either objectId or executionContextId or " + "uniqueContextId must be specified")); return; } WrapMode wrap_mode = generatePreview.fromMaybe(false) ? WrapMode::kWithPreview @@ -407,8 +415,8 @@ void V8RuntimeAgentImpl::callFunctionOn( } else { int contextId = 0; Response response = ensureContext(m_inspector, m_session->contextGroupId(), - std::move(executionContextId.fromJust()), - /* uniqueContextId */ {}, &contextId); + std::move(executionContextId), + std::move(uniqueContextId), &contextId); if (!response.IsSuccess()) { callback->sendFailure(response); return; @@ -491,11 +499,13 @@ Response V8RuntimeAgentImpl::releaseObjectGroup(const String16& objectGroup) { } Response V8RuntimeAgentImpl::runIfWaitingForDebugger() { - if (m_runIfWaitingForDebuggerCalled) return Response::Success(); - m_runIfWaitingForDebuggerCalled = true; - // The client implementation is resposible for checking if the session is - // actually waiting for debugger. m_runIfWaitingForDebuggerCalled only makes - // sure that the client implementation is invoked once per agent instance. + if (m_debuggerBarrier) { + m_debuggerBarrier.reset(); + return Response::Success(); + } + // TODO(chromium:1352175): the below is provisional until client-side changes + // land. The call should come through the barrier only once client properly + // communicates whether the session is waiting for debugger. m_inspector->client()->runIfWaitingForDebugger(m_session->contextGroupId()); return Response::Success(); } @@ -705,7 +715,13 @@ Response V8RuntimeAgentImpl::getHeapUsage(double* out_usedSize, void V8RuntimeAgentImpl::terminateExecution( std::unique_ptr<TerminateExecutionCallback> callback) { - m_inspector->debugger()->terminateExecution(std::move(callback)); + v8::HandleScope handles(m_inspector->isolate()); + v8::Local<v8::Context> defaultContext = + m_inspector->client()->ensureDefaultContextInGroup( + m_session->contextGroupId()); + + m_inspector->debugger()->terminateExecution(defaultContext, + std::move(callback)); } namespace { @@ -981,7 +997,8 @@ void V8RuntimeAgentImpl::reportExecutionContextDestroyed( InspectedContext* context) { if (m_enabled && context->isReported(m_session->sessionId())) { context->setReported(m_session->sessionId(), false); - m_frontend.executionContextDestroyed(context->contextId()); + m_frontend.executionContextDestroyed(context->contextId(), + context->uniqueId().toString()); } } |