From cf0d0480ebe3b2d512ac858bab03da0b326bd5fc Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Thu, 11 Oct 2018 16:26:45 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- .../mochitest/browser_dbg-chrome-debugging.js | 2 +- ...er_dbg_promises-chrome-allocation-stack.js | 2 +- devtools/client/framework/connect/connect.js | 2 +- devtools/client/framework/devtools-browser.js | 2 +- devtools/client/framework/target-from-url.js | 2 +- devtools/client/framework/test/head.js | 2 +- .../framework/toolbox-process-window.js | 2 +- devtools/client/scratchpad/scratchpad.js | 2 +- devtools/client/webconsole/hudservice.js | 2 +- devtools/client/webide/modules/app-manager.js | 2 +- .../tests/mochitest/test_getProcess.html | 4 ++-- devtools/server/tests/unit/head_dbg.js | 4 ++-- .../tests/unit/test_xpcshell_debugging.js | 2 +- devtools/shared/client/debugger-client.js | 19 ------------------- devtools/shared/client/root-client.js | 12 +++++++++++- devtools/shared/webconsole/test/common.js | 2 +- 16 files changed, 27 insertions(+), 36 deletions(-) diff --git a/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js b/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js index ad4fae79ffab..b995476ada66 100644 --- a/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js +++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js @@ -63,7 +63,7 @@ add_task(async function() { 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"); diff --git 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 index c3795e094de3..bd127e1c2a01 100644 --- 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 @@ -29,7 +29,7 @@ function test() { 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(); diff --git a/devtools/client/framework/connect/connect.js b/devtools/client/framework/connect/connect.js index b52aba87637c..5e79da980da8 100644 --- a/devtools/client/framework/connect/connect.js +++ b/devtools/client/framework/connect/connect.js @@ -128,7 +128,7 @@ var onConnectionReady = async function([aType, aTraits]) { 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); }); diff --git a/devtools/client/framework/devtools-browser.js b/devtools/client/framework/devtools-browser.js index f638c1dbbfdf..712d04be5a86 100644 --- a/devtools/client/framework/devtools-browser.js +++ b/devtools/client/framework/devtools-browser.js @@ -318,7 +318,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = { 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, diff --git a/devtools/client/framework/target-from-url.js b/devtools/client/framework/target-from-url.js index 20ed78f62eea..6b3b3e16f528 100644 --- a/devtools/client/framework/target-from-url.js +++ b/devtools/client/framework/target-from-url.js @@ -75,7 +75,7 @@ exports.targetFromURL = async function targetFromURL(url) { 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) { diff --git a/devtools/client/framework/test/head.js b/devtools/client/framework/test/head.js index 4f2eb09075ff..7f4a2f9eb692 100644 --- a/devtools/client/framework/test/head.js +++ b/devtools/client/framework/test/head.js @@ -34,7 +34,7 @@ function getParentProcessActors(callback) { const client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect() - .then(() => client.getProcess()) + .then(() => client.mainRoot.getProcess(0)) .then(response => { callback(client, response.form); }); diff --git a/devtools/client/framework/toolbox-process-window.js b/devtools/client/framework/toolbox-process-window.js index 91ef896c6697..501f6a055344 100644 --- a/devtools/client/framework/toolbox-process-window.js +++ b/devtools/client/framework/toolbox-process-window.js @@ -93,7 +93,7 @@ var connect = async function() { 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}); } }; diff --git a/devtools/client/scratchpad/scratchpad.js b/devtools/client/scratchpad/scratchpad.js index c359eddc0afd..fe8c7eac57aa 100644 --- a/devtools/client/scratchpad/scratchpad.js +++ b/devtools/client/scratchpad/scratchpad.js @@ -2075,7 +2075,7 @@ ScratchpadWindow.prototype = extend(ScratchpadTab.prototype, { 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 }; } }); diff --git a/devtools/client/webconsole/hudservice.js b/devtools/client/webconsole/hudservice.js index f90557a3ab49..b543274d1d25 100644 --- a/devtools/client/webconsole/hudservice.js +++ b/devtools/client/webconsole/hudservice.js @@ -136,7 +136,7 @@ HUDService.prototype = { 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 }; } diff --git a/devtools/client/webide/modules/app-manager.js b/devtools/client/webide/modules/app-manager.js index 6b894a4022f2..274f54ff335d 100644 --- a/devtools/client/webide/modules/app-manager.js +++ b/devtools/client/webide/modules/app-manager.js @@ -254,7 +254,7 @@ var AppManager = exports.AppManager = { 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, diff --git a/devtools/server/tests/mochitest/test_getProcess.html b/devtools/server/tests/mochitest/test_getProcess.html index caf754184228..b3302d54a74d 100644 --- a/devtools/server/tests/mochitest/test_getProcess.html +++ b/devtools/server/tests/mochitest/test_getProcess.html @@ -85,7 +85,7 @@ function runTests() { // 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"); @@ -106,7 +106,7 @@ 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"); diff --git a/devtools/server/tests/unit/head_dbg.js b/devtools/server/tests/unit/head_dbg.js index 110937ba9445..075fb36db8a1 100644 --- a/devtools/server/tests/unit/head_dbg.js +++ b/devtools/server/tests/unit/head_dbg.js @@ -443,7 +443,7 @@ function get_parent_process_actors(callback) { const client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect() - .then(() => client.getProcess()) + .then(() => client.mainRoot.getProcess(0)) .then(response => { callback(client, response.form); }); @@ -451,7 +451,7 @@ function get_parent_process_actors(callback) { function getParentProcessActors(client, server = DebuggerServer) { server.allowChromeProcess = true; - return client.getProcess().then(response => response.form); + return client.mainRoot.getProcess(0).then(response => response.form); } /** diff --git a/devtools/server/tests/unit/test_xpcshell_debugging.js b/devtools/server/tests/unit/test_xpcshell_debugging.js index 393016ce40ac..bb12ace97b79 100644 --- a/devtools/server/tests/unit/test_xpcshell_debugging.js +++ b/devtools/server/tests/unit/test_xpcshell_debugging.js @@ -26,7 +26,7 @@ add_task(async function() { 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); diff --git a/devtools/shared/client/debugger-client.js b/devtools/shared/client/debugger-client.js index 95be7584aa74..8f781ea1427c 100644 --- a/devtools/shared/client/debugger-client.js +++ b/devtools/shared/client/debugger-client.js @@ -487,25 +487,6 @@ DebuggerClient.prototype = { }); }, - /** - * 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. * diff --git a/devtools/shared/client/root-client.js b/devtools/shared/client/root-client.js index 9708641d2c7b..577983542529 100644 --- a/devtools/shared/client/root-client.js +++ b/devtools/shared/client/root-client.js @@ -105,6 +105,16 @@ RootClient.prototype = { */ 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 @@ -138,7 +148,7 @@ RootClient.prototype = { 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, diff --git a/devtools/shared/webconsole/test/common.js b/devtools/shared/webconsole/test/common.js index 50dcbd01164a..46648ab4ae28 100644 --- a/devtools/shared/webconsole/test/common.js +++ b/devtools/shared/webconsole/test/common.js @@ -78,7 +78,7 @@ var _attachConsole = async function( } 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;