Backed out 9 changesets (bug 838146) for suspected B2G Mn orange on a CLOSED TREE.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 12 Jul 2013 18:15:10 -0400
changeset 150698 33fb417caccf3fb5b2676d9d119f2f9e9ab71447
parent 150697 417682db13bdac13cffb8676650c555d8fceb7b3
child 150699 67eb0198434e93de33312c01cd58cb0c8654130c
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs838146
milestone25.0a1
backs out955a14e3c18138598b4d5a5244bc5bc61d2260d6
fddccc5fce6ec0376570263bb80e7014145d9a7e
7cddfebc261c604ca1f83cbd6a972392cca00705
fd3a62dd39104255c2130d7b5a493afb43e42cd0
f06b420e0dfa610a1a2e95ecfdbab0fef586d652
e0c3d84965cfb596113d4ce5df46eb78debd19e6
d3b135e58350b949872337e647b85bbc3290f88f
1bc7f216750320b2cfa936e9de6166f6dcc62d10
483fbc6878a8ecd493006eba4ef7ecfedc6a8e2a
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
Backed out 9 changesets (bug 838146) for suspected B2G Mn orange on a CLOSED TREE. Backed out changeset 955a14e3c181 (bug 838146) Backed out changeset fddccc5fce6e (bug 838146) Backed out changeset 7cddfebc261c (bug 838146) Backed out changeset fd3a62dd3910 (bug 838146) Backed out changeset f06b420e0dfa (bug 838146) Backed out changeset e0c3d84965cf (bug 838146) Backed out changeset d3b135e58350 (bug 838146) Backed out changeset 1bc7f2167503 (bug 838146) Backed out changeset 483fbc6878a8 (bug 838146)
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsDOMClassInfo.cpp
dom/bindings/Bindings.conf
dom/bindings/Codegen.py
dom/bindings/Makefile.in
dom/bluetooth/BluetoothManager.cpp
dom/bluetooth/BluetoothManager.h
dom/camera/DOMCameraManager.cpp
dom/camera/DOMCameraManager.h
dom/media/MediaManager.cpp
dom/media/tests/crashtests/802982.html
dom/media/tests/mochitest/test_getUserMedia_exceptions.html
dom/mobilemessage/src/SmsManager.cpp
dom/mobilemessage/src/SmsManager.h
dom/mobilemessage/tests/test_sms_basics.html
dom/power/PowerManager.cpp
dom/power/PowerManager.h
dom/telephony/Telephony.cpp
dom/telephony/Telephony.h
dom/telephony/TelephonyFactory.h
dom/tests/mochitest/general/test_idleapi_permissions.html
dom/tests/mochitest/general/test_vibrator.html
dom/webidl/Navigator.webidl
dom/webidl/WebIDL.mk
dom/workers/RuntimeService.cpp
dom/workers/test/test_navigator.html
js/xpconnect/tests/chrome/test_weakmaps.xul
js/xpconnect/tests/mochitest/file_crosscompartment_weakmap.html
js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.html
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -53,35 +53,30 @@
 #include "nsNetUtil.h"
 #include "nsIHttpChannel.h"
 #include "TimeManager.h"
 
 #ifdef MOZ_MEDIA_NAVIGATOR
 #include "MediaManager.h"
 #endif
 #ifdef MOZ_B2G_RIL
-#include "Telephony.h"
+#include "TelephonyFactory.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
 
 #include "nsIDOMGlobalPropertyInitializer.h"
