From 7a25608d3576809934eb9e1caeb8c0262b5b2ac5 Mon Sep 17 00:00:00 2001 From: Danny Su <dsc@meta.com> Date: Tue, 17 Dec 2024 17:26:02 -0800 Subject: [PATCH] add scriptLanguage="JavaScript" to Debugger.scriptParsed Summary: Original Author: vzaidman@meta.com Original Git: 95b2b528f5b8df1c9cbcf31e0b7e1b529ddac487 Original Reviewed By: dannysu Original Revision: D66101955 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: fbmal7 Differential Revision: D67311668 fbshipit-source-id: d0bf53b04b962d8a38920071c031bda26e141673 --- 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 cb970be9f51..55774f6abbc 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<<b6f23d499b731c057a44576d724cde32>> #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<JSONFactory::Prop, 13> paramsProps; + llvh::SmallVector<JSONFactory::Prop, 14> 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<JSONFactory::Prop, 1> 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<bool> hasSourceURL; std::optional<bool> isModule; std::optional<long long> length; + std::optional<debugger::ScriptLanguage> 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}"