зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1813476 - [devtools] Mass migrate all actors from devtools/server/actors/*.js to ES Classes. r=devtools-reviewers,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D168258
This commit is contained in:
Родитель
63582a6a12
Коммит
c4aab2d940
|
@ -25,12 +25,12 @@
|
|||
* /dom/webidl/Animation*.webidl
|
||||
*/
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = protocol;
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
animationPlayerSpec,
|
||||
animationsSpec,
|
||||
} = require("resource://devtools/shared/specs/animation.js");
|
||||
|
||||
const {
|
||||
ANIMATION_TYPE_FOR_LONGHANDS,
|
||||
} = require("resource://devtools/server/actors/animation-type-longhand.js");
|
||||
|
@ -63,14 +63,14 @@ exports.getAnimationTypeForLonghand = getAnimationTypeForLonghand;
|
|||
*
|
||||
* This actor also allows playing, pausing and seeking the animation.
|
||||
*/
|
||||
var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
||||
class AnimationPlayerActor extends Actor {
|
||||
/**
|
||||
* @param {AnimationsActor} The main AnimationsActor instance
|
||||
* @param {AnimationPlayer} The player object returned by getAnimationPlayers
|
||||
* @param {Number} Time which animation created
|
||||
*/
|
||||
initialize(animationsActor, player, createdTime) {
|
||||
Actor.prototype.initialize.call(this, animationsActor.conn);
|
||||
constructor(animationsActor, player, createdTime) {
|
||||
super(animationsActor.conn, animationPlayerSpec);
|
||||
|
||||
this.onAnimationMutation = this.onAnimationMutation.bind(this);
|
||||
|
||||
|
@ -95,7 +95,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
|
||||
this.createdTime = createdTime;
|
||||
this.currentTimeAtCreated = player.currentTime;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
// Only try to disconnect the observer if it's not already dead (i.e. if the
|
||||
|
@ -105,12 +105,12 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
}
|
||||
this.player = this.observer = this.walker = null;
|
||||
|
||||
Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
get isPseudoElement() {
|
||||
return !!this.player.effect.pseudoElement;
|
||||
},
|
||||
}
|
||||
|
||||
get pseudoElemenName() {
|
||||
if (!this.isPseudoElement) {
|
||||
|
@ -121,7 +121,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
/^::/,
|
||||
""
|
||||
)}`;
|
||||
},
|
||||
}
|
||||
|
||||
get node() {
|
||||
if (!this.isPseudoElement) {
|
||||
|
@ -148,21 +148,21 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
`Pseudo element ${this.player.effect.pseudoElement} is not found`
|
||||
);
|
||||
return originatingElem;
|
||||
},
|
||||
}
|
||||
|
||||
get document() {
|
||||
return this.node.ownerDocument;
|
||||
},
|
||||
}
|
||||
|
||||
get window() {
|
||||
return this.document.defaultView;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the actor, when it isn't needed anymore.
|
||||
* Protocol.js uses this release method to call the destroy method.
|
||||
*/
|
||||
release() {},
|
||||
release() {}
|
||||
|
||||
form(detail) {
|
||||
const data = this.getCurrentState();
|
||||
|
@ -175,15 +175,15 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
}
|
||||
|
||||
isCssAnimation(player = this.player) {
|
||||
return player instanceof this.window.CSSAnimation;
|
||||
},
|
||||
}
|
||||
|
||||
isCssTransition(player = this.player) {
|
||||
return player instanceof this.window.CSSTransition;
|
||||
},
|
||||
}
|
||||
|
||||
isScriptAnimation(player = this.player) {
|
||||
return (
|
||||
|
@ -193,7 +193,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
player instanceof this.window.CSSTransition
|
||||
)
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
getType() {
|
||||
if (this.isCssAnimation()) {
|
||||
|
@ -205,7 +205,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
}
|
||||
|
||||
return ANIMATION_TYPES.UNKNOWN;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this animation. This can be either the animation.id
|
||||
|
@ -223,7 +223,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
}
|
||||
|
||||
return "";
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation duration from this player, in milliseconds.
|
||||
|
@ -231,7 +231,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
*/
|
||||
getDuration() {
|
||||
return this.player.effect.getComputedTiming().duration;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation delay from this player, in milliseconds.
|
||||
|
@ -239,7 +239,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
*/
|
||||
getDelay() {
|
||||
return this.player.effect.getComputedTiming().delay;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation endDelay from this player, in milliseconds.
|
||||
|
@ -247,7 +247,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
*/
|
||||
getEndDelay() {
|
||||
return this.player.effect.getComputedTiming().endDelay;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation iteration count for this player. That is, how many times
|
||||
|
@ -258,7 +258,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
getIterationCount() {
|
||||
const iterations = this.player.effect.getComputedTiming().iterations;
|
||||
return iterations === Infinity ? null : iterations;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation iterationStart from this player, in ratio.
|
||||
|
@ -267,7 +267,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
*/
|
||||
getIterationStart() {
|
||||
return this.player.effect.getComputedTiming().iterationStart;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation easing from this player.
|
||||
|
@ -275,7 +275,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
*/
|
||||
getEasing() {
|
||||
return this.player.effect.getComputedTiming().easing;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation fill mode from this player.
|
||||
|
@ -283,7 +283,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
*/
|
||||
getFill() {
|
||||
return this.player.effect.getComputedTiming().fill;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation direction from this player.
|
||||
|
@ -291,7 +291,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
*/
|
||||
getDirection() {
|
||||
return this.player.effect.getComputedTiming().direction;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get animation-timing-function from animated element if CSS Animations.
|
||||
|
@ -310,7 +310,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
target = target.element;
|
||||
}
|
||||
return this.window.getComputedStyle(target, pseudo).animationTimingFunction;
|
||||
},
|
||||
}
|
||||
|
||||
getPropertiesCompositorStatus() {
|
||||
const properties = this.player.effect.getProperties();
|
||||
|
@ -321,7 +321,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
warning: prop.warning,
|
||||
};
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current start of the Animation.
|
||||
|
@ -365,7 +365,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
currentTimeAtCreated: this.currentTimeAtCreated,
|
||||
properties: this.getProperties(),
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current state of the AnimationPlayer (currentTime, playState, ...).
|
||||
|
@ -399,7 +399,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
this.currentState = newState;
|
||||
|
||||
return sentState;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Executed when the current animation changes, used to emit the new state
|
||||
|
@ -443,7 +443,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
if (hasChanged) {
|
||||
this.emit("changed", this.getCurrentState());
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data about the animated properties of this animation player.
|
||||
|
@ -541,7 +541,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
}
|
||||
}
|
||||
return properties;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation types for a given list of CSS property names.
|
||||
|
@ -554,7 +554,7 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
animationTypes[propertyName] = getAnimationTypeForLonghand(propertyName);
|
||||
}
|
||||
return animationTypes;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance of between value1, value2.
|
||||
|
@ -582,17 +582,17 @@ var AnimationPlayerActor = protocol.ActorClassWithSpec(animationPlayerSpec, {
|
|||
// 'auto' keyword and so on.
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.AnimationPlayerActor = AnimationPlayerActor;
|
||||
|
||||
/**
|
||||
* The Animations actor lists animation players for a given node.
|
||||
*/
|
||||
exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
||||
initialize(conn, targetActor) {
|
||||
Actor.prototype.initialize.call(this, conn);
|
||||
exports.AnimationsActor = class AnimationsActor extends Actor {
|
||||
constructor(conn, targetActor) {
|
||||
super(conn, animationsSpec);
|
||||
this.targetActor = targetActor;
|
||||
|
||||
this.onWillNavigate = this.onWillNavigate.bind(this);
|
||||
|
@ -602,16 +602,16 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
this.allAnimationsPaused = false;
|
||||
this.targetActor.on("will-navigate", this.onWillNavigate);
|
||||
this.targetActor.on("navigate", this.onNavigate);
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
this.targetActor.off("will-navigate", this.onWillNavigate);
|
||||
this.targetActor.off("navigate", this.onNavigate);
|
||||
|
||||
this.stopAnimationPlayerUpdates();
|
||||
this.targetActor = this.observer = this.actors = this.walker = null;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Clients can optionally call this with a reference to their WalkerActor.
|
||||
|
@ -623,7 +623,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
*/
|
||||
setWalkerActor(walker) {
|
||||
this.walker = walker;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of AnimationPlayerActor actors for currently running
|
||||
|
@ -668,7 +668,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
});
|
||||
|
||||
return this.actors;
|
||||
},
|
||||
}
|
||||
|
||||
onAnimationMutation(mutations) {
|
||||
const eventData = [];
|
||||
|
@ -743,7 +743,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
this.emit("mutations", eventData);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* After the client has called getAnimationPlayersForNode for a given DOM
|
||||
|
@ -754,19 +754,19 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
if (this.observer && !Cu.isDeadWrapper(this.observer)) {
|
||||
this.observer.disconnect();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
onWillNavigate({ isTopLevel }) {
|
||||
if (isTopLevel) {
|
||||
this.stopAnimationPlayerUpdates();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
onNavigate({ isTopLevel }) {
|
||||
if (isTopLevel) {
|
||||
this.allAnimationsPaused = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause given animations.
|
||||
|
@ -779,7 +779,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
}
|
||||
|
||||
return this.waitForNextFrame(actors);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Play given animations.
|
||||
|
@ -792,7 +792,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
}
|
||||
|
||||
return this.waitForNextFrame(actors);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current time of several animations at the same time.
|
||||
|
@ -816,7 +816,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
}
|
||||
|
||||
return this.waitForNextFrame(players);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the playback rate of several animations at the same time.
|
||||
|
@ -830,7 +830,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
return player.ready;
|
||||
})
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause given player synchronously.
|
||||
|
@ -839,7 +839,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
*/
|
||||
pauseSync(player) {
|
||||
player.startTime = null;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Play given player synchronously.
|
||||
|
@ -856,7 +856,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
const currentTime = player.currentTime || 0;
|
||||
player.startTime =
|
||||
player.timeline.currentTime - currentTime / player.playbackRate;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Return created fime of given animaiton.
|
||||
|
@ -869,7 +869,7 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
animation.timeline.currentTime -
|
||||
animation.currentTime / animation.playbackRate
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for next animation frame.
|
||||
|
@ -895,5 +895,5 @@ exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, {
|
|||
});
|
||||
|
||||
return Promise.all(promises);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
arrayBufferSpec,
|
||||
} = require("resource://devtools/shared/specs/array-buffer.js");
|
||||
|
@ -17,16 +17,16 @@ const {
|
|||
* @param buffer ArrayBuffer
|
||||
* The buffer.
|
||||
*/
|
||||
const ArrayBufferActor = protocol.ActorClassWithSpec(arrayBufferSpec, {
|
||||
initialize(conn, buffer) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
class ArrayBufferActor extends Actor {
|
||||
constructor(conn, buffer) {
|
||||
super(conn, arrayBufferSpec);
|
||||
this.buffer = buffer;
|
||||
this.bufferLength = buffer.byteLength;
|
||||
},
|
||||
}
|
||||
|
||||
rawValue() {
|
||||
return this.buffer;
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
return {
|
||||
|
@ -36,7 +36,7 @@ const ArrayBufferActor = protocol.ActorClassWithSpec(arrayBufferSpec, {
|
|||
// which can either be an ArrayBuffer actor or a LongString actor.
|
||||
typeName: this.typeName,
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
slice(start, count) {
|
||||
const slice = new Uint8Array(this.buffer, start, count);
|
||||
|
@ -61,8 +61,8 @@ const ArrayBufferActor = protocol.ActorClassWithSpec(arrayBufferSpec, {
|
|||
from: this.actorID,
|
||||
encoded: parts.join(""),
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ArrayBufferActor,
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
ActorClassWithSpec,
|
||||
Actor,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
blackboxingSpec,
|
||||
} = require("resource://devtools/shared/specs/blackboxing.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
|
@ -27,15 +25,11 @@ const { BLACKBOXING } = SUPPORTED_DATA;
|
|||
* @constructor
|
||||
*
|
||||
*/
|
||||
const BlackboxingActor = ActorClassWithSpec(blackboxingSpec, {
|
||||
initialize(watcherActor) {
|
||||
class BlackboxingActor extends Actor {
|
||||
constructor(watcherActor) {
|
||||
super(watcherActor.conn, blackboxingSpec);
|
||||
this.watcherActor = watcherActor;
|
||||
Actor.prototype.initialize.call(this, this.watcherActor.conn);
|
||||
},
|
||||
|
||||
destroy(conn) {
|
||||
Actor.prototype.destroy.call(this, conn);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to blackbox a new JS file either completely if no range is passed.
|
||||
|
@ -66,7 +60,7 @@ const BlackboxingActor = ActorClassWithSpec(blackboxingSpec, {
|
|||
};
|
||||
})
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to unblackbox some JS sources.
|
||||
|
@ -90,7 +84,7 @@ const BlackboxingActor = ActorClassWithSpec(blackboxingSpec, {
|
|||
};
|
||||
})
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.BlackboxingActor = BlackboxingActor;
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
ActorClassWithSpec,
|
||||
Actor,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
breakpointListSpec,
|
||||
} = require("resource://devtools/shared/specs/breakpoint-list.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
|
@ -27,25 +25,21 @@ const { BREAKPOINTS, XHR_BREAKPOINTS, EVENT_BREAKPOINTS } = SUPPORTED_DATA;
|
|||
* @constructor
|
||||
*
|
||||
*/
|
||||
const BreakpointListActor = ActorClassWithSpec(breakpointListSpec, {
|
||||
initialize(watcherActor) {
|
||||
class BreakpointListActor extends Actor {
|
||||
constructor(watcherActor) {
|
||||
super(watcherActor.conn, breakpointListSpec);
|
||||
this.watcherActor = watcherActor;
|
||||
Actor.prototype.initialize.call(this, this.watcherActor.conn);
|
||||
},
|
||||
|
||||
destroy(conn) {
|
||||
Actor.prototype.destroy.call(this, conn);
|
||||
},
|
||||
}
|
||||
|
||||
setBreakpoint(location, options) {
|
||||
return this.watcherActor.addDataEntry(BREAKPOINTS, [{ location, options }]);
|
||||
},
|
||||
}
|
||||
|
||||
removeBreakpoint(location, options) {
|
||||
return this.watcherActor.removeDataEntry(BREAKPOINTS, [
|
||||
{ location, options },
|
||||
]);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to break on next XHR or Fetch request for a given URL and HTTP Method.
|
||||
|
@ -60,7 +54,7 @@ const BreakpointListActor = ActorClassWithSpec(breakpointListSpec, {
|
|||
*/
|
||||
setXHRBreakpoint(path, method) {
|
||||
return this.watcherActor.addDataEntry(XHR_BREAKPOINTS, [{ path, method }]);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop breakpoint on requests we ask to break on via setXHRBreakpoint.
|
||||
|
@ -71,7 +65,7 @@ const BreakpointListActor = ActorClassWithSpec(breakpointListSpec, {
|
|||
return this.watcherActor.removeDataEntry(XHR_BREAKPOINTS, [
|
||||
{ path, method },
|
||||
]);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the active breakpoints
|
||||
|
@ -94,7 +88,7 @@ const BreakpointListActor = ActorClassWithSpec(breakpointListSpec, {
|
|||
if (removeIds.length) {
|
||||
this.watcherActor.removeDataEntry(EVENT_BREAKPOINTS, removeIds);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.BreakpointListActor = BreakpointListActor;
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const { changesSpec } = require("resource://devtools/shared/specs/changes.js");
|
||||
|
||||
const TrackChangeEmitter = require("resource://devtools/server/actors/utils/track-change-emitter.js");
|
||||
|
||||
/**
|
||||
* The ChangesActor stores a stack of changes made by devtools on
|
||||
* the document in the associated tab.
|
||||
*/
|
||||
const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
||||
class ChangesActor extends Actor {
|
||||
/**
|
||||
* Create a ChangesActor.
|
||||
*
|
||||
|
@ -21,8 +22,8 @@ const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
|||
* @param {TargetActor} targetActor
|
||||
* The top-level Actor for this tab.
|
||||
*/
|
||||
initialize(conn, targetActor) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
constructor(conn, targetActor) {
|
||||
super(conn, changesSpec);
|
||||
this.targetActor = targetActor;
|
||||
|
||||
this.onTrackChange = this.pushChange.bind(this);
|
||||
|
@ -32,14 +33,14 @@ const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
|||
this.targetActor.on("will-navigate", this.onWillNavigate);
|
||||
|
||||
this.changes = [];
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.clearChanges();
|
||||
this.targetActor.off("will-navigate", this.onWillNavigate);
|
||||
TrackChangeEmitter.off("track-change", this.onTrackChange);
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
start() {
|
||||
/**
|
||||
|
@ -48,11 +49,11 @@ const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
|||
* the front, without triggering side effects, and with a sensible semantic
|
||||
* meaning.
|
||||
*/
|
||||
},
|
||||
}
|
||||
|
||||
changeCount() {
|
||||
return this.changes.length;
|
||||
},
|
||||
}
|
||||
|
||||
change(index) {
|
||||
if (index >= 0 && index < this.changes.length) {
|
||||
|
@ -61,7 +62,7 @@ const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
|||
}
|
||||
// No change at that index -- return undefined.
|
||||
return undefined;
|
||||
},
|
||||
}
|
||||
|
||||
allChanges() {
|
||||
/**
|
||||
|
@ -72,7 +73,7 @@ const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
|||
*/
|
||||
this._changesHaveBeenRequested = true;
|
||||
return this.changes.slice();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for "will-navigate" event from the browsing context. The event is fired for
|
||||
|
@ -94,14 +95,14 @@ const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
|||
if (eventData.isTopLevel) {
|
||||
this.clearChanges();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
pushChange(change) {
|
||||
this.changes.push(change);
|
||||
if (this._changesHaveBeenRequested) {
|
||||
this.emit("add-change", change);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
popChange() {
|
||||
const change = this.changes.pop();
|
||||
|
@ -109,14 +110,14 @@ const ChangesActor = protocol.ActorClassWithSpec(changesSpec, {
|
|||
this.emit("remove-change", change);
|
||||
}
|
||||
return change;
|
||||
},
|
||||
}
|
||||
|
||||
clearChanges() {
|
||||
this.changes.length = 0;
|
||||
if (this._changesHaveBeenRequested) {
|
||||
this.emit("clear-changes");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.ChangesActor = ChangesActor;
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { ActorClassWithSpec, Actor } = protocol;
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
cssPropertiesSpec,
|
||||
} = require("resource://devtools/shared/specs/css-properties.js");
|
||||
|
||||
const { cssColors } = require("resource://devtools/shared/css/color-db.js");
|
||||
const InspectorUtils = require("InspectorUtils");
|
||||
|
||||
|
@ -19,14 +19,10 @@ loader.lazyRequireGetter(
|
|||
true
|
||||
);
|
||||
|
||||
exports.CssPropertiesActor = ActorClassWithSpec(cssPropertiesSpec, {
|
||||
initialize(conn) {
|
||||
Actor.prototype.initialize.call(this, conn);
|
||||
},
|
||||
|
||||
destroy() {
|
||||
Actor.prototype.destroy.call(this);
|
||||
},
|
||||
class CssPropertiesActor extends Actor {
|
||||
constructor(conn) {
|
||||
super(conn, cssPropertiesSpec);
|
||||
}
|
||||
|
||||
getCSSDatabase() {
|
||||
const properties = generateCssProperties();
|
||||
|
@ -39,8 +35,9 @@ exports.CssPropertiesActor = ActorClassWithSpec(cssPropertiesSpec, {
|
|||
};
|
||||
|
||||
return { properties, pseudoElements, supportedFeature };
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CssPropertiesActor = CssPropertiesActor;
|
||||
|
||||
/**
|
||||
* Generate the CSS properties object. Every key is the property name, while
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const { deviceSpec } = require("resource://devtools/shared/specs/device.js");
|
||||
|
||||
const {
|
||||
DevToolsServer,
|
||||
} = require("resource://devtools/server/devtools-server.js");
|
||||
const { getSystemInfo } = require("resource://devtools/shared/system.js");
|
||||
const { deviceSpec } = require("resource://devtools/shared/specs/device.js");
|
||||
const { AppConstants } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/AppConstants.sys.mjs"
|
||||
);
|
||||
|
||||
exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
|
||||
initialize(conn) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
exports.DeviceActor = class DeviceActor extends Actor {
|
||||
constructor(conn) {
|
||||
super(conn, deviceSpec);
|
||||
// pageshow and pagehide event release wake lock, so we have to acquire
|
||||
// wake lock again by pageshow event
|
||||
this._onPageShow = this._onPageShow.bind(this);
|
||||
|
@ -25,21 +25,21 @@ exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
|
|||
this._window.addEventListener("pageshow", this._onPageShow, true);
|
||||
}
|
||||
this._acquireWakeLock();
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
this._releaseWakeLock();
|
||||
if (this._window) {
|
||||
this._window.removeEventListener("pageshow", this._onPageShow, true);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
getDescription() {
|
||||
return Object.assign({}, getSystemInfo(), {
|
||||
canDebugServiceWorkers: true,
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_acquireWakeLock() {
|
||||
if (AppConstants.platform !== "android") {
|
||||
|
@ -50,7 +50,7 @@ exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
|
|||
Ci.nsIPowerManagerService
|
||||
);
|
||||
this._wakelock = pm.newWakeLock("screen", this._window);
|
||||
},
|
||||
}
|
||||
|
||||
_releaseWakeLock() {
|
||||
if (this._wakelock) {
|
||||
|
@ -61,14 +61,14 @@ exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
|
|||
}
|
||||
this._wakelock = null;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onPageShow() {
|
||||
this._releaseWakeLock();
|
||||
this._acquireWakeLock();
|
||||
},
|
||||
}
|
||||
|
||||
get _window() {
|
||||
return Services.wm.getMostRecentWindow(DevToolsServer.chromeWindowType);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
ActorClassWithSpec,
|
||||
Actor,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
createValueGrip,
|
||||
} = require("resource://devtools/server/actors/object/utils.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
environmentSpec,
|
||||
} = require("resource://devtools/shared/specs/environment.js");
|
||||
|
||||
const {
|
||||
createValueGrip,
|
||||
} = require("resource://devtools/server/actors/object/utils.js");
|
||||
|
||||
/**
|
||||
* Creates an EnvironmentActor. EnvironmentActors are responsible for listing
|
||||
* the bindings introduced by a lexical environment and assigning new values to
|
||||
|
@ -24,13 +22,13 @@ const {
|
|||
* @param ThreadActor aThreadActor
|
||||
* The parent thread actor that contains this environment.
|
||||
*/
|
||||
const EnvironmentActor = ActorClassWithSpec(environmentSpec, {
|
||||
initialize(environment, threadActor) {
|
||||
Actor.prototype.initialize.call(this, threadActor.conn);
|
||||
class EnvironmentActor extends Actor {
|
||||
constructor(environment, threadActor) {
|
||||
super(threadActor.conn, environmentSpec);
|
||||
|
||||
this.obj = environment;
|
||||
this.threadActor = threadActor;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* When the Environment Actor is destroyed it removes the
|
||||
|
@ -39,8 +37,8 @@ const EnvironmentActor = ActorClassWithSpec(environmentSpec, {
|
|||
*/
|
||||
destroy() {
|
||||
this.obj.actor = null;
|
||||
Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an environment form for use in a protocol message.
|
||||
|
@ -88,7 +86,7 @@ const EnvironmentActor = ActorClassWithSpec(environmentSpec, {
|
|||
}
|
||||
|
||||
return form;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a protocol request to fully enumerate the bindings introduced by the
|
||||
|
@ -202,7 +200,7 @@ const EnvironmentActor = ActorClassWithSpec(environmentSpec, {
|
|||
}
|
||||
|
||||
return bindings;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.EnvironmentActor = EnvironmentActor;
|
||||
|
|
|
@ -4,17 +4,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { Actor } = require("resource://devtools/shared/protocol/Actor.js");
|
||||
const { Pool } = require("resource://devtools/shared/protocol/Pool.js");
|
||||
const { frameSpec } = require("resource://devtools/shared/specs/frame.js");
|
||||
|
||||
const Debugger = require("Debugger");
|
||||
const { assert } = require("resource://devtools/shared/DevToolsUtils.js");
|
||||
const { Pool } = require("resource://devtools/shared/protocol/Pool.js");
|
||||
const {
|
||||
createValueGrip,
|
||||
} = require("resource://devtools/server/actors/object/utils.js");
|
||||
const {
|
||||
ActorClassWithSpec,
|
||||
Actor,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { frameSpec } = require("resource://devtools/shared/specs/frame.js");
|
||||
|
||||
function formatDisplayName(frame) {
|
||||
if (frame.type === "call") {
|
||||
|
@ -71,7 +69,7 @@ function getSavedFrameParent(threadActor, savedFrame) {
|
|||
/**
|
||||
* An actor for a specified stack frame.
|
||||
*/
|
||||
const FrameActor = ActorClassWithSpec(frameSpec, {
|
||||
class FrameActor extends Actor {
|
||||
/**
|
||||
* Creates the Frame actor.
|
||||
*
|
||||
|
@ -80,24 +78,24 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
|
|||
* @param threadActor ThreadActor
|
||||
* The parent thread actor for this frame.
|
||||
*/
|
||||
initialize(frame, threadActor, depth) {
|
||||
Actor.prototype.initialize.call(this, threadActor.conn);
|
||||
constructor(frame, threadActor, depth) {
|
||||
super(threadActor.conn, frameSpec);
|
||||
|
||||
this.frame = frame;
|
||||
this.threadActor = threadActor;
|
||||
this.depth = depth;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* A pool that contains frame-lifetime objects, like the environment.
|
||||
*/
|
||||
_frameLifetimePool: null,
|
||||
_frameLifetimePool = null;
|
||||
get frameLifetimePool() {
|
||||
if (!this._frameLifetimePool) {
|
||||
this._frameLifetimePool = new Pool(this.conn, "frame");
|
||||
}
|
||||
return this._frameLifetimePool;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalization handler that is called when the actor is being evicted from
|
||||
|
@ -108,8 +106,8 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
|
|||
this._frameLifetimePool.destroy();
|
||||
this._frameLifetimePool = null;
|
||||
}
|
||||
Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
getEnvironment() {
|
||||
try {
|
||||
|
@ -129,7 +127,7 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
|
|||
);
|
||||
|
||||
return envActor.form();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a frame form for use in a protocol message.
|
||||
|
@ -204,7 +202,7 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
|
|||
}
|
||||
|
||||
return form;
|
||||
},
|
||||
}
|
||||
|
||||
_args() {
|
||||
if (!this.frame.onStack || !this.frame.arguments) {
|
||||
|
@ -218,8 +216,8 @@ const FrameActor = ActorClassWithSpec(frameSpec, {
|
|||
this.threadActor.objectGrip
|
||||
)
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.FrameActor = FrameActor;
|
||||
exports.formatDisplayName = formatDisplayName;
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
heapSnapshotFileSpec,
|
||||
} = require("resource://devtools/shared/specs/heap-snapshot-file.js");
|
||||
|
@ -27,55 +26,48 @@ loader.lazyRequireGetter(
|
|||
* because child processes are sandboxed and do not have access to the file
|
||||
* system.
|
||||
*/
|
||||
exports.HeapSnapshotFileActor = protocol.ActorClassWithSpec(
|
||||
heapSnapshotFileSpec,
|
||||
{
|
||||
initialize(conn, parent) {
|
||||
if (
|
||||
Services.appinfo.processType !== Services.appinfo.PROCESS_TYPE_DEFAULT
|
||||
) {
|
||||
const err = new Error(
|
||||
"Attempt to create a HeapSnapshotFileActor in a " +
|
||||
"child process! The HeapSnapshotFileActor *MUST* " +
|
||||
"be in the parent process!"
|
||||
);
|
||||
DevToolsUtils.reportException(
|
||||
"HeapSnapshotFileActor.prototype.initialize",
|
||||
err
|
||||
);
|
||||
return;
|
||||
}
|
||||
exports.HeapSnapshotFileActor = class HeapSnapshotFileActor extends Actor {
|
||||
constructor(conn, parent) {
|
||||
super(conn, heapSnapshotFileSpec);
|
||||
|
||||
protocol.Actor.prototype.initialize.call(this, conn, parent);
|
||||
},
|
||||
|
||||
/**
|
||||
* @see MemoryFront.prototype.transferHeapSnapshot
|
||||
*/
|
||||
async transferHeapSnapshot(snapshotId) {
|
||||
const snapshotFilePath = HeapSnapshotFileUtils.getHeapSnapshotTempFilePath(
|
||||
snapshotId
|
||||
if (
|
||||
Services.appinfo.processType !== Services.appinfo.PROCESS_TYPE_DEFAULT
|
||||
) {
|
||||
const err = new Error(
|
||||
"Attempt to create a HeapSnapshotFileActor in a " +
|
||||
"child process! The HeapSnapshotFileActor *MUST* " +
|
||||
"be in the parent process!"
|
||||
);
|
||||
if (!snapshotFilePath) {
|
||||
throw new Error(`No heap snapshot with id: ${snapshotId}`);
|
||||
}
|
||||
|
||||
const streamPromise = DevToolsUtils.openFileStream(snapshotFilePath);
|
||||
|
||||
const { size } = await IOUtils.stat(snapshotFilePath);
|
||||
const bulkPromise = this.conn.startBulkSend({
|
||||
actor: this.actorID,
|
||||
type: "heap-snapshot",
|
||||
length: size,
|
||||
});
|
||||
|
||||
const [bulk, stream] = await Promise.all([bulkPromise, streamPromise]);
|
||||
|
||||
try {
|
||||
await bulk.copyFrom(stream);
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
},
|
||||
DevToolsUtils.reportException("HeapSnapshotFileActor's constructor", err);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* @see MemoryFront.prototype.transferHeapSnapshot
|
||||
*/
|
||||
async transferHeapSnapshot(snapshotId) {
|
||||
const snapshotFilePath = HeapSnapshotFileUtils.getHeapSnapshotTempFilePath(
|
||||
snapshotId
|
||||
);
|
||||
if (!snapshotFilePath) {
|
||||
throw new Error(`No heap snapshot with id: ${snapshotId}`);
|
||||
}
|
||||
|
||||
const streamPromise = DevToolsUtils.openFileStream(snapshotFilePath);
|
||||
|
||||
const { size } = await IOUtils.stat(snapshotFilePath);
|
||||
const bulkPromise = this.conn.startBulkSend({
|
||||
actor: this.actorID,
|
||||
type: "heap-snapshot",
|
||||
length: size,
|
||||
});
|
||||
|
||||
const [bulk, stream] = await Promise.all([bulkPromise, streamPromise]);
|
||||
|
||||
try {
|
||||
await bulk.copyFrom(stream);
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const { Actor } = require("devtools/shared/protocol");
|
||||
const { customHighlighterSpec } = require("devtools/shared/specs/highlighters");
|
||||
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"isXUL",
|
||||
|
@ -45,131 +46,126 @@ const registerHighlighter = (typeName, modulePath) => {
|
|||
* CustomHighlighterActor proxies calls to methods of the highlighter class instance:
|
||||
* constructor(targetActor), show(node, options), hide(), destroy()
|
||||
*/
|
||||
exports.CustomHighlighterActor = protocol.ActorClassWithSpec(
|
||||
customHighlighterSpec,
|
||||
{
|
||||
/**
|
||||
* Create a highlighter instance given its typeName.
|
||||
*/
|
||||
initialize(parent, typeName) {
|
||||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
exports.CustomHighlighterActor = class CustomHighligherActor extends Actor {
|
||||
/**
|
||||
* Create a highlighter instance given its typeName.
|
||||
*/
|
||||
constructor(parent, typeName) {
|
||||
super(null, customHighlighterSpec);
|
||||
|
||||
this._parent = parent;
|
||||
this._parent = parent;
|
||||
|
||||
const modulePath = highlighterTypes.get(typeName);
|
||||
if (!modulePath) {
|
||||
const list = [...highlighterTypes.keys()];
|
||||
const modulePath = highlighterTypes.get(typeName);
|
||||
if (!modulePath) {
|
||||
const list = [...highlighterTypes.keys()];
|
||||
|
||||
throw new Error(
|
||||
`${typeName} isn't a valid highlighter class (${list})`
|
||||
throw new Error(`${typeName} isn't a valid highlighter class (${list})`);
|
||||
}
|
||||
|
||||
const constructor = require(modulePath)[typeName];
|
||||
// The assumption is that custom highlighters either need the canvasframe
|
||||
// container to append their elements and thus a non-XUL window or they have
|
||||
// to define a static XULSupported flag that indicates that the highlighter
|
||||
// supports XUL windows. Otherwise, bail out.
|
||||
if (!isXUL(this._parent.targetActor.window) || constructor.XULSupported) {
|
||||
this._highlighterEnv = new HighlighterEnvironment();
|
||||
this._highlighterEnv.initFromTargetActor(parent.targetActor);
|
||||
this._highlighter = new constructor(this._highlighterEnv);
|
||||
if (this._highlighter.on) {
|
||||
this._highlighter.on(
|
||||
"highlighter-event",
|
||||
this._onHighlighterEvent.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
const constructor = require(modulePath)[typeName];
|
||||
// The assumption is that custom highlighters either need the canvasframe
|
||||
// container to append their elements and thus a non-XUL window or they have
|
||||
// to define a static XULSupported flag that indicates that the highlighter
|
||||
// supports XUL windows. Otherwise, bail out.
|
||||
if (!isXUL(this._parent.targetActor.window) || constructor.XULSupported) {
|
||||
this._highlighterEnv = new HighlighterEnvironment();
|
||||
this._highlighterEnv.initFromTargetActor(parent.targetActor);
|
||||
this._highlighter = new constructor(this._highlighterEnv);
|
||||
if (this._highlighter.on) {
|
||||
this._highlighter.on(
|
||||
"highlighter-event",
|
||||
this._onHighlighterEvent.bind(this)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
"Custom " + typeName + "highlighter cannot be created in a XUL window"
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
get conn() {
|
||||
return this._parent && this._parent.conn;
|
||||
},
|
||||
|
||||
destroy() {
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
this.finalize();
|
||||
this._parent = null;
|
||||
},
|
||||
|
||||
release() {},
|
||||
|
||||
/**
|
||||
* Get current instance of the highlighter object.
|
||||
*/
|
||||
get instance() {
|
||||
return this._highlighter;
|
||||
},
|
||||
|
||||
/**
|
||||
* Show the highlighter.
|
||||
* This calls through to the highlighter instance's |show(node, options)|
|
||||
* method.
|
||||
*
|
||||
* Most custom highlighters are made to highlight DOM nodes, hence the first
|
||||
* NodeActor argument (NodeActor as in devtools/server/actor/inspector).
|
||||
* Note however that some highlighters use this argument merely as a context
|
||||
* node: The SelectorHighlighter for instance uses it as a base node to run the
|
||||
* provided CSS selector on.
|
||||
*
|
||||
* @param {NodeActor} The node to be highlighted
|
||||
* @param {Object} Options for the custom highlighter
|
||||
* @return {Boolean} True, if the highlighter has been successfully shown
|
||||
*/
|
||||
show(node, options) {
|
||||
if (!this._highlighter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const rawNode = node?.rawNode;
|
||||
|
||||
return this._highlighter.show(rawNode, options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide the highlighter if it was shown before
|
||||
*/
|
||||
hide() {
|
||||
if (this._highlighter) {
|
||||
this._highlighter.hide();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Upon receiving an event from the highlighter, forward it to the client.
|
||||
*/
|
||||
_onHighlighterEvent(data) {
|
||||
this.emit("highlighter-event", data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the custom highlighter implementation.
|
||||
* This method is called automatically just before the actor is destroyed.
|
||||
*/
|
||||
finalize() {
|
||||
if (this._highlighter) {
|
||||
if (this._highlighter.off) {
|
||||
this._highlighter.off(
|
||||
"highlighter-event",
|
||||
this._onHighlighterEvent.bind(this)
|
||||
);
|
||||
}
|
||||
this._highlighter.destroy();
|
||||
this._highlighter = null;
|
||||
}
|
||||
|
||||
if (this._highlighterEnv) {
|
||||
this._highlighterEnv.destroy();
|
||||
this._highlighterEnv = null;
|
||||
}
|
||||
},
|
||||
} else {
|
||||
throw new Error(
|
||||
"Custom " + typeName + "highlighter cannot be created in a XUL window"
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
get conn() {
|
||||
return this._parent && this._parent.conn;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
super.destroy();
|
||||
this.finalize();
|
||||
this._parent = null;
|
||||
}
|
||||
|
||||
release() {}
|
||||
|
||||
/**
|
||||
* Get current instance of the highlighter object.
|
||||
*/
|
||||
get instance() {
|
||||
return this._highlighter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the highlighter.
|
||||
* This calls through to the highlighter instance's |show(node, options)|
|
||||
* method.
|
||||
*
|
||||
* Most custom highlighters are made to highlight DOM nodes, hence the first
|
||||
* NodeActor argument (NodeActor as in devtools/server/actor/inspector).
|
||||
* Note however that some highlighters use this argument merely as a context
|
||||
* node: The SelectorHighlighter for instance uses it as a base node to run the
|
||||
* provided CSS selector on.
|
||||
*
|
||||
* @param {NodeActor} The node to be highlighted
|
||||
* @param {Object} Options for the custom highlighter
|
||||
* @return {Boolean} True, if the highlighter has been successfully shown
|
||||
*/
|
||||
show(node, options) {
|
||||
if (!this._highlighter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const rawNode = node?.rawNode;
|
||||
|
||||
return this._highlighter.show(rawNode, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the highlighter if it was shown before
|
||||
*/
|
||||
hide() {
|
||||
if (this._highlighter) {
|
||||
this._highlighter.hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upon receiving an event from the highlighter, forward it to the client.
|
||||
*/
|
||||
_onHighlighterEvent(data) {
|
||||
this.emit("highlighter-event", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the custom highlighter implementation.
|
||||
* This method is called automatically just before the actor is destroyed.
|
||||
*/
|
||||
finalize() {
|
||||
if (this._highlighter) {
|
||||
if (this._highlighter.off) {
|
||||
this._highlighter.off(
|
||||
"highlighter-event",
|
||||
this._onHighlighterEvent.bind(this)
|
||||
);
|
||||
}
|
||||
this._highlighter.destroy();
|
||||
this._highlighter = null;
|
||||
}
|
||||
|
||||
if (this._highlighterEnv) {
|
||||
this._highlighterEnv.destroy();
|
||||
this._highlighterEnv = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The HighlighterEnvironment is an object that holds all the required data for
|
||||
|
@ -183,27 +179,25 @@ exports.CustomHighlighterActor = protocol.ActorClassWithSpec(
|
|||
* It can also be initialized just with a window object (which is
|
||||
* useful for when a highlighter is used outside of the devtools server context.
|
||||
*/
|
||||
function HighlighterEnvironment() {
|
||||
this.relayTargetActorWindowReady = this.relayTargetActorWindowReady.bind(
|
||||
this
|
||||
);
|
||||
this.relayTargetActorNavigate = this.relayTargetActorNavigate.bind(this);
|
||||
this.relayTargetActorWillNavigate = this.relayTargetActorWillNavigate.bind(
|
||||
this
|
||||
);
|
||||
|
||||
EventEmitter.decorate(this);
|
||||
}
|
||||
class HighlighterEnvironment extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
this.relayTargetActorWindowReady = this.relayTargetActorWindowReady.bind(
|
||||
this
|
||||
);
|
||||
this.relayTargetActorNavigate = this.relayTargetActorNavigate.bind(this);
|
||||
this.relayTargetActorWillNavigate = this.relayTargetActorWillNavigate.bind(
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
exports.HighlighterEnvironment = HighlighterEnvironment;
|
||||
|
||||
HighlighterEnvironment.prototype = {
|
||||
initFromTargetActor(targetActor) {
|
||||
this._targetActor = targetActor;
|
||||
this._targetActor.on("window-ready", this.relayTargetActorWindowReady);
|
||||
this._targetActor.on("navigate", this.relayTargetActorNavigate);
|
||||
this._targetActor.on("will-navigate", this.relayTargetActorWillNavigate);
|
||||
},
|
||||
}
|
||||
|
||||
initFromWindow(win) {
|
||||
this._win = win;
|
||||
|
@ -249,15 +243,15 @@ HighlighterEnvironment.prototype = {
|
|||
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW |
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
get isInitialized() {
|
||||
return this._win || this._targetActor;
|
||||
},
|
||||
}
|
||||
|
||||
get isXUL() {
|
||||
return isXUL(this.window);
|
||||
},
|
||||
}
|
||||
|
||||
get window() {
|
||||
if (!this.isInitialized) {
|
||||
|
@ -274,15 +268,15 @@ HighlighterEnvironment.prototype = {
|
|||
// win is null
|
||||
return null;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
get document() {
|
||||
return this.window && this.window.document;
|
||||
},
|
||||
}
|
||||
|
||||
get docShell() {
|
||||
return this.window && this.window.docShell;
|
||||
},
|
||||
}
|
||||
|
||||
get webProgress() {
|
||||
return (
|
||||
|
@ -291,7 +285,7 @@ HighlighterEnvironment.prototype = {
|
|||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress)
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the right target for listening to events on the page.
|
||||
|
@ -310,19 +304,19 @@ HighlighterEnvironment.prototype = {
|
|||
return this.window;
|
||||
}
|
||||
return this.docShell && this.docShell.chromeEventHandler;
|
||||
},
|
||||
}
|
||||
|
||||
relayTargetActorWindowReady(data) {
|
||||
this.emit("window-ready", data);
|
||||
},
|
||||
}
|
||||
|
||||
relayTargetActorNavigate(data) {
|
||||
this.emit("navigate", data);
|
||||
},
|
||||
}
|
||||
|
||||
relayTargetActorWillNavigate(data) {
|
||||
this.emit("will-navigate", data);
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this._targetActor) {
|
||||
|
@ -343,8 +337,9 @@ HighlighterEnvironment.prototype = {
|
|||
|
||||
this._targetActor = null;
|
||||
this._win = null;
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.HighlighterEnvironment = HighlighterEnvironment;
|
||||
|
||||
// This constant object is created to make the calls array more
|
||||
// readable. Otherwise, linting rules force some array defs to span 4
|
||||
|
|
|
@ -4,16 +4,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
Actor,
|
||||
ActorClassWithSpec,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
flexboxSpec,
|
||||
flexItemSpec,
|
||||
gridSpec,
|
||||
layoutSpec,
|
||||
} = require("resource://devtools/shared/specs/layout.js");
|
||||
|
||||
const {
|
||||
getStringifiableFragments,
|
||||
} = require("resource://devtools/server/actors/utils/css-grid-utils.js");
|
||||
|
@ -67,26 +65,26 @@ loader.lazyRequireGetter(
|
|||
* The |Grid| actor provides the grid fragment information to inspect the grid container.
|
||||
*/
|
||||
|
||||
const FlexboxActor = ActorClassWithSpec(flexboxSpec, {
|
||||
class FlexboxActor extends Actor {
|
||||
/**
|
||||
* @param {LayoutActor} layoutActor
|
||||
* The LayoutActor instance.
|
||||
* @param {DOMNode} containerEl
|
||||
* The flex container element.
|
||||
*/
|
||||
initialize(layoutActor, containerEl) {
|
||||
Actor.prototype.initialize.call(this, layoutActor.conn);
|
||||
constructor(layoutActor, containerEl) {
|
||||
super(layoutActor.conn, flexboxSpec);
|
||||
|
||||
this.containerEl = containerEl;
|
||||
this.walker = layoutActor.walker;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
|
||||
this.containerEl = null;
|
||||
this.walker = null;
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
const styles = CssLogic.getComputedStyle(this.containerEl);
|
||||
|
@ -111,7 +109,7 @@ const FlexboxActor = ActorClassWithSpec(flexboxSpec, {
|
|||
}
|
||||
|
||||
return form;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of FlexItemActor objects for all the flex item elements contained
|
||||
|
@ -153,13 +151,13 @@ const FlexboxActor = ActorClassWithSpec(flexboxSpec, {
|
|||
}
|
||||
|
||||
return flexItemActors;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The FlexItemActor provides information about a flex items' data.
|
||||
*/
|
||||
const FlexItemActor = ActorClassWithSpec(flexItemSpec, {
|
||||
class FlexItemActor extends Actor {
|
||||
/**
|
||||
* @param {FlexboxActor} flexboxActor
|
||||
* The FlexboxActor instance.
|
||||
|
@ -168,23 +166,23 @@ const FlexItemActor = ActorClassWithSpec(flexItemSpec, {
|
|||
* @param {Object} flexItemSizing
|
||||
* The flex item sizing data.
|
||||
*/
|
||||
initialize(flexboxActor, element, flexItemSizing) {
|
||||
Actor.prototype.initialize.call(this, flexboxActor.conn);
|
||||
constructor(flexboxActor, element, flexItemSizing) {
|
||||
super(flexboxActor.conn, flexItemSpec);
|
||||
|
||||
this.containerEl = flexboxActor.containerEl;
|
||||
this.element = element;
|
||||
this.flexItemSizing = flexItemSizing;
|
||||
this.walker = flexboxActor.walker;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
|
||||
this.containerEl = null;
|
||||
this.element = null;
|
||||
this.flexItemSizing = null;
|
||||
this.walker = null;
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
const { mainAxisDirection } = this.flexItemSizing;
|
||||
|
@ -285,33 +283,33 @@ const FlexItemActor = ActorClassWithSpec(flexItemSpec, {
|
|||
}
|
||||
|
||||
return form;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The GridActor provides information about a given grid's fragment data.
|
||||
*/
|
||||
const GridActor = ActorClassWithSpec(gridSpec, {
|
||||
class GridActor extends Actor {
|
||||
/**
|
||||
* @param {LayoutActor} layoutActor
|
||||
* The LayoutActor instance.
|
||||
* @param {DOMNode} containerEl
|
||||
* The grid container element.
|
||||
*/
|
||||
initialize(layoutActor, containerEl) {
|
||||
Actor.prototype.initialize.call(this, layoutActor.conn);
|
||||
constructor(layoutActor, containerEl) {
|
||||
super(layoutActor.conn, gridSpec);
|
||||
|
||||
this.containerEl = containerEl;
|
||||
this.walker = layoutActor.walker;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
|
||||
this.containerEl = null;
|
||||
this.gridFragments = null;
|
||||
this.walker = null;
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
// Seralize the grid fragment data into JSON so protocol.js knows how to write
|
||||
|
@ -346,26 +344,26 @@ const GridActor = ActorClassWithSpec(gridSpec, {
|
|||
gridTemplateColumns.startsWith("subgrid");
|
||||
|
||||
return form;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The CSS layout actor provides layout information for the given document.
|
||||
*/
|
||||
const LayoutActor = ActorClassWithSpec(layoutSpec, {
|
||||
initialize(conn, targetActor, walker) {
|
||||
Actor.prototype.initialize.call(this, conn);
|
||||
class LayoutActor extends Actor {
|
||||
constructor(conn, targetActor, walker) {
|
||||
super(conn, layoutSpec);
|
||||
|
||||
this.targetActor = targetActor;
|
||||
this.walker = walker;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
|
||||
this.targetActor = null;
|
||||
this.walker = null;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getAsFlexItem, getCurrentGrid and getCurrentFlexbox. Returns the
|
||||
|
@ -435,7 +433,7 @@ const LayoutActor = ActorClassWithSpec(layoutSpec, {
|
|||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grid container for a given selected node.
|
||||
|
@ -451,7 +449,7 @@ const LayoutActor = ActorClassWithSpec(layoutSpec, {
|
|||
*/
|
||||
getCurrentGrid(node) {
|
||||
return this.getCurrentDisplay(node, "grid");
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flex container for a given selected node.
|
||||
|
@ -469,7 +467,7 @@ const LayoutActor = ActorClassWithSpec(layoutSpec, {
|
|||
*/
|
||||
getCurrentFlexbox(node, onlyLookAtParents) {
|
||||
return this.getCurrentDisplay(node, "flex", onlyLookAtParents);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of GridActor objects for all the grid elements contained in the
|
||||
|
@ -511,8 +509,8 @@ const LayoutActor = ActorClassWithSpec(layoutSpec, {
|
|||
}
|
||||
|
||||
return gridActors;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function isNodeDead(node) {
|
||||
return !node || (node.rawNode && Cu.isDeadWrapper(node.rawNode));
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
Actor,
|
||||
ActorClassWithSpec,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
manifestSpec,
|
||||
} = require("resource://devtools/shared/specs/manifest.js");
|
||||
|
@ -23,11 +20,11 @@ ChromeUtils.defineModuleGetter(
|
|||
/**
|
||||
* An actor for a Web Manifest
|
||||
*/
|
||||
const ManifestActor = ActorClassWithSpec(manifestSpec, {
|
||||
initialize(conn, targetActor) {
|
||||
Actor.prototype.initialize.call(this, conn);
|
||||
class ManifestActor extends Actor {
|
||||
constructor(conn, targetActor) {
|
||||
super(conn, manifestSpec);
|
||||
this.targetActor = targetActor;
|
||||
},
|
||||
}
|
||||
|
||||
async fetchCanonicalManifest() {
|
||||
try {
|
||||
|
@ -39,7 +36,7 @@ const ManifestActor = ActorClassWithSpec(manifestSpec, {
|
|||
} catch (error) {
|
||||
return { manifest: null, errorMessage: error.message };
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.ManifestActor = ManifestActor;
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const { memorySpec } = require("resource://devtools/shared/specs/memory.js");
|
||||
|
||||
const { Memory } = require("resource://devtools/server/performance/memory.js");
|
||||
const {
|
||||
actorBridgeWithSpec,
|
||||
} = require("resource://devtools/server/actors/common.js");
|
||||
const { memorySpec } = require("resource://devtools/shared/specs/memory.js");
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"StackFrameCache",
|
||||
|
@ -28,61 +30,61 @@ loader.lazyRequireGetter(
|
|||
*
|
||||
* @see devtools/server/performance/memory.js for documentation.
|
||||
*/
|
||||
exports.MemoryActor = protocol.ActorClassWithSpec(memorySpec, {
|
||||
initialize(conn, parent, frameCache = new StackFrameCache()) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
exports.MemoryActor = class MemoryActor extends Actor {
|
||||
constructor(conn, parent, frameCache = new StackFrameCache()) {
|
||||
super(conn, memorySpec);
|
||||
|
||||
this._onGarbageCollection = this._onGarbageCollection.bind(this);
|
||||
this._onAllocations = this._onAllocations.bind(this);
|
||||
this.bridge = new Memory(parent, frameCache);
|
||||
this.bridge.on("garbage-collection", this._onGarbageCollection);
|
||||
this.bridge.on("allocations", this._onAllocations);
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.bridge.off("garbage-collection", this._onGarbageCollection);
|
||||
this.bridge.off("allocations", this._onAllocations);
|
||||
this.bridge.destroy();
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
attach: actorBridgeWithSpec("attach"),
|
||||
attach = actorBridgeWithSpec("attach");
|
||||
|
||||
detach: actorBridgeWithSpec("detach"),
|
||||
detach = actorBridgeWithSpec("detach");
|
||||
|
||||
getState: actorBridgeWithSpec("getState"),
|
||||
getState = actorBridgeWithSpec("getState");
|
||||
|
||||
saveHeapSnapshot(boundaries) {
|
||||
return this.bridge.saveHeapSnapshot(boundaries);
|
||||
},
|
||||
}
|
||||
|
||||
takeCensus: actorBridgeWithSpec("takeCensus"),
|
||||
takeCensus = actorBridgeWithSpec("takeCensus");
|
||||
|
||||
startRecordingAllocations: actorBridgeWithSpec("startRecordingAllocations"),
|
||||
startRecordingAllocations = actorBridgeWithSpec("startRecordingAllocations");
|
||||
|
||||
stopRecordingAllocations: actorBridgeWithSpec("stopRecordingAllocations"),
|
||||
stopRecordingAllocations = actorBridgeWithSpec("stopRecordingAllocations");
|
||||
|
||||
getAllocationsSettings: actorBridgeWithSpec("getAllocationsSettings"),
|
||||
getAllocationsSettings = actorBridgeWithSpec("getAllocationsSettings");
|
||||
|
||||
getAllocations: actorBridgeWithSpec("getAllocations"),
|
||||
getAllocations = actorBridgeWithSpec("getAllocations");
|
||||
|
||||
forceGarbageCollection: actorBridgeWithSpec("forceGarbageCollection"),
|
||||
forceGarbageCollection = actorBridgeWithSpec("forceGarbageCollection");
|
||||
|
||||
forceCycleCollection: actorBridgeWithSpec("forceCycleCollection"),
|
||||
forceCycleCollection = actorBridgeWithSpec("forceCycleCollection");
|
||||
|
||||
measure: actorBridgeWithSpec("measure"),
|
||||
measure = actorBridgeWithSpec("measure");
|
||||
|
||||
residentUnique: actorBridgeWithSpec("residentUnique"),
|
||||
residentUnique = actorBridgeWithSpec("residentUnique");
|
||||
|
||||
_onGarbageCollection(data) {
|
||||
if (this.conn.transport) {
|
||||
this.emit("garbage-collection", data);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onAllocations(data) {
|
||||
if (this.conn.transport) {
|
||||
this.emit("allocations", data);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
pageStyleSpec,
|
||||
} = require("resource://devtools/shared/specs/page-style.js");
|
||||
|
||||
const { getCSSLexer } = require("resource://devtools/shared/css/lexer.js");
|
||||
const {
|
||||
LongStringActor,
|
||||
|
@ -12,9 +16,6 @@ const {
|
|||
const InspectorUtils = require("InspectorUtils");
|
||||
const TrackChangeEmitter = require("resource://devtools/server/actors/utils/track-change-emitter.js");
|
||||
|
||||
const {
|
||||
pageStyleSpec,
|
||||
} = require("resource://devtools/shared/specs/page-style.js");
|
||||
const {
|
||||
style: { ELEMENT_STYLE },
|
||||
} = require("resource://devtools/shared/constants.js");
|
||||
|
@ -69,7 +70,7 @@ const BOLD_FONT_WEIGHT = 700;
|
|||
* The PageStyle actor lets the client look at the styles on a page, as
|
||||
* they are applied to a given node.
|
||||
*/
|
||||
var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
||||
class PageStyleActor extends Actor {
|
||||
/**
|
||||
* Create a PageStyleActor.
|
||||
*
|
||||
|
@ -78,8 +79,8 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
*
|
||||
* @constructor
|
||||
*/
|
||||
initialize(inspector) {
|
||||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
constructor(inspector) {
|
||||
super(null, pageStyleSpec);
|
||||
this.inspector = inspector;
|
||||
if (!this.inspector.walker) {
|
||||
throw Error(
|
||||
|
@ -110,13 +111,13 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
|
||||
this._onStylesheetUpdated = this._onStylesheetUpdated.bind(this);
|
||||
this.styleSheetsManager.on("stylesheet-updated", this._onStylesheetUpdated);
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (!this.walker) {
|
||||
return;
|
||||
}
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
this.inspector.targetActor.off("will-navigate", this.onFrameUnload);
|
||||
this.inspector = null;
|
||||
this.walker = null;
|
||||
|
@ -126,15 +127,15 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
this.styleElements = null;
|
||||
|
||||
this._observedRules = [];
|
||||
},
|
||||
}
|
||||
|
||||
get conn() {
|
||||
return this.inspector.conn;
|
||||
},
|
||||
}
|
||||
|
||||
get ownerWindow() {
|
||||
return this.inspector.targetActor.window;
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
// We need to use CSS from the inspected window in order to use CSS.supports() and
|
||||
|
@ -159,7 +160,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
CSS.supports("font-weight: 1") && CSS.supports("font-stretch: 100%"),
|
||||
},
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a style sheet is updated.
|
||||
|
@ -171,7 +172,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
if (kind === UPDATE_GENERAL) {
|
||||
this.emit("stylesheet-updated");
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Return or create a StyleRuleActor for the given item.
|
||||
|
@ -186,7 +187,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
this.refMap.set(item, actor);
|
||||
|
||||
return actor;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the association between a StyleRuleActor and its
|
||||
|
@ -201,7 +202,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
updateStyleRef(oldItem, item, actor) {
|
||||
this.refMap.delete(oldItem);
|
||||
this.refMap.set(item, actor);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the StyleRuleActor matching the given rule id or null if no match is found.
|
||||
|
@ -221,7 +222,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
|
||||
return match;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the computed style for a node.
|
||||
|
@ -281,7 +282,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the fonts from a page.
|
||||
|
@ -306,7 +307,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
|
||||
return fontsList;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font faces used in an element.
|
||||
|
@ -419,7 +420,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
});
|
||||
|
||||
return fontsArray;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of selectors that match a given property for a node.
|
||||
|
@ -488,7 +489,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
matched,
|
||||
rules: [...rules],
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
// Get a selector source for a CssSelectorInfo relative to a given
|
||||
// node.
|
||||
|
@ -504,7 +505,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
result += ".style";
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the set of styles that apply to a given node.
|
||||
|
@ -552,13 +553,13 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
this._observedRules = result.rules;
|
||||
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
_hasInheritedProps(style) {
|
||||
return Array.prototype.some.call(style, prop => {
|
||||
return InspectorUtils.isInheritedProperty(prop);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
async isPositionEditable(node) {
|
||||
if (!node || node.rawNode.nodeType !== node.rawNode.ELEMENT_NODE) {
|
||||
|
@ -575,7 +576,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
props.has("left") ||
|
||||
props.has("bottom")
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getApplied, gets all the rules from a given
|
||||
|
@ -655,7 +656,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
|
||||
return rules;
|
||||
},
|
||||
}
|
||||
|
||||
_nodeIsTextfieldLike(node) {
|
||||
if (node.nodeName == "TEXTAREA") {
|
||||
|
@ -665,7 +666,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
node.mozIsTextField &&
|
||||
(node.mozIsTextField(false) || node.type == "number")
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
_nodeIsButtonLike(node) {
|
||||
if (node.nodeName == "BUTTON") {
|
||||
|
@ -675,13 +676,13 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
node.nodeName == "INPUT" &&
|
||||
["submit", "color", "button"].includes(node.type)
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
_nodeIsListItem(node) {
|
||||
const display = CssLogic.getComputedStyle(node).getPropertyValue("display");
|
||||
// This is written this way to handle `inline list-item` and such.
|
||||
return display.split(" ").includes("list-item");
|
||||
},
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
_pseudoIsRelevant(node, pseudo) {
|
||||
|
@ -718,7 +719,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
default:
|
||||
throw Error("Unhandled pseudo-element " + pseudo);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for _getAllElementRules, returns the rules from a given
|
||||
|
@ -777,7 +778,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
});
|
||||
}
|
||||
return rules;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a node and a CSS rule, walk up the DOM looking for a
|
||||
|
@ -802,7 +803,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
|
||||
return entries.filter(entry => entry.rule.rawRule === filterRule);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getApplied that fetches a set of style properties that
|
||||
|
@ -901,7 +902,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
entries,
|
||||
rules: [...rules],
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a set of rules to include all parent rules.
|
||||
|
@ -916,7 +917,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get layout-related information about a node.
|
||||
|
@ -983,7 +984,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
|
||||
return layout;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Find 'auto' margin properties.
|
||||
|
@ -1000,14 +1001,14 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
|
||||
return margins;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* On page navigation, tidy up remaining objects.
|
||||
*/
|
||||
onFrameUnload() {
|
||||
this.styleElements = new WeakMap();
|
||||
},
|
||||
}
|
||||
|
||||
_onStylesheetUpdated({ resourceId, updateKind, updates = {} }) {
|
||||
if (updateKind != "style-applied") {
|
||||
|
@ -1029,7 +1030,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
}
|
||||
this._styleApplied(kind);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for adding a new rule and getting its applied style
|
||||
|
@ -1043,7 +1044,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
return this.getAppliedProps(node, [{ rule: ruleActor }], {
|
||||
matchedSelectors: true,
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new rule, and returns the new StyleRuleActor.
|
||||
|
@ -1101,7 +1102,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
});
|
||||
|
||||
return this.getNewAppliedProps(node, cssRule);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Cause all StyleRuleActor instances of observed CSS rules to check whether the
|
||||
|
@ -1121,7 +1122,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
for (const rule of this._observedRules) {
|
||||
rule.refresh();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of existing attribute values in a node document.
|
||||
|
@ -1162,7 +1163,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
);
|
||||
|
||||
return Array.from(result).sort();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect attribute values from the document DOM tree, matching the passed filter and
|
||||
|
@ -1211,7 +1212,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
result.add(value);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect attribute values from the document stylesheets, matching the passed filter
|
||||
|
@ -1240,7 +1241,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
this._collectAttributesFromRule(result, rule, search, attributeType);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect attribute values from the rule, matching the passed filter and type, to the
|
||||
|
@ -1292,6 +1293,6 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.PageStyleActor = PageStyleActor;
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { ActorClassWithSpec, Actor } = protocol;
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const { perfSpec } = require("resource://devtools/shared/specs/perf.js");
|
||||
|
||||
const {
|
||||
actorBridgeWithSpec,
|
||||
} = require("resource://devtools/server/actors/common.js");
|
||||
const { perfSpec } = require("resource://devtools/shared/specs/perf.js");
|
||||
const {
|
||||
ActorReadyGeckoProfilerInterface,
|
||||
} = require("resource://devtools/shared/performance-new/gecko-profiler-interface.js");
|
||||
|
@ -27,29 +27,29 @@ function _bridgeEvents(actor, names) {
|
|||
/**
|
||||
* The PerfActor wraps the Gecko Profiler interface
|
||||
*/
|
||||
exports.PerfActor = ActorClassWithSpec(perfSpec, {
|
||||
initialize(conn, targetActor) {
|
||||
Actor.prototype.initialize.call(this, conn);
|
||||
exports.PerfActor = class PerfActor extends Actor {
|
||||
constructor(conn, targetActor) {
|
||||
super(conn, perfSpec);
|
||||
// The "bridge" is the actual implementation of the actor. It is separated
|
||||
// for historical reasons, and could be merged into this class.
|
||||
this.bridge = new ActorReadyGeckoProfilerInterface();
|
||||
|
||||
_bridgeEvents(this, ["profiler-started", "profiler-stopped"]);
|
||||
},
|
||||
}
|
||||
|
||||
destroy(conn) {
|
||||
Actor.prototype.destroy.call(this, conn);
|
||||
destroy() {
|
||||
super.destroy();
|
||||
this.bridge.destroy();
|
||||
},
|
||||
}
|
||||
|
||||
// Connect the rest of the ActorReadyGeckoProfilerInterface's methods to the PerfActor.
|
||||
startProfiler: actorBridgeWithSpec("startProfiler"),
|
||||
stopProfilerAndDiscardProfile: actorBridgeWithSpec(
|
||||
startProfiler = actorBridgeWithSpec("startProfiler");
|
||||
stopProfilerAndDiscardProfile = actorBridgeWithSpec(
|
||||
"stopProfilerAndDiscardProfile"
|
||||
),
|
||||
getSymbolTable: actorBridgeWithSpec("getSymbolTable"),
|
||||
getProfileAndStopProfiler: actorBridgeWithSpec("getProfileAndStopProfiler"),
|
||||
isActive: actorBridgeWithSpec("isActive"),
|
||||
isSupportedPlatform: actorBridgeWithSpec("isSupportedPlatform"),
|
||||
getSupportedFeatures: actorBridgeWithSpec("getSupportedFeatures"),
|
||||
});
|
||||
);
|
||||
getSymbolTable = actorBridgeWithSpec("getSymbolTable");
|
||||
getProfileAndStopProfiler = actorBridgeWithSpec("getProfileAndStopProfiler");
|
||||
isActive = actorBridgeWithSpec("isActive");
|
||||
isSupportedPlatform = actorBridgeWithSpec("isSupportedPlatform");
|
||||
getSupportedFeatures = actorBridgeWithSpec("getSupportedFeatures");
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
preferenceSpec,
|
||||
} = require("resource://devtools/shared/specs/preference.js");
|
||||
|
@ -28,29 +28,32 @@ function ensurePrefType(name, expectedType) {
|
|||
* This actor is used as a global-scoped actor, targeting the entire browser, not an
|
||||
* individual tab.
|
||||
*/
|
||||
var PreferenceActor = protocol.ActorClassWithSpec(preferenceSpec, {
|
||||
class PreferenceActor extends Actor {
|
||||
constructor(conn) {
|
||||
super(conn, preferenceSpec);
|
||||
}
|
||||
getTraits() {
|
||||
// The *Pref traits are used to know if remote-debugging bugs related to
|
||||
// specific preferences are fixed on the server or if the client should set
|
||||
// default values for them. See the about:debugging module
|
||||
// runtime-default-preferences.js
|
||||
return {};
|
||||
},
|
||||
}
|
||||
|
||||
getBoolPref(name) {
|
||||
ensurePrefType(name, PREF_BOOL);
|
||||
return Services.prefs.getBoolPref(name);
|
||||
},
|
||||
}
|
||||
|
||||
getCharPref(name) {
|
||||
ensurePrefType(name, PREF_STRING);
|
||||
return Services.prefs.getCharPref(name);
|
||||
},
|
||||
}
|
||||
|
||||
getIntPref(name) {
|
||||
ensurePrefType(name, PREF_INT);
|
||||
return Services.prefs.getIntPref(name);
|
||||
},
|
||||
}
|
||||
|
||||
getAllPrefs() {
|
||||
const prefs = {};
|
||||
|
@ -79,27 +82,27 @@ var PreferenceActor = protocol.ActorClassWithSpec(preferenceSpec, {
|
|||
}
|
||||
});
|
||||
return prefs;
|
||||
},
|
||||
}
|
||||
|
||||
setBoolPref(name, value) {
|
||||
Services.prefs.setBoolPref(name, value);
|
||||
Services.prefs.savePrefFile(null);
|
||||
},
|
||||
}
|
||||
|
||||
setCharPref(name, value) {
|
||||
Services.prefs.setCharPref(name, value);
|
||||
Services.prefs.savePrefFile(null);
|
||||
},
|
||||
}
|
||||
|
||||
setIntPref(name, value) {
|
||||
Services.prefs.setIntPref(name, value);
|
||||
Services.prefs.savePrefFile(null);
|
||||
},
|
||||
}
|
||||
|
||||
clearUserPref(name) {
|
||||
Services.prefs.clearUserPref(name);
|
||||
Services.prefs.savePrefFile(null);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.PreferenceActor = PreferenceActor;
|
||||
|
|
|
@ -24,22 +24,23 @@
|
|||
* These dedicated classes are used by the LayoutChangesObserver.
|
||||
*/
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const EventEmitter = require("resource://devtools/shared/event-emitter.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const { reflowSpec } = require("resource://devtools/shared/specs/reflow.js");
|
||||
|
||||
const EventEmitter = require("resource://devtools/shared/event-emitter.js");
|
||||
|
||||
/**
|
||||
* The reflow actor tracks reflows and emits events about them.
|
||||
*/
|
||||
exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, {
|
||||
initialize(conn, targetActor) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
exports.ReflowActor = class ReflowActor extends Actor {
|
||||
constructor(conn, targetActor) {
|
||||
super(conn, reflowSpec);
|
||||
|
||||
this.targetActor = targetActor;
|
||||
this._onReflow = this._onReflow.bind(this);
|
||||
this.observer = getLayoutChangesObserver(targetActor);
|
||||
this._isStarted = false;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.stop();
|
||||
|
@ -47,8 +48,8 @@ exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, {
|
|||
this.observer = null;
|
||||
this.targetActor = null;
|
||||
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start tracking reflows and sending events to clients about them.
|
||||
|
@ -60,7 +61,7 @@ exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, {
|
|||
this.observer.on("reflows", this._onReflow);
|
||||
this._isStarted = true;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop tracking reflows and sending events to clients about them.
|
||||
|
@ -72,14 +73,14 @@ exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, {
|
|||
this.observer.off("reflows", this._onReflow);
|
||||
this._isStarted = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onReflow(reflows) {
|
||||
if (this._isStarted) {
|
||||
this.emit("reflows", reflows);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for all sorts of observers that need to listen to events on the
|
||||
|
@ -87,22 +88,22 @@ exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, {
|
|||
* @param {WindowGlobalTargetActor} targetActor
|
||||
* @param {Function} callback Executed everytime the observer observes something
|
||||
*/
|
||||
function Observable(targetActor, callback) {
|
||||
this.targetActor = targetActor;
|
||||
this.callback = callback;
|
||||
class Observable {
|
||||
constructor(targetActor, callback) {
|
||||
this.targetActor = targetActor;
|
||||
this.callback = callback;
|
||||
|
||||
this._onWindowReady = this._onWindowReady.bind(this);
|
||||
this._onWindowDestroyed = this._onWindowDestroyed.bind(this);
|
||||
this._onWindowReady = this._onWindowReady.bind(this);
|
||||
this._onWindowDestroyed = this._onWindowDestroyed.bind(this);
|
||||
|
||||
this.targetActor.on("window-ready", this._onWindowReady);
|
||||
this.targetActor.on("window-destroyed", this._onWindowDestroyed);
|
||||
}
|
||||
this.targetActor.on("window-ready", this._onWindowReady);
|
||||
this.targetActor.on("window-destroyed", this._onWindowDestroyed);
|
||||
}
|
||||
|
||||
Observable.prototype = {
|
||||
/**
|
||||
* Is the observer currently observing
|
||||
*/
|
||||
isObserving: false,
|
||||
isObserving = false;
|
||||
|
||||
/**
|
||||
* Stop observing and detroy this observer instance
|
||||
|
@ -120,7 +121,7 @@ Observable.prototype = {
|
|||
|
||||
this.callback = null;
|
||||
this.targetActor = null;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Start observing whatever it is this observer is supposed to observe
|
||||
|
@ -132,7 +133,7 @@ Observable.prototype = {
|
|||
this.isObserving = true;
|
||||
|
||||
this._startListeners(this.targetActor.windows);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop observing
|
||||
|
@ -147,35 +148,35 @@ Observable.prototype = {
|
|||
// It's only worth stopping if the targetActor is still active
|
||||
this._stopListeners(this.targetActor.windows);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onWindowReady({ window }) {
|
||||
if (this.isObserving) {
|
||||
this._startListeners([window]);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onWindowDestroyed({ window }) {
|
||||
if (this.isObserving) {
|
||||
this._stopListeners([window]);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_startListeners(windows) {
|
||||
// To be implemented by sub-classes.
|
||||
},
|
||||
}
|
||||
|
||||
_stopListeners(windows) {
|
||||
// To be implemented by sub-classes.
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* To be called by sub-classes when something has been observed
|
||||
*/
|
||||
notifyCallback(...args) {
|
||||
this.isObserving && this.callback && this.callback.apply(null, args);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The LayouChangesObserver will observe reflows as soon as it is started.
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
Actor,
|
||||
ActorClassWithSpec,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
screenshotContentSpec,
|
||||
} = require("resource://devtools/shared/specs/screenshot-content.js");
|
||||
|
@ -21,18 +18,18 @@ loader.lazyRequireGetter(
|
|||
true
|
||||
);
|
||||
|
||||
exports.ScreenshotContentActor = ActorClassWithSpec(screenshotContentSpec, {
|
||||
initialize(conn, targetActor) {
|
||||
Actor.prototype.initialize.call(this, conn);
|
||||
exports.ScreenshotContentActor = class ScreenshotContentActor extends Actor {
|
||||
constructor(conn, targetActor) {
|
||||
super(conn, screenshotContentSpec);
|
||||
this.targetActor = targetActor;
|
||||
},
|
||||
}
|
||||
|
||||
_getRectForNode(node) {
|
||||
const originWindow = this.targetActor.ignoreSubFrames
|
||||
? node.ownerGlobal
|
||||
: node.ownerGlobal.top;
|
||||
return getRect(originWindow, node, node.ownerGlobal);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve some window-related information that will be passed to the parent process
|
||||
|
@ -143,5 +140,5 @@ exports.ScreenshotContentActor = ActorClassWithSpec(screenshotContentSpec, {
|
|||
rect: { left, top, width, height },
|
||||
messages,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,17 +4,22 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
captureScreenshot,
|
||||
} = require("resource://devtools/server/actors/utils/capture-screenshot.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
screenshotSpec,
|
||||
} = require("resource://devtools/shared/specs/screenshot.js");
|
||||
|
||||
exports.ScreenshotActor = protocol.ActorClassWithSpec(screenshotSpec, {
|
||||
const {
|
||||
captureScreenshot,
|
||||
} = require("resource://devtools/server/actors/utils/capture-screenshot.js");
|
||||
|
||||
exports.ScreenshotActor = class ScreenshotActor extends Actor {
|
||||
constructor(conn) {
|
||||
super(conn, screenshotSpec);
|
||||
}
|
||||
|
||||
async capture(args) {
|
||||
const browsingContext = BrowsingContext.get(args.browsingContextID);
|
||||
return captureScreenshot(args, browsingContext);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const { sourceSpec } = require("resource://devtools/shared/specs/source.js");
|
||||
|
||||
const {
|
||||
setBreakpointAtEntryPoints,
|
||||
} = require("resource://devtools/server/actors/breakpoint.js");
|
||||
const {
|
||||
ActorClassWithSpec,
|
||||
Actor,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { sourceSpec } = require("resource://devtools/shared/specs/source.js");
|
||||
const {
|
||||
getSourcemapBaseURL,
|
||||
} = require("resource://devtools/server/actors/utils/source-map-utils.js");
|
||||
|
@ -111,16 +109,16 @@ function getSourceURL(source, targetActor) {
|
|||
* @param ThreadActor thread
|
||||
* The current thread actor.
|
||||
*/
|
||||
const SourceActor = ActorClassWithSpec(sourceSpec, {
|
||||
initialize({ source, thread }) {
|
||||
Actor.prototype.initialize.call(this, thread.conn);
|
||||
class SourceActor extends Actor {
|
||||
constructor({ source, thread }) {
|
||||
super(thread.conn, sourceSpec);
|
||||
|
||||
this._threadActor = thread;
|
||||
this._url = undefined;
|
||||
this._source = source;
|
||||
this.__isInlineSource = undefined;
|
||||
this._startLineColumnDisplacement = null;
|
||||
},
|
||||
}
|
||||
|
||||
get _isInlineSource() {
|
||||
const source = this._source;
|
||||
|
@ -135,26 +133,26 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
!this.url.startsWith("about:srcdoc");
|
||||
}
|
||||
return this.__isInlineSource;
|
||||
},
|
||||
}
|
||||
|
||||
get threadActor() {
|
||||
return this._threadActor;
|
||||
},
|
||||
}
|
||||
get sourcesManager() {
|
||||
return this._threadActor.sourcesManager;
|
||||
},
|
||||
}
|
||||
get dbg() {
|
||||
return this.threadActor.dbg;
|
||||
},
|
||||
}
|
||||
get breakpointActorMap() {
|
||||
return this.threadActor.breakpointActorMap;
|
||||
},
|
||||
}
|
||||
get url() {
|
||||
if (this._url === undefined) {
|
||||
this._url = getSourceURL(this._source, this.threadActor._parent);
|
||||
}
|
||||
return this._url;
|
||||
},
|
||||
}
|
||||
|
||||
get extensionName() {
|
||||
if (this._extensionName === undefined) {
|
||||
|
@ -176,11 +174,11 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
|
||||
return this._extensionName;
|
||||
},
|
||||
}
|
||||
|
||||
get internalSourceId() {
|
||||
return this._source.id;
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
const source = this._source;
|
||||
|
@ -209,19 +207,19 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
introductionType,
|
||||
isInlineSource: this._isInlineSource,
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
const parent = this.getParent();
|
||||
if (parent && parent.sourceActors) {
|
||||
delete parent.sourceActors[this.actorID];
|
||||
}
|
||||
Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
get _isWasm() {
|
||||
return this._source.introductionType === "wasm";
|
||||
},
|
||||
}
|
||||
|
||||
async _getSourceText() {
|
||||
if (this._isWasm) {
|
||||
|
@ -264,7 +262,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
/* partial */ false,
|
||||
/* canUseCache */ this._isInlineSource
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
// Get the actual text of this source, padded so that line numbers will match
|
||||
// up with the source itself.
|
||||
|
@ -279,7 +277,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
? "\n".repeat(this._source.startLine - 1)
|
||||
: "";
|
||||
return padding + this._source.text;
|
||||
},
|
||||
}
|
||||
|
||||
// Return whether the specified fetched contents includes the actual text of
|
||||
// this source in the expected position.
|
||||
|
@ -295,7 +293,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
async getBreakableLines() {
|
||||
const positions = await this.getBreakpointPositions();
|
||||
|
@ -307,7 +305,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
|
||||
return Array.from(lines);
|
||||
},
|
||||
}
|
||||
|
||||
// For inline <script> tags in HTML pages, the column numbers of the start
|
||||
// line are relative to the column immediately after the opening <script> tag,
|
||||
|
@ -338,13 +336,13 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
);
|
||||
}
|
||||
return this._setStartLineColumnDisplacement(fileContents);
|
||||
},
|
||||
}
|
||||
|
||||
_setStartLineColumnDisplacement(fileContents) {
|
||||
const d = this._calculateStartLineColumnDisplacement(fileContents);
|
||||
this._startLineColumnDisplacement = d;
|
||||
return d;
|
||||
},
|
||||
}
|
||||
|
||||
_calculateStartLineColumnDisplacement(fileContents) {
|
||||
const startLine = this._source.startLine;
|
||||
|
@ -374,7 +372,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
return { startLine, column };
|
||||
}
|
||||
return {};
|
||||
},
|
||||
}
|
||||
|
||||
// If a { line, column } location is on the starting line of an inline source,
|
||||
// adjust it upwards or downwards (per |upward|) according to the starting
|
||||
|
@ -395,7 +393,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
location,
|
||||
upward
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
_adjustInlineScriptLocationFromDisplacement(info, location, upward) {
|
||||
const { line, column } = location;
|
||||
|
@ -407,7 +405,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
return { line, column: column + displacement };
|
||||
}
|
||||
return location;
|
||||
},
|
||||
}
|
||||
|
||||
// Get all toplevel scripts in the source. Transitive child scripts must be
|
||||
// found by traversing the child script tree.
|
||||
|
@ -435,11 +433,11 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
|
||||
this._scripts = scripts;
|
||||
return scripts;
|
||||
},
|
||||
}
|
||||
|
||||
resetDebuggeeScripts() {
|
||||
this._scripts = null;
|
||||
},
|
||||
}
|
||||
|
||||
// Get toplevel scripts which contain all breakpoint positions for the source.
|
||||
// This is different from _scripts if we detected that some scripts have been
|
||||
|
@ -480,7 +478,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
|
||||
this._breakpointPositionScripts = scripts;
|
||||
return scripts;
|
||||
},
|
||||
}
|
||||
|
||||
// Get all scripts in this source that might include content in the range
|
||||
// specified by the given query.
|
||||
|
@ -540,7 +538,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
async getBreakpointPositions(query) {
|
||||
const scripts = this._findDebuggeeScripts(
|
||||
|
@ -561,7 +559,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
return lineDiff === 0 ? a.column - b.column : lineDiff;
|
||||
})
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
async _addScriptBreakpointPositions(query, script, positions) {
|
||||
const {
|
||||
|
@ -592,7 +590,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
|
||||
positions.push(position);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
async getBreakpointPositionsCompressed(query) {
|
||||
const items = await this.getBreakpointPositions(query);
|
||||
|
@ -604,7 +602,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
compressed[line].push(column);
|
||||
}
|
||||
return compressed;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the "onSource" packet.
|
||||
|
@ -640,7 +638,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
DevToolsUtils.safeErrorString(error)
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the "blackbox" packet.
|
||||
|
@ -655,14 +653,14 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the "unblackbox" packet.
|
||||
*/
|
||||
unblackbox(range) {
|
||||
this.sourcesManager.unblackBox(this.url, range);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the "setPausePoints" packet.
|
||||
|
@ -693,7 +691,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
|
||||
this.pausePoints = uncompressed;
|
||||
},
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure the given BreakpointActor is set as a breakpoint handler on all
|
||||
|
@ -783,7 +781,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
|
||||
setBreakpointAtEntryPoints(actor, entryPoints);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.SourceActor = SourceActor;
|
||||
|
|
|
@ -4,26 +4,26 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var {
|
||||
DevToolsServer,
|
||||
} = require("resource://devtools/server/devtools-server.js");
|
||||
|
||||
var protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
longStringSpec,
|
||||
} = require("resource://devtools/shared/specs/string.js");
|
||||
|
||||
exports.LongStringActor = protocol.ActorClassWithSpec(longStringSpec, {
|
||||
initialize(conn, str) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
const {
|
||||
DevToolsServer,
|
||||
} = require("resource://devtools/server/devtools-server.js");
|
||||
|
||||
exports.LongStringActor = class LongStringActor extends Actor {
|
||||
constructor(conn, str) {
|
||||
super(conn, longStringSpec);
|
||||
this.str = str;
|
||||
this.short = this.str.length < DevToolsServer.LONG_STRING_LENGTH;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.str = null;
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
form() {
|
||||
if (this.short) {
|
||||
|
@ -35,11 +35,11 @@ exports.LongStringActor = protocol.ActorClassWithSpec(longStringSpec, {
|
|||
length: this.str.length,
|
||||
initial: this.str.substring(0, DevToolsServer.LONG_STRING_INITIAL_LENGTH),
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
substring(start, end) {
|
||||
return this.str.substring(start, end);
|
||||
},
|
||||
}
|
||||
|
||||
release() {},
|
||||
});
|
||||
release() {}
|
||||
};
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
styleRuleSpec,
|
||||
} = require("resource://devtools/shared/specs/style-rule.js");
|
||||
|
||||
const { getCSSLexer } = require("resource://devtools/shared/css/lexer.js");
|
||||
const InspectorUtils = require("InspectorUtils");
|
||||
const TrackChangeEmitter = require("resource://devtools/server/actors/utils/track-change-emitter.js");
|
||||
|
@ -13,9 +17,6 @@ const {
|
|||
getTextAtLineColumn,
|
||||
} = require("resource://devtools/server/actors/utils/style-utils.js");
|
||||
|
||||
const {
|
||||
styleRuleSpec,
|
||||
} = require("resource://devtools/shared/specs/style-rule.js");
|
||||
const {
|
||||
style: { ELEMENT_STYLE },
|
||||
} = require("resource://devtools/shared/constants.js");
|
||||
|
@ -80,9 +81,9 @@ const SUPPORTED_RULE_TYPES = [
|
|||
* (which have a CSSStyle but no CSSRule) we create a StyleRuleActor
|
||||
* with a special rule type (100).
|
||||
*/
|
||||
const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
||||
initialize(pageStyle, item) {
|
||||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
class StyleRuleActor extends Actor {
|
||||
constructor(pageStyle, item) {
|
||||
super(null, styleRuleSpec);
|
||||
this.pageStyle = pageStyle;
|
||||
this.rawStyle = item.style;
|
||||
this._parentSheet = null;
|
||||
|
@ -116,29 +117,29 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
get conn() {
|
||||
return this.pageStyle.conn;
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (!this.rawStyle) {
|
||||
return;
|
||||
}
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
super.destroy();
|
||||
this.rawStyle = null;
|
||||
this.pageStyle = null;
|
||||
this.rawNode = null;
|
||||
this.rawRule = null;
|
||||
this._declarations = null;
|
||||
},
|
||||
}
|
||||
|
||||
// Objects returned by this actor are owned by the PageStyleActor
|
||||
// to which this rule belongs.
|
||||
get marshallPool() {
|
||||
return this.pageStyle;
|
||||
},
|
||||
}
|
||||
|
||||
// True if this rule supports as-authored styles, meaning that the
|
||||
// rule text can be rewritten using setRuleText.
|
||||
|
@ -155,7 +156,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
// https://bugzilla.mozilla.org/show_bug.cgi?id=935803#c37
|
||||
this._parentSheet.href !== "about:PreferenceStyleSheet")
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with StyleRuleActor instances for each of this rule's ancestor rules
|
||||
|
@ -174,7 +175,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
}
|
||||
|
||||
return ancestors;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an object with information about this rule used for tracking changes.
|
||||
|
@ -264,7 +265,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
}
|
||||
|
||||
getDocument(sheet) {
|
||||
if (!sheet.associatedDocument) {
|
||||
|
@ -273,11 +274,11 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
);
|
||||
}
|
||||
return sheet.associatedDocument;
|
||||
},
|
||||
}
|
||||
|
||||
toString() {
|
||||
return "[StyleRuleActor for " + this.rawRule + "]";
|
||||
},
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
form() {
|
||||
|
@ -461,7 +462,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
}
|
||||
|
||||
return form;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an event notifying that the location of the rule has
|
||||
|
@ -472,7 +473,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
*/
|
||||
_notifyLocationChanged(line, column) {
|
||||
this.emit("location-changed", line, column);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the index of this actor's raw rule in its parent style
|
||||
|
@ -510,7 +511,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
}
|
||||
|
||||
this._ruleIndex = result;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rule corresponding to |this._ruleIndex| from the given
|
||||
|
@ -531,7 +532,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
}
|
||||
}
|
||||
return currentRule;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from PageStyle actor _onStylesheetUpdated.
|
||||
|
@ -563,7 +564,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
this.line = line;
|
||||
this.column = column;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a promise that resolves to the authored form of a rule's
|
||||
|
@ -596,7 +597,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
// Cache the result on the rule actor to avoid parsing again next time
|
||||
this.authoredText = text;
|
||||
return this.authoredText;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a promise that resolves to the complete cssText of the rule as authored.
|
||||
|
@ -657,7 +658,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
|
||||
const { result } = prettifyCSS(text);
|
||||
return Promise.resolve(result);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the contents of the rule. This rewrites the rule in the
|
||||
|
@ -720,7 +721,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
// Returning this updated actor over the protocol will update its corresponding front
|
||||
// and any references to it.
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a rule's properties. Passed an array of modifications:
|
||||
|
@ -780,7 +781,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
this._pendingDeclarationChanges.push(...modifications);
|
||||
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for modifySelector, inserts the new
|
||||
|
@ -857,7 +858,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
}
|
||||
|
||||
return this._getRuleFromIndex(parentStyleSheet);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Take an object with instructions to modify a CSS declaration and log an object with
|
||||
|
@ -947,7 +948,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
}
|
||||
|
||||
TrackChangeEmitter.trackChange(data);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for tracking CSS changes. Logs the change of this rule's selector as
|
||||
|
@ -974,7 +975,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
remove: null,
|
||||
selector: newSelector,
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the current rule's selector by inserting a new rule with the new
|
||||
|
@ -1043,7 +1044,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
|
||||
return { ruleProps, isMatching };
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the eligible query container for a given @container rule and a given node
|
||||
|
@ -1084,7 +1085,7 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
inlineSize: computedStyle.inlineSize,
|
||||
blockSize: computedStyle.blockSize,
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Using the latest computed style applicable to the selected element,
|
||||
|
@ -1120,8 +1121,8 @@ const StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
|
|||
// The update of the front happens automatically.
|
||||
this.emit("rule-updated", this);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.StyleRuleActor = StyleRuleActor;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
LongStringActor,
|
||||
} = require("resource://devtools/server/actors/string.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
styleSheetsSpec,
|
||||
} = require("resource://devtools/shared/specs/style-sheets.js");
|
||||
|
||||
const {
|
||||
LongStringActor,
|
||||
} = require("resource://devtools/server/actors/string.js");
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"UPDATE_GENERAL",
|
||||
|
@ -23,32 +24,32 @@ loader.lazyRequireGetter(
|
|||
* Creates a StyleSheetsActor. StyleSheetsActor provides remote access to the
|
||||
* stylesheets of a document.
|
||||
*/
|
||||
var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
||||
class StyleSheetsActor extends Actor {
|
||||
constructor(conn, targetActor) {
|
||||
super(conn, styleSheetsSpec);
|
||||
|
||||
this.parentActor = targetActor;
|
||||
}
|
||||
|
||||
/**
|
||||
* The window we work with, taken from the parent actor.
|
||||
*/
|
||||
get window() {
|
||||
return this.parentActor.window;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* The current content document of the window we work with.
|
||||
*/
|
||||
get document() {
|
||||
return this.window.document;
|
||||
},
|
||||
|
||||
initialize(conn, targetActor) {
|
||||
protocol.Actor.prototype.initialize.call(this, targetActor.conn);
|
||||
|
||||
this.parentActor = targetActor;
|
||||
},
|
||||
}
|
||||
|
||||
getTraits() {
|
||||
return {
|
||||
traits: {},
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
for (const win of this.parentActor.windows) {
|
||||
|
@ -57,8 +58,8 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
|||
win.document.styleSheetChangeEventsEnabled = false;
|
||||
}
|
||||
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new style sheet in the document with the given text.
|
||||
|
@ -74,22 +75,22 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
|||
async addStyleSheet(text, fileName = null) {
|
||||
const styleSheetsManager = this._getStyleSheetsManager();
|
||||
await styleSheetsManager.addStyleSheet(this.document, text, fileName);
|
||||
},
|
||||
}
|
||||
|
||||
_getStyleSheetsManager() {
|
||||
return this.parentActor.getStyleSheetsManager();
|
||||
},
|
||||
}
|
||||
|
||||
toggleDisabled(resourceId) {
|
||||
const styleSheetsManager = this._getStyleSheetsManager();
|
||||
return styleSheetsManager.toggleDisabled(resourceId);
|
||||
},
|
||||
}
|
||||
|
||||
async getText(resourceId) {
|
||||
const styleSheetsManager = this._getStyleSheetsManager();
|
||||
const text = await styleSheetsManager.getText(resourceId);
|
||||
return new LongStringActor(this.conn, text || "");
|
||||
},
|
||||
}
|
||||
|
||||
update(resourceId, text, transition, cause = "") {
|
||||
const styleSheetsManager = this._getStyleSheetsManager();
|
||||
|
@ -98,7 +99,7 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
|||
kind: UPDATE_GENERAL,
|
||||
cause,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.StyleSheetsActor = StyleSheetsActor;
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
ActorClassWithSpec,
|
||||
Actor,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
targetConfigurationSpec,
|
||||
} = require("resource://devtools/shared/specs/target-configuration.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
|
@ -68,10 +66,10 @@ const SUPPORTED_OPTIONS = {
|
|||
* @constructor
|
||||
*
|
||||
*/
|
||||
const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
||||
initialize(watcherActor) {
|
||||
class TargetConfigurationActor extends Actor {
|
||||
constructor(watcherActor) {
|
||||
super(watcherActor.conn, targetConfigurationSpec);
|
||||
this.watcherActor = watcherActor;
|
||||
Actor.prototype.initialize.call(this, this.watcherActor.conn);
|
||||
|
||||
this._onBrowsingContextAttached = this._onBrowsingContextAttached.bind(
|
||||
this
|
||||
|
@ -95,7 +93,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
);
|
||||
|
||||
this._browsingContext = this.watcherActor.browserElement?.browsingContext;
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
return {
|
||||
|
@ -103,7 +101,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
configuration: this._getConfiguration(),
|
||||
traits: { supportedOptions: SUPPORTED_OPTIONS },
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this actor should handle the flag that should be set on the
|
||||
|
@ -117,7 +115,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
// For now, the Browser Toolbox and Web Extension are having a unique target
|
||||
// which applies the configuration by itself on new documents.
|
||||
return this.watcherActor.sessionContext.type == "browser-element";
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handler for attached browsing context. This will be called when
|
||||
|
@ -175,13 +173,13 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
this._browsingContext.inRDMPane = true;
|
||||
}
|
||||
this._updateParentProcessConfiguration(this._getConfiguration());
|
||||
},
|
||||
}
|
||||
|
||||
_onBfCacheNavigation({ windowGlobal } = {}) {
|
||||
if (windowGlobal) {
|
||||
this._onBrowsingContextAttached(windowGlobal.browsingContext);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_getConfiguration() {
|
||||
const targetConfigurationData = this.watcherActor.getSessionDataForType(
|
||||
|
@ -196,7 +194,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
cfgMap[key] = value;
|
||||
}
|
||||
return cfgMap;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -217,7 +215,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
this._updateParentProcessConfiguration(configuration);
|
||||
await this.watcherActor.addDataEntry(TARGET_CONFIGURATION, cfgArray);
|
||||
return this._getConfiguration();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -274,7 +272,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (shouldReload) {
|
||||
this._browsingContext.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_restoreParentProcessConfiguration() {
|
||||
if (!this._shouldHandleConfigurationInParentProcess()) {
|
||||
|
@ -312,7 +310,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (this._initialTouchEventsOverride !== undefined) {
|
||||
this._setTouchEventsOverride(this._initialTouchEventsOverride);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable or enable the service workers testing features.
|
||||
|
@ -321,7 +319,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (this._browsingContext.serviceWorkersTestingEnabled != enabled) {
|
||||
this._browsingContext.serviceWorkersTestingEnabled = enabled;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable or enable the print simulation.
|
||||
|
@ -331,7 +329,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (this._browsingContext.mediumOverride != value) {
|
||||
this._browsingContext.mediumOverride = value;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable or enable the color-scheme simulation.
|
||||
|
@ -342,7 +340,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
this._browsingContext.prefersColorSchemeOverride = value;
|
||||
this._resetColorSchemeSimulationOnDestroy = true;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom user agent on the page
|
||||
|
@ -361,11 +359,11 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
}
|
||||
|
||||
this._browsingContext.customUserAgent = userAgent;
|
||||
},
|
||||
}
|
||||
|
||||
isJavascriptEnabled() {
|
||||
return this._browsingContext.allowJavascript;
|
||||
},
|
||||
}
|
||||
|
||||
_setJavascriptEnabled(allow) {
|
||||
if (this._initialJavascriptEnabled === undefined) {
|
||||
|
@ -374,7 +372,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (allow !== undefined) {
|
||||
this._browsingContext.allowJavascript = allow;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/* DPPX override */
|
||||
_setDPPXOverride(dppx) {
|
||||
|
@ -391,7 +389,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (dppx !== undefined) {
|
||||
this._browsingContext.overrideDPPX = dppx;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the touchEventsOverride on the browsing context.
|
||||
|
@ -415,7 +413,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (flag !== undefined) {
|
||||
this._browsingContext.touchEventsOverride = flag;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides navigator.maxTouchPoints.
|
||||
|
@ -426,7 +424,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
*/
|
||||
_setRDMPaneMaxTouchPoints(maxTouchPoints) {
|
||||
this._browsingContext.setRDMPaneMaxTouchPoints(maxTouchPoints);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an orientation and an angle on the browsing context. This will be applied only
|
||||
|
@ -438,7 +436,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
*/
|
||||
_setRDMPaneOrientation({ type, angle }) {
|
||||
this._browsingContext.setRDMPaneOrientation(type, angle);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable or enable the cache via the browsing context.
|
||||
|
@ -452,7 +450,7 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
if (this._browsingContext.defaultLoadFlags != value) {
|
||||
this._browsingContext.defaultLoadFlags = value;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
Services.obs.removeObserver(
|
||||
|
@ -464,8 +462,8 @@ const TargetConfigurationActor = ActorClassWithSpec(targetConfigurationSpec, {
|
|||
this._onBfCacheNavigation
|
||||
);
|
||||
this._restoreParentProcessConfiguration();
|
||||
Actor.prototype.destroy.call(this);
|
||||
},
|
||||
});
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
exports.TargetConfigurationActor = TargetConfigurationActor;
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
ActorClassWithSpec,
|
||||
Actor,
|
||||
} = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const {
|
||||
threadConfigurationSpec,
|
||||
} = require("resource://devtools/shared/specs/thread-configuration.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
|
@ -53,11 +51,11 @@ const SUPPORTED_OPTIONS = {
|
|||
* @constructor
|
||||
*
|
||||
*/
|
||||
const ThreadConfigurationActor = ActorClassWithSpec(threadConfigurationSpec, {
|
||||
initialize(watcherActor) {
|
||||
class ThreadConfigurationActor extends Actor {
|
||||
constructor(watcherActor) {
|
||||
super(watcherActor.conn, threadConfigurationSpec);
|
||||
this.watcherActor = watcherActor;
|
||||
Actor.prototype.initialize.call(this, this.watcherActor.conn);
|
||||
},
|
||||
}
|
||||
|
||||
async updateConfiguration(configuration) {
|
||||
const configArray = Object.keys(configuration)
|
||||
|
@ -71,7 +69,7 @@ const ThreadConfigurationActor = ActorClassWithSpec(threadConfigurationSpec, {
|
|||
.map(key => ({ key, value: configuration[key] }));
|
||||
|
||||
await this.watcherActor.addDataEntry(THREAD_CONFIGURATION, configArray);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.ThreadConfigurationActor = ThreadConfigurationActor;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
const protocol = require("resource://devtools/shared/protocol.js");
|
||||
const { Actor } = require("resource://devtools/shared/protocol.js");
|
||||
const { watcherSpec } = require("resource://devtools/shared/specs/watcher.js");
|
||||
|
||||
const Resources = require("resource://devtools/server/actors/resources/index.js");
|
||||
|
@ -71,7 +71,7 @@ loader.lazyRequireGetter(
|
|||
true
|
||||
);
|
||||
|
||||
exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
||||
exports.WatcherActor = class WatcherActor extends Actor {
|
||||
/**
|
||||
* Initialize a new WatcherActor which is the main entry point to debug
|
||||
* something. The main features of this actor are to:
|
||||
|
@ -95,8 +95,8 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
* @param {Boolean} sessionContext.isServerTargetSwitchingEnabled: Flag to to know if we should
|
||||
* spawn new top level targets for the debugged context.
|
||||
*/
|
||||
initialize(conn, sessionContext) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
constructor(conn, sessionContext) {
|
||||
super(conn, watcherSpec);
|
||||
this._sessionContext = sessionContext;
|
||||
if (sessionContext.type == "browser-element") {
|
||||
// Retrieve the <browser> element for the given browser ID
|
||||
|
@ -129,11 +129,11 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
// but there are certain cases when a new target is available before the
|
||||
// old target is destroyed.
|
||||
this._currentWindowGlobalTargets = new Map();
|
||||
},
|
||||
}
|
||||
|
||||
get sessionContext() {
|
||||
return this._sessionContext;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* If we are debugging only one Tab or Document, returns its BrowserElement.
|
||||
|
@ -145,11 +145,11 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
*/
|
||||
get browserElement() {
|
||||
return this._browserElement;
|
||||
},
|
||||
}
|
||||
|
||||
getAllBrowsingContexts(options) {
|
||||
return getAllBrowsingContextsForContext(this.sessionContext, options);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to know if the context we are debugging has been already destroyed
|
||||
|
@ -165,7 +165,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
throw new Error(
|
||||
"Unsupported session context type: " + this.sessionContext.type
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
// Force unwatching for all types, even if we weren't watching.
|
||||
|
@ -178,8 +178,8 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
WatcherRegistry.unregisterWatcher(this);
|
||||
|
||||
// Destroy the actor at the end so that its actorID keeps being defined.
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the list of the currently watched resources for this watcher.
|
||||
|
@ -189,7 +189,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
*/
|
||||
get sessionData() {
|
||||
return WatcherRegistry.getSessionData(this);
|
||||
},
|
||||
}
|
||||
|
||||
form() {
|
||||
return {
|
||||
|
@ -201,7 +201,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
resources: this.sessionContext.supportedResources,
|
||||
},
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Start watching for a new target type.
|
||||
|
@ -222,7 +222,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
const targetHelperModule = TARGET_HELPERS[targetType];
|
||||
// Await the registration in order to ensure receiving the already existing targets
|
||||
await targetHelperModule.createTargets(this);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop watching for a given target type.
|
||||
|
@ -252,7 +252,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
if (!options.isModeSwitching) {
|
||||
WatcherRegistry.maybeUnregisteringJSWindowActor();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any early iframe targets relating to this top level
|
||||
|
@ -264,7 +264,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
const actor = this._earlyIframeTargets[topInnerWindowID].shift();
|
||||
this.emit("target-available-form", actor);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a Watcher module, whenever a new target is available
|
||||
|
@ -301,7 +301,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
// Set the first early iframe target
|
||||
this._earlyIframeTargets[actor.topInnerWindowId] = [actor];
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a Watcher module, whenever a target has been destroyed
|
||||
|
@ -364,7 +364,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
await documentEventWatcher.onceWillNavigateIsEmitted(actor.innerWindowId);
|
||||
}
|
||||
this.emit("target-destroyed-form", actor, options);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a browsingContextID, returns its parent browsingContextID. Returns null if a
|
||||
|
@ -392,7 +392,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
return browsingContext.embedderWindowGlobal.browsingContext.id;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by Resource Watchers, when new resources are available, updated or destroyed.
|
||||
|
@ -414,7 +414,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
}
|
||||
|
||||
this.emit(`resource-${updateType}-form`, resources);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* For WebExtension, we have to hack all resource's browsingContextID
|
||||
|
@ -429,7 +429,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
resources.forEach(resource => {
|
||||
resource.browsingContextID = this.sessionContext.addonBrowsingContextID;
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to retrieve a parent process TargetActor:
|
||||
|
@ -446,7 +446,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
this.sessionContext,
|
||||
this.conn.prefix
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Start watching for a list of resource types.
|
||||
|
@ -529,7 +529,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
targetActorResourceTypes
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop watching for a list of resource types.
|
||||
|
@ -600,7 +600,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
|
||||
// Unregister the JS Window Actor if there is no more DevTools code observing any target/resource
|
||||
WatcherRegistry.maybeUnregisteringJSWindowActor();
|
||||
},
|
||||
}
|
||||
|
||||
clearResources(resourceTypes) {
|
||||
// First process resources which have to be listened from the parent process
|
||||
|
@ -610,7 +610,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
this,
|
||||
Resources.getParentProcessResourceTypes(resourceTypes)
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the network actor.
|
||||
|
@ -624,7 +624,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
}
|
||||
|
||||
return this._networkParentActor;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blackboxing actor.
|
||||
|
@ -638,7 +638,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
}
|
||||
|
||||
return this._blackboxingActor;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the breakpoint list actor.
|
||||
|
@ -652,7 +652,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
}
|
||||
|
||||
return this._breakpointListActor;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target configuration actor.
|
||||
|
@ -665,7 +665,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
this._targetConfigurationListActor = new TargetConfigurationActor(this);
|
||||
}
|
||||
return this._targetConfigurationListActor;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the thread configuration actor.
|
||||
|
@ -678,7 +678,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
this._threadConfigurationListActor = new ThreadConfigurationActor(this);
|
||||
}
|
||||
return this._threadConfigurationListActor;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Server internal API, called by other actors, but not by the client.
|
||||
|
@ -720,7 +720,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
if (targetActor) {
|
||||
await targetActor.addSessionDataEntry(type, entries);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Server internal API, called by other actors, but not by the client.
|
||||
|
@ -756,7 +756,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
if (targetActor) {
|
||||
targetActor.removeSessionDataEntry(type, entries);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current watched data for the provided type.
|
||||
|
@ -766,5 +766,5 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
*/
|
||||
getSessionDataForType(type) {
|
||||
return this.sessionData?.[type];
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче