From 95b2b528f5b8df1c9cbcf31e0b7e1b529ddac487 Mon Sep 17 00:00:00 2001 From: Vitali Zaidman Date: Mon, 16 Dec 2024 06:08:40 -0800 Subject: [PATCH] add scriptLanguage="JavaScript" to Debugger.scriptParsed Summary: The option to "ignore scripts" from the context menu only works for JS files. The type of file is set when the debugger raises the CDP command [Debugger.scriptParsed](https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#event-scriptParsed) using the `scriptLanguage` field. That field was not set before. Now it's sent as "JavaScript". (the other possible option is WebAssembly" which we don't support). See: * https://github.com/ChromeDevTools/devtools-frontend/blob/7a7a8a4ba54c30d7e00ec5aee105910c57466a06/front_end/panels/sources/SourcesPanel.ts#L968 * https://source.chromium.org/chromium/chromium/src/+/main:v8/src/inspector/v8-debugger-agent-impl.cc;l=1875-1882 Reviewed By: dannysu Differential Revision: D66101955 fbshipit-source-id: 501b44782f6aed145fd145ee957ef0a9bcbcdd91 --- API/hermes/cdp/DebuggerDomainAgent.cpp | 3 +++ API/hermes/cdp/MessageTypes.cpp | 6 ++++-- API/hermes/cdp/MessageTypes.h | 4 +++- API/hermes/cdp/tools/run_msggen | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/API/hermes/cdp/DebuggerDomainAgent.cpp b/API/hermes/cdp/DebuggerDomainAgent.cpp index 4a823162664..2f40386ac64 100644 --- a/API/hermes/cdp/DebuggerDomainAgent.cpp +++ b/API/hermes/cdp/DebuggerDomainAgent.cpp @@ -733,6 +733,9 @@ void DebuggerDomainAgent::sendScriptParsedNotificationToClient( note.scriptId = std::to_string(srcLoc.fileId); note.url = srcLoc.fileName; note.executionContextId = executionContextID_; + // Either JavaScript or WebAssembly. See: + // https://source.chromium.org/chromium/chromium/src/+/main:v8/src/inspector/v8-debugger-agent-impl.cc;l=1875-1882 + note.scriptLanguage = "JavaScript"; std::string sourceMappingUrl = runtime_.getDebugger().getSourceMappingUrl(srcLoc.fileId); if (!sourceMappingUrl.empty()) { diff --git a/API/hermes/cdp/MessageTypes.cpp b/API/hermes/cdp/MessageTypes.cpp index eb84e19cd47..e4820ffeee8 100644 --- a/API/hermes/cdp/MessageTypes.cpp +++ b/API/hermes/cdp/MessageTypes.cpp @@ -1,5 +1,5 @@ // Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. -// @generated SignedSource<<310395f971015ee3431e0c8490405e5c>> +// @generated SignedSource<> #include "MessageTypes.h" @@ -2786,12 +2786,13 @@ debugger::ScriptParsedNotification::tryMake(const JSONObject *obj) { TRY_ASSIGN(notif->hasSourceURL, params, "hasSourceURL"); TRY_ASSIGN(notif->isModule, params, "isModule"); TRY_ASSIGN(notif->length, params, "length"); + TRY_ASSIGN(notif->scriptLanguage, params, "scriptLanguage"); return notif; } JSONValue *debugger::ScriptParsedNotification::toJsonVal( JSONFactory &factory) const { - llvh::SmallVector paramsProps; + llvh::SmallVector paramsProps; put(paramsProps, "scriptId", scriptId, factory); put(paramsProps, "url", url, factory); put(paramsProps, "startLine", startLine, factory); @@ -2806,6 +2807,7 @@ JSONValue *debugger::ScriptParsedNotification::toJsonVal( put(paramsProps, "hasSourceURL", hasSourceURL, factory); put(paramsProps, "isModule", isModule, factory); put(paramsProps, "length", length, factory); + put(paramsProps, "scriptLanguage", scriptLanguage, factory); llvh::SmallVector props; put(props, "method", method, factory); diff --git a/API/hermes/cdp/MessageTypes.h b/API/hermes/cdp/MessageTypes.h index 06fc8478ad8..bdc14d394a7 100644 --- a/API/hermes/cdp/MessageTypes.h +++ b/API/hermes/cdp/MessageTypes.h @@ -1,5 +1,5 @@ // Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved. -// @generated SignedSource<<7e121aac8a1883c75ff45194ba469176>> +// @generated SignedSource<<1284c402aedd087ebdf70e9e76596f1c>> #pragma once @@ -35,6 +35,7 @@ struct RemoveBreakpointRequest; struct ResumeRequest; struct ResumedNotification; struct Scope; +using ScriptLanguage = std::string; struct ScriptParsedNotification; struct ScriptPosition; struct SetBlackboxPatternsRequest; @@ -1196,6 +1197,7 @@ struct debugger::ScriptParsedNotification : public Notification { std::optional hasSourceURL; std::optional isModule; std::optional length; + std::optional scriptLanguage; }; struct heapProfiler::AddHeapSnapshotChunkNotification : public Notification { diff --git a/API/hermes/cdp/tools/run_msggen b/API/hermes/cdp/tools/run_msggen index 520feea3273..74a48b4ba32 100755 --- a/API/hermes/cdp/tools/run_msggen +++ b/API/hermes/cdp/tools/run_msggen @@ -19,7 +19,7 @@ yarn build node bin/index.js \ --ignore-experimental \ - --include-experimental=Debugger.ScriptPosition,Debugger.setBlackboxedRanges,Debugger.setBlackboxPatterns,Runtime.inspectRequested.executionContextId,Runtime.getProperties.generatePreview,Runtime.getProperties.accessorPropertiesOnly,Runtime.evaluate.generatePreview,Runtime.callFunctionOn.generatePreview,Debugger.evaluateOnCallFrame.generatePreview,Runtime.RemoteObject.preview,Runtime.RemoteObject.customPreview,Runtime.CustomPreview,Runtime.EntryPreview,Runtime.ObjectPreview,Runtime.PropertyPreview,Runtime.getHeapUsage \ + --include-experimental=Debugger.scriptParsed.scriptLanguage,Debugger.ScriptPosition,Debugger.setBlackboxedRanges,Debugger.setBlackboxPatterns,Runtime.inspectRequested.executionContextId,Runtime.getProperties.generatePreview,Runtime.getProperties.accessorPropertiesOnly,Runtime.evaluate.generatePreview,Runtime.callFunctionOn.generatePreview,Debugger.evaluateOnCallFrame.generatePreview,Runtime.RemoteObject.preview,Runtime.RemoteObject.customPreview,Runtime.CustomPreview,Runtime.EntryPreview,Runtime.ObjectPreview,Runtime.PropertyPreview,Runtime.getHeapUsage \ --roots "${MSGTYPES_PATH}" \ "${HEADER_PATH}" "${CPP_PATH}"