зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1700076 - Clean up test_httpssvc_priority.js r=necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D109592
This commit is contained in:
Родитель
c82e24d35f
Коммит
2d17089150
|
@ -6,97 +6,15 @@
|
|||
|
||||
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
let prefs;
|
||||
let h2Port;
|
||||
trr_test_setup();
|
||||
registerCleanupFunction(async () => {
|
||||
trr_clear_prefs();
|
||||
Services.prefs.clearUserPref("network.dns.echconfig.enabled");
|
||||
});
|
||||
|
||||
const dns = Cc["@mozilla.org/network/dns-service;1"].getService(
|
||||
Ci.nsIDNSService
|
||||
);
|
||||
const certOverrideService = Cc[
|
||||
"@mozilla.org/security/certoverride;1"
|
||||
].getService(Ci.nsICertOverrideService);
|
||||
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
const mainThread = threadManager.currentThread;
|
||||
|
||||
const defaultOriginAttributes = {};
|
||||
|
||||
function setup() {
|
||||
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||
Ci.nsIEnvironment
|
||||
);
|
||||
h2Port = env.get("MOZHTTP2_PORT");
|
||||
Assert.notEqual(h2Port, null);
|
||||
Assert.notEqual(h2Port, "");
|
||||
|
||||
// Set to allow the cert presented by our H2 server
|
||||
do_get_profile();
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
|
||||
prefs.setBoolPref("network.http.spdy.enabled", true);
|
||||
prefs.setBoolPref("network.http.spdy.enabled.http2", true);
|
||||
// the TRR server is on 127.0.0.1
|
||||
prefs.setCharPref("network.trr.bootstrapAddress", "127.0.0.1");
|
||||
|
||||
// make all native resolve calls "secretly" resolve localhost instead
|
||||
prefs.setBoolPref("network.dns.native-is-localhost", true);
|
||||
|
||||
// 0 - off, 1 - race, 2 TRR first, 3 TRR only, 4 shadow
|
||||
prefs.setIntPref("network.trr.mode", 2); // TRR first
|
||||
prefs.setBoolPref("network.trr.wait-for-portal", false);
|
||||
// don't confirm that TRR is working, just go!
|
||||
prefs.setCharPref("network.trr.confirmationNS", "skip");
|
||||
|
||||
// So we can change the pref without clearing the cache to check a pushed
|
||||
// record with a TRR path that fails.
|
||||
Services.prefs.setBoolPref("network.trr.clear-cache-on-pref-change", false);
|
||||
|
||||
// The moz-http2 cert is for foo.example.com and is signed by http2-ca.pem
|
||||
// so add that cert to the trust list as a signing cert. // the foo.example.com domain name.
|
||||
const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
|
||||
Ci.nsIX509CertDB
|
||||
);
|
||||
addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
|
||||
}
|
||||
|
||||
setup();
|
||||
registerCleanupFunction(() => {
|
||||
prefs.clearUserPref("network.http.spdy.enabled");
|
||||
prefs.clearUserPref("network.http.spdy.enabled.http2");
|
||||
prefs.clearUserPref("network.dns.localDomains");
|
||||
prefs.clearUserPref("network.dns.native-is-localhost");
|
||||
prefs.clearUserPref("network.trr.mode");
|
||||
prefs.clearUserPref("network.trr.uri");
|
||||
prefs.clearUserPref("network.trr.credentials");
|
||||
prefs.clearUserPref("network.trr.wait-for-portal");
|
||||
prefs.clearUserPref("network.trr.allow-rfc1918");
|
||||
prefs.clearUserPref("network.trr.useGET");
|
||||
prefs.clearUserPref("network.trr.confirmationNS");
|
||||
prefs.clearUserPref("network.trr.bootstrapAddress");
|
||||
prefs.clearUserPref("network.trr.request-timeout");
|
||||
prefs.clearUserPref("network.trr.clear-cache-on-pref-change");
|
||||
prefs.clearUserPref("network.dns.echconfig.enabled");
|
||||
});
|
||||
|
||||
class DNSListener {
|
||||
constructor() {
|
||||
this.promise = new Promise(resolve => {
|
||||
this.resolve = resolve;
|
||||
});
|
||||
}
|
||||
onLookupComplete(inRequest, inRecord, inStatus) {
|
||||
this.resolve([inRequest, inRecord, inStatus]);
|
||||
}
|
||||
// So we can await this as a promise.
|
||||
then() {
|
||||
return this.promise.then.apply(this.promise, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
DNSListener.prototype.QueryInterface = ChromeUtils.generateQI([
|
||||
"nsIDNSListener",
|
||||
]);
|
||||
|
||||
add_task(async function testPriorityAndECHConfig() {
|
||||
let trrServer = new TRRServer();
|
||||
|
@ -161,21 +79,9 @@ add_task(async function testPriorityAndECHConfig() {
|
|||
],
|
||||
});
|
||||
|
||||
let listener = new DNSListener();
|
||||
|
||||
let request = dns.asyncResolve(
|
||||
"test.priority.com",
|
||||
dns.RESOLVE_TYPE_HTTPSSVC,
|
||||
0,
|
||||
null, // resolverInfo
|
||||
listener,
|
||||
mainThread,
|
||||
defaultOriginAttributes
|
||||
);
|
||||
|
||||
let [inRequest, inRecord, inStatus] = await listener;
|
||||
Assert.equal(inRequest, request, "correct request was used");
|
||||
Assert.equal(inStatus, Cr.NS_OK, "status OK");
|
||||
let [, inRecord] = await new TRRDNSListener("test.priority.com", {
|
||||
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
|
||||
});
|
||||
|
||||
let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records;
|
||||
Assert.equal(answer.length, 4);
|
||||
|
@ -194,21 +100,9 @@ add_task(async function testPriorityAndECHConfig() {
|
|||
|
||||
Services.prefs.setBoolPref("network.dns.echconfig.enabled", true);
|
||||
dns.clearCache(true);
|
||||
listener = new DNSListener();
|
||||
|
||||
request = dns.asyncResolve(
|
||||
"test.priority.com",
|
||||
dns.RESOLVE_TYPE_HTTPSSVC,
|
||||
0,
|
||||
null, // resolverInfo
|
||||
listener,
|
||||
mainThread,
|
||||
defaultOriginAttributes
|
||||
);
|
||||
|
||||
[inRequest, inRecord, inStatus] = await listener;
|
||||
Assert.equal(inRequest, request, "correct request was used");
|
||||
Assert.equal(inStatus, Cr.NS_OK, "status OK");
|
||||
[, inRecord] = await new TRRDNSListener("test.priority.com", {
|
||||
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
|
||||
});
|
||||
|
||||
answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records;
|
||||
Assert.equal(answer.length, 4);
|
||||
|
|
Загрузка…
Ссылка в новой задаче