diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/shared/remote-debugging/test/xpcshell/test_version_checker.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/shared/remote-debugging/test/xpcshell/test_version_checker.js')
-rw-r--r-- | devtools/client/shared/remote-debugging/test/xpcshell/test_version_checker.js | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/devtools/client/shared/remote-debugging/test/xpcshell/test_version_checker.js b/devtools/client/shared/remote-debugging/test/xpcshell/test_version_checker.js new file mode 100644 index 0000000000..92f7d54a1e --- /dev/null +++ b/devtools/client/shared/remote-debugging/test/xpcshell/test_version_checker.js @@ -0,0 +1,159 @@ +/* global equal */ + +"use strict"; + +const { + _compareVersionCompatibility, + checkVersionCompatibility, + COMPATIBILITY_STATUS, +} = require("resource://devtools/client/shared/remote-debugging/version-checker.js"); + +const TEST_DATA = [ + { + description: "same build date and same version number", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190131000000", + runtimeVersion: "60.0", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: "same build date and older version in range (-1)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190131000000", + runtimeVersion: "59.0", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: "same build date and older version in range (-2)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190131000000", + runtimeVersion: "58.0", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: "same build date and older version in range (-2 Nightly)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190131000000", + runtimeVersion: "58.0a1", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: "same build date and older version out of range (-3)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190131000000", + runtimeVersion: "57.0", + expected: COMPATIBILITY_STATUS.TOO_OLD, + }, + { + description: "same build date and newer version out of range (+1)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190131000000", + runtimeVersion: "61.0", + expected: COMPATIBILITY_STATUS.TOO_RECENT, + }, + { + description: "same major version and build date in range (-10 days)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190121000000", + runtimeVersion: "60.0", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: "same major version and build date in range (+2 days)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190202000000", + runtimeVersion: "60.0", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: "same major version and build date out of range (+8 days)", + localBuildId: "20190131000000", + localVersion: "60.0", + runtimeBuildId: "20190208000000", + runtimeVersion: "60.0", + expected: COMPATIBILITY_STATUS.TOO_RECENT, + }, + { + description: + "fennec 68 compatibility error not raised for 68 -> 68 Android", + localBuildId: "20190131000000", + localVersion: "68.0", + runtimeBuildId: "20190202000000", + runtimeVersion: "68.0", + runtimeOs: "Android", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: + "fennec 68 compatibility error not raised for 70 -> 68 Android", + localBuildId: "20190131000000", + localVersion: "70.0", + runtimeBuildId: "20190202000000", + runtimeVersion: "68.0", + runtimeOs: "Android", + expected: COMPATIBILITY_STATUS.COMPATIBLE, + }, + { + description: "fennec 68 compatibility error raised for 71 -> 68 Android", + localBuildId: "20190131000000", + localVersion: "71.0", + runtimeBuildId: "20190202000000", + runtimeVersion: "68.0", + runtimeOs: "Android", + expected: COMPATIBILITY_STATUS.TOO_OLD_FENNEC, + }, + { + description: + "fennec 68 compatibility error not raised for 71 -> 68 non-Android", + localBuildId: "20190131000000", + localVersion: "71.0", + runtimeBuildId: "20190202000000", + runtimeVersion: "68.0", + runtimeOs: "NotAndroid", + expected: COMPATIBILITY_STATUS.TOO_OLD, + }, +]; + +add_task(async function testVersionChecker() { + for (const testData of TEST_DATA) { + const localDescription = { + appbuildid: testData.localBuildId, + platformversion: testData.localVersion, + }; + + const runtimeDescription = { + appbuildid: testData.runtimeBuildId, + platformversion: testData.runtimeVersion, + os: testData.runtimeOs, + }; + + const report = _compareVersionCompatibility( + localDescription, + runtimeDescription + ); + equal( + report.status, + testData.expected, + "Expected status for test: " + testData.description + ); + } +}); + +add_task(async function testVersionCheckWithVeryOldClient() { + // Use an empty object as devtools client, calling any method on it will fail. + const emptyClient = {}; + const report = await checkVersionCompatibility(emptyClient); + equal( + report.status, + COMPATIBILITY_STATUS.TOO_OLD, + "Report status too old if devtools client is not implementing expected interface" + ); +}); |