Bug 1783821 - [devtools] Manual rewrites r=bomsy

In md files and code comments and mostly from common js files.

I'm moving away from require to load sys.mjs files so that we are closer
to what we do in mozilla-central.

Differential Revision: https://phabricator.services.mozilla.com/D154073
This commit is contained in:
Alexandre Poirot 2022-09-05 12:29:57 +00:00
Родитель 10e8296ed1
Коммит 15211b3be5
8 изменённых файлов: 45 добавлений и 42 удалений

Просмотреть файл

@ -18,13 +18,13 @@ When describing the setup used by the Browser Toolbox, we will refer to those tw
The startup sequence of the browser toolbox begins in the target Firefox.
`browser-toolbox/Launcher.jsm` will be first reponsible for creating a remote DevToolsServer. This new DevToolsServer runs in the parent process but is separated from any existing DevTools DevToolsServer that spawned earlier for regular DevTools usage. Thanks to this, we will be able to debug files loaded in those regular DevToolsServers used for content toolboxes, about:debugging, ...
`browser-toolbox/Launcher.sys.mjs` will be first reponsible for creating a remote DevToolsServer. This new DevToolsServer runs in the parent process but is separated from any existing DevTools DevToolsServer that spawned earlier for regular DevTools usage. Thanks to this, we will be able to debug files loaded in those regular DevToolsServers used for content toolboxes, about:debugging, ...
Then we need to start the client Firefox. To do that, `browser-toolbox/Launcher.jsm` creates a profile that will be a copy of the current profile loaded in the target Firefox, so that all user preferences can be automatically ported over. As a reminder both client and target Firefox will run simultaneously, so they can't use the same profile.
Then we need to start the client Firefox. To do that, `browser-toolbox/Launcher.sys.mjs` creates a profile that will be a copy of the current profile loaded in the target Firefox, so that all user preferences can be automatically ported over. As a reminder both client and target Firefox will run simultaneously, so they can't use the same profile.
This new profile is stored inside the folder of the target profile, in a `chrome_debugger_profile` folder. So the next time the Browser Toolbox opens this for profile, it will be reused.
Once the profile is ready (or if it was already there), `browser-toolbox/Launcher.jsm` spawns a new Firefox instance with a few additional parameters, most importantly `-chrome chrome://devtools/content/framework/browser-toolbox/window.html`.
Once the profile is ready (or if it was already there), `browser-toolbox/Launcher.sys.mjs` spawns a new Firefox instance with a few additional parameters, most importantly `-chrome chrome://devtools/content/framework/browser-toolbox/window.html`.
This way Firefox will load `browser-toolbox/window.html` instead of the regular browser window. Most of the logic is then handled by `browser-toolbox/window.js` which will connect to the remote server opened on the target Firefox and will then load a toolbox connected to this server.
@ -32,6 +32,6 @@ This way Firefox will load `browser-toolbox/window.html` instead of the regular
Note that you can open a Browser Toolbox from the Browser Toolbox. Simply reuse the same shortcut as the one you used to open the first Browser Toolbox, but this time while the Browser Toolbox window is focused.
Another Browser Toolbox will spawn, this time debugging the first Browser Toolbox Firefox instance. If you are curious about how this is done, `browser-toolbox/window.js` simply loads `browser-toolbox/Launcher.jsm` and requests to open a new Browser Toolbox.
Another Browser Toolbox will spawn, this time debugging the first Browser Toolbox Firefox instance. If you are curious about how this is done, `browser-toolbox/window.js` simply loads `browser-toolbox/Launcher.sys.mjs` and requests to open a new Browser Toolbox.
This will open yet another Firefox instance, running in another process. And a new `chrome_debugger_profile` folder will be created inside the existing Browser Toolbox profile (which as explained in the previous section, is already in a `chrome_debugger_profile` folder under the target Firefox profile).

Просмотреть файл

