Bug 888595: Convert BluetoothManager bindings to WebIDL, r=bzbarsky,echou
☠☠ backed out by 26fc51548503 ☠ ☠
authorThomas Zimmermann <tdz@users.sourceforge.net>
Mon, 12 Aug 2013 10:31:58 +0200
changeset 142308 3e6be7551207a0bd4c515c60e6e21621e4984853
parent 142307 7478498667992129889e8e2abbef8a638bb96496
child 142309 4ce3e048289cb3640577e5d43841ef8b2270c61d
push id32372
push userryanvm@gmail.com
push dateTue, 13 Aug 2013 01:59:20 +0000
treeherdermozilla-inbound@86b6480829c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky, echou
bugs888595
milestone26.0a1
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
Bug 888595: Convert BluetoothManager bindings to WebIDL, r=bzbarsky,echou This patch converts the BluetoothManager to WebIDL and removes the old XPIDL bindings. The only user of BluetoothManager is the class Navigator, which has been adapted to the change.
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/bindings/Bindings.conf
dom/bluetooth/BluetoothManager.cpp
dom/bluetooth/BluetoothManager.h
dom/bluetooth/moz.build
dom/bluetooth/nsIDOMBluetoothManager.idl
dom/webidl/BluetoothManager.webidl
dom/webidl/Navigator.webidl
dom/webidl/WebIDL.mk
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -54,17 +54,16 @@
 
 #ifdef MOZ_MEDIA_NAVIGATOR
 #include "MediaManager.h"
 #endif
 #ifdef MOZ_B2G_RIL
 #include "Telephony.h"
 #endif
 #ifdef MOZ_B2G_BT
-#include "nsIDOMBluetoothManager.h"
 #include "BluetoothManager.h"
 #endif
 #include "nsIDOMCameraManager.h"
 #include "DOMCameraManager.h"
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
 #include "AudioChannelManager.h"
 #endif
@@ -1244,17 +1243,17 @@ Navigator::GetMozMobileConnection(ErrorR
     mMobileConnection->Init(mWindow);
   }
 
   return mMobileConnection;
 }
 #endif // MOZ_B2G_RIL
 
 #ifdef MOZ_B2G_BT
-nsIDOMBluetoothManager*
+bluetooth::BluetoothManager*
 Navigator::GetMozBluetooth(ErrorResult& aRv)
 {
   if (!mBluetooth) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
     mBluetooth = bluetooth::BluetoothManager::Create(mWindow);
@@ -1271,17 +1270,17 @@ Navigator::EnsureMessagesManager()
     return NS_OK;
   }
 
   NS_ENSURE_STATE(mWindow);
 
   nsresult rv;
   nsCOMPtr<nsIDOMNavigatorSystemMessages> messageManager =
     do_CreateInstance("@mozilla.org/system-message-manager;1", &rv);
-  
+
   nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi =
     do_QueryInterface(messageManager);
   NS_ENSURE_TRUE(gpi, NS_ERROR_FAILURE);
 
   // We don't do anything with the return value.
   AutoJSContext cx;
   JS::Rooted<JS::Value> prop_val(cx);
   rv = gpi->Init(mWindow, prop_val.address());
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -34,20 +34,16 @@ class systemMessageCallback;
 
 #ifdef MOZ_B2G_RIL
 class nsIDOMMozMobileConnection;
 class nsIDOMMozCellBroadcast;
 class nsIDOMMozVoicemail;
 class nsIDOMMozIccManager;
 #endif // MOZ_B2G_RIL
 
-#ifdef MOZ_B2G_BT
-class nsIDOMBluetoothManager;
-#endif // MOZ_B2G_BT
-
 #include "nsIDOMNavigatorSystemMessages.h"
 
 #include "DOMCameraManager.h"
 
 //*****************************************************************************
 // Navigator: Script "navigator" object
 //*****************************************************************************
 
@@ -86,16 +82,22 @@ class MobileConnection;
 } // namespace Connection;
 
 #ifdef MOZ_B2G_RIL
 namespace telephony {
 class Telephony;
 } // namespace Telephony;
 #endif
 
+#ifdef MOZ_B2G_BT
+namespace bluetooth {
+class BluetoothManager;
+} // namespace bluetooth
+#endif // MOZ_B2G_BT
+
 namespace power {
 class PowerManager;
 } // namespace power
 
 namespace time {
 class TimeManager;
 } // namespace time
 
