tor-browser

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

test_version_checker.js (4722B)


      1 /* global equal */
      2 
      3 "use strict";
      4 
      5 const {
      6  _compareVersionCompatibility,
      7  checkVersionCompatibility,
      8  COMPATIBILITY_STATUS,
      9 } = require("resource://devtools/client/shared/remote-debugging/version-checker.js");
     10 
     11 const TEST_DATA = [
     12  {
     13    description: "same build date and same version number",
     14    localBuildId: "20190131000000",
     15    localVersion: "60.0",
     16    runtimeBuildId: "20190131000000",
     17    runtimeVersion: "60.0",
     18    expected: COMPATIBILITY_STATUS.COMPATIBLE,
     19  },
     20  {
     21    description: "same build date and older version in range (-1)",
     22    localBuildId: "20190131000000",
     23    localVersion: "60.0",
     24    runtimeBuildId: "20190131000000",
     25    runtimeVersion: "59.0",
     26    expected: COMPATIBILITY_STATUS.COMPATIBLE,
     27  },
     28  {
     29    description: "same build date and older version in range (-2)",
     30    localBuildId: "20190131000000",
     31    localVersion: "60.0",
     32    runtimeBuildId: "20190131000000",
     33    runtimeVersion: "58.0",
     34    expected: COMPATIBILITY_STATUS.COMPATIBLE,
     35  },
     36  {
     37    description: "same build date and older version in range (-2 Nightly)",
     38    localBuildId: "20190131000000",
     39    localVersion: "60.0",
     40    runtimeBuildId: "20190131000000",
     41    runtimeVersion: "58.0a1",
     42    expected: COMPATIBILITY_STATUS.COMPATIBLE,
     43  },
     44  {
     45    description: "same build date and older version out of range (-3)",
     46    localBuildId: "20190131000000",
     47    localVersion: "60.0",
     48    runtimeBuildId: "20190131000000",
     49    runtimeVersion: "57.0",
     50    expected: COMPATIBILITY_STATUS.TOO_OLD,
     51  },
     52  {
     53    description: "same build date and newer version out of range (+1)",
     54    localBuildId: "20190131000000",
     55    localVersion: "60.0",
     56    runtimeBuildId: "20190131000000",
     57    runtimeVersion: "61.0",
     58    expected: COMPATIBILITY_STATUS.TOO_RECENT,
     59  },
     60  {
     61    description: "same major version and build date in range (-10 days)",
     62    localBuildId: "20190131000000",
     63    localVersion: "60.0",
     64    runtimeBuildId: "20190121000000",
     65    runtimeVersion: "60.0",
     66    expected: COMPATIBILITY_STATUS.COMPATIBLE,
     67  },
     68  {
     69    description: "same major version and build date in range (+2 days)",
     70    localBuildId: "20190131000000",
     71    localVersion: "60.0",
     72    runtimeBuildId: "20190202000000",
     73    runtimeVersion: "60.0",
     74    expected: COMPATIBILITY_STATUS.COMPATIBLE,
     75  },
     76  {
     77    description: "same major version and build date out of range (+8 days)",
     78    localBuildId: "20190131000000",
     79    localVersion: "60.0",
     80    runtimeBuildId: "20190208000000",
     81    runtimeVersion: "60.0",
     82    expected: COMPATIBILITY_STATUS.TOO_RECENT,
     83  },
     84  {
     85    description:
     86      "fennec 68 compatibility error not raised for 68 -> 68 Android",
     87    localBuildId: "20190131000000",
     88    localVersion: "68.0",
     89    runtimeBuildId: "20190202000000",
     90    runtimeVersion: "68.0",
     91    runtimeOs: "Android",
     92    expected: COMPATIBILITY_STATUS.COMPATIBLE,
     93  },
     94  {
     95    description:
     96      "fennec 68 compatibility error not raised for 70 -> 68 Android",
     97    localBuildId: "20190131000000",
     98    localVersion: "70.0",
     99    runtimeBuildId: "20190202000000",
    100    runtimeVersion: "68.0",
    101    runtimeOs: "Android",
    102    expected: COMPATIBILITY_STATUS.COMPATIBLE,
    103  },
    104  {
    105    description: "fennec 68 compatibility error raised for 71 -> 68 Android",
    106    localBuildId: "20190131000000",
    107    localVersion: "71.0",
    108    runtimeBuildId: "20190202000000",
    109    runtimeVersion: "68.0",
    110    runtimeOs: "Android",
    111    expected: COMPATIBILITY_STATUS.TOO_OLD_FENNEC,
    112  },
    113  {
    114    description:
    115      "fennec 68 compatibility error not raised for 71 -> 68 non-Android",
    116    localBuildId: "20190131000000",
    117    localVersion: "71.0",
    118    runtimeBuildId: "20190202000000",
    119    runtimeVersion: "68.0",
    120    runtimeOs: "NotAndroid",
    121    expected: COMPATIBILITY_STATUS.TOO_OLD,
    122  },
    123 ];
    124 
    125 add_task(async function testVersionChecker() {
    126  for (const testData of TEST_DATA) {
    127    const localDescription = {
    128      appbuildid: testData.localBuildId,
    129      platformversion: testData.localVersion,
    130    };
    131 
    132    const runtimeDescription = {
    133      appbuildid: testData.runtimeBuildId,
    134      platformversion: testData.runtimeVersion,
    135      os: testData.runtimeOs,
    136    };
    137 
    138    const report = _compareVersionCompatibility(
    139      localDescription,
    140      runtimeDescription
    141    );
    142    equal(
    143      report.status,
    144      testData.expected,
    145      "Expected status for test: " + testData.description
    146    );
    147  }
    148 });
    149 
    150 add_task(async function testVersionCheckWithVeryOldClient() {
    151  // Use an empty object as devtools client, calling any method on it will fail.
    152  const emptyClient = {};
    153  const report = await checkVersionCompatibility(emptyClient);
    154  equal(
    155    report.status,
    156    COMPATIBILITY_STATUS.TOO_OLD,
    157    "Report status too old if devtools client is not implementing expected interface"
    158  );
    159 });