Bug 952084 - Porting nsIDOMMozConnection to WebIDL, r=ehsan, r=bz
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 16 Jan 2014 11:53:48 +0100
changeset 179781 5302ee051b865fb943b88a520f29686bcb2f882c
parent 179780 6a232abb58963e19e380a4bbbadb3755aa0233f7
child 179782 41a1598f3c024d9a4a5bfa13ed6609741162db89
push idunknown
push userunknown
push dateunknown
reviewersehsan, bz
bugs952084
milestone29.0a1
Bug 952084 - Porting nsIDOMMozConnection to WebIDL, r=ehsan, r=bz
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/bindings/Bindings.conf
dom/network/interfaces/moz.build
dom/network/interfaces/nsIDOMConnection.idl
dom/network/interfaces/nsIMozNavigatorNetwork.idl
dom/network/src/Connection.cpp
dom/network/src/Connection.h
dom/network/src/moz.build
dom/network/tests/test_network_basics.html
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/MozConnection.webidl
dom/webidl/Navigator.webidl
dom/webidl/moz.build
netwerk/protocol/http/nsHttpHandler.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1260,23 +1260,24 @@ Navigator::GetGamepads(nsTArray<nsRefPtr
 }
 #endif
 
 //*****************************************************************************
 //    Navigator::nsIMozNavigatorNetwork
 //*****************************************************************************
 
 NS_IMETHODIMP
-Navigator::GetMozConnection(nsIDOMMozConnection** aConnection)
+Navigator::GetMozConnection(nsISupports** aConnection)
 {
-  NS_IF_ADDREF(*aConnection = GetMozConnection());
+  nsCOMPtr<nsINetworkProperties> properties = GetMozConnection();
+  properties.forget(aConnection);
   return NS_OK;
 }
 
-nsIDOMMozConnection*
+network::Connection*
 Navigator::GetMozConnection()
 {
   if (!mConnection) {
     NS_ENSURE_TRUE(mWindow, nullptr);
     NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
 
     mConnection = new network::Connection();
     mConnection->Init(mWindow);
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -190,17 +190,17 @@ public:
   void GetDeviceStorages(const nsAString& aType,
                          nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores,
                          ErrorResult& aRv);
   DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
   bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
                              ErrorResult& aRv);
   nsIDOMMozMobileMessageManager* GetMozMobileMessage();
   Telephony* GetMozTelephony(ErrorResult& aRv);
-  nsIDOMMozConnection* GetMozConnection();
+  network::Connection* GetMozConnection();
   nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
   void MozSetMessageHandler(const nsAString& aType,
                             systemMessageCallback* aCallback,
                             ErrorResult& aRv);
   bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
 #ifdef MOZ_B2G_RIL
   network::MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
   CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -149,17 +149,16 @@
 #include "mozilla/dom/HTMLCollectionBinding.h"
 
 #include "nsIDOMMobileMessageManager.h"
 #include "nsIDOMMozSmsMessage.h"
 #include "nsIDOMMozMmsMessage.h"
 #include "nsIDOMSmsFilter.h"
 #include "nsIDOMSmsSegmentInfo.h"
 #include "nsIDOMMozMobileMessageThread.h"
-#include "nsIDOMConnection.h"
 
 #ifdef MOZ_B2G_RIL
 #include "nsIDOMIccManager.h"
 #include "nsIDOMMobileConnection.h"
 #endif // MOZ_B2G_RIL
 
 #ifdef MOZ_B2G_FM
 #include "FMRadio.h"
@@ -448,19 +447,16 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsSegmentInfo, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozMobileMessageThread, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
-  NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
 #ifdef MOZ_B2G_RIL
   NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
@@ -1142,21 +1138,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(MozSmsSegmentInfo, nsIDOMMozSmsSegmentInfo)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsSegmentInfo)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageThread, nsIDOMMozMobileMessageThread)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageThread)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
-     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
-     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
-  DOM_CLASSINFO_MAP_END
-
 #ifdef MOZ_B2G_RIL
   DOM_CLASSINFO_MAP_BEGIN(MozMobileConnection, nsIDOMMozMobileConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 #endif // MOZ_B2G_RIL
 
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -79,17 +79,16 @@ DOMCI_CLASS(ModalContentWindow)
 
 DOMCI_CLASS(MozMobileMessageManager)
 DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozMmsMessage)
 DOMCI_CLASS(MozSmsFilter)
 DOMCI_CLASS(MozSmsSegmentInfo)
 DOMCI_CLASS(MozMobileMessageThread)
 
