This repository was archived by the owner on Jul 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
toolkit/components/messaging-system/targeting Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
15
15
FilterExpressions :
16
16
"resource://gre/modules/components-utils/FilterExpressions.jsm" ,
17
17
ClientEnvironment : "resource://normandy/lib/ClientEnvironment.jsm" ,
18
+ ClientEnvironmentBase :
19
+ "resource://gre/modules/components-utils/ClientEnvironment.jsm" ,
18
20
AppConstants : "resource://gre/modules/AppConstants.jsm" ,
19
21
} ) ;
20
22
@@ -56,6 +58,10 @@ const TargetingEnvironment = {
56
58
get platform ( ) {
57
59
return AppConstants . platform ;
58
60
} ,
61
+
62
+ get os ( ) {
63
+ return ClientEnvironmentBase . os ;
64
+ } ,
59
65
} ;
60
66
61
67
class TargetingContext {
Original file line number Diff line number Diff line change @@ -243,3 +243,15 @@ add_task(async function test_default_targeting() {
243
243
) ;
244
244
}
245
245
} ) ;
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments