diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/mozapps/update/tests/browser/browser_memory_allocation_error_fallback.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | toolkit/mozapps/update/tests/browser/browser_memory_allocation_error_fallback.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/toolkit/mozapps/update/tests/browser/browser_memory_allocation_error_fallback.js b/toolkit/mozapps/update/tests/browser/browser_memory_allocation_error_fallback.js new file mode 100644 index 0000000000..55ec2e14a1 --- /dev/null +++ b/toolkit/mozapps/update/tests/browser/browser_memory_allocation_error_fallback.js @@ -0,0 +1,81 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * When the updater fails with a memory allocation error, we should fall back to + * updating without staging. + */ + +const READ_STRINGS_MEM_ERROR = 10; +const ARCHIVE_READER_MEM_ERROR = 11; +const BSPATCH_MEM_ERROR = 12; +const UPDATER_MEM_ERROR = 13; +const UPDATER_QUOTED_PATH_MEM_ERROR = 14; + +const EXPECTED_STATUS = + AppConstants.platform == "win" ? STATE_PENDING_SVC : STATE_PENDING; + +add_setup(async function setup() { + await SpecialPowers.pushPrefEnv({ + set: [ + [PREF_APP_UPDATE_STAGING_ENABLED, true], + [PREF_APP_UPDATE_SERVICE_ENABLED, true], + ], + }); + + registerCleanupFunction(() => { + Services.env.set("MOZ_FORCE_ERROR_CODE", ""); + }); +}); + +async function memAllocErrorFallback(errorCode) { + Services.env.set("MOZ_FORCE_ERROR_CODE", errorCode.toString()); + + // Since the partial should be successful specify an invalid size for the + // complete update. + let params = { + queryString: "&invalidCompleteSize=1", + backgroundUpdate: true, + continueFile: CONTINUE_STAGING, + waitForUpdateState: EXPECTED_STATUS, + }; + await runAboutPrefsUpdateTest(params, [ + { + panelId: "apply", + checkActiveUpdate: { state: EXPECTED_STATUS }, + continueFile: null, + }, + ]); +} + +function cleanup() { + reloadUpdateManagerData(true); + removeUpdateFiles(true); +} + +add_task(async function memAllocErrorFallback_READ_STRINGS_MEM_ERROR() { + await memAllocErrorFallback(READ_STRINGS_MEM_ERROR); + cleanup(); +}); + +add_task(async function memAllocErrorFallback_ARCHIVE_READER_MEM_ERROR() { + await memAllocErrorFallback(ARCHIVE_READER_MEM_ERROR); + cleanup(); +}); + +add_task(async function memAllocErrorFallback_BSPATCH_MEM_ERROR() { + await memAllocErrorFallback(BSPATCH_MEM_ERROR); + cleanup(); +}); + +add_task(async function memAllocErrorFallback_UPDATER_MEM_ERROR() { + await memAllocErrorFallback(UPDATER_MEM_ERROR); + cleanup(); +}); + +add_task(async function memAllocErrorFallback_UPDATER_QUOTED_PATH_MEM_ERROR() { + await memAllocErrorFallback(UPDATER_QUOTED_PATH_MEM_ERROR); + cleanup(); +}); |