-#include "nsJSUtils.h"
-
-#include "nsScriptNameSpaceManager.h"
-
-#include "mozilla/dom/NavigatorBinding.h"
 
 using namespace mozilla::dom::power;
 
 // This should not be in the namespace.
 DOMCI_DATA(Navigator, mozilla::dom::Navigator)
 
 namespace mozilla {
 namespace dom {
@@ -106,17 +101,16 @@ Navigator::Init()
                                "dom.vibrator.max_vibrate_list_len", 128);
 }
 
 Navigator::Navigator(nsPIDOMWindow* aWindow)
   : mWindow(aWindow)
 {
   NS_ASSERTION(aWindow->IsInnerWindow(),
                "Navigator must get an inner window!");
-  SetIsDOMBinding();
 }
 
 Navigator::~Navigator()
 {
   Invalidate();
 }
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Navigator)
@@ -363,18 +357,17 @@ NS_IMETHODIMP
 Navigator::GetAppVersion(nsAString& aAppVersion)
 {
   return NS_GetNavigatorAppVersion(aAppVersion);
 }
 
 NS_IMETHODIMP
 Navigator::GetAppName(nsAString& aAppName)
 {
-  NS_GetNavigatorAppName(aAppName);
-  return NS_OK;
+  return NS_GetNavigatorAppName(aAppName);
 }
 
 /**
  * JS property navigator.language, exposed to web content.
  * Take first value from Accept-Languages (HTTP header), which is
  * the "content language" freely set by the user in the Pref window.
  *
  * Do not use UI language (chosen app locale) here.
@@ -487,130 +480,99 @@ Navigator::GetProductSub(nsAString& aPro
   // Legacy build ID hardcoded for backward compatibility (bug 776376)
   aProductSub.AssignLiteral("20100101");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::GetMimeTypes(nsISupports** aMimeTypes)
 {
-  ErrorResult rv;
-  NS_IF_ADDREF(*aMimeTypes = GetMimeTypes(rv));
-  return rv.ErrorCode();
-}
-
-nsMimeTypeArray*
-Navigator::GetMimeTypes(ErrorResult& aRv)
-{
   if (!mMimeTypes) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
+    NS_ENSURE_STATE(mWindow);
     nsWeakPtr win = do_GetWeakReference(mWindow);
     mMimeTypes = new nsMimeTypeArray(win);
   }
 
-  return mMimeTypes;
+  NS_ADDREF(*aMimeTypes = mMimeTypes);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::GetPlugins(nsISupports** aPlugins)
 {
-  ErrorResult rv;
-  NS_IF_ADDREF(*aPlugins = static_cast<nsIObserver*>(GetPlugins(rv)));
-  return rv.ErrorCode();
-}
-
-nsPluginArray*
-Navigator::GetPlugins(ErrorResult& aRv)
-{
   if (!mPlugins) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
+    NS_ENSURE_STATE(mWindow);
     nsWeakPtr win = do_GetWeakReference(mWindow);
     mPlugins = new nsPluginArray(win);
     mPlugins->Init();
   }
 
-  return mPlugins;
+  NS_ADDREF(*aPlugins = static_cast<nsIObserver*>(mPlugins.get()));
+
+  return NS_OK;
 }
 
 // Values for the network.cookie.cookieBehavior pref are documented in
 // nsCookieService.cpp.
 #define COOKIE_BEHAVIOR_REJECT 2
 
 NS_IMETHODIMP
 Navigator::GetCookieEnabled(bool* aCookieEnabled)
 {
-  *aCookieEnabled = CookieEnabled();
-  return NS_OK;
-}
-
-bool
-Navigator::CookieEnabled()
-{
-  bool cookieEnabled =
+  *aCookieEnabled =
     (Preferences::GetInt("network.cookie.cookieBehavior",
                          COOKIE_BEHAVIOR_REJECT) != COOKIE_BEHAVIOR_REJECT);
 
   // Check whether an exception overrides the global cookie behavior
   // Note that the code for getting the URI here matches that in
   // nsHTMLDocument::SetCookie.
   if (!mWindow || !mWindow->GetDocShell()) {
-    return cookieEnabled;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
   if (!doc) {
-    return cookieEnabled;
+    return NS_OK;
   }
 
   nsCOMPtr<nsIURI> codebaseURI;
   doc->NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
 
   if (!codebaseURI) {
     // Not a codebase, so technically can't set cookies, but let's
     // just return the default value.
-    return cookieEnabled;
+    return NS_OK;
   }
 
   nsCOMPtr<nsICookiePermission> permMgr =
     do_GetService(NS_COOKIEPERMISSION_CONTRACTID);
-  NS_ENSURE_TRUE(permMgr, cookieEnabled);
+  NS_ENSURE_TRUE(permMgr, NS_OK);
 
   // Pass null for the channel, just like the cookie service does.
   nsCookieAccess access;
   nsresult rv = permMgr->CanAccess(codebaseURI, nullptr, &access);
-  NS_ENSURE_SUCCESS(rv, cookieEnabled);
+  NS_ENSURE_SUCCESS(rv, NS_OK);
 
   if (access != nsICookiePermission::ACCESS_DEFAULT) {
-    cookieEnabled = access != nsICookiePermission::ACCESS_DENY;
+    *aCookieEnabled = access != nsICookiePermission::ACCESS_DENY;
   }
 
-  return cookieEnabled;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::GetOnLine(bool* aOnline)
 {
   NS_PRECONDITION(aOnline, "Null out param");
 
-  *aOnline = OnLine();
+  *aOnline = !NS_IsOffline();
   return NS_OK;
 }
 
-bool
-Navigator::OnLine()
-{
-  return !NS_IsOffline();
-}
-
 NS_IMETHODIMP
 Navigator::GetBuildID(nsAString& aBuildID)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     const nsAdoptingString& override =
       Preferences::GetString("general.buildID.override");
 
     if (override) {
@@ -646,48 +608,41 @@ Navigator::GetDoNotTrack(nsAString &aRes
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::JavaEnabled(bool* aReturn)
 {
-  ErrorResult rv;
-  *aReturn = JavaEnabled(rv);
-  return rv.ErrorCode();
-}
-
-bool
-Navigator::JavaEnabled(ErrorResult& aRv)
-{
   Telemetry::AutoTimer<Telemetry::CHECK_JAVA_ENABLED> telemetryTimer;
   // Return true if we have a handler for "application/x-java-vm",
   // otherwise return false.
+  *aReturn = false;
+
   if (!mMimeTypes) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return false;
-    }
+    NS_ENSURE_STATE(mWindow);
     nsWeakPtr win = do_GetWeakReference(mWindow);
     mMimeTypes = new nsMimeTypeArray(win);
   }
 
   RefreshMIMEArray();
 
   nsMimeType *mimeType =
     mMimeTypes->NamedItem(NS_LITERAL_STRING("application/x-java-vm"));
 
-  return mimeType && mimeType->GetEnabledPlugin();
+  *aReturn = mimeType && mimeType->GetEnabledPlugin();
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::TaintEnabled(bool *aReturn)
 {
-  *aReturn = TaintEnabled();
+  *aReturn = false;
   return NS_OK;
 }
 
 void
 Navigator::RefreshMIMEArray()
 {
   if (mMimeTypes) {
     mMimeTypes->Refresh();
@@ -795,83 +750,53 @@ Navigator::AddIdleObserver(nsIIdleObserv
   }
 
   NS_ENSURE_ARG_POINTER(aIdleObserver);
 
   if (!CheckPermission("idle")) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
-  AddIdleObserver(*aIdleObserver);
-  return NS_OK;
-}
-
-void
-Navigator::AddIdleObserver(nsIIdleObserver& aIdleObserver)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (NS_FAILED(mWindow->RegisterIdleObserver(&aIdleObserver))) {
+  if (NS_FAILED(mWindow->RegisterIdleObserver(aIdleObserver))) {
     NS_WARNING("Failed to add idle observer.");
   }
-}
 
-void
-Navigator::AddIdleObserver(MozIdleObserver& aIdleObserver, ErrorResult& aRv)
-{
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
-  CallbackObjectHolder<MozIdleObserver, nsIIdleObserver> holder(&aIdleObserver);
-  nsCOMPtr<nsIIdleObserver> obs = holder.ToXPCOMCallback();
-  return AddIdleObserver(*obs);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::RemoveIdleObserver(nsIIdleObserver* aIdleObserver)
 {
   NS_ENSURE_STATE(mWindow);
 
   if (!nsContentUtils::IsIdleObserverAPIEnabled()) {
     NS_WARNING("The IdleObserver API has been disabled");
     return NS_OK;
   }
 
   NS_ENSURE_ARG_POINTER(aIdleObserver);
 
-  RemoveIdleObserver(*aIdleObserver);
-  return NS_OK;
-}
-
-void
-Navigator::RemoveIdleObserver(nsIIdleObserver& aIdleObserver)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (NS_FAILED(mWindow->UnregisterIdleObserver(&aIdleObserver))) {
+  if (NS_FAILED(mWindow->UnregisterIdleObserver(aIdleObserver))) {
     NS_WARNING("Failed to remove idle observer.");
   }
-}
-
-void
-Navigator::RemoveIdleObserver(MozIdleObserver& aIdleObserver, ErrorResult& aRv)
-{
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
-  CallbackObjectHolder<MozIdleObserver, nsIIdleObserver> holder(&aIdleObserver);
-  nsCOMPtr<nsIIdleObserver> obs = holder.ToXPCOMCallback();
-  return RemoveIdleObserver(*obs);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
 {
+  NS_ENSURE_STATE(mWindow);
+
+  nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
+  NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
+  if (doc->Hidden()) {
+    // Hidden documents cannot start or stop a vibration.
+    return NS_OK;
+  }
+
   nsAutoTArray<uint32_t, 8> pattern;
 
   // null or undefined pattern is an error.
   if (JSVAL_IS_NULL(aPattern) || JSVAL_IS_VOID(aPattern)) {
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   if (JSVAL_IS_PRIMITIVE(aPattern)) {
@@ -899,81 +824,38 @@ Navigator::Vibrate(const JS::Value& aPat
         pattern[i] = pv;
       }
       else {
         return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       }
     }
   }
 
-  ErrorResult rv;
-  Vibrate(pattern, rv);
-  return rv.ErrorCode();
-}
-
-void
-Navigator::Vibrate(uint32_t aDuration, ErrorResult& aRv)
-{
-  nsAutoTArray<uint32_t, 1> pattern;
-  pattern.AppendElement(aDuration);
-  Vibrate(pattern, aRv);
-}
-
-void
-Navigator::Vibrate(const nsTArray<uint32_t>& aPattern, ErrorResult& aRv)
-{
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
-  nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
-  if (!doc) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-  if (doc->Hidden()) {
-    // Hidden documents cannot start or stop a vibration.
-    return;
-  }
-
-  if (aPattern.Length() > sMaxVibrateListLen) {
-    // XXXbz this should be returning false instead
-    aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
-    return;
-  }
-
-  for (size_t i = 0; i < aPattern.Length(); ++i) {
-    if (aPattern[i] > sMaxVibrateMS) {
-      // XXXbz this should be returning false instead
-      aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
-      return;
-    }
-  }
-
   // The spec says we check sVibratorEnabled after we've done the sanity
   // checking on the pattern.
   if (!sVibratorEnabled) {
-    return;
+    return NS_OK;
   }
 
   // Add a listener to cancel the vibration if the document becomes hidden,
   // and remove the old visibility listener, if there was one.
 
   if (!gVibrateWindowListener) {
     // If gVibrateWindowListener is null, this is the first time we've vibrated,
     // and we need to register a listener to clear gVibrateWindowListener on
     // shutdown.
     ClearOnShutdown(&gVibrateWindowListener);
   }
   else {
     gVibrateWindowListener->RemoveListener();
   }
   gVibrateWindowListener = new VibrateWindowListener(mWindow, doc);
 
-  hal::Vibrate(aPattern, mWindow);
+  hal::Vibrate(pattern, mWindow);
+  return NS_OK;
 }
 
 //*****************************************************************************
 //    Navigator::nsIDOMClientInformation
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::RegisterContentHandler(const nsAString& aMIMEType,
@@ -1097,127 +979,100 @@ NS_IMETHODIMP Navigator::GetDeviceStorag
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nullptr;
 
   if (!Preferences::GetBool("device.storage.enabled", false)) {
     return NS_OK;
   }
 
-  ErrorResult rv;
-  NS_IF_ADDREF(*_retval = GetDeviceStorage(aType, rv));
-  return rv.ErrorCode();
-}
-
-nsDOMDeviceStorage*
-Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the pref check here.
   if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
+    return NS_ERROR_FAILURE;
   }
 
   nsRefPtr<nsDOMDeviceStorage> storage;
   nsDOMDeviceStorage::CreateDeviceStorageFor(mWindow, aType,
                                              getter_AddRefs(storage));
 
   if (!storage) {
-    return nullptr;
+    return NS_OK;
   }
 
+  NS_ADDREF(*_retval = storage.get());
   mDeviceStorageStores.AppendElement(storage);
-  return storage;
+  return NS_OK;
 }
 
 NS_IMETHODIMP Navigator::GetDeviceStorages(const nsAString &aType, nsIVariant** _retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nullptr;
 
   if (!Preferences::GetBool("device.storage.enabled", false)) {
     return NS_OK;
   }
 
+  if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) {
+    return NS_ERROR_FAILURE;
+  }
+
   nsTArray<nsRefPtr<nsDOMDeviceStorage> > stores;
-  ErrorResult rv;
-  GetDeviceStorages(aType, stores, rv);
-  if (rv.Failed()) {
-    return rv.ErrorCode();
-  }
+  nsDOMDeviceStorage::CreateDeviceStoragesFor(mWindow, aType, stores, false);
 
   nsCOMPtr<nsIWritableVariant> result = do_CreateInstance("@mozilla.org/variant;1");
   NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
 
   if (stores.Length() == 0) {
     result->SetAsEmptyArray();
   } else {
     result->SetAsArray(nsIDataType::VTYPE_INTERFACE,
                        &NS_GET_IID(nsIDOMDeviceStorage),
                        stores.Length(),
                        const_cast<void*>(static_cast<const void*>(stores.Elements())));
   }
   result.forget(_retval);
 
+  mDeviceStorageStores.AppendElements(stores);
   return NS_OK;
 }
 
-void
-Navigator::GetDeviceStorages(const nsAString& aType,
-                             nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores,
-                             ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the pref check here.
-  if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  nsDOMDeviceStorage::CreateDeviceStoragesFor(mWindow, aType, aStores, false);
-
-  mDeviceStorageStores.AppendElements(aStores);
-}
-
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorGeolocation
 //*****************************************************************************
 
 NS_IMETHODIMP Navigator::GetGeolocation(nsIDOMGeoGeolocation** _retval)
 {
-  ErrorResult rv;
-  NS_IF_ADDREF(*_retval = GetGeolocation(rv));
-  return rv.ErrorCode();
-}
+  NS_ENSURE_ARG_POINTER(_retval);
+  *_retval = nullptr;
 
-Geolocation*
-Navigator::GetGeolocation(ErrorResult& aRv)
-{
   if (!Preferences::GetBool("geo.enabled", true)) {
-    return nullptr;
+    return NS_OK;
   }
 
   if (mGeolocation) {
-    return mGeolocation;
+    NS_ADDREF(*_retval = mGeolocation);
+    return NS_OK;
   }
 
   if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
+    return NS_ERROR_FAILURE;
   }
 
   mGeolocation = new Geolocation();
+  if (!mGeolocation) {
+    return NS_ERROR_FAILURE;
+  }
+
   if (NS_FAILED(mGeolocation->Init(mWindow->GetOuterWindow()))) {
     mGeolocation = nullptr;
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
+    return NS_ERROR_FAILURE;
   }
 
-  return mGeolocation;
+  NS_ADDREF(*_retval = mGeolocation);
+  return NS_OK;
 }
 
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorUserMedia (mozGetUserMedia)
 //*****************************************************************************
 #ifdef MOZ_MEDIA_NAVIGATOR
 NS_IMETHODIMP
 Navigator::MozGetUserMedia(nsIMediaStreamOptions* aParams,
@@ -1225,460 +1080,297 @@ Navigator::MozGetUserMedia(nsIMediaStrea
                            nsIDOMGetUserMediaErrorCallback* aOnError)
 {
   // Make enabling peerconnection enable getUserMedia() as well
   if (!(Preferences::GetBool("media.navigator.enabled", false) ||
         Preferences::GetBool("media.peerconnection.enabled", false))) {
     return NS_OK;
   }
 
-  ErrorResult rv;
-  MozGetUserMedia(aParams, aOnSuccess, aOnError, rv);
-  return rv.ErrorCode();
-}
-
-void
-Navigator::MozGetUserMedia(nsIMediaStreamOptions* aParams,
-                           MozDOMGetUserMediaSuccessCallback* aOnSuccess,
-                           MozDOMGetUserMediaErrorCallback* aOnError,
-                           ErrorResult& aRv)
-{
-  CallbackObjectHolder<MozDOMGetUserMediaSuccessCallback,
-                       nsIDOMGetUserMediaSuccessCallback> holder1(aOnSuccess);
-  nsCOMPtr<nsIDOMGetUserMediaSuccessCallback> onsucces =
-    holder1.ToXPCOMCallback();
-
-  CallbackObjectHolder<MozDOMGetUserMediaErrorCallback,
-                       nsIDOMGetUserMediaErrorCallback> holder2(aOnError);
-  nsCOMPtr<nsIDOMGetUserMediaErrorCallback> onerror = holder2.ToXPCOMCallback();
-
-  MozGetUserMedia(aParams, onsucces, onerror, aRv);
-}
-
-void
-Navigator::MozGetUserMedia(nsIMediaStreamOptions* aParams,
-                           nsIDOMGetUserMediaSuccessCallback* aOnSuccess,
-                           nsIDOMGetUserMediaErrorCallback* aOnError,
-                           ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the pref check here.
   if (!mWindow || !mWindow->GetOuterWindow() ||
       mWindow->GetOuterWindow()->GetCurrentInnerWindow() != mWindow) {
-    aRv.Throw(NS_ERROR_NOT_AVAILABLE);
-    return;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   bool privileged = nsContentUtils::IsChromeDoc(mWindow->GetExtantDoc());
 
   MediaManager* manager = MediaManager::Get();
-  aRv = manager->GetUserMedia(privileged, mWindow, aParams, aOnSuccess,
-                              aOnError);
+  return manager->GetUserMedia(privileged, mWindow, aParams, aOnSuccess,
+                               aOnError);
 }
 
 //*****************************************************************************
 //    Navigator::nsINavigatorUserMedia (mozGetUserMediaDevices)
 //*****************************************************************************
 NS_IMETHODIMP
 Navigator::MozGetUserMediaDevices(nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
                                   nsIDOMGetUserMediaErrorCallback* aOnError)
 {
+  if (!mWindow || !mWindow->GetOuterWindow() ||
+      mWindow->GetOuterWindow()->GetCurrentInnerWindow() != mWindow) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
+
   // Check if the caller is chrome privileged, bail if not
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_FAILURE;
   }
 
-  ErrorResult rv;
-  MozGetUserMediaDevices(aOnSuccess, aOnError, rv);
-  return rv.ErrorCode();
-}
-
-void
-Navigator::MozGetUserMediaDevices(MozGetUserMediaDevicesSuccessCallback* aOnSuccess,
-                                  MozDOMGetUserMediaErrorCallback* aOnError,
-                                  ErrorResult& aRv)
-{
-  CallbackObjectHolder<MozGetUserMediaDevicesSuccessCallback,
-                       nsIGetUserMediaDevicesSuccessCallback> holder1(aOnSuccess);
-  nsCOMPtr<nsIGetUserMediaDevicesSuccessCallback> onsucces =
-    holder1.ToXPCOMCallback();
-
-  CallbackObjectHolder<MozDOMGetUserMediaErrorCallback,
-                       nsIDOMGetUserMediaErrorCallback> holder2(aOnError);
-  nsCOMPtr<nsIDOMGetUserMediaErrorCallback> onerror = holder2.ToXPCOMCallback();
-
-  MozGetUserMediaDevices(onsucces, onerror, aRv);
-}
-
-void
-Navigator::MozGetUserMediaDevices(nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
-                                  nsIDOMGetUserMediaErrorCallback* aOnError,
-                                  ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the chromeonly check here.
-  if (!mWindow || !mWindow->GetOuterWindow() ||
-      mWindow->GetOuterWindow()->GetCurrentInnerWindow() != mWindow) {
-    aRv.Throw(NS_ERROR_NOT_AVAILABLE);
-    return;
-  }
-
   MediaManager* manager = MediaManager::Get();
-  aRv = manager->GetUserMediaDevices(mWindow, aOnSuccess, aOnError);
+  return manager->GetUserMediaDevices(mWindow, aOnSuccess, aOnError);
 }
 #endif
 
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorDesktopNotification
 //*****************************************************************************
 
 NS_IMETHODIMP Navigator::GetMozNotification(nsISupports** aRetVal)
 {
-  ErrorResult rv;
-  NS_IF_ADDREF(*aRetVal = GetMozNotification(rv));
-  return rv.ErrorCode();
-}
+  NS_ENSURE_ARG_POINTER(aRetVal);
+  *aRetVal = nullptr;
 
-DesktopNotificationCenter*
-Navigator::GetMozNotification(ErrorResult& aRv)
-{
   if (mNotification) {
-    return mNotification;
+    NS_ADDREF(*aRetVal = mNotification);
+    return NS_OK;
   }
 
-  if (!mWindow || !mWindow->GetDocShell()) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
+  NS_ENSURE_TRUE(mWindow && mWindow->GetDocShell(), NS_ERROR_FAILURE);
 
   mNotification = new DesktopNotificationCenter(mWindow);
-  return mNotification;
+
+  NS_ADDREF(*aRetVal = mNotification);
+  return NS_OK;
 }
 
 //*****************************************************************************
 //    Navigator::nsINavigatorBattery
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetBattery(nsISupports** aBattery)
 {
-  ErrorResult rv;
-  NS_IF_ADDREF(*aBattery = GetBattery(rv));
-  return rv.ErrorCode();
-}
+  if (!mBatteryManager) {
+    *aBattery = nullptr;
 
-battery::BatteryManager*
-Navigator::GetBattery(ErrorResult& aRv)
-{
-  if (!mBatteryManager) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-    NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
+    NS_ENSURE_STATE(mWindow);
+    NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK);
 
     mBatteryManager = new battery::BatteryManager();
     mBatteryManager->Init(mWindow);
   }
 
-  return mBatteryManager;
+  NS_ADDREF(*aBattery = mBatteryManager);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::GetMozPower(nsIDOMMozPowerManager** aPower)
 {
-  if (!PowerManager::CheckPermission(mWindow)) {
-    *aPower = nullptr;
-    return NS_OK;
-  }
-  ErrorResult rv;
-  NS_IF_ADDREF(*aPower = GetMozPower(rv));
-  return rv.ErrorCode();
-}
+  *aPower = nullptr;
 
-nsIDOMMozPowerManager*
-Navigator::GetMozPower(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
   if (!mPowerManager) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-    mPowerManager = PowerManager::CreateInstance(mWindow);
-    if (!mPowerManager) {
-      // We failed to get the power manager service?
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-    }
+    NS_ENSURE_STATE(mWindow);
+    mPowerManager = PowerManager::CheckPermissionAndCreateInstance(mWindow);
+    NS_ENSURE_TRUE(mPowerManager, NS_OK);
   }
 
-  return mPowerManager;
+  nsCOMPtr<nsIDOMMozPowerManager> power(mPowerManager);
+  power.forget(aPower);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 Navigator::RequestWakeLock(const nsAString &aTopic, nsIDOMMozWakeLock **aWakeLock)
 {
-  ErrorResult rv;
-  *aWakeLock = RequestWakeLock(aTopic, rv).get();
-  return rv.ErrorCode();
-}
+  NS_ENSURE_STATE(mWindow);
 
-already_AddRefed<nsIDOMMozWakeLock>
-Navigator::RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv)
-{
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
+  *aWakeLock = nullptr;
 
   nsCOMPtr<nsIPowerManagerService> pmService =
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
-  // Maybe it went away for some reason... Or maybe we're just called
-  // from our XPCOM method.
-  NS_ENSURE_TRUE(pmService, nullptr);
+  NS_ENSURE_TRUE(pmService, NS_OK);
 
-  nsCOMPtr<nsIDOMMozWakeLock> wakelock;
-  aRv = pmService->NewWakeLock(aTopic, mWindow, getter_AddRefs(wakelock));
-  return wakelock.forget();
+  return pmService->NewWakeLock(aTopic, mWindow, aWakeLock);
 }
 
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorSms
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager)
 {
+  *aSmsManager = nullptr;
+
   if (!mSmsManager) {
-    if (!mWindow || !SmsManager::CreationIsAllowed(mWindow)) {
-      *aSmsManager = nullptr;
-      return NS_OK;
-    }
+    NS_ENSURE_STATE(mWindow);
+    NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK);
+
+    mSmsManager = SmsManager::CreateInstanceIfAllowed(mWindow);
+    NS_ENSURE_TRUE(mSmsManager, NS_OK);
   }
 
-  NS_IF_ADDREF(*aSmsManager = GetMozSms());
-  return NS_OK;
-}
+  NS_ADDREF(*aSmsManager = mSmsManager);
 
-nsIDOMMozSmsManager*
-Navigator::GetMozSms()
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (!mSmsManager) {
-    NS_ENSURE_TRUE(mWindow, nullptr);
-    NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
-
-    mSmsManager = SmsManager::CreateInstance(mWindow);
-  }
-
-  return mSmsManager;
+  return NS_OK;
 }
 
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorMobileMessage
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozMobileMessage(nsIDOMMozMobileMessageManager** aMobileMessageManager)
 {
-  if (!HasMobileMessageSupport(mWindow)) {
-    *aMobileMessageManager = nullptr;
-    return NS_OK;
-  }
+  *aMobileMessageManager = nullptr;
 
-  NS_IF_ADDREF(*aMobileMessageManager = GetMozMobileMessage());
+#ifndef MOZ_WEBSMS_BACKEND
   return NS_OK;
-}
+#endif
 
-nsIDOMMozMobileMessageManager*
-Navigator::GetMozMobileMessage()
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
+  // First of all, the general pref has to be turned on.
+  bool enabled = false;
+  Preferences::GetBool("dom.sms.enabled", &enabled);
+  NS_ENSURE_TRUE(enabled, NS_OK);
+
   if (!mMobileMessageManager) {
-    // Check that our window has not gone away
-    NS_ENSURE_TRUE(mWindow, nullptr);
-    NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
+    NS_ENSURE_STATE(mWindow);
+    NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK);
+
+    if (!CheckPermission("sms")) {
+      return NS_OK;
+    }
 
     mMobileMessageManager = new MobileMessageManager();
     mMobileMessageManager->Init(mWindow);
   }
 
-  return mMobileMessageManager;
+  NS_ADDREF(*aMobileMessageManager = mMobileMessageManager);
+
+  return NS_OK;
 }
 
 #ifdef MOZ_B2G_RIL
 
 //*****************************************************************************
 //    Navigator::nsIMozNavigatorCellBroadcast
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozCellBroadcast(nsIDOMMozCellBroadcast** aCellBroadcast)
 {
-  if (!mCellBroadcast &&
-      !CheckPermission("cellbroadcast")) {
-    *aCellBroadcast = nullptr;
-    return NS_OK;
+  *aCellBroadcast = nullptr;
+
+  if (!mCellBroadcast) {
+    NS_ENSURE_STATE(mWindow);
+
+    if (!CheckPermission("cellbroadcast")) {
+      return NS_OK;
+    }
+
+    nsresult rv = NS_NewCellBroadcast(mWindow, getter_AddRefs(mCellBroadcast));
+    NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  ErrorResult rv;
-  NS_IF_ADDREF(*aCellBroadcast = GetMozCellBroadcast(rv));
-  return rv.ErrorCode();
-}
-
-nsIDOMMozCellBroadcast*
-Navigator::GetMozCellBroadcast(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (!mCellBroadcast) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-
-    aRv = NS_NewCellBroadcast(mWindow, getter_AddRefs(mCellBroadcast));
-    if (aRv.Failed()) {
-      return nullptr;
-    }
-  }
-
-  return mCellBroadcast;
+  NS_ADDREF(*aCellBroadcast = mCellBroadcast);
+  return NS_OK;
 }
 
 //*****************************************************************************
 //    nsNavigator::nsIDOMNavigatorTelephony
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozTelephony(nsIDOMTelephony** aTelephony)
 {
-  if (!mTelephony) {
+  nsCOMPtr<nsIDOMTelephony> telephony = mTelephony;
+
+  if (!telephony) {
     NS_ENSURE_STATE(mWindow);
-    if (!telephony::Telephony::CheckPermission(mWindow)) {
-      *aTelephony = nullptr;
-      return NS_OK;
-    }
+    nsresult rv = NS_NewTelephony(mWindow, getter_AddRefs(mTelephony));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    // mTelephony may be null here!
+    telephony = mTelephony;
   }
 
-  ErrorResult rv;
-  NS_IF_ADDREF(*aTelephony = GetMozTelephony(rv));
-  return rv.ErrorCode();
-}
-
-nsIDOMTelephony*
-Navigator::GetMozTelephony(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (!mTelephony) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-    mTelephony = telephony::Telephony::Create(mWindow, aRv);
-  }
-
-  return mTelephony;
+  telephony.forget(aTelephony);
+  return NS_OK;
 }
 
 //*****************************************************************************
 //    nsNavigator::nsINavigatorVoicemail
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozVoicemail(nsIDOMMozVoicemail** aVoicemail)
 {
-  if (!mVoicemail &&
-      !CheckPermission("voicemail")) {
-    *aVoicemail = nullptr;
-    return NS_OK;
+  *aVoicemail = nullptr;
+
+  if (!mVoicemail) {
+    NS_ENSURE_STATE(mWindow);
+    if (!CheckPermission("voicemail")) {
+      return NS_OK;
+    }
+
+    nsresult rv = NS_NewVoicemail(mWindow, getter_AddRefs(mVoicemail));
+    NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  ErrorResult rv;
-  NS_IF_ADDREF(*aVoicemail = GetMozVoicemail(rv));
-  return rv.ErrorCode();
-}
-
-nsIDOMMozVoicemail*
-Navigator::GetMozVoicemail(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (!mVoicemail) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-
-    aRv = NS_NewVoicemail(mWindow, getter_AddRefs(mVoicemail));
-    if (aRv.Failed()) {
-      return nullptr;
-    }
-  }
-
-  return mVoicemail;
+  NS_ADDREF(*aVoicemail = mVoicemail);
+  return NS_OK;
 }
 
 //*****************************************************************************
 //    nsNavigator::nsIMozNavigatorIccManager
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozIccManager(nsIDOMMozIccManager** aIccManager)
 {
-  if (!mIccManager &&
-      !CheckPermission("mobileconnection")) {
-    *aIccManager = nullptr;
-    return NS_OK;
-  }
-
-  ErrorResult rv;
-  NS_IF_ADDREF(*aIccManager = GetMozIccManager(rv));
-  return rv.ErrorCode();
-}
+  *aIccManager = nullptr;
 
-nsIDOMMozIccManager*
-Navigator::GetMozIccManager(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
   if (!mIccManager) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
+    NS_ENSURE_STATE(mWindow);
+    NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK);
+
+    if (!CheckPermission("mobileconnection")) {
+      return NS_OK;
     }
-    NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
 
     mIccManager = new icc::IccManager();
     mIccManager->Init(mWindow);
   }
 
-  return mIccManager;
+  NS_ADDREF(*aIccManager = mIccManager);
+  return NS_OK;
 }
 
 #endif // MOZ_B2G_RIL
 
 #ifdef MOZ_GAMEPAD
 //*****************************************************************************
 //    Navigator::nsINavigatorGamepads
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetGamepads(nsIVariant** aRetVal)
 {
-  ErrorResult rv;
+  NS_ENSURE_ARG_POINTER(aRetVal);
+  *aRetVal = nullptr;
+
+  NS_ENSURE_STATE(mWindow);
+  NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK);
+  nsGlobalWindow* win = static_cast<nsGlobalWindow*>(mWindow.get());
+
   nsAutoTArray<nsRefPtr<Gamepad>, 2> gamepads;
-  GetGamepads(gamepads, rv);
-  if (rv.Failed()) {
-    return rv.ErrorCode();
-  }
+  win->GetGamepads(gamepads);
 
   nsRefPtr<nsVariant> out = new nsVariant();
   NS_ENSURE_STATE(out);
 
   if (gamepads.Length() == 0) {
     nsresult rv = out->SetAsEmptyArray();
     NS_ENSURE_SUCCESS(rv, rv);
   } else {
@@ -1686,127 +1378,84 @@ Navigator::GetGamepads(nsIVariant** aRet
                     &NS_GET_IID(nsISupports),
                     gamepads.Length(),
                     const_cast<void*>(static_cast<const void*>(gamepads.Elements())));
   }
   out.forget(aRetVal);
 
   return NS_OK;
 }
-
-void
-Navigator::GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads,
-                       ErrorResult& aRv)
-{
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
-  NS_ENSURE_TRUE_VOID(mWindow->GetDocShell());
-  nsGlobalWindow* win = static_cast<nsGlobalWindow*>(mWindow.get());
-  win->GetGamepads(aGamepads);
-}
 #endif
 
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorNetwork
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozConnection(nsIDOMMozConnection** aConnection)
 {
-  NS_IF_ADDREF(*aConnection = GetMozConnection());
-  return NS_OK;
-}
+  *aConnection = nullptr;
 
-nsIDOMMozConnection*
-Navigator::GetMozConnection()
-{
   if (!mConnection) {
-    NS_ENSURE_TRUE(mWindow, nullptr);
-    NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
+    NS_ENSURE_STATE(mWindow);
+    NS_ENSURE_TRUE(mWindow->GetDocShell(), NS_OK);
 
     mConnection = new network::Connection();
     mConnection->Init(mWindow);
   }
 
-  return mConnection;
+  NS_ADDREF(*aConnection = mConnection);
+  return NS_OK;
 }
 
 #ifdef MOZ_B2G_RIL
 //*****************************************************************************
 //    Navigator::nsINavigatorMobileConnection
 //*****************************************************************************
 NS_IMETHODIMP
 Navigator::GetMozMobileConnection(nsIDOMMozMobileConnection** aMobileConnection)
 {
-  if (!mMobileConnection &&
-      !CheckPermission("mobileconnection") &&
-      !CheckPermission("mobilenetwork")) {
-    return NS_OK;
-  }
-
-  ErrorResult rv;
-  NS_IF_ADDREF(*aMobileConnection = GetMozMobileConnection(rv));
-  return rv.ErrorCode();
-}
+  *aMobileConnection = nullptr;
 
-nsIDOMMozMobileConnection*
-Navigator::GetMozMobileConnection(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
   if (!mMobileConnection) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
+    NS_ENSURE_STATE(mWindow);
+    if (!CheckPermission("mobileconnection") &&
+        !CheckPermission("mobilenetwork")) {
+      return NS_OK;
     }
+
     mMobileConnection = new network::MobileConnection();
     mMobileConnection->Init(mWindow);
   }
 
-  return mMobileConnection;
+  NS_ADDREF(*aMobileConnection = mMobileConnection);
+  return NS_OK;
 }
 #endif // MOZ_B2G_RIL
 
 #ifdef MOZ_B2G_BT
 //*****************************************************************************
 //    nsNavigator::nsIDOMNavigatorBluetooth
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozBluetooth(nsIDOMBluetoothManager** aBluetooth)
 {
-  if (!mBluetooth) {
+  nsCOMPtr<nsIDOMBluetoothManager> bluetooth = mBluetooth;
+
+  if (!bluetooth) {
     NS_ENSURE_STATE(mWindow);
-    if (!bluetooth::BluetoothManager::CheckPermission(mWindow)) {
-      *aBluetooth = nullptr;
-      return NS_OK;
-    }
+    nsresult rv = NS_NewBluetoothManager(mWindow, getter_AddRefs(mBluetooth));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    bluetooth = mBluetooth;
   }
 
-  ErrorResult rv;
-  NS_IF_ADDREF(*aBluetooth = GetMozBluetooth(rv));
-  return rv.ErrorCode();
-}
-
-nsIDOMBluetoothManager*
-Navigator::GetMozBluetooth(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (!mBluetooth) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-    mBluetooth = bluetooth::BluetoothManager::Create(mWindow);
-  }
-
-  return mBluetooth;
+  bluetooth.forget(aBluetooth);
+  return NS_OK;
 }
 #endif //MOZ_B2G_BT
 
 //*****************************************************************************
 //    nsNavigator::nsIDOMNavigatorSystemMessages
 //*****************************************************************************
 nsresult
 Navigator::EnsureMessagesManager()
@@ -1838,147 +1487,83 @@ Navigator::EnsureMessagesManager()
 
 NS_IMETHODIMP
 Navigator::MozHasPendingMessage(const nsAString& aType, bool *aResult)
 {
   if (!Preferences::GetBool("dom.sysmsg.enabled", false)) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
-  ErrorResult rv;
-  *aResult = MozHasPendingMessage(aType, rv);
-  return rv.ErrorCode();
-}
-
-bool
-Navigator::MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv)
-{
-  // The WebIDL binding is responsible for the pref check here.
+  *aResult = false;
   nsresult rv = EnsureMessagesManager();
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return false;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  bool result = false;
-  rv = mMessagesManager->MozHasPendingMessage(aType, &result);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return false;
-  }
-  return result;
+  return mMessagesManager->MozHasPendingMessage(aType, aResult);
 }
 
 NS_IMETHODIMP
 Navigator::MozSetMessageHandler(const nsAString& aType,
                                 nsIDOMSystemMessageCallback *aCallback)
 {
   if (!Preferences::GetBool("dom.sysmsg.enabled", false)) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   nsresult rv = EnsureMessagesManager();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return mMessagesManager->MozSetMessageHandler(aType, aCallback);
 }
 
-void
-Navigator::MozSetMessageHandler(const nsAString& aType,
-                                systemMessageCallback* aCallback,
-                                ErrorResult& aRv)
-{
-  // The WebIDL binding is responsible for the pref check here.
-  nsresult rv = EnsureMessagesManager();
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return;
-  }
-
-  CallbackObjectHolder<systemMessageCallback, nsIDOMSystemMessageCallback>
-    holder(aCallback);
-  nsCOMPtr<nsIDOMSystemMessageCallback> callback = holder.ToXPCOMCallback();
-
-  rv = mMessagesManager->MozSetMessageHandler(aType, callback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-  }
-}
-
 //*****************************************************************************
 //    Navigator::nsIDOMNavigatorTime
 //*****************************************************************************
 #ifdef MOZ_TIME_MANAGER
 NS_IMETHODIMP
 Navigator::GetMozTime(nsISupports** aTime)
 {
+  *aTime = nullptr;
+
+  NS_ENSURE_STATE(mWindow);
   if (!CheckPermission("time")) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
-  ErrorResult rv;
-  NS_IF_ADDREF(*aTime = GetMozTime(rv));
-  return rv.ErrorCode();
-}
-
-time::TimeManager*
-Navigator::GetMozTime(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (!mWindow) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-
   if (!mTimeManager) {
     mTimeManager = new time::TimeManager(mWindow);
   }
 
-  return mTimeManager;
+  NS_ADDREF(*aTime = mTimeManager);
+  return NS_OK;
 }
 #endif
 
 //*****************************************************************************
 //    nsNavigator::nsIDOMNavigatorCamera
 //*****************************************************************************
 
 NS_IMETHODIMP
 Navigator::GetMozCameras(nsISupports** aCameraManager)
 {
   if (!mCameraManager) {
-    NS_ENSURE_STATE(mWindow);
-    if (!nsDOMCameraManager::CheckPermission(mWindow)) {
-      *aCameraManager = nullptr;
-      return NS_OK;
-    }
-  }
-
-  ErrorResult rv;
-  NS_IF_ADDREF(*aCameraManager = static_cast<nsIObserver*>(GetMozCameras(rv)));
-  return rv.ErrorCode();
-}
-
-nsDOMCameraManager*
-Navigator::GetMozCameras(ErrorResult& aRv)
-{
-  // Callers (either the XPCOM method or the WebIDL binding) are responsible for
-  // the permission check here.
-  if (!mCameraManager) {
     if (!mWindow ||
         !mWindow->GetOuterWindow() ||
         mWindow->GetOuterWindow()->GetCurrentInnerWindow() != mWindow) {
-      aRv.Throw(NS_ERROR_NOT_AVAILABLE);
-      return nullptr;
+      return NS_ERROR_NOT_AVAILABLE;
     }
 
-    mCameraManager = nsDOMCameraManager::CreateInstance(mWindow);
+    mCameraManager =
+      nsDOMCameraManager::CheckPermissionAndCreateInstance(mWindow);
+    NS_ENSURE_TRUE(mCameraManager, NS_OK);
   }
 
-  return mCameraManager;
+  nsCOMPtr<nsIObserver> cameraManager = mCameraManager.get();
+  cameraManager.forget(aCameraManager);
+
+  return NS_OK;
 }
 
 size_t
 Navigator::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
 
   // TODO: add SizeOfIncludingThis() to nsMimeTypeArray, bug 674113.
@@ -2014,354 +1599,49 @@ Navigator::OnNavigation()
   if (mCameraManager) {
     mCameraManager->OnNavigation(mWindow->WindowID());
   }
 }
 
 bool
 Navigator::CheckPermission(const char* type)
 {
-  return CheckPermission(mWindow, type);
-}
-
-/* static */
-bool
-Navigator::CheckPermission(nsPIDOMWindow* aWindow, const char* aType)
-{
-  if (!aWindow) {
+  if (!mWindow) {
     return false;
   }
 
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
   NS_ENSURE_TRUE(permMgr, false);
 
   uint32_t permission = nsIPermissionManager::DENY_ACTION;
-  permMgr->TestPermissionFromWindow(aWindow, aType, &permission);
+  permMgr->TestPermissionFromWindow(mWindow, type, &permission);
   return permission == nsIPermissionManager::ALLOW_ACTION;
 }
 
 //*****************************************************************************
 //    Navigator::nsINavigatorAudioChannelManager
 //*****************************************************************************
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
 NS_IMETHODIMP
 Navigator::GetMozAudioChannelManager(nsISupports** aAudioChannelManager)
 {
-  ErrorResult rv;
-  NS_IF_ADDREF(*aAudioChannelManager = GetMozAudioChannelManager(rv));
-  return rv.ErrorCode();
-}
+  *aAudioChannelManager = nullptr;
 
-system::AudioChannelManager*
-Navigator::GetMozAudioChannelManager(ErrorResult& aRv)
-{
   if (!mAudioChannelManager) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
+    NS_ENSURE_STATE(mWindow);
     mAudioChannelManager = new system::AudioChannelManager();
     mAudioChannelManager->Init(mWindow);
   }
 
-  return mAudioChannelManager;
+  NS_ADDREF(*aAudioChannelManager = mAudioChannelManager);
+  return NS_OK;
 }
 #endif
 
