1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
6 const { ExperimentAPI
} = ChromeUtils
.importESModule(
7 "resource://nimbus/ExperimentAPI.sys.mjs"
9 const { ExperimentFakes
} = ChromeUtils
.importESModule(
10 "resource://testing-common/NimbusTestUtils.sys.mjs"
12 const { ContentRelevancyManager
} = ChromeUtils
.importESModule(
13 "resource://gre/modules/ContentRelevancyManager.sys.mjs"
15 const { sinon
} = ChromeUtils
.importESModule(
16 "resource://testing-common/Sinon.sys.mjs"
22 gSandbox
= sinon
.createSandbox();
24 registerCleanupFunction(() => {
30 * Test Nimbus integration - enable.
32 add_task(async
function test_NimbusIntegration_enable() {
33 gSandbox
.spy(ContentRelevancyManager
, "notify");
35 await ExperimentAPI
.ready();
36 const doExperimentCleanup
= await ExperimentFakes
.enrollWithFeatureConfig({
37 featureId
: "contentRelevancy",
42 // Set the timer interval to 0 will trigger the timer right away.
48 await TestUtils
.waitForCondition(
49 () => ContentRelevancyManager
.shouldEnable
,
50 "Should enable it via Nimbus"
53 await TestUtils
.waitForCondition(
54 () => ContentRelevancyManager
.notify
.called
,
55 "The timer callback should be called"
58 doExperimentCleanup();
63 * Test Nimbus integration - disable.
65 add_task(async
function test_NimbusIntegration_disable() {
66 gSandbox
.spy(ContentRelevancyManager
, "notify");
68 await ExperimentAPI
.ready();
69 const doExperimentCleanup
= await ExperimentFakes
.enrollWithFeatureConfig({
70 featureId
: "contentRelevancy",
75 // Set the timer interval to 0 will trigger the timer right away.
81 await TestUtils
.waitForCondition(
82 () => !ContentRelevancyManager
.shouldEnable
,
83 "Should disable it via Nimbus"
86 await TestUtils
.waitForCondition(
87 () => ContentRelevancyManager
.notify
.notCalled
,
88 "The timer callback should not be called"
91 doExperimentCleanup();