3 var ioService = Services.io;
4 var prefs = Services.prefs;
5 var mainThread = Services.tm.currentThread;
8 onLookupComplete(inRequest, inRecord, inStatus) {
9 Assert.equal(inStatus, Cr.NS_ERROR_OFFLINE);
16 onLookupComplete(inRequest, inRecord, inStatus) {
17 Assert.equal(inStatus, Cr.NS_OK);
18 inRecord.QueryInterface(Ci.nsIDNSAddrRecord);
19 var answer = inRecord.getNextAddrAsString();
20 Assert.ok(answer == "127.0.0.1" || answer == "::1");
27 onLookupComplete(inRequest, inRecord, inStatus) {
28 Assert.equal(inStatus, Cr.NS_OK);
29 inRecord.QueryInterface(Ci.nsIDNSAddrRecord);
30 var answer = inRecord.getNextAddrAsString();
31 Assert.ok(answer == "127.0.0.1" || answer == "::1");
37 const defaultOriginAttributes = {};
41 prefs.setBoolPref("network.dns.offline-localhost", false);
42 // We always resolve localhost as it's hardcoded without the following pref:
43 prefs.setBoolPref("network.proxy.allow_hijacking_localhost", true);
44 ioService.offline = true;
46 Services.dns.asyncResolve(
48 Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
53 defaultOriginAttributes
56 Assert.equal(e.result, Cr.NS_ERROR_OFFLINE);
64 prefs.setBoolPref("network.dns.offline-localhost", true);
65 ioService.offline = false;
66 ioService.offline = true;
67 // we need to let the main thread run and apply the changes
68 do_timeout(0, test2Continued);
71 function test2Continued() {
72 Services.dns.asyncResolve(
74 Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
79 defaultOriginAttributes
85 ioService.offline = false;
86 // we need to let the main thread run and apply the changes
87 do_timeout(0, test3Continued);
90 function test3Continued() {
91 Services.dns.asyncResolve(
93 Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
98 defaultOriginAttributes
103 prefs.clearUserPref("network.dns.offline-localhost");
104 prefs.clearUserPref("network.proxy.allow_hijacking_localhost");