diff --git a/toolkit/components/normandy/lib/RecipeRunner.jsm b/toolkit/components/normandy/lib/RecipeRunner.jsm index a09e08ef67d8..ecdde8fe4380 100644 --- a/toolkit/components/normandy/lib/RecipeRunner.jsm +++ b/toolkit/components/normandy/lib/RecipeRunner.jsm @@ -284,6 +284,8 @@ var RecipeRunner = { arguments: recipe.arguments, }; return { + environment, + // Backwards compatibility -- see bug 1477255. normandy: environment, }; }, diff --git a/toolkit/components/normandy/test/browser/browser_RecipeRunner.js b/toolkit/components/normandy/test/browser/browser_RecipeRunner.js index 08d6f24cfbb7..8251ec1fd462 100644 --- a/toolkit/components/normandy/test/browser/browser_RecipeRunner.js +++ b/toolkit/components/normandy/test/browser/browser_RecipeRunner.js @@ -37,26 +37,29 @@ add_task(async function getFilterContext() { "version", ]; for (const key of expectedNormandyKeys) { + ok(key in context.environment, `environment.${key} is available`); ok(key in context.normandy, `normandy.${key} is available`); } + Assert.deepEqual(context.normandy, context.environment, + "context offers normandy as backwards-compatible alias for context.environment"); is( - context.normandy.recipe.id, + context.environment.recipe.id, recipe.id, - "normandy.recipe is the recipe passed to getFilterContext", + "environment.recipe is the recipe passed to getFilterContext", ); delete recipe.unrelated; Assert.deepEqual( - context.normandy.recipe, + context.environment.recipe, recipe, - "normandy.recipe drops unrecognized attributes from the 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.normandy.userId, "some id", "User id is read from prefs when accessed"); + is(context.environment.userId, "some id", "User id is read from prefs when accessed"); await SpecialPowers.pushPrefEnv({set: [["app.normandy.user_id", "real id"]]}); - is(context.normandy.userId, "some id", "userId was cached"); + is(context.environment.userId, "some id", "userId was cached"); });