Bug 952079 - Porting nsIDOMWakeLock to WebIDL, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 07 Jan 2014 13:16:07 +0100
changeset 162689 9fc62be406070e684a80f27976c4e1a9bfab3de4
parent 162688 2f8927b0f01c9f12d7b9d0c02cb7be2b98e36b0a
child 162690 a1ed0445a56857c3af4b897c043a5ea14e676477
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs952079
milestone29.0a1
Bug 952079 - Porting nsIDOMWakeLock to WebIDL, r=smaug
content/html/content/public/HTMLMediaElement.h
content/html/content/public/HTMLVideoElement.h
content/html/content/src/HTMLMediaElement.cpp
content/html/content/src/HTMLVideoElement.cpp
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/bindings/Bindings.conf
dom/interfaces/base/domstubs.idl
dom/ipc/ContentParent.cpp
dom/power/PowerManagerService.cpp
dom/power/PowerManagerService.h
dom/power/WakeLock.cpp
dom/power/WakeLock.h
dom/power/moz.build
dom/power/nsIDOMWakeLock.idl
dom/power/nsIPowerManagerService.idl
dom/system/gonk/nsIVolume.idl
dom/system/gonk/nsVolumeMountLock.cpp
dom/system/gonk/nsVolumeMountLock.h
dom/webidl/MozWakeLock.webidl
dom/webidl/Navigator.webidl
dom/webidl/moz.build
--- a/content/html/content/public/HTMLMediaElement.h
+++ b/content/html/content/public/HTMLMediaElement.h
@@ -34,16 +34,17 @@ namespace mozilla {
 class AudioStream;
 class ErrorResult;
 class MediaResource;
 class MediaDecoder;
 class VideoFrameContainer;
 namespace dom {
 class TextTrack;
 class TimeRanges;
+class WakeLock;
 }
 }
 
 class nsITimer;
 class nsRange;
 class nsIRunnable;
 
 namespace mozilla {
@@ -583,17 +584,17 @@ protected:
   };
 
   /**
    * These two methods are called by the WakeLockBoolWrapper when the wakelock
    * has to be created or released.
    */
   virtual void WakeLockCreate();
   virtual void WakeLockRelease();
