Bug 1813477 - [devtools] Convert all tests still using ActorClassWithSpec. r=devtools-reviewers,perftest-reviewers,jdescottes,sparky

Differential Revision: https://phabricator.services.mozilla.com/D169358
This commit is contained in:
Alexandre Poirot 2023-02-14 10:34:19 +00:00
Родитель 47b8b20969
Коммит 09e00fefc6
16 изменённых файлов: 248 добавлений и 257 удалений

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

@ -199,16 +199,16 @@ var highlighterTestSpec = protocol.generateActorSpec({
},
});
var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
initialize(conn, targetActor, options) {
protocol.Actor.prototype.initialize.call(this, conn);
this.conn = conn;
class HighlighterTestActor extends protocol.Actor {
constructor(conn, targetActor, options) {
super(conn, highlighterTestSpec);
this.targetActor = targetActor;
},
}
get content() {
return this.targetActor.window;
},
}
/**
* Helper to retrieve a DOM element.
@ -255,7 +255,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
);
}
return node;
},
}
/**
* Get a value for a given attribute name, on one of the elements of the box
@ -273,7 +273,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
}
return helper.getAttributeForElement(nodeID, name);
},
}
/**
* Get the computed style for a given property, on one of the elements of the
@ -291,7 +291,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
}
return helper.getElement(nodeID).computedStyle.getPropertyValue(property);
},
}
/**
* Get the textcontent of one of the elements of the box model highlighter,
@ -307,7 +307,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
value = helper.getTextContentForElement(nodeID);
}
return value;
},
}
/**
* Get the number of box-model highlighters created by the SelectorHighlighter
@ -322,7 +322,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
return null;
}
return h._highlighters.length;
},
}
/**
* Subscribe to the box-model highlighter's update event, modify an attribute of
@ -341,7 +341,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
h.currentNode.setAttribute(name, value);
});
},
}
/**
* Register a one-time "updated" event listener.
@ -356,18 +356,18 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
_highlighter.once("updated").then(() => this.emit("highlighter-updated"));
// Return directly so the client knows the event listener is set
},
}
async getNodeRect(selector) {
const node = this._querySelector(selector);
return getRect(this.content, node, this.content);
},
}
async getTextNodeRect(parentSelector, childNodeIndex) {
const parentNode = this._querySelector(parentSelector);
const node = parentNode.childNodes[childNodeIndex];
return getAdjustedQuads(this.content, node)[0].bounds;
},
}
/**
* @returns {PausedDebuggerOverlay} The paused overlay instance
@ -376,7 +376,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
// We use `_pauseOverlay` since it's the cached value; `pauseOverlay` is a getter that
// will create the overlay when called (if it does not exist yet).
return this.targetActor?.threadActor?._pauseOverlay;
},
}
isPausedDebuggerOverlayVisible() {
const pauseOverlay = this._getPausedDebuggerOverlay();
@ -393,7 +393,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
toolbar.getAttribute("hidden") !== "true" &&
!!toolbar.getTextContent()
);
},
}
/**
* Simulates a click on a button of the debugger pause overlay.
@ -412,7 +412,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
// We're directly calling `handleEvent` on the pause overlay, which is the mouse events
// listener callback on the overlay.
pauseOverlay.handleEvent({ type: "mousedown", target: { id } });
},
}
/**
* @returns {EyeDropper}
@ -421,7 +421,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
const form = this.targetActor.form();
const inspectorActor = this.conn._getOrCreateActor(form.inspectorActor);
return inspectorActor?._eyeDropper;
},
}
isEyeDropperVisible() {
const eyeDropper = this._getEyeDropper();
@ -430,7 +430,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
}
return eyeDropper.getElement("root").getAttribute("hidden") !== "true";
},
}
getEyeDropperElementAttribute(elementId, attributeName) {
const eyeDropper = this._getEyeDropper();
@ -439,7 +439,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
}
return eyeDropper.getElement(elementId).getAttribute(attributeName);
},
}
async getEyeDropperColorValue() {
const eyeDropper = this._getEyeDropper();
@ -456,7 +456,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
}, "Couldn't get a non-empty text content for the color-value element");
return color;
},
}
/**
* Get the TabbingOrderHighlighter for the associated targetActor
@ -475,7 +475,7 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
// We use `_tabbingOrderHighlighter` since it's the cached value; `tabbingOrderHighlighter`
// is a getter that will create the highlighter when called (if it does not exist yet).
return accessibilityActor.walker?._tabbingOrderHighlighter;
},
}
/**
* Get a representation of the NodeTabbingOrderHighlighters created by the
@ -510,8 +510,8 @@ var HighlighterTestActor = protocol.ActorClassWithSpec(highlighterTestSpec, {
}
return `${nodeStr} : ${h.getElement("root").getTextContent()}`;
});
},
});
}
}
exports.HighlighterTestActor = HighlighterTestActor;
class HighlighterTestFront extends protocol.FrontClassWithSpec(

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

@ -32,36 +32,35 @@ const testErrorsSpec = protocol.generateActorSpec({
},
});
const TestErrorsActor = protocol.ActorClassWithSpec(testErrorsSpec, {
initialize(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
this.conn = conn;
},
class TestErrorsActor extends protocol.Actor {
constructor(conn) {
super(conn, testErrorsSpec);
}
throwsComponentsException() {
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
}
throwsException() {
return this.a.b.c;
},
}
throwsJSError() {
throw new Error("JSError");
},
}
throwsString() {
// eslint-disable-next-line no-throw-literal
throw "ErrorString";
},
}
throwsObject() {
// eslint-disable-next-line no-throw-literal
throw {
error: "foo",
};
},
});
}
}
exports.TestErrorsActor = TestErrorsActor;
class TestErrorsFront extends protocol.FrontClassWithSpec(testErrorsSpec) {

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

@ -16,13 +16,13 @@ const helloSpec = protocol.generateActorSpec({
},
});
var HelloActor = protocol.ActorClassWithSpec(helloSpec, {
initialize() {
protocol.Actor.prototype.initialize.apply(this, arguments);
class HelloActor extends protocol.Actor {
constructor(conn) {
super(conn, helloSpec);
this.counter = 0;
},
}
count() {
return ++this.counter;
},
});
}
}

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

@ -14,6 +14,10 @@ const helloSpec = protocol.generateActorSpec({
},
});
var HelloActor = protocol.ActorClassWithSpec(helloSpec, {
hello() {},
});
class HelloActor extends protocol.Actor {
constructor(conn) {
super(conn, helloSpec);
}
hello() {}
}

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

@ -6,7 +6,6 @@
var {
RetVal,
Actor,
ActorClassWithSpec,
FrontClassWithSpec,
generateActorSpec,
} = require("resource://devtools/shared/protocol.js");
@ -21,17 +20,18 @@ const lazySpec = generateActorSpec({
},
});
exports.LazyActor = ActorClassWithSpec(lazySpec, {
initialize(conn, id) {
Actor.prototype.initialize.call(this, conn);
class LazyActor extends Actor {
constructor(conn, id) {
super(conn, lazySpec);
Services.obs.notifyObservers(null, "actor", "instantiated");
},
}
hello(str) {
return "world";
},
});
}
}
exports.LazyActor = LazyActor;
Services.obs.notifyObservers(null, "actor", "loaded");

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

@ -116,21 +116,20 @@ exports.createRootActor = function createRootActor(connection) {
return root;
};
const TestDescriptorActor = protocol.ActorClassWithSpec(tabDescriptorSpec, {
initialize(conn, targetActor) {
protocol.Actor.prototype.initialize.call(this, conn);
this.conn = conn;
class TestDescriptorActor extends protocol.Actor {
constructor(conn, targetActor) {
super(conn, tabDescriptorSpec);
this._targetActor = targetActor;
},
}
// We don't exercise the selected tab in xpcshell tests.
get selected() {
return false;
},
}
get title() {
return this._targetActor.title;
},
}
form() {
const form = {
@ -142,21 +141,20 @@ const TestDescriptorActor = protocol.ActorClassWithSpec(tabDescriptorSpec, {
};
return form;
},
}
getFavicon() {
return "";
},
}
getTarget() {
return this._targetActor.form();
},
});
}
}
const TestTargetActor = protocol.ActorClassWithSpec(windowGlobalTargetSpec, {
initialize(conn, global) {
protocol.Actor.prototype.initialize.call(this, conn);
this.conn = conn;
class TestTargetActor extends protocol.Actor {
constructor(conn, global) {
super(conn, windowGlobalTargetSpec);
this.sessionContext = createContentProcessSessionContext();
this._global = global;
@ -172,29 +170,29 @@ const TestTargetActor = protocol.ActorClassWithSpec(windowGlobalTargetSpec, {
});
this.dbg = this.makeDebugger();
this.notifyResources = this.notifyResources.bind(this);
},
}
targetType: Targets.TYPES.FRAME,
targetType = Targets.TYPES.FRAME;
get window() {
return this._global;
},
}
// Both title and url point to this._global.__name
get title() {
return this._global.__name;
},
}
get url() {
return this._global.__name;
},
}
get sourcesManager() {
if (!this._sourcesManager) {
this._sourcesManager = new SourcesManager(this.threadActor);
}
return this._sourcesManager;
},
}
form() {
const response = {
@ -216,19 +214,19 @@ const TestTargetActor = protocol.ActorClassWithSpec(windowGlobalTargetSpec, {
}
return { ...response, ...actors };
},
}
detach(request) {
this.threadActor.destroy();
return { type: "detached" };
},
}
reload(request) {
this.sourcesManager.reset();
this.threadActor.clearDebuggees();
this.threadActor.dbg.addDebuggees();
return {};
},
}
removeActorByName(name) {
const actor = this._extraActors[name];
@ -236,9 +234,9 @@ const TestTargetActor = protocol.ActorClassWithSpec(windowGlobalTargetSpec, {
this._descriptorActorPool.removeActor(actor);
}
delete this._extraActors[name];
},
}
notifyResources(updateType, resources) {
this.emit(`resource-${updateType}-form`, resources);
},
});
}
}

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

@ -11,14 +11,6 @@
var protocol = require("resource://devtools/shared/protocol.js");
var { RetVal } = protocol;
function simpleHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
const rootSpec = protocol.generateActorSpec({
typeName: "root",
@ -29,22 +21,28 @@ const rootSpec = protocol.generateActorSpec({
},
});
var RootActor = protocol.ActorClassWithSpec(rootSpec, {
typeName: "root",
initialize(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
class RootActor extends protocol.Actor {
constructor(conn) {
super(conn, rootSpec);
// Root actor owns itself.
this.manage(this);
this.actorID = "root";
this.sequence = 0;
},
}
sayHello: simpleHello,
sayHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
simpleReturn() {
return this.sequence++;
},
});
}
}
class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
constructor(client) {
@ -57,7 +55,7 @@ class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
protocol.registerFront(RootFront);
add_task(async function() {
DevToolsServer.createRootActor = RootActor;
DevToolsServer.createRootActor = conn => new RootActor(conn);
DevToolsServer.init();
const trace = connectPipeTracing();

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

@ -13,14 +13,6 @@ const { waitForTick } = require("resource://devtools/shared/DevToolsUtils.js");
const protocol = require("resource://devtools/shared/protocol.js");
const { Arg, RetVal } = protocol;
function simpleHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
const rootSpec = protocol.generateActorSpec({
typeName: "root",
@ -42,20 +34,27 @@ const rootSpec = protocol.generateActorSpec({
},
});
const RootActor = protocol.ActorClassWithSpec(rootSpec, {
initialize(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
class RootActor extends protocol.Actor {
constructor(conn) {
super(conn, rootSpec);
// Root actor owns itself.
this.manage(this);
this.actorID = "root";
this.sequence = 0;
},
}
sayHello: simpleHello,
sayHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
simpleReturn() {
return this.sequence++;
},
}
// Guarantee that this resolves after simpleReturn returns.
async promiseReturn(toWait) {
@ -68,17 +67,17 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
}
return sequence;
},
}
simpleThrow() {
throw new Error(this.sequence++);
},
}
// Guarantee that this resolves after simpleReturn returns.
promiseThrow(toWait) {
return this.promiseReturn(toWait).then(Promise.reject);
},
});
}
}
class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
constructor(client) {
@ -91,7 +90,7 @@ class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
protocol.registerFront(RootFront);
add_task(async function() {
DevToolsServer.createRootActor = RootActor;
DevToolsServer.createRootActor = conn => new RootActor(conn);
DevToolsServer.init();
const trace = connectPipeTracing();

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

@ -10,14 +10,6 @@
const protocol = require("resource://devtools/shared/protocol.js");
const { types, Arg, RetVal } = protocol;
function simpleHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
// Predeclaring the actor type so that it can be used in the
// implementation of the child actor.
types.addActorType("childActor");
@ -93,48 +85,48 @@ const childSpec = protocol.generateActorSpec({
},
});
var ChildActor = protocol.ActorClassWithSpec(childSpec, {
class ChildActor extends protocol.Actor {
constructor(conn, id) {
super(conn, childSpec);
this.childID = id;
}
// Actors returned by this actor should be owned by the root actor.
marshallPool() {
return this.getParent();
},
}
toString() {
return "[ChildActor " + this.childID + "]";
},
initialize(conn, id) {
protocol.Actor.prototype.initialize.call(this, conn);
this.childID = id;
},
}
destroy() {
protocol.Actor.prototype.destroy.call(this);
super.destroy();
this.destroyed = true;
},
}
form() {
return {
actor: this.actorID,
childID: this.childID,
};
},
}
echo(str) {
return str;
},
}
getDetail1() {
return this;
},
}
getDetail2() {
return this;
},
}
getIDDetail() {
return this;
},
}
getIntArray(inputArray) {
// Test that protocol.js converts an iterator to an array.
@ -144,11 +136,11 @@ var ChildActor = protocol.ActorClassWithSpec(childSpec, {
}
};
return f();
},
}
getSibling(id) {
return this.getParent().getChild(id);
},
}
emitEvents() {
this.emit("event1", 1, 2, 3);
@ -157,10 +149,10 @@ var ChildActor = protocol.ActorClassWithSpec(childSpec, {
this.emit("object-event", this);
this.emit("array-object-event", [this]);
return "correct response";
},
}
release() {},
});
release() {}
}
class ChildFront extends protocol.FrontClassWithSpec(childSpec) {
constructor(client, targetFront, parentFront) {
@ -217,11 +209,17 @@ const otherChildSpec = protocol.generateActorSpec({
},
events: {},
});
const OtherChildActor = protocol.ActorClassWithSpec(otherChildSpec, {
class OtherChildActor extends protocol.Actor {
constructor(conn) {
super(conn, otherChildSpec);
}
getOtherChild() {
return new OtherChildActor(this.conn);
},
});
}
}
class OtherChildFront extends protocol.FrontClassWithSpec(otherChildSpec) {}
protocol.registerFront(OtherChildFront);
@ -268,19 +266,26 @@ const rootSpec = protocol.generateActorSpec({
});
let rootActor = null;
const RootActor = protocol.ActorClassWithSpec(rootSpec, {
toString() {
return "[root actor]";
},
class RootActor extends protocol.Actor {
constructor(conn) {
super(conn, rootSpec);
initialize(conn) {
rootActor = this;
this.actorID = "root";
this._children = {};
protocol.Actor.prototype.initialize.call(this, conn);
},
}
sayHello: simpleHello,
toString() {
return "[root actor]";
}
sayHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
getChild(id) {
if (id in this._children) {
@ -289,17 +294,17 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
const child = new ChildActor(this.conn, id);
this._children[id] = child;
return child;
},
}
// Other child actor won't all be own by the root actor
// and can have their own children
getOtherChild() {
return new OtherChildActor(this.conn);
},
}
getChildren(ids) {
return ids.map(id => this.getChild(id));
},
}
getChildren2(ids) {
const f = function*() {
@ -308,7 +313,7 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
}
};
return f();
},
}
getManyChildren() {
return {
@ -317,7 +322,7 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
child5: this.getChild("child5"),
more: [this.getChild("child6"), this.getChild("child7")],
};
},
}
getPolymorphism(id) {
if (id == 0) {
@ -326,7 +331,7 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
return new OtherChildActor(this.conn);
}
throw new Error("Unexpected id");
},
}
requestPolymorphism(id, actor) {
if (id == 0 && actor instanceof ChildActor) {
@ -335,8 +340,8 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
return actor;
}
throw new Error("Unexpected id or actor");
},
});
}
}
class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
constructor(client, targetFront, parentFront) {
@ -368,7 +373,7 @@ function childrenOfType(pool, type) {
add_task(async function() {
DevToolsServer.createRootActor = conn => {
return RootActor(conn);
return new RootActor(conn);
};
DevToolsServer.init();

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

@ -17,14 +17,6 @@ var {
// The test implicitly relies on this.
require("resource://devtools/client/fronts/string.js");
function simpleHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
DevToolsServer.LONG_STRING_LENGTH = DevToolsServer.LONG_STRING_INITIAL_LENGTH = DevToolsServer.LONG_STRING_READ_LENGTH = 5;
var SHORT_STR = "abc";
@ -57,24 +49,31 @@ const rootSpec = protocol.generateActorSpec({
},
});
var RootActor = protocol.ActorClassWithSpec(rootSpec, {
initialize(conn) {
class RootActor extends protocol.Actor {
constructor(conn) {
super(conn, rootSpec);
rootActor = this;
protocol.Actor.prototype.initialize.call(this, conn);
// Root actor owns itself.
this.manage(this);
this.actorID = "root";
},
}
sayHello: simpleHello,
sayHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
shortString() {
return new LongStringActor(this.conn, SHORT_STR);
},
}
longString() {
return new LongStringActor(this.conn, LONG_STR);
},
}
emitShortString() {
EventEmitter.emit(
@ -82,7 +81,7 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, {
"string-event",
new LongStringActor(this.conn, SHORT_STR)
);
},
}
emitLongString() {
EventEmitter.emit(
@ -90,8 +89,8 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, {
"string-event",
new LongStringActor(this.conn, LONG_STR)
);
},
});
}
}
class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
constructor(client) {
@ -106,7 +105,7 @@ protocol.registerFront(RootFront);
function run_test() {
DevToolsServer.createRootActor = conn => {
return RootActor(conn);
return new RootActor(conn);
};
DevToolsServer.init();

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

@ -11,14 +11,6 @@ var protocol = require("resource://devtools/shared/protocol.js");
var { Arg, Option, RetVal } = protocol;
var EventEmitter = require("resource://devtools/shared/event-emitter.js");
function simpleHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
const rootSpec = protocol.generateActorSpec({
typeName: "root",
@ -91,43 +83,50 @@ const rootSpec = protocol.generateActorSpec({
},
});
var RootActor = protocol.ActorClassWithSpec(rootSpec, {
initialize(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
class RootActor extends protocol.Actor {
constructor(conn) {
super(conn, rootSpec);
// Root actor owns itself.
this.manage(this);
this.actorID = "root";
},
}
sayHello: simpleHello,
sayHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
simpleReturn() {
return 1;
},
}
promiseReturn() {
return Promise.resolve(1);
},
}
simpleArgs(a, b) {
return { firstResponse: a + 1, secondResponse: b + 1 };
},
}
optionArgs(options) {
return { option1: options.option1, option2: options.option2 };
},
}
optionalArgs(a, b = 200) {
return b;
},
}
arrayArgs(a) {
return a;
},
}
nestedArrayArgs(a) {
return a;
},
}
/**
* Test that the 'type' part of the request packet works
@ -138,17 +137,17 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, {
return "goodbye";
}
return a;
},
}
testOneWay(a) {
// Emit to show that we got this message, because there won't be a response.
EventEmitter.emit(this, "oneway", a);
},
}
emitFalsyOptions() {
EventEmitter.emit(this, "falsyOptions", { zero: 0, farce: false });
},
});
}
}
class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
constructor(client) {
@ -162,15 +161,10 @@ protocol.registerFront(RootFront);
add_task(async function() {
DevToolsServer.createRootActor = conn => {
return RootActor(conn);
return new RootActor(conn);
};
DevToolsServer.init();
Assert.throws(() => {
const badActor = protocol.ActorClassWithSpec({}, {});
void badActor;
}, /Actor specification must have a typeName member/);
protocol.types.getType("array:array:array:number");
protocol.types.getType("array:array:array:number");

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

@ -13,14 +13,6 @@
var protocol = require("resource://devtools/shared/protocol.js");
var { RetVal } = protocol;
function simpleHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
const rootSpec = protocol.generateActorSpec({
typeName: "root",
@ -31,21 +23,28 @@ const rootSpec = protocol.generateActorSpec({
},
});
var RootActor = protocol.ActorClassWithSpec(rootSpec, {
initialize(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
class RootActor extends protocol.Actor {
constructor(conn) {
super(conn, rootSpec);
// Root actor owns itself.
this.manage(this);
this.actorID = "root";
this.sequence = 0;
},
}
sayHello: simpleHello,
sayHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
simpleReturn() {
return this.sequence++;
},
});
}
}
class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
constructor(client) {
@ -58,7 +57,7 @@ class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
protocol.registerFront(RootFront);
function run_test() {
DevToolsServer.createRootActor = RootActor;
DevToolsServer.createRootActor = conn => new RootActor(conn);
DevToolsServer.init();
const trace = connectPipeTracing();

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

@ -20,13 +20,13 @@ const childSpec = protocol.generateActorSpec({
},
});
const ChildActor = protocol.ActorClassWithSpec(childSpec, {
initialize(conn, id) {
protocol.Actor.prototype.initialize.call(this, conn);
class ChildActor extends protocol.Actor {
constructor(conn, id) {
super(conn, childSpec);
this.childID = id;
},
}
release() {},
release() {}
form() {
return {
@ -34,8 +34,8 @@ const ChildActor = protocol.ActorClassWithSpec(childSpec, {
childID: this.childID,
foo: "bar",
};
},
});
}
}
const rootSpec = protocol.generateActorSpec({
typeName: "root",
@ -48,11 +48,9 @@ const rootSpec = protocol.generateActorSpec({
},
});
const RootActor = protocol.ActorClassWithSpec(rootSpec, {
typeName: "root",
initialize(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
class RootActor extends protocol.Actor {
constructor(conn) {
super(conn, rootSpec);
this.actorID = "root";
@ -60,7 +58,7 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
this.manage(this);
this.sequence = 0;
},
}
sayHello() {
return {
@ -68,12 +66,12 @@ const RootActor = protocol.ActorClassWithSpec(rootSpec, {
applicationType: "xpcshell-tests",
traits: [],
};
},
}
createChild() {
return new ChildActor(this.conn, this.sequence++);
},
});
}
}
class ChildFront extends protocol.FrontClassWithSpec(childSpec) {
form(form) {
@ -94,7 +92,7 @@ class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
protocol.registerFront(RootFront);
add_task(async function run_test() {
DevToolsServer.createRootActor = RootActor;
DevToolsServer.createRootActor = conn => new RootActor(conn);
DevToolsServer.init();
const trace = connectPipeTracing();

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

@ -29,9 +29,8 @@ function run_test() {
const { Actor } = require("resource://devtools/shared/protocol/Actor.js");
class TestBulkActor extends Actor {
constructor(conn) {
super(conn);
super(conn, { typeName: "testBulk", methods: [] });
this.typeName = "testBulk";
this.requestTypes = {
bulkEcho: this.bulkEcho,
bulkReply: this.bulkReply,

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

@ -21,9 +21,8 @@ function run_test() {
const { Actor } = require("resource://devtools/shared/protocol/Actor.js");
class EchoTestActor extends Actor {
constructor(conn) {
super(conn);
super(conn, { typeName: "EchoTestActor", methods: [] });
this.typeName = "EchoTestActor";
this.requestTypes = {
echo: EchoTestActor.prototype.onEcho,
};

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

@ -4,14 +4,13 @@
"use strict";
const protocol = require("devtools/shared/protocol");
const { Actor } = require("devtools/shared/protocol");
const { dampTestSpec } = require("damp-test/tests/server/spec");
exports.DampTestActor = protocol.ActorClassWithSpec(dampTestSpec, {
initialize(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
},
class DampTestActor extends Actor {
constructor(conn) {
super(conn, dampTestSpec);
}
testMethod(arg, { option }, arraySize) {
// Emit an event with second argument's option.
@ -19,5 +18,6 @@ exports.DampTestActor = protocol.ActorClassWithSpec(dampTestSpec, {
// Returns back an array of repetition of first argument.
return arg;
},
});
}
}
exports.DampTestActor = DampTestActor;