Bug 1506546 - Change the spec type of listAddons and accomodate using the front rather than the form. r=yulia

MozReview-Commit-ID: 4MAjszUiGUZ

Depends on D12573

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-11-27 19:18:28 +00:00
Родитель fe4a5688be
Коммит 78feeeba2d
5 изменённых файлов: 31 добавлений и 31 удалений

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

@ -576,14 +576,11 @@ Target.prototype = {
// to be attached via DebuggerClient.attachTarget. // to be attached via DebuggerClient.attachTarget.
if (this.isBrowsingContext) { if (this.isBrowsingContext) {
await attachBrowsingContextTarget(); await attachBrowsingContextTarget();
} else if (this.isLegacyAddon) {
const [, addonTargetFront] = await this._client.attachAddon(this.form);
this.activeTab = addonTargetFront;
// Worker and Content process targets are the first target to have their front already // Addon Worker and Content process targets are the first targets to have their
// instantiated. The plan is to have all targets to have their front passed as // front already instantiated. The plan is to have all targets to have their front
// constructor argument. // passed as constructor argument.
} else if (this.isWorkerTarget) { } else if (this.isWorkerTarget || this.isLegacyAddon) {
// Worker is the first front to be completely migrated to have only its attach // Worker is the first front to be completely migrated to have only its attach
// method being called from Target.attach. Other fronts should be refactored. // method being called from Target.attach. Other fronts should be refactored.
await this.activeTab.attach(); await this.activeTab.attach();

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

@ -22,7 +22,6 @@ loader.lazyRequireGetter(this, "DebuggerSocket", "devtools/shared/security/socke
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter"); loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
loader.lazyRequireGetter(this, "WebConsoleClient", "devtools/shared/webconsole/client", true); loader.lazyRequireGetter(this, "WebConsoleClient", "devtools/shared/webconsole/client", true);
loader.lazyRequireGetter(this, "AddonTargetFront", "devtools/shared/fronts/targets/addon", true);
loader.lazyRequireGetter(this, "RootFront", "devtools/shared/fronts/root", true); loader.lazyRequireGetter(this, "RootFront", "devtools/shared/fronts/root", true);
loader.lazyRequireGetter(this, "BrowsingContextTargetFront", "devtools/shared/fronts/targets/browsing-context", true); loader.lazyRequireGetter(this, "BrowsingContextTargetFront", "devtools/shared/fronts/targets/browsing-context", true);
loader.lazyRequireGetter(this, "ThreadClient", "devtools/shared/client/thread-client"); loader.lazyRequireGetter(this, "ThreadClient", "devtools/shared/client/thread-client");
@ -380,23 +379,6 @@ DebuggerClient.prototype = {
return [response, front]; return [response, front];
}, },
/**
* Attach to an addon target actor.
*
* @param string addonTargetActor
* The actor ID for the addon to attach.
*/
attachAddon: async function(form) {
let front = this._frontPool.actor(form.actor);
if (!front) {
front = new AddonTargetFront(this, form);
this._frontPool.manage(front);
}
const response = await front.attach();
return [response, front];
},
/** /**
* Attach to a Web Console actor. Depending on the listeners being passed as second * Attach to a Web Console actor. Depending on the listeners being passed as second
* arguments, starts listening for: * arguments, starts listening for:

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

@ -8,14 +8,31 @@ const protocol = require("devtools/shared/protocol");
const {custom} = protocol; const {custom} = protocol;
const AddonTargetFront = protocol.FrontClassWithSpec(addonTargetSpec, { const AddonTargetFront = protocol.FrontClassWithSpec(addonTargetSpec, {
initialize: function(client, form) { initialize: function(client) {
protocol.Front.prototype.initialize.call(this, client, form); protocol.Front.prototype.initialize.call(this, client);
this.client = client; this.client = client;
this.traits = {}; this.traits = {};
}, },
form(json) {
this.actorID = json.actor;
// 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;
// We used to manipulate the form rather than the front itself.
// Expose all form attributes to ease accessing them.
for (const name in json) {
if (name == "actor") {
continue;
}
this[name] = json[name];
}
},
attach: custom(async function() { attach: custom(async function() {
const response = await this._attach(); const response = await this._attach();

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

@ -239,6 +239,11 @@ const Types = exports.__TypesForTests = [
spec: "devtools/shared/specs/symbol-iterator", spec: "devtools/shared/specs/symbol-iterator",
front: null, front: null,
}, },
{
types: ["addonTarget"],
spec: "devtools/shared/specs/targets/addon",
front: "devtools/shared/fronts/targets/addon",
},
{ {
types: ["browsingContextTarget"], types: ["browsingContextTarget"],
spec: "devtools/shared/specs/targets/browsing-context", spec: "devtools/shared/specs/targets/browsing-context",

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

@ -11,9 +11,6 @@ types.addDictType("root.getTab", {
types.addDictType("root.getWindow", { types.addDictType("root.getWindow", {
window: "json", window: "json",
}); });
types.addDictType("root.listAddons", {
addons: "array:json",
});
types.addDictType("root.listWorkers", { types.addDictType("root.listWorkers", {
workers: "array:workerTarget", workers: "array:workerTarget",
}); });
@ -57,7 +54,9 @@ const rootSpecPrototype = {
listAddons: { listAddons: {
request: {}, request: {},
response: RetVal("root.listAddons"), response: {
addons: RetVal("array:addonTarget"),
},
}, },
listWorkers: { listWorkers: {