-  nsCOMPtr<nsIDOMMozWakeLock> mWakeLock;
+  nsRefPtr<WakeLock> mWakeLock;
 
   /**
    * Logs a warning message to the web console to report various failures.
    * aMsg is the localized message identifier, aParams is the parameters to
    * be substituted into the localized message, and aParamCount is the number
    * of parameters in aParams.
    */
   void ReportLoadError(const char* aMsg,
--- a/content/html/content/public/HTMLVideoElement.h
+++ b/content/html/content/public/HTMLVideoElement.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/Attributes.h"
 #include "nsIDOMHTMLVideoElement.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 
 namespace mozilla {
 namespace dom {
 
+class WakeLock;
 class VideoPlaybackQuality;
 
 class HTMLVideoElement MOZ_FINAL : public HTMLMediaElement,
                                    public nsIDOMHTMLVideoElement
 {
 public:
   HTMLVideoElement(already_AddRefed<nsINodeInfo> aNodeInfo);
   virtual ~HTMLVideoElement();
@@ -110,17 +111,17 @@ public:
 protected:
   virtual JSObject* WrapNode(JSContext* aCx,
                              JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual void WakeLockCreate();
   virtual void WakeLockRelease();
   void WakeLockUpdate();
 
-  nsCOMPtr<nsIDOMMozWakeLock> mScreenWakeLock;
+  nsRefPtr<WakeLock> mScreenWakeLock;
 
 private:
   static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                                     nsRuleData* aData);
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -70,20 +70,20 @@
 #include "mozilla/dom/MediaSource.h"
 #include "MediaMetadataManager.h"
 #include "MediaSourceDecoder.h"
 
 #include "AudioChannelService.h"
 
 #include "nsCSSParser.h"
 #include "nsIMediaList.h"
-#include "nsIDOMWakeLock.h"
+#include "mozilla/dom/power/PowerManagerService.h"
+#include "mozilla/dom/WakeLock.h"
 
 #include "ImageContainer.h"
-#include "nsIPowerManagerService.h"
 #include "nsRange.h"
 #include <algorithm>
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gMediaElementLog;
 static PRLogModuleInfo* gMediaElementEventsLog;
 #define LOG(type, msg) PR_LOG(gMediaElementLog, type, msg)
 #define LOG_EVENT(type, msg) PR_LOG(gMediaElementEventsLog, type, msg)
@@ -2240,31 +2240,34 @@ HTMLMediaElement::WakeLockBoolWrapper::T
   wakeLock->mOuter->WakeLockRelease();
   wakeLock->mTimer = nullptr;
 }
 
 void
 HTMLMediaElement::WakeLockCreate()
 {
   if (!mWakeLock) {
-    nsCOMPtr<nsIPowerManagerService> pmService =
-      do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+    nsRefPtr<power::PowerManagerService> pmService =
+      power::PowerManagerService::GetInstance();
     NS_ENSURE_TRUE_VOID(pmService);
 
-    pmService->NewWakeLock(NS_LITERAL_STRING("cpu"),
-                           OwnerDoc()->GetWindow(),
-                           getter_AddRefs(mWakeLock));
+    ErrorResult rv;
+    mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("cpu"),
+                                       OwnerDoc()->GetInnerWindow(),
+                                       rv);
   }
 }
 
 void
 HTMLMediaElement::WakeLockRelease()
 {
   if (mWakeLock) {
-    mWakeLock->Unlock();
+    ErrorResult rv;
+    mWakeLock->Unlock(rv);
+    NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
     mWakeLock = nullptr;
   }
 }
 
 bool HTMLMediaElement::ParseAttribute(int32_t aNamespaceID,
                                       nsIAtom* aAttribute,
                                       const nsAString& aValue,
                                       nsAttrValue& aResult)
--- a/content/html/content/src/HTMLVideoElement.cpp
+++ b/content/html/content/src/HTMLVideoElement.cpp
@@ -22,21 +22,21 @@
 
 #include "nsIScriptSecurityManager.h"
 #include "nsIXPConnect.h"
 
 #include "nsITimer.h"
 
 #include "nsEventDispatcher.h"
 #include "nsIDOMProgressEvent.h"
-#include "nsIPowerManagerService.h"
 #include "MediaError.h"
 #include "MediaDecoder.h"
 #include "mozilla/Preferences.h"
-#include "nsIDOMWakeLock.h"
+#include "mozilla/dom/WakeLock.h"
+#include "mozilla/dom/power/PowerManagerService.h"
 #include "nsPerformance.h"
 #include "mozilla/dom/VideoPlaybackQuality.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Video)
 
 namespace mozilla {
 namespace dom {
 
@@ -297,29 +297,32 @@ HTMLVideoElement::WakeLockRelease()
 }
 
 void
 HTMLVideoElement::WakeLockUpdate()
 {
   bool hidden = OwnerDoc()->Hidden();
 
   if (mScreenWakeLock && (mPaused || hidden)) {
-    mScreenWakeLock->Unlock();
+    ErrorResult rv;
+    mScreenWakeLock->Unlock(rv);
+    NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
     mScreenWakeLock = nullptr;
     return;
   }
 
   if (!mScreenWakeLock && !mPaused && !hidden) {
-    nsCOMPtr<nsIPowerManagerService> pmService =
-      do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+    nsRefPtr<power::PowerManagerService> pmService =
+      power::PowerManagerService::GetInstance();
     NS_ENSURE_TRUE_VOID(pmService);
 
-    pmService->NewWakeLock(NS_LITERAL_STRING("screen"),
-                           OwnerDoc()->GetWindow(),
-                           getter_AddRefs(mScreenWakeLock));
+    ErrorResult rv;
+    mScreenWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("screen"),
+                                             OwnerDoc()->GetInnerWindow(),
+                                             rv);
   }
 }
 
 void
 HTMLVideoElement::Init()
 {
   Preferences::AddBoolVarCache(&sVideoStatsEnabled, "media.video_stats.enabled");
 }
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -21,18 +21,18 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentUtils.h"
 #include "nsUnicharUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "BatteryManager.h"
 #include "mozilla/dom/PowerManager.h"
-#include "nsIDOMWakeLock.h"
-#include "nsIPowerManagerService.h"
+#include "mozilla/dom/WakeLock.h"
+#include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/MobileMessageManager.h"
 #include "mozilla/dom/Telephony.h"
 #include "mozilla/Hal.h"
 #include "nsISiteSpecificUserAgent.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/StaticPtr.h"
 #include "Connection.h"
 #include "nsDOMEvent.h"
@@ -1126,33 +1126,32 @@ Navigator::GetMozPower(ErrorResult& aRv)
       // We failed to get the power manager service?
       aRv.Throw(NS_ERROR_UNEXPECTED);
     }
   }
 
   return mPowerManager;
 }
 
