tor-browser

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

browser_aboutdebugging_runtime_disconnect_remote_runtime.js (1943B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const USB_RUNTIME_ID = "1337id";
      7 const USB_DEVICE_NAME = "Fancy Phone";
      8 const USB_APP_NAME = "Lorem ipsum";
      9 
     10 const DEFAULT_PAGE = "#/runtime/this-firefox";
     11 
     12 /**
     13 * Check if the disconnect button disconnects the remote runtime
     14 * and redirects to the default page.
     15 */
     16 add_task(async function () {
     17  // Create a real local client and use it as the remote USB client for this
     18  // test.
     19  const clientWrapper = await createLocalClientWrapper();
     20 
     21  // enable USB devices mocks
     22  const mocks = new Mocks();
     23  mocks.createUSBRuntime(USB_RUNTIME_ID, {
     24    clientWrapper,
     25    deviceName: USB_DEVICE_NAME,
     26    name: USB_APP_NAME,
     27  });
     28 
     29  const { document, tab, window } = await openAboutDebugging();
     30  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     31 
     32  mocks.emitUSBUpdate();
     33 
     34  const onRequestSuccess = waitForRequestsSuccess(window.AboutDebugging.store);
     35  await connectToRuntime(USB_DEVICE_NAME, document);
     36  await waitForRuntimePage(USB_APP_NAME, document);
     37  await onRequestSuccess;
     38 
     39  const disconnectRemoteRuntimeButton = document.querySelector(
     40    ".qa-runtime-info__action"
     41  );
     42 
     43  info("Check whether disconnect remote runtime button exists");
     44  ok(!!disconnectRemoteRuntimeButton, "Runtime contains the disconnect button");
     45 
     46  info("Click on the disconnect button");
     47  disconnectRemoteRuntimeButton.click();
     48 
     49  info("Wait until the runtime is disconnected");
     50  await waitUntil(() => document.querySelector(".qa-connect-button"));
     51 
     52  is(
     53    document.location.hash,
     54    DEFAULT_PAGE,
     55    "Redirection to the default page (this-firefox)"
     56  );
     57 
     58  info("Wait until the Runtime name is displayed");
     59  await waitUntil(() => {
     60    const runtimeInfo = document.querySelector(".qa-runtime-name");
     61    return runtimeInfo && runtimeInfo.textContent.includes("Firefox");
     62  });
     63 
     64  await removeTab(tab);
     65 });