Bug 1700405 - Make it possible to skip the NS check when a host is added into blocked list, r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D117284
This commit is contained in:
Kershaw Chang 2021-06-15 13:59:10 +00:00
parent eaa8bc77cc
commit b7427a5f15
3 changed files with 21 additions and 3 deletions

View File

@ -9557,6 +9557,13 @@
value: ""
mirror: never
# Whether to skip the NS check for the blocked host.
# Note this is used for test only.
- name: network.trr.skip-check-for-blocked-host
type: RelaxedAtomicBool
value: false
mirror: always
# Allow the network changed event to get sent when a network topology or setup
# change is noticed while running.
- name: network.notify.changed

View File

@ -1007,7 +1007,10 @@ void TRRService::AddToBlocklist(const nsACString& aHost,
bl->InsertOrUpdate(hashkey, NowInSeconds());
}
if (aParentsToo) {
// See bug 1700405. Some test expects 15 trr consecutive failures, but the NS
// check against the base domain is successful. So, we skip this NS check when
// the pref said so in order to pass the test reliably.
if (aParentsToo && !StaticPrefs::network_trr_skip_check_for_blocked_host()) {
// when given a full host name, verify its domain as well
int32_t dot = aHost.FindChar('.');
if (dot != kNotFound) {

View File

@ -28,9 +28,15 @@ const CONFIRM_FAILED = 3;
const CONFIRM_TRYING_FAILED = 4;
const CONFIRM_DISABLED = 5;
trr_test_setup();
function setup() {
trr_test_setup();
Services.prefs.setBoolPref("network.trr.skip-check-for-blocked-host", true);
}
setup();
registerCleanupFunction(async () => {
trr_clear_prefs();
Services.prefs.clearUserPref("network.trr.skip-check-for-blocked-host");
});
let trrServer = null;
@ -70,7 +76,9 @@ function trigger15Failures() {
dns.clearCache(true);
let dnsRequests = [];
for (let i = 0; i < 15; i++) {
// There are actually two TRR requests sent for A and AAAA records, so doing
// DNS query 10 times should be enough to trigger confirmation process.
for (let i = 0; i < 10; i++) {
dnsRequests.push(
new TRRDNSListener(`failing-domain${i}.faily.com`, {
expectedAnswer: "127.0.0.1",