-already_AddRefed<nsIDOMMozWakeLock>
+already_AddRefed<WakeLock>
 Navigator::RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv)
 {
   if (!mWindow) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
-  nsCOMPtr<nsIPowerManagerService> pmService =
-    do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+  nsRefPtr<power::PowerManagerService> pmService =
+    power::PowerManagerService::GetInstance();
   // Maybe it went away for some reason... Or maybe we're just called
   // from our XPCOM method.
   NS_ENSURE_TRUE(pmService, nullptr);
 
-  nsCOMPtr<nsIDOMMozWakeLock> wakelock;
-  aRv = pmService->NewWakeLock(aTopic, mWindow, getter_AddRefs(wakelock));
-  return wakelock.forget();
+  ErrorResult rv;
+  return pmService->NewWakeLock(aTopic, mWindow, rv);
 }
 
 nsIDOMMozMobileMessageManager*
 Navigator::GetMozMobileMessage()
 {
   if (!mMobileMessageManager) {
     // Check that our window has not gone away
     NS_ENSURE_TRUE(mWindow, nullptr);
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -26,16 +26,17 @@ class nsDOMCameraManager;
 class nsDOMDeviceStorage;
 
 namespace mozilla {
 namespace dom {
 class Geolocation;
 class systemMessageCallback;
 class MediaStreamConstraints;
 class MediaStreamConstraintsInternal;
+class WakeLock;
 }
 }
 
 #ifdef MOZ_B2G_RIL
 class nsIDOMMozIccManager;
 #endif // MOZ_B2G_RIL
 
 //*****************************************************************************
@@ -177,18 +178,18 @@ public:
   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,
-                                                      ErrorResult& aRv);
+  already_AddRefed<WakeLock> RequestWakeLock(const nsAString &aTopic,
+                                             ErrorResult& aRv);
   nsDOMDeviceStorage* GetDeviceStorage(const nsAString& aType,
                                        ErrorResult& aRv);
   void GetDeviceStorages(const nsAString& aType,
                          nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores,
                          ErrorResult& aRv);
   DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
   bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
                              ErrorResult& aRv);
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -143,17 +143,16 @@
 #include "nsIEventListenerService.h"
 #include "nsIMessageManager.h"
 
 #include "nsDOMTouchEvent.h"
 
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/dom/HTMLCollectionBinding.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"
 
@@ -431,19 +430,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(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)
 
   NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1122,20 +1118,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(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
 
   DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
   DOM_CLASSINFO_MAP_END
 
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -72,18 +72,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(MozWakeLock)
-
 DOMCI_CLASS(MozMobileMessageManager)
 DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozMmsMessage)
 DOMCI_CLASS(MozSmsFilter)
 DOMCI_CLASS(MozSmsSegmentInfo)
 DOMCI_CLASS(MozMobileMessageThread)
 
 DOMCI_CLASS(MozConnection)
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -17,23 +17,23 @@
 #include "nsPerformance.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsIDOMStorage.h"
 #include "nsIDOMStorageManager.h"
 #include "DOMStorage.h"
 #include "nsDOMOfflineResourceList.h"
 #include "nsError.h"
 #include "nsIIdleService.h"
-#include "nsIPowerManagerService.h"
 #include "nsISizeOfEventTarget.h"
 #include "nsDOMJSUtils.h"
 #include "nsArrayUtils.h"
 #include "nsIDOMWindowCollection.h"
 #include "nsDOMWindowList.h"
-#include "nsIDOMWakeLock.h"
+#include "mozilla/dom/WakeLock.h"
+#include "mozilla/dom/power/PowerManagerService.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIPermissionManager.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptTimeoutHandler.h"
 #include "nsIController.h"
 
 // Helper Classes
 #include "nsJSUtils.h"
@@ -5693,23 +5693,31 @@ nsGlobalWindow::SetFullScreenInternal(bo
     // Force exit from DOM full-screen mode. This is so that if we're in
     // DOM full-screen mode and the user exits full-screen mode with
     // the browser full-screen mode toggle keyboard-shortcut, we'll detect
     // that and leave DOM API full-screen mode too.
     nsIDocument::ExitFullscreen(mDoc, /* async */ false);
   }
 
   if (!mWakeLock && mFullScreen) {
-    nsCOMPtr<nsIPowerManagerService> pmService =
-      do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+    nsRefPtr<power::PowerManagerService> pmService =
+      power::PowerManagerService::GetInstance();
     NS_ENSURE_TRUE(pmService, NS_OK);
 
-    pmService->NewWakeLock(NS_LITERAL_STRING("DOM_Fullscreen"), this, getter_AddRefs(mWakeLock));
+    ErrorResult rv;
+    mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("DOM_Fullscreen"),
+                                       this, rv);
+    if (rv.Failed()) {
+      return rv.ErrorCode();
+    }
+
   } else if (mWakeLock && !mFullScreen) {
-    mWakeLock->Unlock();
+    ErrorResult rv;
+    mWakeLock->Unlock(rv);
+    NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
     mWakeLock = nullptr;
   }
 
   return NS_OK;
 }
 
 bool
 nsGlobalWindow::GetFullScreen(ErrorResult& aError)
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -77,17 +77,16 @@
 
 class nsIArray;
 class nsIBaseWindow;
 class nsIContent;
 class nsICSSDeclaration;
 class nsIDocShellTreeOwner;
 class nsIDOMCrypto;
 class nsIDOMOfflineResourceList;
-class nsIDOMMozWakeLock;
 class nsIScrollableFrame;
 class nsIControllers;
 class nsIScriptContext;
 class nsIScriptTimeoutHandler;
 class nsIWebBrowserChrome;
 
 class nsDOMWindowList;
 class nsLocation;
