2012-04-25 05:54:42 -07:00
|
|
|
const CC = Components.Constructor;
|
|
|
|
|
|
|
|
const ServerSocket = CC("@mozilla.org/network/server-socket;1",
|
|
|
|
"nsIServerSocket",
|
|
|
|
"init");
|
|
|
|
|
|
|
|
var serv;
|
|
|
|
|
|
|
|
function TestServer() {
|
2013-07-19 10:19:28 -07:00
|
|
|
this.listener = ServerSocket(-1, true, -1);
|
2012-04-25 05:54:42 -07:00
|
|
|
this.listener.asyncListen(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestServer.prototype = {
|
|
|
|
QueryInterface: function(iid) {
|
|
|
|
if (iid.equals(Ci.nsIServerSocket) ||
|
|
|
|
iid.equals(Ci.nsISupports))
|
|
|
|
return this;
|
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
|
|
},
|
|
|
|
onSocketAccepted: function(socket, trans) {
|
|
|
|
try { this.listener.close(); } catch(e) {}
|
|
|
|
do_check_true(true);
|
|
|
|
do_test_finished();
|
|
|
|
},
|
|
|
|
|
|
|
|
onStopListening: function(socket) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
var ios = Cc["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(Ci.nsIIOService);
|
|
|
|
|
|
|
|
serv = new TestServer();
|
2013-07-19 10:19:28 -07:00
|
|
|
URI = ios.newURI("http://localhost:" + serv.listener.port + "/just/a/test", null, null);
|
2012-04-25 05:54:42 -07:00
|
|
|
ios.QueryInterface(Components.interfaces.nsISpeculativeConnect)
|
2012-11-14 08:00:44 -08:00
|
|
|
.speculativeConnect(URI, null);
|
2012-04-25 05:54:42 -07:00
|
|
|
do_test_pending();
|
|
|
|
}
|
|
|
|
|