commit d8541bfd5737659a445ea490de305ddb93f834d3
parent fcd48a7b01e85ecdd92ec70de434aa63852d891f
Author: Emily McMinn <emcminn@mozilla.com>
Date: Thu, 16 Oct 2025 19:46:06 +0000
Bug 1994457 - Add backupArchiveEnabled && backupRestoreEnabled to ASRouterTargeting, and update onboarding spotlight targeting r=omc-reviewers,mviar,mimi
Differential Revision: https://phabricator.services.mozilla.com/D268755
Diffstat:
4 files changed, 82 insertions(+), 2 deletions(-)
diff --git a/browser/components/asrouter/docs/targeting-attributes.md b/browser/components/asrouter/docs/targeting-attributes.md
@@ -17,6 +17,8 @@ Please note that some targeting attributes require stricter controls on the tele
* [attributionData](#attributiondata)
* [backgroundTaskName](#backgroundtaskname)
* [backupsInfo](#backupsinfo)
+* [backupArchiveEnabled](#backuparchiveenabled)
+* [backupRestoreEnabled](#backuprestoreenabled)
* [blockedCountByType](#blockedcountbytype)
* [browserIsSelected](#browserisselected)
* [browserSettings](#browsersettings)
@@ -50,6 +52,7 @@ Please note that some targeting attributes require stricter controls on the tele
* [isDefaultBrowserUncached](#isdefaultbrowseruncached)
* [isDefaultHandler](#isdefaulthandler)
* [isDeviceMigration](#isdevicemigration)
+* [isEncryptedBackup](#isEncryptedBackup)
* [isFxAEnabled](#isfxaenabled)
* [isFxASignedIn](#isfxasignedin)
* [isMajorUpgrade](#ismajorupgrade)
@@ -92,7 +95,6 @@ Please note that some targeting attributes require stricter controls on the tele
* [usesFirefoxSync](#usesfirefoxsync)
* [xpinstallEnabled](#xpinstallenabled)
* [totalSearches](#totalsearches)
-* [isEncryptedBackup](#isEncryptedBackup)
## Detailed usage
@@ -1186,6 +1188,14 @@ declare const backupsInfo: {
};
```
+### `backupArchiveEnabled`
+
+Indicates whether the archive function is enabled by BackupService.
+
+### `backupRestoreEnabled`
+
+Indicates whether the restore function is enabled by BackupService.
+
### `isEncryptedBackup`
Indicates whether a user has selected an encrypted or non-encrypted backup method during the spotlight onboarding flow. (Refers to the `messaging-system-action.backupChooser` pref.)
diff --git a/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs b/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs
@@ -1320,6 +1320,26 @@ const TargetingGetters = {
return QueryCache.getters.backupsInfo.get().catch(() => null);
},
+ get backupArchiveEnabled() {
+ let bs;
+ try {
+ bs = lazy.BackupService.get();
+ } catch {
+ bs = lazy.BackupService.init();
+ }
+ return bs.archiveEnabledStatus.enabled;
+ },
+
+ get backupRestoreEnabled() {
+ let bs;
+ try {
+ bs = lazy.BackupService.get();
+ } catch {
+ bs = lazy.BackupService.init();
+ }
+ return bs.restoreEnabledStatus.enabled;
+ },
+
get isEncryptedBackup() {
const isEncryptedBackup =
Services.prefs.getStringPref(
diff --git a/browser/components/asrouter/modules/OnboardingMessageProvider.sys.mjs b/browser/components/asrouter/modules/OnboardingMessageProvider.sys.mjs
@@ -66,7 +66,7 @@ const BASE_MESSAGES = () => [
groups: ["win10-eos-sync", "eco"],
// TODO: The backup preferences in this expression should be updated once BackupService exposes getters; see Bug 1993272
targeting:
- "source == newtab && os.isWindows && os.windowsVersion == 10 && os.windowsBuildNumber <= 19045 && isFxAEnabled && !isFxASignedIn && !hasSelectableProfiles && !hasActiveEnterprisePolicies && ('browser.backup.archive.enabled' | preferenceValue) && (!'browser.backup.scheduled.enabled' | preferenceValue) && (!'browser.backup.scheduled.user-disabled' | preferenceValue) && !isMajorUpgrade && !willShowDefaultPrompt && !activeNotifications && previousSessionEnd && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features' | preferenceValue != false",
+ "source == newtab && os.isWindows && os.windowsVersion == 10 && os.windowsBuildNumber <= 19045 && isFxAEnabled && !isFxASignedIn && !hasSelectableProfiles && !hasActiveEnterprisePolicies && backupArchiveEnabled && (!'browser.backup.scheduled.enabled' | preferenceValue) && (!'browser.backup.scheduled.user-disabled' | preferenceValue) && !isMajorUpgrade && !willShowDefaultPrompt && !activeNotifications && previousSessionEnd && 'browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features' | preferenceValue != false",
trigger: {
id: "defaultBrowserCheck",
},
diff --git a/browser/components/asrouter/tests/browser/browser_asrouter_targeting.js b/browser/components/asrouter/tests/browser/browser_asrouter_targeting.js
@@ -2438,3 +2438,53 @@ add_task(async function check_isEncryptedBackup() {
"should return true if the pref value is full"
);
});
+
+add_task(async function check_backupArchiveEnabled() {
+ const sandbox = sinon.createSandbox();
+ registerCleanupFunction(() => sandbox.restore());
+
+ is(
+ await ASRouterTargeting.Environment.backupArchiveEnabled,
+ true,
+ "should return true if the killswitch is not on"
+ );
+
+ const archiveExperiment = await NimbusTestUtils.enrollWithFeatureConfig({
+ featureId: "backupService",
+ value: { archiveKillswitch: true },
+ });
+
+ is(
+ await ASRouterTargeting.Environment.backupArchiveEnabled,
+ false,
+ "should return false if the killswitch is on"
+ );
+
+ // End the experiment.
+ await archiveExperiment();
+});
+
+add_task(async function check_backupRestoreEnabled() {
+ const sandbox = sinon.createSandbox();
+ registerCleanupFunction(() => sandbox.restore());
+
+ is(
+ await ASRouterTargeting.Environment.backupRestoreEnabled,
+ true,
+ "should return true if the killswitch is not on"
+ );
+
+ const restoreExperiment = await NimbusTestUtils.enrollWithFeatureConfig({
+ featureId: "backupService",
+ value: { restoreKillswitch: true },
+ });
+
+ is(
+ await ASRouterTargeting.Environment.backupRestoreEnabled,
+ false,
+ "should return false if the killswitch is on"
+ );
+
+ // End the experiment.
+ await restoreExperiment();
+});