@@ -224,17 +226,17 @@ public:
   nsIDOMMozCellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
   nsIDOMMozVoicemail* GetMozVoicemail(ErrorResult& aRv);
   nsIDOMMozIccManager* GetMozIccManager(ErrorResult& aRv);
 #endif // MOZ_B2G_RIL
 #ifdef MOZ_GAMEPAD
   void GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
 #endif // MOZ_GAMEPAD
 #ifdef MOZ_B2G_BT
-  nsIDOMBluetoothManager* GetMozBluetooth(ErrorResult& aRv);
+  bluetooth::BluetoothManager* GetMozBluetooth(ErrorResult& aRv);
 #endif // MOZ_B2G_BT
 #ifdef MOZ_TIME_MANAGER
   time::TimeManager* GetMozTime(ErrorResult& aRv);
 #endif // MOZ_TIME_MANAGER
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   system::AudioChannelManager* GetMozAudioChannelManager(ErrorResult& aRv);
 #endif // MOZ_AUDIO_CHANNEL_MANAGER
 #ifdef MOZ_MEDIA_NAVIGATOR
@@ -319,17 +321,17 @@ private:
 #endif
   nsRefPtr<network::Connection> mConnection;
 #ifdef MOZ_B2G_RIL
   nsRefPtr<network::MobileConnection> mMobileConnection;
   nsCOMPtr<nsIDOMMozCellBroadcast> mCellBroadcast;
   nsRefPtr<icc::IccManager> mIccManager;
 #endif
 #ifdef MOZ_B2G_BT
-  nsCOMPtr<nsIDOMBluetoothManager> mBluetooth;
+  nsCOMPtr<bluetooth::BluetoothManager> mBluetooth;
 #endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   nsRefPtr<system::AudioChannelManager> mAudioChannelManager;
 #endif
   nsRefPtr<nsDOMCameraManager> mCameraManager;
   nsCOMPtr<nsIDOMNavigatorSystemMessages> mMessagesManager;
   nsTArray<nsRefPtr<nsDOMDeviceStorage> > mDeviceStorageStores;
   nsRefPtr<time::TimeManager> mTimeManager;
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -231,17 +231,16 @@ using mozilla::dom::workers::ResolveWork
 #include "nsIDOMMobileConnection.h"
 #endif // MOZ_B2G_RIL
 
 #ifdef MOZ_B2G_FM
 #include "FMRadio.h"
 #endif
 
 #ifdef MOZ_B2G_BT
-#include "BluetoothManager.h"
 #include "BluetoothAdapter.h"
 #include "BluetoothDevice.h"
 #endif
 
 #include "DOMCameraManager.h"
 #include "DOMCameraControl.h"
 #include "DOMCameraCapabilities.h"
 #include "nsIOpenWindowEventDetail.h"
@@ -634,18 +633,16 @@ static nsDOMClassInfoData sClassInfoData
 #endif
 
 #ifdef MOZ_B2G_FM
   NS_DEFINE_CLASSINFO_DATA(FMRadio, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
 #endif
 
 #ifdef MOZ_B2G_BT
-  NS_DEFINE_CLASSINFO_DATA(BluetoothManager, nsEventTargetSH,
-                           EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(BluetoothDevice, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
 #endif
 
   NS_DEFINE_CLASSINFO_DATA(CameraControl, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1532,20 +1529,16 @@ nsDOMClassInfo::Init()
 #ifdef MOZ_B2G_FM
   DOM_CLASSINFO_MAP_BEGIN(FMRadio, nsIFMRadio)
     DOM_CLASSINFO_MAP_ENTRY(nsIFMRadio)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 #endif
 
 #ifdef MOZ_B2G_BT
-  DOM_CLASSINFO_MAP_BEGIN(BluetoothManager, nsIDOMBluetoothManager)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothManager)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(BluetoothAdapter, nsIDOMBluetoothAdapter)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothAdapter)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(BluetoothDevice, nsIDOMBluetoothDevice)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothDevice)
   DOM_CLASSINFO_MAP_END
 #endif
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -132,17 +132,16 @@ DOMCI_CLASS(MozVoicemail)
 DOMCI_CLASS(MozIccManager)
 #endif
 
 #ifdef MOZ_B2G_FM
 DOMCI_CLASS(FMRadio)
 #endif
 
 #ifdef MOZ_B2G_BT
-DOMCI_CLASS(BluetoothManager)
 DOMCI_CLASS(BluetoothAdapter)
 DOMCI_CLASS(BluetoothDevice)
 #endif
 
 DOMCI_CLASS(CameraControl)
 DOMCI_CLASS(CameraCapabilities)
 
 DOMCI_CLASS(OpenWindowEventDetail)
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -145,16 +145,21 @@ DOMInterfaces = {
     'workers': True,
 }],
 
 'BatteryManager': {
     'nativeType': 'mozilla::dom::battery::BatteryManager',
     'headerFile': 'BatteryManager.h'
 },
 
