Backout 736a590cb652 and 0c409a9f58c9 (Bug 853423) due to xpcshell failures
authorSteve Workman <sworkman@mozilla.com>
Sat, 28 Sep 2013 12:37:30 -0700
changeset 149150 edcc336b40338c38639a332989c7d0dada46a88b
parent 149149 ae2c2e730c2ad7721ed4cc1cb9660a9161a0fff7
child 149151 cea4196cd3b23fb559d5899a2161dbe9c488c977
push id34457
push usersworkman@mozilla.com
push dateSat, 28 Sep 2013 19:38:19 +0000
treeherdermozilla-inbound@edcc336b4033 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs853423
milestone27.0a1
backs out736a590cb652fcc98eaeedb494fa419280d515c8
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout 736a590cb652 and 0c409a9f58c9 (Bug 853423) due to xpcshell failures
netwerk/base/public/nsISocketTransport.idl
netwerk/base/src/nsSocketTransport2.cpp
netwerk/dns/DNS.cpp
netwerk/dns/DNS.h
netwerk/protocol/http/nsHttpConnectionInfo.cpp
netwerk/protocol/http/nsHttpConnectionInfo.h
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/test/unit/test_speculative_connect.js
--- a/netwerk/base/public/nsISocketTransport.idl
+++ b/netwerk/base/public/nsISocketTransport.idl
@@ -172,22 +172,16 @@ interface nsISocketTransport : nsITransp
 
     /**
      * If set, we will skip all IPv4 addresses the host may have and only
      * connect to IPv6 ones.
      */
     const unsigned long DISABLE_IPV4 = (1 << 4);
 
     /**
-     * If set, indicates that the socket should not connect if the hostname
-     * resolves to an RFC1918 address or IPv6 equivalent.
-     */
-    const unsigned long DISABLE_RFC1918 = (1 << 5);
-
-    /**
      * Socket QoS/ToS markings. Valid values are IPTOS_DSCP_AFxx or
      * IPTOS_CLASS_CSx (or IPTOS_DSCP_EF, but currently no supported
      * services require expedited-forwarding).
      * Not setting this value will leave the socket with the default
      * ToS value, which on most systems if IPTOS_CLASS_CS0 (formerly
      * IPTOS_PREC_ROUTINE).
      */
     attribute octet QoSBits;
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -1156,38 +1156,16 @@ nsSocketTransport::InitiateSocket()
     if (gIOService->IsOffline()) {
         bool isLocal;
 
         IsLocal(&isLocal);
         if (!isLocal)
             return NS_ERROR_OFFLINE;
     }
 
-    // Hosts/Proxy Hosts that are Local IP Literals should not be speculatively
-    // connected - Bug 853423.
-    if (mConnectionFlags & nsISocketTransport::DISABLE_RFC1918 &&
-        IsIPAddrLocal(&mNetAddr)) {
-#ifdef PR_LOGGING
-        if (SOCKET_LOG_ENABLED()) {
-            nsAutoCString netAddrCString;
-            netAddrCString.SetCapacity(kIPv6CStrBufSize);
-            if (!NetAddrToString(&mNetAddr,
-                                 netAddrCString.BeginWriting(),
-                                 kIPv6CStrBufSize))
-                netAddrCString = NS_LITERAL_CSTRING("<IP-to-string failed>");
-            SOCKET_LOG(("nsSocketTransport::InitiateSocket skipping "
-                        "speculative connection for host [%s:%d] proxy "
-                        "[%s:%d] with Local IP address [%s]",
-                        mHost.get(), mPort, mProxyHost.get(), mProxyPort,
-                        netAddrCString.get()));
-        }
-#endif
-        return NS_ERROR_CONNECTION_REFUSED;
-    }
-
     //
     // find out if it is going to be ok to attach another socket to the STS.
     // if not then we have to wait for the STS to tell us that it is ok.
     // the notification is asynchronous, which means that when we could be
     // in a race to call AttachSocket once notified.  for this reason, when
     // we get notified, we just re-enter this function.  as a result, we are
     // sure to ask again before calling AttachSocket.  in this way we deal
     // with the race condition.  though it isn't the most elegant solution,
