Bug 911603 - Convert MozPowerManager to WebIDL r=Ms2ger
authorDavid Zbarsky <dzbarsky@gmail.com>
Tue, 10 Sep 2013 19:03:56 -0400
changeset 159369 3f5a70095b1db19032848449ae40e0d53051643a
parent 159368 6db45ff38334372feacb051363f45c1180da90e9
child 159370 708477a47e2595878192c142a0376999b0d5aa6a
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs911603
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 911603 - Convert MozPowerManager to WebIDL r=Ms2ger
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/bindings/Bindings.conf
dom/interfaces/base/domstubs.idl
dom/permission/tests/test_power.html
dom/power/PowerManager.cpp
dom/power/PowerManager.h
dom/power/moz.build
dom/power/nsIDOMPowerManager.idl
dom/webidl/MozPowerManager.webidl
dom/webidl/Navigator.webidl
dom/webidl/moz.build
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1095,17 +1095,17 @@ Navigator::GetBattery(ErrorResult& aRv)
 
     mBatteryManager = new battery::BatteryManager();
     mBatteryManager->Init(mWindow);
   }
 
   return mBatteryManager;
 }
 
-nsIDOMMozPowerManager*
+power::PowerManager*
 Navigator::GetMozPower(ErrorResult& aRv)
 {
   if (!mPowerManager) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
     mPowerManager = PowerManager::CreateInstance(mWindow);
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -194,17 +194,17 @@ public:
   // The XPCOM GetVendor is OK
   // The XPCOM GetVendorSub is OK
   // The XPCOM GetProductSub is OK
   bool CookieEnabled();
   void GetBuildID(nsString& aBuildID, ErrorResult& aRv)
   {
     aRv = GetBuildID(aBuildID);
   }
-  nsIDOMMozPowerManager* GetMozPower(ErrorResult& aRv);
+  power::PowerManager* GetMozPower(ErrorResult& aRv);
   bool JavaEnabled(ErrorResult& aRv);
   bool TaintEnabled()
   {
     return false;
   }
   void AddIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
   void RemoveIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
   already_AddRefed<nsIDOMMozWakeLock> RequestWakeLock(const nsAString &aTopic,
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -153,17 +153,16 @@
 #include "mozilla/dom/indexedDB/IDBKeyRange.h"
 #include "nsIDOMMediaQueryList.h"
 
 #include "nsDOMTouchEvent.h"
 
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/dom/HTMLCollectionBinding.h"
 
-#include "nsIDOMPowerManager.h"
 #include "nsIDOMWakeLock.h"
 #include "nsIDOMMobileMessageManager.h"
 #include "nsIDOMMozSmsMessage.h"
 #include "nsIDOMMozMmsMessage.h"
 #include "nsIDOMSmsFilter.h"
 #include "nsIDOMSmsSegmentInfo.h"
 #include "nsIDOMMozMobileMessageThread.h"
 #include "nsIDOMConnection.h"
@@ -459,19 +458,16 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
                            DEFAULT_SCRIPTABLE_FLAGS |
                            WINDOW_SCRIPTABLE_FLAGS)
 
-  NS_DEFINE_CLASSINFO_DATA(MozPowerManager, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
   NS_DEFINE_CLASSINFO_DATA(MozWakeLock, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozMobileMessageManager, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1275,20 +1271,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
     DOM_CLASSINFO_WINDOW_MAP_ENTRIES
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
 #ifdef MOZ_WEBSPEECH
     DOM_CLASSINFO_MAP_ENTRY(nsISpeechSynthesisGetter)
 #endif
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(MozPowerManager, nsIDOMMozPowerManager)
-     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozPowerManager)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(MozWakeLock, nsIDOMMozWakeLock)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozWakeLock)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageManager, nsIDOMMozMobileMessageManager)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageManager)
   DOM_CLASSINFO_MAP_END
 
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -83,17 +83,16 @@ DOMCI_CLASS(XPathResult)
 DOMCI_CLASS(Storage)
 
 DOMCI_CLASS(Blob)
 DOMCI_CLASS(File)
 
 // DOM modal content window class, almost identical to Window
 DOMCI_CLASS(ModalContentWindow)
 
