From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mail/components/devtools/tb-root-actor.js | 104 +++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 comm/mail/components/devtools/tb-root-actor.js (limited to 'comm/mail/components/devtools/tb-root-actor.js') diff --git a/comm/mail/components/devtools/tb-root-actor.js b/comm/mail/components/devtools/tb-root-actor.js new file mode 100644 index 0000000000..3f546605f6 --- /dev/null +++ b/comm/mail/components/devtools/tb-root-actor.js @@ -0,0 +1,104 @@ +/* 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/. */ + +/* globals loader, require, exports */ + +/** + * Actors for Thunderbird Developer Tools, for example the root actor or tab + * list actor. + */ + +var { ActorRegistry } = require("devtools/server/actors/utils/actor-registry"); + +loader.lazyRequireGetter( + this, + "RootActor", + "devtools/server/actors/root", + true +); +loader.lazyRequireGetter( + this, + "BrowserTabList", + "devtools/server/actors/webbrowser", + true +); +loader.lazyRequireGetter( + this, + "BrowserAddonList", + "devtools/server/actors/webbrowser", + true +); +loader.lazyRequireGetter( + this, + "sendShutdownEvent", + "devtools/server/actors/webbrowser", + true +); +loader.lazyRequireGetter( + this, + "WorkerDescriptorActorList", + "devtools/server/actors/worker/worker-descriptor-actor-list", + true +); +loader.lazyRequireGetter( + this, + "ServiceWorkerRegistrationActorList", + "devtools/server/actors/worker/service-worker-registration-list", + true +); +loader.lazyRequireGetter( + this, + "ProcessActorList", + "devtools/server/actors/process", + true +); + +/** + * Create the root actor for Thunderbird. + * + * @param aConnection The debugger connection to create the actor for. + * @returns The mail actor for the connection. + */ +exports.createRootActor = function (aConnection) { + let parameters = { + tabList: new TBTabList(aConnection), + addonList: new BrowserAddonList(aConnection), + workerList: new WorkerDescriptorActorList(aConnection, {}), + serviceWorkerRegistrationList: new ServiceWorkerRegistrationActorList( + aConnection + ), + processList: new ProcessActorList(), + globalActorFactories: ActorRegistry.globalActorFactories, + onShutdown: sendShutdownEvent, + }; + + // Create the root actor and set the application type + let rootActor = new RootActor(aConnection, parameters); + rootActor.applicationType = "mail"; + + return rootActor; +}; + +/** + * Thunderbird's version of the tab list. We don't have gBrowser, but tabmail has similar functions + * that will be helpful. The tabs displayed are those tabs in tabmail that have a browser element. + * This is mainly the contentTabs, but can also be others such as the start page. + */ +class TBTabList extends BrowserTabList { + _getSelectedBrowser(window) { + let tabmail = window.document.getElementById("tabmail"); + return tabmail ? tabmail.selectedBrowser : null; + } + + _getChildren(window) { + let tabmail = window.document.getElementById("tabmail"); + if (!tabmail) { + return []; + } + + return tabmail.tabInfo + .map(tab => tabmail.getBrowserForTab(tab)) + .filter(Boolean); + } +} -- cgit v1.2.3