diff options
Diffstat (limited to 'toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js')
-rw-r--r-- | toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js b/toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js new file mode 100644 index 0000000000..cf8871e9d1 --- /dev/null +++ b/toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js @@ -0,0 +1,28 @@ +/* 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(); + +// We need to initialize it once, otherwise operations will be stuck in the pre-init queue. +Services.fog.initializeFOG(); + +add_task(function test_fog_experiment_annotations() { + const id = "my-experiment-id"; + const branch = "my-branch"; + const extra = { extra_key: "extra_value" }; + Services.fog.setExperimentActive(id, branch, extra); + + let data = Services.fog.testGetExperimentData(id); + Assert.equal(data.branch, branch); + Assert.deepEqual(data.extra, extra); + + // Unknown id gets nothing. + Assert.equal(undefined, Services.fog.testGetExperimentData(id + id)); + + // Inactive id gets nothing. + Services.fog.setExperimentInactive(id); + Assert.equal(undefined, Services.fog.testGetExperimentData(id)); +}); |