diff options
Diffstat (limited to 'toolkit/mozapps/update/tests/unit_base_updater')
19 files changed, 57 insertions, 42 deletions
diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js index 29c2c2a30e..faac7510d0 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js @@ -10,9 +10,12 @@ async function run_test() { } const STATE_AFTER_STAGE = STATE_APPLIED; gTestFiles = gTestFilesCompleteSuccess; - gTestFiles[gTestFiles.length - 1].originalContents = null; - gTestFiles[gTestFiles.length - 1].compareContents = "FromComplete\n"; - gTestFiles[gTestFiles.length - 1].comparePerms = 0o644; + const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); + if (channelPrefs) { + channelPrefs.originalContents = null; + channelPrefs.compareContents = "FromComplete\n"; + channelPrefs.comparePerms = 0o644; + } gTestDirs = gTestDirsCompleteSuccess; await setupUpdaterTest(FILE_COMPLETE_MAR, true); setupSymLinks(); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js index de8db067bc..379fb00a27 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js @@ -10,7 +10,7 @@ async function run_test() { return; } gTestFiles = gTestFilesPartialSuccess; - gTestFiles[11].originalFile = "partial.png"; + getTestFileByName("0exe0.exe").originalFile = "partial.png"; gTestDirs = gTestDirsPartialSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_PARTIAL_MAR, false); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js index b93b023934..11181f4420 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js @@ -15,10 +15,8 @@ async function run_test() { gTestFiles = gTestFilesCompleteSuccess; gTestDirs = gTestDirsCompleteSuccess; await setupUpdaterTest(FILE_COMPLETE_MAR, false); - await runHelperFileInUse( - gTestFiles[13].relPathDir + gTestFiles[13].fileName, - false - ); + const testFile = getTestFileByName("0exe0.exe"); + await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); await stageUpdate(STATE_AFTER_STAGE, true); checkPostUpdateRunningFile(false); checkFilesAfterUpdateSuccess(getStageDirFile, true); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js index b41da12396..def7f8db9c 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js @@ -15,10 +15,8 @@ async function run_test() { gTestFiles = gTestFilesPartialSuccess; gTestDirs = gTestDirsPartialSuccess; await setupUpdaterTest(FILE_PARTIAL_MAR, false); - await runHelperFileInUse( - gTestFiles[11].relPathDir + gTestFiles[11].fileName, - false - ); + const testFile = getTestFileByName("0exe0.exe"); + await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); await stageUpdate(STATE_AFTER_STAGE, true); checkPostUpdateRunningFile(false); checkFilesAfterUpdateSuccess(getStageDirFile, true); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js index 4b946ac3e4..d1f938bb02 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js @@ -11,10 +11,8 @@ async function run_test() { gTestFiles = gTestFilesCompleteSuccess; gTestDirs = gTestDirsCompleteSuccess; await setupUpdaterTest(FILE_COMPLETE_MAR, false); - await runHelperFileInUse( - gTestFiles[13].relPathDir + gTestFiles[13].fileName, - false - ); + const testFile = getTestFileByName("0exe0.exe"); + await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); runUpdate(STATE_SUCCEEDED, false, 0, true); await waitForHelperExit(); await checkPostUpdateAppLog(); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js index 15c3a1121a..f851c543a6 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js @@ -11,10 +11,8 @@ async function run_test() { gTestFiles = gTestFilesPartialSuccess; gTestDirs = gTestDirsPartialSuccess; await setupUpdaterTest(FILE_PARTIAL_MAR, false); - await runHelperFileInUse( - gTestFiles[11].relPathDir + gTestFiles[11].fileName, - false - ); + const testFile = getTestFileByName("0exe0.exe"); + await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); runUpdate(STATE_SUCCEEDED, false, 0, true); await waitForHelperExit(); await checkPostUpdateAppLog(); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js index 698ccb7fe5..5517d5ed81 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js @@ -12,7 +12,7 @@ async function run_test() { gTestDirs = gTestDirsCompleteSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_COMPLETE_MAR, false); - await runHelperLockFile(gTestFiles[3]); + await runHelperLockFile(getTestFileByName("searchpluginspng0.png")); runUpdate(STATE_FAILED_WRITE_ERROR, false, 1, true); await waitForHelperExit(); standardInit(); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js index c8c019ec5c..03eb6122c8 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js @@ -12,7 +12,7 @@ async function run_test() { gTestDirs = gTestDirsPartialSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_PARTIAL_MAR, false); - await runHelperLockFile(gTestFiles[2]); + await runHelperLockFile(getTestFileByName("searchpluginspng1.png")); runUpdate(STATE_FAILED_READ_ERROR, false, 1, true); await waitForHelperExit(); standardInit(); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js index 7b582dbd45..4d5fe599cf 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js @@ -13,7 +13,7 @@ async function run_test() { gTestDirs = gTestDirsCompleteSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_COMPLETE_MAR, false); - await runHelperLockFile(gTestFiles[3]); + await runHelperLockFile(getTestFileByName("searchpluginspng0.png")); await stageUpdate(STATE_AFTER_STAGE, true); checkPostUpdateRunningFile(false); // Files aren't checked after staging since this test locks a file which diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js index bf3abd8c37..3d4a8e0c51 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js @@ -13,7 +13,7 @@ async function run_test() { gTestDirs = gTestDirsPartialSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_PARTIAL_MAR, false); - await runHelperLockFile(gTestFiles[2]); + await runHelperLockFile(getTestFileByName("searchpluginspng1.png")); await stageUpdate(STATE_AFTER_STAGE, true); checkPostUpdateRunningFile(false); // Files aren't checked after staging since this test locks a file which diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettings.js b/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettings.js index b0a0cfe657..fbb0e7c4cd 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettings.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettings.js @@ -14,7 +14,17 @@ async function run_test() { return; } gTestFiles = gTestFilesCompleteSuccess; - gTestFiles[gTestFiles.length - 2].originalContents = null; + if (AppConstants.platform == "macosx") { + // On macOS, the update settings Framework already exists. Remove it. + const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_FRAMEWORK); + updateSettings.removeOriginalFile = true; + } else { + // On non-macOS, the update settings INI will normally be written out with + // the contents specified by `originalContents`. Setting this to `null` + // prevents anything from being written out. + const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_INI); + updateSettings.originalContents = null; + } gTestDirs = gTestDirsCompleteSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_COMPLETE_MAR, false); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js b/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js index e26d2aefc3..a6d204aa92 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js @@ -15,7 +15,17 @@ async function run_test() { } const STATE_AFTER_STAGE = STATE_FAILED; gTestFiles = gTestFilesCompleteSuccess; - gTestFiles[gTestFiles.length - 2].originalContents = null; + if (AppConstants.platform == "macosx") { + // On macOS, the update settings Framework already exists. Remove it. + const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_FRAMEWORK); + updateSettings.removeOriginalFile = true; + } else { + // On non-macOS, the update settings INI will normally be written out with + // the contents specified by `originalContents`. Setting this to `null` + // prevents anything from being written out. + const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_INI); + updateSettings.originalContents = null; + } gTestDirs = gTestDirsCompleteSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_COMPLETE_MAR, false); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js index a1a0de0fe4..47c184e67b 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js @@ -11,7 +11,7 @@ async function run_test() { } const STATE_AFTER_STAGE = STATE_FAILED; gTestFiles = gTestFilesPartialSuccess; - gTestFiles[11].originalFile = "partial.png"; + getTestFileByName("0exe0.exe").originalFile = "partial.png"; gTestDirs = gTestDirsPartialSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_PARTIAL_MAR, false); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js index 943a45ba95..2c9c3298d4 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js @@ -11,9 +11,10 @@ async function run_test() { } const STATE_AFTER_STAGE = gIsServiceTest ? STATE_APPLIED_SVC : STATE_APPLIED; gTestFiles = gTestFilesCompleteSuccess; - gTestFiles[gTestFiles.length - 1].originalContents = null; - gTestFiles[gTestFiles.length - 1].compareContents = "FromComplete\n"; - gTestFiles[gTestFiles.length - 1].comparePerms = 0o644; + const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); + channelPrefs.originalContents = null; + channelPrefs.compareContents = "FromComplete\n"; + channelPrefs.comparePerms = 0o644; gTestDirs = gTestDirsCompleteSuccess; setupSymLinks(); await setupUpdaterTest(FILE_COMPLETE_MAR, false); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js index dd5c240919..e565ffe550 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js @@ -11,9 +11,10 @@ async function run_test() { } const STATE_AFTER_STAGE = gIsServiceTest ? STATE_APPLIED_SVC : STATE_APPLIED; gTestFiles = gTestFilesPartialSuccess; - gTestFiles[gTestFiles.length - 1].originalContents = null; - gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n"; - gTestFiles[gTestFiles.length - 1].comparePerms = 0o644; + const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); + channelPrefs.originalContents = null; + channelPrefs.compareContents = "FromPartial\n"; + channelPrefs.comparePerms = 0o644; gTestDirs = gTestDirsPartialSuccess; preventDistributionFiles(); await setupUpdaterTest(FILE_PARTIAL_MAR, true); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js index 8e8e9d094a..f4f856278c 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js @@ -10,9 +10,10 @@ async function run_test() { return; } gTestFiles = gTestFilesPartialSuccess; - gTestFiles[gTestFiles.length - 1].originalContents = null; - gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n"; - gTestFiles[gTestFiles.length - 1].comparePerms = 0o644; + const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); + channelPrefs.originalContents = null; + channelPrefs.compareContents = "FromPartial\n"; + channelPrefs.comparePerms = 0o644; gTestDirs = gTestDirsPartialSuccess; // The third parameter will test that a relative path that contains a // directory traversal to the post update binary doesn't execute. diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js index 37511bd789..e80e52e9a3 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js @@ -45,8 +45,7 @@ async function run_test() { // won't be updated if it already exists. The manipulations below arrange a) // for the file to exist and b) for the comparison afterward to succeed. gTestFiles = gTestFilesPartialSuccess; - let channelPrefs = gTestFiles[gTestFiles.length - 1]; - Assert.equal("channel-prefs.js", channelPrefs.fileName); + let channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); let f = gGREDirOrig.clone(); f.append("defaults"); f.append("pref"); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js index d31188dcca..5d6ee61776 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js @@ -14,8 +14,7 @@ async function run_test() { return; } gTestFiles = gTestFilesCompleteSuccess; - gTestFiles[gTestFiles.length - 2].originalContents = - UPDATE_SETTINGS_CONTENTS.replace("xpcshell-test", "wrong-channel"); + setUpdateSettingsUseWrongChannel(); gTestDirs = gTestDirsCompleteSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_COMPLETE_MAR, false); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannelStage.js b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannelStage.js index 4d512fd12a..9aca22df66 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannelStage.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannelStage.js @@ -15,8 +15,7 @@ async function run_test() { } const STATE_AFTER_STAGE = STATE_FAILED; gTestFiles = gTestFilesCompleteSuccess; - gTestFiles[gTestFiles.length - 2].originalContents = - UPDATE_SETTINGS_CONTENTS.replace("xpcshell-test", "wrong-channel"); + setUpdateSettingsUseWrongChannel(); gTestDirs = gTestDirsCompleteSuccess; setTestFilesAndDirsForFailure(); await setupUpdaterTest(FILE_COMPLETE_MAR, false); |