Skip to content

Commit

Permalink
add scriptLanguage="JavaScript" to Debugger.scriptParsed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vzaidman authored and facebook-github-bot committed Dec 16, 2024
1 parent f708c3b commit 95b2b52
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions API/hermes/cdp/DebuggerDomainAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 4 additions & 2 deletions API/hermes/cdp/MessageTypes.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved.
// @generated SignedSource<<310395f971015ee3431e0c8490405e5c>>
// @generated SignedSource<<b6f23d499b731c057a44576d724cde32>>

#include "MessageTypes.h"

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion API/hermes/cdp/MessageTypes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved.
// @generated SignedSource<<7e121aac8a1883c75ff45194ba469176>>
// @generated SignedSource<<1284c402aedd087ebdf70e9e76596f1c>>

#pragma once

Expand Down Expand Up @@ -35,6 +35,7 @@ struct RemoveBreakpointRequest;
struct ResumeRequest;
struct ResumedNotification;
struct Scope;
using ScriptLanguage = std::string;
struct ScriptParsedNotification;
struct ScriptPosition;
struct SetBlackboxPatternsRequest;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion API/hermes/cdp/tools/run_msggen
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down

0 comments on commit 95b2b52

Please sign in to comment.