summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_real_usb_runtime_page_runtime_info.js
blob: 16462fd2b3349406331d6e6f486b68f19be89cec (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/* import-globals-from helper-real-usb.js */
Services.scriptloader.loadSubScript(
  CHROME_URL_ROOT + "helper-real-usb.js",
  this
);

// Test that runtime info of USB runtime appears on main pane.
// Documentation for real usb tests in /documentation/TESTS_REAL_DEVICES.md
add_task(async function () {
  if (!isAvailable()) {
    ok(true, "Real usb runtime test is not available");
    return;
  }

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

  const expectedRuntime = await getExpectedRuntime();
  const { runtimeDetails, sidebarInfo } = expectedRuntime;

  info("Connect a USB runtime");
  await Promise.race([
    connectToRuntime(sidebarInfo.deviceName, document),
    /* eslint-disable mozilla/no-arbitrary-setTimeout */
    new Promise(resolve =>
      setTimeout(() => {
        ok(
          false,
          "Failed to connect, did you disable the connection prompt for this runtime?"
        );
        resolve();
      }, 5000)
    ),
    /* eslint-enable mozilla/no-arbitrary-setTimeout */
  ]);

  info("Select a USB runtime");
  await selectRuntime(
    sidebarInfo.deviceName,
    runtimeDetails.info.name,
    document
  );

  info("Check that runtime info is properly displayed");
  const runtimeInfo = document.querySelector(".qa-runtime-name");
  ok(runtimeInfo, "Runtime info is displayed");
  const runtimeInfoText = runtimeInfo.textContent;
  ok(
    runtimeInfoText.includes(runtimeDetails.info.name),
    "Runtime info shows the correct runtime name: " + runtimeInfoText
  );
  ok(
    runtimeInfoText.includes(runtimeDetails.info.version),
    "Runtime info shows the correct version number: " + runtimeInfoText
  );

  await removeTab(tab);
});