diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/server/actors/breakpoint-list.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/actors/breakpoint-list.js')
-rw-r--r-- | devtools/server/actors/breakpoint-list.js | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/devtools/server/actors/breakpoint-list.js b/devtools/server/actors/breakpoint-list.js new file mode 100644 index 0000000000..86efe4f4c7 --- /dev/null +++ b/devtools/server/actors/breakpoint-list.js @@ -0,0 +1,94 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { Actor } = require("resource://devtools/shared/protocol.js"); +const { + breakpointListSpec, +} = require("resource://devtools/shared/specs/breakpoint-list.js"); + +const { + SessionDataHelpers, +} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm"); +const { SUPPORTED_DATA } = SessionDataHelpers; +const { BREAKPOINTS, XHR_BREAKPOINTS, EVENT_BREAKPOINTS } = SUPPORTED_DATA; + +/** + * This actor manages the breakpoints list. + * + * Breakpoints should be available as early as possible to new targets and + * will be forwarded to the WatcherActor to populate the shared session data available to + * all DevTools targets. + * + * @constructor + * + */ +class BreakpointListActor extends Actor { + constructor(watcherActor) { + super(watcherActor.conn, breakpointListSpec); + this.watcherActor = watcherActor; + } + + setBreakpoint(location, options) { + return this.watcherActor.addDataEntry(BREAKPOINTS, [{ location, options }]); + } + + removeBreakpoint(location, options) { + return this.watcherActor.removeDataEntry(BREAKPOINTS, [ + { location, options }, + ]); + } + + /** + * Request to break on next XHR or Fetch request for a given URL and HTTP Method. + * + * @param {String} path + * If empty, will pause on regardless or the request's URL. + * Otherwise, will pause on any request whose URL includes this string. + * This is not specific to URL's path. It can match the URL origin. + * @param {String} method + * If set to "ANY", will pause regardless of which method is used. + * Otherwise, should be set to any valid HTTP Method (GET, POST, ...) + */ + setXHRBreakpoint(path, method) { + return this.watcherActor.addDataEntry(XHR_BREAKPOINTS, [{ path, method }]); + } + + /** + * Stop breakpoint on requests we ask to break on via setXHRBreakpoint. + * + * See setXHRBreakpoint for arguments definition. + */ + removeXHRBreakpoint(path, method) { + return this.watcherActor.removeDataEntry(XHR_BREAKPOINTS, [ + { path, method }, + ]); + } + + /** + * Set the active breakpoints + * + * @param {Array<String>} ids + * An array of eventlistener breakpoint ids. These + * are unique identifiers for event breakpoints. + * See devtools/server/actors/utils/event-breakpoints.js + * for details. + */ + setActiveEventBreakpoints(ids) { + const existingIds = + this.watcherActor.getSessionDataForType(EVENT_BREAKPOINTS) || []; + const addIds = ids.filter(id => !existingIds.includes(id)); + const removeIds = existingIds.filter(id => !ids.includes(id)); + + if (addIds.length) { + this.watcherActor.addDataEntry(EVENT_BREAKPOINTS, addIds); + } + if (removeIds.length) { + this.watcherActor.removeDataEntry(EVENT_BREAKPOINTS, removeIds); + } + } +} + +exports.BreakpointListActor = BreakpointListActor; |