tor-browser

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

browser_aboutdebugging_sidebar_usb_runtime_connect.js (1698B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const RUNTIME_ID = "test-runtime-id";
      7 const RUNTIME_NAME = "test runtime name";
      8 const RUNTIME_DEVICE_NAME = "test device name";
      9 const RUNTIME_SHORT_NAME = "test short name";
     10 
     11 // Test that USB runtimes appear and disappear from the sidebar,
     12 // as well as their connect button.
     13 // Also checks whether the label of item is updated after connecting.
     14 add_task(async function () {
     15  const mocks = new Mocks();
     16 
     17  const { document, tab } = await openAboutDebugging();
     18 
     19  mocks.createUSBRuntime(RUNTIME_ID, {
     20    name: RUNTIME_NAME,
     21    deviceName: RUNTIME_DEVICE_NAME,
     22    shortName: RUNTIME_SHORT_NAME,
     23  });
     24  mocks.emitUSBUpdate();
     25 
     26  info("Wait until the USB sidebar item appears");
     27  await waitUntil(() => findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
     28  const usbRuntimeSidebarItem = findSidebarItemByText(
     29    RUNTIME_DEVICE_NAME,
     30    document
     31  );
     32  const connectButton =
     33    usbRuntimeSidebarItem.querySelector(".qa-connect-button");
     34  ok(connectButton, "Connect button is displayed for the USB runtime");
     35 
     36  info("Click on the connect button and wait until it disappears");
     37  connectButton.click();
     38  await waitUntil(
     39    () => !usbRuntimeSidebarItem.querySelector(".qa-connect-button")
     40  );
     41 
     42  info("Check whether the label of item is updated after connecting");
     43  ok(
     44    usbRuntimeSidebarItem.textContent.includes(RUNTIME_NAME),
     45    "Label of item updated"
     46  );
     47 
     48  info("Remove all USB runtimes");
     49  mocks.removeUSBRuntime(RUNTIME_ID);
     50  mocks.emitUSBUpdate();
     51  await waitUntilUsbDeviceIsUnplugged(RUNTIME_DEVICE_NAME, document);
     52 
     53  await removeTab(tab);
     54 });