actually call test_wrongpw1, and shut down the HTTP server before the scope

goes away
This commit is contained in:
cbiesinger%web.de 2006-08-02 02:02:37 +00:00
Родитель 73d63ecdde
Коммит f9a96047a4
6 изменённых файлов: 51 добавлений и 7 удалений

Просмотреть файл

@ -127,6 +127,7 @@ nsTestServ.prototype =
onStopListening: function(serverSocket, status)
{
dump(">>> shutting down server socket\n");
this.shutdown = true;
},
startListening: function()
@ -137,6 +138,21 @@ nsTestServ.prototype =
socket.init(this.port, true /* loopback only */, 5);
dump(">>> listening on port "+socket.port+"\n");
socket.asyncListen(this);
this.socket = socket;
},
// Shuts down the server. Note that this processes events.
stopListening: function()
{
if (!this.socket)
return;
this.socket.close();
this.socket = null;
var thr = Components.classes["@mozilla.org/thread-manager;1"]
.getService().currentThread;
while (!this.shutdown) {
thr.processNextEvent(true);
}
},
parseInput: function(input)
@ -177,11 +193,17 @@ nsTestServ.prototype =
return [400];
return [request[1], req_head];
}
},
socket: null,
shutdown: false
}
function start_server(port) {
new nsTestServ(port).startListening();
var serv = new nsTestServ(port);
serv.startListening();
return serv;
}

Просмотреть файл

@ -113,9 +113,17 @@ var listener = {
do_check_eq(status, Components.results.NS_ERROR_ABORT);
if (current_test < (tests.length - 1)) {
// First, gotta clear the auth cache
Components.classes["@mozilla.org/network/http-auth-manager;1"]
.getService(Components.interfaces.nsIHttpAuthManager)
.clearAll();
current_test++;
tests[current_test]();
} else {
httpserv.stopListening();
}
do_test_finished();
}
};
@ -129,11 +137,13 @@ function makeChan(url) {
return chan;
}
var tests = [test_noauth, test_returnfalse1, test_prompt1];
var tests = [test_noauth, test_returnfalse1, test_wrongpw1, test_prompt1];
var current_test = 0;
var httpserv = null;
function run_test() {
start_server(4444);
httpserv = start_server(4444);
tests[0]();
}

Просмотреть файл

@ -15,6 +15,7 @@ TestListener.prototype.onStopRequest = function(request, context, status) {
do_check_eq(channel.responseStatus, 304);
do_test_finished();
server.stopListening();
}
function run_test() {

Просмотреть файл

@ -86,8 +86,10 @@ var urls = [
"http://localhost:4444"
];
var httpserv = null;
function run_test() {
start_server(4444);
httpserv = start_server(4444);
Components.manager.nsIComponentRegistrar.registerFactory(snifferCID,
"Unit test content sniffer", snifferContract, sniffer);
@ -101,6 +103,7 @@ function run_test_iteration(index) {
sniffing_enabled = false;
index = listener._iteration = 1;
} else {
httpserv.stopListening();
return; // we're done
}
}

Просмотреть файл

@ -32,6 +32,8 @@ var listener = {
onStopRequest: function test_onStopR(request, ctx, status) {
if (this._iteration == 1)
run_test_continued();
else
httpserv.stopListening();
do_test_finished();
},
@ -47,8 +49,10 @@ function makeChan() {
return chan;
}
var httpserv = null;
function run_test() {
start_server(4444);
httpserv = start_server(4444);
var chan = makeChan();

Просмотреть файл

@ -81,6 +81,8 @@ var listener = {
onStopRequest: function test_onStopR(request, ctx, status) {
if (this._iteration <= 2)
run_test_continued();
else
httpserv.stopListening();
do_test_finished();
},
@ -96,8 +98,10 @@ function makeChan(url) {
return chan;
}
var httpserv = null;
function run_test() {
start_server(4444);
httpserv = start_server(4444);
Components.manager.nsIComponentRegistrar.registerFactory(sinkCID,
"Unit test Event sink", sinkContract, eventsink);