1
0
Fork 0
firefox/toolkit/components/antitracking/test/browser/browser_nimbus_thirdPartyTrackerCookieBlocking.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

89 lines
2.4 KiB
JavaScript

/* 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 { NimbusTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/NimbusTestUtils.sys.mjs"
);
add_task(async function test_nimbus_tracker_cookie_blocking_feature() {
await ExperimentAPI.ready();
let originalPrefValue = Services.prefs.getBoolPref(
"network.cookie.cookieBehavior.trackerCookieBlocking"
);
info("Enroll with the third party tracker cookie blocking feature.");
let doExperimentCleanup = await NimbusTestUtils.enrollWithFeatureConfig({
featureId: "thirdPartyTrackerCookieBlocking",
value: {
enabled: true,
},
});
is(
Services.prefs.getBoolPref(
"network.cookie.cookieBehavior.trackerCookieBlocking"
),
true,
"The third party tracker cookie blocking pref has been set correctly"
);
is(
Services.prefs
.getDefaultBranch("")
.getBoolPref("network.cookie.cookieBehavior.trackerCookieBlocking"),
true,
"The third party tracker cookie blocking pref has been set correctly to the default branch"
);
await doExperimentCleanup();
is(
Services.prefs.getBoolPref(
"network.cookie.cookieBehavior.trackerCookieBlocking"
),
originalPrefValue,
"The third party tracker cookie blocking pref has been reset correctly"
);
info(
"Enroll with the third party tracker cookie blocking feature with different settings."
);
doExperimentCleanup = await NimbusTestUtils.enrollWithFeatureConfig({
featureId: "thirdPartyTrackerCookieBlocking",
value: {
enabled: false,
},
});
is(
Services.prefs.getBoolPref(
"network.cookie.cookieBehavior.trackerCookieBlocking"
),
false,
"The third party tracker cookie blocking pref has been set correctly"
);
is(
Services.prefs
.getDefaultBranch("")
.getBoolPref("network.cookie.cookieBehavior.trackerCookieBlocking"),
false,
"The third party tracker cookie blocking pref has been set correctly to the default branch"
);
await doExperimentCleanup();
is(
Services.prefs.getBoolPref(
"network.cookie.cookieBehavior.trackerCookieBlocking"
),
originalPrefValue,
"The third party tracker cookie blocking pref has been reset correctly"
);
});