mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1234591 - Use channel.asyncOpen2 within netwerk/test/unit/test_http2.js r=ckerschb
This commit is contained in:
parent
9f784d6ae1
commit
736aaab8e3
@ -155,8 +155,8 @@ Http2PushListener.prototype = new Http2CheckListener();
|
||||
Http2PushListener.prototype.onDataAvailable = function(request, ctx, stream, off, cnt) {
|
||||
this.onDataAvailableFired = true;
|
||||
this.isHttp2Connection = checkIsHttp2(request);
|
||||
if (ctx.originalURI.spec == "https://localhost:" + serverPort + "/push.js" ||
|
||||
ctx.originalURI.spec == "https://localhost:" + serverPort + "/push2.js") {
|
||||
if (request.originalURI.spec == "https://localhost:" + serverPort + "/push.js" ||
|
||||
request.originalURI.spec == "https://localhost:" + serverPort + "/push2.js") {
|
||||
do_check_eq(request.getResponseHeader("pushed"), "yes");
|
||||
}
|
||||
read_stream(stream, cnt);
|
||||
@ -216,7 +216,7 @@ Http2ContinuedHeaderListener.prototype.onPush = function(associatedChannel, push
|
||||
do_check_eq(pushChannel.getRequestHeader("x-pushed-request"), "true");
|
||||
checkContinuedHeaders(pushChannel.getRequestHeader, "X-Push-Test-Header-", pushHdrTxt);
|
||||
|
||||
pushChannel.asyncOpen(this, pushChannel);
|
||||
pushChannel.asyncOpen2(this);
|
||||
};
|
||||
|
||||
// Does the appropriate checks for a large GET response
|
||||
@ -283,17 +283,8 @@ Http2PostListener.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);
|
||||
}
|
||||
|
||||
var ResumeStalledChannelListener = function() {};
|
||||
@ -339,7 +330,7 @@ function test_http2_blocking_download() {
|
||||
internalChannel.initialRwin = 500000; // make the stream.suspend push back in h2
|
||||
var listener = new Http2CheckListener();
|
||||
listener.expected = 3 * 1024 * 1024;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
chan.suspend();
|
||||
// wait 5 seconds so that stream flow control kicks in and then see if we
|
||||
// can do a basic transaction (i.e. session not blocked). afterwards resume
|
||||
@ -348,7 +339,7 @@ function test_http2_blocking_download() {
|
||||
var simpleChannel = makeChan("https://localhost:" + serverPort + "/");
|
||||
var sl = new ResumeStalledChannelListener();
|
||||
sl.resumable = chan;
|
||||
simpleChannel.asyncOpen(sl, null);
|
||||
simpleChannel.asyncOpen2(sl);
|
||||
});
|
||||
}
|
||||
|
||||
@ -356,7 +347,7 @@ function test_http2_blocking_download() {
|
||||
function test_http2_basic() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/");
|
||||
var listener = new Http2CheckListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_basic_unblocked_dep() {
|
||||
@ -364,7 +355,7 @@ function test_http2_basic_unblocked_dep() {
|
||||
var cos = chan.QueryInterface(Ci.nsIClassOfService);
|
||||
cos.addClassFlags(Ci.nsIClassOfService.Unblocked);
|
||||
var listener = new Http2CheckListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// make sure we don't use h2 when disallowed
|
||||
@ -374,7 +365,7 @@ function test_http2_nospdy() {
|
||||
var internalChannel = chan.QueryInterface(Ci.nsIHttpChannelInternal);
|
||||
internalChannel.allowSpdy = false;
|
||||
listener.shouldBeHttp2 = false;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Support for making sure XHR works over SPDY
|
||||
@ -434,7 +425,7 @@ function test_http2_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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +445,7 @@ function test_http2_concurrent_post() {
|
||||
var uchan = concurrent_channels[i].QueryInterface(Ci.nsIUploadChannel);
|
||||
uchan.setUploadStream(stream, "text/plain", stream.available());
|
||||
concurrent_channels[i].requestMethod = "POST";
|
||||
concurrent_channels[i].asyncOpen(concurrent_listener, null);
|
||||
concurrent_channels[i].asyncOpen2(concurrent_listener);
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,8 +455,8 @@ function test_http2_multiplex() {
|
||||
var chan2 = makeChan("https://localhost:" + serverPort + "/multiplex2");
|
||||
var listener1 = new Http2MultiplexListener();
|
||||
var listener2 = new Http2MultiplexListener();
|
||||
chan1.asyncOpen(listener1, null);
|
||||
chan2.asyncOpen(listener2, null);
|
||||
chan1.asyncOpen2(listener1);
|
||||
chan2.asyncOpen2(listener2);
|
||||
}
|
||||
|
||||
// Test to make sure we gateway non-standard headers properly
|
||||
@ -476,7 +467,7 @@ function test_http2_header() {
|
||||
var listener = new Http2HeaderListener("X-Received-Test-Header", function(received_hvalue) {
|
||||
do_check_eq(received_hvalue, hvalue);
|
||||
});
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Test to make sure cookies are split into separate fields before compression
|
||||
@ -495,35 +486,35 @@ function test_http2_cookie_crumbling() {
|
||||
do_check_eq(cookiesSent[index], cookieReceived)
|
||||
});
|
||||
});
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_push1() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new Http2PushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_push2() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push.js");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new Http2PushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_push3() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push2");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new Http2PushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_push4() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/push2.js");
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new Http2PushListener();
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// this is a basic test where the server sends a simple document with 2 header
|
||||
@ -531,20 +522,20 @@ function test_http2_push4() {
|
||||
function test_http2_doubleheader() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/doubleheader");
|
||||
var listener = new Http2CheckListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Make sure we handle GETs that cover more than 2 frames properly
|
||||
function test_http2_big() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/big");
|
||||
var listener = new Http2BigListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_huge_suspended() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/huge");
|
||||
var listener = new Http2HugeSuspendedListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
chan.suspend();
|
||||
do_timeout(500, chan.resume);
|
||||
}
|
||||
@ -560,7 +551,7 @@ function do_post(content, chan, listener, method) {
|
||||
|
||||
chan.requestMethod = method;
|
||||
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
// Make sure we can do a simple POST
|
||||
@ -585,7 +576,7 @@ function test_http2_post_big() {
|
||||
}
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
var httpserv = null;
|
||||
var httpserv2 = null;
|
||||
@ -612,13 +603,13 @@ var altsvcClientListener = {
|
||||
chan.setRequestHeader("x-redirect-origin",
|
||||
"http://localhost:" + httpserv2.identity.primaryPort, false);
|
||||
chan.loadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
chan.asyncOpen(altsvcClientListener, chan);
|
||||
chan.asyncOpen2(altsvcClientListener);
|
||||
} else {
|
||||
do_check_true(isHttp2Connection);
|
||||
var chan = makeChan("http://localhost:" + httpserv2.identity.primaryPort + "/altsvc2")
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
chan.loadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
chan.asyncOpen(altsvcClientListener2, chan);
|
||||
chan.asyncOpen2(altsvcClientListener2);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -639,7 +630,7 @@ var altsvcClientListener2 = {
|
||||
var chan = makeChan("http://localhost:" + httpserv2.identity.primaryPort + "/altsvc2")
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
chan.loadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
chan.asyncOpen(altsvcClientListener2, chan);
|
||||
chan.asyncOpen2(altsvcClientListener2);
|
||||
} else {
|
||||
do_check_true(isHttp2Connection);
|
||||
run_next_test();
|
||||
@ -671,7 +662,7 @@ function altsvcHttp1Server2(metadata, response) {
|
||||
function test_http2_altsvc() {
|
||||
var chan = makeChan("http://localhost:" + httpserv.identity.primaryPort + "/altsvc1")
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
chan.asyncOpen(altsvcClientListener, chan);
|
||||
chan.asyncOpen2(altsvcClientListener);
|
||||
}
|
||||
|
||||
var Http2PushApiListener = function() {};
|
||||
@ -695,7 +686,7 @@ Http2PushApiListener.prototype = {
|
||||
do_check_eq(associatedChannel.originalURI.spec, "https://localhost:" + serverPort + "/pushapi1");
|
||||
do_check_eq (pushChannel.getRequestHeader("x-pushed-request"), "true");
|
||||
|
||||
pushChannel.asyncOpen(this, pushChannel);
|
||||
pushChannel.asyncOpen2(this);
|
||||
if (pushChannel.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/2") {
|
||||
pushChannel.cancel(Components.results.NS_ERROR_ABORT);
|
||||
}
|
||||
@ -706,17 +697,17 @@ Http2PushApiListener.prototype = {
|
||||
},
|
||||
|
||||
onDataAvailable: function pushAPIOnDataAvailable(request, ctx, stream, offset, cnt) {
|
||||
do_check_neq(ctx.originalURI.spec, "https://localhost:" + serverPort + "/pushapi1/2");
|
||||
do_check_neq(request.originalURI.spec, "https://localhost:" + serverPort + "/pushapi1/2");
|
||||
|
||||
var data = read_stream(stream, cnt);
|
||||
|
||||
if (ctx.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1") {
|
||||
if (request.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1") {
|
||||
do_check_eq(data[0], '0');
|
||||
--this.checksPending;
|
||||
} else if (ctx.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/1") {
|
||||
} else if (request.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/1") {
|
||||
do_check_eq(data[0], '1');
|
||||
--this.checksPending; // twice
|
||||
} else if (ctx.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/3") {
|
||||
} else if (request.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/3") {
|
||||
do_check_eq(data[0], '3');
|
||||
--this.checksPending;
|
||||
} else {
|
||||
@ -725,7 +716,7 @@ Http2PushApiListener.prototype = {
|
||||
},
|
||||
|
||||
onStopRequest: function test_onStopR(request, ctx, status) {
|
||||
if (ctx.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/2") {
|
||||
if (request.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/2") {
|
||||
do_check_eq(request.status, Components.results.NS_ERROR_ABORT);
|
||||
} else {
|
||||
do_check_eq(request.status, Components.results.NS_OK);
|
||||
@ -751,7 +742,7 @@ function test_http2_pushapi_1() {
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new Http2PushApiListener();
|
||||
chan.notificationCallbacks = listener;
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
var WrongSuiteListener = function() {};
|
||||
@ -768,14 +759,14 @@ function test_http2_wrongsuite() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/wrongsuite");
|
||||
chan.loadFlags = Ci.nsIRequest.LOAD_FRESH_CONNECTION | Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
|
||||
var listener = new WrongSuiteListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_h11required_stream() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/h11required_stream");
|
||||
var listener = new Http2CheckListener();
|
||||
listener.shouldBeHttp2 = false;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function H11RequiredSessionListener () { }
|
||||
@ -797,13 +788,13 @@ function test_http2_h11required_session() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/h11required_session");
|
||||
var listener = new H11RequiredSessionListener();
|
||||
listener.shouldBeHttp2 = false;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_retry_rst() {
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/rstonce");
|
||||
var listener = new Http2CheckListener();
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_continuations() {
|
||||
@ -811,7 +802,7 @@ function test_http2_continuations() {
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new Http2ContinuedHeaderListener();
|
||||
chan.notificationCallbacks = listener;
|
||||
chan.asyncOpen(listener, chan);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function Http2IllegalHpackValidationListener() { }
|
||||
@ -838,7 +829,7 @@ Http2IllegalHpackListener.prototype.onStopRequest = function (request, ctx, stat
|
||||
var chan = makeChan("https://localhost:" + serverPort + "/illegalhpack_validate");
|
||||
var listener = new Http2IllegalHpackValidationListener();
|
||||
listener.shouldGoAway = this.shouldGoAway;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
};
|
||||
|
||||
function test_http2_illegalhpacksoft() {
|
||||
@ -846,7 +837,7 @@ function test_http2_illegalhpacksoft() {
|
||||
var listener = new Http2IllegalHpackListener();
|
||||
listener.shouldGoAway = false;
|
||||
listener.shouldSucceed = false;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_illegalhpackhard() {
|
||||
@ -854,7 +845,7 @@ function test_http2_illegalhpackhard() {
|
||||
var listener = new Http2IllegalHpackListener();
|
||||
listener.shouldGoAway = true;
|
||||
listener.shouldSucceed = false;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_http2_folded_header() {
|
||||
@ -862,7 +853,7 @@ function test_http2_folded_header() {
|
||||
chan.loadGroup = loadGroup;
|
||||
var listener = new Http2CheckListener();
|
||||
listener.shouldSucceed = false;
|
||||
chan.asyncOpen(listener, null);
|
||||
chan.asyncOpen2(listener);
|
||||
}
|
||||
|
||||
function test_complete() {
|
||||
|
Loading…
Reference in New Issue
Block a user