Commit 7a46b06f authored by Nicolas Chevobbe's avatar Nicolas Chevobbe
Browse files

Bug 1782667 - [devtools] Start multiprocess browser toolbox when running...

Bug 1782667 - [devtools] Start multiprocess browser toolbox when running mochitests with --jsdebugger. r=jdescottes.

Differential Revision: https://phabricator.services.mozilla.com/D153599
parent c4bac4b0
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ const processes = new Set();
 * @property {function} onRun - A function called when the process starts running.
 * @property {boolean} overwritePreferences - Set to force overwriting the toolbox
 *                     profile's preferences with the current set of preferences.
 * @property {boolean} forceMultiprocess - Set to force the Browser Toolbox to be in
 *                     multiprocess mode.
 */

class BrowserToolboxLauncher extends EventEmitter {
@@ -104,7 +106,7 @@ class BrowserToolboxLauncher extends EventEmitter {
   *
   * @param {...BrowserToolboxLauncherArgs} args
   */
  constructor({ onRun, overwritePreferences } = {}) {
  constructor({ forceMultiprocess, onRun, overwritePreferences } = {}) {
    super();

    if (onRun) {
@@ -115,7 +117,7 @@ class BrowserToolboxLauncher extends EventEmitter {
    Services.obs.addObserver(this.close, "quit-application");
    this.#initServer();
    this.#initProfile(overwritePreferences);
    this.#create();
    this.#create({ forceMultiprocess });

    processes.add(this);
  }
@@ -287,8 +289,12 @@ class BrowserToolboxLauncher extends EventEmitter {

  /**
   * Creates and initializes the profile & process for the remote debugger.
   *
   * @param {Object} options
   * @param {boolean} options.forceMultiprocess: Set to true to force the Browser Toolbox to be in
   *                    multiprocess mode.
   */
  #create() {
  #create({ forceMultiprocess } = {}) {
    dumpn("Initializing chrome debugging process.");

    let command = Services.dirsvc.get("XREExeF", Ci.nsIFile).path;
@@ -337,6 +343,7 @@ class BrowserToolboxLauncher extends EventEmitter {
      // Will be read by the Browser Toolbox Firefox instance to update the
      // devtools.browsertoolbox.fission pref on the Browser Toolbox profile.
      MOZ_BROWSER_TOOLBOX_FISSION_PREF: isBrowserToolboxFission ? "1" : "0",
      MOZ_BROWSER_TOOLBOX_FORCE_MULTIPROCESS: forceMultiprocess ? "1" : "0",
      // Similar, but for the WebConsole input context dropdown.
      MOZ_BROWSER_TOOLBOX_INPUT_CONTEXT: isInputContextEnabled ? "1" : "0",
      // Disable safe mode for the new process in case this was opened via the
+4 −0
Original line number Diff line number Diff line
@@ -81,6 +81,10 @@ var connect = async function() {
    "devtools.webconsole.input.context",
    env.get("MOZ_BROWSER_TOOLBOX_INPUT_CONTEXT") === "1"
  );
  // Similar, but for the Browser Toolbox mode
  if (env.get("MOZ_BROWSER_TOOLBOX_FORCE_MULTIPROCESS") === "1") {
    Services.prefs.setCharPref("devtools.browsertoolbox.scope", "everything");
  }

  const port = env.get("MOZ_BROWSER_TOOLBOX_PORT");

+9 −1
Original line number Diff line number Diff line
@@ -919,7 +919,15 @@ DevToolsStartup.prototype = {
    // See comment within BrowserToolboxLauncher.
    // Setting it as an environment variable helps it being reused if we restart the browser via CmdOrCtrl+R
    env.set("MOZ_BROWSER_TOOLBOX_BINARY", binaryPath);
    BrowserToolboxLauncher.init();

    const browserToolboxLauncherConfig = {};

    // If user passed the --jsdebugger in mochitests, we want to enable the
    // multiprocess Browser Toolbox (by default it's parent process only)
    if (Services.prefs.getBoolPref("devtools.testing", false)) {
      browserToolboxLauncherConfig.forceMultiprocess = true;
    }
    BrowserToolboxLauncher.init(browserToolboxLauncherConfig);

    if (pauseOnStartup) {
      // Spin the event loop until the debugger connects.