2 // Tests that calling asyncResolve with the RESOLVE_DISABLE_IPV4 flag doesn't
3 // return any IPv4 addresses.
8 const gOverride = Cc["@mozilla.org/network/native-dns-override;1"].getService(
9 Ci.nsINativeDNSResolverOverride
12 const defaultOriginAttributes = {};
14 add_task(async function test_none() {
15 let [, inRecord] = await new Promise(resolve => {
17 onLookupComplete(inRequest, inRecord, inStatus) {
18 resolve([inRequest, inRecord, inStatus]);
20 QueryInterface: ChromeUtils.generateQI(["nsIDNSListener"]),
23 Services.dns.asyncResolve(
25 Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
26 Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
30 defaultOriginAttributes
34 if (inRecord && inRecord.QueryInterface(Ci.nsIDNSAddrRecord)) {
35 while (inRecord.hasMore()) {
36 let nextIP = inRecord.getNextAddrAsString();
37 ok(nextIP.includes(":"), `${nextIP} should be IPv6`);
42 add_task(async function test_some() {
43 Services.dns.clearCache(true);
44 gOverride.addIPOverride("example.com", "1.1.1.1");
45 gOverride.addIPOverride("example.org", "::1:2:3");
46 let [, inRecord] = await new Promise(resolve => {
48 onLookupComplete(inRequest, inRecord, inStatus) {
49 resolve([inRequest, inRecord, inStatus]);
51 QueryInterface: ChromeUtils.generateQI(["nsIDNSListener"]),
54 Services.dns.asyncResolve(
56 Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
57 Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
61 defaultOriginAttributes
65 ok(inRecord.QueryInterface(Ci.nsIDNSAddrRecord));
66 equal(inRecord.getNextAddrAsString(), "::1:2:3");
67 equal(inRecord.hasMore(), false);