Bug 1743122 - Disable TRR temp blocklist feature in tests. r=valentin,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D132245
This commit is contained in:
Nihanth Subramanya 2021-12-01 17:32:20 +00:00
parent c0e84672de
commit a993ca428a
3 changed files with 25 additions and 0 deletions

View File

@ -9856,6 +9856,15 @@
value: @IS_NIGHTLY_BUILD@
mirror: always
# If false, the temporary blocklisting feature is disabled.
# This is useful for tests to prevent bleeding extra reqs
# between tasks, since we may attempt to look up the
# parent domain in the background when blocklisting a host.
- name: network.trr.temp_blocklist
type: RelaxedAtomicBool
value: true
mirror: always
# Single TRR request timeout, in milliseconds
- name: network.trr.request_timeout_ms
type: RelaxedAtomicUint32

View File

@ -889,6 +889,11 @@ bool TRRService::IsTemporarilyBlocked(const nsACString& aHost,
bool aPrivateBrowsing,
bool aParentsToo) // false if domain
{
if (!StaticPrefs::network_trr_temp_blocklist()) {
LOG(("TRRService::IsTemporarilyBlocked temp blocklist disabled by pref"));
return false;
}
if (mMode == nsIDNSService::MODE_TRRONLY) {
return false; // might as well try
}
@ -970,6 +975,11 @@ bool TRRService::IsExcludedFromTRR_unlocked(const nsACString& aHost) {
void TRRService::AddToBlocklist(const nsACString& aHost,
const nsACString& aOriginSuffix,
bool privateBrowsing, bool aParentsToo) {
if (!StaticPrefs::network_trr_temp_blocklist()) {
LOG(("TRRService::AddToBlocklist temp blocklist disabled by pref"));
return;
}
LOG(("TRR blocklist %s\n", nsCString(aHost).get()));
nsAutoCString hashkey(aHost + aOriginSuffix);

View File

@ -60,6 +60,11 @@ function trr_test_setup() {
// Turn off strict fallback mode for most tests, it is tested specifically.
Services.prefs.setBoolPref("network.trr.strict_native_fallback", false);
// Turn off temp blocklist feature in tests. When enabled we may issue a
// lookup to resolve a parent name when blocklisting, which may bleed into
// and interfere with subsequent tasks.
Services.prefs.setBoolPref("network.trr.temp_blocklist", false);
// We intentionally don't set the TRR mode. Each test should set it
// after setup in the first test.
@ -95,6 +100,7 @@ function trr_clear_prefs() {
"network.trr.send_empty_accept-encoding_headers"
);
Services.prefs.clearUserPref("network.trr.strict_native_fallback");
Services.prefs.clearUserPref("network.trr.temp_blocklist");
}
/// This class sends a DNS query and can be awaited as a promise to get the