@@ -107,16 +106,17 @@ namespace mozilla {
 class Selection;
 namespace dom {
 class BarProp;
 class Function;
 class Gamepad;
 class MediaQueryList;
 class Navigator;
 class SpeechSynthesis;
+class WakeLock;
 namespace indexedDB {
 class IDBFactory;
 } // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
 
 extern nsresult
 NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow,
@@ -967,17 +967,17 @@ protected:
   bool mCurrentlyIdle;
 
   // Set to true when a fuzz time needs to be applied
   // to active notifications to the idle observer.
   bool mAddActiveEventFuzzTime;
 
   nsCOMPtr <nsIIdleService> mIdleService;
 
-  nsCOMPtr <nsIDOMMozWakeLock> mWakeLock;
+  nsRefPtr<mozilla::dom::WakeLock> mWakeLock;
 
   static bool sIdleObserversAPIFuzzTimeDisabled;
 
   friend class HashchangeCallback;
   friend class mozilla::dom::BarProp;
 
   // Object Management
   virtual ~nsGlobalWindow();
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -817,16 +817,20 @@ DOMInterfaces = {
     'nativeType': 'mozilla::dom::SpeakerManager',
     'headerFile': 'SpeakerManager.h'
 },
 
 'MozPowerManager': {
     'nativeType': 'mozilla::dom::PowerManager',
 },
 
+'MozWakeLock': {
+    'nativeType': 'mozilla::dom::WakeLock',
+},
+
 'MozTimeManager': {
     'nativeType': 'mozilla::dom::time::TimeManager',
 },
 
 'MozVoicemail': {
     'nativeType': 'mozilla::dom::Voicemail',
 },
 
@@ -1891,17 +1895,16 @@ addExternalIface('MozObserver', nativeTy
 addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
                  notflattened=True)
 addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
 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('nsIDOMCrypto', nativeType='nsIDOMCrypto',
                  headerFile='Crypto.h')
 addExternalIface('nsIInputStreamCallback', nativeType='nsIInputStreamCallback',
                  headerFile='nsIAsyncInputStream.h')
 addExternalIface('nsISelectionListener', nativeType='nsISelectionListener')
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -78,11 +78,8 @@ interface nsIDOMRange;
 // Crypto
 interface nsIDOMCRMFObject;
 interface nsIDOMCrypto;
 interface nsIDOMPkcs11;
 
 // Used font face (for inspector)
 interface nsIDOMFontFace;
 interface nsIDOMFontFaceList;
-
-// Power
-interface nsIDOMMozWakeLock;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -59,17 +59,17 @@
 #include "nsDebugImpl.h"
 #include "nsDOMFile.h"
 #include "nsFrameMessageManager.h"
 #include "nsHashPropertyBag.h"
 #include "nsIAlertsService.h"
 #include "nsIAppsService.h"
 #include "nsIClipboard.h"
 #include "nsIDOMGeoGeolocation.h"
-#include "nsIDOMWakeLock.h"
+#include "mozilla/dom/WakeLock.h"
 #include "nsIDOMWindow.h"
 #include "nsIExternalProtocolService.h"
 #include "nsIFilePicker.h"
 #include "nsIIdleService.h"
 #include "nsIMemoryReporter.h"
 #include "nsIMozBrowserFrame.h"
 #include "nsIMutable.h"
 #include "nsIObserverService.h"
@@ -708,17 +708,17 @@ public:
         if (!listener) {
             return;
         }
 
         // Careful: ShutDown() may delete |this|.
         listener->ShutDown();
     }
 
-    void Init(nsIDOMMozWakeLock* aWakeLock)
+    void Init(WakeLock* aWakeLock)
     {
         MOZ_ASSERT(!mWakeLock);
         MOZ_ASSERT(!mTimer);
 
         // mTimer keeps a strong reference to |this|.  When this object's
         // destructor runs, it will remove itself from the LinkedList.
 
         if (!sListeners) {
@@ -746,25 +746,26 @@ public:
 
 private:
     static StaticAutoPtr<LinkedList<SystemMessageHandledListener> > sListeners;
 
     void ShutDown()
     {
         nsRefPtr<SystemMessageHandledListener> kungFuDeathGrip = this;
 
-        mWakeLock->Unlock();
+        ErrorResult rv;
+        mWakeLock->Unlock(rv);
 
         if (mTimer) {
             mTimer->Cancel();
             mTimer = nullptr;
         }
     }
 
-    nsCOMPtr<nsIDOMMozWakeLock> mWakeLock;
+    nsRefPtr<WakeLock> mWakeLock;
     nsCOMPtr<nsITimer> mTimer;
 };
 
 StaticAutoPtr<LinkedList<SystemMessageHandledListener> >
     SystemMessageHandledListener::sListeners;
 
 NS_IMPL_ISUPPORTS1(SystemMessageHandledListener,
                    nsITimerCallback)
@@ -781,17 +782,17 @@ ContentParent::MaybeTakeCPUWakeLock(Elem
     nsCOMPtr<nsIMozBrowserFrame> browserFrame =
         do_QueryInterface(aFrameElement);
     if (!browserFrame ||
         !browserFrame->GetIsExpectingSystemMessage()) {
         return;
     }
 
     nsRefPtr<PowerManagerService> pms = PowerManagerService::GetInstance();
-    nsCOMPtr<nsIDOMMozWakeLock> lock =
+    nsRefPtr<WakeLock> lock =
         pms->NewWakeLockOnBehalfOfProcess(NS_LITERAL_STRING("cpu"), this);
 
     // This object's Init() function keeps it alive.
     nsRefPtr<SystemMessageHandledListener> listener =
         new SystemMessageHandledListener();
     listener->Init(lock);
 }
 
--- a/dom/power/PowerManagerService.cpp
+++ b/dom/power/PowerManagerService.cpp
@@ -200,32 +200,47 @@ PowerManagerService::GetWakeLockState(co
   WakeLockInformation info;
   GetWakeLockInfo(aTopic, &info);
 
   ComputeWakeLockState(info, aState);
 
   return NS_OK;
 }
 
+already_AddRefed<WakeLock>
+PowerManagerService::NewWakeLock(const nsAString& aTopic,
+                                 nsIDOMWindow* aWindow,
+                                 mozilla::ErrorResult& aRv)
+{
+  nsRefPtr<WakeLock> wakelock = new WakeLock();
+  aRv = wakelock->Init(aTopic, aWindow);
+  if (aRv.Failed()) {
+    return nullptr;
+  }
+
+  return wakelock.forget();
+}
+
 NS_IMETHODIMP
 PowerManagerService::NewWakeLock(const nsAString &aTopic,
                                  nsIDOMWindow *aWindow,
-                                 nsIDOMMozWakeLock **aWakeLock)
+                                 nsISupports **aWakeLock)
 {
-  nsRefPtr<WakeLock> wakelock = new WakeLock();
-  nsresult rv = wakelock->Init(aTopic, aWindow);
-  NS_ENSURE_SUCCESS(rv, rv);
+  mozilla::ErrorResult rv;
+  nsRefPtr<WakeLock> wakelock = NewWakeLock(aTopic, aWindow, rv);
+  if (rv.Failed()) {
+    return rv.ErrorCode();
+  }
 
-  nsCOMPtr<nsIDOMMozWakeLock> wl(wakelock);
-  wl.forget(aWakeLock);
-
+  nsCOMPtr<nsIDOMEventListener> eventListener = wakelock.get();
+  eventListener.forget(aWakeLock);
   return NS_OK;
 }
 
-already_AddRefed<nsIDOMMozWakeLock>
+already_AddRefed<WakeLock>
 PowerManagerService::NewWakeLockOnBehalfOfProcess(const nsAString& aTopic,
                                                   ContentParent* aContentParent)
 {
   nsRefPtr<WakeLock> wakelock = new WakeLock();
   nsresult rv = wakelock->Init(aTopic, aContentParent);
   NS_ENSURE_SUCCESS(rv, nullptr);
   return wakelock.forget();
 }
--- a/dom/power/PowerManagerService.h
+++ b/dom/power/PowerManagerService.h
@@ -8,16 +8,17 @@
 #include "nsCOMPtr.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
 #include "nsIPowerManagerService.h"
 #include "mozilla/Observer.h"
 #include "Types.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/dom/WakeLock.h"
 
 namespace mozilla {
 namespace dom {
 
 class ContentParent;
 
 namespace power {
 
@@ -43,20 +44,24 @@ public:
    * which acquires a wake lock on behalf of the /current/ process.
    *
    * NewWakeLockOnBehalfOfProcess is different from NewWakeLock in that
    *
    *  - The wake lock unlocks itself if the /given/ process dies, and
    *  - The /given/ process shows up in WakeLockInfo::lockingProcesses.
    *
    */
-  already_AddRefed<nsIDOMMozWakeLock>
+  already_AddRefed<WakeLock>
   NewWakeLockOnBehalfOfProcess(const nsAString& aTopic,
                                ContentParent* aContentParent);
 
+  already_AddRefed<WakeLock>
+  NewWakeLock(const nsAString& aTopic, nsIDOMWindow* aWindow,
+              mozilla::ErrorResult& aRv);
+
 private:
 
   ~PowerManagerService();
 
   void ComputeWakeLockState(const hal::WakeLockInformation& aWakeLockInfo,
                             nsAString &aState);
 
   void SyncProfile();
--- a/dom/power/WakeLock.cpp
+++ b/dom/power/WakeLock.cpp
@@ -1,59 +1,63 @@
 /* -*- Mode: C++; tab-width: 40; 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 "WakeLock.h"
 #include "mozilla/dom/ContentParent.h"
+#include "mozilla/dom/MozWakeLockBinding.h"
 #include "mozilla/Hal.h"
 #include "mozilla/HalWakeLock.h"
-#include "nsDOMClassInfoID.h"
 #include "nsDOMEvent.h"
 #include "nsError.h"
 #include "nsIDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsIPropertyBag2.h"
 
-DOMCI_DATA(MozWakeLock, mozilla::dom::power::WakeLock)
-
 using namespace mozilla::hal;
 
 namespace mozilla {
 namespace dom {
-namespace power {
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WakeLock)
 
-NS_INTERFACE_MAP_BEGIN(WakeLock)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMozWakeLock)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozWakeLock)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WakeLock)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozWakeLock)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_ADDREF(WakeLock)
-NS_IMPL_RELEASE(WakeLock)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(WakeLock)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(WakeLock)
 
 WakeLock::WakeLock()
   : mLocked(false)
   , mHidden(true)
   , mContentParentID(CONTENT_PROCESS_ID_UNKNOWN)
 {
+  SetIsDOMBinding();
 }
 
 WakeLock::~WakeLock()
 {
   DoUnlock();
   DetachEventListener();
 }
 
+JSObject*
+WakeLock::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+{
+  return MozWakeLockBinding::Wrap(aCx, aScope, this);
+}
+
 nsresult
 WakeLock::Init(const nsAString &aTopic, nsIDOMWindow *aWindow)
 {
   // Don't Init() a WakeLock twice.
   MOZ_ASSERT(mTopic.IsEmpty());
 
   if (aTopic.IsEmpty()) {
     return NS_ERROR_INVALID_ARG;
@@ -207,37 +211,35 @@ WakeLock::DetachEventListener()
                                         /* useCapture = */ true);
       target->RemoveSystemEventListener(NS_LITERAL_STRING("pageshow"),
                                         this,
                                         /* useCapture = */ true);
     }
   }
 }
 