-DOMCI_CLASS(MozConnection)
 #ifdef MOZ_B2G_RIL
 DOMCI_CLASS(MozMobileConnection)
 #endif
 
 // @font-face in CSS
 DOMCI_CLASS(CSSFontFaceRule)
 
 DOMCI_CLASS(DataTransfer)
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -795,16 +795,20 @@ DOMInterfaces = {
 {
     'workers': True,
 }],
 
 'MozCellBroadcast': {
     'nativeType': 'mozilla::dom::CellBroadcast',
 },
 
+'MozConnection': {
+    'nativeType': 'mozilla::dom::network::Connection',
+},
+
 'MozIcc': {
     'nativeType': 'mozilla::dom::Icc',
 },
 
 'MozMobileConnectionArray': {
     'nativeType': 'mozilla::dom::network::MobileConnectionArray',
     'resultNotAddRefed': [ 'item' ]
 },
@@ -1877,17 +1881,16 @@ addExternalIface('DOMStringList')
 addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
-addExternalIface('MozConnection', headerFile='nsIDOMConnection.h')
 addExternalIface('MozControllers', nativeType='nsIControllers')
 addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
 addExternalIface('MozFrameRequestCallback', nativeType='nsIFrameRequestCallback',
                  notflattened=True)
 addExternalIface('MozIccInfo', headerFile='nsIDOMIccInfo.h')
 addExternalIface('MozIccManager', headerFile='nsIDOMIccManager.h')
 addExternalIface('MozMobileConnection', headerFile='nsIDOMMobileConnection.h')
 addExternalIface('MozMobileMessageManager', headerFile='nsIDOMMobileMessageManager.h')
