Set offline=false, if network manager init failed. Fixes xulrunner, and seamonkey+thunderbird test. Bug 616520, r=bz, a=bz
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 08 Dec 2010 18:08:09 +0100
changeset 58899 e68363d923898a5378964b9553cbe465b724f8e0
parent 58898 35ea831c27abbe8630b6329bad3a69840a1671f1
child 58900 3171bf1a510970a5c61af4238cbc6a44fa9c9079
push idunknown
push userunknown
push dateunknown
reviewersbz, bz
bugs616520
milestone2.0b8pre
Set offline=false, if network manager init failed. Fixes xulrunner, and seamonkey+thunderbird test. Bug 616520, r=bz, a=bz
netwerk/base/src/nsIOService.cpp
netwerk/test/unit/test_offline_status.js
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -263,18 +263,22 @@ nsIOService::Init()
     gIOService = this;
 
 #ifdef MOZ_IPC
     // go into managed mode if we can, and chrome process
     if (XRE_GetProcessType() == GeckoProcessType_Default)
 #endif
         mNetworkLinkService = do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID);
 
-    if (!mNetworkLinkService)
+    if (!mNetworkLinkService) {
         mManageOfflineStatus = PR_FALSE;
+        // We can't really determine if the machine has a usable network connection,
+        // so let's cross our fingers!
+        SetOffline(PR_FALSE);
+    }
 
     if (mManageOfflineStatus)
         TrackNetworkLinkStatusForOffline();
     
     NS_TIME_FUNCTION_MARK("Set up network link service");
 
     return NS_OK;
 }
--- a/netwerk/test/unit/test_offline_status.js
+++ b/netwerk/test/unit/test_offline_status.js
@@ -1,10 +1,15 @@
 function run_test() {
   var ioService = Components.classes["@mozilla.org/network/io-service;1"]
                             .getService(Components.interfaces.nsIIOService);
 
-  var linkService = Components.classes["@mozilla.org/network/network-link-service;1"]
-                              .getService(Components.interfaces.nsINetworkLinkService);
+  try {
+    var linkService = Components.classes["@mozilla.org/network/network-link-service;1"]
+                                .getService(Components.interfaces.nsINetworkLinkService);
 
-  // The offline status should depends on the link status
-  do_check_neq(ioService.offline, linkService.isLinkUp);
+    // The offline status should depends on the link status
+    do_check_neq(ioService.offline, linkService.isLinkUp);
+  } catch (e) {
+    // The network link service might not be available
+    do_check_eq(ioService.offline, false);
+  }
 }