var gTestGlobals = new Set();
DevToolsServer.addTestGlobal = function (global) {
gTestGlobals.add(global);
};
DevToolsServer.removeTestGlobal = function (global) {
gTestGlobals.delete(global);
};
DevToolsServer.getTestGlobal = function (name) { for (const g of gTestGlobals) { if (g.__name == name) { return g;
}
}
returnnull;
};
var gAllowNewThreadGlobals = false;
DevToolsServer.allowNewThreadGlobals = function () {
gAllowNewThreadGlobals = true;
};
DevToolsServer.disallowNewThreadGlobals = function () {
gAllowNewThreadGlobals = false;
};
// A mock tab list, for use by tests. This simply presents each global in // gTestGlobals as a tab, and the list is fixed: it never calls its // onListChanged handler. // // As implemented now, we consult gTestGlobals when we're constructed, not // when we're iterated over, so tests have to add their globals before the // root actor is created. function TestTabList(connection) { this.conn = connection;
// An array of actors for each global added with // DevToolsServer.addTestGlobal. this._descriptorActors = [];
// A pool mapping those actors' names to the actors. this._descriptorActorPool = new LazyPool(connection);
for (const global of gTestGlobals) { const actor = new TestTargetActor(connection, global); this._descriptorActorPool.manage(actor);
// Register the target actor, so that the Watcher actor can have access to it.
TargetActorRegistry.registerXpcShellTargetActor(actor);
const descriptorActor = new TestDescriptorActor(connection, actor); this._descriptorActorPool.manage(descriptorActor);
this._descriptorActors.push(descriptorActor);
}
}
TestTabList.prototype = {
constructor: TestTabList,
destroy() {},
getList() { return Promise.resolve([...this._descriptorActors]);
}, // Helper method only available for the xpcshell implementation of tablist.
getTargetActorForTab(title) { const descriptorActor = this._descriptorActors.find(d => d.title === title); if (!descriptorActor) { returnnull;
} return descriptorActor._targetActor;
},
};
exports.createRootActor = function createRootActor(connection) {
ActorRegistry.registerModule("devtools/server/actors/webconsole", {
prefix: "console",
constructor: "WebConsoleActor",
type: { target: true },
}); const root = new RootActor(connection, {
tabList: new TestTabList(connection),
globalActorFactories: ActorRegistry.globalActorFactories,
});
// Walk over target-scoped actors and add them to a new LazyPool. const actorPool = new LazyPool(this.conn); const actors = createExtraActors(
ActorRegistry.targetScopedActorFactories,
actorPool, this
); if (actorPool?._poolMap.size > 0) { this._descriptorActorPool = actorPool; this.conn.addActorPool(this._descriptorActorPool);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.