bug 1104987 - cleanup h1 instances in h2 tests promptly r=hurley

This commit is contained in:
Patrick McManus 2014-11-25 16:24:02 -05:00
parent be4ba5f501
commit cf33d62e79
2 changed files with 22 additions and 2 deletions

View File

@ -508,6 +508,12 @@ function test_http2_retry_rst() {
chan.asyncOpen(listener, null);
}
function test_complete() {
resetPrefs();
do_test_finished();
do_timeout(0,run_next_test);
}
// hack - the header test resets the multiplex object on the server,
// so make sure header is always run before the multiplex test.
//
@ -533,6 +539,9 @@ var tests = [ test_http2_post_big
, test_http2_h11required_stream
, test_http2_h11required_session
, test_http2_retry_rst
// cleanup
, test_complete
];
var current_test = 0;
@ -621,7 +630,7 @@ function resetPrefs() {
function run_test() {
// Set to allow the cert presented by our SPDY server
do_get_profile();
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var oldPref = prefs.getIntPref("network.http.speculative-parallel-limit");
prefs.setIntPref("network.http.speculative-parallel-limit", 0);

View File

@ -2,6 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This module is the stateful server side of test_http2.js and is meant
// to have node be restarted in between each invocation
var http2 = require('../node-http2');
var fs = require('fs');
var url = require('url');
@ -102,6 +105,7 @@ function handleRequest(req, res) {
if (u.pathname === '/exit') {
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Connection', 'close');
res.writeHead(200);
res.end('ok');
process.exit();
@ -265,7 +269,7 @@ function handleRequest(req, res) {
}
else if (u.pathname === "/rstonce") {
if (!didRst) {
if (!didRst && req.httpVersionMajor === 2) {
didRst = true;
rstConnection = req.stream.connection;
req.stream.reset('REFUSED_STREAM');
@ -274,17 +278,24 @@ function handleRequest(req, res) {
if (rstConnection === null ||
rstConnection !== req.stream.connection) {
res.setHeader('Connection', 'close');
res.writeHead(400);
res.end("WRONG CONNECTION, HOMIE!");
return;
}
if (req.httpVersionMajor != 2) {
res.setHeader('Connection', 'close');
}
res.writeHead(200);
res.end("It's all good.");
return;
}
res.setHeader('Content-Type', 'text/html');
if (req.httpVersionMajor != 2) {
res.setHeader('Connection', 'close');
}
res.writeHead(200);
res.end(content);
}