summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_select_network_runtime.js
blob: e3f770f948031025b00212f436e49a07e7dfd92a (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const NETWORK_RUNTIME_HOST = "localhost:6080";
const NETWORK_RUNTIME_APP_NAME = "TestNetworkApp";
const NETWORK_RUNTIME_CHANNEL = "SomeChannel";
const NETWORK_RUNTIME_VERSION = "12.3";

// Test that network runtimes can be selected.
add_task(async function () {
  const mocks = new Mocks();

  const { document, tab, window } = await openAboutDebugging();
  await selectThisFirefoxPage(document, window.AboutDebugging.store);

  info("Prepare Network client mock");
  const networkClient = mocks.createNetworkRuntime(NETWORK_RUNTIME_HOST, {
    name: NETWORK_RUNTIME_APP_NAME,
  });
  networkClient.getDeviceDescription = () => {
    return {
      name: NETWORK_RUNTIME_APP_NAME,
      channel: NETWORK_RUNTIME_CHANNEL,
      version: NETWORK_RUNTIME_VERSION,
    };
  };

  info("Test addons in runtime page for Network client");
  await connectToRuntime(NETWORK_RUNTIME_HOST, document);
  await selectRuntime(NETWORK_RUNTIME_HOST, NETWORK_RUNTIME_APP_NAME, document);

  info("Check that the network runtime mock is properly displayed");
  const thisFirefoxRuntimeInfo = document.querySelector(".qa-runtime-name");
  ok(
    thisFirefoxRuntimeInfo,
    "Runtime info for this-firefox runtime is displayed"
  );
  const runtimeInfoText = thisFirefoxRuntimeInfo.textContent;

  ok(
    runtimeInfoText.includes(NETWORK_RUNTIME_APP_NAME),
    "network runtime info shows the correct runtime name: " + runtimeInfoText
  );
  ok(
    runtimeInfoText.includes(NETWORK_RUNTIME_VERSION),
    "network runtime info shows the correct version number: " + runtimeInfoText
  );

  await removeTab(tab);
});