--- a/dom/network/interfaces/moz.build
+++ b/dom/network/interfaces/moz.build
@@ -1,16 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 XPIDL_SOURCES += [
-    'nsIDOMConnection.idl',
     'nsIDOMTCPServerSocket.idl',
     'nsIDOMTCPSocket.idl',
     'nsIMozNavigatorNetwork.idl',
     'nsITCPServerSocketChild.idl',
     'nsITCPServerSocketParent.idl',
     'nsITCPSocketChild.idl',
     'nsITCPSocketParent.idl',
     'nsIUDPSocketChild.idl',
deleted file mode 100644
--- a/dom/network/interfaces/nsIDOMConnection.idl
+++ /dev/null
@@ -1,16 +0,0 @@
-/* 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/. */
-
-#include "nsISupports.idl"
-
-interface nsIDOMEventListener;
-
-[scriptable, uuid(a0eb16f3-5fa2-4cbd-bf7a-4ce7704b13ea)]
-interface nsIDOMMozConnection : nsISupports
-{
-  readonly attribute double  bandwidth;
-  readonly attribute boolean metered;
-
-  [implicit_jscontext] attribute jsval onchange;
-};
--- a/dom/network/interfaces/nsIMozNavigatorNetwork.idl
+++ b/dom/network/interfaces/nsIMozNavigatorNetwork.idl
@@ -1,13 +1,12 @@
 /* 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/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMMozConnection;
-
 [uuid(7f021f5d-f704-4a29-b166-829595169aaf)]
 interface nsIMozNavigatorNetwork : nsISupports
 {
-  readonly attribute nsIDOMMozConnection mozConnection;
+  // This is a MozConnection
+  readonly attribute nsISupports mozConnection;
 };
--- a/dom/network/src/Connection.cpp
+++ b/dom/network/src/Connection.cpp
@@ -1,55 +1,50 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include <limits>
 #include "mozilla/Hal.h"
-#include "Connection.h"
+#include "mozilla/dom/network/Connection.h"
+#include "mozilla/dom/MozConnectionBinding.h"
 #include "nsIDOMClassInfo.h"
 #include "mozilla/Preferences.h"
 #include "nsDOMEvent.h"
 #include "Constants.h"
 
 /**
  * We have to use macros here because our leak analysis tool things we are
  * leaking strings when we have |static const nsString|. Sad :(
  */
 #define CHANGE_EVENT_NAME NS_LITERAL_STRING("change")
 
-DOMCI_DATA(MozConnection, mozilla::dom::network::Connection)
-
 namespace mozilla {
 namespace dom {
 namespace network {
 
 const char* Connection::sMeteredPrefName     = "dom.network.metered";
 const bool  Connection::sMeteredDefaultValue = false;
 
-NS_INTERFACE_MAP_BEGIN(Connection)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMozConnection)
-  NS_INTERFACE_MAP_ENTRY(nsINetworkProperties)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozConnection)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
+NS_IMPL_QUERY_INTERFACE_INHERITED1(Connection, nsDOMEventTargetHelper,
+                                   nsINetworkProperties)
 
 // Don't use |Connection| alone, since that confuses nsTraceRefcnt since
 // we're not the only class with that name.
 NS_IMPL_ADDREF_INHERITED(dom::network::Connection, nsDOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(dom::network::Connection, nsDOMEventTargetHelper)
 
-NS_IMPL_EVENT_HANDLER(Connection, change)
-
 Connection::Connection()
   : mCanBeMetered(kDefaultCanBeMetered)
   , mBandwidth(kDefaultBandwidth)
   , mIsWifi(kDefaultIsWifi)
   , mDHCPGateway(kDefaultDHCPGateway)
 {
+  SetIsDOMBinding();
 }
 
 void
 Connection::Init(nsPIDOMWindow* aWindow)
 {
   BindToOwner(aWindow);
 
   hal::RegisterNetworkObserver(this);
@@ -61,39 +56,34 @@ Connection::Init(nsPIDOMWindow* aWindow)
 }
 
 void
 Connection::Shutdown()
 {
   hal::UnregisterNetworkObserver(this);
 }
 
-NS_IMETHODIMP
-Connection::GetBandwidth(double* aBandwidth)
+double
+Connection::Bandwidth() const
 {
   if (mBandwidth == kDefaultBandwidth) {
-    *aBandwidth = std::numeric_limits<double>::infinity();
-    return NS_OK;
+    return std::numeric_limits<double>::infinity();
   }
 
-  *aBandwidth = mBandwidth;
-  return NS_OK;
+  return mBandwidth;
 }
 
-NS_IMETHODIMP
-Connection::GetMetered(bool* aMetered)
+bool
+Connection::Metered() const
 {
   if (!mCanBeMetered) {
-    *aMetered = false;
-    return NS_OK;
+    return false;
   }
 
-  *aMetered = Preferences::GetBool(sMeteredPrefName,
-                                   sMeteredDefaultValue);
-  return NS_OK;
+  return Preferences::GetBool(sMeteredPrefName, sMeteredDefaultValue);
 }
 
 NS_IMETHODIMP
 Connection::GetIsWifi(bool *aIsWifi)
 {
   *aIsWifi = mIsWifi;
   return NS_OK;
 }
@@ -125,12 +115,17 @@ Connection::Notify(const hal::NetworkInf
   if (previousBandwidth == mBandwidth &&
       previousCanBeMetered == mCanBeMetered) {
     return;
   }
 
   DispatchTrustedEvent(CHANGE_EVENT_NAME);
 }
 
+JSObject*
+Connection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+{
+  return MozConnectionBinding::Wrap(aCx, aScope, this);
+}
+
 } // namespace network
 } // namespace dom
 } // namespace mozilla
-
--- a/dom/network/src/Connection.h
+++ b/dom/network/src/Connection.h
@@ -1,52 +1,60 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #ifndef mozilla_dom_network_Connection_h
 #define mozilla_dom_network_Connection_h
 
