Bug 1234368 - Convert netwerk/test/unit/test_bug203271.js to use asyncOpen2 (r=mcmanus)

This commit is contained in:
Christoph Kerschbaumer 2016-01-15 11:38:21 -08:00
parent 558c941198
commit a133946ebd

View File

@ -5,7 +5,7 @@
// take precedence
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const BUGID = "203271";
var httpserver = new HttpServer();
@ -95,17 +95,10 @@ function logit(i, data, ctx) {
}
function setupChannel(suffix, value) {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var chan = ios.newChannel2("http://localhost:" +
httpserver.identity.primaryPort + suffix,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: "http://localhost:" + httpserver.identity.primaryPort + suffix,
loadUsingSystemPrincipal: true
});
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
httpChan.requestMethod = "GET"; // default value, just being paranoid...
httpChan.setRequestHeader("x-request", value, false);
@ -114,7 +107,7 @@ function setupChannel(suffix, value) {
function triggerNextTest() {
var channel = setupChannel(tests[index].url, tests[index].server);
channel.asyncOpen(new ChannelListener(checkValueAndTrigger, channel), null);
channel.asyncOpen2(new ChannelListener(checkValueAndTrigger, channel));
}
function checkValueAndTrigger(request, data, ctx) {