diff --git a/.eslintignore b/.eslintignore index 9a4ccde9f0b1..72cd109828be 100644 --- a/.eslintignore +++ b/.eslintignore @@ -188,6 +188,8 @@ mobile/android/locales/ modules/libpref/greprefs.js modules/libpref/init/all.js modules/libpref/test/unit/*data/ +toolkit/components/backgroundtasks/defaults/backgroundtasks.js +toolkit/components/backgroundtasks/defaults/backgroundtasks_browser.js # Only contains non-standard test files. python/ diff --git a/.prettierignore b/.prettierignore index 7ffb37880e48..a2bea24d3361 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1161,6 +1161,8 @@ mobile/android/locales/ modules/libpref/greprefs.js modules/libpref/init/all.js modules/libpref/test/unit/*data/ +toolkit/components/backgroundtasks/defaults/backgroundtasks.js +toolkit/components/backgroundtasks/defaults/backgroundtasks_browser.js # Only contains non-standard test files. python/ diff --git a/toolkit/components/backgroundtasks/defaults/backgroundtasks.js b/toolkit/components/backgroundtasks/defaults/backgroundtasks.js index 4aff06f9d7f5..43a937def42e 100644 --- a/toolkit/components/backgroundtasks/defaults/backgroundtasks.js +++ b/toolkit/components/backgroundtasks/defaults/backgroundtasks.js @@ -2,6 +2,8 @@ * 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/. */ +#filter substitution; + // These preferences override Gecko preferences in `greprefs.js`. Use // `backgroundtasks_browser.js` to override browser/-specific preferences in // `firefox.js`. @@ -45,3 +47,10 @@ pref("security.nocertdb", true); // Prevent asynchronous preference writes. pref("preferences.allow.omt-write", false); + +// Enable automatic restarts during background updates for Nightly builds. +#ifdef NIGHTLY_BUILD +pref("app.update.background.automaticRestartEnabled", true); +#else +pref("app.update.background.automaticRestartEnabled", false); +#endif diff --git a/toolkit/components/backgroundtasks/defaults/backgroundtasks_browser.js b/toolkit/components/backgroundtasks/defaults/backgroundtasks_browser.js index fbb8b3482701..0df5bafd1adb 100644 --- a/toolkit/components/backgroundtasks/defaults/backgroundtasks_browser.js +++ b/toolkit/components/backgroundtasks/defaults/backgroundtasks_browser.js @@ -2,6 +2,8 @@ * 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/. */ +#filter substitution; + // These preferences override override browser/-specific preferences in // `firefox.js`. Use `backgroundtasks.js` to override general Gecko preferences // in `greprefs.js`. diff --git a/toolkit/components/backgroundtasks/moz.build b/toolkit/components/backgroundtasks/moz.build index e66698a1bbfb..5f8b17c68825 100644 --- a/toolkit/components/backgroundtasks/moz.build +++ b/toolkit/components/backgroundtasks/moz.build @@ -91,11 +91,11 @@ if CONFIG["MOZ_BUILD_APP"] == "browser": "tests/BackgroundTask_targeting.sys.mjs", ] - FINAL_TARGET_FILES.browser.defaults.backgroundtasks += [ + FINAL_TARGET_PP_FILES.browser.defaults.backgroundtasks += [ "defaults/backgroundtasks_browser.js", ] -FINAL_TARGET_FILES.defaults.backgroundtasks += [ +FINAL_TARGET_PP_FILES.defaults.backgroundtasks += [ "defaults/backgroundtasks.js", ] diff --git a/toolkit/components/nimbus/FeatureManifest.yaml b/toolkit/components/nimbus/FeatureManifest.yaml index 5303f8c5f05b..151debfa1160 100644 --- a/toolkit/components/nimbus/FeatureManifest.yaml +++ b/toolkit/components/nimbus/FeatureManifest.yaml @@ -1172,6 +1172,23 @@ backgroundTaskMessage: path: "browser/components/newtab/content-src/asrouter/schemas/BackgroundTaskMessagingExperiment.schema.json" variables: {} +backgroundUpdateAutomaticRestart: + description: "Whether to automatically restart when the background update task could make more progress." + owner: nalexander@mozilla.com + applications: + - firefox-desktop-background-task + hasExposure: false + isEarlyStartup: false + variables: + enabled: + type: boolean + fallbackPref: app.update.background.automaticRestartEnabled + description: >- + When true, make the background update task restart when the final update state is `READY_FOR_RESTART`. + Generally, this will finish applying a staged update, completing the update earlier than it + otherwise would have been completed. + + pictureinpicture: description: Message for first time Picture-in-Picture users owner: nbaumgardner@mozilla.com diff --git a/toolkit/mozapps/update/BackgroundTask_backgroundupdate.sys.mjs b/toolkit/mozapps/update/BackgroundTask_backgroundupdate.sys.mjs index c16519a37d4e..d5cf96cbaa9d 100644 --- a/toolkit/mozapps/update/BackgroundTask_backgroundupdate.sys.mjs +++ b/toolkit/mozapps/update/BackgroundTask_backgroundupdate.sys.mjs @@ -17,6 +17,7 @@ ChromeUtils.defineESModuleGetters(lazy, { AppUpdater: "resource://gre/modules/AppUpdater.sys.mjs", BackgroundTasksUtils: "resource://gre/modules/BackgroundTasksUtils.sys.mjs", ExtensionUtils: "resource://gre/modules/ExtensionUtils.sys.mjs", + NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs", UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs", }); @@ -436,6 +437,9 @@ export async function runBackgroundTask(commandLine) { ); // If a restart loop is occurring then automaticRestartFound will be true. if ( + lazy.NimbusFeatures.backgroundUpdateAutomaticRestart.getVariable( + "enabled" + ) && updateStatus === lazy.AppUpdater.STATUS.READY_FOR_RESTART && !automaticRestartFound ) {