test_trr_strict_mode.js (1596B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 function setup() { 8 trr_test_setup(); 9 } 10 setup(); 11 12 add_task(async function checkBlocklisting() { 13 Services.prefs.setBoolPref("network.trr.temp_blocklist", true); 14 Services.prefs.setBoolPref("network.trr.strict_native_fallback", true); 15 16 let trrServer = new TRRServer(); 17 registerCleanupFunction(async () => { 18 await trrServer.stop(); 19 }); 20 await trrServer.start(); 21 info(`port = ${trrServer.port()}\n`); 22 23 Services.dns.clearCache(true); 24 Services.prefs.setCharPref( 25 "network.trr.uri", 26 `https://foo.example.com:${trrServer.port()}/dns-query` 27 ); 28 Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST); 29 30 // Check that we properly fallback to native DNS for a variety of DNS rcodes 31 for (let i = 0; i <= 5; i++) { 32 info(`testing rcode=${i}`); 33 await trrServer.registerDoHAnswers(`sub${i}.blocklisted.com`, "A", { 34 flags: i, 35 }); 36 await trrServer.registerDoHAnswers(`sub${i}.blocklisted.com`, "AAAA", { 37 flags: i, 38 }); 39 40 await new TRRDNSListener(`sub${i}.blocklisted.com`, { 41 expectedAnswer: "127.0.0.1", 42 }); 43 Services.dns.clearCache(true); 44 await new TRRDNSListener(`sub${i}.blocklisted.com`, { 45 expectedAnswer: "127.0.0.1", 46 }); 47 await new TRRDNSListener(`sub.sub${i}.blocklisted.com`, { 48 expectedAnswer: "127.0.0.1", 49 }); 50 Services.dns.clearCache(true); 51 } 52 });