tor-browser

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

browser_aboutdebugging_debug-target-pane_usb_runtime.js (2119B)


      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-collapsibilities.js */
      7 Services.scriptloader.loadSubScript(
      8  CHROME_URL_ROOT + "helper-collapsibilities.js",
      9  this
     10 );
     11 
     12 const RUNTIME_ID = "test-runtime-id";
     13 const RUNTIME_DEVICE_NAME = "test device name";
     14 const RUNTIME_APP_NAME = "TestApp";
     15 
     16 // Test that the expected supported categories are displayed for USB runtimes.
     17 add_task(async function () {
     18  const mocks = new Mocks();
     19  await checkTargetPanes({ enableLocalTabs: false }, mocks);
     20 
     21  info(
     22    "Check that enableLocalTabs has no impact on the categories displayed for remote" +
     23      " runtimes."
     24  );
     25  await checkTargetPanes({ enableLocalTabs: true }, mocks);
     26 });
     27 
     28 async function checkTargetPanes({ enableLocalTabs }, mocks) {
     29  const { document, tab, window } = await openAboutDebugging({
     30    enableLocalTabs,
     31  });
     32  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     33 
     34  mocks.createUSBRuntime(RUNTIME_ID, {
     35    deviceName: RUNTIME_DEVICE_NAME,
     36    name: RUNTIME_APP_NAME,
     37  });
     38  mocks.emitUSBUpdate();
     39 
     40  await connectToRuntime(RUNTIME_DEVICE_NAME, document);
     41  await waitForRuntimePage(RUNTIME_APP_NAME, document);
     42 
     43  const SUPPORTED_TARGET_PANES = [
     44    "Temporary Extensions",
     45    "Extensions",
     46    "Other Workers",
     47    "Shared Workers",
     48    "Service Workers",
     49    "Tabs",
     50  ];
     51 
     52  for (const { title } of TARGET_PANES) {
     53    const debugTargetPaneEl = getDebugTargetPane(title, document);
     54    if (SUPPORTED_TARGET_PANES.includes(title)) {
     55      ok(debugTargetPaneEl, `Supported target pane [${title}] is displayed`);
     56    } else {
     57      ok(!debugTargetPaneEl, `Unsupported target pane [${title}] is hidden`);
     58    }
     59  }
     60 
     61  const installButton = document.querySelector(
     62    ".qa-temporary-extension-install-button"
     63  );
     64  ok(!installButton, "Temporary Extensions install button is hidden");
     65 
     66  info("Remove USB runtime");
     67  mocks.removeUSBRuntime(RUNTIME_ID);
     68  mocks.emitUSBUpdate();
     69  await waitUntilUsbDeviceIsUnplugged(RUNTIME_DEVICE_NAME, document);
     70 
     71  await removeTab(tab);
     72 }