-bool
-Navigator::DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
-                        JS::Handle<jsid> aId, unsigned aFlags,
-                        JS::MutableHandle<JSObject*> aObjp)
-{
-  if (!JSID_IS_STRING(aId)) {
-    return true;
-  }
-
-  nsScriptNameSpaceManager *nameSpaceManager =
-    nsJSRuntime::GetNameSpaceManager();
-  if (!nameSpaceManager) {
-    return Throw<true>(aCx, NS_ERROR_NOT_INITIALIZED);
-  }
-
-  nsDependentJSString name(aId);
-
-  const nsGlobalNameStruct* name_struct =
-    nameSpaceManager->LookupNavigatorName(name);
-  if (!name_struct) {
-    return true;
-  }
-
-  if (name_struct->mType == nsGlobalNameStruct::eTypeNewDOMBinding) {
-    ConstructNavigatorProperty construct = name_struct->mConstructNavigatorProperty;
-    MOZ_ASSERT(construct);
-
-    JS::Rooted<JSObject*> naviObj(aCx,
-                                  js::CheckedUnwrap(aObject,
-                                                    /* stopAtOuter = */ false));
-    if (!naviObj) {
-      return Throw<true>(aCx, NS_ERROR_DOM_SECURITY_ERR);
-    }
-
-    JS::Rooted<JSObject*> domObject(aCx);
-    {
-      JSAutoCompartment ac(aCx, naviObj);
-
-      // Check whether our constructor is enabled after we unwrap Xrays, since
-      // we don't want to define an interface on the Xray if it's disabled in
-      // the target global, even if it's enabled in the Xray's global.
-      if (name_struct->mConstructorEnabled &&
-          !(*name_struct->mConstructorEnabled)(aCx, naviObj)) {
-        return true;
-      }
-
-      domObject = construct(aCx, naviObj);
-      if (!domObject) {
-        return Throw<true>(aCx, NS_ERROR_FAILURE);
-      }
-    }
-
-    if (!JS_WrapObject(aCx, domObject.address()) ||
-        !JS_DefinePropertyById(aCx, aObject, aId,
-                               JS::ObjectValue(*domObject),
-                               nullptr, nullptr, JSPROP_ENUMERATE)) {
-      return false;
-    }
-
-    aObjp.set(aObject);
-
-    return true;
-  }
-
-  NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeNavigatorProperty,
-               "unexpected type");
-
-  nsresult rv = NS_OK;
-
-  nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
-  if (NS_FAILED(rv)) {
-    return Throw<true>(aCx, rv);
-  }
-
-  JS::Rooted<JS::Value> prop_val(aCx, JS::UndefinedValue()); // Property value.
-
-  nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
-
-  if (gpi) {
-    if (!mWindow) {
-      return Throw<true>(aCx, NS_ERROR_UNEXPECTED);
-    }
-
-    rv = gpi->Init(mWindow, prop_val.address());
-    if (NS_FAILED(rv)) {
-      return Throw<true>(aCx, rv);
-    }
-  }
-
-  if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
-    nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
-    rv = nsContentUtils::WrapNative(aCx, aObject, native, prop_val.address(),
-                                    getter_AddRefs(holder), true);
-
-    if (NS_FAILED(rv)) {
-      return Throw<true>(aCx, rv);
-    }
-  }
-
-  if (!JS_WrapValue(aCx, prop_val.address())) {
-    return Throw<true>(aCx, NS_ERROR_UNEXPECTED);
-  }
-
-  JSBool ok = ::JS_DefinePropertyById(aCx, aObject, aId, prop_val,
-                                      JS_PropertyStub, JS_StrictPropertyStub,
-                                      JSPROP_ENUMERATE);
-
-  aObjp.set(aObject);
-
-  return ok;
-}
-
-JSObject*
-Navigator::WrapObject(JSContext* cx, JS::Handle<JSObject*> scope)
-{
-  return NavigatorBinding::Wrap(cx, scope, this);
-}
-
-/* static */
-bool
-Navigator::HasBatterySupport(JSContext* /* unused*/, JSObject* /*unused */)
-{
-  return battery::BatteryManager::HasSupport();
-}
-
-/* static */
-bool
-Navigator::HasPowerSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && PowerManager::CheckPermission(win);
-}
-
-/* static */
-bool
-Navigator::HasIdleSupport(JSContext*  /* unused */, JSObject* aGlobal)
-{
-  if (!nsContentUtils::IsIdleObserverAPIEnabled()) {
-    return false;
-  }
-
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return CheckPermission(win, "idle");
-}
-
-/* static */
-bool
-Navigator::HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */)
-{
-  nsCOMPtr<nsIPowerManagerService> pmService =
-    do_GetService(POWERMANAGERSERVICE_CONTRACTID);
-  // No service means no wake lock support
-  return !!pmService;
-}
-
-/* static */
-bool
-Navigator::HasSmsSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && SmsManager::CreationIsAllowed(win);
-}
-
-/* static */
-bool
-Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return HasMobileMessageSupport(win);
-}
-
-/* static */
-bool
-Navigator::HasMobileMessageSupport(nsPIDOMWindow* aWindow)
-{
-#ifndef MOZ_WEBSMS_BACKEND
-  return false;
-#endif
-
-  // First of all, the general pref has to be turned on.
-  bool enabled = false;
-  Preferences::GetBool("dom.sms.enabled", &enabled);
-  NS_ENSURE_TRUE(enabled, false);
-
-  NS_ENSURE_TRUE(aWindow, false);
-  NS_ENSURE_TRUE(aWindow->GetDocShell(), false);
-
-  if (!CheckPermission(aWindow, "sms")) {
-    return false;
-  }
-
-  return true;
-}
-
-/* static */
-bool
-Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && nsDOMCameraManager::CheckPermission(win);
-}
-
-#ifdef MOZ_B2G_RIL
-/* static */
-bool
-Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && telephony::Telephony::CheckPermission(win);
-}
-
-/* static */
-bool
-Navigator::HasMobileConnectionSupport(JSContext* /* unused */,
-                                      JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && (CheckPermission(win, "mobileconnection") ||
-                 CheckPermission(win, "mobilenetwork"));
-}
-
-/* static */
-bool
-Navigator::HasCellBroadcastSupport(JSContext* /* unused */,
-                                   JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && CheckPermission(win, "cellbroadcast");
-}
-
-/* static */
-bool
-Navigator::HasVoicemailSupport(JSContext* /* unused */,
-                               JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && CheckPermission(win, "voicemail");
-}
-
-/* static */
-bool
-Navigator::HasIccManagerSupport(JSContext* /* unused */,
-                                JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && CheckPermission(win, "mobileconnection");
-}
-#endif // MOZ_B2G_RIL
-
-#ifdef MOZ_B2G_BT
-/* static */
-bool
-Navigator::HasBluetoothSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && bluetooth::BluetoothManager::CheckPermission(win);
-}
-#endif // MOZ_B2G_BT
-
-#ifdef MOZ_TIME_MANAGER
-/* static */
-bool
-Navigator::HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && CheckPermission(win, "time");
-}
-#endif // MOZ_TIME_MANAGER
-
-#ifdef MOZ_MEDIA_NAVIGATOR
-/* static */
-bool Navigator::HasUserMediaSupport(JSContext* /* unused */,
-                                    JSObject* /* unused */)
-{
-  // Make enabling peerconnection enable getUserMedia() as well
-  return Preferences::GetBool("media.navigator.enabled", false) ||
-         Preferences::GetBool("media.peerconnection.enabled", false);
-}
-#endif // MOZ_MEDIA_NAVIGATOR
-
-/* static */
-already_AddRefed<nsPIDOMWindow>
-Navigator::GetWindowFromGlobal(JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win =
-    do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(aGlobal));
-  MOZ_ASSERT(!win || win->IsInnerWindow());
-  return win.forget();
-}
-
 } // namespace dom
 } // namespace mozilla
 
 nsresult
 NS_GetNavigatorUserAgent(nsAString& aUserAgent)
 {
   nsresult rv;
 
@@ -2450,22 +1730,24 @@ NS_GetNavigatorAppVersion(nsAString& aAp
   NS_ENSURE_SUCCESS(rv, rv);
 
   AppendASCIItoUTF16(str, aAppVersion);
   aAppVersion.Append(PRUnichar(')'));
 
   return rv;
 }
 
-void
+nsresult
 NS_GetNavigatorAppName(nsAString& aAppName)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     const nsAdoptingString& override =
       mozilla::Preferences::GetString("general.appname.override");
 
     if (override) {
       aAppName = override;
+      return NS_OK;
     }
   }
 
   aAppName.AssignLiteral("Netscape");
