summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_usb_runtime_select.js
blob: 66ca219bf34b58fff0d8045ab5b639a12d6ab931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const RUNTIME_DEVICE_ID = "1234";
const RUNTIME_DEVICE_NAME = "A device";

// Test that we can select a runtime in the sidebar
add_task(async function () {
  const mocks = new Mocks();

  const { document, tab } = await openAboutDebugging();

  mocks.createUSBRuntime(RUNTIME_DEVICE_ID, {
    deviceName: RUNTIME_DEVICE_NAME,
  });
  mocks.emitUSBUpdate();

  info("Wait until the USB sidebar item appears");
  await waitUntil(() => findSidebarItemByText(RUNTIME_DEVICE_NAME, document));
  const sidebarItem = findSidebarItemByText(RUNTIME_DEVICE_NAME, document);
  const connectButton = sidebarItem.querySelector(".qa-connect-button");
  ok(connectButton, "Connect button is displayed for the USB runtime");

  info(
    "Click on the connect button and wait until the sidebar displays a link"
  );
  connectButton.click();
  await waitUntil(() =>
    findSidebarItemLinkByText(RUNTIME_DEVICE_NAME, document)
  );

  info("Click on the runtime link");
  const link = findSidebarItemLinkByText(RUNTIME_DEVICE_NAME, document);
  link.click();
  is(
    document.location.hash,
    `#/runtime/${RUNTIME_DEVICE_ID}`,
    "Redirection to runtime page"
  );

  await removeTab(tab);
});