Bug 1497644 - Always call Root actor's getProcess request via RootClient.getProcess r=yulia
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 11 Oct 2018 16:26:45 +0000
changeset 499183 9b6dac8e39db00a7a5739c05f0b868e2fd88efb5
parent 499182 d41905041ca7f615f90fce70e1de3c325e490c44
child 499184 eaf50a59155d0bef730fc4b48038589297860fc2
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia
bugs1497644
milestone64.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 1497644 - Always call Root actor's getProcess request via RootClient.getProcess r=yulia I also made its argument mandatory, so that later in root spec we can use a non-nullable number. MozReview-Commit-ID: BUPgI1ww1gC Differential Revision: https://phabricator.services.mozilla.com/D8141
devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js
devtools/client/debugger/test/mochitest/browser_dbg_promises-chrome-allocation-stack.js
devtools/client/framework/connect/connect.js
devtools/client/framework/devtools-browser.js
devtools/client/framework/target-from-url.js
devtools/client/framework/test/head.js
devtools/client/framework/toolbox-process-window.js
devtools/client/scratchpad/scratchpad.js
devtools/client/webconsole/hudservice.js
devtools/client/webide/modules/app-manager.js
devtools/server/tests/mochitest/test_getProcess.html
devtools/server/tests/unit/head_dbg.js
devtools/server/tests/unit/test_xpcshell_debugging.js
devtools/shared/client/debugger-client.js
devtools/shared/client/root-client.js
devtools/shared/webconsole/test/common.js
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js
@@ -58,17 +58,17 @@ registerCleanupFunction(function() {
 });
 
 add_task(async function() {
   gClient = initDebuggerClient();
 
   const [type] = await gClient.connect();
   is(type, "browser", "Root actor should identify itself as a browser.");
 
-  const response = await gClient.getProcess();
+  const response = await gClient.mainRoot.getProcess(0);
   let actor = response.form.actor;
   gThreadClient = await attachThread(gClient, actor);
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
 
   // listen for a new source and global
   gThreadClient.addListener("newSource", onNewSource);
   await gNewChromeSource.promise;
 
--- a/devtools/client/debugger/test/mochitest/browser_dbg_promises-chrome-allocation-stack.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_promises-chrome-allocation-stack.js
@@ -24,17 +24,17 @@ function test() {
     requestLongerTimeout(10);
 
     DebuggerServer.init();
     DebuggerServer.registerAllActors();
     DebuggerServer.allowChromeProcess = true;
 
     let client = new DebuggerClient(DebuggerServer.connectPipe());
     yield connect(client);
-    let chrome = yield client.getProcess();
+    let chrome = yield client.mainRoot.getProcess(0);
     let [, tabClient] = yield attachTarget(client, chrome.form);
     yield tabClient.attachThread();
 
     yield testGetAllocationStack(client, chrome.form, () => {
       let p = new Promise(() => {});
       p.name = "p";
       let q = p.then();
       q.name = "q";
--- a/devtools/client/framework/connect/connect.js
+++ b/devtools/client/framework/connect/connect.js
@@ -123,17 +123,17 @@ var onConnectionReady = async function([
 
   // Build the Remote Process button
   // If Fx<39, chrome target actors were used to be exposed on RootActor
   // but in Fx>=39, chrome is debuggable via getProcess() and ParentProcessTargetActor
   if (globals.consoleActor || gClient.mainRoot.traits.allowChromeProcess) {
     const a = document.createElement("a");
     a.onclick = function() {
       if (gClient.mainRoot.traits.allowChromeProcess) {
-        gClient.getProcess()
+        gClient.mainRoot.getProcess(0)
                .then(aResponse => {
                  openToolbox(aResponse.form, true);
                });
       } else if (globals.consoleActor) {
         openToolbox(globals, true, "webconsole", false);
       }
     };
     a.title = a.textContent = L10N.getStr("mainProcess");
--- a/devtools/client/framework/devtools-browser.js
+++ b/devtools/client/framework/devtools-browser.js
@@ -313,17 +313,17 @@ var gDevToolsBrowser = exports.gDevTools
     DebuggerServer.init();
     DebuggerServer.registerAllActors();
     DebuggerServer.allowChromeProcess = true;
 
     const transport = DebuggerServer.connectPipe();
     const client = new DebuggerClient(transport);
 
     await client.connect();
-    const response = await client.getProcess(processId);
+    const response = await client.mainRoot.getProcess(processId);
     const options = {
       form: response.form,
       client: client,
       chrome: true,
     };
     const target = await TargetFactory.forRemoteTab(options);
     // Ensure closing the connection in order to cleanup
     // the debugger client and also the server created in the
--- a/devtools/client/framework/target-from-url.js
+++ b/devtools/client/framework/target-from-url.js
@@ -70,17 +70,17 @@ exports.targetFromURL = async function t
   } else if (type == "process") {
     // Fetch target for a remote chrome actor
     DebuggerServer.allowChromeProcess = true;
     try {
       id = parseInt(id, 10);
       if (isNaN(id)) {
         id = 0;
       }
-      const response = await client.getProcess(id);
+      const response = await client.mainRoot.getProcess(id);
       form = response.form;
       chrome = true;
     } catch (ex) {
       if (ex.error == "noProcess") {
         throw new Error(`targetFromURL, process with id '${id}' doesn't exist`);
       }
       throw ex;
     }
--- a/devtools/client/framework/test/head.js
+++ b/devtools/client/framework/test/head.js
@@ -29,17 +29,17 @@ function getParentProcessActors(callback
   const { DebuggerClient } = require("devtools/shared/client/debugger-client");
 
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
   DebuggerServer.allowChromeProcess = true;
 
   const client = new DebuggerClient(DebuggerServer.connectPipe());
   client.connect()
-    .then(() => client.getProcess())
+    .then(() => client.mainRoot.getProcess(0))
     .then(response => {
       callback(client, response.form);
     });
 
   SimpleTest.registerCleanupFunction(() => {
     DebuggerServer.destroy();
   });
 }
--- a/devtools/client/framework/toolbox-process-window.js
+++ b/devtools/client/framework/toolbox-process-window.js
@@ -88,17 +88,17 @@ var connect = async function() {
   await gClient.connect();
 
   appendStatusMessage("Get root form for toolbox");
   if (addonID) {
     const { addons } = await gClient.listAddons();
     const addonTargetActor = addons.filter(addon => addon.id === addonID).pop();
     await openToolbox({form: addonTargetActor, chrome: true});
   } else {
-    const response = await gClient.getProcess();
+    const response = await gClient.mainRoot.getProcess(0);
     await openToolbox({form: response.form, chrome: true});
   }
 };
 
 // Certain options should be toggled since we can assume chrome debugging here
 function setPrefDefaults() {
   Services.prefs.setBoolPref("devtools.inspector.showUserAgentStyles", true);
   Services.prefs.setBoolPref("devtools.performance.ui.show-platform-data", true);
--- a/devtools/client/scratchpad/scratchpad.js
+++ b/devtools/client/scratchpad/scratchpad.js
@@ -2070,17 +2070,17 @@ ScratchpadWindow.prototype = extend(Scra
    */
   async _attach() {
     DebuggerServer.init();
     DebuggerServer.registerAllActors();
     DebuggerServer.allowChromeProcess = true;
 
     const client = new DebuggerClient(DebuggerServer.connectPipe());
     await client.connect();
-    const response = await client.getProcess();
+    const response = await client.mainRoot.getProcess(0);
     return { form: response.form, client };
   }
 });
 
 function ScratchpadTarget(aTarget) {
   this._target = aTarget;
 }
 
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -131,17 +131,17 @@ HUDService.prototype = {
       // (See Bug 1416105 for rationale).
       DebuggerServer.init();
       DebuggerServer.registerActors({ root: true, target: true });
 
       DebuggerServer.allowChromeProcess = true;
 
       const client = new DebuggerClient(DebuggerServer.connectPipe());
       await client.connect();
-      const response = await client.getProcess();
+      const response = await client.mainRoot.getProcess(0);
       return { form: response.form, client, chrome: true };
     }
 
     async function openWindow(t) {
       const win = Services.ww.openWindow(null, Tools.webConsole.url,
                                        "_blank", BC_WINDOW_FEATURES, null);
 
       await new Promise(resolve => {
--- a/devtools/client/webide/modules/app-manager.js
+++ b/devtools/client/webide/modules/app-manager.js
@@ -249,17 +249,17 @@ var AppManager = exports.AppManager = {
       target.activeTab.reload();
     }, console.error);
   },
 
   getTarget: function() {
     if (this.selectedProject.type == "mainProcess") {
       // Fx >=39 exposes a ParentProcessTargetActor to debug the main process
       if (this.connection.client.mainRoot.traits.allowChromeProcess) {
-        return this.connection.client.getProcess()
+        return this.connection.client.mainRoot.getProcess(0)
                    .then(aResponse => {
                      return TargetFactory.forRemoteTab({
                        form: aResponse.form,
                        client: this.connection.client,
                        chrome: true
                      });
                    });
       }
--- a/devtools/server/tests/mochitest/test_getProcess.html
+++ b/devtools/server/tests/mochitest/test_getProcess.html
@@ -80,17 +80,17 @@ function runTests() {
     client.mainRoot.listProcesses(response => {
       ok(response.processes.length >= 2, "Got at least the parent process and one child");
       is(response.processes.length, processCount + 1,
          "Got one additional process on the second call to listProcesses");
 
       // Connect to the first content processe available
       const content = response.processes.filter(p => (!p.parent))[0];
 
-      client.getProcess(content.id).then(({form: actor}) => {
+      client.mainRoot.getProcess(content.id).then(({form: actor}) => {
         ok(actor.consoleActor, "Got the console actor");
         ok(actor.chromeDebugger, "Got the thread actor");
 
         // Ensure sending at least one request to an actor...
         client.request({
           to: actor.consoleActor,
           type: "evaluateJS",
           text: "var a = 42; a"
@@ -101,17 +101,17 @@ function runTests() {
         });
       });
     });
   }
 
   // Assert that calling client.getProcess against the same process id is
   // returning the same actor.
   function getProcessAgain(firstActor, id) {
-    client.getProcess(id).then(response => {
+    client.mainRoot.getProcess(id).then(response => {
       const actor = response.form;
       is(actor, firstActor,
          "Second call to getProcess with the same id returns the same form");
       closeClient();
     });
   }
 
   function processScript() {
--- a/devtools/server/tests/unit/head_dbg.js
+++ b/devtools/server/tests/unit/head_dbg.js
@@ -438,25 +438,25 @@ function finishClient(client) {
 // pass |callback| the debugger client and target actor form with all actor IDs.
 function get_parent_process_actors(callback) {
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
   DebuggerServer.allowChromeProcess = true;
 
   const client = new DebuggerClient(DebuggerServer.connectPipe());
   client.connect()
-    .then(() => client.getProcess())
+    .then(() => client.mainRoot.getProcess(0))
     .then(response => {
       callback(client, response.form);
     });
 }
 
 function getParentProcessActors(client, server = DebuggerServer) {
   server.allowChromeProcess = true;
-  return client.getProcess().then(response => response.form);
+  return client.mainRoot.getProcess(0).then(response => response.form);
 }
 
 /**
  * Takes a relative file path and returns the absolute file url for it.
  */
 function getFileUrl(name, allowMissing = false) {
   const file = do_get_file(name, allowMissing);
   return Services.io.newFileURI(file).spec;
--- a/devtools/server/tests/unit/test_xpcshell_debugging.js
+++ b/devtools/server/tests/unit/test_xpcshell_debugging.js
@@ -21,17 +21,17 @@ add_task(async function() {
   await client.connect();
 
   // Ensure that global actors are available. Just test the device actor.
   const deviceFront = await client.mainRoot.getFront("device");
   const desc = await deviceFront.getDescription();
   equal(desc.geckobuildid, Services.appinfo.platformBuildID, "device actor works");
 
   // Even though we have no tabs, getProcess gives us the chromeDebugger.
-  const response = await client.getProcess();
+  const response = await client.mainRoot.getProcess(0);
 
   const { chromeDebugger } = response.form;
   const [, threadClient] = await client.attachThread(chromeDebugger);
   const onResumed = new Promise(resolve => {
     threadClient.addOneTimeListener("paused", (event, packet) => {
       equal(packet.why.type, "breakpoint",
           "yay - hit the breakpoint at the first line in our script");
       // Resume again - next stop should be our "debugger" statement.
--- a/devtools/shared/client/debugger-client.js
+++ b/devtools/shared/client/debugger-client.js
@@ -483,35 +483,16 @@ DebuggerClient.prototype = {
     return this.request(packet).then(response => {
       const threadClient = new ThreadClient(this, threadActor);
       this.registerClient(threadClient);
       return [response, threadClient];
     });
   },
 
   /**
-   * Fetch the ChromeActor for the main process or ChildProcessActor for a
-   * a given child process ID.
-   *
-   * @param number id
-   *        The ID for the process to attach (returned by `listProcesses`).
-   *        Connected to the main process if omitted, or is 0.
-   */
-  getProcess: function(id) {
-    const packet = {
-      to: "root",
-      type: "getProcess"
-    };
-    if (typeof (id) == "number") {
-      packet.id = id;
-    }
-    return this.request(packet);
-  },
-
-  /**
    * Release an object actor.
    *
    * @param string actor
    *        The actor ID to send the request to.
    */
   release: DebuggerClient.requester({
     to: arg(0),
     type: "release"
--- a/devtools/shared/client/root-client.js
+++ b/devtools/shared/client/root-client.js
@@ -101,16 +101,26 @@ RootClient.prototype = {
    * List the running processes.
    *
    * @param function onResponse
    *        Called with the response packet.
    */
   listProcesses: DebuggerClient.requester({ type: "listProcesses" }),
 
   /**
+   * Fetch the ParentProcessTargetActor for the main process or ContentProcessTargetActor
+   * for a a given child process ID.
+   *
+   * @param number id
+   *        The ID for the process to attach (returned by `listProcesses`).
+   *        Connected to the main process if is 0.
+   */
+  getProcess: DebuggerClient.requester({ type: "getProcess", id: arg(0) }),
+
+  /**
    * Retrieve all service worker registrations as well as workers from the parent and
    * content processes. Listing service workers involves merging information coming from
    * registrations and workers, this method will combine this information to present a
    * unified array of serviceWorkers. If you are only interested in other workers, use
    * listWorkers.
    *
    * @return {Object}
    *         - {Array} service
@@ -133,17 +143,17 @@ RootClient.prototype = {
 
       // And then from the Child processes
       const { processes } = await this.listProcesses();
       for (const process of processes) {
         // Ignore parent process
         if (process.parent) {
           continue;
         }
-        const { form } = await this._client.getProcess(process.id);
+        const { form } = await this.getProcess(process.id);
         const processActor = form.actor;
         const response = await this._client.request({
           to: processActor,
           type: "listWorkers"
         });
         workers = workers.concat(response.workers);
       }
     } catch (e) {
--- a/devtools/shared/webconsole/test/common.js
+++ b/devtools/shared/webconsole/test/common.js
@@ -73,17 +73,17 @@ var _attachConsole = async function(
   if (response.error) {
     console.error("client.connect() failed: " + response.error + " " +
                   response.message);
     callback(state, response);
     return;
   }
 
   if (!attachToTab) {
-    response = await state.dbgClient.getProcess();
+    response = await state.dbgClient.mainRoot.getProcess(0);
     await state.dbgClient.attachTarget(response.form.actor);
     const consoleActor = response.form.consoleActor;
     state.actor = consoleActor;
     state.dbgClient.attachConsole(consoleActor, listeners)
       .then(_onAttachConsole.bind(null, state), _onAttachError.bind(null, state));
     return;
   }
   response = await state.dbgClient.listTabs();