+  return NS_OK;
 }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -35,17 +35,16 @@
 class nsPluginArray;
 class nsMimeTypeArray;
 class nsPIDOMWindow;
 class nsIDOMMozConnection;
 
 namespace mozilla {
 namespace dom {
 class Geolocation;
-class systemMessageCallback;
 }
 }
 
 #ifdef MOZ_MEDIA_NAVIGATOR
 #include "nsIDOMNavigatorUserMedia.h"
 #endif
 
 #ifdef MOZ_B2G_RIL
@@ -65,37 +64,26 @@ class nsIDOMTelephony;
 #ifdef MOZ_GAMEPAD
 #include "nsINavigatorGamepads.h"
 #endif
 
 //*****************************************************************************
 // Navigator: Script "navigator" object
 //*****************************************************************************
 
-void NS_GetNavigatorAppName(nsAString& aAppName);
-
 namespace mozilla {
 namespace dom {
 
 namespace battery {
 class BatteryManager;
 } // namespace battery
 
 class DesktopNotificationCenter;
 class SmsManager;
 class MobileMessageManager;
-class MozIdleObserver;
-#ifdef MOZ_GAMEPAD
-class Gamepad;
-#endif // MOZ_GAMEPAD
-#ifdef MOZ_MEDIA_NAVIGATOR
-class MozDOMGetUserMediaSuccessCallback;
-class MozDOMGetUserMediaErrorCallback;
-class MozGetUserMediaDevicesSuccessCallback;
-#endif // MOZ_MEDIA_NAVIGATOR
 
 namespace icc {
 #ifdef MOZ_B2G_RIL
 class IccManager;
 #endif
 }
 
 namespace network {
@@ -199,17 +187,17 @@ public:
 #endif
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   NS_DECL_NSIMOZNAVIGATORAUDIOCHANNELMANAGER
 #endif
   static void Init();
 
   void Invalidate();
-  nsPIDOMWindow *GetWindow() const
+  nsPIDOMWindow *GetWindow()
   {
     return mWindow;
   }
 
   void RefreshMIMEArray();
 
   static bool HasDesktopNotificationSupport();
 
@@ -225,197 +213,18 @@ public:
    */
   void OnNavigation();
 
   // Helper to initialize mMessagesManager.
   nsresult EnsureMessagesManager();
 
   NS_DECL_NSIDOMNAVIGATORCAMERA
 
-  // WebIDL API
-  void GetAppName(nsString& aAppName)
-  {
-    NS_GetNavigatorAppName(aAppName);
-  }
-  void GetAppVersion(nsString& aAppVersion, ErrorResult& aRv)
-  {
-    aRv = GetAppVersion(aAppVersion);
-  }
-  void GetPlatform(nsString& aPlatform, ErrorResult& aRv)
-  {
-    aRv = GetPlatform(aPlatform);
-  }
-  void GetUserAgent(nsString& aUserAgent, ErrorResult& aRv)
-  {
-    aRv = GetUserAgent(aUserAgent);
-  }
-  // The XPCOM GetProduct is OK
-  // The XPCOM GetLanguage is OK
-  bool OnLine();
-  void RegisterProtocolHandler(const nsAString& aScheme, const nsAString& aURL,
-                               const nsAString& aTitle, ErrorResult& rv)
-  {
-    rv = RegisterProtocolHandler(aScheme, aURL, aTitle);
-  }
-  void RegisterContentHandler(const nsAString& aMIMEType, const nsAString& aURL,
-                              const nsAString& aTitle, ErrorResult& rv)
-  {
-    rv = RegisterContentHandler(aMIMEType, aURL, aTitle);
-  }
-  nsMimeTypeArray* GetMimeTypes(ErrorResult& aRv);
-  nsPluginArray* GetPlugins(ErrorResult& aRv);
-  // The XPCOM GetDoNotTrack is ok
-  Geolocation* GetGeolocation(ErrorResult& aRv);
-  battery::BatteryManager* GetBattery(ErrorResult& aRv);
-  void Vibrate(uint32_t aDuration, ErrorResult& aRv);
-  void Vibrate(const nsTArray<uint32_t>& aDuration, ErrorResult& aRv);
-  void GetAppCodeName(nsString& aAppCodeName, ErrorResult& aRv)
-  {
-    aRv = GetAppCodeName(aAppCodeName);
-  }
-  void GetOscpu(nsString& aOscpu, ErrorResult& aRv)
-  {
-    aRv = GetOscpu(aOscpu);
-  }
-  // 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);
-  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);
-  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)
-  {
-    bool available = false;
-    aRv = MozIsLocallyAvailable(aURI, aWhenOffline, &available);
-    return available;
-  }
-  nsIDOMMozSmsManager* GetMozSms();
-  nsIDOMMozMobileMessageManager* GetMozMobileMessage();
-  nsIDOMMozConnection* 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
-  nsIDOMTelephony* GetMozTelephony(ErrorResult& aRv);
-  nsIDOMMozMobileConnection* GetMozMobileConnection(ErrorResult& aRv);
-  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);
-#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
-  void MozGetUserMedia(nsIMediaStreamOptions* aParams,
-                       MozDOMGetUserMediaSuccessCallback* aOnSuccess,
-                       MozDOMGetUserMediaErrorCallback* aOnError,
-                       ErrorResult& aRv);
-  void MozGetUserMedia(nsIMediaStreamOptions* aParams,
-                       nsIDOMGetUserMediaSuccessCallback* aOnSuccess,
-                       nsIDOMGetUserMediaErrorCallback* aOnError,
-                       ErrorResult& aRv);
-  void MozGetUserMediaDevices(MozGetUserMediaDevicesSuccessCallback* aOnSuccess,
-                              MozDOMGetUserMediaErrorCallback* aOnError,
-                              ErrorResult& aRv);
-  void MozGetUserMediaDevices(nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
-                              nsIDOMGetUserMediaErrorCallback* aOnError,
-                              ErrorResult& aRv);
-#endif // MOZ_MEDIA_NAVIGATOR
-  bool DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
-                    JS::Handle<jsid> aId, unsigned aFlags,
-                    JS::MutableHandle<JSObject*> aObjp);
-
-  // WebIDL helper methods
-  static bool HasBatterySupport(JSContext* /* unused*/, JSObject* /*unused */);
-  static bool HasPowerSupport(JSContext* /* unused */, JSObject* aGlobal);
-  static bool HasIdleSupport(JSContext* /* unused */, JSObject* aGlobal);
-  static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
-  static bool HasDesktopNotificationSupport(JSContext* /* unused*/,
-                                            JSObject* /*unused */)
-  {
-    return HasDesktopNotificationSupport();
-  }
-  static bool HasSmsSupport(JSContext* /* unused */, JSObject* aGlobal);
-  static bool HasMobileMessageSupport(JSContext* /* unused */,
-                                      JSObject* aGlobal);
-  static bool HasCameraSupport(JSContext* /* unused */,
-                               JSObject* aGlobal);
-#ifdef MOZ_B2G_RIL
-  static bool HasTelephonySupport(JSContext* /* unused */,
-                                  JSObject* aGlobal);
-  static bool HasMobileConnectionSupport(JSContext* /* unused */,
-                                         JSObject* aGlobal);
-  static bool HasCellBroadcastSupport(JSContext* /* unused */,
-                                      JSObject* aGlobal);
-  static bool HasVoicemailSupport(JSContext* /* unused */,
-                                  JSObject* aGlobal);
-  static bool HasIccManagerSupport(JSContext* /* unused */,
-                                   JSObject* aGlobal);
-#endif // MOZ_B2G_RIL
-#ifdef MOZ_B2G_BT
-  static bool HasBluetoothSupport(JSContext* /* unused */, JSObject* aGlobal);
-#endif // MOZ_B2G_BT
-#ifdef MOZ_TIME_MANAGER
-  static bool HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal);
-#endif // MOZ_TIME_MANAGER
-#ifdef MOZ_MEDIA_NAVIGATOR
-  static bool HasUserMediaSupport(JSContext* /* unused */,
-                                  JSObject* /* unused */);
-#endif // MOZ_MEDIA_NAVIGATOR
-
-  nsPIDOMWindow* GetParentObject() const
-  {
-    return GetWindow();
-  }
-
-  virtual JSObject* WrapObject(JSContext* cx,
-                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
-
 private:
   bool CheckPermission(const char* type);
-  static bool CheckPermission(nsPIDOMWindow* aWindow, const char* aType);
-  static bool HasMobileMessageSupport(nsPIDOMWindow* aWindow);
-  // GetWindowFromGlobal returns the inner window for this global, if
-  // any, else null.
-  static already_AddRefed<nsPIDOMWindow> GetWindowFromGlobal(JSObject* aGlobal);
-
-  // Methods to common up the XPCOM and WebIDL implementations of
-  // Add/RemoveIdleObserver.
-  void AddIdleObserver(nsIIdleObserver& aIdleObserver);
-  void RemoveIdleObserver(nsIIdleObserver& aIdleObserver);
 
   nsRefPtr<nsMimeTypeArray> mMimeTypes;
   nsRefPtr<nsPluginArray> mPlugins;
   nsRefPtr<Geolocation> mGeolocation;
   nsRefPtr<DesktopNotificationCenter> mNotification;
   nsRefPtr<battery::BatteryManager> mBatteryManager;
   nsRefPtr<power::PowerManager> mPowerManager;
   nsRefPtr<SmsManager> mSmsManager;
@@ -444,10 +253,11 @@ private:
 };
 
 } // namespace dom
 } // namespace mozilla
 
 nsresult NS_GetNavigatorUserAgent(nsAString& aUserAgent);
 nsresult NS_GetNavigatorPlatform(nsAString& aPlatform);
 nsresult NS_GetNavigatorAppVersion(nsAString& aAppVersion);
