Bug 1735628 - Test FOG Experiment Annotations r=TravisLong
authorChris H-C <chutten@mozilla.com>
Tue, 19 Oct 2021 20:32:39 +0000
changeset 596412 db955030e715dbea2ad7b33e26ea2bf4ff4f8ca9
parent 596411 5ce42bec78810e9f16b8dae078bb261e890db979
child 596413 efde0d0929be5f23705577d98fd6eacbc9ae5bfb
push id38898
push userimoraru@mozilla.com
push dateThu, 21 Oct 2021 03:32:00 +0000
treeherdermozilla-central@811f11b91f11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersTravisLong
bugs1735628
milestone95.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 1735628 - Test FOG Experiment Annotations r=TravisLong Depends on D128929 Differential Revision: https://phabricator.services.mozilla.com/D128930
toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js
toolkit/components/glean/tests/xpcshell/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js
@@ -0,0 +1,30 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// FOG needs a profile directory to put its data in.
+do_get_profile();
+
+const FOG = Cc["@mozilla.org/toolkit/glean;1"].createInstance(Ci.nsIFOG);
+// We need to initialize it once, otherwise operations will be stuck in the pre-init queue.
+FOG.initializeFOG();
+
+add_task(function test_fog_experiment_annotations() {
+
+  const id = "my-experiment-id";
+  const branch = "my-branch";
+  const extra = { extra_key: "extra_value" };
+  FOG.setExperimentActive(id, branch, extra);
+
+  let data = FOG.testGetExperimentData(id);
+  Assert.equal(data.branch, branch);
+  Assert.deepEqual(data.extra, extra);
+
+  // Unknown id gets nothing.
+  Assert.equal(undefined, FOG.testGetExperimentData(id + id));
+
+  // Inactive id gets nothing.
+  FOG.setExperimentInactive(id);
+  Assert.equal(undefined, FOG.testGetExperimentData(id));
+});
--- a/toolkit/components/glean/tests/xpcshell/xpcshell.ini
+++ b/toolkit/components/glean/tests/xpcshell/xpcshell.ini
@@ -7,8 +7,11 @@ skip-if = os == "android" # Disabled unt
 [test_Glean.js]
 skip-if = os == "android" # Disabled until FOG is enabled on GeckoView (bug 1670261)
 
 [test_GleanAndroid.js]
 skip-if = os != "android" # Required until FOG is enabled on GeckoView (bug 1670261)
 
 [test_GleanIPC.js]
 skip-if = os == "android" # FOG doesn't do IPC on Android
+
+[test_GleanExperiments.js]
+skip-if = os == "android" # FOG isn't responsible for experiment annotations on Android