summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_telemetry_runtime_connected_details.js
blob: 808cfdcae8e1bbdc7865d910e79806532064c95b (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
63
64
65
66
67
68
69
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

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

const REMOTE_RUNTIME_ID = "remote-runtime";
const REMOTE_RUNTIME = "Remote Runtime";
const REMOTE_DEVICE = "Remote Device";

const REMOTE_VERSION = "12.0a1";
const REMOTE_OS = "SOME_OS";

/**
 * Runtime connected events will log additional extras about the runtime connection that
 * was established.
 */
add_task(async function () {
  const mocks = new Mocks();

  const usbClient = mocks.createUSBRuntime(REMOTE_RUNTIME_ID, {
    deviceName: REMOTE_DEVICE,
    name: REMOTE_RUNTIME,
    shortName: REMOTE_RUNTIME,
  });
  usbClient.getDeviceDescription = () => {
    return {
      os: REMOTE_OS,
      version: REMOTE_VERSION,
    };
  };

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

  mocks.emitUSBUpdate();
  await connectToRuntime(REMOTE_DEVICE, document);
  const evts = readAboutDebuggingEvents().filter(
    e => e.method === "runtime_connected"
  );

  is(
    evts.length,
    1,
    "runtime_connected event logged when connecting to remote runtime"
  );
  const {
    connection_type,
    device_name,
    runtime_name,
    runtime_os,
    runtime_version,
  } = evts[0].extras;
  is(connection_type, "usb", "Expected value for `connection_type` extra");
  is(device_name, REMOTE_DEVICE, "Expected value for `device_name` extra");
  is(runtime_name, REMOTE_RUNTIME, "Expected value for `runtime_name` extra");
  is(runtime_os, REMOTE_OS, "Expected value for `runtime_os` extra");
  is(
    runtime_version,
    REMOTE_VERSION,
    "Expected value for `runtime_version` extra"
  );

  await removeTab(tab);
});