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/unit_aus_update/onlyDownloadUpdatesThisSession.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.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 'toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js')
-rw-r--r-- | toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js b/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js new file mode 100644 index 0000000000..ab08ac854f --- /dev/null +++ b/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +"use strict"; + +function setup() { + setupTestCommon(); + start_httpserver(); + setUpdateURL(gURLData + gHTTPHandlerPath); + setUpdateChannel("test_channel"); +} +setup(); + +/** + * Checks for updates and makes sure that the update process does not proceed + * beyond the downloading stage. + */ +async function downloadUpdate() { + let patches = getRemotePatchString({}); + let updateString = getRemoteUpdateString({}, patches); + gResponseBody = getRemoteUpdatesXMLString(updateString); + + let { updates } = await waitForUpdateCheck(true); + + initMockIncrementalDownload(); + gIncrementalDownloadErrorType = 3; + + let downloadRestrictionHitPromise = new Promise(resolve => { + let downloadRestrictionHitListener = (subject, topic) => { + Services.obs.removeObserver(downloadRestrictionHitListener, topic); + resolve(); + }; + Services.obs.addObserver( + downloadRestrictionHitListener, + "update-download-restriction-hit" + ); + }); + + let bestUpdate = gAUS.selectUpdate(updates); + let success = await gAUS.downloadUpdate(bestUpdate, false); + Assert.ok(success, "Update download should have started"); + return downloadRestrictionHitPromise; +} + +add_task(async function onlyDownloadUpdatesThisSession() { + gAUS.onlyDownloadUpdatesThisSession = true; + + await downloadUpdate(); + + Assert.ok( + !gUpdateManager.readyUpdate, + "There should not be a ready update. The update should still be downloading" + ); + Assert.ok( + !!gUpdateManager.downloadingUpdate, + "A downloading update should exist" + ); + Assert.equal( + gUpdateManager.downloadingUpdate.state, + STATE_DOWNLOADING, + "The downloading update should still be in the downloading state" + ); +}); + +add_task(async function finish() { + stop_httpserver(doTestFinish); +}); |