Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit b398609

Browse files
committed
Bug 1691526 - Enable 'os' level targeting for Nimbus Experiment r=k88hudson
Differential Revision: https://phabricator.services.mozilla.com/D104545
1 parent 5fd39ec commit b398609

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

toolkit/components/messaging-system/targeting/Targeting.jsm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
1515
FilterExpressions:
1616
"resource://gre/modules/components-utils/FilterExpressions.jsm",
1717
ClientEnvironment: "resource://normandy/lib/ClientEnvironment.jsm",
18+
ClientEnvironmentBase:
19+
"resource://gre/modules/components-utils/ClientEnvironment.jsm",
1820
AppConstants: "resource://gre/modules/AppConstants.jsm",
1921
});
2022

@@ -56,6 +58,10 @@ const TargetingEnvironment = {
5658
get platform() {
5759
return AppConstants.platform;
5860
},
61+
62+
get os() {
63+
return ClientEnvironmentBase.os;
64+
},
5965
};
6066

6167
class TargetingContext {

toolkit/components/messaging-system/targeting/test/unit/test_targeting.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,15 @@ add_task(async function test_default_targeting() {
243243
);
244244
}
245245
});
246+
247+
add_task(async function test_targeting_os() {
248+
const targeting = new TargetingContext();
249+
let res = await targeting.eval(
250+
"ctx.os.isWindows || ctx.os.isMac || ctx.os.isLinux"
251+
);
252+
Assert.ok(res, `Should detect a platform got: ${res}`);
253+
res = await targeting.eval(
254+
"(ctx.os.windowsVersion && ctx.os.windowsBuildNumber) || ctx.os.macVersion || ctx.os.darwinVersion"
255+
);
256+
Assert.ok(res, `Should detect platform version got: ${res}`);
257+
});

0 commit comments

Comments
 (0)