test_trr_decoding.js (1434B)
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 trr_test_setup(); 8 registerCleanupFunction(async () => { 9 trr_clear_prefs(); 10 }); 11 12 let trrServer = null; 13 add_setup(async function start_trr_server() { 14 trrServer = new TRRServer(); 15 registerCleanupFunction(async () => { 16 await trrServer.stop(); 17 }); 18 await trrServer.start(); 19 dump(`port = ${trrServer.port()}\n`); 20 21 Services.prefs.setCharPref( 22 "network.trr.uri", 23 `https://foo.example.com:${trrServer.port()}/dns-query` 24 ); 25 Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRONLY); 26 }); 27 28 add_task(async function ignoreUnknownTypes() { 29 Services.dns.clearCache(true); 30 await trrServer.registerDoHAnswers("abc.def.ced.com", "A", { 31 answers: [ 32 { 33 name: "abc.def.ced.com", 34 ttl: 55, 35 type: "DNAME", 36 flush: false, 37 data: "def.ced.com.test", 38 }, 39 { 40 name: "abc.def.ced.com", 41 ttl: 55, 42 type: "CNAME", 43 flush: false, 44 data: "abc.def.ced.com.test", 45 }, 46 { 47 name: "abc.def.ced.com.test", 48 ttl: 55, 49 type: "A", 50 flush: false, 51 data: "3.3.3.3", 52 }, 53 ], 54 }); 55 await new TRRDNSListener("abc.def.ced.com", { expectedAnswer: "3.3.3.3" }); 56 });