tor-browser

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

browser_aboutdebugging_fenix_runtime_node_picker.js (2842B)


      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 = "1337id";
      7 const DEVICE_NAME = "Fancy Phone";
      8 const SERVER_RUNTIME_NAME = "Mozilla Firefox";
      9 const ADB_RUNTIME_NAME = "Firefox Preview";
     10 const SERVER_VERSION = "v7.3.31";
     11 const ADB_VERSION = "v1.3.37";
     12 
     13 /**
     14 * Check that the node picker button in about:devtools-toolbox has the expected class when
     15 * connecting to an Android phone.
     16 */
     17 add_task(async function () {
     18  // We use a real local client combined with a mocked USB runtime to be able to open
     19  // about:devtools-toolbox on a real target.
     20  const clientWrapper = await createLocalClientWrapper();
     21 
     22  const mocks = new Mocks();
     23  mocks.createUSBRuntime(RUNTIME_ID, {
     24    channel: "nightly",
     25    clientWrapper,
     26    deviceName: DEVICE_NAME,
     27    isFenix: true,
     28    name: SERVER_RUNTIME_NAME,
     29    shortName: ADB_RUNTIME_NAME,
     30    versionName: ADB_VERSION,
     31    version: SERVER_VERSION,
     32  });
     33 
     34  // open a remote runtime page
     35  const { document, tab, window } = await openAboutDebugging();
     36  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     37 
     38  mocks.emitUSBUpdate();
     39  info("Select the runtime page for the USB runtime");
     40  const onRequestSuccess = waitForRequestsSuccess(window.AboutDebugging.store);
     41  await connectToRuntime(DEVICE_NAME, document);
     42  await waitForRuntimePage(ADB_RUNTIME_NAME, document);
     43  info(
     44    "Wait for requests to finish the USB runtime is backed by a real local client"
     45  );
     46  await onRequestSuccess;
     47 
     48  info("Wait for the about:debugging target to be available");
     49  await waitUntil(() => findDebugTargetByText("about:debugging", document));
     50  const { devtoolsDocument, devtoolsTab } = await openAboutDevtoolsToolbox(
     51    document,
     52    tab,
     53    window
     54  );
     55 
     56  const pickerButton = devtoolsDocument.querySelector("#command-button-pick");
     57  ok(
     58    pickerButton.classList.contains("remote-fenix"),
     59    "The node picker does have the expected additional className when debugging an android phone"
     60  );
     61  const pickerButtonTitle = pickerButton.getAttribute("title");
     62  const expectedKeyboardShortcut =
     63    Services.appinfo.OS === "Darwin"
     64      ? `Cmd+Shift+C or Cmd+Opt+C`
     65      : `Ctrl+Shift+C`;
     66  is(
     67    pickerButtonTitle,
     68    `Pick an element from the Android phone (${expectedKeyboardShortcut})`,
     69    `The node picker does have the expected tooltip when debugging an android phone`
     70  );
     71 
     72  info("Wait for all pending requests to settle on the DevToolsClient");
     73  await clientWrapper.client.waitForRequestsToSettle();
     74  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
     75 
     76  info("Remove USB runtime");
     77  mocks.removeUSBRuntime(RUNTIME_ID);
     78  mocks.emitUSBUpdate();
     79  await waitUntilUsbDeviceIsUnplugged(DEVICE_NAME, document);
     80 
     81  await removeTab(tab);
     82  await clientWrapper.close();
     83 });