From bcc4b4f167bd22cda694fc54e12590511d30d26f Mon Sep 17 00:00:00 2001 From: Robin Steuber Date: Wed, 15 May 2024 17:06:13 +0000 Subject: [PATCH] Bug 1875502 - Pre: Update tests to accomodate async readyUpdate r=nalexander,application-update-reviewers Differential Revision: https://phabricator.services.mozilla.com/D209116 --- .../whats_new_page/browser_whats_new_page.js | 4 +- .../browser_whats_new_page_nimbus.js | 4 +- .../urlbar/tests/browser-tips/head.js | 2 +- .../browser/browser_aboutPrefs_settings.js | 17 +++-- ...er_doorhanger_bc_downloaded_disableBITS.js | 2 +- .../tests/browser/browser_elevationDialog.js | 13 ++-- toolkit/mozapps/update/tests/browser/head.js | 36 ++++++----- .../update/tests/data/xpcshellUtilsAUS.js | 18 +++--- .../cleanupDownloadingForDifferentChannel.js | 5 +- .../cleanupDownloadingForOlderAppVersion.js | 5 +- ...anupDownloadingForSameVersionAndBuildID.js | 5 +- .../cleanupDownloadingIncorrectStatus.js | 5 +- ...leanupPendingVersionFileIncorrectStatus.js | 5 +- .../unit_aus_update/cleanupSuccessLogMove.js | 5 +- .../unit_aus_update/cleanupSuccessLogsFIFO.js | 5 +- .../tests/unit_aus_update/multiUpdate.js | 62 +++++++++---------- .../onlyDownloadUpdatesThisSession.js | 2 +- .../unit_aus_update/updateDirectoryMigrate.js | 5 +- .../tests/unit_aus_update/updateManagerXML.js | 5 +- 19 files changed, 125 insertions(+), 80 deletions(-) diff --git a/browser/components/tests/browser/whats_new_page/browser_whats_new_page.js b/browser/components/tests/browser/whats_new_page/browser_whats_new_page.js index 024879c604b6..38215abe22cc 100644 --- a/browser/components/tests/browser/whats_new_page/browser_whats_new_page.js +++ b/browser/components/tests/browser/whats_new_page/browser_whats_new_page.js @@ -32,10 +32,10 @@ add_task(async function whats_new_page() { Ci.nsIUpdateManager ); await TestUtils.waitForCondition( - () => !um.readyUpdate, + async () => !(await um.getReadyUpdate()), "Waiting for the ready update to be removed" ); - ok(!um.readyUpdate, "There should not be a ready update"); + ok(!(await um.getReadyUpdate()), "There should not be a ready update"); let history; await TestUtils.waitForCondition(async () => { history = await um.getHistory(); diff --git a/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js b/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js index 261a80e7bf37..37c27ab9d849 100644 --- a/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js +++ b/browser/components/tests/browser/whats_new_page/browser_whats_new_page_nimbus.js @@ -33,10 +33,10 @@ add_task(async function nimbus_whats_new_page() { Ci.nsIUpdateManager ); await TestUtils.waitForCondition( - () => !um.readyUpdate, + async () => !(await um.getReadyUpdate()), "Waiting for the ready update to be removed" ); - ok(!um.readyUpdate, "There should not be a ready update"); + ok(!(await um.getReadyUpdate()), "There should not be a ready update"); let history; await TestUtils.waitForCondition(async () => { history = await um.getHistory(); diff --git a/browser/components/urlbar/tests/browser-tips/head.js b/browser/components/urlbar/tests/browser-tips/head.js index a126accc975e..fa12d34aebda 100644 --- a/browser/components/urlbar/tests/browser-tips/head.js +++ b/browser/components/urlbar/tests/browser-tips/head.js @@ -228,7 +228,7 @@ async function processUpdateStep(step) { ); } else { Assert.ok( - !gUpdateManager.readyUpdate, + !(await gUpdateManager.getReadyUpdate()), "There should not be a ready update" ); Assert.ok( diff --git a/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js b/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js index db1b538d143f..da35aba2d218 100644 --- a/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js +++ b/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js @@ -69,7 +69,7 @@ async function changeAndVerifyUpdateWrites({ `We should ${expectPrompt ? "" : "not "}be prompted` ); is( - !!gUpdateManager.readyUpdate, + !!(await gUpdateManager.getReadyUpdate()), expectRemainingUpdate, `There should ${expectRemainingUpdate ? "" : "not "}be a ready update` ); @@ -92,7 +92,10 @@ add_task(async function testUpdateAutoPrefUI() { !gUpdateManager.downloadingUpdate, "There should not be a downloading update" ); - ok(!gUpdateManager.readyUpdate, "There should not be a ready update"); + ok( + !(await gUpdateManager.getReadyUpdate()), + "There should not be a ready update" + ); info("Disable automatic updates and check that works."); await changeAndVerifyPref(tab, false); @@ -100,7 +103,10 @@ add_task(async function testUpdateAutoPrefUI() { !gUpdateManager.downloadingUpdate, "There should not be a downloading update" ); - ok(!gUpdateManager.readyUpdate, "There should not be a ready update"); + ok( + !(await gUpdateManager.getReadyUpdate()), + "There should not be a ready update" + ); let patchProps = { state: STATE_PENDING }; let patches = getLocalPatchString(patchProps); @@ -109,7 +115,10 @@ add_task(async function testUpdateAutoPrefUI() { writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); writeStatusFile(STATE_PENDING); reloadUpdateManagerData(); - ok(!!gUpdateManager.readyUpdate, "There should be a ready update"); + ok( + !!(await gUpdateManager.getReadyUpdate()), + "There should be a ready update" + ); let { prompt } = Services; registerCleanupFunction(() => { diff --git a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloaded_disableBITS.js b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloaded_disableBITS.js index 5f89c953224f..9adfa347fb56 100644 --- a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloaded_disableBITS.js +++ b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloaded_disableBITS.js @@ -22,7 +22,7 @@ add_task(async function doorhanger_bc_downloaded_disableBITS() { let patch = getPatchOfType( "partial", - gUpdateManager.readyUpdate + await gUpdateManager.getReadyUpdate() ).QueryInterface(Ci.nsIWritablePropertyBag); ok( !patch.getProperty("bitsId"), diff --git a/toolkit/mozapps/update/tests/browser/browser_elevationDialog.js b/toolkit/mozapps/update/tests/browser/browser_elevationDialog.js index 639af1ffff7f..89accf368504 100644 --- a/toolkit/mozapps/update/tests/browser/browser_elevationDialog.js +++ b/toolkit/mozapps/update/tests/browser/browser_elevationDialog.js @@ -44,9 +44,10 @@ add_task(async function elevation_dialog() { () => !Services.wm.getMostRecentWindow("Update:Elevation"), "The Update Elevation dialog should have closed" ); - ok(!!gUpdateManager.readyUpdate, "There should be a ready update"); + let readyUpdate = await gUpdateManager.getReadyUpdate(); + ok(!!readyUpdate, "There should be a ready update"); is( - gUpdateManager.readyUpdate.state, + readyUpdate.state, STATE_PENDING_ELEVATE, "The ready update state should equal " + STATE_PENDING_ELEVATE ); @@ -64,7 +65,8 @@ add_task(async function elevation_dialog() { () => !Services.wm.getMostRecentWindow("Update:Elevation"), "The Update Elevation dialog should have closed" ); - ok(!gUpdateManager.readyUpdate, "There should not be a ready update"); + readyUpdate = await gUpdateManager.getReadyUpdate(); + ok(!readyUpdate, "There should not be a ready update"); is( readStatusFile(), STATE_NONE, @@ -79,9 +81,10 @@ add_task(async function elevation_dialog() { () => !Services.wm.getMostRecentWindow("Update:Elevation"), "The Update Elevation dialog should have closed" ); - ok(!!gUpdateManager.readyUpdate, "There should be a ready update"); + readyUpdate = await gUpdateManager.getReadyUpdate(); + ok(!!readyUpdate, "There should be a ready update"); is( - gUpdateManager.readyUpdate.state, + readyUpdate.state, STATE_PENDING_ELEVATE, "The active update state should equal " + STATE_PENDING_ELEVATE ); diff --git a/toolkit/mozapps/update/tests/browser/head.js b/toolkit/mozapps/update/tests/browser/head.js index 14153b84bfee..ec8c67001176 100644 --- a/toolkit/mozapps/update/tests/browser/head.js +++ b/toolkit/mozapps/update/tests/browser/head.js @@ -576,10 +576,9 @@ function runDoorhangerUpdateTest(params, steps) { ); if (checkActiveUpdate) { - let activeUpdate = - checkActiveUpdate.state == STATE_DOWNLOADING - ? gUpdateManager.downloadingUpdate - : gUpdateManager.readyUpdate; + let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING + ? gUpdateManager.downloadingUpdate + : gUpdateManager.getReadyUpdate()); ok(!!activeUpdate, "There should be an active update"); is( activeUpdate.state, @@ -591,7 +590,10 @@ function runDoorhangerUpdateTest(params, steps) { !gUpdateManager.downloadingUpdate, "There should not be a downloading update" ); - ok(!gUpdateManager.readyUpdate, "There should not be a ready update"); + ok( + !(await gUpdateManager.getReadyUpdate()), + "There should not be a ready update" + ); } let buttonEl = getNotificationButton(window, notificationId, button); @@ -753,10 +755,9 @@ function runAboutDialogUpdateTest(params, steps) { ); if (checkActiveUpdate) { - let activeUpdate = - checkActiveUpdate.state == STATE_DOWNLOADING - ? gUpdateManager.downloadingUpdate - : gUpdateManager.readyUpdate; + let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING + ? gUpdateManager.downloadingUpdate + : gUpdateManager.getReadyUpdate()); ok(!!activeUpdate, "There should be an active update"); is( activeUpdate.state, @@ -768,7 +769,10 @@ function runAboutDialogUpdateTest(params, steps) { !gUpdateManager.downloadingUpdate, "There should not be a downloading update" ); - ok(!gUpdateManager.readyUpdate, "There should not be a ready update"); + ok( + !(await gUpdateManager.getReadyUpdate()), + "There should not be a ready update" + ); } // Some tests just want to stop at the downloading state. These won't @@ -1060,10 +1064,9 @@ function runAboutPrefsUpdateTest(params, steps) { ); if (checkActiveUpdate) { - let activeUpdate = - checkActiveUpdate.state == STATE_DOWNLOADING - ? gUpdateManager.downloadingUpdate - : gUpdateManager.readyUpdate; + let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING + ? gUpdateManager.downloadingUpdate + : gUpdateManager.getReadyUpdate()); ok(!!activeUpdate, "There should be an active update"); is( activeUpdate.state, @@ -1075,7 +1078,10 @@ function runAboutPrefsUpdateTest(params, steps) { !gUpdateManager.downloadingUpdate, "There should not be a downloading update" ); - ok(!gUpdateManager.readyUpdate, "There should not be a ready update"); + ok( + !(await gUpdateManager.getReadyUpdate()), + "There should not be a ready update" + ); } if (panelId == "downloading") { diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js index 2e3827913309..448a7fdad16f 100644 --- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js +++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js @@ -1312,10 +1312,9 @@ async function checkUpdateManager( aUpdateErrCode, aUpdateCount ) { - let activeUpdate = - aUpdateStatusState == STATE_DOWNLOADING - ? gUpdateManager.downloadingUpdate - : gUpdateManager.readyUpdate; + let activeUpdate = await (aUpdateStatusState == STATE_DOWNLOADING + ? gUpdateManager.downloadingUpdate + : gUpdateManager.getReadyUpdate()); Assert.equal( readStatusState(), aStatusFileState, @@ -2286,7 +2285,7 @@ function checkSymlink() { /** * Sets the active update and related information for updater tests. */ -function setupActiveUpdate() { +async function setupActiveUpdate() { let pendingState = gIsServiceTest ? STATE_PENDING_SVC : STATE_PENDING; let patchProps = { state: pendingState }; let patches = getLocalPatchString(patchProps); @@ -2295,7 +2294,10 @@ function setupActiveUpdate() { writeVersionFile(DEFAULT_UPDATE_VERSION); writeStatusFile(pendingState); reloadUpdateManagerData(); - Assert.ok(!!gUpdateManager.readyUpdate, "the ready update should be defined"); + Assert.ok( + !!(await gUpdateManager.getReadyUpdate()), + "the ready update should be defined" + ); } /** @@ -2357,7 +2359,7 @@ async function stageUpdate( ); Assert.equal( - gUpdateManager.readyUpdate.state, + (await gUpdateManager.getReadyUpdate()).state, aStateAfterStage, "the update state" + MSG_SHOULD_EQUAL ); @@ -3299,7 +3301,7 @@ async function setupUpdaterTest( }); if (aSetupActiveUpdate) { - setupActiveUpdate(); + await setupActiveUpdate(); } if (aPostUpdateAsync !== null) { diff --git a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForDifferentChannel.js b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForDifferentChannel.js index 57dd2c426261..28ffdae2c92e 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForDifferentChannel.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForDifferentChannel.js @@ -26,7 +26,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForOlderAppVersion.js b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForOlderAppVersion.js index 60a30d51fed3..22444dceefdc 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForOlderAppVersion.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForOlderAppVersion.js @@ -24,7 +24,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForSameVersionAndBuildID.js b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForSameVersionAndBuildID.js index 97d346eeac11..9f0549749ff9 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForSameVersionAndBuildID.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForSameVersionAndBuildID.js @@ -25,7 +25,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingIncorrectStatus.js b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingIncorrectStatus.js index 143498869d6e..6733e600485c 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingIncorrectStatus.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingIncorrectStatus.js @@ -23,7 +23,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/cleanupPendingVersionFileIncorrectStatus.js b/toolkit/mozapps/update/tests/unit_aus_update/cleanupPendingVersionFileIncorrectStatus.js index 2d0932820be9..e38dda5fdc70 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupPendingVersionFileIncorrectStatus.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupPendingVersionFileIncorrectStatus.js @@ -23,7 +23,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js b/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js index 8582c9ed80e0..2c5ccab02b71 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js @@ -27,7 +27,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js b/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js index 20229dbad5ba..f0bbdf6e9943 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js @@ -105,7 +105,10 @@ async function testCleanupSuccessLogsFIFO( !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/multiUpdate.js b/toolkit/mozapps/update/tests/unit_aus_update/multiUpdate.js index bfe00ddbac8f..f2d1314cedc0 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/multiUpdate.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/multiUpdate.js @@ -73,9 +73,9 @@ async function downloadUpdate(appUpdateAuto, onDownloadStartCallback) { } let waitToStartPromise = new Promise(resolve => { let listener = { - onStartRequest: _aRequest => { + onStartRequest: async _aRequest => { gAUS.removeDownloadListener(listener); - onDownloadStartCallback(); + await onDownloadStartCallback(); resolve(); }, onProgress: (_aRequest, _aContext, _aProgress, _aMaxProgress) => {}, @@ -197,11 +197,9 @@ async function multi_update_test(appUpdateAuto) { prepareToDownloadVersion(FIRST_UPDATE_VERSION); - await downloadUpdate(appUpdateAuto, () => { - Assert.ok( - !gUpdateManager.readyUpdate, - "There should not be a ready update yet" - ); + await downloadUpdate(appUpdateAuto, async () => { + const readyUpdate = await gUpdateManager.getReadyUpdate(); + Assert.ok(!readyUpdate, "There should not be a ready update yet"); Assert.ok( !!gUpdateManager.downloadingUpdate, "First update download should be in downloadingUpdate" @@ -218,21 +216,19 @@ async function multi_update_test(appUpdateAuto) { ); }); + let readyUpdate = await gUpdateManager.getReadyUpdate(); Assert.ok( !gUpdateManager.downloadingUpdate, "First update download should no longer be in downloadingUpdate" ); - Assert.ok( - !!gUpdateManager.readyUpdate, - "First update download should be in readyUpdate" - ); + Assert.ok(!!readyUpdate, "First update download should be in readyUpdate"); Assert.equal( - gUpdateManager.readyUpdate.state, + readyUpdate.state, STATE_PENDING, "readyUpdate should be pending" ); Assert.equal( - gUpdateManager.readyUpdate.appVersion, + readyUpdate.appVersion, FIRST_UPDATE_VERSION, "readyUpdate version should be match the version of the first update" ); @@ -242,21 +238,22 @@ async function multi_update_test(appUpdateAuto) { "Updater state should be pending" ); - let existingUpdate = gUpdateManager.readyUpdate; + let existingUpdate = readyUpdate; await testUpdateDoesNotDownload(); + readyUpdate = await gUpdateManager.getReadyUpdate(); Assert.equal( - gUpdateManager.readyUpdate, + readyUpdate, existingUpdate, "readyUpdate should not have changed when no newer update is available" ); Assert.equal( - gUpdateManager.readyUpdate.state, + readyUpdate.state, STATE_PENDING, "readyUpdate should still be pending" ); Assert.equal( - gUpdateManager.readyUpdate.appVersion, + readyUpdate.appVersion, FIRST_UPDATE_VERSION, "readyUpdate version should be match the version of the first update" ); @@ -271,18 +268,19 @@ async function multi_update_test(appUpdateAuto) { prepareToDownloadVersion(SECOND_UPDATE_VERSION, true); await testUpdateDoesNotDownload(); + readyUpdate = await gUpdateManager.getReadyUpdate(); Assert.equal( - gUpdateManager.readyUpdate, + readyUpdate, existingUpdate, "readyUpdate should not have changed when no newer partial update is available" ); Assert.equal( - gUpdateManager.readyUpdate.state, + readyUpdate.state, STATE_PENDING, "readyUpdate should still be pending" ); Assert.equal( - gUpdateManager.readyUpdate.appVersion, + readyUpdate.appVersion, FIRST_UPDATE_VERSION, "readyUpdate version should be match the version of the first update" ); @@ -294,7 +292,8 @@ async function multi_update_test(appUpdateAuto) { prepareToDownloadVersion(SECOND_UPDATE_VERSION); - await downloadUpdate(appUpdateAuto, () => { + await downloadUpdate(appUpdateAuto, async () => { + readyUpdate = await gUpdateManager.getReadyUpdate(); Assert.ok( !!gUpdateManager.downloadingUpdate, "Second update download should be in downloadingUpdate" @@ -305,16 +304,16 @@ async function multi_update_test(appUpdateAuto) { "downloadingUpdate should be downloading" ); Assert.ok( - !!gUpdateManager.readyUpdate, + !!readyUpdate, "First update download should still be in readyUpdate" ); Assert.equal( - gUpdateManager.readyUpdate.state, + readyUpdate.state, STATE_PENDING, "readyUpdate should still be pending" ); Assert.equal( - gUpdateManager.readyUpdate.appVersion, + readyUpdate.appVersion, FIRST_UPDATE_VERSION, "readyUpdate version should be match the version of the first update" ); @@ -325,21 +324,19 @@ async function multi_update_test(appUpdateAuto) { ); }); + readyUpdate = await gUpdateManager.getReadyUpdate(); Assert.ok( !gUpdateManager.downloadingUpdate, "Second update download should no longer be in downloadingUpdate" ); - Assert.ok( - !!gUpdateManager.readyUpdate, - "Second update download should be in readyUpdate" - ); + Assert.ok(!!readyUpdate, "Second update download should be in readyUpdate"); Assert.equal( - gUpdateManager.readyUpdate.state, + readyUpdate.state, STATE_PENDING, "readyUpdate should be pending" ); Assert.equal( - gUpdateManager.readyUpdate.appVersion, + readyUpdate.appVersion, SECOND_UPDATE_VERSION, "readyUpdate version should be match the version of the second update" ); @@ -356,7 +353,7 @@ async function multi_update_test(appUpdateAuto) { // Second parameter forces a complete MAR download. prepareToDownloadVersion(FIRST_UPDATE_VERSION, true); - await downloadUpdate(appUpdateAuto, () => { + await downloadUpdate(appUpdateAuto, async () => { Assert.equal( gUpdateManager.downloadingUpdate.selectedPatch.type, "complete", @@ -364,8 +361,9 @@ async function multi_update_test(appUpdateAuto) { ); }); + readyUpdate = await gUpdateManager.getReadyUpdate(); Assert.equal( - gUpdateManager.readyUpdate.selectedPatch.type, + readyUpdate.selectedPatch.type, "complete", "First update download should be a complete patch" ); diff --git a/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js b/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js index b3536e55d650..16fa3821ab18 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js @@ -50,7 +50,7 @@ add_task(async function onlyDownloadUpdatesThisSession() { await downloadUpdate(); Assert.ok( - !gUpdateManager.readyUpdate, + !(await gUpdateManager.getReadyUpdate()), "There should not be a ready update. The update should still be downloading" ); Assert.ok( diff --git a/toolkit/mozapps/update/tests/unit_aus_update/updateDirectoryMigrate.js b/toolkit/mozapps/update/tests/unit_aus_update/updateDirectoryMigrate.js index 08a794cb6cf0..6800211e08df 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/updateDirectoryMigrate.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/updateDirectoryMigrate.js @@ -159,7 +159,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length, diff --git a/toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js b/toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js index 0c720ee80424..e1fe2c79e307 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js @@ -80,7 +80,10 @@ async function run_test() { !gUpdateManager.downloadingUpdate, "there should not be a downloading update" ); - Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update"); + Assert.ok( + !(await gUpdateManager.getReadyUpdate()), + "there should not be a ready update" + ); const history = await gUpdateManager.getHistory(); Assert.equal( history.length,