-NS_IMETHODIMP
-WakeLock::Unlock()
+void
+WakeLock::Unlock(ErrorResult& aRv)
 {
   /*
    * We throw NS_ERROR_DOM_INVALID_STATE_ERR on double unlock.
    */
   if (!mLocked) {
-    return NS_ERROR_DOM_INVALID_STATE_ERR;
+    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+    return;
   }
 
   DoUnlock();
   DetachEventListener();
-
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 WakeLock::GetTopic(nsAString &aTopic)
 {
   aTopic.Assign(mTopic);
-  return NS_OK;
 }
 
 NS_IMETHODIMP
 WakeLock::HandleEvent(nsIDOMEvent *aEvent)
 {
   nsAutoString type;
   aEvent->GetType(type);
 
@@ -267,11 +269,17 @@ WakeLock::HandleEvent(nsIDOMEvent *aEven
   if (type.EqualsLiteral("pageshow")) {
     DoLock();
     return NS_OK;
   }
 
   return NS_OK;
 }
 
-} // power
+nsISupports*
+WakeLock::GetParentObject() const
+{
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mWindow);
+  return window;
+}
+
 } // dom
 } // mozilla
--- a/dom/power/WakeLock.h
+++ b/dom/power/WakeLock.h
@@ -2,43 +2,43 @@
 /* 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_WakeLock_h
 #define mozilla_dom_power_WakeLock_h
 
 #include "nsCOMPtr.h"
-#include "nsIDOMWakeLock.h"
 #include "nsIDOMEventListener.h"
 #include "nsIObserver.h"
 #include "nsString.h"
 #include "nsWeakReference.h"
+#include "nsWrapperCache.h"
+#include "mozilla/ErrorResult.h"
 
 class nsIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 
 class ContentParent;
 
-namespace power {
-
-class WakeLock
-  : public nsIDOMMozWakeLock
-  , public nsIDOMEventListener
+class WakeLock MOZ_FINAL
+  : public nsIDOMEventListener
+  , public nsWrapperCache
   , public nsIObserver
   , public nsSupportsWeakReference
 {
 public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMMOZWAKELOCK
   NS_DECL_NSIDOMEVENTLISTENER
   NS_DECL_NSIOBSERVER
 
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WakeLock, nsIDOMEventListener)
+
   // Note: WakeLock lives for the lifetime of the document in order to avoid
   // exposing GC behavior to pages. This means that
   // |var foo = navigator.requestWakeLock('cpu'); foo = null;|
   // doesn't unlock the 'cpu' resource.
 
   WakeLock();
   virtual ~WakeLock();
 
@@ -47,16 +47,27 @@ public:
   // invisible.
   nsresult Init(const nsAString &aTopic, nsIDOMWindow* aWindow);
 
   // Initialize this wake lock on behalf of the given process.  If the process
   // dies, the lock is released.  A wake lock initialized via this method is
   // always considered visible.
   nsresult Init(const nsAString &aTopic, ContentParent* aContentParent);
 
+  // WebIDL methods
+
+  nsISupports* GetParentObject() const;
+
+  virtual JSObject*
+  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
+
+  void GetTopic(nsAString& aTopic);
+
+  void Unlock(ErrorResult& aRv);
+
 private:
   void     DoUnlock();
   void     DoLock();
   void     AttachEventListener();
   void     DetachEventListener();
 
   bool      mLocked;
   bool      mHidden;
@@ -66,13 +77,12 @@ private:
   // current process.
   uint64_t  mContentParentID;
   nsString  mTopic;
 
   // window that this was created for.  Weak reference.
   nsWeakPtr mWindow;
 };
 
-} // namespace power
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_power_WakeLock_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 += [
-    'nsIDOMWakeLock.idl',
     'nsIDOMWakeLockListener.idl',
     'nsIPowerManagerService.idl',
 ]
 
 XPIDL_MODULE = 'dom_power'
 
 EXPORTS.mozilla.dom += [
     'PowerManager.h',
+    'WakeLock.h',
 ]
 
 EXPORTS.mozilla.dom.power += [
     'PowerManagerService.h',
     'Types.h',
 ]
 
 UNIFIED_SOURCES += [
deleted file mode 100644
--- a/dom/power/nsIDOMWakeLock.idl
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- Mode: C++; tab-width: 40; 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 "nsISupports.idl"
-
-[scriptable, uuid(2e61eed1-5983-4562-8f26-fd361ab4a00d)]
-interface nsIDOMMozWakeLock : nsISupports
-{
-    readonly attribute DOMString topic;
-
-    /**
-     * Release the wake lock.
-     *
-     * @throw NS_ERROR_DOM_INVALID_STATE_ERR if already unlocked.
-     */
-    void unlock();
-};
--- a/dom/power/nsIPowerManagerService.idl
+++ b/dom/power/nsIPowerManagerService.idl
@@ -5,17 +5,16 @@
 
 #include "nsISupports.idl"
 
 %{C++
 #define NS_POWERMANAGERSERVICE_CID { 0x18c2e238, 0x3a0a, 0x4153, {0x89, 0xfc, 0x16, 0x6b, 0x3b, 0x14, 0x65, 0xa1 } }
 #define POWERMANAGERSERVICE_CONTRACTID "@mozilla.org/power/powermanagerservice;1"
 %}
 
