tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

helper-real-usb.js (1624B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /* import-globals-from helper-adb.js */
      7 Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-adb.js", this);
      8 
      9 async function getExpectedRuntime() {
     10  const runtimes = await getExpectedRuntimeAll();
     11  return runtimes[0];
     12 }
     13 /* exported getExpectedRuntime */
     14 
     15 async function getExpectedRuntimeAll() {
     16  const runtimesPath = _getExpectedRuntimesPath();
     17  const currentPath = Services.env.get("PWD");
     18  const path = `${currentPath}/${runtimesPath}`;
     19  info(`Load ${path}`);
     20  const buffer = await IOUtils.read(path);
     21  const data = new TextDecoder().decode(buffer);
     22  return JSON.parse(data);
     23 }
     24 /* exported getExpectedRuntimeAll */
     25 
     26 function isAvailable() {
     27  return !!_getExpectedRuntimesPath();
     28 }
     29 /* exported isAvailable */
     30 
     31 async function openAboutDebuggingWithADB() {
     32  const { document, tab, window } = await openAboutDebugging();
     33 
     34  await pushPref(
     35    "devtools.remote.adb.extensionURL",
     36    CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi"
     37  );
     38  await checkAdbNotRunning();
     39 
     40  const {
     41    adbAddon,
     42  } = require("resource://devtools/client/shared/remote-debugging/adb/adb-addon.js");
     43  adbAddon.install("internal");
     44  const usbStatusElement = document.querySelector(".qa-sidebar-usb-status");
     45  await waitUntil(() => usbStatusElement.textContent.includes("USB enabled"));
     46  await waitForAdbStart();
     47 
     48  return { document, tab, window };
     49 }
     50 /* exported openAboutDebuggingWithADB */
     51 
     52 function _getExpectedRuntimesPath() {
     53  return Services.env.get("USB_RUNTIMES");
     54 }