diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/components/urlbar/tests/unit/test_frecency_alternative_nimbus.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/urlbar/tests/unit/test_frecency_alternative_nimbus.js')
-rw-r--r-- | browser/components/urlbar/tests/unit/test_frecency_alternative_nimbus.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/browser/components/urlbar/tests/unit/test_frecency_alternative_nimbus.js b/browser/components/urlbar/tests/unit/test_frecency_alternative_nimbus.js new file mode 100644 index 0000000000..d50d5314ad --- /dev/null +++ b/browser/components/urlbar/tests/unit/test_frecency_alternative_nimbus.js @@ -0,0 +1,77 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +add_task(async function () { + const tests = [ + { + enableVariable: "originsAlternativeEnable", + enablePref: "places.frecency.origins.alternative.featureGate", + variables: { + originsDaysCutOff: "places.frecency.origins.alternative.daysCutOff", + }, + }, + { + enableVariable: "pagesAlternativeEnable", + enablePref: "places.frecency.pages.alternative.featureGate", + variables: { + pagesNumSampledVisits: + "places.frecency.pages.alternative.numSampledVisits", + pagesHalfLifeDays: "places.frecency.pages.alternative.halfLifeDays", + pagesHighWeight: "places.frecency.pages.alternative.highWeight", + pagesMediumWeight: "places.frecency.pages.alternative.mediumWeight", + pagesLowWeight: "places.frecency.pages.alternative.lowWeight", + }, + }, + ]; + for (let test of tests) { + await doTest(test.enableVariable, test.enablePref, test.variables); + } +}); + +async function doTest(enableVariable, enablePref, otherVariables) { + info(`Testing ${enableVariable}`); + let reset = await UrlbarTestUtils.initNimbusFeature( + { + // Empty for sanity check. + }, + "urlbar", + "config" + ); + Assert.ok(!Services.prefs.prefHasUserValue(enablePref)); + Assert.ok(!Services.prefs.getBoolPref(enablePref, false)); + for (let pref of Object.values(otherVariables)) { + Assert.ok(!Services.prefs.prefHasUserValue(pref)); + } + await reset(); + + reset = await UrlbarTestUtils.initNimbusFeature( + { + [enableVariable]: true, + }, + "urlbar", + "config" + ); + Assert.ok(Services.prefs.prefHasUserValue(enablePref)); + Assert.equal(Services.prefs.getBoolPref(enablePref), true); + for (let pref of Object.values(otherVariables)) { + Assert.ok(!Services.prefs.prefHasUserValue(pref)); + } + await reset(); + + const FAKE_VALUE = 777; + let config = { + [enableVariable]: true, + }; + for (let variable of Object.keys(otherVariables)) { + config[variable] = FAKE_VALUE; + } + reset = await UrlbarTestUtils.initNimbusFeature(config, "urlbar", "config"); + Assert.ok(Services.prefs.prefHasUserValue(enablePref)); + Assert.equal(Services.prefs.getBoolPref(enablePref), true); + for (let pref of Object.values(otherVariables)) { + Assert.ok(Services.prefs.prefHasUserValue(pref)); + Assert.equal(Services.prefs.getIntPref(pref, 90), FAKE_VALUE); + } + + await reset(); +} |