+'BluetoothManager': {
+    'nativeType': 'mozilla::dom::bluetooth::BluetoothManager',
+    'headerFile': 'BluetoothManager.h'
+},
+
 'CallEvent': {
     'nativeType': 'mozilla::dom::telephony::CallEvent',
     'headerFile': 'CallEvent.h',
 },
 
 'CallsList': {
     'nativeType': 'mozilla::dom::telephony::CallsList',
     'headerFile': 'CallsList.h',
@@ -1734,24 +1739,23 @@ addExternalIface('File')
 addExternalIface('FileCallback', nativeType='nsIFileCallback',
                  headerFile='nsIDOMHTMLCanvasElement.h')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
 addExternalIface('MediaList')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
-addExternalIface('MozBluetoothManager', nativeType='nsIDOMBluetoothManager')
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
 addExternalIface('MozCellBroadcast')
 addExternalIface('MozConnection', headerFile='nsIDOMConnection.h')
 addExternalIface('MozControllers', nativeType='nsIControllers')
 addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
 addExternalIface('MozIccManager', headerFile='nsIDOMIccManager.h')
-addExternalIface('MozMediaStreamOptions', nativeType='nsIMediaStreamOptions',	
+addExternalIface('MozMediaStreamOptions', nativeType='nsIMediaStreamOptions',
                  headerFile='nsIDOMNavigatorUserMedia.h')
 addExternalIface('MozMobileConnection', headerFile='nsIDOMMobileConnection.h')
 addExternalIface('MozMobileMessageManager', headerFile='nsIDOMMobileMessageManager.h')
 addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
 addExternalIface('MozPowerManager', headerFile='nsIDOMPowerManager.h')
 addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
                  notflattened=True)
 addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
--- a/dom/bluetooth/BluetoothManager.cpp
+++ b/dom/bluetooth/BluetoothManager.cpp
@@ -13,26 +13,24 @@
 
 #include "DOMRequest.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsIPermissionManager.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Util.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
+#include "mozilla/dom/BluetoothManagerBinding.h"
 
 using namespace mozilla;
 
 USING_BLUETOOTH_NAMESPACE
 
-DOMCI_DATA(BluetoothManager, BluetoothManager)
-
-NS_INTERFACE_MAP_BEGIN(BluetoothManager)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothManager)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothManager)
+// QueryInterface implementation for BluetoothManager
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothManager)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
 
 NS_IMPL_ADDREF_INHERITED(BluetoothManager, nsDOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(BluetoothManager, nsDOMEventTargetHelper)
 
 class GetAdapterTask : public BluetoothReplyRunnable
 {
 public:
@@ -88,19 +86,21 @@ public:
     mManagerPtr = nullptr;
   }
 
 private:
   nsRefPtr<BluetoothManager> mManagerPtr;
 };
 
 BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow)
-  : BluetoothPropertyContainer(BluetoothObjectType::TYPE_MANAGER)
+  : nsDOMEventTargetHelper(aWindow)
+  , BluetoothPropertyContainer(BluetoothObjectType::TYPE_MANAGER)
 {
   MOZ_ASSERT(aWindow);
+  MOZ_ASSERT(IsDOMBinding());
 
   BindToOwner(aWindow);
   mPath.AssignLiteral("/");
 
   BluetoothService* bs = BluetoothService::Get();
   NS_ENSURE_TRUE_VOID(bs);
   bs->RegisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_MANAGER), this);
 }
@@ -119,47 +119,54 @@ BluetoothManager::SetPropertyByValue(con
     const nsString& name = aValue.name();
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling manager property: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(name));
     NS_WARNING(warningMsg.get());
 #endif
 }
 
