tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_aboutdebugging_thisfirefox_runtime_info.js (1836B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Check that the runtime info is correctly displayed for ThisFirefox.
      8 * Also acts as basic sanity check for the default mock of the this-firefox client.
      9 */
     10 
     11 add_task(async function () {
     12  // Setup a mock for our runtime client factory to return the default THIS_FIREFOX client
     13  // when the client for the this-firefox runtime is requested.
     14  const runtimeClientFactoryMock = createRuntimeClientFactoryMock();
     15  const thisFirefoxClient = createThisFirefoxClientMock();
     16  runtimeClientFactoryMock.createClientForRuntime = runtime => {
     17    const {
     18      RUNTIMES,
     19    } = require("resource://devtools/client/aboutdebugging/src/constants.js");
     20    if (runtime.id === RUNTIMES.THIS_FIREFOX) {
     21      return thisFirefoxClient;
     22    }
     23    throw new Error("Unexpected runtime id " + runtime.id);
     24  };
     25 
     26  info("Enable mocks");
     27  enableRuntimeClientFactoryMock(runtimeClientFactoryMock);
     28  registerCleanupFunction(() => {
     29    disableRuntimeClientFactoryMock();
     30  });
     31 
     32  const { document, tab, window } = await openAboutDebugging();
     33  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     34 
     35  info("Check that the 'This Firefox' mock is properly displayed");
     36  const thisFirefoxRuntimeInfo = document.querySelector(".qa-runtime-name");
     37  ok(
     38    thisFirefoxRuntimeInfo,
     39    "Runtime info for this-firefox runtime is displayed"
     40  );
     41  const runtimeInfoText = thisFirefoxRuntimeInfo.textContent;
     42  ok(
     43    runtimeInfoText.includes("Firefox"),
     44    "this-firefox runtime info shows the correct runtime name: " +
     45      runtimeInfoText
     46  );
     47  ok(
     48    runtimeInfoText.includes("63.0"),
     49    "this-firefox runtime info shows the correct version number: " +
     50      runtimeInfoText
     51  );
     52 
     53  await removeTab(tab);
     54 });