--- a/netwerk/dns/DNS.cpp
+++ b/netwerk/dns/DNS.cpp
@@ -172,42 +172,16 @@ bool IsIPAddrAny(const NetAddr *addr)
 bool IsIPAddrV4Mapped(const NetAddr *addr)
 {
   if (addr->raw.family == AF_INET6) {
     return IPv6ADDR_IS_V4MAPPED(&addr->inet6.ip);
   }
   return false;
 }
 
-bool IsIPAddrLocal(const NetAddr *addr)
-{
-  MOZ_ASSERT(addr);
-
-  // IPv4 RFC1918 and Link Local Addresses.
-  if (addr->raw.family == AF_INET) {
-    uint32_t addr32 = ntohl(addr->inet.ip);
-    if (addr32 >> 24 == 0x0A ||    // 10/8 prefix (RFC 1918).
-        addr32 >> 20 == 0xAC1 ||   // 172.16/12 prefix (RFC 1918).
-        addr32 >> 16 == 0xC0A8 ||  // 192.168/16 prefix (RFC 1918).
-        addr32 >> 16 == 0xA9FE) {  // 169.254/16 prefix (Link Local).
-      return true;
-    }
-  }
-  // IPv6 Unique and Link Local Addresses.
-  if (addr->raw.family == AF_INET6) {
-    uint16_t addr16 = ntohs(addr->inet6.ip.u16[0]);
-    if (addr16 >> 9 == 0xfc >> 1 ||   // fc00::/7 Unique Local Address.
-        addr16 >> 6 == 0xfe80 >> 6) { // fe80::/10 Link Local Address.
-      return true;
-    }
-  }
-  // Not an IPv4/6 local address.
-  return false;
-}
-
 NetAddrElement::NetAddrElement(const PRNetAddr *prNetAddr)
 {
   PRNetAddrToNetAddr(prNetAddr, &mAddress);
 }
 
 NetAddrElement::NetAddrElement(const NetAddrElement& netAddr)
 {
   mAddress = netAddr.mAddress;
--- a/netwerk/dns/DNS.h
+++ b/netwerk/dns/DNS.h
@@ -155,14 +155,12 @@ void NetAddrToPRNetAddr(const NetAddr *a
 bool NetAddrToString(const NetAddr *addr, char *buf, uint32_t bufSize);
 
 bool IsLoopBackAddress(const NetAddr *addr);
 
 bool IsIPAddrAny(const NetAddr *addr);
 
 bool IsIPAddrV4Mapped(const NetAddr *addr);
 
-bool IsIPAddrLocal(const NetAddr *addr);
-
 } // namespace net
 } // namespace mozilla
 
 #endif // DNS_h_
--- a/netwerk/protocol/http/nsHttpConnectionInfo.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.cpp
@@ -3,20 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include "nsHttpConnectionInfo.h"
-#include "mozilla/net/DNS.h"
-#include "prnetdb.h"
-
-using namespace mozilla::net;
 
 nsHttpConnectionInfo::nsHttpConnectionInfo(const nsACString &host, int32_t port,
                                            nsProxyInfo* proxyInfo,
                                            bool usingSSL)
     : mRef(0)
     , mProxyInfo(proxyInfo)
     , mUsingSSL(usingSSL)
     , mUsingConnect(false)
@@ -112,24 +108,8 @@ nsHttpConnectionInfo::Clone() const
 bool
 nsHttpConnectionInfo::UsingProxy()
 {
     if (!mProxyInfo)
         return false;
     return !mProxyInfo->IsDirect();
 }
 