+nsresult NS_GetNavigatorAppName(nsAString& aAppName);
 
 #endif // mozilla_dom_Navigator_h
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -4655,25 +4655,111 @@ nsLocationSH::AddProperty(nsIXPConnectWr
 
 NS_IMETHODIMP
 nsNavigatorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                           JSObject *aObj, jsid aId, uint32_t flags,
                           JSObject **objp, bool *_retval)
 {
   JS::Rooted<JSObject*> obj(cx, aObj);
   JS::Rooted<jsid> id(cx, aId);
-  nsCOMPtr<nsIDOMNavigator> navigator = do_QueryWrappedNative(wrapper);
-  if (!static_cast<Navigator*>(navigator.get())->
-        DoNewResolve(cx, obj, id, flags,
-                     JS::MutableHandle<JSObject*>::fromMarkedLocation(objp))) {
-    return NS_ERROR_FAILURE;
-  }
+  if (!JSID_IS_STRING(id)) {
+    return NS_OK;
+  }
+
+  nsScriptNameSpaceManager *nameSpaceManager =
+    nsJSRuntime::GetNameSpaceManager();
+  NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
+
+  nsDependentJSString name(id);
+
+  const nsGlobalNameStruct* name_struct =
+    nameSpaceManager->LookupNavigatorName(name);
+  if (!name_struct) {
+    return NS_OK;
+  }
+
+  if (name_struct->mType == nsGlobalNameStruct::eTypeNewDOMBinding) {
+    mozilla::dom::ConstructNavigatorProperty construct = name_struct->mConstructNavigatorProperty;
+    MOZ_ASSERT(construct);
+
+    JS::Rooted<JSObject*> naviObj(cx, js::CheckedUnwrap(obj, /* stopAtOuter = */ false));
+    NS_ENSURE_TRUE(naviObj, NS_ERROR_DOM_SECURITY_ERR);
+
+    JS::Rooted<JSObject*> domObject(cx);
+    {
+      JSAutoCompartment ac(cx, naviObj);
+
+      // Check whether our constructor is enabled after we unwrap Xrays, since
+      // we don't want to define an interface on the Xray if it's disabled in
+      // the target global, even if it's enabled in the Xray's global.
+      if (name_struct->mConstructorEnabled &&
+          !(*name_struct->mConstructorEnabled)(cx, naviObj)) {
+        return NS_OK;
+      }
+
+      domObject = construct(cx, naviObj);
+      if (!domObject) {
+        return NS_ERROR_FAILURE;
+      }
+    }
+
+    if (!JS_WrapObject(cx, domObject.address()) ||
+        !JS_DefinePropertyById(cx, obj, id,
+                               JS::ObjectValue(*domObject),
+                               nullptr, nullptr, JSPROP_ENUMERATE)) {
+      return NS_ERROR_FAILURE;
+    }
+
+    *_retval = true;
+    *objp = obj;
+
+    return NS_OK;
+  }
+
+  NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeNavigatorProperty,
+               "unexpected type");
+
+  nsresult rv = NS_OK;
+
+  nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  JS::Rooted<JS::Value> prop_val(cx, JS::UndefinedValue()); // Property value.
+
+  nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
+
+  if (gpi) {
+    nsCOMPtr<nsIDOMNavigator> navigator = do_QueryWrappedNative(wrapper);
+    nsIDOMWindow *window = static_cast<Navigator*>(navigator.get())->GetWindow();
+    NS_ENSURE_TRUE(window, NS_ERROR_UNEXPECTED);
+
+    rv = gpi->Init(window, prop_val.address());
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
+    nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
+    rv = WrapNative(cx, obj, native, true, prop_val.address(),
+                    getter_AddRefs(holder));
+
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  if (!JS_WrapValue(cx, prop_val.address())) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val,
+                                      JS_PropertyStub, JS_StrictPropertyStub,
+                                      JSPROP_ENUMERATE);
 
   *_retval = true;
