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

"use strict";

/**
 * Check that the runtime info is correctly displayed for ThisFirefox.
 * Also acts as basic sanity check for the default mock of the this-firefox client.
 */

add_task(async function () {
  // Setup a mock for our runtime client factory to return the default THIS_FIREFOX client
  // when the client for the this-firefox runtime is requested.
  const runtimeClientFactoryMock = createRuntimeClientFactoryMock();
  const thisFirefoxClient = createThisFirefoxClientMock();
  runtimeClientFactoryMock.createClientForRuntime = runtime => {
    const {
      RUNTIMES,
    } = require("resource://devtools/client/aboutdebugging/src/constants.js");
    if (runtime.id === RUNTIMES.THIS_FIREFOX) {
      return thisFirefoxClient;
    }
    throw new Error("Unexpected runtime id " + runtime.id);
  };

  info("Enable mocks");
  enableRuntimeClientFactoryMock(runtimeClientFactoryMock);
  registerCleanupFunction(() => {
    disableRuntimeClientFactoryMock();
  });

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

  info("Check that the 'This Firefox' 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("Firefox"),
    "this-firefox runtime info shows the correct runtime name: " +
      runtimeInfoText
  );
  ok(
    runtimeInfoText.includes("63.0"),
    "this-firefox runtime info shows the correct version number: " +
      runtimeInfoText
  );

  await removeTab(tab);
});