зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1695744 - [devtools] Use a DescriptorMixin in order to share a common interface between all descriptor fronts. r=jdescottes
This will help expose getCommands method in the next patch. Differential Revision: https://phabricator.services.mozilla.com/D105610
This commit is contained in:
Родитель
96d4ce500a
Коммит
5fb00fe32f
|
@ -0,0 +1,30 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A Descriptor represents a debuggable context. It can be a browser tab, a tab on
|
||||
* a remote device, like a tab on Firefox for Android. But it can also be an add-on,
|
||||
* as well as firefox parent process, or just one of its content process.
|
||||
* It can be very similar to a Target. The key difference is the lifecycle of these two classes.
|
||||
* The descriptor is meant to be always alive and meaningful/usable until the end of the RDP connection.
|
||||
* Typically a Tab Descriptor will describe the tab and not the one document currently loaded in this tab,
|
||||
* while the Target, will describe this one document and a new Target may be created on each navigation.
|
||||
*/
|
||||
function DescriptorMixin(parentClass) {
|
||||
class Descriptor extends parentClass {
|
||||
constructor(client, targetFront, parentFront) {
|
||||
super(client, targetFront, parentFront);
|
||||
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
get client() {
|
||||
return this._client;
|
||||
}
|
||||
}
|
||||
return Descriptor;
|
||||
}
|
||||
exports.DescriptorMixin = DescriptorMixin;
|
|
@ -5,6 +5,7 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DevToolsModules(
|
||||
"descriptor-mixin.js",
|
||||
"process.js",
|
||||
"tab.js",
|
||||
"webextension.js",
|
||||
|
|
|
@ -16,18 +16,18 @@ const {
|
|||
FrontClassWithSpec,
|
||||
registerFront,
|
||||
} = require("devtools/shared/protocol");
|
||||
const {
|
||||
DescriptorMixin,
|
||||
} = require("devtools/client/fronts/descriptors/descriptor-mixin");
|
||||
|
||||
class ProcessDescriptorFront extends FrontClassWithSpec(processDescriptorSpec) {
|
||||
class ProcessDescriptorFront extends DescriptorMixin(
|
||||
FrontClassWithSpec(processDescriptorSpec)
|
||||
) {
|
||||
constructor(client, targetFront, parentFront) {
|
||||
super(client, targetFront, parentFront);
|
||||
this.isParent = false;
|
||||
this._processTargetFront = null;
|
||||
this._targetFrontPromise = null;
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
get client() {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
form(json) {
|
||||
|
|
|
@ -21,6 +21,9 @@ const {
|
|||
FrontClassWithSpec,
|
||||
registerFront,
|
||||
} = require("devtools/shared/protocol");
|
||||
const {
|
||||
DescriptorMixin,
|
||||
} = require("devtools/client/fronts/descriptors/descriptor-mixin");
|
||||
|
||||
/**
|
||||
* DescriptorFront for tab targets.
|
||||
|
@ -30,10 +33,11 @@ const {
|
|||
* TODO: This event could move to the server in order to support
|
||||
* remoteness change for remote debugging.
|
||||
*/
|
||||
class TabDescriptorFront extends FrontClassWithSpec(tabDescriptorSpec) {
|
||||
class TabDescriptorFront extends DescriptorMixin(
|
||||
FrontClassWithSpec(tabDescriptorSpec)
|
||||
) {
|
||||
constructor(client, targetFront, parentFront) {
|
||||
super(client, targetFront, parentFront);
|
||||
this._client = client;
|
||||
|
||||
// The tab descriptor can be configured to create either local tab targets
|
||||
// (eg, regular tab toolbox) or browsing context targets (eg tab remote
|
||||
|
@ -48,10 +52,6 @@ class TabDescriptorFront extends FrontClassWithSpec(tabDescriptorSpec) {
|
|||
this._handleTabEvent = this._handleTabEvent.bind(this);
|
||||
}
|
||||
|
||||
get client() {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
form(json) {
|
||||
this.actorID = json.actor;
|
||||
this._form = json;
|
||||
|
|
|
@ -10,6 +10,9 @@ const {
|
|||
FrontClassWithSpec,
|
||||
registerFront,
|
||||
} = require("devtools/shared/protocol");
|
||||
const {
|
||||
DescriptorMixin,
|
||||
} = require("devtools/client/fronts/descriptors/descriptor-mixin");
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"BrowsingContextTargetFront",
|
||||
|
@ -17,17 +20,13 @@ loader.lazyRequireGetter(
|
|||
true
|
||||
);
|
||||
|
||||
class WebExtensionDescriptorFront extends FrontClassWithSpec(
|
||||
webExtensionDescriptorSpec
|
||||
class WebExtensionDescriptorFront extends DescriptorMixin(
|
||||
FrontClassWithSpec(webExtensionDescriptorSpec)
|
||||
) {
|
||||
constructor(client, targetFront, parentFront) {
|
||||
super(client, targetFront, parentFront);
|
||||
this._client = client;
|
||||
this.traits = {};
|
||||
}
|
||||
get client() {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
form(json) {
|
||||
this.actorID = json.actor;
|
||||
|
|
|
@ -12,13 +12,15 @@ const {
|
|||
registerFront,
|
||||
} = require("devtools/shared/protocol");
|
||||
const { TargetMixin } = require("devtools/client/fronts/targets/target-mixin");
|
||||
const {
|
||||
DescriptorMixin,
|
||||
} = require("devtools/client/fronts/descriptors/descriptor-mixin");
|
||||
|
||||
class WorkerDescriptorFront extends TargetMixin(
|
||||
FrontClassWithSpec(workerDescriptorSpec)
|
||||
class WorkerDescriptorFront extends DescriptorMixin(
|
||||
TargetMixin(FrontClassWithSpec(workerDescriptorSpec))
|
||||
) {
|
||||
constructor(client, targetFront, parentFront) {
|
||||
super(client, targetFront, parentFront);
|
||||
this._client = client;
|
||||
|
||||
this.traits = {};
|
||||
|
||||
|
@ -30,10 +32,6 @@ class WorkerDescriptorFront extends TargetMixin(
|
|||
this.once("worker-close", this.destroy.bind(this));
|
||||
}
|
||||
|
||||
get client() {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
form(json) {
|
||||
this.actorID = json.actor;
|
||||
this.id = json.id;
|
||||
|
|
Загрузка…
Ссылка в новой задаче