Bug 1780015 - Add targeting for users who prefer reduced motion in AboutWelcome message surfaces r=pdahiya

Differential Revision: https://phabricator.services.mozilla.com/D152174
This commit is contained in:
Meg Viar 2022-07-22 17:10:26 +00:00
parent bdc4ade597
commit 98f95b2a3f
3 changed files with 19 additions and 0 deletions

View File

@ -55,6 +55,7 @@ Please note that some targeting attributes require stricter controls on the tele
* [doesAppNeedPrivatePin](#doesappneedprivatepin)
* [isBackgroundTaskMode](#isbackgroundtaskmode)
* [backgroundTaskName](#backgroundtaskname)
* [userPrefersReducedMotion](#userPrefersReducedMotion)
## Detailed usage
@ -843,3 +844,8 @@ Checks if this invocation is running in background task mode.
A non-empty string task name if this invocation is running in background task
mode, or `null` if this invocation is not running in background task mode.
### `userPrefersReducedMotion`
Checks if user prefers reduced motion as indicated by the value of a media query for `prefers-reduced-motion`.

View File

@ -741,6 +741,11 @@ const TargetingGetters = {
);
return bts?.backgroundTaskName();
},
get userPrefersReducedMotion() {
let window = lazy.BrowserWindowTracker.getTopWindow();
return window?.matchMedia("(prefers-reduced-motion: reduce)")?.matches;
},
};
const ASRouterTargeting = {

View File

@ -1163,3 +1163,11 @@ add_task(async function check_isBackgroundTaskMode() {
"Has no background task name"
);
});
add_task(async function check_userPrefersReducedMotion() {
is(
typeof (await ASRouterTargeting.Environment.userPrefersReducedMotion),
"boolean",
"Should return a boolean"
);
});