From 78feeeba2d2e8c09c130be7b37ea24b42a06c0e7 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Tue, 27 Nov 2018 19:18:28 +0000 Subject: [PATCH] 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 --- devtools/client/framework/target.js | 11 ++++------- devtools/shared/client/debugger-client.js | 18 ------------------ devtools/shared/fronts/targets/addon.js | 21 +++++++++++++++++++-- devtools/shared/specs/index.js | 5 +++++ devtools/shared/specs/root.js | 7 +++---- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/devtools/client/framework/target.js b/devtools/client/framework/target.js index 4a5d13102921..eb52803cdfd7 100644 --- a/devtools/client/framework/target.js +++ b/devtools/client/framework/target.js @@ -576,14 +576,11 @@ Target.prototype = { // to be attached via DebuggerClient.attachTarget. if (this.isBrowsingContext) { 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 - // instantiated. The plan is to have all targets to have their front passed as - // constructor argument. - } else if (this.isWorkerTarget) { + // Addon Worker and Content process targets are the first targets to have their + // front already instantiated. The plan is to have all targets to have their front + // passed as constructor argument. + } else if (this.isWorkerTarget || this.isLegacyAddon) { // 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. await this.activeTab.attach(); diff --git a/devtools/shared/client/debugger-client.js b/devtools/shared/client/debugger-client.js index 15a4432fcef4..9cbecbb44d5c 100644 --- a/devtools/shared/client/debugger-client.js +++ b/devtools/shared/client/debugger-client.js @@ -22,7 +22,6 @@ loader.lazyRequireGetter(this, "DebuggerSocket", "devtools/shared/security/socke loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter"); 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, "BrowsingContextTargetFront", "devtools/shared/fronts/targets/browsing-context", true); loader.lazyRequireGetter(this, "ThreadClient", "devtools/shared/client/thread-client"); @@ -380,23 +379,6 @@ DebuggerClient.prototype = { 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 * arguments, starts listening for: diff --git a/devtools/shared/fronts/targets/addon.js b/devtools/shared/fronts/targets/addon.js index 8c189ca26553..e5b5f7b8c539 100644 --- a/devtools/shared/fronts/targets/addon.js +++ b/devtools/shared/fronts/targets/addon.js @@ -8,14 +8,31 @@ const protocol = require("devtools/shared/protocol"); const {custom} = protocol; const AddonTargetFront = protocol.FrontClassWithSpec(addonTargetSpec, { - initialize: function(client, form) { - protocol.Front.prototype.initialize.call(this, client, form); + initialize: function(client) { + protocol.Front.prototype.initialize.call(this, client); this.client = client; 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() { const response = await this._attach(); diff --git a/devtools/shared/specs/index.js b/devtools/shared/specs/index.js index 9b0b8c2340c8..7be1becd9ba9 100644 --- a/devtools/shared/specs/index.js +++ b/devtools/shared/specs/index.js @@ -239,6 +239,11 @@ const Types = exports.__TypesForTests = [ spec: "devtools/shared/specs/symbol-iterator", front: null, }, + { + types: ["addonTarget"], + spec: "devtools/shared/specs/targets/addon", + front: "devtools/shared/fronts/targets/addon", + }, { types: ["browsingContextTarget"], spec: "devtools/shared/specs/targets/browsing-context", diff --git a/devtools/shared/specs/root.js b/devtools/shared/specs/root.js index ad1131c1754b..ed39436ab55a 100644 --- a/devtools/shared/specs/root.js +++ b/devtools/shared/specs/root.js @@ -11,9 +11,6 @@ types.addDictType("root.getTab", { types.addDictType("root.getWindow", { window: "json", }); -types.addDictType("root.listAddons", { - addons: "array:json", -}); types.addDictType("root.listWorkers", { workers: "array:workerTarget", }); @@ -57,7 +54,9 @@ const rootSpecPrototype = { listAddons: { request: {}, - response: RetVal("root.listAddons"), + response: { + addons: RetVal("array:addonTarget"), + }, }, listWorkers: {