Bug 1506545 - Instantiate Target for ContentProcessTargetActor via its front. r=yulia

MozReview-Commit-ID: EE4d0YULRBU

Depends on D11614

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-11-13 20:39:58 +00:00
parent fffd078e5c
commit a8d8b5dffc
4 changed files with 21 additions and 20 deletions

View File

@ -318,10 +318,12 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
const client = new DebuggerClient(transport);
await client.connect();
const response = await client.mainRoot.getProcess(processId);
const { form } = await client.mainRoot.getProcess(processId);
const front = await client.mainRoot.attachContentProcessTarget(form);
const options = {
form: response.form,
client: client,
form,
activeTab: front,
client,
chrome: true,
};
const target = await TargetFactory.forRemoteTab(options);

View File

@ -578,18 +578,17 @@ Target.prototype = {
// to be attached via DebuggerClient.attachTarget.
if (this.isBrowsingContext) {
await attachBrowsingContextTarget();
} else if (this.isContentProcess) {
// But ContentProcessTargetActor now has a front that is instantiated here
this.activeTab = await this._client.attachContentProcessTarget(this._form);
} else if (this.isLegacyAddon) {
const [, addonTargetFront] = await this._client.attachAddon(this._form);
this.activeTab = addonTargetFront;
} else if (this.isWorkerTarget) {
// Worker target is the first target to have its front already instantiated.
// The plan is to have all targets to have its front passed as constructor argument.
} else if (this.isWorkerTarget || this.isContentProcess) {
// Worker and Content process targets are the first target to have their front already
// instantiated. The plan is to have all targets to have their front passed as
// constructor argument.
} else {
throw new Error(`Unsupported type of target. Expected target of one of the` +
` following types: BrowsingContext, ContentProcess, or Addon (legacy).`);
` following types: BrowsingContext, ContentProcess, Worker or ` +
`Addon (legacy).`);
}
// _setupRemoteListeners has to be called after the potential call to `attachTarget`

View File

@ -26,7 +26,6 @@ loader.lazyRequireGetter(this, "AddonTargetFront", "devtools/shared/fronts/targe
loader.lazyRequireGetter(this, "RootFront", "devtools/shared/fronts/root", true);
loader.lazyRequireGetter(this, "BrowsingContextTargetFront", "devtools/shared/fronts/targets/browsing-context", true);
loader.lazyRequireGetter(this, "WorkerTargetFront", "devtools/shared/fronts/targets/worker", true);
loader.lazyRequireGetter(this, "ContentProcessTargetFront", "devtools/shared/fronts/targets/content-process", true);
loader.lazyRequireGetter(this, "ThreadClient", "devtools/shared/client/thread-client");
loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/object-client");
loader.lazyRequireGetter(this, "Pool", "devtools/shared/protocol", true);
@ -382,15 +381,6 @@ DebuggerClient.prototype = {
return [response, front];
},
attachContentProcessTarget: async function(form) {
let front = this._frontPool.actor(form.actor);
if (!front) {
front = new ContentProcessTargetFront(this, form);
this._frontPool.manage(front);
}
return front;
},
attachWorker: async function(workerTargetActor) {
let front = this._frontPool.actor(workerTargetActor);
if (!front) {

View File

@ -9,6 +9,7 @@ const protocol = require("devtools/shared/protocol");
const {custom} = protocol;
loader.lazyRequireGetter(this, "getFront", "devtools/shared/protocol", true);
loader.lazyRequireGetter(this, "ContentProcessTargetFront", "devtools/shared/fronts/targets/content-process", true);
const RootFront = protocol.FrontClassWithSpec(rootSpec, {
initialize: function(client, form) {
@ -190,6 +191,15 @@ const RootFront = protocol.FrontClassWithSpec(rootSpec, {
impl: "_getTab",
}),
attachContentProcessTarget: async function(form) {
let front = this.actor(form.actor);
if (!front) {
front = new ContentProcessTargetFront(this._client, form);
this.manage(front);
}
return front;
},
/**
* Test request that returns the object passed as first argument.
*