1
0
Fork 0
firefox/devtools/client/aboutdebugging/test/browser/helper-real-usb.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

54 lines
1.6 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from helper-adb.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-adb.js", this);
async function getExpectedRuntime() {
const runtimes = await getExpectedRuntimeAll();
return runtimes[0];
}
/* exported getExpectedRuntime */
async function getExpectedRuntimeAll() {
const runtimesPath = _getExpectedRuntimesPath();
const currentPath = Services.env.get("PWD");
const path = `${currentPath}/${runtimesPath}`;
info(`Load ${path}`);
const buffer = await IOUtils.read(path);
const data = new TextDecoder().decode(buffer);
return JSON.parse(data);
}
/* exported getExpectedRuntimeAll */
function isAvailable() {
return !!_getExpectedRuntimesPath();
}
/* exported isAvailable */
async function openAboutDebuggingWithADB() {
const { document, tab, window } = await openAboutDebugging();
await pushPref(
"devtools.remote.adb.extensionURL",
CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi"
);
await checkAdbNotRunning();
const {
adbAddon,
} = require("resource://devtools/client/shared/remote-debugging/adb/adb-addon.js");
adbAddon.install("internal");
const usbStatusElement = document.querySelector(".qa-sidebar-usb-status");
await waitUntil(() => usbStatusElement.textContent.includes("USB enabled"));
await waitForAdbStart();
return { document, tab, window };
}
/* exported openAboutDebuggingWithADB */
function _getExpectedRuntimesPath() {
return Services.env.get("USB_RUNTIMES");
}