-interface nsIDOMMozWakeLock;
 interface nsIDOMMozWakeLockListener;
 interface nsIDOMWindow;
 
 /**
  * For use with non-content code.
  */
 [scriptable, builtinclass, uuid(a232e826-07bd-11e2-8a8f-236186ff1a14)]
 interface nsIPowerManagerService : nsISupports
@@ -35,14 +34,14 @@ interface nsIPowerManagerService : nsISu
    */
   void              restart();
 
   void              addWakeLockListener(in nsIDOMMozWakeLockListener aListener);
   void              removeWakeLockListener(in nsIDOMMozWakeLockListener aListener);
   DOMString         getWakeLockState(in DOMString aTopic);
 
   /**
-   * Return a wake lock object of aTopic associated with aWindow.
+   * Return a wake lock (MozWakeLock) object of aTopic associated with aWindow.
    * A wake lock without associated window, e.g. used in chrome, is
    * always considered invisible.
    */
-  nsIDOMMozWakeLock newWakeLock(in DOMString aTopic, [optional] in nsIDOMWindow aWindow);
+  nsISupports newWakeLock(in DOMString aTopic, [optional] in nsIDOMWindow aWindow);
 };
--- a/dom/system/gonk/nsIVolume.idl
+++ b/dom/system/gonk/nsIVolume.idl
@@ -34,17 +34,17 @@ interface nsIVolume : nsISupports
 
   // mountGeneration is a unique number which is used distinguish between
   // periods of time that a volume is in the mounted state. Each time a
   // volume transitions to the mounted state, the mountGeneration will
   // be different from the last time it transitioned to the mounted state.
   readonly attribute long mountGeneration;
 
   // While a volume is mounted, it can be locked, preventing it from being