-  return NS_OK;
+  *objp = obj;
+
+  return ok ? NS_OK : NS_ERROR_FAILURE;
 }
 
 // static
 nsresult
 nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
                          JSObject *globalObj, JSObject **parentObj)
 {
   // window.navigator can hold expandos and thus we need to only ever
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1697,40 +1697,27 @@ addExternalIface('FileCallback', nativeT
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase')
 addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
 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',	
-                 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('MozSmsManager', headerFile='nsIDOMSmsManager.h')
-addExternalIface('MozTelephony', nativeType='nsIDOMTelephony')
 addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject',
                  notflattened=True)
 addExternalIface('MozTreeColumn', nativeType='nsITreeColumn',
                  headerFile='nsITreeColumns.h')
-addExternalIface('MozVoicemail')
-addExternalIface('MozWakeLock', headerFile='nsIDOMWakeLock.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/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -3727,17 +3727,17 @@ def convertConstIDLValueToJSVal(value):
     if tag == IDLType.Tags.uint32:
         return "UINT_TO_JSVAL(%sU)" % (value.value)
     if tag in [IDLType.Tags.int64, IDLType.Tags.uint64]:
         return "DOUBLE_TO_JSVAL(%s)" % numericValue(tag, value.value)
     if tag == IDLType.Tags.bool:
         return "JSVAL_TRUE" if value.value else "JSVAL_FALSE"
     if tag in [IDLType.Tags.float, IDLType.Tags.double]:
         return "DOUBLE_TO_JSVAL(%s)" % (value.value)
-    raise TypeError("Const value of unhandled type: %s" % value.type)
+    raise TypeError("Const value of unhandled type: " + value.type)
 
 class CGArgumentConverter(CGThing):
     """
     A class that takes an IDL argument object and its index in the
     argument list and generates code to unwrap the argument to the
     right native type.
 
     argDescription is a description of the argument for error-reporting
--- a/dom/bindings/Makefile.in
+++ b/dom/bindings/Makefile.in
@@ -17,17 +17,17 @@ include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 
 # Need this to find all our DOM source files.
 include $(topsrcdir)/dom/dom-config.mk
 
 include $(topsrcdir)/dom/webidl/WebIDL.mk
 
 binding_include_path := mozilla/dom
-all_webidl_files = $(webidl_files) $(generated_webidl_files) $(preprocessed_webidl_files)
+all_webidl_files = $(webidl_files) $(generated_webidl_files)
 # Set exported_binding_headers before adding the test IDL to the mix
 exported_binding_headers := $(subst .webidl,Binding.h,$(all_webidl_files))
 # Set linked_binding_cpp_files before adding the test IDL to the mix
 linked_binding_cpp_files := $(subst .webidl,Binding.cpp,$(all_webidl_files))
 
 all_webidl_files += $(test_webidl_files)
 
 binding_header_files := $(subst .webidl,Binding.h,$(all_webidl_files))
@@ -137,33 +137,16 @@ CSS2Properties.webidl: $(topsrcdir)/layo
 	  $(srcdir)/GenerateCSS2PropertiesWebIDL.py $(webidl_base)/CSS2Properties.webidl.in > CSS2Properties.webidl
 
 $(webidl_files): %: $(webidl_base)/%
 	$(INSTALL) $(IFLAGS1) $(webidl_base)/$* .
 
 $(test_webidl_files): %: $(srcdir)/test/%
 	$(INSTALL) $(IFLAGS1) $(srcdir)/test/$* .
 
-# We can't easily use PP_TARGETS here because it insists on outputting targets
-# that look like "$(CURDIR)/foo" whereas we want our target to just be "foo".
-# Make sure to include $(GLOBAL_DEPS) so we pick up changes to what symbols are
-# defined.  Also make sure to remove $@ before writing to it, because otherwise
-# if a file goes from non-preprocessed to preprocessed we can end up writing to
-# a symlink, which will clobber files in the srcdir, which is bad.
-$(preprocessed_webidl_files): %: $(webidl_base)/% $(GLOBAL_DEPS)
-	$(RM) $@
-	PYTHONDONTWRITEBYTECODE=1 $(PYTHON) \
-          $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $(webidl_base)/$* -o $@
-
-# Make is dumb and can get confused between "foo" and "$(CURDIR)/foo".  Make
-# sure that the latter depends on the former, since the latter gets used in .pp
-# files.
-all_webidl_files_absolute = $(addprefix $(CURDIR)/,$(all_webidl_files))
-$(all_webidl_files_absolute): $(CURDIR)/%: %
-
 $(binding_header_files): .BindingGen
 
 $(binding_cpp_files): .BindingGen
 
 # $(binding_dependency_trackers) pick up additional dependencies via .pp files
 $(binding_dependency_trackers):
 	# Just bring it up to date, if it's out of date, so that we'll know that
 	# we have to redo binding generation and flag this prerequisite there as
--- a/dom/bluetooth/BluetoothManager.cpp
+++ b/dom/bluetooth/BluetoothManager.cpp
@@ -163,33 +163,40 @@ BluetoothManager::Create(nsPIDOMWindow* 
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aWindow);
 
   nsRefPtr<BluetoothManager> manager = new BluetoothManager(aWindow);
   return manager.forget();
 }
 
-// static
-bool
-BluetoothManager::CheckPermission(nsPIDOMWindow* aWindow)
+nsresult
+NS_NewBluetoothManager(nsPIDOMWindow* aWindow,
+                       nsIDOMBluetoothManager** aBluetoothManager)
 {
   NS_ASSERTION(aWindow, "Null pointer!");
 
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
-  NS_ENSURE_TRUE(permMgr, false);
+  NS_ENSURE_TRUE(permMgr, NS_ERROR_UNEXPECTED);
 
   uint32_t permission;
   nsresult rv =
     permMgr->TestPermissionFromWindow(aWindow, "bluetooth",
                                       &permission);
-  NS_ENSURE_SUCCESS(rv, false);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsRefPtr<BluetoothManager> bluetoothManager;
 
-  return permission == nsIPermissionManager::ALLOW_ACTION;
+  if (permission == nsIPermissionManager::ALLOW_ACTION) {
+    bluetoothManager = BluetoothManager::Create(aWindow);
+  }
+
+  bluetoothManager.forget(aBluetoothManager);
+  return NS_OK;
 }
 
 void
 BluetoothManager::Notify(const BluetoothSignal& aData)
 {
   BT_LOG("[M] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
 
   if (aData.name().EqualsLiteral("AdapterAdded")) {
--- a/dom/bluetooth/BluetoothManager.h
+++ b/dom/bluetooth/BluetoothManager.h
@@ -24,22 +24,23 @@ class BluetoothManager : public nsDOMEve
                        , 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);
+  Create(nsPIDOMWindow* aWindow);
   void Notify(const BluetoothSignal& aData);
   virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
 private:
   BluetoothManager(nsPIDOMWindow* aWindow);
   ~BluetoothManager();
 };
 
 END_BLUETOOTH_NAMESPACE
 
+nsresult NS_NewBluetoothManager(nsPIDOMWindow* aWindow,
+                                nsIDOMBluetoothManager** aBluetoothManager);
+
 #endif
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -66,37 +66,31 @@ nsDOMCameraManager::nsDOMCameraManager(n
 nsDOMCameraManager::~nsDOMCameraManager()
 {
   /* destructor code */
   DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   obs->RemoveObserver(this, "xpcom-shutdown");
 }
 
-bool
-nsDOMCameraManager::CheckPermission(nsPIDOMWindow* aWindow)
+// static creator
+already_AddRefed<nsDOMCameraManager>
+nsDOMCameraManager::CheckPermissionAndCreateInstance(nsPIDOMWindow* aWindow)
 {
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
-  NS_ENSURE_TRUE(permMgr, false);
+  NS_ENSURE_TRUE(permMgr, nullptr);
 
   uint32_t permission = nsIPermissionManager::DENY_ACTION;
   permMgr->TestPermissionFromWindow(aWindow, "camera", &permission);
   if (permission != nsIPermissionManager::ALLOW_ACTION) {
     NS_WARNING("No permission to access camera");
-    return false;
+    return nullptr;
   }
 
-  return true;
-}
-
-// static creator
-already_AddRefed<nsDOMCameraManager>
-nsDOMCameraManager::CreateInstance(nsPIDOMWindow* aWindow)
-{
   // Initialize the shared active window tracker
   if (!sActiveWindowsInitialized) {
     sActiveWindows.Init();
     sActiveWindowsInitialized = true;
   }
 
   nsRefPtr<nsDOMCameraManager> cameraManager =
     new nsDOMCameraManager(aWindow);
--- a/dom/camera/DOMCameraManager.h
+++ b/dom/camera/DOMCameraManager.h
@@ -40,19 +40,18 @@ class nsDOMCameraManager MOZ_FINAL
   , public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCameraManager,
                                                          nsIObserver)
   NS_DECL_NSIOBSERVER
 
-  static bool CheckPermission(nsPIDOMWindow* aWindow);
   static already_AddRefed<nsDOMCameraManager>
-    CreateInstance(nsPIDOMWindow* aWindow);
+    CheckPermissionAndCreateInstance(nsPIDOMWindow* aWindow);
   static bool IsWindowStillActive(uint64_t aWindowId);
 
   void Register(mozilla::nsDOMCameraControl* aDOMCameraControl);
   void OnNavigation(uint64_t aWindowId);
 
   nsresult GetNumberOfCameras(int32_t& aDeviceCount);
   nsresult GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName);
 
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1090,19 +1090,19 @@ MediaManager::GetUserMedia(bool aPrivile
     // Stream from default device from WebRTC backend.
     gUMRunnable = new GetUserMediaRunnable(
       audio, video, picture, onSuccess.forget(), onError.forget(), windowID, listener, mPrefs
                                            );
   }
 
 #ifdef MOZ_B2G_CAMERA
   if (mCameraManager == nullptr) {
-    aPrivileged = nsDOMCameraManager::CheckPermission(aWindow);
-    if (aPrivileged) {
-      mCameraManager = nsDOMCameraManager::CreateInstance(aWindow);
+    mCameraManager = nsDOMCameraManager::CheckPermissionAndCreateInstance(aWindow);
+    if (!mCameraManager) {
+      aPrivileged = false;
     }
   }
 #endif
 
 #if defined(ANDROID) && !defined(MOZ_WIDGET_GONK)
   if (picture) {
     // ShowFilePickerForMimeType() must run on the Main Thread! (on Android)
     NS_DispatchToMainThread(gUMRunnable);
--- a/dom/media/tests/crashtests/802982.html
+++ b/dom/media/tests/crashtests/802982.html
@@ -10,17 +10,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   function finish() {
     document.documentElement.removeAttribute("class");
   }
 
   function boom()
   {
     for (var j = 0; j < 100; ++j) {
-      navigator.mozGetUserMedia({}, function(){}, function(){});
+      navigator.mozGetUserMedia({}, {}, {});
     }
     finish(); // we're not waiting for success/error callbacks here
   }
 
   </script>
 </head>
 
 <body onload="setTimeout(boom, 100)">
--- a/dom/media/tests/mochitest/test_getUserMedia_exceptions.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_exceptions.html
@@ -21,36 +21,36 @@ https://bugzilla.mozilla.org/show_bug.cg
 /**
   These tests verify that the appropriate exception is thrown when incorrect
   values are provided to the immediate mozGetUserMedia call.
 */
 var exceptionTests = [
   // Each test here verifies that a caller is required to have all
   // three arguments in order to call mozGetUserMedia
   { params: undefined,
-    error: "Not enough arguments to Navigator.mozGetUserMedia.",
+    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
     message: "no arguments specified" },
   { params: [{video: true, fake: true}],
-    error: "Not enough arguments to Navigator.mozGetUserMedia.",
+    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
     message: "one argument specified" },
   { params: [{video: true, fake: true}, unexpectedCall],
-    error: "Not enough arguments to Navigator.mozGetUserMedia.",
+    error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
     message: "two arguments specified" },
 
   // Each test here verifies that providing an incorret object
   // type to any mozGetUserMedia parameter should throw
   // the correct exception specified
   { params: [1, unexpectedCall, unexpectedCall],
-    error: "Argument 1 of Navigator.mozGetUserMedia is not an object.",
+    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
     message: "wrong object type as first parameter" },
   { params: [{video: true, fake: true}, 1, unexpectedCall],
-    error: "Argument 2 of Navigator.mozGetUserMedia is not an object.",
+    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
     message: "wrong object type as second parameter" },
   { params: [{video: true, fake: true}, unexpectedCall, 1],
-    error: "Argument 3 of Navigator.mozGetUserMedia is not an object.",
+    error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
     message: "wrong object type as third parameter" }
 ];
 
 /**
  * A callback function that is only called if a particular
  * exception was not thrown, resulting in the test failing.
  *
  * @param  {MediaStream} argument ignored
@@ -66,17 +66,17 @@ function unexpectedCall(obj) {
  * specified.
  */
 runTest(function () {
   exceptionTests.forEach(function (test) {
     var exception = false;
     try {
       navigator.mozGetUserMedia.apply(navigator, test.params);
     } catch (e) {
-      exception = (e.message === test.error);
+      exception = (e.result === test.error);
     }
     ok(exception, "Exception for " + test.message);
   });
 
   SimpleTest.finish();
 });
 
 </script>
--- a/dom/mobilemessage/src/SmsManager.cpp
+++ b/dom/mobilemessage/src/SmsManager.cpp
@@ -49,59 +49,51 @@ NS_IMPL_RELEASE_INHERITED(SmsManager, ns
 
 NS_IMPL_EVENT_HANDLER(SmsManager, received)
 NS_IMPL_EVENT_HANDLER(SmsManager, sending)
 NS_IMPL_EVENT_HANDLER(SmsManager, sent)
 NS_IMPL_EVENT_HANDLER(SmsManager, failed)
 NS_IMPL_EVENT_HANDLER(SmsManager, deliverysuccess)
 NS_IMPL_EVENT_HANDLER(SmsManager, deliveryerror)
 
-/* static */
-bool
-SmsManager::CreationIsAllowed(nsPIDOMWindow* aWindow)
+/* static */already_AddRefed<SmsManager>
+SmsManager::CreateInstanceIfAllowed(nsPIDOMWindow* aWindow)
 {
   NS_ASSERTION(aWindow, "Null pointer!");
 
 #ifndef MOZ_WEBSMS_BACKEND
-  return false;
+  return nullptr;
 #endif
 
   // First of all, the general pref has to be turned on.
   bool enabled = false;
   Preferences::GetBool("dom.sms.enabled", &enabled);
-  NS_ENSURE_TRUE(enabled, false);
+  NS_ENSURE_TRUE(enabled, nullptr);
 
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
-  NS_ENSURE_TRUE(permMgr, false);
+  NS_ENSURE_TRUE(permMgr, nullptr);
 
   uint32_t permission = nsIPermissionManager::DENY_ACTION;
   permMgr->TestPermissionFromWindow(aWindow, "sms", &permission);
 
   if (permission != nsIPermissionManager::ALLOW_ACTION) {
-    return false;
+    return nullptr;
   }
 
   // Check the Sms Service:
   nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsService, false);
+  NS_ENSURE_TRUE(smsService, nullptr);
 
   bool result = false;
   smsService->HasSupport(&result);
   if (!result) {
-    return false;
+    return nullptr;
   }
 
-  return true;
-}
-
-// static
-already_AddRefed<SmsManager>
-SmsManager::CreateInstance(nsPIDOMWindow* aWindow)
-{
   nsRefPtr<SmsManager> smsMgr = new SmsManager();
   smsMgr->Init(aWindow);
 
   return smsMgr.forget();
 }
 
 void
 SmsManager::Init(nsPIDOMWindow *aWindow)
--- a/dom/mobilemessage/src/SmsManager.h
+++ b/dom/mobilemessage/src/SmsManager.h
@@ -22,20 +22,17 @@ class SmsManager : public nsDOMEventTarg
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIDOMMOZSMSMANAGER
 
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
 
   static already_AddRefed<SmsManager>
-  CreateInstance(nsPIDOMWindow *aWindow);
-
-  static bool
-  CreationIsAllowed(nsPIDOMWindow *aWindow);
+  CreateInstanceIfAllowed(nsPIDOMWindow *aWindow);
 
   void Init(nsPIDOMWindow *aWindow);
   void Shutdown();
 
 private:
   /**
    * Internal Send() method used to send one message.
    */
--- a/dom/mobilemessage/tests/test_sms_basics.html
+++ b/dom/mobilemessage/tests/test_sms_basics.html
@@ -11,19 +11,18 @@
 <iframe></iframe>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for WebSMS **/
 
 function checkSmsDisabled() {
-  ok(!('mozSms' in frames[0].navigator), "navigator.mozSms should not exist");
-  ok(frames[0].navigator.mozSms === undefined,
-     "navigator.mozSms should return undefined");
+  ok('mozSms' in frames[0].navigator, "navigator.mozSms should exist");
+  is(frames[0].navigator.mozSms, null, "navigator.mozSms should return null");
 }
 
 function checkSmsEnabled() {
   // Bug 784617: WebSms is disabled on all platforms except Android for the moment.
   if (navigator.appVersion.indexOf("Android") == -1) {
     checkSmsDisabled();
     return;
   }
--- a/dom/power/PowerManager.cpp
+++ b/dom/power/PowerManager.cpp
@@ -174,35 +174,31 @@ PowerManager::GetCpuSleepAllowed(bool *a
 
 NS_IMETHODIMP
 PowerManager::SetCpuSleepAllowed(bool aAllowed)
 {
   hal::SetCpuSleepAllowed(aAllowed);
   return NS_OK;
 }
 
-bool
-PowerManager::CheckPermission(nsPIDOMWindow* aWindow)
+already_AddRefed<PowerManager>
+PowerManager::CheckPermissionAndCreateInstance(nsPIDOMWindow* aWindow)
 {
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
-  NS_ENSURE_TRUE(permMgr, false);
+  NS_ENSURE_TRUE(permMgr, nullptr);
 
   uint32_t permission = nsIPermissionManager::DENY_ACTION;
   permMgr->TestPermissionFromWindow(aWindow, "power", &permission);
 
-  return permission == nsIPermissionManager::ALLOW_ACTION;
-}
+  if (permission != nsIPermissionManager::ALLOW_ACTION) {
+    return nullptr;
+  }
 
-already_AddRefed<PowerManager>
-PowerManager::CreateInstance(nsPIDOMWindow* aWindow)
-{
   nsRefPtr<PowerManager> powerManager = new PowerManager();
-  if (NS_FAILED(powerManager->Init(aWindow))) {
-    powerManager = nullptr;
-  }
+  powerManager->Init(aWindow);
 
   return powerManager.forget();
 }
 
 } // power
 } // dom
 } // mozilla
--- a/dom/power/PowerManager.h
+++ b/dom/power/PowerManager.h
@@ -28,19 +28,18 @@ public:
   NS_DECL_NSIDOMMOZWAKELOCKLISTENER
 
   PowerManager() {};
   virtual ~PowerManager() {};
 
   nsresult Init(nsIDOMWindow *aWindow);
   nsresult Shutdown();
 
-  static bool CheckPermission(nsPIDOMWindow*);
-
-  static already_AddRefed<PowerManager> CreateInstance(nsPIDOMWindow*);
+  static already_AddRefed<PowerManager>
+  CheckPermissionAndCreateInstance(nsPIDOMWindow*);
 
 private:
 
   nsWeakPtr mWindow;
   nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mListeners;
 };
 
 } // namespace power
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -112,57 +112,39 @@ Telephony::~Telephony()
   }
   else {
     gTelephonyList->RemoveElement(this);
   }
 }
 
 // static
 already_AddRefed<Telephony>
-Telephony::Create(nsPIDOMWindow* aOwner, ErrorResult& aRv)
+Telephony::Create(nsPIDOMWindow* aOwner, nsITelephonyProvider* aProvider)
 {
   NS_ASSERTION(aOwner, "Null owner!");
-
-  nsCOMPtr<nsITelephonyProvider> ril =
-    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
-  if (!ril) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
+  NS_ASSERTION(aProvider, "Null provider!");
 
   nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aOwner);
-  if (!sgo) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
+  NS_ENSURE_TRUE(sgo, nullptr);
 
   nsCOMPtr<nsIScriptContext> scriptContext = sgo->GetContext();
-  if (!scriptContext) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
+  NS_ENSURE_TRUE(scriptContext, nullptr);
 
   nsRefPtr<Telephony> telephony = new Telephony();
 
   telephony->BindToOwner(aOwner);
 
-  telephony->mProvider = ril;
+  telephony->mProvider = aProvider;
   telephony->mListener = new Listener(telephony);
 
-  nsresult rv = ril->EnumerateCalls(telephony->mListener);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
+  nsresult rv = aProvider->EnumerateCalls(telephony->mListener);
+  NS_ENSURE_SUCCESS(rv, nullptr);
 
-  rv = ril->RegisterTelephonyMsg(telephony->mListener);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
+  rv = aProvider->RegisterTelephonyMsg(telephony->mListener);
+  NS_ENSURE_SUCCESS(rv, nullptr);
 
   return telephony.forget();
 }
 
 already_AddRefed<TelephonyCall>
 Telephony::CreateNewDialingCall(const nsAString& aNumber)
 {
   nsRefPtr<TelephonyCall> call =
@@ -587,29 +569,41 @@ Telephony::EnqueueEnumerationAck()
   }
 
   nsCOMPtr<nsIRunnable> task = new EnumerationAck(this);
   if (NS_FAILED(NS_DispatchToCurrentThread(task))) {
     NS_WARNING("Failed to dispatch to current thread!");
   }
 }
 
-/* static */
-bool
-Telephony::CheckPermission(nsPIDOMWindow* aWindow)
+nsresult
+NS_NewTelephony(nsPIDOMWindow* aWindow, nsIDOMTelephony** aTelephony)
 {
-  MOZ_ASSERT(aWindow && aWindow->IsInnerWindow());
+  NS_ASSERTION(aWindow, "Null pointer!");
+
+  nsPIDOMWindow* innerWindow = aWindow->IsInnerWindow() ?
+    aWindow :
+    aWindow->GetCurrentInnerWindow();
 
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
-  NS_ENSURE_TRUE(permMgr, false);
+  NS_ENSURE_TRUE(permMgr, NS_ERROR_UNEXPECTED);
 
   uint32_t permission;
   nsresult rv =
     permMgr->TestPermissionFromWindow(aWindow, "telephony", &permission);
-  NS_ENSURE_SUCCESS(rv, false);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   if (permission != nsIPermissionManager::ALLOW_ACTION) {
-    return false;
+    *aTelephony = nullptr;
+    return NS_OK;
   }
 
-  return true;
+  nsCOMPtr<nsITelephonyProvider> ril =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
+  NS_ENSURE_TRUE(ril, NS_ERROR_UNEXPECTED);
+
+  nsRefPtr<Telephony> telephony = Telephony::Create(innerWindow, ril);
+  NS_ENSURE_TRUE(telephony, NS_ERROR_UNEXPECTED);
+
+  telephony.forget(aTelephony);
+  return NS_OK;
 }
--- a/dom/telephony/Telephony.h
+++ b/dom/telephony/Telephony.h
@@ -3,19 +3,16 @@
 /* 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_telephony_telephony_h__
 #define mozilla_dom_telephony_telephony_h__
 
 #include "TelephonyCommon.h"
-// Need to include TelephonyCall.h because we have inline methods that
-// assume they see the definition of TelephonyCall.
-#include "TelephonyCall.h"
 
 #include "nsIDOMTelephony.h"
 #include "nsIDOMTelephonyCall.h"
 #include "nsITelephonyProvider.h"
 
 class nsIScriptContext;
 class nsPIDOMWindow;
 
@@ -54,19 +51,17 @@ public:
   NS_DECL_NSIDOMTELEPHONY
   NS_DECL_NSITELEPHONYLISTENER
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
                                                    Telephony,
                                                    nsDOMEventTargetHelper)
 
   static already_AddRefed<Telephony>
-  Create(nsPIDOMWindow* aOwner, ErrorResult& aRv);
-
-  static bool CheckPermission(nsPIDOMWindow* aOwner);
+  Create(nsPIDOMWindow* aOwner, nsITelephonyProvider* aProvider);
 
   nsISupports*
   ToISupports()
   {
     return static_cast<EventTarget*>(this);
   }
 
   void
new file mode 100644
--- /dev/null
+++ b/dom/telephony/TelephonyFactory.h
@@ -0,0 +1,18 @@
+/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
+/* vim: set ts=2 et sw=2 tw=40: */
+/* 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_telephony_telephonyfactory_h__
+#define mozilla_dom_telephony_telephonyfactory_h__
+
+#include "nsIDOMTelephony.h"
+#include "nsPIDOMWindow.h"
+
+// Implemented in Telephony.cpp.
+
+nsresult
+NS_NewTelephony(nsPIDOMWindow* aWindow, nsIDOMTelephony** aTelephony);
+
+#endif // mozilla_dom_telephony_telephonyfactory_h__
--- a/dom/tests/mochitest/general/test_idleapi_permissions.html
+++ b/dom/tests/mochitest/general/test_idleapi_permissions.html
@@ -12,38 +12,33 @@
 <pre id="test">
 <script type="application/javascript">
 
 var idleObserver = {
   onidle: null,
   onactive: null
 };
 
-function doAddIdleObserver(obs) {
-  var i = document.createElement("iframe");
-  document.body.appendChild(i);
-  var added = false;
-  try {
-    i.contentWindow.navigator.addIdleObserver(obs);
-    added = true;
-  } catch (e) { }
-  i.remove();
-  return added;
-}
-
 function run_test() {
   // addIdleObserver checks whether time is > 0.
   this.idleObserver.time = 100;
 
-  var added = doAddIdleObserver(this.idleObserver, false);
+  var added = false;
+  try {
+    navigator.addIdleObserver(this.idleObserver);
+    added = true;
+  } catch (e) { }
   ok(!added, "Should not be able to add idle observer without permission");
   
   SpecialPowers.addPermission("idle", true, document);
-
-  added = doAddIdleObserver(this.idleObserver, true);
+  added = false;
+  try {
+    navigator.addIdleObserver(this.idleObserver);
+    added = true;
+  } catch (e) { }
   ok(added, "Should be able to add idle observer with permission.");
   
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(run_test);
 </script>
--- a/dom/tests/mochitest/general/test_vibrator.html
+++ b/dom/tests/mochitest/general/test_vibrator.html
@@ -30,22 +30,22 @@ function expectSuccess(param) {
   catch(e) {
     ok(false, 'vibrate(' + param + ') threw an unexpected exception.');
     return;
   }
   ok(true, 'vibrate(' + param + ') did not throw an exception.');
 }
 
 function testFailures() {
-  expectSuccess(null);
-  expectSuccess(undefined);
+  expectFailure(null);
+  expectFailure(undefined);
   expectFailure(-1);
-  expectSuccess('a');
+  expectFailure('a');
   expectFailure([100, -1]);
-  expectSuccess([100, 'a']);
+  expectFailure([100, 'a']);
 
   var maxVibrateMs = SpecialPowers.getIntPref('dom.vibrator.max_vibrate_ms');
   var maxVibrateListLen = SpecialPowers.getIntPref('dom.vibrator.max_vibrate_list_len');
 
   // Make sure that these preferences are respected.
   expectFailure(maxVibrateMs + 1);
   expectFailure([maxVibrateMs + 1]);
 
deleted file mode 100644
--- a/dom/webidl/Navigator.webidl
+++ /dev/null
@@ -1,353 +0,0 @@
-/* -*- 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/.
- *
- * The origin of this IDL file is
- * http://www.whatwg.org/specs/web-apps/current-work/#the-navigator-object
- * http://www.w3.org/TR/tracking-dnt/
- * http://www.w3.org/TR/geolocation-API/#geolocation_interface
- * http://www.w3.org/TR/battery-status/#navigatorbattery-interface
- * http://www.w3.org/TR/vibration/#vibration-interface
- * 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;
-Navigator implements NavigatorLanguage;
-Navigator implements NavigatorOnLine;
-Navigator implements NavigatorContentUtils;
-Navigator implements NavigatorStorageUtils;
-
-[NoInterfaceObject]
-interface NavigatorID {
-  readonly attribute DOMString appName;
-  [Throws]
-  readonly attribute DOMString appVersion;
-  [Throws]
-  readonly attribute DOMString platform;
-  [Throws]
-  readonly attribute DOMString userAgent;
-
-  // Spec has this as a const, but that's wrong because it should not
-  // be on the interface object.
-  //const DOMString product = "Gecko"; // for historical reasons
-  readonly attribute DOMString product;
-};
-
-[NoInterfaceObject]
-interface NavigatorLanguage {
-  readonly attribute DOMString? language;
-};
-
-[NoInterfaceObject]
-interface NavigatorOnLine {
-  readonly attribute boolean onLine;
-};
-
-[NoInterfaceObject]
-interface NavigatorContentUtils {
-  // content handler registration
-  [Throws]
-  void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title);
-  [Throws]
-  void registerContentHandler(DOMString mimeType, DOMString url, DOMString title);
-  // NOT IMPLEMENTED
-  //DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url);
-  //DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url);
-  //void unregisterProtocolHandler(DOMString scheme, DOMString url);
-  //void unregisterContentHandler(DOMString mimeType, DOMString url);
-};
-
-[NoInterfaceObject]
-interface NavigatorStorageUtils {
-  // NOT IMPLEMENTED
-  //void yieldForStorageUpdates();
-};
-
-// Things that definitely need to be in the spec and and are not for some
-// reason.  See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22406
-partial interface Navigator {
-  [Throws]
-  readonly attribute MimeTypeArray mimeTypes;
-  [Throws]
-  readonly attribute PluginArray plugins;
-};
-
-// http://www.w3.org/TR/tracking-dnt/ sort of
-partial interface Navigator {
-  readonly attribute DOMString doNotTrack;
-};
-
-// http://www.w3.org/TR/geolocation-API/#geolocation_interface
-[NoInterfaceObject]
-interface NavigatorGeolocation {
-  // XXXbz This should perhaps be controleld by the "geo.enabled" pref, instead
-  // of checking it in the C++.  Let's not for now to reduce risk.
-  // Also, we violate the spec as a result, since we can return null.  See bug
-  // 884921.
-  [Throws]
-  readonly attribute Geolocation? geolocation;
-};
-Navigator implements NavigatorGeolocation;
-
-// http://www.w3.org/TR/battery-status/#navigatorbattery-interface
-[NoInterfaceObject]
-interface NavigatorBattery {
-    // XXXbz Per spec this should be non-nullable, but we return null in
-    // torn-down windows.  See bug 884925.
-    [Throws, Func="Navigator::HasBatterySupport"]
-    readonly attribute BatteryManager? battery;
-};
-Navigator implements NavigatorBattery;
-
-// http://www.w3.org/TR/vibration/#vibration-interface
-partial interface Navigator {
-    // We don't support sequences in unions yet
-    //boolean vibrate ((unsigned long or sequence<unsigned long>) pattern);
-    // XXXbz also, per spec we should be returning a boolean, and we just don't.
-    // See bug 884935.
-    [Throws]
-    void vibrate(unsigned long duration);
-    [Throws]
-    void vibrate(sequence<unsigned long> pattern);
-};
-
-// Mozilla-specific extensions
-
-callback interface MozIdleObserver {
-  // Time is in seconds and is read only when idle observers are added
-  // and removed.
-  readonly attribute unsigned long time;
-  void onidle();
-  void onactive();
-};
-
-// nsIDOMNavigator
-partial interface Navigator {
-  // WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla").
-  [Throws]
-  readonly attribute DOMString appCodeName;
-  [Throws]
-  readonly attribute DOMString oscpu;
-  // WebKit/Blink support this; Trident/Presto do not.
-  readonly attribute DOMString vendor;
-  // WebKit/Blink supports this (hardcoded ""); Trident/Presto do not.
-  readonly attribute DOMString vendorSub;
-  // WebKit/Blink supports this (hardcoded "20030107"); Trident/Presto don't
-  readonly attribute DOMString productSub;
-  // WebKit/Blink/Trident/Presto support this.
-  readonly attribute boolean cookieEnabled;
-  [Throws]
-  readonly attribute DOMString buildID;
-  [Throws, Func="Navigator::HasPowerSupport"]
-  readonly attribute MozPowerManager mozPower;
-
-  // WebKit/Blink/Trident/Presto support this.
-  [Throws]
-  boolean javaEnabled();
-  // Everyone but WebKit/Blink supports this.  See bug 679971.
-  boolean taintEnabled();
-
-  /**
-   * Navigator requests to add an idle observer to the existing window.
-   */
-  [Throws, Func="Navigator::HasIdleSupport"]
-  void addIdleObserver(MozIdleObserver aIdleObserver);
-
-  /**
-   * Navigator requests to remove an idle observer from the existing window.
-   */
-  [Throws, Func="Navigator::HasIdleSupport"]
-  void removeIdleObserver(MozIdleObserver aIdleObserver);
-
-  /**
-   * Request a wake lock for a resource.
-   *
-   * A page holds a wake lock to request that a resource not be turned
-   * off (or otherwise made unavailable).
-   *
-   * The topic is the name of a resource that might be made unavailable for
-   * various reasons. For example, on a mobile device the power manager might
-   * decide to turn off the screen after a period of idle time to save power.
-   *
-   * The resource manager checks the lock state of a topic before turning off
-   * the associated resource. For example, a page could hold a lock on the
-   * "screen" topic to prevent the screensaver from appearing or the screen
-   * from turning off.
-   *
-   * 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
-   * 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);
-};
-
-// nsIDOMNavigatorDeviceStorage
-partial interface Navigator {
-  [Throws, Pref="device.storage.enabled"]
-  DeviceStorage? getDeviceStorage(DOMString type);
-  [Throws, Pref="device.storage.enabled"]
-  sequence<DeviceStorage> getDeviceStorages(DOMString type);
-};
-
-// nsIDOMNavigatorDesktopNotification
-partial interface Navigator {
-  [Throws, Func="Navigator::HasDesktopNotificationSupport"]
-  readonly attribute DesktopNotificationCenter mozNotification;
-};
-
-// nsIDOMClientInformation
-partial interface Navigator {
-  [Throws]
-  boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline);
-};
-
-// nsIDOMMozNavigatorSms
-interface MozSmsManager;
-partial interface Navigator {
-  [Func="Navigator::HasSmsSupport"]
-  readonly attribute MozSmsManager? mozSms;
-};
-
-// nsIDOMMozNavigatorMobileMessage
-interface MozMobileMessageManager;
-partial interface Navigator {
-  [Func="Navigator::HasMobileMessageSupport"]
-  readonly attribute MozMobileMessageManager? mozMobileMessage;
-};
-
-// nsIDOMMozNavigatorNetwork
-interface MozConnection;
-partial interface Navigator {
-  readonly attribute MozConnection? mozConnection;
-};
-
-// nsIDOMNavigatorCamera
-partial interface Navigator {
-  [Throws, Func="Navigator::HasCameraSupport"]
-  readonly attribute CameraManager mozCameras;
-};
-
-// nsIDOMNavigatorSystemMessages and sort of maybe
-// http://www.w3.org/2012/sysapps/runtime/#extension-to-the-navigator-interface-1
-callback systemMessageCallback = void (optional object message);
-partial interface Navigator {
-  [Throws, Pref="dom.sysmsg.enabled"]
-  void    mozSetMessageHandler (DOMString type, systemMessageCallback? callback);
-  [Throws, Pref="dom.sysmsg.enabled"]
-  boolean mozHasPendingMessage (DOMString type);
-};
-
-#ifdef MOZ_B2G_RIL
-interface MozTelephony;
-// nsIDOMNavigatorTelephony
-partial interface Navigator {
-  [Throws, Func="Navigator::HasTelephonySupport"]
-  readonly attribute MozTelephony? mozTelephony;
-};
-
-// nsIMozNavigatorMobileConnection
-interface MozMobileConnection;
-partial interface Navigator {
-  [Throws, Func="Navigator::HasMobileConnectionSupport"]
-  readonly attribute MozMobileConnection mozMobileConnection;
-};
-
-// nsIMozNavigatorCellBroadcast
-interface MozCellBroadcast;
-partial interface Navigator {
-  [Throws, Func="Navigator::HasCellBroadcastSupport"]
-  readonly attribute MozCellBroadcast mozCellBroadcast;
-};
-
-// nsIMozNavigatorVoicemail
-interface MozVoicemail;
-partial interface Navigator {
-  [Throws, Func="Navigator::HasVoicemailSupport"]
-  readonly attribute MozVoicemail mozVoicemail;
-};
-
-// nsIMozNavigatorIccManager
-interface MozIccManager;
-partial interface Navigator {
-  [Throws, Func="Navigator::HasIccManagerSupport"]
-  readonly attribute MozIccManager? mozIccManager;
-};
-#endif // MOZ_B2G_RIL
-
-#ifdef MOZ_GAMEPAD
-// 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;
-};
-#endif // MOZ_B2G_BT
-
-#ifdef MOZ_TIME_MANAGER
-// nsIDOMMozNavigatorTime
-partial interface Navigator {
-  [Throws, Func="Navigator::HasTimeSupport"]
-  readonly attribute MozTimeManager mozTime;
-};
-#endif // MOZ_TIME_MANAGER
-
-#ifdef MOZ_AUDIO_CHANNEL_MANAGER
-// nsIMozNavigatorAudioChannelManager
-partial interface Navigator {
-  [Throws]
-  readonly attribute AudioChannelManager mozAudioChannelManager;
-};
-#endif // MOZ_AUDIO_CHANNEL_MANAGER
-
-#ifdef MOZ_MEDIA_NAVIGATOR
-// nsIDOMNavigatorUserMedia
-callback MozDOMGetUserMediaSuccessCallback = void (nsISupports? value);
-callback MozDOMGetUserMediaErrorCallback = void (DOMString error);
-interface MozMediaStreamOptions;
-partial interface Navigator {
-  [Throws, Func="Navigator::HasUserMediaSupport"]
-  void mozGetUserMedia(MozMediaStreamOptions? params,
-                       MozDOMGetUserMediaSuccessCallback? onsuccess,
-                       MozDOMGetUserMediaErrorCallback? onerror);
-};
-
-// nsINavigatorUserMedia
-callback MozGetUserMediaDevicesSuccessCallback = void (nsIVariant? devices);
-partial interface Navigator {
-  [Throws, ChromeOnly]
-  void mozGetUserMediaDevices(MozGetUserMediaDevicesSuccessCallback? onsuccess,
-                              MozDOMGetUserMediaErrorCallback? onerror);
-};
-#endif // MOZ_MEDIA_NAVIGATOR
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -3,20 +3,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 webidl_base = $(topsrcdir)/dom/webidl
 
 generated_webidl_files = \
   CSS2Properties.webidl \
   $(NULL)
 
-preprocessed_webidl_files = \
-  Navigator.webidl \
-  $(NULL)
-
 webidl_files = \
   AnalyserNode.webidl \
   AnimationEvent.webidl \
   ArchiveReader.webidl \
   ArchiveRequest.webidl \
   Attr.webidl \
   AudioBuffer.webidl \
   AudioBufferSourceNode.webidl \
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -1153,18 +1153,18 @@ RuntimeService::RegisterWorker(JSContext
   if (parent) {
     if (!parent->AddChildWorker(aCx, aWorkerPrivate)) {
       UnregisterWorker(aCx, aWorkerPrivate);
       return false;
     }
   }
   else {
     if (!mNavigatorStringsLoaded) {
-      NS_GetNavigatorAppName(mNavigatorStrings.mAppName);
-      if (NS_FAILED(NS_GetNavigatorAppVersion(mNavigatorStrings.mAppVersion)) ||
+      if (NS_FAILED(NS_GetNavigatorAppName(mNavigatorStrings.mAppName)) ||
+          NS_FAILED(NS_GetNavigatorAppVersion(mNavigatorStrings.mAppVersion)) ||
           NS_FAILED(NS_GetNavigatorPlatform(mNavigatorStrings.mPlatform)) ||
           NS_FAILED(NS_GetNavigatorUserAgent(mNavigatorStrings.mUserAgent))) {
         JS_ReportError(aCx, "Failed to load navigator strings!");
         UnregisterWorker(aCx, aWorkerPrivate);
         return false;
       }
 
       mNavigatorStringsLoaded = true;
--- a/dom/workers/test/test_navigator.html
+++ b/dom/workers/test/test_navigator.html
@@ -30,18 +30,17 @@ Tests of DOM Worker Navigator
       return;
     }
 
     if (typeof navigator[args.name] == "undefined") {
       ok(false, "Navigator has no '" + args.name + "' property!");
       return;
     }
 
-    is(navigator[args.name], args.value,
-       "Mismatched navigator string for " + args.name + "!");
+    is(navigator[args.name], args.value, "Mismatched navigator string!");
   };
 
   worker.onerror = function(event) {
     ok(false, "Worker had an error: " + event.message);
     SimpleTest.finish();
   }
 
   SimpleTest.waitForExplicitFinish();
--- a/js/xpconnect/tests/chrome/test_weakmaps.xul
+++ b/js/xpconnect/tests/chrome/test_weakmaps.xul
@@ -216,27 +216,23 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   let unpreservable_native_key = function () {
     // We only allow natives that support wrapper preservation to be used as weak
     // map keys.  We should be able to try to add unpreservable natives as keys without
     // crashing (bug 711616), but we should throw an error (bug 761620).
 
     let dummy_test_map = new WeakMap;
 
-    let rule_fail = false;
-    let got_rule = false;
+    let navi_fail = false;
     try {
-      var rule = document.styleSheets[0].cssRules[0];
-      got_rule = true;
-      dummy_test_map.set(rule, 1);
+      dummy_test_map.set(window.navigator, 1);
     } catch (e) {
-      rule_fail = true;
+      navi_fail = true;
     }
-    ok(got_rule, "Got the CSS rule");
-    ok(rule_fail, "Using a CSS rule as a weak map key should produce an exception because it can't be wrapper preserved.");
+    ok(navi_fail, "Using window.navigator as a weak map key should produce an exception because it can't be wrapper preserved.");
 
   }
 
   unpreservable_native_key();
 
   /* set up for running precise GC/CC then checking the results */
 
   SimpleTest.waitForExplicitFinish();
--- a/js/xpconnect/tests/mochitest/file_crosscompartment_weakmap.html
+++ b/js/xpconnect/tests/mochitest/file_crosscompartment_weakmap.html
@@ -1,9 +1,8 @@
 <!DOCTYPE HTML>
 <html>
 <head>
-  <link rel="stylesheet" href="data:text/css,div {}">
   <title>Test Cross-Compartment DOM WeakMaps</title>
 </head>
 <body>
 </body>
 </html>
--- a/js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.html
+++ b/js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.html
@@ -11,23 +11,23 @@
 
 var my_map = WeakMap();
 
 function setup() {
   var item = window.frames[0].document.querySelector("body");
 
   my_map.set(item, "success_string");
 
-  var rule_fail = false;
+  var navi_fail = false;
   try {
-    my_map.set(window.frames[0].document.styleSheets[0].cssRules[0], 1);
+    my_map.set(window.frames[0].navigator, 1);
   } catch (e) {
-    rule_fail = true;
+    navi_fail = true;
   }
-  ok(rule_fail, "Using rule as a weak map key across compartments should produce an exception because it can't be wrapper preserved.");
+  ok(navi_fail, "Using window.navigator as a weak map key across compartments should produce an exception because it can't be wrapper preserved.");
 }
 
 function runTest() {
   setup();
   SpecialPowers.forceGC();
   SpecialPowers.forceCC();
   SpecialPowers.forceGC();
   SpecialPowers.forceCC();