Bug 1498280 - Introduce RootClient.getMainProcess to fetch ParentProcessTargetActor. r=yulia

MozReview-Commit-ID: E9OiwqDwNk7

Differential Revision: https://phabricator.services.mozilla.com/D11758

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-11-13 14:07:36 +00:00
Родитель 8f54bcb47f
Коммит fb3dcac40b
12 изменённых файлов: 23 добавлений и 13 удалений

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

@ -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.mainRoot.getProcess(0);
const response = await gClient.mainRoot.getMainProcess();
let actor = response.form.actor;
gThreadClient = await attachThread(gClient, actor);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");

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

@ -29,7 +29,7 @@ function test() {
let client = new DebuggerClient(DebuggerServer.connectPipe());
yield connect(client);
let chrome = yield client.mainRoot.getProcess(0);
let chrome = yield client.mainRoot.getMainProcess();
let [, targetFront] = yield attachTarget(client, chrome.form);
yield targetFront.attachThread();

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

@ -128,7 +128,7 @@ var onConnectionReady = async function([aType, aTraits]) {
const a = document.createElement("a");
a.onclick = function() {
if (gClient.mainRoot.traits.allowChromeProcess) {
gClient.mainRoot.getProcess(0)
gClient.mainRoot.getMainProcess()
.then(aResponse => {
openToolbox(aResponse.form, true);
});

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

@ -34,7 +34,7 @@ function getParentProcessActors(callback) {
const client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect()
.then(() => client.mainRoot.getProcess(0))
.then(() => client.mainRoot.getMainProcess())
.then(response => {
callback(client, response.form);
});

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

@ -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.mainRoot.getProcess(0);
const response = await gClient.mainRoot.getMainProcess();
await openToolbox({form: response.form, chrome: true});
}
};

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

@ -2071,7 +2071,7 @@ ScratchpadWindow.prototype = extend(ScratchpadTab.prototype, {
const client = new DebuggerClient(DebuggerServer.connectPipe());
await client.connect();
const response = await client.mainRoot.getProcess(0);
const response = await client.mainRoot.getMainProcess();
return { form: response.form, client };
},
});

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

@ -136,7 +136,7 @@ HUDService.prototype = {
const client = new DebuggerClient(DebuggerServer.connectPipe());
await client.connect();
const response = await client.mainRoot.getProcess(0);
const response = await client.mainRoot.getMainProcess();
return { form: response.form, client, chrome: true };
}

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

@ -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.mainRoot.getProcess(0)
return this.connection.client.mainRoot.getMainProcess()
.then(aResponse => {
return TargetFactory.forRemoteTab({
form: aResponse.form,

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

@ -101,7 +101,7 @@ async function createFullRuntimeMemoryFront() {
const client = new DebuggerClient(DebuggerServer.connectPipe());
await client.connect();
const { form } = await client.mainRoot.getProcess(0);
const { form } = await client.mainRoot.getMainProcess();
const options = {
form,
client,
@ -405,7 +405,7 @@ async function finishClient(client) {
function getParentProcessActors(client, server = DebuggerServer) {
server.allowChromeProcess = true;
return client.mainRoot.getProcess(0).then(response => response.form);
return client.mainRoot.getMainProcess().then(response => response.form);
}
/**

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

@ -25,8 +25,8 @@ add_task(async function() {
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.mainRoot.getProcess(0);
// Even though we have no tabs, getMainProcess gives us the chromeDebugger.
const response = await client.mainRoot.getMainProcess();
const { chromeDebugger } = response.form;
const [, threadClient] = await client.attachThread(chromeDebugger);

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

@ -136,6 +136,16 @@ const RootFront = protocol.FrontClassWithSpec(rootSpec, {
return result;
},
/**
* Fetch the ParentProcessTargetActor for the main process.
*
* `getProcess` requests allows to fetch the target actor for any process
* and the main process is having the process ID zero.
*/
getMainProcess() {
return this.getProcess(0);
},
/**
* Fetch the target actor for the currently selected tab, or for a specific
* tab given as first parameter.

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

@ -78,7 +78,7 @@ var _attachConsole = async function(
}
if (!attachToTab) {
response = await state.dbgClient.mainRoot.getProcess(0);
response = await state.dbgClient.mainRoot.getMainProcess();
await state.dbgClient.attachTarget(response.form.actor);
const consoleActor = response.form.consoleActor;
state.actor = consoleActor;