diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
commit | def92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch) | |
tree | 2ef34b9ad8bb9a9220e05d60352558b15f513894 /toolkit/components/contentrelevancy/tests/browser | |
parent | Adding debian version 125.0.3-1. (diff) | |
download | firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/contentrelevancy/tests/browser')
-rw-r--r-- | toolkit/components/contentrelevancy/tests/browser/browser.toml | 6 | ||||
-rw-r--r-- | toolkit/components/contentrelevancy/tests/browser/browser_contentrelevancy_nimbus.js | 91 |
2 files changed, 97 insertions, 0 deletions
diff --git a/toolkit/components/contentrelevancy/tests/browser/browser.toml b/toolkit/components/contentrelevancy/tests/browser/browser.toml new file mode 100644 index 0000000000..ec1d3a3e66 --- /dev/null +++ b/toolkit/components/contentrelevancy/tests/browser/browser.toml @@ -0,0 +1,6 @@ +[DEFAULT] +prefs = [ + "toolkit.contentRelevancy.enabled=false", +] + +["browser_contentrelevancy_nimbus.js"] diff --git a/toolkit/components/contentrelevancy/tests/browser/browser_contentrelevancy_nimbus.js b/toolkit/components/contentrelevancy/tests/browser/browser_contentrelevancy_nimbus.js new file mode 100644 index 0000000000..47d54c2a87 --- /dev/null +++ b/toolkit/components/contentrelevancy/tests/browser/browser_contentrelevancy_nimbus.js @@ -0,0 +1,91 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { ExperimentAPI } = ChromeUtils.importESModule( + "resource://nimbus/ExperimentAPI.sys.mjs" +); +const { ExperimentFakes } = ChromeUtils.importESModule( + "resource://testing-common/NimbusTestUtils.sys.mjs" +); +const { ContentRelevancyManager } = ChromeUtils.importESModule( + "resource://gre/modules/ContentRelevancyManager.sys.mjs" +); +const { sinon } = ChromeUtils.importESModule( + "resource://testing-common/Sinon.sys.mjs" +); + +let gSandbox; + +add_setup(() => { + gSandbox = sinon.createSandbox(); + + registerCleanupFunction(() => { + gSandbox.restore(); + }); +}); + +/** + * Test Nimbus integration - enable. + */ +add_task(async function test_NimbusIntegration_enable() { + gSandbox.spy(ContentRelevancyManager, "notify"); + + await ExperimentAPI.ready(); + const doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ + featureId: "contentRelevancy", + value: { + enabled: true, + minInputUrls: 1, + maxInputUrls: 3, + // Set the timer interval to 0 will trigger the timer right away. + timerInterval: 0, + }, + }); + + await TestUtils.waitForCondition( + () => ContentRelevancyManager.shouldEnable, + "Should enable it via Nimbus" + ); + + await TestUtils.waitForCondition( + () => ContentRelevancyManager.notify.called, + "The timer callback should be called" + ); + + await doExperimentCleanup(); + gSandbox.restore(); +}); + +/** + * Test Nimbus integration - disable. + */ +add_task(async function test_NimbusIntegration_disable() { + gSandbox.spy(ContentRelevancyManager, "notify"); + + await ExperimentAPI.ready(); + const doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ + featureId: "contentRelevancy", + value: { + enabled: false, + minInputUrls: 1, + maxInputUrls: 3, + // Set the timer interval to 0 will trigger the timer right away. + timerInterval: 0, + }, + }); + + await TestUtils.waitForCondition( + () => !ContentRelevancyManager.shouldEnable, + "Should disable it via Nimbus" + ); + + await TestUtils.waitForCondition( + () => ContentRelevancyManager.notify.notCalled, + "The timer callback should not be called" + ); + + await doExperimentCleanup(); + gSandbox.restore(); +}); |