summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/update/tests/data
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/data
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/data')
-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
5 files changed, 143 insertions, 37 deletions
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"
+ );
+ }
+}