From ca3a939da83b87453d8c59d8acced5ac6452ef50 Mon Sep 17 00:00:00 2001 From: Vladimir Nechaev Date: Wed, 4 Jan 2023 18:14:42 +0000 Subject: [PATCH] [inspector] Provide more details about destroyed context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Runtime.executionContextCreated provides many details in ExecutionContextDescription structure while Runtime.executionContextDestroyed provides only executionContextId. This information is insufficient for the clients that use uniqueContextId. Bug: v8:12896 Change-Id: I31df0ed618dc1c8b55c7eba8f96eeaef2d4de6c8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3657439 Commit-Queue: Simon Zünd Auto-Submit: Vladimir Nechaev Reviewed-by: Simon Zünd Cr-Commit-Position: refs/heads/main@{#85110} --- include/js_protocol.pdl | 4 +++- src/inspector/v8-runtime-agent-impl.cc | 3 ++- test/inspector/protocol-test.js | 3 ++- .../context-destroyed-on-context-collected-expected.txt | 1 + test/inspector/sessions/create-session-expected.txt | 3 +++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/js_protocol.pdl b/include/js_protocol.pdl index 7960a56f54..d4102f5c6c 100644 --- a/include/js_protocol.pdl +++ b/include/js_protocol.pdl @@ -1741,7 +1741,9 @@ domain Runtime event executionContextDestroyed parameters # Id of the destroyed context - ExecutionContextId executionContextId + deprecated ExecutionContextId executionContextId + # Unique Id of the destroyed context + experimental string executionContextUniqueId # Issued when all executionContexts were cleared in browser event executionContextsCleared diff --git a/src/inspector/v8-runtime-agent-impl.cc b/src/inspector/v8-runtime-agent-impl.cc index 5cb582c0bf..9a1a845487 100644 --- a/src/inspector/v8-runtime-agent-impl.cc +++ b/src/inspector/v8-runtime-agent-impl.cc @@ -997,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()); } } diff --git a/test/inspector/protocol-test.js b/test/inspector/protocol-test.js index d45ea22baf..a5e9505b82 100644 --- a/test/inspector/protocol-test.js +++ b/test/inspector/protocol-test.js @@ -36,7 +36,8 @@ InspectorTest.logMessage = function(originalMessage) { const nonStableFields = new Set([ 'objectId', 'scriptId', 'exceptionId', 'timestamp', 'executionContextId', 'callFrameId', 'breakpointId', 'bindRemoteObjectFunctionId', - 'formatterObjectId', 'debuggerId', 'bodyGetterId', 'uniqueId' + 'formatterObjectId', 'debuggerId', 'bodyGetterId', 'uniqueId', + 'executionContextUniqueId' ]); const message = JSON.parse(JSON.stringify(originalMessage, replacer.bind(null, Symbol(), nonStableFields))); if (message.id) diff --git a/test/inspector/runtime/context-destroyed-on-context-collected-expected.txt b/test/inspector/runtime/context-destroyed-on-context-collected-expected.txt index 9a5e1708c1..381cf88c2e 100644 --- a/test/inspector/runtime/context-destroyed-on-context-collected-expected.txt +++ b/test/inspector/runtime/context-destroyed-on-context-collected-expected.txt @@ -3,5 +3,6 @@ Tests that contextDesrtoyed nofitication is fired when context is collected. method : Runtime.executionContextDestroyed params : { executionContextId : + executionContextUniqueId : } } diff --git a/test/inspector/sessions/create-session-expected.txt b/test/inspector/sessions/create-session-expected.txt index 4459f4d19c..b8f9c5f828 100644 --- a/test/inspector/sessions/create-session-expected.txt +++ b/test/inspector/sessions/create-session-expected.txt @@ -70,6 +70,7 @@ From session 2 method : Runtime.executionContextDestroyed params : { executionContextId : + executionContextUniqueId : } } id matching: true @@ -78,6 +79,7 @@ From session 1 method : Runtime.executionContextDestroyed params : { executionContextId : + executionContextUniqueId : } } id matching: true @@ -86,6 +88,7 @@ From session 3 method : Runtime.executionContextDestroyed params : { executionContextId : + executionContextUniqueId : } } id matching: true