@ -24,11 +24,12 @@ const L10N = new LocalizationHelper(
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
loader.lazyImporter(
this,
"BrowserToolboxLauncher",
"resource://devtools/client/framework/browser-toolbox/Launcher.jsm"
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BrowserToolboxLauncher:
"resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs",
});
// Timeout to wait before we assume that a connect() timed out without an error.
// In milliseconds. (With the Debugger pane open, this has been reported to last
@ -187,7 +188,7 @@ function onCloseCommand(event) {
* running in the parent process. i.e. frontend code.
*/
function onDebugBrowserToolbox() {
BrowserToolboxLauncher.init();
lazy.BrowserToolboxLauncher.init();
}
/**

Просмотреть файл

@ -13,6 +13,14 @@
**/
const Services = require("Services");
const ChromeUtils = require("ChromeUtils");
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BrowserToolboxLauncher:
"resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs",
});
const { gDevTools } = require("devtools/client/framework/devtools");
const {
getTheme,
@ -61,11 +69,6 @@ loader.lazyRequireGetter(
"devtools/client/framework/enable-devtools-popup",
true
);
loader.lazyImporter(
this,
"BrowserToolboxLauncher",
"resource://devtools/client/framework/browser-toolbox/Launcher.jsm"
);
const { LocalizationHelper } = require("devtools/shared/l10n");
const L10N = new LocalizationHelper(
@ -321,7 +324,7 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = {
}
break;
case "browserToolbox":
BrowserToolboxLauncher.init();
lazy.BrowserToolboxLauncher.init();
break;
case "browserConsole":
const {

Просмотреть файл

@ -6,11 +6,18 @@
const { Cu } = require("chrome");
const Services = require("Services");
const ChromeUtils = require("ChromeUtils");
const {
DevToolsShim,
} = require("chrome://devtools-startup/content/DevToolsShim.jsm");
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BrowserToolboxLauncher:
"resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs",
});
loader.lazyRequireGetter(
this,
"TabDescriptorFactory",
@ -43,11 +50,6 @@ loader.lazyRequireGetter(
);
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
loader.lazyImporter(
this,
"BrowserToolboxLauncher",
"resource://devtools/client/framework/browser-toolbox/Launcher.jsm"
);
const {
defaultTools: DefaultTools,
@ -451,7 +453,7 @@ DevTools.prototype = {
*/
saveDevToolsSession(state) {
state.browserConsole = BrowserConsoleManager.getBrowserConsoleSessionState();
state.browserToolbox = BrowserToolboxLauncher.getBrowserToolboxSessionState();
state.browserToolbox = lazy.BrowserToolboxLauncher.getBrowserToolboxSessionState();
},
/**
@ -459,7 +461,7 @@ DevTools.prototype = {
*/
async restoreDevToolsSession({ browserConsole, browserToolbox }) {
if (browserToolbox) {
BrowserToolboxLauncher.init();
lazy.BrowserToolboxLauncher.init();
}
if (browserConsole && !BrowserConsoleManager.getBrowserConsole()) {

Просмотреть файл

@ -26,6 +26,13 @@
*/
const { Cu } = require("chrome");
const ChromeUtils = require("ChromeUtils");
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BrowserToolboxLauncher:
"resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs",
});
loader.lazyRequireGetter(this, "Services", "Services");
loader.lazyRequireGetter(this, "flags", "devtools/shared/flags");
@ -54,11 +61,6 @@ loader.lazyRequireGetter(
true
);
loader.lazyImporter(
this,
"BrowserToolboxLauncher",
"resource://devtools/client/framework/browser-toolbox/Launcher.jsm"
);
loader.lazyRequireGetter(
this,
"PICKER_TYPES",
@ -92,7 +94,7 @@ exports.menuitems = [
id: "menu_browserToolbox",
l10nKey: "browserToolboxMenu",
oncommand() {
BrowserToolboxLauncher.init();
lazy.BrowserToolboxLauncher.init();
},
keyId: "browserToolbox",
},

Просмотреть файл

@ -215,7 +215,7 @@ var loader = new DevToolsLoader({
* B2G. It is not the default case for desktop Firefox because we offer the
* Browser Toolbox for chrome debugging there, which uses its own, separate
* loader instance.
* @see devtools/client/framework/browser-toolbox/Launcher.jsm
* @see devtools/client/framework/browser-toolbox/Launcher.sys.mjs
*/
invisibleToDebugger: Services.appinfo.name !== "Firefox",
});

Просмотреть файл

@ -19,16 +19,11 @@ const { E10SUtils } = ChromeUtils.import(
const { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
var { loader } = ChromeUtils.import(
"resource://devtools/shared/loader/Loader.jsm"
);
loader.lazyImporter(
this,
"BrowserToolboxLauncher",
"resource://devtools/client/framework/browser-toolbox/Launcher.jsm"
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BrowserToolboxLauncher:
"resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs",
});
const FEATURES = {
paintDumping: "nglayout.debug.paint_dumping",
@ -112,7 +107,7 @@ class Debugger {
}
openDevTools() {
BrowserToolboxLauncher.init();
lazy.BrowserToolboxLauncher.init();
}
async _sendMessage(name, arg) {

Просмотреть файл

@ -4564,7 +4564,7 @@ Maybe<ShouldNotProcessUpdatesReason> ShouldNotProcessUpdates(
// "--chrome ..." with the browser toolbox chrome document URL.
// Keep this synchronized with the value of the same name in
// devtools/client/framework/browser-toolbox/Launcher.jsm. Or, for bonus
// devtools/client/framework/browser-toolbox/Launcher.sys.mjs. Or, for bonus
// points, lift this value to nsIXulRuntime or similar, so that it can be
// accessed in both locations. (The prefs service isn't available at this
// point so the simplest manner of sharing the value is not available to us.)