зеркало из https://github.com/mozilla/gecko-dev.git
Bug 279158 - nsIDNSRecord::canonicalName should document what it does for IDN r=valentin
Differential Revision: https://phabricator.services.mozilla.com/D72651
This commit is contained in:
Родитель
04d2b23c67
Коммит
57b639c19c
|
@ -32,6 +32,9 @@ interface nsIDNSRecord : nsISupports
|
|||
* the record was not fetched with the RESOLVE_CANONICAL_NAME flag.
|
||||
*
|
||||
* e.g., www.mozilla.org --> rheet.mozilla.org
|
||||
*
|
||||
* That the result, if IDN will be returned as punycode.
|
||||
* e.g., élève.w3c-test.org --> xn--lve-6lad.w3c-test.org
|
||||
*/
|
||||
readonly attribute ACString canonicalName;
|
||||
|
||||
|
|
|
@ -1,24 +1,41 @@
|
|||
"use strict";
|
||||
|
||||
var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
|
||||
|
||||
var listener = {
|
||||
onLookupComplete(inRequest, inRecord, inStatus) {
|
||||
var answer = inRecord.getNextAddrAsString();
|
||||
Assert.ok(answer == "127.0.0.1" || answer == "::1");
|
||||
|
||||
do_test_finished();
|
||||
},
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIDNSListener"]),
|
||||
};
|
||||
|
||||
const dns = Cc["@mozilla.org/network/dns-service;1"].getService(
|
||||
Ci.nsIDNSService
|
||||
);
|
||||
const defaultOriginAttributes = {};
|
||||
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
const mainThread = threadManager.currentThread;
|
||||
|
||||
function run_test() {
|
||||
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
var mainThread = threadManager.currentThread;
|
||||
class Listener {
|
||||
constructor() {
|
||||
this.promise = new Promise(resolve => {
|
||||
this.resolve = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
onLookupComplete(inRequest, inRecord, inStatus) {
|
||||
this.resolve([inRequest, inRecord, inStatus]);
|
||||
}
|
||||
|
||||
then() {
|
||||
return this.promise.then.apply(this.promise, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
Listener.prototype.QueryInterface = ChromeUtils.generateQI(["nsIDNSListener"]);
|
||||
|
||||
const DOMAIN_IDN = "bücher.org";
|
||||
const ACE_IDN = "xn--bcher-kva.org";
|
||||
|
||||
const DOMAIN = "localhost";
|
||||
const ADDR1 = "127.0.0.1";
|
||||
const ADDR2 = "::1";
|
||||
|
||||
add_task(async function test_dns_localhost() {
|
||||
let listener = new Listener();
|
||||
dns.asyncResolve(
|
||||
"localhost",
|
||||
0,
|
||||
|
@ -26,6 +43,21 @@ function run_test() {
|
|||
mainThread,
|
||||
defaultOriginAttributes
|
||||
);
|
||||
let [inRequest, inRecord, inStatus] = await listener;
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
let answer = inRecord.getNextAddrAsString();
|
||||
Assert.ok(answer == ADDR1 || answer == ADDR2);
|
||||
});
|
||||
|
||||
add_task(async function test_idn_cname() {
|
||||
let listener = new Listener();
|
||||
dns.asyncResolve(
|
||||
DOMAIN_IDN,
|
||||
Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
|
||||
listener,
|
||||
mainThread,
|
||||
defaultOriginAttributes
|
||||
);
|
||||
let [inRequest, inRecord, inStatus] = await listener;
|
||||
Assert.equal(inRecord.canonicalName, ACE_IDN, "IDN is returned as punycode");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче