From a866bb1c3a7182700231c0861ef43dcd842a58f8 Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Wed, 10 Jan 2024 16:12:43 +0100 Subject: [PATCH] #633 enables a new option in the developer tools settings for deactivating the debugger javascript statement --- build/cromite_patches_list.txt | 1 + ...ivation-of-the-js-debugger-statement.patch | 336 ++++++++++++++++++ 2 files changed, 337 insertions(+) create mode 100644 build/patches/00Enables-deactivation-of-the-js-debugger-statement.patch diff --git a/build/cromite_patches_list.txt b/build/cromite_patches_list.txt index c845b26b1..f8b346f1b 100644 --- a/build/cromite_patches_list.txt +++ b/build/cromite_patches_list.txt @@ -277,6 +277,7 @@ Timezone-customization.patch 00Enable-search-engine-settings-desktop-ui.patch 00Disable-Android-AppRestrictions.patch 00Customize-selection-popup.patch +00Enables-deactivation-of-the-js-debugger-statement.patch 00Temp-PerformanceNavigationTiming-privacy-fix.patch 00Temp-disable-predictive-back-gesture.patch diff --git a/build/patches/00Enables-deactivation-of-the-js-debugger-statement.patch b/build/patches/00Enables-deactivation-of-the-js-debugger-statement.patch new file mode 100644 index 000000000..83430190f --- /dev/null +++ b/build/patches/00Enables-deactivation-of-the-js-debugger-statement.patch @@ -0,0 +1,336 @@ +From: uazo +Date: Wed, 10 Jan 2024 13:42:27 +0000 +Subject: Enables deactivation of the js debugger statement + +enables a new option in the developer tools settings for +deactivating the debugger javascript statement + +License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html +--- + .../src/front_end/core/sdk/DebuggerModel.ts | 9 ++++++++ + .../src/front_end/core/sdk/sdk-meta.ts | 23 +++++++++++++++++++ + .../generated/InspectorBackendCommands.js | 4 ++++ + .../front_end/generated/protocol-mapping.d.ts | 4 ++++ + .../generated/protocol-proxy-api.d.ts | 2 ++ + .../src/front_end/generated/protocol.ts | 4 ++++ + .../devtools_protocol/browser_protocol.json | 15 +++++++++--- + v8/include/js_protocol.pdl | 4 ++++ + v8/src/common/message-template.h | 1 + + v8/src/debug/debug-interface.cc | 5 ++++ + v8/src/debug/debug-interface.h | 3 +++ + v8/src/debug/debug.h | 5 ++++ + v8/src/execution/messages.cc | 1 + + v8/src/inspector/v8-debugger-agent-impl.cc | 8 +++++++ + v8/src/inspector/v8-debugger-agent-impl.h | 1 + + v8/src/runtime/runtime-debug.cc | 17 ++++++++++++-- + 16 files changed, 101 insertions(+), 5 deletions(-) + +diff --git a/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts b/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts +--- a/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts ++++ b/third_party/devtools-frontend/src/front_end/core/sdk/DebuggerModel.ts +@@ -220,6 +220,9 @@ export class DebuggerModel extends SDKModel { + Common.Settings.Settings.instance() + .moduleSetting('disableAsyncStackTraces') + .addChangeListener(this.asyncStackTracesStateChanged, this); ++ Common.Settings.Settings.instance() ++ .moduleSetting('disableDebuggerStatement') ++ .addChangeListener(this.DebuggerStatementChanged, this); + Common.Settings.Settings.instance() + .moduleSetting('breakpointsActive') + .addChangeListener(this.breakpointsActiveChanged, this); +@@ -233,6 +236,7 @@ export class DebuggerModel extends SDKModel { + Common.Settings.Settings.instance() + .moduleSetting('jsSourceMapsEnabled') + .addChangeListener(event => this.#sourceMapManagerInternal.setEnabled((event.data as boolean))); ++ this.DebuggerStatementChanged(); + + const resourceTreeModel = (target.model(ResourceTreeModel) as ResourceTreeModel); + if (resourceTreeModel) { +@@ -389,6 +393,11 @@ export class DebuggerModel extends SDKModel { + return this.agent.invoke_setAsyncCallStackDepth({maxDepth}); + } + ++ private DebuggerStatementChanged(): Promise { ++ const enabled = !Common.Settings.Settings.instance().moduleSetting('disableDebuggerStatement').get(); ++ return this.agent.invoke_setDebuggerStatementEnabled({enabled}); ++ } ++ + private breakpointsActiveChanged(): void { + void this.agent.invoke_setBreakpointsActive( + {active: Common.Settings.Settings.instance().moduleSetting('breakpointsActive').get()}); +diff --git a/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts b/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts +--- a/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts ++++ b/third_party/devtools-frontend/src/front_end/core/sdk/sdk-meta.ts +@@ -34,6 +34,10 @@ const UIStrings = { + *@description Title of a setting under the Debugger category in Settings + */ + disableAsyncStackTraces: 'Disable async stack traces', ++ /** ++ *@description Title of a setting under the Debugger category in Settings ++ */ ++ disableDebuggerStatement: 'Disable debugger statement', + /** + *@description Title of a setting under the Debugger category that can be invoked through the Command Menu + */ +@@ -438,6 +442,25 @@ Common.Settings.registerSettingExtension({ + ], + }); + ++Common.Settings.registerSettingExtension({ ++ category: Common.Settings.SettingCategory.DEBUGGER, ++ title: i18nLazyString(UIStrings.disableDebuggerStatement), ++ settingName: 'disableDebuggerStatement', ++ settingType: Common.Settings.SettingType.BOOLEAN, ++ defaultValue: false, ++ order: 999, ++ options: [ ++ { ++ value: true, ++ title: i18nLazyString(UIStrings.doNotCaptureAsyncStackTraces), ++ }, ++ { ++ value: false, ++ title: i18nLazyString(UIStrings.captureAsyncStackTraces), ++ }, ++ ], ++}); ++ + Common.Settings.registerSettingExtension({ + category: Common.Settings.SettingCategory.DEBUGGER, + settingName: 'breakpointsActive', +diff --git a/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js b/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js +--- a/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js ++++ b/third_party/devtools-frontend/src/front_end/generated/InspectorBackendCommands.js +@@ -1276,6 +1276,10 @@ inspectorBackend.registerCommand("Debugger.restartFrame", [{"name": "callFrameId + inspectorBackend.registerCommand("Debugger.resume", [{"name": "terminateOnResume", "type": "boolean", "optional": true, "description": "Set to true to terminate execution upon resuming execution. In contrast to Runtime.terminateExecution, this will allows to execute further JavaScript (i.e. via evaluation) until execution of the paused code is actually resumed, at which point termination is triggered. If execution is currently not paused, this parameter has no effect.", "typeRef": null}], [], "Resumes JavaScript execution."); + inspectorBackend.registerCommand("Debugger.searchInContent", [{"name": "scriptId", "type": "string", "optional": false, "description": "Id of the script to search in.", "typeRef": "Runtime.ScriptId"}, {"name": "query", "type": "string", "optional": false, "description": "String to search for.", "typeRef": null}, {"name": "caseSensitive", "type": "boolean", "optional": true, "description": "If true, search is case sensitive.", "typeRef": null}, {"name": "isRegex", "type": "boolean", "optional": true, "description": "If true, treats string parameter as regex.", "typeRef": null}], ["result"], "Searches for given string in script content."); + inspectorBackend.registerCommand("Debugger.setAsyncCallStackDepth", [{"name": "maxDepth", "type": "number", "optional": false, "description": "Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async call stacks (default).", "typeRef": null}], [], "Enables or disables async call stacks tracking."); ++inspectorBackend.registerCommand("Debugger.setDebuggerStatementEnabled", [ ++ {"name": "value", "type": "boolean", "optional": false, ++ "description": "", ++ "typeRef": null}], [], ""); + inspectorBackend.registerCommand("Debugger.setBlackboxPatterns", [{"name": "patterns", "type": "array", "optional": false, "description": "Array of regexps that will be used to check script url for blackbox state.", "typeRef": "string"}], [], "Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful."); + inspectorBackend.registerCommand("Debugger.setBlackboxedRanges", [{"name": "scriptId", "type": "string", "optional": false, "description": "Id of the script.", "typeRef": "Runtime.ScriptId"}, {"name": "positions", "type": "array", "optional": false, "description": "", "typeRef": "Debugger.ScriptPosition"}], [], "Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted."); + inspectorBackend.registerCommand("Debugger.setBreakpoint", [{"name": "location", "type": "object", "optional": false, "description": "Location to set breakpoint in.", "typeRef": "Debugger.Location"}, {"name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.", "typeRef": null}], ["breakpointId", "actualLocation"], "Sets JavaScript breakpoint at a given location."); +diff --git a/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts b/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts +--- a/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts ++++ b/third_party/devtools-frontend/src/front_end/generated/protocol-mapping.d.ts +@@ -4417,6 +4417,10 @@ export namespace ProtocolMapping { + paramsType: [Protocol.Debugger.SetAsyncCallStackDepthRequest]; + returnType: void; + }; ++ 'Debugger.setDebuggerStatementEnabled': { ++ paramsType: [Protocol.Debugger.setDebuggerStatementEnabledRequest]; ++ returnType: void; ++ }; + /** + * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in + * scripts with url matching one of the patterns. VM will try to leave blackboxed script by +diff --git a/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts b/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts +--- a/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts ++++ b/third_party/devtools-frontend/src/front_end/generated/protocol-proxy-api.d.ts +@@ -3908,6 +3908,8 @@ declare namespace ProtocolProxyApi { + */ + invoke_setAsyncCallStackDepth(params: Protocol.Debugger.SetAsyncCallStackDepthRequest): Promise; + ++ invoke_setDebuggerStatementEnabled(params: Protocol.Debugger.SetDebuggerStatementEnabledRequest): Promise; ++ + /** + * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in + * scripts with url matching one of the patterns. VM will try to leave blackboxed script by +diff --git a/third_party/devtools-frontend/src/front_end/generated/protocol.ts b/third_party/devtools-frontend/src/front_end/generated/protocol.ts +--- a/third_party/devtools-frontend/src/front_end/generated/protocol.ts ++++ b/third_party/devtools-frontend/src/front_end/generated/protocol.ts +@@ -16837,6 +16837,10 @@ export namespace Debugger { + maxDepth: integer; + } + ++ export interface SetDebuggerStatementEnabledRequest { ++ enabled: boolean; ++ } ++ + export interface SetBlackboxPatternsRequest { + /** + * Array of regexps that will be used to check script url for blackbox state. +diff --git a/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json b/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json +--- a/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json ++++ b/third_party/devtools-frontend/src/third_party/blink/public/devtools_protocol/browser_protocol.json +@@ -25238,8 +25238,17 @@ + "$ref": "WasmDisassemblyChunk" + } + ] +- }, +- { ++ },{ ++ "name": "setDebuggerStatementEnabled", ++ "description": "Enables or disables debugger javascript statement.", ++ "parameters": [ ++ { ++ "name": "enabled", ++ "description": "Enables or disables debugger javascript statement", ++ "type": "boolean" ++ } ++ ] ++ },{ + "name": "nextWasmDisassemblyChunk", + "description": "Disassemble the next chunk of lines for the module corresponding to the\nstream. If disassembly is complete, this API will invalidate the streamId\nand return an empty chunk. Any subsequent calls for the now invalid stream\nwill return errors.", + "experimental": true, +@@ -28367,4 +28376,4 @@ + ] + } + ] +-} +\ No newline at end of file ++} +diff --git a/v8/include/js_protocol.pdl b/v8/include/js_protocol.pdl +--- a/v8/include/js_protocol.pdl ++++ b/v8/include/js_protocol.pdl +@@ -362,6 +362,10 @@ domain Debugger + # List of search matches. + array of SearchMatch result + ++ command setDebuggerStatementEnabled ++ parameters ++ boolean enabled ++ + # Enables or disables async call stacks tracking. + command setAsyncCallStackDepth + parameters +diff --git a/v8/src/common/message-template.h b/v8/src/common/message-template.h +--- a/v8/src/common/message-template.h ++++ b/v8/src/common/message-template.h +@@ -729,6 +729,7 @@ namespace internal { + /* AggregateError */ \ + T(AllPromisesRejected, "All promises were rejected") \ + T(CannotDeepFreezeObject, "Cannot DeepFreeze object of type %") \ ++ T(DebuggerStatementSuppressed, "debugger statement suppressed") \ + T(CannotDeepFreezeValue, "Cannot DeepFreeze non-const value %") + + enum class MessageTemplate { +diff --git a/v8/src/debug/debug-interface.cc b/v8/src/debug/debug-interface.cc +--- a/v8/src/debug/debug-interface.cc ++++ b/v8/src/debug/debug-interface.cc +@@ -1013,6 +1013,11 @@ void SetAsyncEventDelegate(Isolate* v8_isolate, AsyncEventDelegate* delegate) { + reinterpret_cast(v8_isolate)->set_async_event_delegate(delegate); + } + ++void SetDebuggerStatementEnabled(Isolate* v8_isolate, bool in_enabled) { ++ i::Isolate* isolate = reinterpret_cast(v8_isolate); ++ isolate->debug()->SetDebuggerStatementEnabled(in_enabled); ++} ++ + void ResetBlackboxedStateCache(Isolate* v8_isolate, Local