From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../aboutdebugging/test/browser/helper-adb.js | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 devtools/client/aboutdebugging/test/browser/helper-adb.js (limited to 'devtools/client/aboutdebugging/test/browser/helper-adb.js') diff --git a/devtools/client/aboutdebugging/test/browser/helper-adb.js b/devtools/client/aboutdebugging/test/browser/helper-adb.js new file mode 100644 index 0000000000..f5e6adfc6b --- /dev/null +++ b/devtools/client/aboutdebugging/test/browser/helper-adb.js @@ -0,0 +1,59 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/* import-globals-from head.js */ + +async function checkAdbNotRunning() { + info("Check if ADB is already running before the test starts"); + const { + check, + } = require("resource://devtools/client/shared/remote-debugging/adb/adb-running-checker.js"); + const isAdbAlreadyRunning = await check(); + if (isAdbAlreadyRunning) { + throw new Error( + "The ADB process is already running on this machine, it should be " + + "stopped before running this test" + ); + } +} +/* exported checkAdbNotRunning */ + +// Returns a promise that resolves when the adb process exists and is running. +async function waitForAdbStart() { + info("Wait for ADB to start"); + const { + adbProcess, + } = require("resource://devtools/client/shared/remote-debugging/adb/adb-process.js"); + const { + check, + } = require("resource://devtools/client/shared/remote-debugging/adb/adb-running-checker.js"); + return asyncWaitUntil(async () => { + const isProcessReady = adbProcess.ready; + const isRunning = await check(); + return isProcessReady && isRunning; + }); +} +/* exported waitForAdbStart */ + +// Attempt to stop ADB. Will only work if ADB was started by the current Firefox instance. +// Returns a promise that resolves when the adb process is no longer running. +async function stopAdbProcess() { + info("Attempt to stop ADB"); + const { + adbProcess, + } = require("resource://devtools/client/shared/remote-debugging/adb/adb-process.js"); + await adbProcess.stop(); + + info("Wait for ADB to stop"); + const { + check, + } = require("resource://devtools/client/shared/remote-debugging/adb/adb-running-checker.js"); + return asyncWaitUntil(async () => { + const isProcessReady = adbProcess.ready; + const isRunning = await check(); + return !isProcessReady && !isRunning; + }); +} +/* exported stopAdbProcess */ -- cgit v1.2.3