Bug 1868192 - Add packageFamilyName attribute for use with ASRouterTargeting. r=nalexander,nrishel,omc-reviewers,jprickett

Differential Revision: https://phabricator.services.mozilla.com/D249417
This commit is contained in:
Duncan McIntosh
2025-05-21 19:04:50 +00:00
committed by nrishel@mozilla.com
parent f642a5bc2a
commit 78bf65ff9b
3 changed files with 90 additions and 0 deletions

View File

@@ -61,6 +61,7 @@ Please note that some targeting attributes require stricter controls on the tele
* [messageImpressions](#messageimpressions) * [messageImpressions](#messageimpressions)
* [needsUpdate](#needsupdate) * [needsUpdate](#needsupdate)
* [newtabSettings](#newtabsettings) * [newtabSettings](#newtabsettings)
* [packageFamilyName](#packagefamilyname)
* [pinnedSites](#pinnedsites) * [pinnedSites](#pinnedsites)
* [platformName](#platformname) * [platformName](#platformname)
* [previousSessionEnd](#previoussessionend) * [previousSessionEnd](#previoussessionend)
@@ -371,6 +372,21 @@ Does the client have the latest available version installed
declare const needsUpdate: boolean; declare const needsUpdate: boolean;
``` ```
### `packageFamilyName`
Provides the package family name as given by the MSIX that Firefox was
installed from, or the empty string if not installed from MSIX.
#### Examples
* Is the user running MSIX Nightly?
```ts
"MozillaNightly" in packageFamilyName
```
#### Definition
```ts
declare const packageFamilyName: string;
```
### `pinnedSites` ### `pinnedSites`
The sites (including search shortcuts) that are pinned on a user's new tab page. The sites (including search shortcuts) that are pinned on a user's new tab page.

View File

@@ -975,6 +975,22 @@ const TargetingGetters = {
return Services.sysinfo.getProperty("hasWinPackageId", false); return Services.sysinfo.getProperty("hasWinPackageId", false);
}, },
get packageFamilyName() {
if (AppConstants.platform !== "win") {
// PackageFamilyNames are an MSIX feature, so they won't be available on non-Windows platforms.
return null;
}
let packageFamilyName = Services.sysinfo.getProperty(
"winPackageFamilyName"
);
if (packageFamilyName === "") {
return null;
}
return packageFamilyName;
},
/** /**
* Is this invocation running in background task mode? * Is this invocation running in background task mode?
* *

View File

@@ -1570,6 +1570,64 @@ add_task(async function check_isMSIX() {
); );
}); });
add_task(async function check_packageFamilyName() {
if (AppConstants.platform !== "win") {
is(
ASRouterTargeting.Environment.packageFamilyName,
null,
"Should always be null on non-Windows"
);
return;
}
let winPackageFamilyName = Services.sysinfo.getProperty(
"winPackageFamilyName"
);
if (winPackageFamilyName === "") {
is(
ASRouterTargeting.Environment.packageFamilyName,
null,
"Should be null if sysinfo is empty"
);
} else {
is(
ASRouterTargeting.Environment.packageFamilyName,
winPackageFamilyName,
"Should match non-empty sysinfo"
);
}
});
add_task(async function check_msixConsistency() {
if (ASRouterTargeting.Environment.isMSIX) {
Assert.greater(
ASRouterTargeting.Environment.packageFamilyName.length,
0,
"packageFamilyName should be non-empty if installed by MSIX"
);
} else {
is(
ASRouterTargeting.Environment.packageFamilyName,
null,
"packageFamilyName should be empty if not installed by MSIX"
);
}
if (ASRouterTargeting.Environment.packageFamilyName === null) {
is(
ASRouterTargeting.Environment.isMSIX,
false,
"isMSIX should be false if packageFamilyName is not present"
);
} else {
is(
ASRouterTargeting.Environment.isMSIX,
true,
"isMSIX should be true if packageFamilyName is present"
);
}
});
add_task(async function check_isRTAMO() { add_task(async function check_isRTAMO() {
is( is(
typeof ASRouterTargeting.Environment.isRTAMO, typeof ASRouterTargeting.Environment.isRTAMO,