-NS_IMETHODIMP
-BluetoothManager::GetEnabled(bool* aEnabled)
+bool
+BluetoothManager::GetEnabled(ErrorResult& aRv)
 {
   BluetoothService* bs = BluetoothService::Get();
-  NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
+  if (!bs) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return false;
+  }
 
-  *aEnabled = bs->IsEnabled();
-  return NS_OK;
+  return bs->IsEnabled();
 }
 
-NS_IMETHODIMP
-BluetoothManager::GetDefaultAdapter(nsIDOMDOMRequest** aAdapter)
+already_AddRefed<dom::DOMRequest>
+BluetoothManager::GetDefaultAdapter(ErrorResult& aRv)
 {
-  nsCOMPtr<nsIDOMRequestService> rs =
-    do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
+  nsCOMPtr<nsPIDOMWindow> win = GetOwner();
+  if (!win) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
-  nsCOMPtr<nsIDOMDOMRequest> request;
-  nsresult rv = rs->CreateRequest(GetOwner(), getter_AddRefs(request));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsRefPtr<BluetoothReplyRunnable> results = new GetAdapterTask(this, request);
+  nsRefPtr<DOMRequest> request = new DOMRequest(win);
+  nsRefPtr<BluetoothReplyRunnable> results =
+    new GetAdapterTask(this, request);
 
   BluetoothService* bs = BluetoothService::Get();
-  NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
-  if (NS_FAILED(bs->GetDefaultAdapterPathInternal(results))) {
-    return NS_ERROR_FAILURE;
+  if (!bs) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
   }
 
-  request.forget(aAdapter);
-  return NS_OK;
+  nsresult rv = bs->GetDefaultAdapterPathInternal(results);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
+
+  return request.forget();
 }
 
 // static
 already_AddRefed<BluetoothManager>
 BluetoothManager::Create(nsPIDOMWindow* aWindow)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aWindow);
@@ -203,24 +210,25 @@ BluetoothManager::Notify(const Bluetooth
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling manager signal: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
     NS_WARNING(warningMsg.get());
 #endif
   }
 }
 
-NS_IMETHODIMP
-BluetoothManager::IsConnected(uint16_t aProfileId, bool* aConnected)
+bool
+BluetoothManager::IsConnected(uint16_t aProfileId, ErrorResult& aRv)
 {
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
-    NS_WARNING("BluetoothService not available!");
-    return NS_ERROR_FAILURE;
+    aRv.Throw(NS_ERROR_FAILURE);
+    return false;
   }
 
-  *aConnected = bs->IsConnected(aProfileId);
-  return NS_OK;
+  return bs->IsConnected(aProfileId);
 }
-NS_IMPL_EVENT_HANDLER(BluetoothManager, enabled)
-NS_IMPL_EVENT_HANDLER(BluetoothManager, disabled)
-NS_IMPL_EVENT_HANDLER(BluetoothManager, adapteradded)
 
+JSObject*
+BluetoothManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+{
+  return BluetoothManagerBinding::Wrap(aCx, aScope, this);
+}
--- a/dom/bluetooth/BluetoothManager.h
+++ b/dom/bluetooth/BluetoothManager.h
@@ -6,40 +6,60 @@
 
 #ifndef mozilla_dom_bluetooth_bluetoothmanager_h__
 #define mozilla_dom_bluetooth_bluetoothmanager_h__
 
 #include "mozilla/Attributes.h"
 #include "BluetoothCommon.h"
 #include "BluetoothPropertyContainer.h"
 #include "nsDOMEventTargetHelper.h"
-#include "nsIDOMBluetoothManager.h"
 #include "mozilla/Observer.h"
+#include "nsISupportsImpl.h"
+
+namespace mozilla {
+namespace dom {
+class DOMRequest;
+}
+}
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothNamedValue;
 
 class BluetoothManager : public nsDOMEventTargetHelper
-                       , public nsIDOMBluetoothManager
                        , public BluetoothSignalObserver
                        , public BluetoothPropertyContainer
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMBLUETOOTHMANAGER
-
-  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
 
   // Never returns null
   static already_AddRefed<BluetoothManager>
     Create(nsPIDOMWindow* aWindow);
   static bool CheckPermission(nsPIDOMWindow* aWindow);
   void Notify(const BluetoothSignal& aData);
   virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
