Bug 1225357 - Convert toolkit tests to use asyncOpen2 (r=sicking)

This commit is contained in:
Christoph Kerschbaumer 2016-01-12 13:45:03 -08:00
parent af6ed3ecc8
commit b79014c498
3 changed files with 19 additions and 30 deletions

View File

@ -6,7 +6,7 @@ var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const PATH = "/file.meh";
var httpserver = new HttpServer();
@ -69,18 +69,13 @@ var listener = {
function setupChannel(url, flags)
{
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let uri = "http://localhost:" +
httpserver.identity.primaryPort + url;
var chan = ios.newChannel2(uri,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_MEDIA);
var chan = NetUtil.newChannel({
uri: uri,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_MEDIA
});
chan.loadFlags |= flags;
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
return httpChan;
@ -96,7 +91,7 @@ function runNext() {
response.setHeader("Content-Type", tests[testRan].contentType, false);
response.bodyOutputStream.write(data, data.length);
});
channel.asyncOpen(listener, channel, null);
channel.asyncOpen2(listener);
}
function run_test() {

View File

@ -12,7 +12,7 @@ var BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1",
"setOutputStream");
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpserver = new HttpServer();
@ -69,17 +69,11 @@ var listener = {
};
function setupChannel(url) {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var chan = ios.newChannel2("http://localhost:" +
httpserver.identity.primaryPort + url,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_MEDIA);
var chan = NetUtil.newChannel({
uri: "http://localhost:" + httpserver.identity.primaryPort + url,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_MEDIA
});
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
return httpChan;
}
@ -90,7 +84,7 @@ function runNext() {
return;
}
var channel = setupChannel("/");
channel.asyncOpen(listener, channel, null);
channel.asyncOpen2(listener);
}
function getFileContents(aFile) {

View File

@ -167,9 +167,9 @@ var resolveCallback = SpecialPowers.wrapCallbackObject({
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
proxyChannel.asyncOpen(SpecialPowers.wrapCallbackObject(new proxyChannelListener()), null);
proxyChannel.asyncOpen2(SpecialPowers.wrapCallbackObject(new proxyChannelListener()));
}
});
@ -186,7 +186,7 @@ function startup() {
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
pps.asyncResolve(channel, 0, resolveCallback);
}
@ -914,7 +914,7 @@ function doTests() {
SpecialPowers.Services.
scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel2 = ioService.newChannel2("http://example2.com",
null,
@ -923,7 +923,7 @@ function doTests() {
SpecialPowers.Services.
scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
var level = Ci.nsIAuthPrompt2.LEVEL_NONE;