From bd7e0ac24a6fb1cddde3e45ea191b7abcc90cf56 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Tue, 16 Apr 2024 02:51:31 +0000 Subject: [PATCH] Bug 1890764 - Backout macOS framework changes from Firefox 125. a=RyanVM Backed out changeset 937a51dbe70c (bug 1883775) Backed out changeset d88ec0d14b41 (bug 1883123) Backed out changeset 49cc33ed1599 (bug 1883123) Backed out changeset b6dff3a3d41b (bug 1882228) Backed out changeset 62677f25e495 (bug 1881662) Backed out changeset ac4d7c08648c (bug 1881635) Backed out changeset 3157eece201c (bug 1881360) Backed out changeset c676fc5d89bc (bug 1848414) Backed out changeset 5c6748ef5865 (bug 1848414) Backed out changeset 672c3f18cb8b (bug 1848414) Backed out changeset 2f4044201b9a (bug 1848414) Backed out changeset ff5f23856542 (bug 1848414) Backed out changeset f81e80cf062f (bug 1848414) Backed out changeset d711a830a93e (bug 1848414) Backed out changeset 62ab286ed401 (bug 1848414) Backed out changeset 24143ec374ff (bug 1854868) Backed out changeset 9c11a87d38fc (bug 1854868) Backed out changeset d7341669eb0b (bug 1854868) Backed out changeset b9753f244f18 (bug 1854868) Backed out changeset 1e094e3ca992 (bug 1799332) Backed out changeset 62d28922bd23 (bug 1799332) Backed out changeset c7aa9b74be01 (bug 1799332) Backed out changeset d8dd28c68304 (bug 1799332) Backed out changeset a50eb05b0b0b (bug 1799332) Backed out changeset 21e9f01c0021 (bug 1882322) Differential Revision: https://phabricator.services.mozilla.com/D207508 --- browser/app/Makefile.in | 14 +- .../browser_startup_mainthreadio.js | 1 - browser/installer/package-manifest.in | 7 - browser/installer/removed-files.in | 12 -- build/moz.build | 5 +- config/createprecomplete.py | 6 +- .../test/marionette/test_autoconfig.py | 8 +- modules/libpref/Preferences.cpp | 25 --- python/mozbuild/mozbuild/artifacts.py | 68 ++++---- taskcluster/ci/config.yml | 6 +- taskcluster/ci/diffoscope/artifacts.yml | 2 +- .../unit/test_TelemetryReportingPolicy.js | 6 - toolkit/library/moz.build | 4 - .../test_UpdateUtils_updatechannel.js | 1 - .../tests/xpcshell/test_UpdateUtils_url.js | 1 - toolkit/moz.build | 1 - .../ChannelPrefs/ChannelPrefs.h | 17 -- .../ChannelPrefs/ChannelPrefs.mm | 12 -- .../macos-frameworks/ChannelPrefs/Info.plist | 24 --- .../macos-frameworks/ChannelPrefs/Makefile.in | 14 -- .../macos-frameworks/ChannelPrefs/README.md | 70 -------- .../macos-frameworks/ChannelPrefs/moz.build | 22 --- .../macos-frameworks/ChannelPrefsUtil.h | 16 -- .../macos-frameworks/ChannelPrefsUtil.mm | 26 --- toolkit/mozapps/macos-frameworks/moz.build | 22 --- toolkit/mozapps/update/common/readstrings.cpp | 75 ++++----- toolkit/mozapps/update/common/readstrings.h | 9 - toolkit/mozapps/update/tests/browser/head.js | 12 +- toolkit/mozapps/update/tests/data/README.md | 15 -- .../update/tests/data/complete_mac.mar | Bin 87143 -> 87129 bytes .../mozapps/update/tests/data/partial_mac.mar | Bin 10351 -> 10361 bytes toolkit/mozapps/update/tests/data/shared.js | 10 +- .../update/tests/data/xpcshellUtilsAUS.js | 155 ++++-------------- .../unit_aus_update/languagePackUpdates.js | 9 +- .../unit_aus_update/verifyChannelPrefsFile.js | 38 +++++ .../tests/unit_aus_update/xpcshell.toml | 4 + .../marAppInUseStageSuccessComplete_unix.js | 9 +- .../unit_base_updater/marFailurePartial.js | 2 +- .../marFileInUseStageFailureComplete_win.js | 6 +- .../marFileInUseStageFailurePartial_win.js | 6 +- .../marFileInUseSuccessComplete_win.js | 6 +- .../marFileInUseSuccessPartial_win.js | 6 +- .../marFileLockedFailureComplete_win.js | 2 +- .../marFileLockedFailurePartial_win.js | 2 +- .../marFileLockedStageFailureComplete_win.js | 2 +- .../marFileLockedStageFailurePartial_win.js | 2 +- .../marMissingUpdateSettings.js | 12 +- .../marMissingUpdateSettingsStage.js | 12 +- .../marStageFailurePartial.js | 2 +- .../marStageSuccessComplete.js | 7 +- .../marStageSuccessPartial.js | 7 +- .../unit_base_updater/marSuccessPartial.js | 7 +- ...uccessPartialWhileBackgroundTaskRunning.js | 3 +- .../unit_base_updater/marWrongChannel.js | 3 +- .../unit_base_updater/marWrongChannelStage.js | 3 +- .../marFailurePartialSvc.js | 2 +- ...marFileInUseStageFailureCompleteSvc_win.js | 6 +- .../marFileInUseStageFailurePartialSvc_win.js | 6 +- .../marFileInUseSuccessCompleteSvc_win.js | 6 +- .../marFileInUseSuccessPartialSvc_win.js | 6 +- .../marFileLockedFailureCompleteSvc_win.js | 2 +- .../marFileLockedFailurePartialSvc_win.js | 2 +- ...arFileLockedStageFailureCompleteSvc_win.js | 2 +- ...marFileLockedStageFailurePartialSvc_win.js | 2 +- .../marStageFailurePartialSvc.js | 2 +- .../marStageSuccessCompleteSvc.js | 7 +- .../marStageSuccessPartialSvc.js | 7 +- .../marSuccessPartialSvc.js | 7 +- toolkit/mozapps/update/updater/Makefile.in | 3 - .../UpdateSettings-WrongChannel/moz.build | 18 -- .../UpdateSettings-xpcshell/moz.build | 18 -- .../UpdateSettings/Info.plist | 24 --- .../macos-frameworks/UpdateSettings/README.md | 77 --------- .../UpdateSettings/UpdateSettings.h | 17 -- .../UpdateSettings/UpdateSettings.mm | 13 -- .../macos-frameworks/UpdateSettings/moz.build | 24 --- .../macos-frameworks/UpdateSettingsUtil.h | 17 -- .../macos-frameworks/UpdateSettingsUtil.mm | 21 --- .../update/updater/macos-frameworks/moz.build | 18 -- toolkit/mozapps/update/updater/moz.build | 3 - .../update/updater/updater-common.build | 13 +- .../updater/updater-xpcshell/Makefile.in | 4 - toolkit/mozapps/update/updater/updater.cpp | 88 +++------- tools/update-packaging/common.sh | 10 +- .../release/common/check_updates.sh | 31 +--- tools/update-verify/release/common/unpack.sh | 24 +-- .../release/compare-directories.py | 38 ++--- tools/update-verify/release/updates/verify.sh | 20 +-- 88 files changed, 278 insertions(+), 1076 deletions(-) delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.h delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.mm delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefs/Info.plist delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefs/Makefile.in delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefs/README.md delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefs/moz.build delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.h delete mode 100644 toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.mm delete mode 100644 toolkit/mozapps/macos-frameworks/moz.build delete mode 100644 toolkit/mozapps/update/tests/data/README.md create mode 100644 toolkit/mozapps/update/tests/unit_aus_update/verifyChannelPrefsFile.js delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-WrongChannel/moz.build delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-xpcshell/moz.build delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/Info.plist delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/README.md delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.h delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.mm delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/moz.build delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.h delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.mm delete mode 100644 toolkit/mozapps/update/updater/macos-frameworks/moz.build diff --git a/browser/app/Makefile.in b/browser/app/Makefile.in index 08490ba27ca2c..7a09bc249462e 100644 --- a/browser/app/Makefile.in +++ b/browser/app/Makefile.in @@ -50,17 +50,14 @@ endif endif -ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) - -# channel-prefs.js has been removed on macOS. -# channel-prefs.js is handled separately from other prefs due to bug 756325. +# channel-prefs.js is handled separate from other prefs due to bug 756325 # DO NOT change the content of channel-prefs.js without taking the appropriate # steps. See bug 1431342. libs:: $(srcdir)/profile/channel-prefs.js $(NSINSTALL) -D $(DIST)/bin/defaults/pref $(call py_action,preprocessor channel-prefs.js,-Fsubstitution $(PREF_PPFLAGS) $(ACDEFINES) $^ -o $(DIST)/bin/defaults/pref/channel-prefs.js) -else +ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) MAC_APP_NAME = $(MOZ_APP_DISPLAYNAME) @@ -84,7 +81,7 @@ MAC_BUNDLE_VERSION = $(shell $(PYTHON3) $(srcdir)/macversion.py --version=$(MOZ_ .PHONY: repackage tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME) $(objdir)/macbuild/Contents/MacOS-files.txt - rm -rf '$(dist_dest)' + rm -rf $(dist_dest) $(MKDIR) -p '$(dist_dest)/Contents/MacOS' $(MKDIR) -p '$(dist_dest)/$(LPROJ)' rsync -a --exclude '*.in' $(srcdir)/macbuild/Contents '$(dist_dest)' --exclude English.lproj @@ -102,9 +99,8 @@ tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME) $(objdir)/macbuild/Contents/MacOS- cp -RL $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/document.icns '$(dist_dest)/Contents/Resources/document.icns' $(MKDIR) -p '$(dist_dest)/Contents/Library/LaunchServices' ifdef MOZ_UPDATER - cp -f '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater' '$(dist_dest)/Contents/Library/LaunchServices' + mv -f '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater' '$(dist_dest)/Contents/Library/LaunchServices' + ln -s ../../../../Library/LaunchServices/org.mozilla.updater '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater' endif - $(MKDIR) -p '$(dist_dest)/Contents/Frameworks' - mv '$(dist_dest)/Contents/Resources/ChannelPrefs.framework' '$(dist_dest)/Contents/Frameworks' printf APPLMOZB > '$(dist_dest)/Contents/PkgInfo' endif diff --git a/browser/base/content/test/performance/browser_startup_mainthreadio.js b/browser/base/content/test/performance/browser_startup_mainthreadio.js index a89a068f130a3..b65ede26d5edf 100644 --- a/browser/base/content/test/performance/browser_startup_mainthreadio.js +++ b/browser/base/content/test/performance/browser_startup_mainthreadio.js @@ -189,7 +189,6 @@ const startupPhases = { { // bug 1541601 path: "PrfDef:channel-prefs.js", - condition: !MAC, stat: 1, read: 1, close: 1, diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index c35f5bc4fbdfa..1b87a9ab4aec9 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -38,7 +38,6 @@ #ifdef MOZ_UPDATER @APPNAME@/Contents/Library/LaunchServices #endif -@APPNAME@/Contents/Frameworks @APPNAME@/Contents/PkgInfo @RESPATH@/firefox.icns @RESPATH@/document.icns @@ -142,11 +141,8 @@ #endif @RESPATH@/application.ini #ifdef MOZ_UPDATER -# update-settings.ini has been removed on macOS. -#ifndef XP_MACOSX @RESPATH@/update-settings.ini #endif -#endif @RESPATH@/platform.ini #ifndef MOZ_FOLD_LIBS @BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@ @@ -254,13 +250,10 @@ @RESPATH@/browser/defaults/settings/main @RESPATH@/browser/defaults/settings/security-state -# channel-prefs.js has been removed on macOS. -#ifndef XP_MACOSX ; Warning: changing the path to channel-prefs.js can cause bugs (Bug 756325) ; Technically this is an app pref file, but we are keeping it in the original ; gre location for now. @RESPATH@/defaults/pref/channel-prefs.js -#endif ; Background tasks-specific preferences. ; These are in the GRE location since they apply to all tasks at this time. diff --git a/browser/installer/removed-files.in b/browser/installer/removed-files.in index ec9b6b075a346..425978a5eb6c4 100644 --- a/browser/installer/removed-files.in +++ b/browser/installer/removed-files.in @@ -72,15 +72,3 @@ @DIR_RESOURCES@chrome.manifest #endif #endif - -# channel-prefs.js has been removed on macOS. -#ifdef XP_MACOSX -@DIR_RESOURCES@defaults/pref/channel-prefs.js -@DIR_RESOURCES@defaults/pref/ -@DIR_RESOURCES@defaults/ -#endif - -# update-settings.ini has been removed on macOS. -#ifdef XP_MACOSX -@DIR_RESOURCES@update-settings.ini -#endif diff --git a/build/moz.build b/build/moz.build index 7bf9c501db06d..a5f4144b0c132 100644 --- a/build/moz.build +++ b/build/moz.build @@ -107,10 +107,7 @@ if CONFIG["MOZ_APP_BASENAME"]: ) FINAL_TARGET_FILES += ["!application.ini"] - if ( - CONFIG["MOZ_WIDGET_TOOLKIT"] not in ("android", "cocoa") - and CONFIG["MOZ_UPDATER"] - ): + if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android" and CONFIG["MOZ_UPDATER"]: FINAL_TARGET_PP_FILES += ["update-settings.ini"] GeneratedFile( diff --git a/config/createprecomplete.py b/config/createprecomplete.py index f3ac8c67136b3..8c5fceefaa657 100644 --- a/config/createprecomplete.py +++ b/config/createprecomplete.py @@ -24,11 +24,7 @@ def get_build_entries(root_path): if not ( rel_path_file.endswith("channel-prefs.js") or rel_path_file.endswith("update-settings.ini") - or "/ChannelPrefs.framework/" in rel_path_file - or rel_path_file.startswith("ChannelPrefs.framework/") - or "/UpdateSettings.framework/" in rel_path_file - or rel_path_file.startswith("UpdateSettings.framework/") - or "distribution/" in rel_path_file + or rel_path_file.find("distribution/") != -1 ): rel_file_path_set.add(rel_path_file) diff --git a/extensions/pref/autoconfig/test/marionette/test_autoconfig.py b/extensions/pref/autoconfig/test/marionette/test_autoconfig.py index 778ef5699d98d..0cdc0feede44d 100644 --- a/extensions/pref/autoconfig/test/marionette/test_autoconfig.py +++ b/extensions/pref/autoconfig/test/marionette/test_autoconfig.py @@ -16,8 +16,6 @@ def tearDown(self): os.remove(self.pref_file) if hasattr(self, "autoconfig_file"): os.remove(self.autoconfig_file) - if hasattr(self, "pref_file_dir_created"): - os.rmdir(self.pref_file_dir) super(TestAutoConfig, self).tearDown() @@ -50,11 +48,7 @@ def test_autoconfig(self): self.marionette.quit() test_dir = os.path.dirname(__file__) - self.pref_file_dir = os.path.join(self.exe_dir, "defaults", "pref") - if not os.path.exists(self.pref_file_dir): - os.makedirs(self.pref_file_dir, exist_ok=True) - self.pref_file_dir_created = True - self.pref_file = os.path.join(self.pref_file_dir, "autoconfig.js") + self.pref_file = os.path.join(self.exe_dir, "defaults", "pref", "autoconfig.js") shutil.copyfile(os.path.join(test_dir, "autoconfig.js"), self.pref_file) self.autoconfig_file = os.path.join(self.exe_dir, "autoconfig.cfg") shutil.copyfile(os.path.join(test_dir, "autoconfig.cfg"), self.autoconfig_file) diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 8387796571395..47759ffadcba2 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -112,10 +112,6 @@ # include "mozilla/WidgetUtilsGtk.h" #endif // defined(MOZ_WIDGET_GTK) -#ifdef MOZ_WIDGET_COCOA -# include "ChannelPrefsUtil.h" -#endif - using namespace mozilla; using ipc::FileDescriptor; @@ -4848,27 +4844,6 @@ nsresult Preferences::InitInitialObjects(bool aIsStartup) { NS_WARNING("Error parsing application default preferences."); } -#ifdef MOZ_WIDGET_COCOA - // On macOS, channel-prefs.js is no longer bundled with the application and - // the "app.update.channel" pref is now read from a Framework instead. - // Previously, channel-prefs.js was read as one of the files in - // NS_APP_PREF_DEFAULTS_50_DIR (see just above). See bug 1799332 for more - // info. - nsAutoCString appUpdatePrefKey; - appUpdatePrefKey.Assign(kChannelPref); - nsAutoCString appUpdatePrefValue; - PrefValue channelPrefValue; - channelPrefValue.mStringVal = MOZ_STRINGIFY(MOZ_UPDATE_CHANNEL); - if (ChannelPrefsUtil::GetChannelPrefValue(appUpdatePrefValue)) { - channelPrefValue.mStringVal = appUpdatePrefValue.get(); - } - pref_SetPref(appUpdatePrefKey, PrefType::String, PrefValueKind::Default, - channelPrefValue, - /* isSticky */ false, - /* isLocked */ true, - /* fromInit */ true); -#endif - // Load jar:$app/omni.jar!/defaults/preferences/*.js // or jar:$gre/omni.jar!/defaults/preferences/*.js. RefPtr appJarReader = Omnijar::GetReader(Omnijar::APP); diff --git a/python/mozbuild/mozbuild/artifacts.py b/python/mozbuild/mozbuild/artifacts.py index eff16f6c9bba4..a4d186816af4d 100644 --- a/python/mozbuild/mozbuild/artifacts.py +++ b/python/mozbuild/mozbuild/artifacts.py @@ -646,38 +646,26 @@ class MacArtifactJob(ArtifactJob): # These get copied into dist/bin without the path, so "root/a/b/c" -> "dist/bin/c". _paths_no_keep_path = ( - ( - "Contents/MacOS", - [ - "crashreporter.app/Contents/MacOS/crashreporter", - "{product}", - "{product}-bin", - "*.dylib", - "minidump-analyzer", - "nmhproxy", - "pingsender", - "plugin-container.app/Contents/MacOS/plugin-container", - "updater.app/Contents/Frameworks/UpdateSettings.framework/UpdateSettings", - "updater.app/Contents/MacOS/org.mozilla.updater", - # 'xpcshell', - "XUL", - ], - ), - ( - "Contents/Frameworks", - [ - "ChannelPrefs.framework/ChannelPrefs", - ], - ), + "Contents/MacOS", + [ + "crashreporter.app/Contents/MacOS/crashreporter", + "{product}", + "{product}-bin", + "*.dylib", + "minidump-analyzer", + "nmhproxy", + "pingsender", + "plugin-container.app/Contents/MacOS/plugin-container", + "updater.app/Contents/MacOS/org.mozilla.updater", + # 'xpcshell', + "XUL", + ], ) @property def paths_no_keep_path(self): - formatted = [] - for root, paths in self._paths_no_keep_path: - formatted.append((root, [p.format(product=self.product) for p in paths])) - - return tuple(formatted) + root, paths = self._paths_no_keep_path + return (root, [p.format(product=self.product) for p in paths]) @contextmanager def get_writer(self, **kwargs): @@ -738,18 +726,18 @@ def process_package_artifact(self, filename, processed_filename): ] with self.get_writer(file=processed_filename, compress_level=5) as writer: - for root, paths in self.paths_no_keep_path: - finder = UnpackFinder(mozpath.join(source, root)) - for path in paths: - for p, f in finder.find(path): - self.log( - logging.DEBUG, - "artifact", - {"path": p}, - "Adding {path} to processed archive", - ) - destpath = mozpath.join("bin", os.path.basename(p)) - writer.add(destpath.encode("utf-8"), f.open(), mode=f.mode) + root, paths = self.paths_no_keep_path + finder = UnpackFinder(mozpath.join(source, root)) + for path in paths: + for p, f in finder.find(path): + self.log( + logging.DEBUG, + "artifact", + {"path": p}, + "Adding {path} to processed archive", + ) + destpath = mozpath.join("bin", os.path.basename(p)) + writer.add(destpath.encode("utf-8"), f.open(), mode=f.mode) for root, paths in paths_keep_path: finder = UnpackFinder(mozpath.join(source, root)) diff --git a/taskcluster/ci/config.yml b/taskcluster/ci/config.yml index 6131c9a14255e..894ce9399a811 100644 --- a/taskcluster/ci/config.yml +++ b/taskcluster/ci/config.yml @@ -790,10 +790,9 @@ mac-signing: - deep: false runtime: true force: true - # These files are signed without entitlements + # These files are signed wihtout entitlements globs: - "/Contents/MacOS/crashreporter.app" - - "/Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework" - "/Contents/MacOS/updater.app" - "/Contents/Library/LaunchServices/org.mozilla.updater" - "/Contents/MacOS/XUL" @@ -802,7 +801,6 @@ mac-signing: - "/Contents/MacOS/nmhproxy" - "/Contents/MacOS/*.dylib" - "/Contents/Resources/gmp-clearkey/*/*.dylib" - - "/Contents/Frameworks/ChannelPrefs.framework" - deep: false runtime: true @@ -838,13 +836,11 @@ mac-signing: entitlements: security/mac/hardenedruntime/v2/developer/utility.xml globs: - "/Contents/MacOS/crashreporter.app" - - "/Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework" - "/Contents/MacOS/updater.app" - "/Contents/Library/LaunchServices/org.mozilla.updater" - "/Contents/MacOS/pingsender" - "/Contents/MacOS/minidump-analyzer" - "/Contents/MacOS/nmhproxy" - - "/Contents/Frameworks/ChannelPrefs.framework" - deep: false runtime: true diff --git a/taskcluster/ci/diffoscope/artifacts.yml b/taskcluster/ci/diffoscope/artifacts.yml index b06604f3cbcd3..0e901f50fd218 100644 --- a/taskcluster/ci/diffoscope/artifacts.yml +++ b/taskcluster/ci/diffoscope/artifacts.yml @@ -18,7 +18,7 @@ job-defaults: # artifact and not-artifact builds, so remove its line if present. - sed -i '/telemetry\.fog\.artifact\_build/d' b/"$RESOURCE_DIR"/browser/defaults/preferences/firefox.js # artifact builds are not fed with accepted-mar-channel-ids - - if [ -f a/"$RESOURCE_DIR"/update-settings.ini ]; then sed -i '/ACCEPTED_MAR_CHANNEL_IDS/d' {a,b}/"$RESOURCE_DIR"/update-settings.ini; fi + - sed -i '/ACCEPTED_MAR_CHANNEL_IDS/d' {a,b}/"$RESOURCE_DIR"/update-settings.ini # Extra diffoscope arguments to account for: # - about:buildconfig being expectedly different. extra-args: >- diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryReportingPolicy.js b/toolkit/components/telemetry/tests/unit/test_TelemetryReportingPolicy.js index df5dc151add7e..01041172d0569 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryReportingPolicy.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryReportingPolicy.js @@ -199,12 +199,6 @@ add_task(async function test_prefs() { "Accepting the policy again should let us upload data." ); - // macOS has the app.update.channel pref locked. Check if it needs to be - // unlocked before proceeding with the test. - if (Services.prefs.getDefaultBranch("").prefIsLocked("app.update.channel")) { - Services.prefs.getDefaultBranch("").unlockPref("app.update.channel"); - } - // Set a new, per channel, minimum policy version. Start by setting a test current channel. Services.prefs .getDefaultBranch("") diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index ad011b4044bbd..185d5f74d0f04 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -100,7 +100,6 @@ def Libxul(name, output_category=None): LDFLAGS += ["-Wl,-U,_OBJC_CLASS_$_NSCustomTouchBarItem"] LDFLAGS += ["-Wl,-U,_OBJC_CLASS_$_NSPopoverTouchBarItem"] LDFLAGS += ["-lresolv"] - LDFLAGS += ["-Wl,-rpath,@executable_path/../Frameworks/ChannelPrefs.framework"] if CONFIG["MOZ_DEBUG_SYMBOLS"] and CONFIG["CC_TYPE"] == "clang-cl": LDFLAGS += ["-NATVIS:%s/toolkit/library/gecko.natvis" % TOPSRCDIR] @@ -233,9 +232,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": "-framework CoreSymbolication", "cups", ] - USE_LIBS += [ - "ChannelPrefs", - ] if CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit": OS_LIBS += [ diff --git a/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js b/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js index 2dc4654492bda..81db867ba44da 100644 --- a/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js +++ b/toolkit/modules/tests/xpcshell/test_UpdateUtils_updatechannel.js @@ -25,7 +25,6 @@ add_task(async function test_updatechannel() { Assert.equal(UpdateUtils.getUpdateChannel(true), currentChannel); Assert.equal(UpdateUtils.getUpdateChannel(false), currentChannel); - defaultPrefs.unlock(PREF_APP_UPDATE_CHANNEL); defaultPrefs.set(PREF_APP_UPDATE_CHANNEL, TEST_CHANNEL); Assert.equal(UpdateUtils.UpdateChannel, TEST_CHANNEL); Assert.equal(UpdateUtils.getUpdateChannel(true), TEST_CHANNEL); diff --git a/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js b/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js index b8618291f8b58..00176a5f3a52c 100644 --- a/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js +++ b/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js @@ -34,7 +34,6 @@ const gAppInfo = getAppInfo(); const gDefaultPrefBranch = Services.prefs.getDefaultBranch(null); function setUpdateChannel(aChannel) { - gDefaultPrefBranch.unlockPref(PREF_APP_UPDATE_CHANNEL); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, aChannel); } diff --git a/toolkit/moz.build b/toolkit/moz.build index e60f9c586bf3e..30ec614ef1962 100644 --- a/toolkit/moz.build +++ b/toolkit/moz.build @@ -55,7 +55,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": DIRS += ["system/unixproxy"] elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": DIRS += [ - "mozapps/macos-frameworks", "system/commonproxy", "system/osxproxy", ] diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.h b/toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.h deleted file mode 100644 index 670fa2e091610..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.h +++ /dev/null @@ -1,17 +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/. */ - -#ifndef ChannelPrefs_h_ -#define ChannelPrefs_h_ - -#import - -extern "C" { - -// Returns the channel name, as an autoreleased string. -extern NSString* ChannelPrefsGetChannel(void) __attribute__((weak_import)) -__attribute__((visibility("default"))); -} - -#endif // ChannelPrefs_h_ diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.mm b/toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.mm deleted file mode 100644 index f437bb857d4a1..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefs/ChannelPrefs.mm +++ /dev/null @@ -1,12 +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/. */ - -#include "ChannelPrefs.h" - -#include "mozilla/HelperMacros.h" - -NSString* ChannelPrefsGetChannel() { - return [NSString stringWithCString:MOZ_STRINGIFY(MOZ_UPDATE_CHANNEL) - encoding:NSUTF8StringEncoding]; -} diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefs/Info.plist b/toolkit/mozapps/macos-frameworks/ChannelPrefs/Info.plist deleted file mode 100644 index f7ce763d7526a..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefs/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ChannelPrefs - CFBundleIdentifier - org.mozilla.channelprefs - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ChannelPrefs - CFBundlePackageType - FMWK - CFBundleSignature - ???? - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1.0 - - diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefs/Makefile.in b/toolkit/mozapps/macos-frameworks/ChannelPrefs/Makefile.in deleted file mode 100644 index 43552a771e590..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefs/Makefile.in +++ /dev/null @@ -1,14 +0,0 @@ -# vim:set ts=8 sw=8 sts=8 noet: -# 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/. - -include $(topsrcdir)/config/rules.mk - -ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) -libs:: - rm -rf $(DIST)/bin/ChannelPrefs.framework - - $(NSINSTALL) $(DIST)/bin/ChannelPrefs $(DIST)/bin/ChannelPrefs.framework - $(NSINSTALL) $(srcdir)/Info.plist $(DIST)/bin/ChannelPrefs.framework/Resources -endif diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefs/README.md b/toolkit/mozapps/macos-frameworks/ChannelPrefs/README.md deleted file mode 100644 index a6285323f6d15..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefs/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# ChannelPrefs macOS Framework - -## Summary - -The ChannelPrefs macOS Framework is used to initialize the `app.update.channel` -pref during startup. - -## What is `app.update.channel` and what is it used for? - -`app.update.channel` is used to set the download channel for application -updates. - -## Why do we need a Framework instead of compiling the download channel directly into the executable? - -There are three main use cases that make it necessary for the -`app.update.channel` pref to be set by external means, such as a macOS -Framework: - - 1. Allowing users on the Beta channel to test RC builds - -Beta users have their update channel set to 'beta'. However, RC builds by -definition have their channel set to `release`, since these are release -candidates that could get released to our release population. If we were to -indiscriminately update our Beta users to an RC build, we would lose our entire -Beta population since everyone would get switched to the `release` channel. - - 2. Switching users to another channel, such as ESR - -In contrast to the Beta use case outlined above, there are times where we -explicitly WANT to switch users to a different channel. An example of this is -when hardware or a particular macOS version have reached their EOL. In this -case, we usually switch users to our ESR channel for extended support. - - 3. QA update testing - -QA requires a way to temporarily switch the update channel to a test channel in -order to test updates before new releases. - -## How does the ChannelPrefs macOS Framework address these use cases? - -We are able to accommodate all three use cases above by enabling the updater to -ignore certain files on disk if they were already present, but continue to force -update them if so desired. - -In the case of a Beta user updating to an RC build, the updater would encounter -a ChannelPrefs macOS Framework inside the .app bundle that has an update channel -of `beta`. In this case, the updater will not update the Framework, but update -everything else. This beta user is now able to run the RC build with the update -channel still set to `beta`. - -In the case of switching users to the ESR channel, the updater will be set to -forcefully update the ChannelPrefs macOS Framework, even if already present on -disk. After the update, the user will now be set to the `esr` channel and start -receiving updates through this channel. - -Before releases, QA replaces the ChannelPrefs macOS Framework within the .app -bundle and point the channel at a test channel in order to test updates. During -testing, the new Framework file would remain in place for typical update -testing, but gets replaced in case QA was testing channel switching. - -## Why is a macOS Framework the best solution to store the update channel? - -Apple has started strengthening code signature checks and the requirements on -developers such as ourselves on how their apps are signed. In particular, -most files in the .app bundle are now included in signature verifications. - -A macOS Framework is the ideal solution to store the update channel because -Frameworks are the only component within a .app bundle that can be replaced -without invalidating the code signature on the .app bundle, as long as both the -previous and the new Framework are signed. diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefs/moz.build b/toolkit/mozapps/macos-frameworks/ChannelPrefs/moz.build deleted file mode 100644 index 13f4186b994b7..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefs/moz.build +++ /dev/null @@ -1,22 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -with Files("**"): - BUG_COMPONENT = ("Toolkit", "Application Update") - -Framework("ChannelPrefs") - -EXPORTS += [ - "ChannelPrefs.h", -] - -UNIFIED_SOURCES += [ - "ChannelPrefs.mm", -] - -OS_LIBS += [ - "-framework Foundation", -] diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.h b/toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.h deleted file mode 100644 index 0f2c38632e40c..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#ifndef ChannelPrefsUtil_h_ -#define ChannelPrefsUtil_h_ - -#include "Units.h" - -class ChannelPrefsUtil { - public: - static bool GetChannelPrefValue(nsACString& aValue); -}; - -#endif // ChannelPrefsUtil_h_ diff --git a/toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.mm b/toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.mm deleted file mode 100644 index 4113b84f5b35e..0000000000000 --- a/toolkit/mozapps/macos-frameworks/ChannelPrefsUtil.mm +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: - * 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* 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/. */ - -#import - -#include "ChannelPrefsUtil.h" - -#include "nsCocoaUtils.h" - -/* static */ -bool ChannelPrefsUtil::GetChannelPrefValue(nsACString& aValue) { - // `ChannelPrefsGetChannel` is resolved at runtime and requires - // the ChannelPrefs framework to be loaded. - if (ChannelPrefsGetChannel) { - nsAutoString value; - nsCocoaUtils::GetStringForNSString(ChannelPrefsGetChannel(), value); - CopyUTF16toUTF8(value, aValue); - return true; - } - - return false; -} diff --git a/toolkit/mozapps/macos-frameworks/moz.build b/toolkit/mozapps/macos-frameworks/moz.build deleted file mode 100644 index b1a315500c5fc..0000000000000 --- a/toolkit/mozapps/macos-frameworks/moz.build +++ /dev/null @@ -1,22 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -with Files("**"): - BUG_COMPONENT = ("Toolkit", "Application Update") - -FINAL_LIBRARY = "xul" - -DIRS += [ - "ChannelPrefs", -] - -EXPORTS += [ - "ChannelPrefsUtil.h", -] - -UNIFIED_SOURCES += [ - "ChannelPrefsUtil.mm", -] diff --git a/toolkit/mozapps/update/common/readstrings.cpp b/toolkit/mozapps/update/common/readstrings.cpp index 28dc8ea6ffb1c..17c2d002a19c2 100644 --- a/toolkit/mozapps/update/common/readstrings.cpp +++ b/toolkit/mozapps/update/common/readstrings.cpp @@ -38,6 +38,16 @@ class AutoFILE { FILE* fp_; }; +class AutoCharArray { + public: + explicit AutoCharArray(size_t len) { ptr_ = new char[len]; } + ~AutoCharArray() { delete[] ptr_; } + operator char*() { return ptr_; } + + private: + char* ptr_; +}; + static const char kNL[] = "\r\n"; static const char kEquals[] = "="; static const char kWhitespace[] = " \t"; @@ -143,8 +153,7 @@ int ReadStrings(const NS_tchar* path, const char* keyList, } size_t flen = size_t(len); - - char* fileContents = new char[flen + 1]; + AutoCharArray fileContents(flen + 1); if (!fileContents) { return READ_STRINGS_MEM_ERROR; } @@ -161,53 +170,12 @@ int ReadStrings(const NS_tchar* path, const char* keyList, fileContents[flen] = '\0'; - int result = ReadStringsFromBuffer(fileContents, keyList, numStrings, results, - section); - delete[] fileContents; - return result; -} - -// A wrapper function to read strings for the updater. -// Added for compatibility with the original code. -int ReadStrings(const NS_tchar* path, StringTable* results) { - const unsigned int kNumStrings = 2; - const char* kUpdaterKeys = "Title\0Info\0"; - mozilla::UniquePtr updater_strings[kNumStrings]; - - int result = ReadStrings(path, kUpdaterKeys, kNumStrings, updater_strings); - - if (result == OK) { - results->title.swap(updater_strings[0]); - results->info.swap(updater_strings[1]); - } - - return result; -} - -/** - * A very basic parser for updater.ini taken mostly from nsINIParser.cpp - * that can be used by standalone apps. - * - * @param stringBuffer The string buffer to parse - * @param keyList List of zero-delimited keys ending with two zero - * characters - * @param numStrings Number of strings to read into results buffer - must be - * equal to the number of keys - * @param results Array of strings. Array's length must be equal to - * numStrings. Each string will be populated with the value - * corresponding to the key with the same index in keyList. - * @param section Optional name of the section to read; defaults to - * "Strings" - */ -int ReadStringsFromBuffer(char* stringBuffer, const char* keyList, - unsigned int numStrings, - mozilla::UniquePtr* results, - const char* section) { + char* buffer = fileContents; bool inStringsSection = false; unsigned int read = 0; - while (char* token = NS_strtok(kNL, &stringBuffer)) { + while (char* token = NS_strtok(kNL, &buffer)) { if (token[0] == '#' || token[0] == ';') { // it's a comment continue; } @@ -265,6 +233,23 @@ int ReadStringsFromBuffer(char* stringBuffer, const char* keyList, return (read == numStrings) ? OK : PARSE_ERROR; } +// A wrapper function to read strings for the updater. +// Added for compatibility with the original code. +int ReadStrings(const NS_tchar* path, StringTable* results) { + const unsigned int kNumStrings = 2; + const char* kUpdaterKeys = "Title\0Info\0"; + mozilla::UniquePtr updater_strings[kNumStrings]; + + int result = ReadStrings(path, kUpdaterKeys, kNumStrings, updater_strings); + + if (result == OK) { + results->title.swap(updater_strings[0]); + results->info.swap(updater_strings[1]); + } + + return result; +} + IniReader::IniReader(const NS_tchar* iniPath, const char* section /* = nullptr */) { if (iniPath) { diff --git a/toolkit/mozapps/update/common/readstrings.h b/toolkit/mozapps/update/common/readstrings.h index 11bd393f2d4a5..9e0ebbefb5da5 100644 --- a/toolkit/mozapps/update/common/readstrings.h +++ b/toolkit/mozapps/update/common/readstrings.h @@ -37,15 +37,6 @@ int ReadStrings(const NS_tchar* path, const char* keyList, unsigned int numStrings, mozilla::UniquePtr* results, const char* section = nullptr); -/** - * This function reads in localized strings corresponding to the keys from a - * given string buffer. - */ -int ReadStringsFromBuffer(char* stringBuffer, const char* keyList, - unsigned int numStrings, - mozilla::UniquePtr* results, - const char* section = nullptr); - /** * This class is meant to be a slightly cleaner interface into the ReadStrings * function. diff --git a/toolkit/mozapps/update/tests/browser/head.js b/toolkit/mozapps/update/tests/browser/head.js index b606331fd3fc5..c5acdad8e40ce 100644 --- a/toolkit/mozapps/update/tests/browser/head.js +++ b/toolkit/mozapps/update/tests/browser/head.js @@ -368,15 +368,9 @@ function copyTestUpdater(attempt = 0) { testUpdater.copyToFollowingLinks(greBinDir, FILE_UPDATER_BIN); let greDir = getGREDir(); - - // 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 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 deleted file mode 100644 index 52a7e9a5b72c4..0000000000000 --- a/toolkit/mozapps/update/tests/data/README.md +++ /dev/null @@ -1,15 +0,0 @@ -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 `/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 ...`, 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: `..//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: `..//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 f4603f1eef9823dac4d64e21417b27a73e0584fc..c54088610a632e158bc98fb72d3473a632b18956 100644 GIT binary patch delta 1775 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 diff --git a/toolkit/mozapps/update/tests/data/partial_mac.mar b/toolkit/mozapps/update/tests/data/partial_mac.mar index 9b17747e43b43dab70f62a2ca3e2e2d4e33c97ec..bcc04b99391957d5eb4999c6a325ea7a17c302e5 100644 GIT binary patch delta 1450 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 KBin^4!2kg9RBl=T diff --git a/toolkit/mozapps/update/tests/data/shared.js b/toolkit/mozapps/update/tests/data/shared.js index e8553f72731be..60de6feeb854d 100644 --- a/toolkit/mozapps/update/tests/data/shared.js +++ b/toolkit/mozapps/update/tests/data/shared.js @@ -71,20 +71,17 @@ 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_ELEVATED_LOG = "backup-update-elevated.log"; const FILE_BACKUP_UPDATE_LOG = "backup-update.log"; +const FILE_BACKUP_UPDATE_ELEVATED_LOG = "backup-update-elevated.log"; const FILE_BT_RESULT = "bt.result"; -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_LAST_UPDATE_ELEVATED_LOG = "last-update-elevated.log"; const FILE_PRECOMPLETE = "precomplete"; const FILE_PRECOMPLETE_BAK = "precomplete.bak"; const FILE_UPDATE_CONFIG_JSON = "update-config.json"; -const FILE_UPDATE_ELEVATED_LOG = "update-elevated.log"; const FILE_UPDATE_LOG = "update.log"; +const FILE_UPDATE_ELEVATED_LOG = "update-elevated.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"; @@ -226,7 +223,6 @@ 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 6374f82b52472..4b12edf6f020b 100644 --- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js +++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js @@ -181,30 +181,12 @@ var gDebugTestLog = false; var gTestsToLog = []; var gRealDump; var gFOS; -var gUpdateBin; var gTestFiles = []; var gTestDirs = []; // Common files for both successful and failed updates. 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, @@ -216,32 +198,19 @@ var gTestFilesCommonNonMac = [ originalPerms: 0o767, comparePerms: 0o767, }, -]; - -if (AppConstants.platform != "macosx") { - gTestFilesCommon = gTestFilesCommon.concat(gTestFilesCommonNonMac); -} - -var gTestFilesCommonMac = [ { description: "Should never change", - fileName: FILE_UPDATE_SETTINGS_FRAMEWORK, - relPathDir: - "Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework/", - originalContents: null, - compareContents: null, + fileName: "channel-prefs.js", + relPathDir: DIR_RESOURCES + "defaults/pref/", + originalContents: "ShouldNotBeReplaced\n", + compareContents: "ShouldNotBeReplaced\n", originalFile: null, compareFile: null, - originalPerms: null, - comparePerms: null, - existingFile: true, + originalPerms: 0o767, + comparePerms: 0o767, }, ]; -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 = [ @@ -688,20 +657,6 @@ 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/", @@ -2064,13 +2019,8 @@ function runUpdate( Services.env.set("MOZ_TEST_SHORTER_WAIT_PID", "1"); } - if (!gUpdateBin) { - gUpdateBin = copyTestUpdaterToBinDir(); - } - Assert.ok( - gUpdateBin.exists(), - MSG_SHOULD_EXIST + getMsgPath(gUpdateBin.path) - ); + let updateBin = copyTestUpdaterToBinDir(); + Assert.ok(updateBin.exists(), MSG_SHOULD_EXIST + getMsgPath(updateBin.path)); let updatesDirPath = aPatchDirPath || getUpdateDirFile(DIR_PATCH).path; let installDirPath = aInstallDirPath || getApplyDirFile().path; @@ -2095,13 +2045,13 @@ function runUpdate( args[3] = pid; } - let launchBin = gIsServiceTest && isInvalidArgTest ? callbackApp : gUpdateBin; + let launchBin = gIsServiceTest && isInvalidArgTest ? callbackApp : updateBin; if (!isInvalidArgTest) { args = args.concat([callbackApp.parent.path, callbackApp.path]); args = args.concat(gCallbackArgs); } else if (gIsServiceTest) { - args = ["launch-service", gUpdateBin.path].concat(args); + args = ["launch-service", updateBin.path].concat(args); } else if (aCallbackPath) { args = args.concat([callbackApp.parent.path, aCallbackPath]); } @@ -3175,13 +3125,6 @@ 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) { @@ -3220,24 +3163,6 @@ 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); }); @@ -3499,13 +3424,21 @@ function checkUpdateLogContents( // Remove leading timestamps updateLogContents = removeTimeStamps(updateLogContents); - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - if (channelPrefs && !channelPrefs.originalContents) { + // 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 + ) { updateLogContents = updateLogContents.replace(/.*defaults\/.*/g, ""); } - const updateSettings = getTestFileByName(FILE_UPDATE_SETTINGS_INI); - if (updateSettings && !updateSettings.originalContents) { + if ( + gTestFiles.length > 2 && + gTestFiles[gTestFiles.length - 2].fileName == FILE_UPDATE_SETTINGS_INI && + !gTestFiles[gTestFiles.length - 2].originalContents + ) { updateLogContents = updateLogContents.replace( /.*update-settings.ini.*/g, "" @@ -3596,11 +3529,21 @@ function checkUpdateLogContents( // Remove leading timestamps compareLogContents = removeTimeStamps(compareLogContents); - if (channelPrefs && !channelPrefs.originalContents) { + // 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 + ) { compareLogContents = compareLogContents.replace(/.*defaults\/.*/g, ""); } - if (updateSettings && !updateSettings.originalContents) { + if ( + gTestFiles.length > 2 && + gTestFiles[gTestFiles.length - 2].fileName == FILE_UPDATE_SETTINGS_INI && + !gTestFiles[gTestFiles.length - 2].originalContents + ) { compareLogContents = compareLogContents.replace( /.*update-settings.ini.*/g, "" @@ -4936,33 +4879,3 @@ 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 1e27efb75368c..9e23fab5e064a 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/languagePackUpdates.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/languagePackUpdates.js @@ -177,12 +177,9 @@ add_task(async function testLangpackStaged() { copyTestUpdaterToBinDir(); let greDir = getGREDir(); - - if (AppConstants.platform != "macosx") { - let updateSettingsIni = greDir.clone(); - updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI); - writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS); - } + 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 new file mode 100644 index 0000000000000..4cca77c73dc72 --- /dev/null +++ b/toolkit/mozapps/update/tests/unit_aus_update/verifyChannelPrefsFile.js @@ -0,0 +1,38 @@ +/* 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 160427ac5e296..74790016e4710 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.toml +++ b/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.toml @@ -83,3 +83,7 @@ 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 faac7510d05c5..29c2c2a30e00a 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js @@ -10,12 +10,9 @@ async function run_test() { } const STATE_AFTER_STAGE = STATE_APPLIED; gTestFiles = gTestFilesCompleteSuccess; - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - if (channelPrefs) { - channelPrefs.originalContents = null; - channelPrefs.compareContents = "FromComplete\n"; - channelPrefs.comparePerms = 0o644; - } + gTestFiles[gTestFiles.length - 1].originalContents = null; + gTestFiles[gTestFiles.length - 1].compareContents = "FromComplete\n"; + gTestFiles[gTestFiles.length - 1].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 379fb00a27e95..de8db067bcaf2 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; - getTestFileByName("0exe0.exe").originalFile = "partial.png"; + gTestFiles[11].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 11181f4420377..b93b0239340ac 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailureComplete_win.js @@ -15,8 +15,10 @@ async function run_test() { gTestFiles = gTestFilesCompleteSuccess; gTestDirs = gTestDirsCompleteSuccess; await setupUpdaterTest(FILE_COMPLETE_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[13].relPathDir + gTestFiles[13].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 def7f8db9c2e7..b41da12396cad 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageFailurePartial_win.js @@ -15,8 +15,10 @@ async function run_test() { gTestFiles = gTestFilesPartialSuccess; gTestDirs = gTestDirsPartialSuccess; await setupUpdaterTest(FILE_PARTIAL_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[11].relPathDir + gTestFiles[11].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 d1f938bb0207f..4b946ac3e45c3 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js @@ -11,8 +11,10 @@ async function run_test() { gTestFiles = gTestFilesCompleteSuccess; gTestDirs = gTestDirsCompleteSuccess; await setupUpdaterTest(FILE_COMPLETE_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[13].relPathDir + gTestFiles[13].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 f851c543a695d..15c3a1121a389 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js @@ -11,8 +11,10 @@ async function run_test() { gTestFiles = gTestFilesPartialSuccess; gTestDirs = gTestDirsPartialSuccess; await setupUpdaterTest(FILE_PARTIAL_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[11].relPathDir + gTestFiles[11].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 5517d5ed81e68..698ccb7fe521a 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(getTestFileByName("searchpluginspng0.png")); + await runHelperLockFile(gTestFiles[3]); 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 03eb6122c8364..c8c019ec5ce21 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(getTestFileByName("searchpluginspng1.png")); + await runHelperLockFile(gTestFiles[2]); 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 4d5fe599cfade..7b582dbd45954 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(getTestFileByName("searchpluginspng0.png")); + await runHelperLockFile(gTestFiles[3]); 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 3d4a8e0c51ce5..bf3abd8c37a8e 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(getTestFileByName("searchpluginspng1.png")); + await runHelperLockFile(gTestFiles[2]); 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 fbb0e7c4cd53c..b0a0cfe657abb 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettings.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettings.js @@ -14,17 +14,7 @@ async function run_test() { return; } gTestFiles = gTestFilesCompleteSuccess; - 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; - } + gTestFiles[gTestFiles.length - 2].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 a6d204aa92603..e26d2aefc3658 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marMissingUpdateSettingsStage.js @@ -15,17 +15,7 @@ async function run_test() { } const STATE_AFTER_STAGE = STATE_FAILED; gTestFiles = gTestFilesCompleteSuccess; - 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; - } + gTestFiles[gTestFiles.length - 2].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 47c184e67bfca..a1a0de0fe4111 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; - getTestFileByName("0exe0.exe").originalFile = "partial.png"; + gTestFiles[11].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 2c9c3298d4645..943a45ba95754 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js @@ -11,10 +11,9 @@ async function run_test() { } const STATE_AFTER_STAGE = gIsServiceTest ? STATE_APPLIED_SVC : STATE_APPLIED; gTestFiles = gTestFilesCompleteSuccess; - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - channelPrefs.originalContents = null; - channelPrefs.compareContents = "FromComplete\n"; - channelPrefs.comparePerms = 0o644; + gTestFiles[gTestFiles.length - 1].originalContents = null; + gTestFiles[gTestFiles.length - 1].compareContents = "FromComplete\n"; + gTestFiles[gTestFiles.length - 1].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 e565ffe550997..dd5c240919e03 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js @@ -11,10 +11,9 @@ async function run_test() { } const STATE_AFTER_STAGE = gIsServiceTest ? STATE_APPLIED_SVC : STATE_APPLIED; gTestFiles = gTestFilesPartialSuccess; - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - channelPrefs.originalContents = null; - channelPrefs.compareContents = "FromPartial\n"; - channelPrefs.comparePerms = 0o644; + gTestFiles[gTestFiles.length - 1].originalContents = null; + gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n"; + gTestFiles[gTestFiles.length - 1].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 f4f856278c064..8e8e9d094a0c4 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js @@ -10,10 +10,9 @@ async function run_test() { return; } gTestFiles = gTestFilesPartialSuccess; - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - channelPrefs.originalContents = null; - channelPrefs.compareContents = "FromPartial\n"; - channelPrefs.comparePerms = 0o644; + gTestFiles[gTestFiles.length - 1].originalContents = null; + gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n"; + gTestFiles[gTestFiles.length - 1].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 e80e52e9a38ed..37511bd789e44 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js @@ -45,7 +45,8 @@ 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 = getTestFileByName(FILE_CHANNEL_PREFS); + let channelPrefs = gTestFiles[gTestFiles.length - 1]; + Assert.equal("channel-prefs.js", channelPrefs.fileName); 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 5d6ee617761dc..d31188dcca6fc 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js @@ -14,7 +14,8 @@ async function run_test() { return; } gTestFiles = gTestFilesCompleteSuccess; - setUpdateSettingsUseWrongChannel(); + gTestFiles[gTestFiles.length - 2].originalContents = + UPDATE_SETTINGS_CONTENTS.replace("xpcshell-test", "wrong-channel"); 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 9aca22df667ca..4d512fd12ae3a 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannelStage.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannelStage.js @@ -15,7 +15,8 @@ async function run_test() { } const STATE_AFTER_STAGE = STATE_FAILED; gTestFiles = gTestFilesCompleteSuccess; - setUpdateSettingsUseWrongChannel(); + gTestFiles[gTestFiles.length - 2].originalContents = + UPDATE_SETTINGS_CONTENTS.replace("xpcshell-test", "wrong-channel"); 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 379fb00a27e95..de8db067bcaf2 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; - getTestFileByName("0exe0.exe").originalFile = "partial.png"; + gTestFiles[11].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 11181f4420377..b93b0239340ac 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailureCompleteSvc_win.js @@ -15,8 +15,10 @@ async function run_test() { gTestFiles = gTestFilesCompleteSuccess; gTestDirs = gTestDirsCompleteSuccess; await setupUpdaterTest(FILE_COMPLETE_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[13].relPathDir + gTestFiles[13].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 def7f8db9c2e7..b41da12396cad 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageFailurePartialSvc_win.js @@ -15,8 +15,10 @@ async function run_test() { gTestFiles = gTestFilesPartialSuccess; gTestDirs = gTestDirsPartialSuccess; await setupUpdaterTest(FILE_PARTIAL_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[11].relPathDir + gTestFiles[11].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 d1f938bb0207f..4b946ac3e45c3 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessCompleteSvc_win.js @@ -11,8 +11,10 @@ async function run_test() { gTestFiles = gTestFilesCompleteSuccess; gTestDirs = gTestDirsCompleteSuccess; await setupUpdaterTest(FILE_COMPLETE_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[13].relPathDir + gTestFiles[13].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 f851c543a695d..15c3a1121a389 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseSuccessPartialSvc_win.js @@ -11,8 +11,10 @@ async function run_test() { gTestFiles = gTestFilesPartialSuccess; gTestDirs = gTestDirsPartialSuccess; await setupUpdaterTest(FILE_PARTIAL_MAR, false); - const testFile = getTestFileByName("0exe0.exe"); - await runHelperFileInUse(testFile.relPathDir + testFile.fileName, false); + await runHelperFileInUse( + gTestFiles[11].relPathDir + gTestFiles[11].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 5517d5ed81e68..698ccb7fe521a 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(getTestFileByName("searchpluginspng0.png")); + await runHelperLockFile(gTestFiles[3]); 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 03eb6122c8364..c8c019ec5ce21 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(getTestFileByName("searchpluginspng1.png")); + await runHelperLockFile(gTestFiles[2]); 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 4d5fe599cfade..7b582dbd45954 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(getTestFileByName("searchpluginspng0.png")); + await runHelperLockFile(gTestFiles[3]); 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 3d4a8e0c51ce5..bf3abd8c37a8e 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(getTestFileByName("searchpluginspng1.png")); + await runHelperLockFile(gTestFiles[2]); 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 47c184e67bfca..a1a0de0fe4111 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; - getTestFileByName("0exe0.exe").originalFile = "partial.png"; + gTestFiles[11].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 2c9c3298d4645..943a45ba95754 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js @@ -11,10 +11,9 @@ async function run_test() { } const STATE_AFTER_STAGE = gIsServiceTest ? STATE_APPLIED_SVC : STATE_APPLIED; gTestFiles = gTestFilesCompleteSuccess; - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - channelPrefs.originalContents = null; - channelPrefs.compareContents = "FromComplete\n"; - channelPrefs.comparePerms = 0o644; + gTestFiles[gTestFiles.length - 1].originalContents = null; + gTestFiles[gTestFiles.length - 1].compareContents = "FromComplete\n"; + gTestFiles[gTestFiles.length - 1].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 e565ffe550997..dd5c240919e03 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js @@ -11,10 +11,9 @@ async function run_test() { } const STATE_AFTER_STAGE = gIsServiceTest ? STATE_APPLIED_SVC : STATE_APPLIED; gTestFiles = gTestFilesPartialSuccess; - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - channelPrefs.originalContents = null; - channelPrefs.compareContents = "FromPartial\n"; - channelPrefs.comparePerms = 0o644; + gTestFiles[gTestFiles.length - 1].originalContents = null; + gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n"; + gTestFiles[gTestFiles.length - 1].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 f4f856278c064..8e8e9d094a0c4 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessPartialSvc.js @@ -10,10 +10,9 @@ async function run_test() { return; } gTestFiles = gTestFilesPartialSuccess; - const channelPrefs = getTestFileByName(FILE_CHANNEL_PREFS); - channelPrefs.originalContents = null; - channelPrefs.compareContents = "FromPartial\n"; - channelPrefs.comparePerms = 0o644; + gTestFiles[gTestFiles.length - 1].originalContents = null; + gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n"; + gTestFiles[gTestFiles.length - 1].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/updater/Makefile.in b/toolkit/mozapps/update/updater/Makefile.in index ec3ad9773acf6..70cf32378afa6 100644 --- a/toolkit/mozapps/update/updater/Makefile.in +++ b/toolkit/mozapps/update/updater/Makefile.in @@ -25,7 +25,4 @@ libs:: $(call py_action,preprocessor updater.app/Contents/Resources/English.lproj/InfoPlist.strings,-Fsubstitution --output-encoding utf-16 -DAPP_NAME='$(MOZ_APP_DISPLAYNAME)' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in -o $(DIST)/bin/updater.app/Contents/Resources/English.lproj/InfoPlist.strings) $(NSINSTALL) -D $(DIST)/bin/updater.app/Contents/MacOS $(NSINSTALL) $(DIST)/bin/org.mozilla.updater $(DIST)/bin/updater.app/Contents/MacOS - $(NSINSTALL) -D $(DIST)/bin/updater.app/Contents/Frameworks - $(NSINSTALL) $(DIST)/bin/UpdateSettings $(DIST)/bin/updater.app/Contents/Frameworks/UpdateSettings.framework - $(NSINSTALL) $(srcdir)/macos-frameworks/UpdateSettings/Info.plist $(DIST)/bin/updater.app/Contents/Frameworks/UpdateSettings.framework/Resources endif diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-WrongChannel/moz.build b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-WrongChannel/moz.build deleted file mode 100644 index e1f4ad098135a..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-WrongChannel/moz.build +++ /dev/null @@ -1,18 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -Framework("UpdateSettings-WrongChannel") -FINAL_TARGET = "_tests/xpcshell/toolkit/mozapps/update/tests" - -DEFINES["ACCEPTED_MAR_CHANNEL_IDS"] = '"wrong-channel"' - -UNIFIED_SOURCES += [ - "../UpdateSettings/UpdateSettings.mm", -] - -OS_LIBS += [ - "-framework Foundation", -] diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-xpcshell/moz.build b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-xpcshell/moz.build deleted file mode 100644 index 6c9b43b1460f2..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings-xpcshell/moz.build +++ /dev/null @@ -1,18 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -Framework("UpdateSettings-xpcshell") -FINAL_TARGET = "_tests/xpcshell/toolkit/mozapps/update/tests" - -DEFINES["ACCEPTED_MAR_CHANNEL_IDS"] = '"xpcshell-test"' - -UNIFIED_SOURCES += [ - "../UpdateSettings/UpdateSettings.mm", -] - -OS_LIBS += [ - "-framework Foundation", -] diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/Info.plist b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/Info.plist deleted file mode 100644 index 65777a475f51e..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - UpdateSettings - CFBundleIdentifier - org.mozilla.updatesettings - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - UpdateSettings - CFBundlePackageType - FMWK - CFBundleSignature - ???? - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1.0 - - diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/README.md b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/README.md deleted file mode 100644 index 32b9d2ea48e62..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# UpdateSettings macOS Framework - -## Summary - -The UpdateSettings macOS Framework is used to set the accepted MAR download -channels. - -## What are MAR update channels and what are they used for? - -As the name implies, MAR update channels are the channels where MAR update files -are served from and we want to ensure that the updater only applies MAR files -from accepted channels. - -## Why do we need a Framework instead of compiling the accepted MAR update channels directly into the executable? - -There are three main use cases that make it necessary for the accepted MAR -update channels to be set by external means, such as a macOS Framework: - - 1. Allowing users on the Beta channel to test RC builds - -Our beta users test release candidate builds before they are released to the -release population. The MAR files related to release candidates have their MAR -channel set to `release`. We make it possible for beta users to test these -release candidate MAR files by having beta Firefox installs accept MAR files -with their internal update channel set to either `release` or `beta`. - - 2. Switching users to another channel, such as ESR - -In contrast to the Beta use case outlined above, there are times where we -explicitly WANT to switch users to a different channel. An example of this is -when hardware or a particular macOS version have reached their EOL. In this -case, we usually switch users to our ESR channel for extended support. We switch -users to a different channel by serving a MAR file that forces a change to the -update channels that will be accepted for future updates. In other words, while -users may have previously accepted MAR update files from the `release` channel, -they now only accept MAR files from the `esr` channel. - - 3. QA update testing - -QA requires a way to temporarily switch the MAR update channel to a test channel -in order to test MAR updates before new releases. - -## How does the UpdateSettings macOS Framework address these use cases? - -We are able to accommodate all three use cases above by enabling the updater to -ignore certain files on disk if they are already present, but continue to force -update them if so desired. - -In the case of a Beta user updating to an RC build, the updater would encounter -an UpdateSettings macOS Framework inside the .app bundle that has the accepted -MAR update channels set to `beta` and `release`. In this case, the updater will -not update the Framework, but update everything else. This beta user is now able -to run the RC build with the update channel still set to `beta` and `release` -and will be able to apply MAR files related to the next beta cycle once the end -of RC builds is reached. - -In the case of switching users to the ESR channel, the updater will be set to -forcefully update the UpdateSettings macOS Framework, even if already present on -disk. After the update, the user will now be set to accept MAR updates from the -`esr` channel only. - -Before releases, QA replaces the UpdateSettings macOS Framework within the .app -bundle and set the accepted MAR update channels to a test channel in order to -test MAR updates. During testing, the new Framework file would remain in place -for typical update testing, but gets replaced in case QA was testing channel -switching. - -## Why is a macOS Framework the best solution to store the accepted MAR update channels? - -Apple has started strengthening code signature checks and the requirements on -developers such as ourselves on how their apps are signed. In particular, -most files in the .app bundle are now included in signature verifications. - -A macOS Framework is the ideal solution to store the accepted MAR update -channels because Frameworks are the only component within a .app bundle that can -be replaced without invalidating the code signature on the .app bundle, as long -as both the previous and the new Framework are signed. diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.h b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.h deleted file mode 100644 index 65a7ba3e00d9a..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.h +++ /dev/null @@ -1,17 +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/. */ - -#ifndef UpdateSettings_h_ -#define UpdateSettings_h_ - -#import - -extern "C" { - -// Returns the accepted MAR channels, as an autoreleased string. -extern NSString* UpdateSettingsGetAcceptedMARChannels(void) - __attribute__((weak_import)) __attribute__((visibility("default"))); -} - -#endif // UpdateSettings_h_ diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.mm b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.mm deleted file mode 100644 index 2c39f13f3b700..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/UpdateSettings.mm +++ /dev/null @@ -1,13 +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/. */ - -#include "UpdateSettings.h" - -#include "mozilla/HelperMacros.h" - -NSString* UpdateSettingsGetAcceptedMARChannels(void) { - return - [NSString stringWithFormat:@"[Settings]\nACCEPTED_MAR_CHANNEL_IDS=%s\n", - ACCEPTED_MAR_CHANNEL_IDS]; -} diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/moz.build b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/moz.build deleted file mode 100644 index 67de1d68f7f97..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettings/moz.build +++ /dev/null @@ -1,24 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -Framework("UpdateSettings") - -if CONFIG["ACCEPTED_MAR_CHANNEL_IDS"]: - DEFINES["ACCEPTED_MAR_CHANNEL_IDS"] = '"%s"' % CONFIG["ACCEPTED_MAR_CHANNEL_IDS"] -else: - DEFINES["ACCEPTED_MAR_CHANNEL_IDS"] = '""' - -EXPORTS += [ - "UpdateSettings.h", -] - -UNIFIED_SOURCES += [ - "UpdateSettings.mm", -] - -OS_LIBS += [ - "-framework Foundation", -] diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.h b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.h deleted file mode 100644 index 5964d9fb18c29..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#ifndef UpdateSettingsUtil_h_ -#define UpdateSettingsUtil_h_ - -#include -#include - -class UpdateSettingsUtil { - public: - static std::optional GetAcceptedMARChannelsValue(); -}; - -#endif // UpdateSettingsUtil_h_ diff --git a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.mm b/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.mm deleted file mode 100644 index 6555fd135083e..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/UpdateSettingsUtil.mm +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: - * 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* 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/. */ - -#import "UpdateSettings/UpdateSettings.h" - -#include "UpdateSettingsUtil.h" - -/* static */ -std::optional UpdateSettingsUtil::GetAcceptedMARChannelsValue() { - // `UpdateSettingsGetAcceptedMARChannels` is resolved at runtime and requires - // the UpdateSettings framework to be loaded. - if (UpdateSettingsGetAcceptedMARChannels) { - NSString* marChannels = UpdateSettingsGetAcceptedMARChannels(); - return [marChannels UTF8String]; - } - return {}; -} diff --git a/toolkit/mozapps/update/updater/macos-frameworks/moz.build b/toolkit/mozapps/update/updater/macos-frameworks/moz.build deleted file mode 100644 index 19fa11942e426..0000000000000 --- a/toolkit/mozapps/update/updater/macos-frameworks/moz.build +++ /dev/null @@ -1,18 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -with Files("**"): - BUG_COMPONENT = ("Toolkit", "Application Update") - -DIRS += ["UpdateSettings", "UpdateSettings-xpcshell", "UpdateSettings-WrongChannel"] - -EXPORTS += [ - "UpdateSettingsUtil.h", -] - -UNIFIED_SOURCES += [ - "UpdateSettingsUtil.mm", -] diff --git a/toolkit/mozapps/update/updater/moz.build b/toolkit/mozapps/update/updater/moz.build index 9620dde22ce79..eede9cd7236dc 100644 --- a/toolkit/mozapps/update/updater/moz.build +++ b/toolkit/mozapps/update/updater/moz.build @@ -26,9 +26,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": "__launchd_plist", SRCDIR + "/Launchd.plist", ] - DIRS += [ - "macos-frameworks", - ] GENERATED_FILES = [ "dep1Cert.h", diff --git a/toolkit/mozapps/update/updater/updater-common.build b/toolkit/mozapps/update/updater/updater-common.build index 6c6d0adf6f56b..fe0b4a85faa11 100644 --- a/toolkit/mozapps/update/updater/updater-common.build +++ b/toolkit/mozapps/update/updater/updater-common.build @@ -22,17 +22,6 @@ if CONFIG["MOZ_VERIFY_MAR_SIGNATURE"]: "verifymar", ] - if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": - srcs += [ - "macos-frameworks/UpdateSettingsUtil.mm", - ] - USE_LIBS += [ - "UpdateSettings", - ] - LDFLAGS += [ - "-Wl,-rpath,@executable_path/../Frameworks/UpdateSettings.framework" - ] - if CONFIG["OS_ARCH"] == "WINNT": have_progressui = 1 srcs += [ @@ -125,7 +114,7 @@ if CONFIG["MOZ_TSAN"]: DEFINES["SPRINTF_H_USES_VSNPRINTF"] = True DEFINES["NS_NO_XPCOM"] = True DisableStlWrapping() -for var in ("MAR_CHANNEL_ID", "MOZ_APP_VERSION", "ACCEPTED_MAR_CHANNEL_IDS"): +for var in ("MAR_CHANNEL_ID", "MOZ_APP_VERSION"): DEFINES[var] = '"%s"' % CONFIG[var] LOCAL_INCLUDES += [ diff --git a/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in b/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in index 7ef90f9ce592f..533533c4d9e95 100644 --- a/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in +++ b/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in @@ -30,10 +30,6 @@ ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) $(call py_action,preprocessor updater-xpcshell.app/Contents/Resources/English.lproj/InfoPlist.strings,-Fsubstitution --output-encoding utf-16 -DAPP_NAME='$(MOZ_APP_DISPLAYNAME)' $(srcdir)/../macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in -o $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/Resources/English.lproj/InfoPlist.strings) $(NSINSTALL) -D $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/MacOS $(NSINSTALL) $(FINAL_TARGET)/updater-xpcshell $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/MacOS - $(NSINSTALL) -D $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/Frameworks - $(NSINSTALL) -D $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/Frameworks/UpdateSettings.framework - cp $(XPCSHELLTESTDIR)/UpdateSettings-xpcshell $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/Frameworks/UpdateSettings.framework/UpdateSettings - $(NSINSTALL) $(srcdir)/../macos-frameworks/UpdateSettings/Info.plist $(XPCSHELLTESTDIR)/data/updater-xpcshell.app/Contents/Frameworks/UpdateSettings.framework/Resources rm -Rf $(XPCSHELLTESTDIR)/data/updater.app mv $(XPCSHELLTESTDIR)/data/updater-xpcshell.app $(XPCSHELLTESTDIR)/data/updater.app mv $(XPCSHELLTESTDIR)/data/updater.app/Contents/MacOS/updater-xpcshell $(XPCSHELLTESTDIR)/data/updater.app/Contents/MacOS/org.mozilla.updater diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index 1116094159335..6b01450b31f3f 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -46,7 +46,6 @@ #include "updatecommon.h" #ifdef XP_MACOSX -# include "UpdateSettingsUtil.h" # include "updaterfileutils_osx.h" #endif // XP_MACOSX @@ -2660,64 +2659,23 @@ static void WaitForServiceFinishThread(void* param) { #endif #ifdef MOZ_VERIFY_MAR_SIGNATURE -# ifndef XP_MACOSX /** * This function reads in the ACCEPTED_MAR_CHANNEL_IDS from update-settings.ini * - * @param aPath The path to the ini file that is to be read - * @param aResults A pointer to the location to store the read strings + * @param path The path to the ini file that is to be read + * @param results A pointer to the location to store the read strings * @return OK on success */ -static int ReadMARChannelIDsFromPath(const NS_tchar* aPath, - MARChannelStringTable* aResults) { +static int ReadMARChannelIDs(const NS_tchar* path, + MARChannelStringTable* results) { const unsigned int kNumStrings = 1; const char* kUpdaterKeys = "ACCEPTED_MAR_CHANNEL_IDS\0"; - return ReadStrings(aPath, kUpdaterKeys, kNumStrings, &aResults->MARChannelID, - "Settings"); -} -# else // XP_MACOSX -/** - * This function reads in the ACCEPTED_MAR_CHANNEL_IDS from a string buffer. - * - * @param aChannels A string buffer containing the MAR channel(s). - * @param aResults A pointer to the location to store the read strings. - * @return OK on success - */ -static int ReadMARChannelIDsFromBuffer(char* aChannels, - MARChannelStringTable* aResults) { - const unsigned int kNumStrings = 1; - const char* kUpdaterKeys = "ACCEPTED_MAR_CHANNEL_IDS\0"; - return ReadStringsFromBuffer(aChannels, kUpdaterKeys, kNumStrings, - &aResults->MARChannelID, "Settings"); -} -# endif // XP_MACOSX + int result = ReadStrings(path, kUpdaterKeys, kNumStrings, + &results->MARChannelID, "Settings"); -/** - * This function reads in the `ACCEPTED_MAR_CHANNEL_IDS` from the appropriate - * (platform-dependent) source. - * - * @param aMARStrings - * An out-param used to return the channel id string read. The contained - * value is not specified if the function's return value is not `OK`. - * @return - * `OK` on success, `UPDATE_SETTINGS_FILE_CHANNEL` on failure. - */ -static int GetAcceptableChannelIDs(MARChannelStringTable* aMARStrings) { - int rv = UPDATE_SETTINGS_FILE_CHANNEL; -# ifdef XP_MACOSX - if (auto marChannels = UpdateSettingsUtil::GetAcceptedMARChannelsValue()) { - rv = ReadMARChannelIDsFromBuffer(marChannels->data(), aMARStrings); - } -# else - NS_tchar updateSettingsPath[MAXPATHLEN]; - NS_tsnprintf(updateSettingsPath, - sizeof(updateSettingsPath) / sizeof(updateSettingsPath[0]), - NS_T("%s/update-settings.ini"), gInstallDirPath); - rv = ReadMARChannelIDsFromPath(updateSettingsPath, aMARStrings); -# endif - return rv == OK ? OK : UPDATE_SETTINGS_FILE_CHANNEL; + return result; } -#endif // MOZ_VERIFY_MAR_SIGNATURE +#endif static int GetUpdateFileName(NS_tchar* fileName, int maxChars) { NS_tsnprintf(fileName, maxChars, NS_T("%s/update.mar"), gPatchDirPath); @@ -2742,9 +2700,19 @@ static void UpdateThreadFunc(void* param) { } if (rv == OK) { + NS_tchar updateSettingsPath[MAXPATHLEN]; + NS_tsnprintf(updateSettingsPath, + sizeof(updateSettingsPath) / sizeof(updateSettingsPath[0]), +# ifdef XP_MACOSX + NS_T("%s/Contents/Resources/update-settings.ini"), +# else + NS_T("%s/update-settings.ini"), +# endif + gInstallDirPath); MARChannelStringTable MARStrings; - rv = GetAcceptableChannelIDs(&MARStrings); - if (rv == OK) { + if (ReadMARChannelIDs(updateSettingsPath, &MARStrings) != OK) { + rv = UPDATE_SETTINGS_FILE_CHANNEL; + } else { rv = gArchiveReader.VerifyProductInformation( MARStrings.MARChannelID.get(), MOZ_APP_VERSION); } @@ -2987,22 +2955,6 @@ int NS_main(int argc, NS_tchar** argv) { putenv(const_cast("MOZ_USING_SERVICE=")); #endif - if (argc == 2 && NS_tstrcmp(argv[1], NS_T("--channels-allowed")) == 0) { -#ifdef MOZ_VERIFY_MAR_SIGNATURE - MARChannelStringTable MARStrings; - int rv = GetAcceptableChannelIDs(&MARStrings); - if (rv == OK) { - printf("Channels Allowed: %s\n", MARStrings.MARChannelID.get()); - return 0; - } - printf("Error: %d\n", rv); - return 1; -#else - printf("Not Applicable: No support for signature verification\n"); - return 0; -#endif - } - // The callback is the remaining arguments starting at callbackIndex. // The argument specified by callbackIndex is the callback executable and the // argument prior to callbackIndex is the working directory. diff --git a/tools/update-packaging/common.sh b/tools/update-packaging/common.sh index e055b1c24efd5..397ed21e2565e 100755 --- a/tools/update-packaging/common.sh +++ b/tools/update-packaging/common.sh @@ -92,14 +92,12 @@ make_add_instruction() { check_for_add_if_not_update() { add_if_not_file_chk="$1" - if [[ "$(basename "$add_if_not_file_chk")" = "channel-prefs.js" || \ - "$add_if_not_file_chk" =~ (^|/)ChannelPrefs\.framework/ || \ - "$(basename "$add_if_not_file_chk")" = "update-settings.ini" || \ - "$add_if_not_file_chk" =~ (^|/)UpdateSettings\.framework/ ]]; then - ## "true" + if [ "$(basename "$add_if_not_file_chk")" = "channel-prefs.js" -o \ + "$(basename "$add_if_not_file_chk")" = "update-settings.ini" ]; then + ## "true" *giggle* return 0; fi - ## "false" + ## 'false'... because this is bash. Oh yay! return 1; } diff --git a/tools/update-verify/release/common/check_updates.sh b/tools/update-verify/release/common/check_updates.sh index 8f9701311fe98..acf06d8b4ef77 100644 --- a/tools/update-verify/release/common/check_updates.sh +++ b/tools/update-verify/release/common/check_updates.sh @@ -12,29 +12,17 @@ check_updates () { channel=$8 mar_channel_IDs=$9 update_to_dep=${10} - local mac_update_settings_dir_override - mac_update_settings_dir_override=${11} # cleanup rm -rf source/* rm -rf target/* - # $mac_update_settings_dir_override allows unpack_build to find a host platform appropriate - # `update-settings.ini` file, which is needed to successfully run the updater later in this - # function. - unpack_build $update_platform source "$source_package" $locale '' "$mar_channel_IDs" $mac_update_settings_dir_override + unpack_build $update_platform source "$source_package" $locale '' $mar_channel_IDs if [ "$?" != "0" ]; then echo "FAILED: cannot unpack_build $update_platform source $source_package" return 1 fi - - # Unlike unpacking the `source` build, we don't actually _need_ $mac_update_settings_dir_override - # here to succesfully apply the update, but its usage in `source` causes an `update-settings.ini` - # file to be present in the directory we diff, which means we either also need it present in the - # `target` directory, or to remove it after the update is applied. The latter was chosen - # because it keeps the workaround close together (as opposed to just above this, and then much - # further down). - unpack_build $update_platform target "$target_package" $locale '' '' $mac_update_settings_dir_override + unpack_build $update_platform target "$target_package" $locale if [ "$?" != "0" ]; then echo "FAILED: cannot unpack_build $update_platform target $target_package" return 1 @@ -122,21 +110,6 @@ check_updates () { ignore_coderesources= fi - # On Mac, there are two Frameworks that are not included with updates, and - # which change with every build. Because of this, we ignore differences in - # them in `compare-directories.py`. The best verification we can do for them - # is that they still exist. - if [[ $update_platform == Darwin_* ]]; then - if ! compgen -G "source/${platform_dirname}/Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework" >/dev/null; then - echo "TEST-UNEXPECTED-FAIL: UpdateSettings.framework doesn't exist after update" - return 4 - fi - if ! compgen -G "source/${platform_dirname}/Contents/Frameworks/ChannelPrefs.framework" >/dev/null; then - echo "TEST-UNEXPECTED-FAIL: ChannelPrefs.framework doesn't exist after update" - return 5 - fi - fi - ../compare-directories.py source/${platform_dirname} target/${platform_dirname} ${channel} ${ignore_coderesources} > "${diff_file}" diffErr=$? cat "${diff_file}" diff --git a/tools/update-verify/release/common/unpack.sh b/tools/update-verify/release/common/unpack.sh index 7728e23d888de..3249936493d27 100755 --- a/tools/update-verify/release/common/unpack.sh +++ b/tools/update-verify/release/common/unpack.sh @@ -13,12 +13,6 @@ unpack_build () { locale=$4 unpack_jars=$5 update_settings_string=$6 - # If provided, must be a directory containing `update-settings.ini` which - # will be used instead of attempting to find this file in the unpacked - # build. `update_settings_string` modifications will still be performed on - # the file. - local mac_update_settings_dir_override - mac_update_settings_dir_override=$7 if [ ! -f "$pkg_file" ]; then return 1 @@ -50,17 +44,13 @@ unpack_build () { rm -rf "${unpack_dir}" appdir=$(ls -1) appdir=$(ls -d *.app) - if [ -d "${mac_update_settings_dir_override}" ]; then - cp "${mac_update_settings_dir_override}/update-settings.ini" "${appdir}/update-settings.ini" - else - # The updater guesses the location of these files based on - # its own target architecture, not the mar. If we're not - # unpacking mac-on-mac, we need to copy them so it can find - # them. It's important to copy (and not move), because when - # we diff the installer vs updated build afterwards, the - # installer version will have them in their original place. - cp "${appdir}/Contents/Resources/update-settings.ini" "${appdir}/update-settings.ini" - fi + # The updater guesses the location of these files based on + # its own target architecture, not the mar. If we're not + # unpacking mac-on-mac, we need to copy them so it can find + # them. It's important to copy (and not move), because when + # we diff the installer vs updated build afterwards, the + # installer version will have them in their original place. + cp "${appdir}/Contents/Resources/update-settings.ini" "${appdir}/update-settings.ini" cp "${appdir}/Contents/Resources/precomplete" "${appdir}/precomplete" fi update_settings_file="${appdir}/update-settings.ini" diff --git a/tools/update-verify/release/compare-directories.py b/tools/update-verify/release/compare-directories.py index 714f02a66d7cd..ea70d79b31c7e 100755 --- a/tools/update-verify/release/compare-directories.py +++ b/tools/update-verify/release/compare-directories.py @@ -29,6 +29,7 @@ # this can be removed once each channel has a watershed above 59.0b2 (from bug 1431342) "files": [ "defaults/pref/channel-prefs.js", + "Contents/Resources/defaults/pref/channel-prefs.js", ], "channel_prefix": ["aurora", "beta", "release", "esr"], "side": "source", @@ -38,6 +39,7 @@ # updates from a beta to an RC build, the latter specifies the release channel "files": [ "defaults/pref/channel-prefs.js", + "Contents/Resources/defaults/pref/channel-prefs.js", ], "channel_prefix": ["beta"], "side": "target", @@ -50,6 +52,7 @@ # updates from an RC to a beta build "files": [ "defaults/pref/channel-prefs.js", + "Contents/Resources/defaults/pref/channel-prefs.js", ], "channel_prefix": ["beta"], "side": "source", @@ -66,6 +69,7 @@ # to break before applying this transform. "files": [ "defaults/pref/channel-prefs.js", + "Contents/Resources/defaults/pref/channel-prefs.js", ], "channel_prefix": ["aurora", "beta", "release", "esr"], "side": "target", @@ -76,7 +80,7 @@ # updates from a beta to an RC build, the latter specifies the release channel # on mac, we actually have both files. The second location is the real # one but we copy to the first to run the linux64 updater - "files": ["update-settings.ini"], + "files": ["update-settings.ini", "Contents/Resources/update-settings.ini"], "channel_prefix": ["beta"], "side": "target", "substitution": [ @@ -84,20 +88,20 @@ "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-beta,firefox-mozilla-release\n", ], }, + { + # updates from an RC to a beta build + # on mac, we only need to modify the legit file this time. unpack_build + # handles the copy for the updater in both source and target + "files": ["Contents/Resources/update-settings.ini"], + "channel_prefix": ["beta"], + "side": "source", + "substitution": [ + "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-release\n", + "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-beta,firefox-mozilla-release\n", + ], + }, ] -# Files that are expected to be different, but cannot be transformed to get a useful diff. -# This should generally only be used for files that have unpredictable contents, eg: -# things that are signed but not updated. -IGNORE_FILES = ( - "Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework/Resources/Info.plist", - "Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework/_CodeSignature/CodeResources", - "Contents/MacOS/updater.app/Contents/Frameworks/UpdateSettings.framework/UpdateSettings", - "Contents/Frameworks/ChannelPrefs.framework/Resources/Info.plist", - "Contents/Frameworks/ChannelPrefs.framework/_CodeSignature/CodeResources", - "Contents/Frameworks/ChannelPrefs.framework/ChannelPrefs", -) - def walk_dir(path): all_files = [] @@ -166,14 +170,6 @@ def compare_common_files(files, channel, source_dir, target_dir): source_file ) != hash_file(target_file): logging.info("Difference found in {}".format(filename)) - if filename in IGNORE_FILES: - logging.info( - "Ignoring difference in {} because it is listed in IGNORE_FILES".format( - filename - ) - ) - continue - file_contents = { "source": open(source_file).readlines(), "target": open(target_file).readlines(), diff --git a/tools/update-verify/release/updates/verify.sh b/tools/update-verify/release/updates/verify.sh index ee6aaf6b47274..3f8556b4248f5 100755 --- a/tools/update-verify/release/updates/verify.sh +++ b/tools/update-verify/release/updates/verify.sh @@ -114,7 +114,6 @@ do use_old_updater=0 mar_channel_IDs="" updater_package="" - mac_update_settings_dir_override="" eval $entry # the arguments for updater changed in Gecko 34/SeaMonkey 2.31 @@ -178,35 +177,18 @@ do platform_dirname="*.app" updater_bins="Contents/MacOS/updater.app/Contents/MacOS/updater Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater" updater_platform="mac" - mac_update_settings_dir_override="" ;; *exe) updater_package_url=`echo "${updater_package_url}" | sed "s/ja-JP-mac/ja/"` platform_dirname="bin" updater_bins="updater.exe" updater_platform="win32" - case $platform in - Darwin_*) - mac_update_settings_dir_override="${PWD}/updater/${platform_dirname}" - ;; - *) - mac_update_settings_dir_override="" - ;; - esac ;; *bz2) updater_package_url=`echo "${updater_package_url}" | sed "s/ja-JP-mac/ja/"` platform_dirname=`echo $product | tr '[A-Z]' '[a-z]'` updater_bins="updater" updater_platform="linux" - case $platform in - Darwin_*) - mac_update_settings_dir_override="${PWD}/updater/${platform_dirname}" - ;; - *) - mac_update_settings_dir_override="" - ;; - esac ;; *) echo "Couldn't detect updater platform" @@ -274,7 +256,7 @@ do if [ -e ${diff_file} ]; then rm ${diff_file} fi - check_updates "${platform}" "downloads/${source_file}" "downloads/${target_file}" ${locale} ${use_old_updater} ${updater} ${diff_file} ${channel} "${mar_channel_IDs}" ${update_to_dep} ${mac_update_settings_dir_override} + check_updates "${platform}" "downloads/${source_file}" "downloads/${target_file}" ${locale} ${use_old_updater} ${updater} ${diff_file} ${channel} "${mar_channel_IDs}" ${update_to_dep} err=$? if [ "$err" == "0" ]; then continue