3 var prefs
= Services
.prefs
;
4 var mainThread
= Services
.tm
.currentThread
;
7 onLookupComplete(inRequest
, inRecord
, inStatus
) {
8 Assert
.equal(inStatus
, Cr
.NS_OK
);
9 inRecord
.QueryInterface(Ci
.nsIDNSAddrRecord
);
10 var answer
= inRecord
.getNextAddrAsString();
11 Assert
.ok(answer
== "127.0.0.1" || answer
== "::1");
18 onLookupComplete(inRequest
, inRecord
, inStatus
) {
19 Assert
.equal(inStatus
, Cr
.NS_OK
);
20 inRecord
.QueryInterface(Ci
.nsIDNSAddrRecord
);
21 var answer
= inRecord
.getNextAddrAsString();
22 Assert
.ok(answer
== "127.0.0.1" || answer
== "::1");
29 onLookupComplete(inRequest
, inRecord
, inStatus
) {
30 Assert
.equal(inStatus
, Cr
.NS_ERROR_OFFLINE
);
36 const firstOriginAttributes
= { userContextId
: 1 };
37 const secondOriginAttributes
= { userContextId
: 2 };
39 // First, we resolve the address normally for first originAttributes.
42 prefs
.setBoolPref("network.proxy.allow_hijacking_localhost", true);
43 Services
.dns
.asyncResolve(
45 Ci
.nsIDNSService
.RESOLVE_TYPE_DEFAULT
,
54 // Second, we resolve the same address offline to see whether its DNS cache works
58 Services
.dns
.asyncResolve(
60 Ci
.nsIDNSService
.RESOLVE_TYPE_DEFAULT
,
61 Ci
.nsIDNSService
.RESOLVE_OFFLINE
,
69 // Third, we resolve the same address offline again with different originAttributes.
70 // This resolving should fail since the DNS cache of the given address is not exist
71 // for this originAttributes.
75 Services
.dns
.asyncResolve(
77 Ci
.nsIDNSService
.RESOLVE_TYPE_DEFAULT
,
78 Ci
.nsIDNSService
.RESOLVE_OFFLINE
,
82 secondOriginAttributes
85 Assert
.equal(e
.result
, Cr
.NS_ERROR_OFFLINE
);
92 prefs
.clearUserPref("network.proxy.allow_hijacking_localhost");