-bool
-nsHttpConnectionInfo::HostIsLocalIPLiteral() const
-{
-    PRNetAddr prAddr;
-    // If the host/proxy host is not an IP address literal, return false.
-    if (ProxyHost()) {
-        if (PR_StringToNetAddr(ProxyHost(), &prAddr) != PR_SUCCESS) {
-          return false;
-        }
-    } else if (PR_StringToNetAddr(Host(), &prAddr) != PR_SUCCESS) {
-        return false;
-    }
-    NetAddr netAddr;
-    PRNetAddrToNetAddr(&prAddr, &netAddr);
-    return IsIPAddrLocal(&netAddr);
-}
--- a/netwerk/protocol/http/nsHttpConnectionInfo.h
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.h
@@ -87,19 +87,16 @@ public:
     void          SetPrivate(bool priv)  { mHashKey.SetCharAt(priv ? 'P' : '.', 3); }
     bool          GetPrivate() const     { return mHashKey.CharAt(3) == 'P'; }
 
     const nsCString &GetHost() { return mHost; }
 
     // Returns true for any kind of proxy (http, socks, etc..)
     bool UsingProxy();
 
-    // Returns true when mHost is an RFC1918 literal.
-    bool HostIsLocalIPLiteral() const;
-
 private:
     mozilla::ThreadSafeAutoRefCnt mRef;
     nsCString              mHashKey;
     nsCString              mHost;
     int32_t                mPort;
     nsCOMPtr<nsProxyInfo>  mProxyInfo;
     bool                   mUsingHttpProxy;
     bool                   mUsingSSL;
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -321,24 +321,16 @@ nsHttpConnectionMgr::DoShiftReloadConnec
 nsresult
 nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci,
                                         nsIInterfaceRequestor *callbacks,
                                         uint32_t caps)
 {
     LOG(("nsHttpConnectionMgr::SpeculativeConnect [ci=%s]\n",
          ci->HashKey().get()));
 
-    // Hosts that are Local IP Literals should not be speculatively
-    // connected - Bug 853423.
-    if (ci && ci->HostIsLocalIPLiteral()) {
-        LOG(("nsHttpConnectionMgr::SpeculativeConnect skipping RFC1918 "
-             "address [%s]", ci->Host()));
-        return NS_OK;
-    }
-
     // Wrap up the callbacks and the target to ensure they're released on the target
     // thread properly.
     nsCOMPtr<nsIInterfaceRequestor> wrappedCallbacks;
     NS_NewInterfaceRequestorAggregation(callbacks, nullptr, getter_AddRefs(wrappedCallbacks));
 
     caps |= ci->GetAnonymous() ? NS_HTTP_LOAD_ANONYMOUS : 0;
     nsRefPtr<NullHttpTransaction> trans =
         new NullHttpTransaction(ci, wrappedCallbacks, caps);
@@ -2657,20 +2649,16 @@ nsHalfOpenSocket::SetupStreams(nsISocket
     if (mEnt->mPreferIPv6) {
         tmpFlags |= nsISocketTransport::DISABLE_IPV4;
     }
     else if (mEnt->mPreferIPv4 ||
              (isBackup && gHttpHandler->FastFallbackToIPv4())) {
         tmpFlags |= nsISocketTransport::DISABLE_IPV6;
     }
 
-    if (IsSpeculative()) {
-        tmpFlags |= nsISocketTransport::DISABLE_RFC1918;
-    }
-
     socketTransport->SetConnectionFlags(tmpFlags);
 
     socketTransport->SetQoSBits(gHttpHandler->GetQoSBits());
 
     rv = socketTransport->SetEventSink(this, nullptr);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = socketTransport->SetSecurityCallbacks(this);
--- a/netwerk/test/unit/test_speculative_connect.js
+++ b/netwerk/test/unit/test_speculative_connect.js
@@ -1,401 +1,40 @@
-/* -*- Mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=4 sts=4 et sw=4 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
+const CC = Components.Constructor;
 
-const CC = Components.Constructor;
 const ServerSocket = CC("@mozilla.org/network/server-socket;1",
                         "nsIServerSocket",
                         "init");
-var serv;
-var ios;
-
-/** Example local IP addresses (literal IP address hostname).
- *
- * Note: for IPv6 Unique Local and Link Local, a wider range of addresses is
- * set aside than those most commonly used. Technically, link local addresses
- * include those beginning with fe80:: through febf::, although in practise
- * only fe80:: is used. Necko code blocks speculative connections for the wider
- * range; hence, this test considers that range too.
- */
-var localIPv4Literals =
-    [ // IPv4 RFC1918 \
-      "10.0.0.1", "10.10.10.10", "10.255.255.255",         // 10/8
-      "172.16.0.1", "172.23.172.12", "172.31.255.255",     // 172.16/20
-      "192.168.0.1", "192.168.192.168", "192.168.255.255", // 192.168/16
-      // IPv4 Link Local
-      "169.254.0.1", "169.254.192.154", "169.254.255.255"  // 169.254/16
-    ];
-var localIPv6Literals =
-    [ // IPv6 Unique Local fc00::/7
-      "fc00::1", "fdfe:dcba:9876:abcd:ef01:2345:6789:abcd",
-      "fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
-      // IPv6 Link Local fe80::/10
-      "fe80::1", "fe80::abcd:ef01:2345:6789",
-      "febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
-    ];
-var localIPLiterals = localIPv4Literals.concat(localIPv6Literals);
 
-/** Example remote IP addresses
- *
- * Note: The test environment may not have external network access, so
- * resolving hostnames may not be possible. Thus, literals are used here, and
- * should be directly converted by the stub resolver to IP addresses.
- */
-var remoteIPv4Literals =
-    [ "93.184.216.119", // example.com
-      "74.125.239.130", // google.com
-      "63.245.217.105", // mozilla.org
-      "173.252.110.27"  // facebook.com
-    ];
-
-var remoteIPv6Literals =
-    [ "2607:f8b0:4005:802::1009",        // google.com
-      "2620:101:8008:5::2:1",            // mozilla.org
-      "2a03:2880:2110:df07:face:b00c::1" // facebook.com
-    ];
-
-var remoteIPLiterals = remoteIPv4Literals.concat(remoteIPv6Literals);
+var serv;
 
-/** Test function list and descriptions.
- */
-var testList =
-    [ test_speculative_connect,
-      test_hostnames_resolving_to_local_addresses,
-      test_hostnames_resolving_to_remote_addresses,
-      test_proxies_with_local_addresses,
-      test_proxies_with_remote_addresses
-    ];
-
-var testDescription =
-    [ "Expect pass with localhost",
-      "Expect failure with resolved local IPs",
-      "Expect success with resolved remote IPs",
-      "Expect failure for proxies with local IPs",
-      "Expect success for proxies with remote IPs"
-    ];
-
-var testIdx = 0;
-var hostIdx = 0;
-
-
-/** TestServer
- *
- * Implements nsIServerSocket for test_speculative_connect.
- */
 function TestServer() {
     this.listener = ServerSocket(-1, true, -1);
     this.listener.asyncListen(this);
 }
 
 TestServer.prototype = {
     QueryInterface: function(iid) {
         if (iid.equals(Ci.nsIServerSocket) ||
             iid.equals(Ci.nsISupports))
             return this;
-        throw Cr.NS_ERROR_NO_INTERFACE;
+        throw Components.results.NS_ERROR_NO_INTERFACE;
     },
     onSocketAccepted: function(socket, trans) {
         try { this.listener.close(); } catch(e) {}
         do_check_true(true);
-        next_test();
+        do_test_finished();
     },
 
     onStopListening: function(socket) {}
-};
-
-/** TestOutputStreamCallback
- *
- * Implements nsIOutputStreamCallback for socket layer tests.
- */
-function TestOutputStreamCallback(hostname, proxied, expectSuccess, next) {
-    this.hostname = hostname;
-    this.proxied = proxied;
-    this.expectSuccess = expectSuccess;
-    this.next = next;
-    this.dummyContent = "Dummy content";
-}
-
-TestOutputStreamCallback.prototype = {
-    QueryInterface: function(iid) {
-        if (iid.equals(Ci.nsIOutputStreamCallback) ||
-            iid.equals(Ci.nsISupports))
-            return this;
-        throw Cr.NS_ERROR_NO_INTERFACE;
-    },
-    onOutputStreamReady: function(stream) {
-        do_check_neq(typeof(stream), undefined);
-        try {
-            stream.write(this.dummyContent, this.dummyContent.length);
-        } catch (e) {
-            // Spec Connect FAILED.
-            do_check_instanceof(e, Ci.nsIException);
-            if (this.expectSuccess) {
-                // We may expect success, but the address could be unreachable
-                // in the test environment, so expect errors.
-                if (this.proxied) {
-                    do_check_true(e.result == Cr.NS_ERROR_NET_TIMEOUT ||
-                                  e.result == Cr.NS_ERROR_PROXY_CONNECTION_REFUSED);
-                } else {
-                    do_check_true(e.result == Cr.NS_ERROR_NET_TIMEOUT ||
-                                  e.result == Cr.NS_ERROR_CONNECTION_REFUSED);
-                }
-            } else {
-                // A refusal to connect speculatively should throw an error.
-                do_check_eq(e.result, Cr.NS_ERROR_CONNECTION_REFUSED);
-            }
-            stream.closeWithStatus(e.result);
-            this.next();
-            return;
-        }
-        // Spec Connect SUCCEEDED.
-        if (this.expectSuccess) {
-            do_check_true(true, "Success for " + this.hostname);
-        } else {
-            do_throw("Speculative Connect should have failed for " +
-                     this.hostname);
-        }
-        stream.closeWithStatus(Cr.NS_ERROR_BINDING_ABORTED);
-        this.next();
-    }
-};
-
-/** test_speculative_connect
- *
- * Tests a basic positive case using nsIOService.SpeculativeConnect:
- * connecting to localhost.
- */
-function test_speculative_connect() {
-    serv = new TestServer();
-    var URI = ios.newURI("http://localhost:" + serv.listener.port + "/just/a/test", null, null);
-    ios.QueryInterface(Ci.nsISpeculativeConnect)
-        .speculativeConnect(URI, null);
-}
-
-/* Speculative connections should not be allowed for hosts with local IP
- * addresses (Bug 853423). That list includes:
- *  -- IPv4 RFC1918 and Link Local Addresses.
- *  -- IPv6 Unique and Link Local Addresses.
- *
- * Two tests are required:
- *  1. Verify IP Literals passed to the SpeculativeConnect API.
- *  2. Verify hostnames that need to be resolved at the socket layer.
- */
-
-/** test_hostnames_resolving_to_addresses
- *
- * Common test function for resolved hostnames. Takes a list of hosts, a
- * boolean to determine if the test is expected to succeed or fail, and a
- * function to call the next test case.
- */
-function test_hostnames_resolving_to_addresses(host, expectSuccess, next) {
-    do_print(host);
-    var sts = Cc["@mozilla.org/network/socket-transport-service;1"]
-              .getService(Ci.nsISocketTransportService);
-    do_check_neq(typeof(sts), undefined);
-    var transport = sts.createTransport(null, 0, host, 80, null);
-    do_check_neq(typeof(transport), undefined);
-
-    transport.connectionFlags = Ci.nsISocketTransport.DISABLE_RFC1918;
-    transport.setTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT, 1);
-    do_check_eq(1, transport.getTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT));
-
-    var outStream = transport.openOutputStream(Ci.nsITransport.OPEN_UNBUFFERED,0,0);
-    do_check_neq(typeof(outStream), undefined);
-
-    var callback = new TestOutputStreamCallback(host, false,
-                                                expectSuccess,
-                                                next);
-    do_check_neq(typeof(callback), undefined);
-
-    // Need to get main thread pointer to ensure nsSocketTransport::AsyncWait
-    // adds callback to nsOutputStreamReadyEvent on main thread, and doesn't
-    // addref off the main thread.
-    var gThreadManager = Cc["@mozilla.org/thread-manager;1"]
-    .getService(Ci.nsIThreadManager);
-    var mainThread = gThreadManager.currentThread;
-
-    try {
-        outStream.QueryInterface(Ci.nsIAsyncOutputStream)
-                 .asyncWait(callback, 0, 0, mainThread);
-    } catch (e) {
-        do_throw("asyncWait should not fail!");
-    }
-}
-
-/**
- * test_hostnames_resolving_to_local_addresses
- *
- * Creates an nsISocketTransport and simulates a speculative connect request
- * for a hostname that resolves to a local IP address.
- * Runs asynchronously; on test success (i.e. failure to connect), the callback
- * will call this function again until all hostnames in the test list are done.
- *
- * Note: This test also uses an IP literal for the hostname. This should be ok,
- * as the socket layer will ask for the hostname to be resolved anyway, and DNS
- * code should return a numerical version of the address internally.
- */
-function test_hostnames_resolving_to_local_addresses() {
-    if (hostIdx >= localIPLiterals.length) {
-        // No more local IP addresses; move on.
-        next_test();
-        return;
-    }
-    var host = localIPLiterals[hostIdx++];
-    // Test another local IP address when the current one is done.
-    var next = test_hostnames_resolving_to_local_addresses;
-    test_hostnames_resolving_to_addresses(host, false, next);
 }
 