+
+  bool GetEnabled(ErrorResult& aRv);
+  bool IsConnected(uint16_t aProfileId, ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest> GetDefaultAdapter(ErrorResult& aRv);
+
+  IMPL_EVENT_HANDLER(enabled);
+  IMPL_EVENT_HANDLER(disabled);
+  IMPL_EVENT_HANDLER(adapteradded);
+
+  nsPIDOMWindow* GetParentObject() const
+  {
+     return GetOwner();
+  }
+
+  virtual JSObject*
+    WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
+
 private:
   BluetoothManager(nsPIDOMWindow* aWindow);
   ~BluetoothManager();
 };
 
 END_BLUETOOTH_NAMESPACE
 
 #endif
--- a/dom/bluetooth/moz.build
+++ b/dom/bluetooth/moz.build
@@ -16,17 +16,16 @@
 
 if CONFIG['MOZ_B2G_BT']:
     MODULE = 'dom'
     XPIDL_MODULE = 'dom_bluetooth'
     XPIDL_SOURCES += [
         'nsIDOMBluetoothAdapter.idl',
         'nsIDOMBluetoothDevice.idl',
         'nsIDOMBluetoothDeviceEvent.idl',
-        'nsIDOMBluetoothManager.idl',
         'nsIDOMBluetoothStatusChangedEvent.idl',
     ]
 
     CPP_SOURCES += [
         'BluetoothService.cpp',
         'BluetoothManager.cpp',
         'BluetoothAdapter.cpp',
         'BluetoothDevice.cpp',
deleted file mode 100644
--- a/dom/bluetooth/nsIDOMBluetoothManager.idl
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 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/. */
-
-#include "nsIDOMEventTarget.idl"
-
-interface nsIDOMDOMRequest;
-interface nsIDOMBluetoothAdapter;
-
-[scriptable, builtinclass, uuid(303a262a-1dd1-486d-a108-d8c582e86765)]
-interface nsIDOMBluetoothManager : nsIDOMEventTarget
-{
-  readonly attribute bool enabled;
-
-  nsIDOMDOMRequest getDefaultAdapter();
-
-  bool isConnected(in unsigned short aProfile);
-
-  [implicit_jscontext] attribute jsval onenabled;
-  [implicit_jscontext] attribute jsval ondisabled;
-  [implicit_jscontext] attribute jsval onadapteradded;
-};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/BluetoothManager.webidl
@@ -0,0 +1,21 @@
+/* -*- Mode: IDL; 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/. */
+
+interface BluetoothManager : EventTarget {
+  [Throws]
+  readonly attribute boolean      enabled;
+
+  [SetterThrows]
+           attribute EventHandler onenabled;
+  [SetterThrows]
+           attribute EventHandler ondisabled;
+  [SetterThrows]
+           attribute EventHandler onadapteradded;
+
+  [Throws]
+  boolean     isConnected(unsigned short aProfile);
+  [Creator, Throws]
+  DOMRequest? getDefaultAdapter();
+};
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -290,21 +290,19 @@ partial interface Navigator {
 // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
 partial interface Navigator {
   [Throws, Pref="dom.gamepad.enabled"]
   sequence<Gamepad?> getGamepads();
 };
 #endif // MOZ_GAMEPAD
 
 #ifdef MOZ_B2G_BT
-// nsIDOMNavigatorBluetooth
-interface MozBluetoothManager;
 partial interface Navigator {
   [Throws, Func="Navigator::HasBluetoothSupport"]
-  readonly attribute MozBluetoothManager mozBluetooth;
+  readonly attribute BluetoothManager mozBluetooth;
 };
 #endif // MOZ_B2G_BT
 
 #ifdef MOZ_TIME_MANAGER
 // nsIDOMMozNavigatorTime
 partial interface Navigator {
   [Throws, Func="Navigator::HasTimeSupport"]
   readonly attribute MozTimeManager mozTime;
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -471,16 +471,17 @@ webidl_files += \
   StyleSheetApplicableStateChangeEvent.webidl \
   StyleSheetChangeEvent.webidl \
   UserProximityEvent.webidl \
   $(NULL)
 
 ifdef MOZ_B2G_BT
 webidl_files += \
   BluetoothDeviceEvent.webidl \
+  BluetoothManager.webidl \
   BluetoothStatusChangedEvent.webidl \
   $(NULL)
 endif
 
 ifdef MOZ_B2G_RIL
 webidl_files += \
   CallEvent.webidl \
   CFStateChangeEvent.webidl \