Bug 1659842 - Make normandy.liveTelemetry accessible from consolidated targeting r=andreio

Differential Revision: https://phabricator.services.mozilla.com/D87521
This commit is contained in:
Michael Cooper 2020-08-19 10:31:51 +00:00
Родитель e116198cc4
Коммит ff83a641c9
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,6 @@
const { ClientEnvironment } = ChromeUtils.import(
"resource://normandy/lib/ClientEnvironment.jsm"
);
const { TargetingContext } = ChromeUtils.import(
"resource://messaging-system/targeting/Targeting.jsm"
);
@ -204,3 +207,13 @@ add_task(async function test_telemetry_event_error() {
TelemetryTestUtils.assertEvents(expectedEvents);
Services.telemetry.clearEvents();
});
// Make sure that when using the Normandy-style ClientEnvironment context,
// `liveTelemetry` works. `liveTelemetry` is a particularly tricky object to
// proxy, so it's useful to check specifically.
add_task(async function test_live_telemetry() {
let ctx = { env: ClientEnvironment };
let targeting = new TargetingContext();
// This shouldn't throw.
await targeting.eval("env.liveTelemetry.main", ctx);
});

Просмотреть файл

@ -16,7 +16,6 @@ ChromeUtils.defineModuleGetter(this, "AppConstants", "resource://gre/modules/App
ChromeUtils.defineModuleGetter(this, "AttributionCode", "resource:///modules/AttributionCode.jsm");
ChromeUtils.defineModuleGetter(this, "WindowsVersionInfo", "resource://gre/modules/components-utils/WindowsVersionInfo.jsm");
ChromeUtils.defineModuleGetter(this, "NormandyUtils", "resource://normandy/lib/NormandyUtils.jsm");
/* eslint-enable prettier/prettier */
var EXPORTED_SYMBOLS = ["ClientEnvironmentBase"];
@ -82,6 +81,10 @@ class ClientEnvironmentBase {
if (prop == "main") {
return target.main;
}
if (prop == "then") {
// this isn't a Promise, but it's not a problem to check
return undefined;
}
throw new Error(
`Live telemetry only includes the main ping, not the ${prop} ping`
);