Bug 1518292: use env instead of environment in JEXL context r=Gijs
authorEthan Glasser-Camp <ethan@betacantrips.com>
Tue, 08 Jan 2019 23:52:35 +0000
changeset 512980 b0858dddedf9
parent 512979 a9422d15a9f5
child 512981 5420c29d49d6
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1518292
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1518292: use env instead of environment in JEXL context r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D15951
services/settings/remote-settings.js
services/settings/test/unit/test_remote_settings_jexl_filters.js
toolkit/components/normandy/lib/RecipeRunner.jsm
toolkit/components/normandy/test/browser/browser_RecipeRunner.js
--- a/services/settings/remote-settings.js
+++ b/services/settings/remote-settings.js
@@ -61,17 +61,17 @@ XPCOMUtils.defineLazyPreferenceGetter(th
 async function jexlFilterFunc(entry, environment) {
   const { filter_expression } = entry;
   if (!filter_expression) {
     return entry;
   }
   let result;
   try {
     const context = {
-      environment,
+      env: environment,
     };
     result = await FilterExpressions.eval(filter_expression, context);
   } catch (e) {
     Cu.reportError(e);
   }
   return result ? entry : null;
 }
 
--- a/services/settings/test/unit/test_remote_settings_jexl_filters.js
+++ b/services/settings/test/unit/test_remote_settings_jexl_filters.js
@@ -51,23 +51,23 @@ add_task(async function test_returns_ent
   }, {
     willMatch: true,
     filter_expression: "[42]",
   }, {
     willMatch: true,
     filter_expression: "1 == 2 || 1 == 1",
   }, {
     willMatch: true,
-    filter_expression: 'environment.appID == "xpcshell@tests.mozilla.org"',
+    filter_expression: 'env.appID == "xpcshell@tests.mozilla.org"',
   }, {
     willMatch: false,
-    filter_expression: "environment.version == undefined",
+    filter_expression: "env.version == undefined",
   }, {
     willMatch: true,
-    filter_expression: "environment.unknown == undefined",
+    filter_expression: "env.unknown == undefined",
   }, {
     willMatch: false,
     filter_expression: "1 == 2",
   }]);
 
   const list = await client.get();
   equal(list.length, 5);
   ok(list.every(e => e.willMatch));
--- a/toolkit/components/normandy/lib/RecipeRunner.jsm
+++ b/toolkit/components/normandy/lib/RecipeRunner.jsm
@@ -279,17 +279,17 @@ var RecipeRunner = {
 
   getFilterContext(recipe) {
     const environment = cacheProxy(ClientEnvironment);
     environment.recipe = {
       id: recipe.id,
       arguments: recipe.arguments,
     };
     return {
-      environment,
+      env: environment,
       // Backwards compatibility -- see bug 1477255.
       normandy: environment,
     };
   },
 
   /**
    * Evaluate a recipe's filter expression against the environment.
    * @param {object} recipe
--- a/toolkit/components/normandy/test/browser/browser_RecipeRunner.js
+++ b/toolkit/components/normandy/test/browser/browser_RecipeRunner.js
@@ -32,39 +32,39 @@ add_task(async function getFilterContext
     "syncMobileDevices",
     "syncSetup",
     "syncTotalDevices",
     "telemetry",
     "userId",
     "version",
   ];
   for (const key of expectedNormandyKeys) {
-    ok(key in context.environment, `environment.${key} is available`);
+    ok(key in context.env, `env.${key} is available`);
     ok(key in context.normandy, `normandy.${key} is available`);
   }
-  Assert.deepEqual(context.normandy, context.environment,
+  Assert.deepEqual(context.normandy, context.env,
                    "context offers normandy as backwards-compatible alias for context.environment");
 
   is(
-    context.environment.recipe.id,
+    context.env.recipe.id,
     recipe.id,
     "environment.recipe is the recipe passed to getFilterContext",
   );
   delete recipe.unrelated;
   Assert.deepEqual(
-    context.environment.recipe,
+    context.env.recipe,
     recipe,
     "environment.recipe drops unrecognized attributes from the recipe",
   );
 
   // Filter context attributes are cached.
   await SpecialPowers.pushPrefEnv({set: [["app.normandy.user_id", "some id"]]});
-  is(context.environment.userId, "some id", "User id is read from prefs when accessed");
+  is(context.env.userId, "some id", "User id is read from prefs when accessed");
   await SpecialPowers.pushPrefEnv({set: [["app.normandy.user_id", "real id"]]});
-  is(context.environment.userId, "some id", "userId was cached");
+  is(context.env.userId, "some id", "userId was cached");
 
 });
 
 add_task(async function checkFilter() {
   const check = filter => RecipeRunner.checkFilter({filter_expression: filter});
 
   // Errors must result in a false return value.
   ok(!(await check("invalid ( + 5yntax")), "Invalid filter expressions return false");