mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1233760 - Convert 25 tests within netwerk/test to use AsyncOpen2 (r=mcmanus)
This commit is contained in:
parent
7d48a6d451
commit
82e194a709
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -16,16 +16,7 @@ XPCOMUtils.defineLazyGetter(this, "noRedirectURI", function() {
|
||||
var httpserver = null;
|
||||
|
||||
function make_channel(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
const requestBody = "request body";
|
||||
@ -54,7 +45,7 @@ function noRedirectStreamObserver(request, buffer)
|
||||
chan.QueryInterface(Ci.nsIUploadChannel).setUploadStream(uploadStream,
|
||||
"text/plain",
|
||||
-1);
|
||||
chan.asyncOpen(new ChannelListener(noHeaderStreamObserver, null), null);
|
||||
chan.asyncOpen2(new ChannelListener(noHeaderStreamObserver, null));
|
||||
}
|
||||
|
||||
function noHeaderStreamObserver(request, buffer)
|
||||
@ -68,7 +59,7 @@ function noHeaderStreamObserver(request, buffer)
|
||||
requestBody;
|
||||
uploadStream.setData(streamBody, streamBody.length);
|
||||
chan.QueryInterface(Ci.nsIUploadChannel).setUploadStream(uploadStream, "", -1);
|
||||
chan.asyncOpen(new ChannelListener(headerStreamObserver, null), null);
|
||||
chan.asyncOpen2(new ChannelListener(headerStreamObserver, null));
|
||||
}
|
||||
|
||||
function headerStreamObserver(request, buffer)
|
||||
@ -95,6 +86,6 @@ function run_test()
|
||||
chan.QueryInterface(Ci.nsIUploadChannel).setUploadStream(uploadStream,
|
||||
"text/plain",
|
||||
-1);
|
||||
chan.asyncOpen(new ChannelListener(noRedirectStreamObserver, null), null);
|
||||
chan.asyncOpen2(new ChannelListener(noRedirectStreamObserver, null));
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
var server;
|
||||
const BUGID = "331825";
|
||||
@ -24,21 +24,14 @@ function run_test() {
|
||||
server.start(-1);
|
||||
|
||||
// make request
|
||||
var channel =
|
||||
Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService).
|
||||
newChannel2("http://localhost:" + server.identity.primaryPort + "/bug" + BUGID,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var channel = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + server.identity.primaryPort + "/bug" + BUGID,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
|
||||
channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
channel.setRequestHeader("If-None-Match", "foobar", false);
|
||||
channel.asyncOpen(new TestListener(), null);
|
||||
channel.asyncOpen2(new TestListener());
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
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();
|
||||
var index = 0;
|
||||
@ -34,17 +34,10 @@ var tests = [
|
||||
];
|
||||
|
||||
function setupChannel(suffix, value, cookie) {
|
||||
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";
|
||||
httpChan.setRequestHeader("x-request", value, false);
|
||||
@ -55,7 +48,7 @@ function setupChannel(suffix, value, cookie) {
|
||||
|
||||
function triggerNextTest() {
|
||||
var channel = setupChannel(tests[index].url, tests[index].server, tests[index].cookie);
|
||||
channel.asyncOpen(new ChannelListener(checkValueAndTrigger, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(checkValueAndTrigger, null));
|
||||
}
|
||||
|
||||
function checkValueAndTrigger(request, data, ctx) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
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();
|
||||
var index = 0;
|
||||
@ -9,18 +9,10 @@ var tests = [
|
||||
];
|
||||
|
||||
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";
|
||||
httpChan.setRequestHeader("x-request", value, false);
|
||||
@ -30,7 +22,7 @@ function setupChannel(suffix, value) {
|
||||
|
||||
function triggerNextTest() {
|
||||
var channel = setupChannel(tests[index].url, tests[index].server);
|
||||
channel.asyncOpen(new ChannelListener(checkValueAndTrigger, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(checkValueAndTrigger, null));
|
||||
}
|
||||
|
||||
function checkValueAndTrigger(request, data, ctx) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
const SERVER_PORT = 8080;
|
||||
const baseURL = "http://localhost:" + SERVER_PORT + "/";
|
||||
@ -31,18 +31,8 @@ function run_test() {
|
||||
response.setHeader("Set-Cookie", "BigCookie=" + cookie, false);
|
||||
response.write("Hello world");
|
||||
});
|
||||
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var chan = ios.newChannel2(baseURL,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
chan.asyncOpen(listener, null);
|
||||
var chan = NetUtil.newChannel({uri: baseURL, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
chan.asyncOpen2(listener);
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://testing-common/MockRegistrar.jsm");
|
||||
|
||||
var httpserv = null;
|
||||
@ -29,19 +29,8 @@ function checkValue(request, data, ctx) {
|
||||
}
|
||||
|
||||
function makeChan(url) {
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var chan = ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
|
||||
return chan;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
@ -66,7 +55,7 @@ function run_test() {
|
||||
|
||||
var chan = makeChan("http://localhost:" + httpserv.identity.primaryPort +
|
||||
"/target");
|
||||
chan.asyncOpen(new ChannelListener(checkValue, null), null);
|
||||
chan.asyncOpen2(new ChannelListener(checkValue, null));
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// This is just a crashtest for a url that is rejected at parse time (port 80,000)
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
function completeTest(request, data, ctx)
|
||||
{
|
||||
@ -9,19 +9,12 @@ function completeTest(request, data, ctx)
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:80000/",
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:80000/",
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
httpChan.asyncOpen(new ChannelListener(completeTest,
|
||||
httpChan, CL_EXPECT_FAILURE), null);
|
||||
httpChan.asyncOpen2(new ChannelListener(completeTest,httpChan, CL_EXPECT_FAILURE));
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,15 @@
|
||||
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();
|
||||
|
||||
function setupChannel(suffix)
|
||||
{
|
||||
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);
|
||||
return chan;
|
||||
return NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + suffix,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
}
|
||||
|
||||
function checkValueAndTrigger(request, data, ctx)
|
||||
@ -40,7 +32,7 @@ function run_test()
|
||||
|
||||
// load first time
|
||||
var channel = setupChannel("/redirect1");
|
||||
channel.asyncOpen(new ChannelListener(checkValueAndTrigger, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(checkValueAndTrigger, null));
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
var httpserver = null;
|
||||
var simplePath = "/simple";
|
||||
@ -15,16 +15,7 @@ XPCOMUtils.defineLazyGetter(this, "uri2", function() {
|
||||
});
|
||||
|
||||
function make_channel(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
var listener_proto = {
|
||||
@ -66,9 +57,7 @@ function run_test()
|
||||
httpserver.start(-1);
|
||||
|
||||
var channel = make_channel(uri1);
|
||||
channel.asyncOpen(new listener("text/plain", function() {
|
||||
run_test2();
|
||||
}), null);
|
||||
channel.asyncOpen2(new listener("text/plain", function() { run_test2();}));
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
@ -76,9 +65,9 @@ function run_test()
|
||||
function run_test2()
|
||||
{
|
||||
var channel = make_channel(uri2);
|
||||
channel.asyncOpen(new listener("text/html", function() {
|
||||
httpserver.stop(do_test_finished);
|
||||
}), null);
|
||||
channel.asyncOpen2(new listener("text/html", function() {
|
||||
httpserver.stop(do_test_finished);
|
||||
}));
|
||||
}
|
||||
|
||||
function simpleHandler(metadata, response)
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
/*
|
||||
- get 302 with Cache-control: no-store
|
||||
@ -23,16 +23,7 @@ XPCOMUtils.defineLazyGetter(this, "randomURI2", function() {
|
||||
});
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
const responseBody = "response body";
|
||||
@ -79,7 +70,7 @@ function check_response(path, request, buffer, expectedExpiration, continuation)
|
||||
|
||||
// Do the request again and check the server handler is called appropriately
|
||||
var chan = make_channel(path);
|
||||
chan.asyncOpen(new ChannelListener(function(request, buffer) {
|
||||
chan.asyncOpen2(new ChannelListener(function(request, buffer) {
|
||||
do_check_eq(buffer, responseBody);
|
||||
|
||||
if (expectedExpiration) {
|
||||
@ -94,26 +85,26 @@ function check_response(path, request, buffer, expectedExpiration, continuation)
|
||||
}
|
||||
|
||||
continuation();
|
||||
}, null), null);
|
||||
}, null));
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_no_store()
|
||||
{
|
||||
var chan = make_channel(randomURI1);
|
||||
chan.asyncOpen(new ChannelListener(function(request, buffer) {
|
||||
chan.asyncOpen2(new ChannelListener(function(request, buffer) {
|
||||
// Cache-control: no-store response should only be found in the memory cache.
|
||||
check_response(randomURI1, request, buffer, false, run_test_expires_past);
|
||||
}, null), null);
|
||||
}, null));
|
||||
}
|
||||
|
||||
function run_test_expires_past()
|
||||
{
|
||||
var chan = make_channel(randomURI2);
|
||||
chan.asyncOpen(new ChannelListener(function(request, buffer) {
|
||||
chan.asyncOpen2(new ChannelListener(function(request, buffer) {
|
||||
// Expires: -1 response should not be found in any cache.
|
||||
check_response(randomURI2, request, buffer, true, finish_test);
|
||||
}, null), null);
|
||||
}, null));
|
||||
}
|
||||
|
||||
function finish_test()
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -19,34 +19,26 @@ function run_test() {
|
||||
|
||||
// Opened channel that has no remaining references on shutdown
|
||||
local_channel = setupChannel(testpath);
|
||||
local_channel.asyncOpen(
|
||||
new ChannelListener(checkRequest, local_channel), null);
|
||||
local_channel.asyncOpen2(new ChannelListener(checkRequest, local_channel));
|
||||
|
||||
// Opened channel that has no remaining references after being opened
|
||||
setupChannel(testpath).asyncOpen(
|
||||
new ChannelListener(function() {}, null), null);
|
||||
setupChannel(testpath).asyncOpen2(new ChannelListener(function() {}, null));
|
||||
|
||||
// Unopened channel that has remaining references on shutdown
|
||||
live_channels.push(setupChannel(testpath));
|
||||
|
||||
// Opened channel that has remaining references on shutdown
|
||||
live_channels.push(setupChannel(testpath));
|
||||
live_channels[1].asyncOpen(
|
||||
new ChannelListener(checkRequestFinish, live_channels[1]), null);
|
||||
live_channels[1].asyncOpen2(new ChannelListener(checkRequestFinish, live_channels[1]));
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function setupChannel(path) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(URL + path,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: URL + path,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.requestMethod = "GET";
|
||||
return chan;
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Test infrastructure
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -32,22 +32,16 @@ function run_test_number(num)
|
||||
|
||||
var channel = setupChannel(testPath);
|
||||
flags = test_flags[num]; // OK if flags undefined for test
|
||||
channel.asyncOpen(new ChannelListener(eval("completeTest" + num),
|
||||
channel, flags), null);
|
||||
channel.asyncOpen2(new ChannelListener(eval("completeTest" + num),
|
||||
channel, flags));
|
||||
}
|
||||
|
||||
function setupChannel(url)
|
||||
{
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(URL + url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: URL + url,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
return httpChan;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Test infrastructure
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -41,8 +41,8 @@ function run_test_number(num)
|
||||
|
||||
var channel = setupChannel(testPath);
|
||||
flags = test_flags[num]; // OK if flags undefined for test
|
||||
channel.asyncOpen(new ChannelListener(eval("completeTest" + num),
|
||||
channel, flags), null);
|
||||
channel.asyncOpen2(new ChannelListener(eval("completeTest" + num),
|
||||
channel, flags));
|
||||
}
|
||||
|
||||
function run_gzip_test(num)
|
||||
@ -77,22 +77,16 @@ function run_gzip_test(num)
|
||||
|
||||
let listener = new StreamListener();
|
||||
|
||||
channel.asyncOpen(listener, null);
|
||||
channel.asyncOpen2(listener);
|
||||
|
||||
}
|
||||
|
||||
function setupChannel(url)
|
||||
{
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(URL + url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: URL + url,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
return httpChan;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserv.identity.primaryPort + "/";
|
||||
@ -56,19 +57,8 @@ var listener = {
|
||||
};
|
||||
|
||||
function makeChan() {
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var chan = ios.newChannel2(URL,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
return NetUtil.newChannel({uri: URL, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
|
||||
return chan;
|
||||
}
|
||||
|
||||
var httpserv = null;
|
||||
@ -85,7 +75,7 @@ function run_test() {
|
||||
|
||||
chan.setRequestHeader("Cookie", cookieVal, false);
|
||||
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
@ -104,7 +94,7 @@ function run_test_continued() {
|
||||
cookieVal = cookie2 + "; " + cookieVal;
|
||||
|
||||
listener._iteration++;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
|
||||
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();
|
||||
|
||||
var cookieSetPath = "/setcookie";
|
||||
@ -48,15 +50,7 @@ var i = 0;
|
||||
|
||||
function setupChannel(path)
|
||||
{
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(URL + path,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var chan = NetUtil.newChannel({uri: URL + path, loadUsingSystemPrincipal: true});
|
||||
chan.notificationCallbacks = tests[i].loadContext;
|
||||
chan.QueryInterface(Ci.nsIHttpChannel);
|
||||
return chan;
|
||||
@ -65,7 +59,7 @@ function setupChannel(path)
|
||||
function setCookie() {
|
||||
var channel = setupChannel(cookieSetPath);
|
||||
channel.setRequestHeader("foo-set-cookie", tests[i].cookieName, false);
|
||||
channel.asyncOpen(new ChannelListener(setNextCookie, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(setNextCookie, null));
|
||||
}
|
||||
|
||||
function setNextCookie(request, data, context)
|
||||
@ -85,7 +79,7 @@ function setNextCookie(request, data, context)
|
||||
function checkCookie()
|
||||
{
|
||||
var channel = setupChannel(cookieCheckPath);
|
||||
channel.asyncOpen(new ChannelListener(completeCheckCookie, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(completeCheckCookie, null));
|
||||
}
|
||||
|
||||
function completeCheckCookie(request, data, context) {
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -68,15 +70,7 @@ function safebrowsingUpdateHandler(metadata, response) {
|
||||
}
|
||||
|
||||
function setupChannel(path, loadContext) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var channel = ios.newChannel2(URL + path,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var channel = NetUtil.newChannel({uri: URL + path, loadUsingSystemPrincipal: true});
|
||||
channel.loadInfo.originAttributes = loadContext.originAttributes;
|
||||
channel.notificationCallbacks = loadContext;
|
||||
channel.QueryInterface(Ci.nsIHttpChannel);
|
||||
@ -132,12 +126,12 @@ add_test(function test_non_safebrowsing_cookie() {
|
||||
function setNonSafeBrowsingCookie() {
|
||||
var channel = setupChannel(setCookiePath, loadContext);
|
||||
channel.setRequestHeader("set-cookie", cookieName, false);
|
||||
channel.asyncOpen(new ChannelListener(checkNonSafeBrowsingCookie, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(checkNonSafeBrowsingCookie, null));
|
||||
}
|
||||
|
||||
function checkNonSafeBrowsingCookie() {
|
||||
var channel = setupChannel(checkCookiePath, loadContext);
|
||||
channel.asyncOpen(new ChannelListener(completeCheckNonSafeBrowsingCookie, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(completeCheckNonSafeBrowsingCookie, null));
|
||||
}
|
||||
|
||||
function completeCheckNonSafeBrowsingCookie(request, data, context) {
|
||||
@ -160,12 +154,12 @@ add_test(function test_safebrowsing_cookie() {
|
||||
function setSafeBrowsingCookie() {
|
||||
var channel = setupChannel(setCookiePath, loadContext);
|
||||
channel.setRequestHeader("set-cookie", cookieName, false);
|
||||
channel.asyncOpen(new ChannelListener(checkSafeBrowsingCookie, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(checkSafeBrowsingCookie, null));
|
||||
}
|
||||
|
||||
function checkSafeBrowsingCookie() {
|
||||
var channel = setupChannel(checkCookiePath, loadContext);
|
||||
channel.asyncOpen(new ChannelListener(completeCheckSafeBrowsingCookie, null), null);
|
||||
channel.asyncOpen2(new ChannelListener(completeCheckSafeBrowsingCookie, null));
|
||||
}
|
||||
|
||||
function completeCheckSafeBrowsingCookie(request, data, context) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* run some tests on the file:// protocol handler */
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
const PR_RDONLY = 0x1; // see prio.h
|
||||
|
||||
@ -40,12 +40,10 @@ function new_file_channel(file) {
|
||||
var ios =
|
||||
Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannelFromURI2(ios.newFileURI(file),
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({
|
||||
uri: ios.newFileURI(file),
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
@ -143,7 +141,7 @@ function test_read_file() {
|
||||
}
|
||||
|
||||
chan.contentType = special_type;
|
||||
chan.asyncOpen(new FileStreamListener(on_read_complete), null);
|
||||
chan.asyncOpen2(new FileStreamListener(on_read_complete));
|
||||
}
|
||||
|
||||
function do_test_read_dir(set_type, expected_type) {
|
||||
@ -165,7 +163,7 @@ function do_test_read_dir(set_type, expected_type) {
|
||||
|
||||
if (set_type)
|
||||
chan.contentType = expected_type;
|
||||
chan.asyncOpen(new FileStreamListener(on_read_complete), null);
|
||||
chan.asyncOpen2(new FileStreamListener(on_read_complete));
|
||||
}
|
||||
|
||||
function test_read_dir_1() {
|
||||
@ -224,7 +222,7 @@ function test_upload_file() {
|
||||
}
|
||||
|
||||
chan.contentType = special_type;
|
||||
chan.asyncOpen(new FileStreamListener(on_upload_complete), null);
|
||||
chan.asyncOpen2(new FileStreamListener(on_upload_complete));
|
||||
}
|
||||
|
||||
function test_load_replace() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// This is essentially a debug mode crashtest to make sure everything
|
||||
// involved in a reload runs on the right thread. It relies on the
|
||||
// assertions in necko.
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
var listener = {
|
||||
onStartRequest: function test_onStartR(request, ctx) {
|
||||
@ -17,20 +17,14 @@ var listener = {
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:4444",
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:4444",
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.loadFlags = Ci.nsIRequest.LOAD_FRESH_CONNECTION |
|
||||
Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
|
||||
chan.QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
@ -14,16 +14,7 @@ XPCOMUtils.defineLazyGetter(this, "randomURI", function() {
|
||||
});
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
function redirectHandler(metadata, response)
|
||||
@ -42,7 +33,7 @@ function makeSureNotInCache(request, buffer)
|
||||
// Can't hurt to test though.
|
||||
var chan = make_channel(randomURI);
|
||||
chan.loadFlags |= Ci.nsIRequest.LOAD_ONLY_FROM_CACHE;
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null);
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE));
|
||||
}
|
||||
|
||||
function finish_test(request, buffer)
|
||||
@ -59,6 +50,6 @@ function run_test()
|
||||
httpServer.start(-1);
|
||||
|
||||
var chan = make_channel(randomURI);
|
||||
chan.asyncOpen(new ChannelListener(makeSureNotInCache, null, CL_EXPECT_FAILURE), null);
|
||||
chan.asyncOpen2(new ChannelListener(makeSureNotInCache, null, CL_EXPECT_FAILURE));
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -14,16 +14,7 @@ XPCOMUtils.defineLazyGetter(this, "randomURI", function() {
|
||||
});
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
const responseBody = "response body";
|
||||
@ -46,7 +37,7 @@ function firstTimeThrough(request, buffer)
|
||||
do_check_eq(buffer, responseBody);
|
||||
var chan = make_channel(randomURI);
|
||||
chan.loadFlags |= Ci.nsIRequest.LOAD_FROM_CACHE;
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null), null);
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null));
|
||||
}
|
||||
|
||||
function finish_test(request, buffer)
|
||||
@ -63,6 +54,6 @@ function run_test()
|
||||
httpserver.start(-1);
|
||||
|
||||
var chan = make_channel(randomURI);
|
||||
chan.asyncOpen(new ChannelListener(firstTimeThrough, null), null);
|
||||
chan.asyncOpen2(new ChannelListener(firstTimeThrough, null));
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
/*
|
||||
* Test whether we fail bad URIs in HTTP redirect as CORRUPTED_CONTENT.
|
||||
@ -13,16 +13,7 @@ XPCOMUtils.defineLazyGetter(this, "BadRedirectURI", function() {
|
||||
});
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
function BadRedirectHandler(metadata, response)
|
||||
@ -46,7 +37,6 @@ function run_test()
|
||||
httpServer.start(-1);
|
||||
|
||||
var chan = make_channel(BadRedirectURI);
|
||||
chan.asyncOpen(new ChannelListener(checkFailed, null, CL_EXPECT_FAILURE),
|
||||
null);
|
||||
chan.asyncOpen2(new ChannelListener(checkFailed, null, CL_EXPECT_FAILURE));
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
@ -14,16 +14,7 @@ XPCOMUtils.defineLazyGetter(this, "randomURI", function() {
|
||||
});
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
const responseBody = "response body";
|
||||
@ -55,6 +46,6 @@ function run_test()
|
||||
|
||||
var chan = make_channel(randomURI);
|
||||
chan.notificationCallbacks = new ChannelEventSink(ES_ABORT_REDIRECT);
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null), null);
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null));
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
@ -14,16 +14,7 @@ XPCOMUtils.defineLazyGetter(this, "randomURI", function() {
|
||||
});
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
function redirectHandler(metadata, response)
|
||||
@ -49,6 +40,6 @@ function run_test()
|
||||
httpServer.start(-1);
|
||||
|
||||
var chan = make_channel(randomURI);
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null);
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE));
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* made with nsIXMLHttpRequest objects.
|
||||
*
|
||||
* testViaAsyncOpen() checks that internal redirects occur correctly when made
|
||||
* with nsIHTTPChannel.asyncOpen().
|
||||
* with nsIHTTPChannel.asyncOpen2().
|
||||
*
|
||||
* Both of the above functions tests four requests:
|
||||
*
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// the topic we observe to use the API. http-on-opening-request might also
|
||||
// work for some purposes.
|
||||
@ -84,16 +84,7 @@ var testHeaderVal = "Success";
|
||||
var testHeaderVal2 = "Success on server 2";
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
}
|
||||
|
||||
function baitHandler(metadata, response)
|
||||
@ -175,7 +166,7 @@ Redirector.prototype = {
|
||||
|
||||
function makeAsyncTest(uri, headerValue, nextTask)
|
||||
{
|
||||
// Make a test to check a redirect that is created with channel.asyncOpen()
|
||||
// Make a test to check a redirect that is created with channel.asyncOpen2()
|
||||
|
||||
// Produce a callback function which checks for the presence of headerValue,
|
||||
// and then continues to the next async test task
|
||||
@ -190,11 +181,11 @@ function makeAsyncTest(uri, headerValue, nextTask)
|
||||
nextTask();
|
||||
};
|
||||
|
||||
// Produce a function to run an asyncOpen test using the above verifier
|
||||
// Produce a function to run an asyncOpen2 test using the above verifier
|
||||
var test = function()
|
||||
{
|
||||
var chan = make_channel(uri);
|
||||
chan.asyncOpen(new ChannelListener(verifier), null);
|
||||
chan.asyncOpen2(new ChannelListener(verifier));
|
||||
};
|
||||
return test;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Note: sets Cc and Ci variables
|
||||
|
||||
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();
|
||||
var testpath = "/simple";
|
||||
@ -26,22 +26,15 @@ function setup_test() {
|
||||
httpserver.start(-1);
|
||||
var channel = setupChannel(testpath);
|
||||
// ChannelListener defined in head_channels.js
|
||||
channel.asyncOpen(new ChannelListener(checkRequest, channel), null);
|
||||
channel.asyncOpen2(new ChannelListener(checkRequest, channel));
|
||||
if (dbg) { print("============== setup_test: out"); }
|
||||
}
|
||||
|
||||
function setupChannel(path) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:" +
|
||||
httpserver.identity.primaryPort + path,
|
||||
"",
|
||||
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 + path,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.requestMethod = "GET";
|
||||
return chan;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// test spdy/3.1
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
// Generate a small and a large post with known pre-calculated md5 sums
|
||||
function generateContent(size) {
|
||||
@ -184,24 +184,15 @@ SpdyPostListener.prototype.onDataAvailable = function(request, ctx, stream, off,
|
||||
};
|
||||
|
||||
function makeChan(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER).QueryInterface(Ci.nsIHttpChannel);
|
||||
|
||||
return chan;
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
}
|
||||
|
||||
// Make sure we make a spdy connection and both us and the server mark it as such
|
||||
function test_spdy_basic() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/");
|
||||
var listener = new SpdyCheckListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Support for making sure XHR works over SPDY
|
||||
@ -249,7 +240,7 @@ function test_spdy_concurrent() {
|
||||
for (var i = 0; i < concurrent_listener.target; i++) {
|
||||
concurrent_channels[i] = makeChan("https://localhost:" + serverPort + "/750ms");
|
||||
concurrent_channels[i].loadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
concurrent_channels[i].asyncOpen(concurrent_listener, null);
|
||||
concurrent_channels[i].asyncOpen2(concurrent_listener);
|
||||
}
|
||||
}
|
||||
|
||||
@ -259,8 +250,8 @@ function test_spdy_multiplex() {
|
||||
var chan2 = makeChan("https://localhost:" + serverPort + "/multiplex2");
|
||||
var listener1 = new SpdyMultiplexListener();
|
||||
var listener2 = new SpdyMultiplexListener();
|
||||
chan1.asyncOpen(listener1, null);
|
||||
chan2.asyncOpen(listener2, null);
|
||||
chan1.asyncOpen2(listener1);
|
||||
chan2.asyncOpen2(listener2);
|
||||
}
|
||||
|
||||
// Test to make sure we gateway non-standard headers properly
|
||||
@ -269,42 +260,42 @@ function test_spdy_header() {
|
||||
var hvalue = "Headers are fun";
|
||||
var listener = new SpdyHeaderListener(hvalue);
|
||||
chan.setRequestHeader("X-Test-Header", hvalue, false);
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_spdy_push1() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new SpdyPushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_spdy_push2() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push.js");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new SpdyPushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_spdy_push3() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push2");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new SpdyPushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_spdy_push4() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push2.js");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new SpdyPushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Make sure we handle GETs that cover more than 2 frames properly
|
||||
function test_spdy_big() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/big");
|
||||
var listener = new SpdyBigListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Support for doing a POST
|
||||
@ -318,7 +309,7 @@ function do_post(content, chan, listener) {
|
||||
|
||||
chan.requestMethod = "POST";
|
||||
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Make sure we can do a simple POST
|
||||
|
Loading…
Reference in New Issue
Block a user