2013-09-28 15:00:20 -07:00
|
|
|
const CC = Components.Constructor;
|
2013-09-28 16:20:59 -07:00
|
|
|
|
2012-04-25 05:54:42 -07:00
|
|
|
const ServerSocket = CC("@mozilla.org/network/server-socket;1",
|
|
|
|
"nsIServerSocket",
|
|
|
|
"init");
|
2013-09-28 15:00:20 -07:00
|
|
|
|
2013-09-28 16:20:59 -07:00
|
|
|
var serv;
|
2013-09-28 15:00:20 -07:00
|
|
|
|
2012-04-25 05:54:42 -07:00
|
|
|
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;
|
2013-09-28 16:20:59 -07:00
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
2012-04-25 05:54:42 -07:00
|
|
|
},
|
|
|
|
onSocketAccepted: function(socket, trans) {
|
|
|
|
try { this.listener.close(); } catch(e) {}
|
|
|
|
do_check_true(true);
|
2013-09-28 16:20:59 -07:00
|
|
|
do_test_finished();
|
2012-04-25 05:54:42 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
onStopListening: function(socket) {}
|
|
|
|
}
|
|
|
|
|
2013-09-28 16:20:59 -07:00
|
|
|
function run_test() {
|
|
|
|
var ios = Cc["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(Ci.nsIIOService);
|
2012-04-25 05:54:42 -07:00
|
|
|
|
|
|
|
serv = new TestServer();
|
2013-09-28 16:20:59 -07:00
|
|
|
URI = ios.newURI("http://localhost:" + serv.listener.port + "/just/a/test", null, null);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|