tor-browser

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

browser_aboutdebugging_runtime_compatibility_warning.js (2940B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const COMPATIBLE_RUNTIME = "Compatible Runtime";
      7 const COMPATIBLE_DEVICE = "Compatible Device";
      8 const OLD_RUNTIME = "Old Runtime";
      9 const OLD_DEVICE = "Old Device";
     10 const FENNEC_68_RUNTIME = "Bad Runtime Fennec 68";
     11 const FENNEC_68_DEVICE = "Bad Device Fennec 68";
     12 const RECENT_RUNTIME = "Recent Runtime";
     13 const RECENT_DEVICE = "Recent Device";
     14 
     15 add_task(async function () {
     16  const {
     17    COMPATIBILITY_STATUS,
     18  } = require("resource://devtools/client/shared/remote-debugging/version-checker.js");
     19  const { COMPATIBLE, TOO_OLD, TOO_OLD_FENNEC, TOO_RECENT } =
     20    COMPATIBILITY_STATUS;
     21 
     22  info("Create several mocked runtimes, with different compatibility reports");
     23  const mocks = new Mocks();
     24  createRuntimeWithReport(
     25    mocks,
     26    COMPATIBLE_RUNTIME,
     27    COMPATIBLE_DEVICE,
     28    COMPATIBLE
     29  );
     30  createRuntimeWithReport(mocks, OLD_RUNTIME, OLD_DEVICE, TOO_OLD);
     31  createRuntimeWithReport(mocks, RECENT_RUNTIME, RECENT_DEVICE, TOO_RECENT);
     32  createRuntimeWithReport(
     33    mocks,
     34    FENNEC_68_RUNTIME,
     35    FENNEC_68_DEVICE,
     36    TOO_OLD_FENNEC
     37  );
     38 
     39  const { document, tab } = await openAboutDebugging();
     40  mocks.emitUSBUpdate();
     41 
     42  info("Connect to all runtimes");
     43  await connectToRuntime(COMPATIBLE_DEVICE, document);
     44  await connectToRuntime(OLD_DEVICE, document);
     45  await connectToRuntime(RECENT_DEVICE, document);
     46  await connectToRuntime(FENNEC_68_DEVICE, document);
     47 
     48  info("Select the compatible runtime and check that no warning is displayed");
     49  await selectRuntime(COMPATIBLE_DEVICE, COMPATIBLE_RUNTIME, document);
     50  ok(
     51    !document.querySelector(".qa-compatibility-warning"),
     52    "Compatibility warning is not displayed"
     53  );
     54 
     55  info(
     56    "Select the old runtime and check that the too-old warning is displayed"
     57  );
     58  await selectRuntime(OLD_DEVICE, OLD_RUNTIME, document);
     59  ok(
     60    document.querySelector(".qa-compatibility-warning-too-old"),
     61    "Expected compatibility warning is displayed (too-old)"
     62  );
     63 
     64  info(
     65    "Select the recent runtime and check that the too-recent warning is displayed"
     66  );
     67  await selectRuntime(RECENT_DEVICE, RECENT_RUNTIME, document);
     68  ok(
     69    document.querySelector(".qa-compatibility-warning-too-recent"),
     70    "Expected compatibility warning is displayed (too-recent)"
     71  );
     72 
     73  info(
     74    "Select the Fennec 68 runtime and check that the correct warning is displayed"
     75  );
     76  await selectRuntime(FENNEC_68_DEVICE, FENNEC_68_RUNTIME, document);
     77  ok(document.querySelector(".qa-compatibility-warning-too-old-fennec"));
     78 
     79  await removeTab(tab);
     80 });
     81 
     82 function createRuntimeWithReport(mocks, name, deviceName, status) {
     83  const runtimeId = [name, deviceName].join("-");
     84  const compatibleUsbClient = mocks.createUSBRuntime(runtimeId, {
     85    deviceName,
     86    name,
     87  });
     88  const report = { status };
     89  compatibleUsbClient.checkVersionCompatibility = () => report;
     90 }