-DOMCI_CLASS(MozPowerManager)
 DOMCI_CLASS(MozWakeLock)
 
 DOMCI_CLASS(MozMobileMessageManager)
 DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozMmsMessage)
 DOMCI_CLASS(MozSmsFilter)
 DOMCI_CLASS(MozSmsSegmentInfo)
 DOMCI_CLASS(MozMobileMessageThread)
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -771,25 +771,29 @@ DOMInterfaces = {
 'MozCellBroadcast': {
     'nativeType': 'mozilla::dom::CellBroadcast',
 },
 
 'MozNamedAttrMap': {
     'nativeType': 'nsDOMAttributeMap',
 },
 
-'MozTimeManager': {
-    'nativeType': 'mozilla::dom::time::TimeManager',
+'MozPowerManager': {
+    'nativeType': 'mozilla::dom::power::PowerManager',
 },
 
 'MozStkCommandEvent' : {
     'nativeType': 'mozilla::dom::icc::StkCommandEvent',
     'headerFile': 'StkCommandEvent.h',
 },
 
+'MozTimeManager': {
+    'nativeType': 'mozilla::dom::time::TimeManager',
+},
+
 'MozVoicemail': {
     'nativeType': 'mozilla::dom::Voicemail',
 },
 
 'MutationEvent': {
     'nativeType': 'nsDOMMutationEvent',
 },
 
@@ -1794,27 +1798,27 @@ addExternalIface('MozConnection', header
 addExternalIface('MozControllers', nativeType='nsIControllers')
 addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
 addExternalIface('MozIccManager', headerFile='nsIDOMIccManager.h')
 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)
 addExternalIface('MozTelephony', nativeType='nsIDOMTelephony')
 addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject',
                  notflattened=True)
 addExternalIface('MozTreeColumn', nativeType='nsITreeColumn',
                  headerFile='nsITreeColumns.h')
 addExternalIface('MozVoicemailStatus')
 addExternalIface('MozWakeLock', headerFile='nsIDOMWakeLock.h')
+addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
 addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder')
 addExternalIface('nsIControllers', nativeType='nsIControllers')
 addExternalIface('nsIInputStreamCallback', nativeType='nsIInputStreamCallback',
                  headerFile='nsIAsyncInputStream.h')
 addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
 addExternalIface('nsISupports', nativeType='nsISupports')
 addExternalIface('nsIEditor', nativeType='nsIEditor', notflattened=True)
 addExternalIface('nsIVariant', nativeType='nsIVariant', notflattened=True)
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -80,10 +80,9 @@ interface nsIDOMCRMFObject;
 interface nsIDOMCrypto;
 interface nsIDOMPkcs11;
 
 // Used font face (for inspector)
 interface nsIDOMFontFace;
 interface nsIDOMFontFaceList;
 
 // Power
-interface nsIDOMMozPowerManager;
 interface nsIDOMMozWakeLock;
--- a/dom/permission/tests/test_power.html
+++ b/dom/permission/tests/test_power.html
@@ -15,16 +15,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none"></div>
 <pre id="test">
 <script type="application/javascript;version=1.8" src="file_framework.js"></script>
 <script type="application/javascript;version=1.8">
 var gData = [
   {
     perm: ["power"],
     obj: "mozPower",
-    idl: "nsIDOMMozPowerManager",
+    webidl: "MozPowerManager",
   },
 ]
 </script>
 </pre>
 </body>
 </html>
 
--- a/dom/power/PowerManager.cpp
+++ b/dom/power/PowerManager.cpp
@@ -10,39 +10,43 @@
 #include "nsIDOMWakeLockListener.h"
 #include "nsIDocument.h"
 #include "nsIPermissionManager.h"
 #include "nsIPowerManagerService.h"
 #include "nsIPrincipal.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsError.h"
-
-DOMCI_DATA(MozPowerManager, mozilla::dom::power::PowerManager)
+#include "mozilla/dom/MozPowerManagerBinding.h"
 
 namespace mozilla {
 namespace dom {
 namespace power {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PowerManager)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMozPowerManager)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozPowerManager)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMozWakeLockListener)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozPowerManager)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION_1(PowerManager, mListeners)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(PowerManager, mListeners, mWindow)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(PowerManager)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(PowerManager)
 
