From 8bcefffe1ad0e7b54418e9adeeb2129a2d80cc12 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 5 May 2021 15:56:46 +0000 Subject: [PATCH] Bug 1707877 - [devtools] Make getTestActorWithoutToolbox use CommandsFactory and commands. r=nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D113507 --- devtools/client/shared/test/shared-head.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/devtools/client/shared/test/shared-head.js b/devtools/client/shared/test/shared-head.js index cc0b2abf5343..f95511d1cee7 100644 --- a/devtools/client/shared/test/shared-head.js +++ b/devtools/client/shared/test/shared-head.js @@ -203,18 +203,12 @@ async function getTestActor(toolbox) { // Sometimes, we need the test actor before opening or without a toolbox then just // create a front for the given `tab` async function getTestActorWithoutToolbox(tab) { - const { DevToolsServer } = require("devtools/server/devtools-server"); - const { DevToolsClient } = require("devtools/client/devtools-client"); + const commands = await CommandsFactory.forTab(tab); + // Initialize the TargetCommands which require some async stuff to be done + // before being fully ready. This will define the `targetCommand.targetFront` attribute. + await commands.targetCommand.startListening(); - // We need to spawn a client instance, - // but for that we have to first ensure a server is running - DevToolsServer.init(); - DevToolsServer.registerAllActors(); - const client = new DevToolsClient(DevToolsServer.connectPipe()); - await client.connect(); - - const descriptor = await client.mainRoot.getTab({ tab }); - const targetFront = await descriptor.getTarget(); + const targetFront = commands.targetCommand.targetFront; return targetFront.getFront("test"); }