-/**
- * test_hostnames_resolving_to_remote_addresses
- *
- * Creates an nsISocketTransport and simulates a speculative connect request
- * for a hostname that resolves to a local IP address.
- * Runs asynchronously; on test success (i.e. failure to connect), the callback
- * will call this function again until all hostnames in the test list are done.
- *
- * Note: This test also uses an IP literal for the hostname. This should be ok,
- * as the socket layer will ask for the hostname to be resolved anyway, and DNS
- * code should return a numerical version of the address internally.
- */
-function test_hostnames_resolving_to_remote_addresses() {
-    if (hostIdx >= remoteIPLiterals.length) {
-        // No more remote IP addresses; move on.
-        next_test();
-        return;
-    }
-    var host = remoteIPLiterals[hostIdx++];
-    // Test another remote IP address when the current one is done.
-    var next = test_hostnames_resolving_to_remote_addresses;
-    test_hostnames_resolving_to_addresses(host, true, next);
-}
+function run_test() {
+    var ios = Cc["@mozilla.org/network/io-service;1"]
+        .getService(Ci.nsIIOService);    
 
-/** test_speculative_connect_with_host_list
- *
- * Common test function for resolved proxy hosts. Takes a list of hosts, a
- * boolean to determine if the test is expected to succeed or fail, and a
- * function to call the next test case.
- */
-function test_proxies(proxyHost, expectSuccess, next) {
-    do_print("Proxy: " + proxyHost);
-    var sts = Cc["@mozilla.org/network/socket-transport-service;1"]
-              .getService(Ci.nsISocketTransportService);
-    do_check_neq(typeof(sts), undefined);
-    var pps = Cc["@mozilla.org/network/protocol-proxy-service;1"]
-              .getService();
-    do_check_neq(typeof(pps), undefined);
-
-    var proxyInfo = pps.newProxyInfo("http", proxyHost, 8080, 0, 1, null);
-    do_check_neq(typeof(proxyInfo), undefined);
-
-    var transport = sts.createTransport(null, 0, "dummyHost", 80, proxyInfo);
-    do_check_neq(typeof(transport), undefined);
-
-    transport.connectionFlags = Ci.nsISocketTransport.DISABLE_RFC1918;
-
-    transport.setTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT, 1);
-    do_check_eq(1, transport.getTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT));
-
-    var outStream = transport.openOutputStream(Ci.nsITransport.OPEN_UNBUFFERED,0,0);
-    do_check_neq(typeof(outStream), undefined);
-
-    var callback = new TestOutputStreamCallback(proxyHost, true,
-                                                expectSuccess,
-                                                next);
-    do_check_neq(typeof(callback), undefined);
-
-    // Need to get main thread pointer to ensure nsSocketTransport::AsyncWait
-    // adds callback to nsOutputStreamReadyEvent on main thread, and doesn't
-    // addref off the main thread.
-    var gThreadManager = Cc["@mozilla.org/thread-manager;1"]
-    .getService(Ci.nsIThreadManager);
-    var mainThread = gThreadManager.currentThread;
-
-    try {
-        outStream.QueryInterface(Ci.nsIAsyncOutputStream)
-                 .asyncWait(callback, 0, 0, mainThread);
-    } catch (e) {
-        do_throw("asyncWait should not fail!");
-    }
+    serv = new TestServer();
+    URI = ios.newURI("http://localhost:" + serv.listener.port + "/just/a/test", null, null);
+    ios.QueryInterface(Components.interfaces.nsISpeculativeConnect)
+        .speculativeConnect(URI, null);
+    do_test_pending();
 }
 