+/* virtual */ JSObject*
+PowerManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+{
+  return MozPowerManagerBinding::Wrap(aCx, aScope, this);
+}
+
 nsresult
 PowerManager::Init(nsIDOMWindow *aWindow)
 {
-  mWindow = do_GetWeakReference(aWindow);
+  mWindow = aWindow;
 
   nsCOMPtr<nsIPowerManagerService> pmService =
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
   NS_ENSURE_STATE(pmService);
 
   // Add ourself to the global notification list.
   pmService->AddWakeLockListener(this);
   return NS_OK;
@@ -55,73 +59,72 @@ PowerManager::Shutdown()
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
   NS_ENSURE_STATE(pmService);
 
   // Remove ourself from the global notification list.
   pmService->RemoveWakeLockListener(this);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-PowerManager::Reboot()
+void
+PowerManager::Reboot(ErrorResult& aRv)
 {
   nsCOMPtr<nsIPowerManagerService> pmService =
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
-  NS_ENSURE_STATE(pmService);
-
-  pmService->Reboot();
-
-  return NS_OK;
+  if (pmService) {
+    pmService->Reboot();
+  } else {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+  }
 }
 
-NS_IMETHODIMP
+void
 PowerManager::FactoryReset()
 {
   hal::FactoryReset();
-  return NS_OK;
 }
 
-NS_IMETHODIMP
-PowerManager::PowerOff()
+void
+PowerManager::PowerOff(ErrorResult& aRv)
 {
   nsCOMPtr<nsIPowerManagerService> pmService =
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
-  NS_ENSURE_STATE(pmService);
-
-  pmService->PowerOff();
-
-  return NS_OK;
+  if (pmService) {
+    pmService->PowerOff();
+  } else {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+  }
 }
 
-NS_IMETHODIMP
+void
 PowerManager::AddWakeLockListener(nsIDOMMozWakeLockListener *aListener)
 {
-  // already added? bail out.
-  if (mListeners.Contains(aListener))
-    return NS_OK;
-
-  mListeners.AppendElement(aListener);
-  return NS_OK;
+  if (!mListeners.Contains(aListener)) {
+    mListeners.AppendElement(aListener);
+  }
 }
 
-NS_IMETHODIMP
+void
 PowerManager::RemoveWakeLockListener(nsIDOMMozWakeLockListener *aListener)
 {
   mListeners.RemoveElement(aListener);
-  return NS_OK;
 }
 
-NS_IMETHODIMP
-PowerManager::GetWakeLockState(const nsAString &aTopic, nsAString &aState)
+void
+PowerManager::GetWakeLockState(const nsAString& aTopic,
+                               nsAString& aState,
+                               ErrorResult& aRv)
 {
   nsCOMPtr<nsIPowerManagerService> pmService =
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
-  NS_ENSURE_STATE(pmService);
-
-  return pmService->GetWakeLockState(aTopic, aState);
+  if (pmService) {
+    aRv = pmService->GetWakeLockState(aTopic, aState);
+  } else {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+  }
 }
 
 NS_IMETHODIMP
 PowerManager::Callback(const nsAString &aTopic, const nsAString &aState)
 {
   /**
    * We maintain a local listener list instead of using the global
    * list so that when the window is destroyed we don't have to
@@ -133,57 +136,54 @@ PowerManager::Callback(const nsAString &
   nsAutoTArray<nsCOMPtr<nsIDOMMozWakeLockListener>, 2> listeners(mListeners);
   for (uint32_t i = 0; i < listeners.Length(); ++i) {
     listeners[i]->Callback(aTopic, aState);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-PowerManager::GetScreenEnabled(bool *aEnabled)
+bool
+PowerManager::ScreenEnabled()
 {
-  *aEnabled = hal::GetScreenEnabled();
-  return NS_OK;
+  return hal::GetScreenEnabled();
 }
 
-NS_IMETHODIMP
+void
 PowerManager::SetScreenEnabled(bool aEnabled)
 {
   hal::SetScreenEnabled(aEnabled);
-  return NS_OK;
 }
 
-NS_IMETHODIMP
-PowerManager::GetScreenBrightness(double *aBrightness)
+double
+PowerManager::ScreenBrightness()
 {
-  *aBrightness = hal::GetScreenBrightness();
-  return NS_OK;
+  return hal::GetScreenBrightness();
 }
 
-NS_IMETHODIMP
-PowerManager::SetScreenBrightness(double aBrightness)
+void
+PowerManager::SetScreenBrightness(double aBrightness, ErrorResult& aRv)
 {
-  NS_ENSURE_TRUE(0 <= aBrightness && aBrightness <= 1, NS_ERROR_INVALID_ARG);
-  hal::SetScreenBrightness(aBrightness);
-  return NS_OK;
+  if (0 <= aBrightness && aBrightness <= 1) {
+    hal::SetScreenBrightness(aBrightness);
+  } else {
+    aRv.Throw(NS_ERROR_INVALID_ARG);
+  }
 }
 
-NS_IMETHODIMP
-PowerManager::GetCpuSleepAllowed(bool *aAllowed)
+bool
+PowerManager::CpuSleepAllowed()
 {
-  *aAllowed = hal::GetCpuSleepAllowed();
-  return NS_OK;
+  return hal::GetCpuSleepAllowed();
 }
 
-NS_IMETHODIMP
+void
 PowerManager::SetCpuSleepAllowed(bool aAllowed)
 {
   hal::SetCpuSleepAllowed(aAllowed);
-  return NS_OK;
 }
 
 bool
 PowerManager::CheckPermission(nsPIDOMWindow* aWindow)
 {
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
   NS_ENSURE_TRUE(permMgr, false);
--- a/dom/power/PowerManager.h
+++ b/dom/power/PowerManager.h
@@ -2,51 +2,72 @@
 /* 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_power_PowerManager_h
 #define mozilla_dom_power_PowerManager_h
 
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
-#include "nsIDOMPowerManager.h"
 #include "nsIDOMWakeLockListener.h"
 #include "nsIDOMWindow.h"
 #include "nsWeakReference.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsWrapperCache.h"
 
 class nsPIDOMWindow;
 
 namespace mozilla {
+class ErrorResult;
+
 namespace dom {
 namespace power {
 
-class PowerManager
-  : public nsIDOMMozPowerManager
-  , public nsIDOMMozWakeLockListener
+class PowerManager MOZ_FINAL : public nsIDOMMozWakeLockListener
+                             , public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(PowerManager, nsIDOMMozPowerManager)
-  NS_DECL_NSIDOMMOZPOWERMANAGER
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PowerManager)
   NS_DECL_NSIDOMMOZWAKELOCKLISTENER
 
-  PowerManager() {};
-  virtual ~PowerManager() {};
+  PowerManager()
+  {
+    SetIsDOMBinding();
+  }
 
   nsresult Init(nsIDOMWindow *aWindow);
   nsresult Shutdown();
 
   static bool CheckPermission(nsPIDOMWindow*);
 
   static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*);
 
-private:
+  // WebIDL
+  nsIDOMWindow* GetParentObject() const
+  {
+    return mWindow;
+  }
+  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
+  void Reboot(ErrorResult& aRv);
+  void FactoryReset();
+  void PowerOff(ErrorResult& aRv);
+  void AddWakeLockListener(nsIDOMMozWakeLockListener* aListener);
+  void RemoveWakeLockListener(nsIDOMMozWakeLockListener* aListener);
+  void GetWakeLockState(const nsAString& aTopic, nsAString& aState,
+                        ErrorResult& aRv);
+  bool ScreenEnabled();
+  void SetScreenEnabled(bool aEnabled);
+  double ScreenBrightness();
+  void SetScreenBrightness(double aBrightness, ErrorResult& aRv);
+  bool CpuSleepAllowed();
+  void SetCpuSleepAllowed(bool aAllowed);
 
-  nsWeakPtr mWindow;
+private:
+  nsCOMPtr<nsIDOMWindow> mWindow;
   nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners;
 };
 
 } // namespace power
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_power_PowerManager_h
--- a/dom/power/moz.build
+++ b/dom/power/moz.build
@@ -3,25 +3,25 @@
 # 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/.
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
-    'nsIDOMPowerManager.idl',
     'nsIDOMWakeLock.idl',
     'nsIDOMWakeLockListener.idl',
     'nsIPowerManagerService.idl',
 ]
 
 XPIDL_MODULE = 'dom_power'
 
 EXPORTS.mozilla.dom.power += [
+    'PowerManager.h',
     'PowerManagerService.h',
     'Types.h',
 ]
 
 CPP_SOURCES += [
     'PowerManager.cpp',
     'PowerManagerService.cpp',
     'WakeLock.cpp',
rename from dom/power/nsIDOMPowerManager.idl
rename to dom/webidl/MozPowerManager.webidl
--- a/dom/power/nsIDOMPowerManager.idl
+++ b/dom/webidl/MozPowerManager.webidl
@@ -1,52 +1,52 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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 nsIDOMMozWakeLockListener;
+interface MozWakeLockListener;
 
 /**
  * This interface implements navigator.mozPower
  */
-[scriptable, uuid(7b181fef-2757-4198-89a0-8c426b8439ea)]
-interface nsIDOMMozPowerManager : nsISupports
+interface MozPowerManager
 {
+    [Throws]
     void    powerOff();
+    [Throws]
     void    reboot();
     void    factoryReset();
 
     /**
      * The listeners are notified when a resource changes its lock state to:
      *  - unlocked
      *  - locked but not visible
      *  - locked and visible
      */
-    void    addWakeLockListener(in nsIDOMMozWakeLockListener aListener);
-    void    removeWakeLockListener(in nsIDOMMozWakeLockListener aListener);
+    void    addWakeLockListener(MozWakeLockListener aListener);
+    void    removeWakeLockListener(MozWakeLockListener aListener);
 
     /**
      * Query the wake lock state of the topic.
      *
      * Possible states are:
      *
      *  - "unlocked" - nobody holds the wake lock.
      *
      *  - "locked-foreground" - at least one window holds the wake lock,
      *    and it is visible.
      *
      *  - "locked-background" - at least one window holds the wake lock,
      *    but all of them are hidden.
      *
      * @param aTopic The resource name related to the wake lock.
      */
-    DOMString getWakeLockState(in DOMString aTopic);
+    [Throws]
+    DOMString getWakeLockState(DOMString aTopic);
 
     /**
      * Is the device's screen currently enabled?  This attribute controls the
      * device's screen, so setting it to false will turn off the screen.
      */
     attribute boolean screenEnabled;
 
     /**
@@ -59,16 +59,17 @@ interface nsIDOMMozPowerManager : nsISup
      *
      * If you write a value of X into this attribute, the attribute may not have
      * the same value X when you later read it.  Most screens don't support as
      * many different brightness levels as there are doubles between 0 and 1, so
      * we may reduce the value's precision before storing it.
      *
      * @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
      */
+    [SetterThrows]
     attribute double screenBrightness;
 
     /**
      * Is it possible that the device's CPU will sleep after the screen is
      * disabled?  Setting this attribute to false will prevent the device
      * entering suspend state.
      */
     attribute boolean cpuSleepAllowed;
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -12,17 +12,16 @@
  * http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1
  * https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
  *
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
-interface MozPowerManager;
 interface MozWakeLock;
 
 // http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object
 [HeaderFile="Navigator.h", NeedNewResolve]
 interface Navigator {
   // objects implementing this interface also implement the interfaces given below
 };
 Navigator implements NavigatorID;
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -206,16 +206,17 @@ WEBIDL_FILES = [
     'MimeType.webidl',
     'MimeTypeArray.webidl',
     'MobileMessageManager.webidl',
     'MouseEvent.webidl',
     'MouseScrollEvent.webidl',
     'MozActivity.webidl',
     'MozMmsMessage.webidl',
     'MozNamedAttrMap.webidl',
+    'MozPowerManager.webidl',
     'MozTimeManager.webidl',
     'MutationEvent.webidl',
     'MutationObserver.webidl',
     'NetDashboard.webidl',
     'Node.webidl',
     'NodeFilter.webidl',
     'NodeIterator.webidl',
     'NodeList.webidl',