summaryrefslogtreecommitdiffstats
path: root/toolkit/components/glean/tests/xpcshell/test_GleanExperiments.js
blob: cf8871e9d11d91b8d2e42d3804c369c427bc74a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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));
});