-/**
- * test_proxies_with_local_addresses
- *
- * Creates an nsISocketTransport and simulates a speculative connect request
- * for a proxy that resolves to a local IP address.
- * Runs asynchronously; on test success (i.e. failure to connect), the callback
- * will call this function again until all proxies in the test list are done.
- *
- * Note: This test also uses an IP literal for the proxy. This should be ok,
- * as the socket layer will ask for the proxy to be resolved anyway, and DNS
- * code should return a numerical version of the address internally.
- */
-function test_proxies_with_local_addresses() {
-    if (hostIdx >= localIPLiterals.length) {
-        // No more local IP addresses; move on.
-        next_test();
-        return;
-    }
-    var host = localIPLiterals[hostIdx++];
-    // Test another local IP address when the current one is done.
-    var next = test_proxies_with_local_addresses;
-    test_proxies(host, false, next);
-}
-
-/**
- * test_proxies_with_remote_addresses
- *
- * Creates an nsISocketTransport and simulates a speculative connect request
- * for a proxy that resolves to a local IP address.
- * Runs asynchronously; on test success (i.e. failure to connect), the callback
- * will call this function again until all proxies in the test list are done.
- *
- * Note: This test also uses an IP literal for the proxy. This should be ok,
- * as the socket layer will ask for the proxy to be resolved anyway, and DNS
- * code should return a numerical version of the address internally.
- */
-function test_proxies_with_remote_addresses() {
-    if (hostIdx >= remoteIPLiterals.length) {
-        // No more local IP addresses; move on.
-        next_test();
-        return;
-    }
-    var host = remoteIPLiterals[hostIdx++];
-    // Test another local IP address when the current one is done.
-    var next = test_proxies_with_remote_addresses;
-    test_proxies(host, true, next);
-}
-
-/** next_test
- *
- * Calls the next test in testList. Each test is responsible for calling this
- * function when its test cases are complete.
- */
-function next_test() {
-    if (testIdx >= testList.length) {
-        // No more tests; we're done.
-        do_test_finished();
-        return;
-    }
-    do_print("SpeculativeConnect: " + testDescription[testIdx]);
-    hostIdx = 0;
-    // Start next test in list.
-    testList[testIdx++]();
-}
-
-/** run_test
- *
- * Main entry function for test execution.
- */
-function run_test() {
-    ios = Cc["@mozilla.org/network/io-service;1"]
-        .getService(Ci.nsIIOService);
-
-    do_test_pending();
-    //next_test();
-    test_hostnames_resolving_to_local_addresses();
-}
-