Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / netwerk / test / unit / test_trr_ttl.js
blob36cd0d4a5a6d1404d589868859e2b93130cf286c
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/. */
5 "use strict";
7 trr_test_setup();
8 registerCleanupFunction(async () => {
9 trr_clear_prefs();
10 });
12 let trrServer = null;
13 add_task(async function setup() {
14 trrServer = new TRRServer();
15 registerCleanupFunction(async () => {
16 await trrServer.stop();
17 });
18 await trrServer.start();
19 dump(`port = ${trrServer.port()}\n`);
21 Services.prefs.setCharPref(
22 "network.trr.uri",
23 `https://foo.example.com:${trrServer.port()}/dns-query`
25 Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRFIRST);
26 });
28 add_task(async function check_ttl_works() {
29 await trrServer.registerDoHAnswers("example.com", "A", {
30 answers: [
32 name: "example.com",
33 ttl: 55,
34 type: "A",
35 flush: false,
36 data: "1.2.3.4",
39 });
40 let { inRecord } = await new TRRDNSListener("example.com", {
41 expectedAnswer: "1.2.3.4",
42 });
43 equal(inRecord.QueryInterface(Ci.nsIDNSAddrRecord).ttl, 55);
44 await trrServer.registerDoHAnswers("example.org", "A", {
45 answers: [
47 name: "example.org",
48 ttl: 999,
49 type: "A",
50 flush: false,
51 data: "1.2.3.4",
54 });
55 // Simple check to see that TRR works.
56 ({ inRecord } = await new TRRDNSListener("example.org", {
57 expectedAnswer: "1.2.3.4",
58 }));
59 equal(inRecord.QueryInterface(Ci.nsIDNSAddrRecord).ttl, 999);
60 });