-  // shared with the PC. To lock a volume, acquire an nsIDOMMozWakeLock
+  // shared with the PC. To lock a volume, acquire an MozWakeLock
   // using the name of this attribute. Note that mountLockName changes
   // every time the mountGeneration changes, so you'll need to reacquire
   // the wakelock every time the volume becomes mounted.
   readonly attribute DOMString mountLockName;
 
   // Determines if a mountlock is currently being held against this volume.
   readonly attribute boolean isMountLocked;
 
--- a/dom/system/gonk/nsVolumeMountLock.cpp
+++ b/dom/system/gonk/nsVolumeMountLock.cpp
@@ -12,16 +12,17 @@
 #include "nsIVolume.h"
 #include "nsIVolumeService.h"
 #include "nsString.h"
 #include "nsXULAppAPI.h"
 
 #define VOLUME_MANAGER_LOG_TAG  "nsVolumeMountLock"
 #include "VolumeManagerLog.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/dom/power/PowerManagerService.h"
 
 using namespace mozilla::dom;
 using namespace mozilla::services;
 
 namespace mozilla {
 namespace system {
 
 NS_IMPL_ISUPPORTS3(nsVolumeMountLock, nsIVolumeMountLock,
@@ -136,24 +137,28 @@ NS_IMETHODIMP nsVolumeMountLock::Observe
 
   // The generation changed, which means that any wakelock we may have
   // been holding is now invalid. Grab a new wakelock for the new generation
   // number.
 
   mWakeLock = nullptr;
   mVolumeGeneration = mountGeneration;
 
-  nsCOMPtr<nsIPowerManagerService> pmService =
-    do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+  nsRefPtr<power::PowerManagerService> pmService =
+    power::PowerManagerService::GetInstance();
   NS_ENSURE_TRUE(pmService, NS_ERROR_FAILURE);
 
   nsString mountLockName;
   vol->GetMountLockName(mountLockName);
-  rv = pmService->NewWakeLock(mountLockName, nullptr, getter_AddRefs(mWakeLock));
-  NS_ENSURE_SUCCESS(rv, rv);
+
+  ErrorResult err;
+  mWakeLock = pmService->NewWakeLock(mountLockName, nullptr, err);
+  if (err.Failed()) {
+    return err.ErrorCode();
+  }
 
   LOG("nsVolumeMountLock acquired for '%s' gen %d",
       NS_LossyConvertUTF16toASCII(mVolumeName).get(), mVolumeGeneration);
   return NS_OK;
 }
 
 } // namespace system
 } // namespace mozilla