-#include "nsIDOMConnection.h"
 #include "nsINetworkProperties.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Observer.h"
 #include "Types.h"
 
 namespace mozilla {
 
 namespace hal {
 class NetworkInformation;
 } // namespace hal
 
 namespace dom {
 namespace network {
 
-class Connection : public nsDOMEventTargetHelper
-                 , public nsIDOMMozConnection
-                 , public NetworkObserver
-                 , public nsINetworkProperties
+class Connection MOZ_FINAL : public nsDOMEventTargetHelper
+                           , public NetworkObserver
+                           , public nsINetworkProperties
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMMOZCONNECTION
   NS_DECL_NSINETWORKPROPERTIES
 
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
 
   Connection();
 
   void Init(nsPIDOMWindow *aWindow);
   void Shutdown();
 
   // For IObserver
   void Notify(const hal::NetworkInformation& aNetworkInfo);
 
+  // WebIDL
+
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
+
+  double Bandwidth() const;
+
+  bool Metered() const;
+
+  IMPL_EVENT_HANDLER(change)
+
 private:
   /**
    * Update the connection information stored in the object using a
    * NetworkInformation object.
    */
   void UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo);
 
   /**
--- a/dom/network/src/moz.build
+++ b/dom/network/src/moz.build
@@ -1,15 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 EXPORTS.mozilla.dom.network += [
+    'Connection.h',
     'Constants.h',
     'TCPServerSocketChild.h',
     'TCPServerSocketParent.h',
     'TCPSocketChild.h',
     'TCPSocketParent.h',
     'Types.h',
     'UDPSocketChild.h',
     'UDPSocketParent.h',
--- a/dom/network/tests/test_network_basics.html
+++ b/dom/network/tests/test_network_basics.html
@@ -14,33 +14,40 @@
 
 /** Test for Network API **/
 
 function checkInterface(aInterface) {
   ok(!(aInterface in window), aInterface + " should be prefixed");
   ok(("Moz" + aInterface) in window, aInterface + " should be prefixed");
 }
 
-ok('mozConnection' in navigator, "navigator.mozConnection should exist");
+function test() {
+  ok('mozConnection' in navigator, "navigator.mozConnection should exist");
 
-ok(navigator.mozConnection, "navigator.mozConnection returns an object");
+  ok(navigator.mozConnection, "navigator.mozConnection returns an object");
 
-ok(navigator.mozConnection instanceof MozConnection,
-   "navigator.mozConnection is a MozConnection object");
-ok(navigator.mozConnection instanceof EventTarget,
-   "navigator.mozConnection is a EventTarget object");
+  ok(navigator.mozConnection instanceof MozConnection,
+     "navigator.mozConnection is a MozConnection object");
+  ok(navigator.mozConnection instanceof EventTarget,
+     "navigator.mozConnection is a EventTarget object");
+
+  checkInterface("Connection");
 
-checkInterface("Connection");
+  ok('bandwidth' in navigator.mozConnection,
+     "bandwidth should be a Connection attribute");
+  is(navigator.mozConnection.bandwidth, Infinity,
+     "By default connection.bandwidth is equals to Infinity");
 
-ok('bandwidth' in navigator.mozConnection,
-   "bandwidth should be a Connection attribute");
-is(navigator.mozConnection.bandwidth, Infinity,
-   "By default connection.bandwidth is equals to Infinity");
+  ok('metered' in navigator.mozConnection,
+     "metered should be a Connection attribute");
+  is(navigator.mozConnection.metered, false,
+     "By default the connection is not metered");
 
-ok('metered' in navigator.mozConnection,
-   "metered should be a Connection attribute");
-is(navigator.mozConnection.metered, false,
-   "By default the connection is not metered");
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({'set': [["dom.network.enabled", true]]}, test);
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -614,17 +614,17 @@ var interfaceNamesInGlobalScope =
     {name: "MozActivity", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozApplicationEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozCellBroadcast", b2g: true, pref: "dom.cellbroadcast.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozCellBroadcastEvent", b2g: true, pref: "dom.cellbroadcast.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    "MozConnection",
+    {name: "MozConnection", pref: "dom.network.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "mozContact",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozContactChangeEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozCSSKeyframeRule",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "MozCSSKeyframesRule",
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozConnection.webidl
@@ -0,0 +1,13 @@
+/* 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/.
+ */
+
+[Pref="dom.network.enabled"]
+interface MozConnection : EventTarget {
+  readonly attribute unrestricted double bandwidth;
+  readonly attribute boolean metered;
+
+  attribute EventHandler onchange;
+};
+
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -224,17 +224,16 @@ partial interface Navigator {
 // nsIDOMMozNavigatorMobileMessage
 interface MozMobileMessageManager;
 partial interface Navigator {
   [Func="Navigator::HasMobileMessageSupport"]
   readonly attribute MozMobileMessageManager? mozMobileMessage;
 };
 
 // nsIDOMMozNavigatorNetwork
-interface MozConnection;
 partial interface Navigator {
   [Pref="dom.network.enabled"]
   readonly attribute MozConnection? mozConnection;
 };
 
 // nsIDOMNavigatorCamera
 partial interface Navigator {
   [Throws, Func="Navigator::HasCameraSupport"]
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -224,16 +224,17 @@ WEBIDL_FILES = [
     'MessagePort.webidl',
     'MessagePortList.webidl',
     'MimeType.webidl',
     'MimeTypeArray.webidl',
     'MobileMessageManager.webidl',
     'MouseEvent.webidl',
     'MouseScrollEvent.webidl',
     'MozActivity.webidl',
+    'MozConnection.webidl',
     'MozMmsMessage.webidl',
     'MozNamedAttrMap.webidl',
     'MozPowerManager.webidl',
     'MozTimeManager.webidl',
     'MozWakeLock.webidl',
     'MutationEvent.webidl',
     'MutationObserver.webidl',
     'NetDashboard.webidl',
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -7,17 +7,16 @@
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include "nsHttp.h"
 #include "nsHttpHandler.h"
 #include "nsHttpChannel.h"
 #include "nsHttpAuthCache.h"
 #include "nsStandardURL.h"
-#include "nsIDOMConnection.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMNavigator.h"
 #include "nsIMozNavigatorNetwork.h"
 #include "nsINetworkProperties.h"
 #include "nsIHttpChannel.h"
 #include "nsIStandardURL.h"
 #include "LoadContextInfo.h"
 #include "nsCategoryManagerUtils.h"
@@ -2047,17 +2046,17 @@ nsHttpHandler::GetNetworkInfoInner(nsIIn
 
     nsCOMPtr<nsIDOMNavigator> domNavigator;
     domWindow->GetNavigator(getter_AddRefs(domNavigator));
     nsCOMPtr<nsIMozNavigatorNetwork> networkNavigator =
         do_QueryInterface(domNavigator);
     if (!networkNavigator)
         return NS_ERROR_FAILURE;
 
-    nsCOMPtr<nsIDOMMozConnection> mozConnection;
+    nsCOMPtr<nsISupports> mozConnection;
     networkNavigator->GetMozConnection(getter_AddRefs(mozConnection));
     nsCOMPtr<nsINetworkProperties> networkProperties =
         do_QueryInterface(mozConnection);
     if (!networkProperties)
         return NS_ERROR_FAILURE;
 
     nsresult rv;
     rv = networkProperties->GetDhcpGateway(aGateway);
@@ -2100,17 +2099,17 @@ nsHttpHandler::GetNetworkEthernetInfoInn
 
     nsCOMPtr<nsIDOMNavigator> domNavigator;
     domWindow->GetNavigator(getter_AddRefs(domNavigator));
     nsCOMPtr<nsIMozNavigatorNetwork> networkNavigator =
         do_QueryInterface(domNavigator);
     if (!networkNavigator)
         return NS_ERROR_FAILURE;
 
-    nsCOMPtr<nsIDOMMozConnection> mozConnection;
+    nsCOMPtr<nsISupports> mozConnection;
     networkNavigator->GetMozConnection(getter_AddRefs(mozConnection));
     nsCOMPtr<nsINetworkProperties> networkProperties =
         do_QueryInterface(mozConnection);
     if (!networkProperties)
         return NS_ERROR_FAILURE;
 
     return networkProperties->GetIsWifi(aEthernet);
 #endif