Bug 1651391 - Display remote type in the browser toolbox context selector. r=nchevobbe
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 26 Jan 2021 13:37:56 +0000
changeset 564673 053436fec044733fe613758ee3993fcc4f21ab6b
parent 564672 4daf19dcc91b24ad0d9a5ab4255880d054c77e03
child 564674 60746aad382ba81e44517e3703e905d64bf7f48c
push id38145
push userbtara@mozilla.com
push dateWed, 27 Jan 2021 04:32:48 +0000
treeherdermozilla-central@3ed82636d765 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1651391
milestone87.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1651391 - Display remote type in the browser toolbox context selector. r=nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D88082
devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_evaluation_context.js
devtools/client/fronts/targets/content-process.js
devtools/server/actors/targets/content-process.js
--- a/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_evaluation_context.js
+++ b/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_evaluation_context.js
@@ -16,58 +16,66 @@ requestLongerTimeout(4);
 
 add_task(async function() {
   // Forces the Browser Toolbox to open on the console by default
   await pushPref("devtools.browsertoolbox.panel", "webconsole");
   await pushPref("devtools.webconsole.input.context", true);
 
   // Open the test *before* opening the Browser toolbox in order to have the right target title.
   // Once created, the target won't update its title, and so would be "New Tab", instead of "Test tab"
-  const tab = await addTab(`data:text/html,<title>Test tab</title>`);
+  const tab = await addTab(
+    "http://example.com/document-builder.sjs?html=<html><title>Test tab</title></html>"
+  );
 
   const ToolboxTask = await initBrowserToolboxTask({
     enableBrowserToolboxFission: true,
   });
 
   const tabProcessID =
     tab.linkedBrowser.browsingContext.currentWindowGlobal.osPid;
 
-  await ToolboxTask.spawn(tabProcessID, async processID => {
-    /* global gToolbox */
-    const { hud } = await gToolbox.getPanel("webconsole");
+  await ToolboxTask.spawn(
+    [tabProcessID, isFissionEnabled()],
+    async (processID, _isFissionEnabled) => {
+      /* global gToolbox */
+      const { hud } = await gToolbox.getPanel("webconsole");
 
-    const evaluationContextSelectorButton = hud.ui.outputNode.querySelector(
-      ".webconsole-evaluation-selector-button"
-    );
+      const evaluationContextSelectorButton = hud.ui.outputNode.querySelector(
+        ".webconsole-evaluation-selector-button"
+      );
 
-    is(
-      !!evaluationContextSelectorButton,
-      true,
-      "The evaluation context selector is visible"
-    );
-    is(
-      evaluationContextSelectorButton.innerText,
-      "Top",
-      "The button has the expected 'Top' text"
-    );
+      is(
+        !!evaluationContextSelectorButton,
+        true,
+        "The evaluation context selector is visible"
+      );
+      is(
+        evaluationContextSelectorButton.innerText,
+        "Top",
+        "The button has the expected 'Top' text"
+      );
 
-    // Note that the context menu is in the top level chrome document (browser-toolbox.xhtml)
-    // instead of webconsole.xhtml.
-    const labels = hud.chromeWindow.document.querySelectorAll(
-      "#webconsole-console-evaluation-context-selector-menu-list li .label"
-    );
-    const labelTexts = Array.from(labels).map(item => item.textContent);
+      // Note that the context menu is in the top level chrome document (browser-toolbox.xhtml)
+      // instead of webconsole.xhtml.
+      const labels = hud.chromeWindow.document.querySelectorAll(
+        "#webconsole-console-evaluation-context-selector-menu-list li .label"
+      );
+      const labelTexts = Array.from(labels).map(item => item.textContent);
 
-    is(
-      labelTexts.includes(`Content Process (pid ${processID})`),
-      true,
-      `${processID} content process visible in the execution context (${labelTexts})`
-    );
+      const expectedTitle = _isFissionEnabled
+        ? `(pid ${processID}) http://example.com`
+        : `(pid ${processID}) web`;
+      is(
+        labelTexts.includes(expectedTitle),
+        true,
+        `${processID} content process visible in the execution context (${labelTexts})`
+      );
 
-    is(
-      labelTexts.includes(`Test tab`),
-      true,
-      `Test tab is visible in the execution context (${labelTexts})`
-    );
-  });
+      is(
+        labelTexts.includes(`Test tab`),
+        true,
+        `Test tab is visible in the execution context (${labelTexts})`
+      );
+    }
+  );
 
   await ToolboxTask.destroy();
 });
--- a/devtools/client/fronts/targets/content-process.js
+++ b/devtools/client/fronts/targets/content-process.js
@@ -23,20 +23,29 @@ class ContentProcessTargetFront extends 
 
   form(json) {
     this.actorID = json.actor;
     this.processID = json.processID;
 
     // Save the full form for Target class usage.
     // Do not use `form` name to avoid colliding with protocol.js's `form` method
     this.targetForm = json;
+
+    this.remoteType = json.remoteType;
   }
 
   get name() {
-    return `Content Process (pid ${this.processID})`;
+    // @backward-compat { version 87 } We now have `remoteType` attribute.
+    if (this.remoteType) {
+      return `(pid ${this.processID}) ${this.remoteType.replace(
+        "webIsolated=",
+        ""
+      )}`;
+    }
+    return `(pid ${this.processID}) Content Process`;
   }
 
   attach() {
     // All target actors have a console actor to attach.
     // All but xpcshell test actors... which is using a ContentProcessTargetActor
     if (this.targetForm.consoleActor) {
       return this.attachConsole();
     }
--- a/devtools/server/actors/targets/content-process.js
+++ b/devtools/server/actors/targets/content-process.js
@@ -147,16 +147,17 @@ const ContentProcessTargetActor = Target
       }
 
       return {
         actor: this.actorID,
         consoleActor: this._consoleActor.actorID,
         threadActor: this.threadActor.actorID,
         memoryActor: this.memoryActor.actorID,
         processID: Services.appinfo.processID,
+        remoteType: Services.appinfo.remoteType,
 
         traits: {
           networkMonitor: false,
         },
       };
     },
 
     ensureWorkerList() {