--- a/dom/system/gonk/nsVolumeMountLock.h
+++ b/dom/system/gonk/nsVolumeMountLock.h
@@ -2,20 +2,21 @@
  * 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_system_nsvolumemountlock_h__
 #define mozilla_system_nsvolumemountlock_h__
 
 #include "nsIVolumeMountLock.h"
 
-#include "nsIDOMWakeLock.h"
+#include "mozilla/dom/WakeLock.h"
 #include "nsIObserver.h"
 #include "nsString.h"
 #include "nsTArray.h"
+#include "nsAutoPtr.h"
 #include "nsWeakReference.h"
 
 namespace mozilla {
 namespace system {
 
 /* The VolumeMountLock is designed so that it can be used in the Child or
  * Parent process. While the VolumeMountLock object exists, then the
  * VolumeManager/AutoMounter will prevent a mounted volume from being
@@ -36,18 +37,18 @@ public:
   const nsString& VolumeName() const  { return mVolumeName; }
 
 private:
   nsVolumeMountLock(const nsAString& aVolumeName);
   ~nsVolumeMountLock();
 
   nsresult Init();
 
-  nsString                    mVolumeName;
-  int32_t                     mVolumeGeneration;
-  nsCOMPtr<nsIDOMMozWakeLock> mWakeLock;
-  bool                        mUnlocked;
+  nsRefPtr<dom::WakeLock>  mWakeLock;
+  nsString                 mVolumeName;
+  int32_t                  mVolumeGeneration;
+  bool                     mUnlocked;
 };
 
 } // namespace system
 } // namespace mozilla
 
 #endif  // mozilla_system_nsvolumemountlock_h__
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozWakeLock.webidl
@@ -0,0 +1,18 @@
+/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+[Func="Navigator::HasWakeLockSupport"]
+interface MozWakeLock
+{
+    readonly attribute DOMString topic;
+
+    /**
+     * Release the wake lock.
+     * @throw NS_ERROR_DOM_INVALID_STATE_ERR if already unlocked.
+     */
+    [Throws]
+    void unlock();
+};
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -12,18 +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 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;
 Navigator implements NavigatorLanguage;
 Navigator implements NavigatorOnLine;
@@ -188,17 +186,17 @@ partial interface Navigator {
    *
    * The resource manager defines what each topic means and sets policy.  For
    * example, the resource manager might decide to ignore 'screen' wake locks
    * held by pages which are not visible.
    *
    * One topic can be locked multiple times; it is considered released only when
    * all locks on the topic have been released.
    *
-   * The returned nsIDOMMozWakeLock object is a token of the lock.  You can
+   * The returned MozWakeLock object is a token of the lock.  You can
    * unlock the lock via the object's |unlock| method.  The lock is released
    * automatically when its associated window is unloaded.
    *
    * @param aTopic resource name
    */
   [Throws, Func="Navigator::HasWakeLockSupport"]
   MozWakeLock requestWakeLock(DOMString aTopic);
 };
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -228,16 +228,17 @@ WEBIDL_FILES = [
     'MobileMessageManager.webidl',
     'MouseEvent.webidl',
     'MouseScrollEvent.webidl',
     'MozActivity.webidl',
     'MozMmsMessage.webidl',
     'MozNamedAttrMap.webidl',
     'MozPowerManager.webidl',
     'MozTimeManager.webidl',
+    'MozWakeLock.webidl',
     'MutationEvent.webidl',
     'MutationObserver.webidl',
     'NetDashboard.webidl',
     'Node.webidl',
     'NodeFilter.webidl',
     'NodeIterator.webidl',
     'NodeList.webidl',
     'Notification.webidl',