mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 01:10:22 +00:00
Bug 1657105 - Use constants to define target types on the server and set targetType on all targets. r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D86632
This commit is contained in:
parent
6154026e68
commit
9f9a8d9b3e
@ -33,6 +33,7 @@ var { assert } = DevToolsUtils;
|
||||
var { TabSources } = require("devtools/server/actors/utils/TabSources");
|
||||
var makeDebugger = require("devtools/server/actors/utils/make-debugger");
|
||||
const InspectorUtils = require("InspectorUtils");
|
||||
const Targets = require("devtools/server/actors/targets/index");
|
||||
const { TargetActorRegistry } = ChromeUtils.import(
|
||||
"resource://devtools/server/actors/targets/target-actor-registry.jsm"
|
||||
);
|
||||
@ -394,10 +395,7 @@ const browsingContextTargetPrototype = {
|
||||
|
||||
_targetScopedActorPool: null,
|
||||
|
||||
/**
|
||||
* A constant prefix that will be used to form the actor ID by the server.
|
||||
*/
|
||||
typeName: "browsingContextTarget",
|
||||
targetType: Targets.TYPES.FRAME,
|
||||
|
||||
/**
|
||||
* An object on which listen for DOMWindowCreated and pageshow events.
|
||||
|
@ -24,6 +24,7 @@ const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
|
||||
const {
|
||||
contentProcessTargetSpec,
|
||||
} = require("devtools/shared/specs/targets/content-process");
|
||||
const Targets = require("devtools/server/actors/targets/index");
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
@ -86,6 +87,8 @@ const ContentProcessTargetActor = ActorClassWithSpec(contentProcessTargetSpec, {
|
||||
Services.obs.addObserver(this.destroyObserver, "xpcom-shutdown");
|
||||
},
|
||||
|
||||
targetType: Targets.TYPES.FRAME,
|
||||
|
||||
get isRootActor() {
|
||||
return true;
|
||||
},
|
||||
|
12
devtools/server/actors/targets/index.js
Normal file
12
devtools/server/actors/targets/index.js
Normal file
@ -0,0 +1,12 @@
|
||||
/* 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";
|
||||
|
||||
const TYPES = {
|
||||
FRAME: "frame",
|
||||
PROCESS: "process",
|
||||
WORKER: "worker",
|
||||
};
|
||||
exports.TYPES = TYPES;
|
@ -9,6 +9,7 @@ DevToolsModules(
|
||||
'chrome-window.js',
|
||||
'content-process.js',
|
||||
'frame.js',
|
||||
'index.js',
|
||||
'parent-process.js',
|
||||
'target-actor-registry.jsm',
|
||||
'webextension.js',
|
||||
|
@ -15,14 +15,12 @@ const {
|
||||
const {
|
||||
WatcherRegistry,
|
||||
} = require("devtools/server/actors/watcher/WatcherRegistry.jsm");
|
||||
const Targets = require("devtools/server/actors/targets/index");
|
||||
|
||||
const TARGET_TYPES = {
|
||||
FRAME: "frame",
|
||||
};
|
||||
const TARGET_HELPERS = {};
|
||||
loader.lazyRequireGetter(
|
||||
TARGET_HELPERS,
|
||||
TARGET_TYPES.FRAME,
|
||||
Targets.TYPES.FRAME,
|
||||
"devtools/server/actors/watcher/target-helpers/frame-helper"
|
||||
);
|
||||
|
||||
@ -65,7 +63,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
||||
destroy: function() {
|
||||
// Force unwatching for all types, even if we weren't watching.
|
||||
// This is fine as unwatchTarget is NOOP if we weren't already watching for this target type.
|
||||
for (const targetType of Object.values(TARGET_TYPES)) {
|
||||
for (const targetType of Object.values(Targets.TYPES)) {
|
||||
this.unwatchTargets(targetType);
|
||||
}
|
||||
this.unwatchResources(Object.values(Resources.TYPES));
|
||||
@ -133,7 +131,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
||||
* resolves.
|
||||
*
|
||||
* @param {string} targetType
|
||||
* Type of context to observe. See TARGET_TYPES object.
|
||||
* Type of context to observe. See Targets.TYPES object.
|
||||
*/
|
||||
async watchTargets(targetType) {
|
||||
WatcherRegistry.watchTargets(this, targetType);
|
||||
@ -148,7 +146,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
||||
* Stop watching for a given target type.
|
||||
*
|
||||
* @param {string} targetType
|
||||
* Type of context to observe. See TARGET_TYPES object.
|
||||
* Type of context to observe. See Targets.TYPES object.
|
||||
*/
|
||||
unwatchTargets(targetType) {
|
||||
const isWatchingTargets = WatcherRegistry.unwatchTargets(this, targetType);
|
||||
@ -253,7 +251,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
||||
// so we should always process it. It does a second check to isWatchingTargets.
|
||||
if (
|
||||
!WatcherRegistry.isWatchingTargets(this, targetType) &&
|
||||
targetType != TARGET_TYPES.FRAME
|
||||
targetType != Targets.TYPES.FRAME
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@ -328,7 +326,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
||||
// so we should always process it. It does a second check to isWatchingTargets.
|
||||
if (
|
||||
!WatcherRegistry.isWatchingTargets(this, targetType) &&
|
||||
targetType != TARGET_TYPES.FRAME
|
||||
targetType != Targets.TYPES.FRAME
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ const Services = require("Services");
|
||||
const {
|
||||
WatcherRegistry,
|
||||
} = require("devtools/server/actors/watcher/WatcherRegistry.jsm");
|
||||
const Targets = require("devtools/server/actors/targets/index");
|
||||
|
||||
/**
|
||||
* Force creating targets for all existing BrowsingContext, that, for a given Watcher Actor.
|
||||
@ -145,7 +146,7 @@ function getWatchingBrowsingContexts(watcher) {
|
||||
// either via devtools.contenttoolbox.fission or devtools.browsertoolbox.fission pref.
|
||||
const watchingAdditionalTargets = WatcherRegistry.isWatchingTargets(
|
||||
watcher,
|
||||
"frame"
|
||||
Targets.TYPES.FRAME
|
||||
);
|
||||
const { browserElement } = watcher;
|
||||
const browsingContexts = watchingAdditionalTargets
|
||||
|
@ -43,6 +43,7 @@ var { WebConsoleActor } = worker.require("devtools/server/actors/webconsole");
|
||||
var { TabSources } = worker.require("devtools/server/actors/utils/TabSources");
|
||||
var makeDebugger = worker.require("devtools/server/actors/utils/make-debugger");
|
||||
var { DevToolsServer } = worker.require("devtools/server/devtools-server");
|
||||
var Targets = worker.require("devtools/server/actors/targets/index");
|
||||
|
||||
DevToolsServer.init();
|
||||
DevToolsServer.createRootActor = function() {
|
||||
@ -81,6 +82,8 @@ this.addEventListener("message", function(event) {
|
||||
|
||||
Object.assign(targetActorMock, {
|
||||
actorID: packet.id,
|
||||
targetType: Targets.TYPES.FRAME,
|
||||
|
||||
// threadActor is needed from the webconsole for grip previewing
|
||||
threadActor,
|
||||
workerGlobal: global,
|
||||
|
@ -20,6 +20,7 @@ const {
|
||||
browsingContextTargetSpec,
|
||||
} = require("devtools/shared/specs/targets/browsing-context");
|
||||
const { tabDescriptorSpec } = require("devtools/shared/specs/descriptors/tab");
|
||||
const Targets = require("devtools/server/actors/targets/index");
|
||||
|
||||
var gTestGlobals = new Set();
|
||||
DevToolsServer.addTestGlobal = function(global) {
|
||||
@ -166,6 +167,8 @@ const TestTargetActor = protocol.ActorClassWithSpec(browsingContextTargetSpec, {
|
||||
this.notifyResourceAvailable = this.notifyResourceAvailable.bind(this);
|
||||
},
|
||||
|
||||
targetType: Targets.TYPES.FRAME,
|
||||
|
||||
get window() {
|
||||
return this._global;
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user