summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/helper-real-usb.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/aboutdebugging/test/browser/helper-real-usb.js')
-rw-r--r--devtools/client/aboutdebugging/test/browser/helper-real-usb.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/test/browser/helper-real-usb.js b/devtools/client/aboutdebugging/test/browser/helper-real-usb.js
new file mode 100644
index 0000000000..dd6c8c263d
--- /dev/null
+++ b/devtools/client/aboutdebugging/test/browser/helper-real-usb.js
@@ -0,0 +1,54 @@
+/* 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");
+}