Bug 1918536 - CREATE_NEW_SELECTABLE_PROFILE Special Message Action && test message r=jhirsch,omc-reviewers,pdahiya

Differential Revision: https://phabricator.services.mozilla.com/D222980
This commit is contained in:
Emily McMinn
2024-10-17 18:18:59 +00:00
parent e3731da318
commit f3bbb3366b
10 changed files with 175 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ Please note that some targeting attributes require stricter controls on the tele
* [blockedCountByType](#blockedcountbytype)
* [browserIsSelected](#browserisselected)
* [browserSettings](#browsersettings)
* [canCreateSelectableProfiles](#cancreateselectableprofiles)
* [creditCardsSaved](#creditcardssaved)
* [currentDate](#currentdate)
* [defaultPDFHandler](#defaultpdfhandler)
@@ -35,6 +36,7 @@ Please note that some targeting attributes require stricter controls on the tele
* [hasMigratedHistory](#hasmigratedhistory)
* [hasMigratedPasswords](#hasmigratedpasswords)
* [hasPinnedTabs](#haspinnedtabs)
* [hasSelectableProfiles](#hasselectableprofiles)
* [homePageSettings](#homepagesettings)
* [isBackgroundTaskMode](#isbackgroundtaskmode)
* [isChinaRepack](#ischinarepack)
@@ -1031,6 +1033,14 @@ A boolean. `true` if the user is configured to use the embedded Migration Wizard
A boolean. `true` when [RTAMO](first-run.md#return-to-amo-rtamo) has been used to download Firefox, `false` otherwise.
### `canCreateSelectableProfiles`
A boolean. `true` when both the current install and current profile support creating additional profiles using the `SelectableProfileService`; `false` otherwise.
### `hasSelectableProfiles`
A boolean. `true` when the `toolkit.profiles.storeID` pref has a value. Indicates that the profile is part of a profile group managed by the `SelectableProfileService`, and the user has used the multiple profiles feature. `false` otherwise.
### `isMSIX`
A boolean. `true` when hasPackageId is `true` on Windows, `false` otherwise.

View File

@@ -50,6 +50,9 @@ ChromeUtils.defineESModuleGetters(lazy, {
HomePage: "resource:///modules/HomePage.sys.mjs",
ProfileAge: "resource://gre/modules/ProfileAge.sys.mjs",
Region: "resource://gre/modules/Region.sys.mjs",
// eslint-disable-next-line mozilla/no-browser-refs-in-toolkit
SelectableProfileService:
"resource:///modules/profiles/SelectableProfileService.sys.mjs",
TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs",
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
TelemetrySession: "resource://gre/modules/TelemetrySession.sys.mjs",
@@ -167,6 +170,12 @@ XPCOMUtils.defineLazyPreferenceGetter(
: 0;
}
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"profileStoreID",
"toolkit.profiles.storeID",
null
);
XPCOMUtils.defineLazyServiceGetters(lazy, {
AUS: ["@mozilla.org/updates/update-service;1", "nsIApplicationUpdateService"],
@@ -577,6 +586,15 @@ const TargetingGetters = {
get currentDate() {
return new Date();
},
get canCreateSelectableProfiles() {
if (!AppConstants.MOZ_SELECTABLE_PROFILES) {
return null;
}
return !!lazy.SelectableProfileService?.groupToolkitProfile;
},
get hasSelectableProfiles() {
return !!lazy.profileStoreID;
},
get profileAgeCreated() {
return lazy.ProfileAge().then(times => times.created);
},

View File

@@ -19,6 +19,56 @@ const isMSIX =
Services.sysinfo.getProperty("hasWinPackageId", false);
const MESSAGES = () => [
{
id: "NEW_PROFILE_SPOTLIGHT",
groups: [],
targeting: "canCreateSelectableProfiles && !hasSelectableProfiles",
trigger: {
id: "defaultBrowserCheck",
},
template: "spotlight",
content: {
template: "multistage",
modal: "tab",
screens: [
{
id: "SCREEN_1",
content: {
logo: {
imageURL:
"https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/a3c640c8-7594-4bb2-bc18-8b4744f3aaf2.gif",
},
title: {
raw: "Say hello to Firefox profiles",
paddingBlock: "8px",
},
subtitle: {
raw: "Easily switch between browsing for work and fun. Profiles keep your browsing info, including search history and passwords, totally separate so you can stay organized.",
},
dismiss_button: {
action: {
dismiss: true,
},
},
primary_button: {
label: "Create a profile",
action: {
navigate: true,
type: "CREATE_NEW_SELECTABLE_PROFILE",
},
},
secondary_button: {
label: "Not now",
action: {
dismiss: true,
},
},
},
},
],
transitions: true,
},
},
{
id: "WNP_THANK_YOU",
template: "update_action",

View File

@@ -211,6 +211,50 @@ add_task(async function checkCurrentDate() {
);
});
add_task(async function check_canCreateSelectableProfiles() {
if (!AppConstants.MOZ_SELECTABLE_PROFILES) {
// `mochitest-browser` suite `add_task` does not yet support
// `properties.skip_if`.
ok(true, "Skipping because !AppConstants.MOZ_SELECTABLE_PROFILES");
return;
}
is(
await ASRouterTargeting.Environment.canCreateSelectableProfiles,
true,
"should return true if the current profile is valid for use with SelectableProfileService"
);
const message = { id: "foo", targeting: "canCreateSelectableProfiles" };
is(
await ASRouterTargeting.findMatchingMessage({ messages: [message] }),
message,
"should select correct item by canCreateSelectableProfiles"
);
});
add_task(async function check_hasSelectableProfiles() {
is(
await ASRouterTargeting.Environment.hasSelectableProfiles,
false,
"should return false before the pref is set"
);
await pushPrefs(["toolkit.profiles.storeID", "someValue"]);
is(
await ASRouterTargeting.Environment.hasSelectableProfiles,
true,
"should return true if the pref is set"
);
const message = { id: "foo", targeting: "hasSelectableProfiles" };
is(
await ASRouterTargeting.findMatchingMessage({ messages: [message] }),
message,
"should select correct item by hasSelectableProfiles"
);
});
add_task(async function check_usesFirefoxSync() {
await pushPrefs(["services.sync.username", "someone@foo.com"]);
is(

View File

@@ -22,7 +22,7 @@ add_task(async function test_PanelTestProvider() {
cfr_doorhanger: 1,
milestone_message: 0,
update_action: 1,
spotlight: 3,
spotlight: 4,
feature_callout: 2,
pb_newtab: 2,
toast_notification: 3,