summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/update/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/mozapps/update/tests
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/update/tests')
-rw-r--r--toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate.js2
-rw-r--r--toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate_promptWaitTime.js2
-rw-r--r--toolkit/mozapps/update/tests/browser/head.js12
-rw-r--r--toolkit/mozapps/update/tests/data/README.md15
-rw-r--r--toolkit/mozapps/update/tests/data/complete_mac.marbin87129 -> 87143 bytes
-rw-r--r--toolkit/mozapps/update/tests/data/partial_mac.marbin10361 -> 10351 bytes
-rw-r--r--toolkit/mozapps/update/tests/data/shared.js10
-rw-r--r--toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js155
-rw-r--r--toolkit/mozapps/update/tests/unit_aus_update/languagePackUpdates.js9
-rw-r--r--toolkit/mozapps/update/tests/unit_aus_update/verifyChannelPrefsFile.js38
-rw-r--r--toolkit/mozapps/update/tests/unit_aus_update/xpcshell.toml4
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js9
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettings.js12
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js12
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js7
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js7
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js7
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js3
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js3
-rw-r--r--toolkit/mozapps/update/tests/unit_base_updater/marWrongChannelStage.js3
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js6
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.js2
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js7
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js7
-rw-r--r--toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js7
43 files changed, 243 insertions, 160 deletions
diff --git a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate.js b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate.js
index 07e7bf51fa..0ca510cfcf 100644
--- a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate.js
+++ b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate.js
@@ -64,7 +64,7 @@ add_task(async function doorhanger_bc_multiUpdate() {
is(
PanelUI.menuButton.getAttribute("badge-status"),
- "",
+ null,
"Should not have restart badge during staging"
);
diff --git a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate_promptWaitTime.js b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate_promptWaitTime.js
index 00c61bcbb4..8012250f36 100644
--- a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate_promptWaitTime.js
+++ b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_multiUpdate_promptWaitTime.js
@@ -74,7 +74,7 @@ add_task(async function doorhanger_bc_multiUpdate() {
is(
PanelUI.menuButton.getAttribute("badge-status"),
- "",
+ null,
"Should not have restart badge during staging"
);
diff --git a/toolkit/mozapps/update/tests/browser/head.js b/toolkit/mozapps/update/tests/browser/head.js
index c5acdad8e4..b606331fd3 100644
--- a/toolkit/mozapps/update/tests/browser/head.js
+++ b/toolkit/mozapps/update/tests/browser/head.js
@@ -368,9 +368,15 @@ function copyTestUpdater(attempt = 0) {
testUpdater.copyToFollowingLinks(greBinDir, FILE_UPDATER_BIN);
let greDir = getGREDir();
- let updateSettingsIni = greDir.clone();
- updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
- writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
+
+ // On macOS, update settings is a Framework, not an INI. This was already
+ // built into updater-xpcshell using the `UpdateSettings-xpcshell`
+ // Framework, so we don't need to do any additional work here.
+ if (AppConstants.platform != "macosx") {
+ let updateSettingsIni = greDir.clone();
+ updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
+ writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
+ }
let precomplete = greDir.clone();
precomplete.append(FILE_PRECOMPLETE);
diff --git a/toolkit/mozapps/update/tests/data/README.md b/toolkit/mozapps/update/tests/data/README.md
new file mode 100644
index 0000000000..52a7e9a5b7
--- /dev/null
+++ b/toolkit/mozapps/update/tests/data/README.md
@@ -0,0 +1,15 @@
+README
+======
+
+I needed to make changes to some of the test MARs in this directory and it was a bit difficult to figure out how, so I want to document what I did so that this is easier next time. In my specific case, I wanted to rename some files in several MARs. These are approximately the steps I used to make changes to `partial_mac.mar`:
+
+ - `./mach build` so that `<obj>/dist/bin/signmar` is available.
+ - We want use the [Python MAR tool](https://github.com/mozilla-releng/build-mar) to build the replacement MAR, but it currently has a problem that we need to fix before we can build a MAR that will allow tests to pass on Apple silicon. Once [this issue](https://github.com/mozilla-releng/build-mar/issues/63) is addressed, we can just use `pip install mar`. Until then, we need to checkout the project and tweak it before we use it. First clone the repository: `cd ~ && git clone https://github.com/mozilla-releng/build-mar`. Next, we want to remove [this line](https://github.com/mozilla-releng/build-mar/blob/2d37c446015b97d6f700fef5766a49609bdc22ea/src/mardor/utils.py#L158). Then make the tweaked version available with `cd ~/build-mar && virtualenv mardor && source mardor/bin/activate && pip install .`.
+ - Made a temporary working directory: `cd /path/to/mozilla/repo && mkdir temp && cd temp`
+ - Extracted the MAR that I wanted to change: `mar -J -x ../toolkit/mozapps/update/tests/data/partial_mac.mar`. The `-J` specifies a compression type of `xz`. You can also specify `--auto` to automatically detect the compression type (though you may want to know the original compression later for recompression) or you can check the compression type by running `mar -T ../toolkit/mozapps/update/tests/data/partial_mac.mar` and looking for the `Compression type:` line.
+ - Made the changes that I wanted to make to the extracted files. This included moving the old files to their new locations and updating those paths in `updatev2.manifest` and `updatev3.manifest`.
+ - Run `mar -T ../toolkit/mozapps/update/tests/data/partial_mac.mar` to get a complete list of the files originally in that MAR as well as the product/version and channel strings (in this case `xpcshell-test` and `*` respectively).
+ - Create the new MAR: `mar -J -c partial_mac_unsigned.mar -V '*' -H xpcshell-test <file1> <file2> ...`, individually specifying each file path listed in by `mar -T`, substituting with renamed paths as necessary.
+ - I had a bit of trouble figuring out the signing. Eventually I discovered the following things: (a) The test MAR signatures successfully verify against `toolkit/mozapps/update/updater/xpcshellCertificate.der` and (b) according to [this comment](https://searchfox.org/mozilla-central/rev/fc00627e34639ef1014e87d9fa24091905e9dc5d/toolkit/mozapps/update/updater/moz.build#41-43), that certificate was generated from `mycert` in `modules/libmar/tests/unit/data`. Thus, I signed the MAR like this: `../<obj>/dist/bin/signmar -d ../modules/libmar/tests/unit/data -n mycert -s partial_mac_unsigned.mar partial_mac.mar`.
+ - I wanted to do some verification to make sure that the new MAR looked right. First I verified the signature: `../<obj>/dist/bin/signmar -D ../toolkit/mozapps/update/updater/xpcshellCertificate.der -v partial_mac.mar`. This appears to output nothing on success, but it's probably good to check to make sure `echo $?` is `0`. I also compared the output of `mar -T partial_mac.mar` to that of the original. I saw a few unexpected size changes which I believe are likely due to slight differences in the compression used (maybe the algorithm changed slightly since this was last generated?). To make sure that these did not correspond to effective changes, I extracted the new MAR with `mkdir cmp && cd cmp && mar -J -x ../partial_mac.mar && cd ..` and compared the resulting files to make sure they had the expected contents.
+ - Overwrite the original MAR with the new one and remove the `temp` directory: `cd .. && mv -f temp/partial_mac.mar toolkit/mozapps/update/tests/data/partial_mac.mar && rm -rf temp`
diff --git a/toolkit/mozapps/update/tests/data/complete_mac.mar b/toolkit/mozapps/update/tests/data/complete_mac.mar
index c54088610a..f4603f1eef 100644
--- a/toolkit/mozapps/update/tests/data/complete_mac.mar
+++ b/toolkit/mozapps/update/tests/data/complete_mac.mar
Binary files differ
diff --git a/toolkit/mozapps/update/tests/data/partial_mac.mar b/toolkit/mozapps/update/tests/data/partial_mac.mar
index bcc04b9939..9b17747e43 100644
--- a/toolkit/mozapps/update/tests/data/partial_mac.mar
+++ b/toolkit/mozapps/update/tests/data/partial_mac.mar
Binary files differ
diff --git a/toolkit/mozapps/update/tests/data/shared.js b/toolkit/mozapps/update/tests/data/shared.js
index 60de6feeb8..e8553f7273 100644
--- a/toolkit/mozapps/update/tests/data/shared.js
+++ b/toolkit/mozapps/update/tests/data/shared.js
@@ -71,17 +71,20 @@ const FILE_ACTIVE_UPDATE_XML = "active-update.xml";
const FILE_ACTIVE_UPDATE_XML_TMP = "active-update.xml.tmp";
const FILE_APPLICATION_INI = "application.ini";
const FILE_BACKUP_UPDATE_CONFIG_JSON = "backup-update-config.json";
-const FILE_BACKUP_UPDATE_LOG = "backup-update.log";
const FILE_BACKUP_UPDATE_ELEVATED_LOG = "backup-update-elevated.log";
+const FILE_BACKUP_UPDATE_LOG = "backup-update.log";
const FILE_BT_RESULT = "bt.result";
-const FILE_LAST_UPDATE_LOG = "last-update.log";
+const FILE_CHANNEL_PREFS =
+ AppConstants.platform == "macosx" ? "ChannelPrefs" : "channel-prefs.js";
const FILE_LAST_UPDATE_ELEVATED_LOG = "last-update-elevated.log";
+const FILE_LAST_UPDATE_LOG = "last-update.log";
const FILE_PRECOMPLETE = "precomplete";
const FILE_PRECOMPLETE_BAK = "precomplete.bak";
const FILE_UPDATE_CONFIG_JSON = "update-config.json";
-const FILE_UPDATE_LOG = "update.log";
const FILE_UPDATE_ELEVATED_LOG = "update-elevated.log";
+const FILE_UPDATE_LOG = "update.log";
const FILE_UPDATE_MAR = "update.mar";
+const FILE_UPDATE_SETTINGS_FRAMEWORK = "UpdateSettings";
const FILE_UPDATE_SETTINGS_INI = "update-settings.ini";
const FILE_UPDATE_SETTINGS_INI_BAK = "update-settings.ini.bak";
const FILE_UPDATE_STATUS = "update.status";
@@ -223,6 +226,7 @@ function setUpdateChannel(aChannel) {
debugDump(
"setting default pref " + PREF_APP_UPDATE_CHANNEL + " to " + gChannel
);
+ gDefaultPrefBranch.unlockPref(PREF_APP_UPDATE_CHANNEL);
gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, gChannel);
gPrefRoot.addObserver(PREF_APP_UPDATE_CHANNEL, observer);
}
diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
index 4b12edf6f0..6374f82b52 100644
--- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
+++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
@@ -181,6 +181,7 @@ var gDebugTestLog = false;
var gTestsToLog = [];
var gRealDump;
var gFOS;
+var gUpdateBin;
var gTestFiles = [];
var gTestDirs = [];
@@ -189,6 +190,23 @@ var gTestDirs = [];
var gTestFilesCommon = [
{
description: "Should never change",
+ fileName: FILE_CHANNEL_PREFS,
+ relPathDir:
+ AppConstants.platform == "macosx"
+ ? "Contents/Frameworks/ChannelPrefs.framework/"
+ : DIR_RESOURCES + "defaults/pref/",
+ originalContents: "ShouldNotBeReplaced\n",
+ compareContents: "ShouldNotBeReplaced\n",
+ originalFile: null,
+ compareFile: null,
+ originalPerms: 0o767,
+ comparePerms: 0o767,
+ },
+];
+
+var gTestFilesCommonNonMac = [
+ {
+ description: "Should never change",
fileName: FILE_UPDATE_SETTINGS_INI,
relPathDir: DIR_RESOURCES,
originalContents: UPDATE_SETTINGS_CONTENTS,
@@ -198,19 +216,32 @@ var gTestFilesCommon = [
originalPerms: 0o767,
comparePerms: 0o767,
},
+];
+
+if (AppConstants.platform != "macosx") {
+ gTestFilesCommon = gTestFilesCommon.concat(gTestFilesCommonNonMac);
+}
+
+var gTestFilesCommonMac = [
{
description: "Should never change",
- fileName: "channel-prefs.js",
- relPathDir: DIR_RESOURCES + "defaults/pref/",
- originalContents: "ShouldNotBeReplaced\n",
- compareContents: "ShouldNotBeReplaced\n",
+ fileName: FILE_UPDATE_SETTINGS_FRAMEWORK,
+ relPathDir:
+ "Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework/",
+ originalContents: null,
+ compareContents: null,
originalFile: null,
compareFile: null,
- originalPerms: 0o767,
- comparePerms: 0o767,
+ originalPerms: null,
+ comparePerms: null,
+ existingFile: true,
},
];
+if (AppConstants.platform == "macosx") {
+ gTestFilesCommon = gTestFilesCommon.concat(gTestFilesCommonMac);
+}
+
// Files for a complete successful update. This can be used for a complete
// failed update by calling setTestFilesAndDirsForFailure.
var gTestFilesCompleteSuccess = [
@@ -657,6 +688,20 @@ var gTestFilesPartialSuccess = [
// Concatenate the common files to the end of the array.
gTestFilesPartialSuccess = gTestFilesPartialSuccess.concat(gTestFilesCommon);
+/**
+ * Searches `gTestFiles` for the file with the given filename. This is currently
+ * not very efficient (it searches the whole array every time).
+ *
+ * @param filename
+ * The name of the file to search for (i.e. the `fileName` attribute).
+ * @returns
+ * The object in `gTestFiles` that describes the requested file.
+ * Or `null`, if the file is not in `gTestFiles`.
+ */
+function getTestFileByName(filename) {
+ return gTestFiles.find(f => f.fileName == filename) ?? null;
+}
+
var gTestDirsCommon = [
{
relPathDir: DIR_RESOURCES + "3/",
@@ -2019,8 +2064,13 @@ function runUpdate(
Services.env.set("MOZ_TEST_SHORTER_WAIT_PID", "1");
}
- let updateBin = copyTestUpdaterToBinDir();
- Assert.ok(updateBin.exists(), MSG_SHOULD_EXIST + getMsgPath(updateBin.path));
+ if (!gUpdateBin) {
+ gUpdateBin = copyTestUpdaterToBinDir();
+ }
+ Assert.ok(
+ gUpdateBin.exists(),
+ MSG_SHOULD_EXIST + getMsgPath(gUpdateBin.path)
+ );
let updatesDirPath = aPatchDirPath || getUpdateDirFile(DIR_PATCH).path;
let installDirPath = aInstallDirPath || getApplyDirFile().path;
@@ -2045,13 +2095,13 @@ function runUpdate(
args[3] = pid;
}
- let launchBin = gIsServiceTest && isInvalidArgTest ? callbackApp : updateBin;
+ let launchBin = gIsServiceTest && isInvalidArgTest ? callbackApp : gUpdateBin;
if (!isInvalidArgTest) {
args = args.concat([callbackApp.parent.path, callbackApp.path]);
args = args.concat(gCallbackArgs);
} else if (gIsServiceTest) {
- args = ["launch-service", updateBin.path].concat(args);
+ args = ["launch-service", gUpdateBin.path].concat(args);
} else if (aCallbackPath) {
args = args.concat([callbackApp.parent.path, aCallbackPath]);
}
@@ -3125,6 +3175,13 @@ async function setupUpdaterTest(
helperBin.copyToFollowingLinks(afterApplyBinDir, gCallbackBinFile);
helperBin.copyToFollowingLinks(afterApplyBinDir, gPostUpdateBinFile);
+ // On macOS, some test files (like the Update Settings file) may be within the
+ // updater app bundle, so make sure it is in place now in case we want to
+ // manipulate it.
+ if (!gUpdateBin) {
+ gUpdateBin = copyTestUpdaterToBinDir();
+ }
+
gTestFiles.forEach(function SUT_TF_FE(aTestFile) {
debugDump("start - setup test file: " + aTestFile.fileName);
if (aTestFile.originalFile || aTestFile.originalContents) {
@@ -3163,6 +3220,24 @@ async function setupUpdaterTest(
aTestFile.comparePerms = testFile.permissions;
}
}
+ } else if (aTestFile.existingFile) {
+ const testFile = getApplyDirFile(
+ aTestFile.relPathDir + aTestFile.fileName
+ );
+ if (aTestFile.removeOriginalFile) {
+ testFile.remove(false);
+ } else {
+ const fileContents = readFileBytes(testFile);
+ if (!aTestFile.originalContents && !aTestFile.originalFile) {
+ aTestFile.originalContents = fileContents;
+ }
+ if (!aTestFile.compareContents && !aTestFile.compareFile) {
+ aTestFile.compareContents = fileContents;
+ }
+ if (!aTestFile.comparePerms) {
+ aTestFile.comparePerms = testFile.permissions;
+ }
+ }
}
debugDump("finish - setup test file: " + aTestFile.fileName);
});
@@ -3424,21 +3499,13 @@ function checkUpdateLogContents(
// Remove leading timestamps
updateLogContents = removeTimeStamps(updateLogContents);
- // The channel-prefs.js is defined in gTestFilesCommon which will always be
- // located to the end of gTestFiles when it is present.
- if (
- gTestFiles.length > 1 &&
- gTestFiles[gTestFiles.length - 1].fileName == "channel-prefs.js" &&
- !gTestFiles[gTestFiles.length - 1].originalContents
- ) {
+ const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS);
+ if (channelPrefs && !channelPrefs.originalContents) {
updateLogContents = updateLogContents.replace(/.*defaults\/.*/g, "");
}
- if (
- gTestFiles.length > 2 &&
- gTestFiles[gTestFiles.length - 2].fileName == FILE_UPDATE_SETTINGS_INI &&
- !gTestFiles[gTestFiles.length - 2].originalContents
- ) {
+ const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_INI);
+ if (updateSettings && !updateSettings.originalContents) {
updateLogContents = updateLogContents.replace(
/.*update-settings.ini.*/g,
""
@@ -3529,21 +3596,11 @@ function checkUpdateLogContents(
// Remove leading timestamps
compareLogContents = removeTimeStamps(compareLogContents);
- // The channel-prefs.js is defined in gTestFilesCommon which will always be
- // located to the end of gTestFiles.
- if (
- gTestFiles.length > 1 &&
- gTestFiles[gTestFiles.length - 1].fileName == "channel-prefs.js" &&
- !gTestFiles[gTestFiles.length - 1].originalContents
- ) {
+ if (channelPrefs && !channelPrefs.originalContents) {
compareLogContents = compareLogContents.replace(/.*defaults\/.*/g, "");
}
- if (
- gTestFiles.length > 2 &&
- gTestFiles[gTestFiles.length - 2].fileName == FILE_UPDATE_SETTINGS_INI &&
- !gTestFiles[gTestFiles.length - 2].originalContents
- ) {
+ if (updateSettings && !updateSettings.originalContents) {
compareLogContents = compareLogContents.replace(
/.*update-settings.ini.*/g,
""
@@ -4879,3 +4936,33 @@ function resetEnvironment() {
Services.env.set("MOZ_NO_SERVICE_FALLBACK", "");
}
}
+
+/**
+ * `gTestFiles` needs to be set such that it contains the Update Settings file
+ * before this function is called.
+ */
+function setUpdateSettingsUseWrongChannel() {
+ if (AppConstants.platform == "macosx") {
+ let replacementUpdateSettings = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
+ replacementUpdateSettings = replacementUpdateSettings.parent;
+ replacementUpdateSettings.append("UpdateSettings-WrongChannel");
+
+ const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_FRAMEWORK);
+ if (!updateSettings) {
+ throw new Error(
+ "gTestFiles does not contain the update settings framework"
+ );
+ }
+ updateSettings.existingFile = false;
+ updateSettings.originalContents = readFileBytes(replacementUpdateSettings);
+ } else {
+ const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_INI);
+ if (!updateSettings) {
+ throw new Error("gTestFiles does not contain the update settings INI");
+ }
+ updateSettings.originalContents = UPDATE_SETTINGS_CONTENTS.replace(
+ "xpcshell-test",
+ "wrong-channel"
+ );
+ }
+}
diff --git a/toolkit/mozapps/update/tests/unit_aus_update/languagePackUpdates.js b/toolkit/mozapps/update/tests/unit_aus_update/languagePackUpdates.js
index 9e23fab5e0..1e27efb753 100644
--- a/toolkit/mozapps/update/tests/unit_aus_update/languagePackUpdates.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/languagePackUpdates.js
@@ -177,9 +177,12 @@ add_task(async function testLangpackStaged() {
copyTestUpdaterToBinDir();
let greDir = getGREDir();
- let updateSettingsIni = greDir.clone();
- updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
- writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
+
+ if (AppConstants.platform != "macosx") {
+ let updateSettingsIni = greDir.clone();
+ updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
+ writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
+ }
await downloadUpdate();
diff --git a/toolkit/mozapps/update/tests/unit_aus_update/verifyChannelPrefsFile.js b/toolkit/mozapps/update/tests/unit_aus_update/verifyChannelPrefsFile.js
deleted file mode 100644
index 4cca77c73d..0000000000
--- a/toolkit/mozapps/update/tests/unit_aus_update/verifyChannelPrefsFile.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/* 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/.
- */
-
-/**
- * This test exists solely to ensure that channel-prefs.js is not changed.
- * If it does get changed, it will cause a variation of Bug 1431342.
- * To summarize, our updater doesn't update that file. But, on macOS, it is
- * still used to compute the application's signature. This means that if Firefox
- * updates and that file has been changed, the signature no will no longer
- * validate.
- */
-
-const expectedChannelPrefsContents = `/* 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/. */
-//
-// This pref is in its own file for complex reasons. See the comment in
-// browser/app/Makefile.in, bug 756325, and bug 1431342 for details. Do not add
-// other prefs to this file.
-
-pref("app.update.channel", "${UpdateUtils.UpdateChannel}");
-`;
-
-async function run_test() {
- let channelPrefsFile = Services.dirsvc.get("GreD", Ci.nsIFile);
- channelPrefsFile.append("defaults");
- channelPrefsFile.append("pref");
- channelPrefsFile.append("channel-prefs.js");
-
- const contents = await IOUtils.readUTF8(channelPrefsFile.path);
- Assert.equal(
- contents,
- expectedChannelPrefsContents,
- "Channel Prefs file should should not change"
- );
-}
diff --git a/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.toml b/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.toml
index 74790016e4..160427ac5e 100644
--- a/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.toml
+++ b/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.toml
@@ -83,7 +83,3 @@ reason = "Update directory migration is currently Windows only"
["urlConstruction.js"]
skip-if = ["socketprocess_networking"] # Bug 1759035
-
-["verifyChannelPrefsFile.js"]
-run-if = ["appname == 'firefox'"]
-reason = "File being verified is Firefox-specific."
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);
diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js
index de8db067bc..379fb00a27 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.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_service_updater/marFileInUseStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js
index b93b023934..11181f4420 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_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_service_updater/marFileInUseStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js
index b41da12396..def7f8db9c 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_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_service_updater/marFileInUseSuccessCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js
index 4b946ac3e4..d1f938bb02 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_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_service_updater/marFileInUseSuccessPartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js
index 15c3a1121a..f851c543a6 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_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_service_updater/marFileLockedFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js
index 698ccb7fe5..5517d5ed81 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_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_service_updater/marFileLockedFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_win.js
index c8c019ec5c..03eb6122c8 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailurePartialSvc_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_service_updater/marFileLockedStageFailureCompleteSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js
index 7b582dbd45..4d5fe599cf 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_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_service_updater/marFileLockedStageFailurePartialSvc_win.js b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js
index bf3abd8c37..3d4a8e0c51 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_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_service_updater/marStageFailurePartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.js
index a1a0de0fe4..47c184e67b 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageFailurePartialSvc.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_service_updater/marStageSuccessCompleteSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
index 943a45ba95..2c9c3298d4 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.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_service_updater/marStageSuccessPartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js
index dd5c240919..e565ffe550 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.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_service_updater/marSuccessPartialSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js
index 8e8e9d094a..f4f856278c 100644
--- a/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.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.