Bug 1299384 - Use MOZ_MUST_USE with NS_warn_if_impl(). r=erahm.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 02 Sep 2016 17:12:24 +1000
changeset 354232 177f41cecedb422d7a11156091ee718ec919c643
parent 354231 838a2c3d46ef8e22b9904546d13973ecbc78f530
child 354233 64a77898c426e8fbcb41246891aa8da48d8be76a
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1299384
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1299384 - Use MOZ_MUST_USE with NS_warn_if_impl(). r=erahm. This change avoids lots of false positives for Coverity's CHECKED_RETURN warning, caused by NS_WARN_IF's current use in both statement-style and expression-style. In the case where the code within the NS_WARN_IF has side-effects, I made the following change. > NS_WARN_IF(NS_FAILED(FunctionWithSideEffects())); > --> > Unused << NS_WARN_IF(NS_FAILED(FunctionWithSideEffects())); In the case where the code within the NS_WARN_IF lacks side-effects, I made the following change. > NS_WARN_IF(!condWithoutSideEffects); > --> > NS_WARNING_ASSERTION(condWithoutSideEffects, "msg"); This has two improvements. - The condition is not evaluated in non-debug builds. - The sense of the condition is inverted to the familiar "this condition should be true" sense used in assertions. A common variation on the side-effect-free case is the following. > nsresult rv = Fn(); > NS_WARN_IF_(NS_FAILED(rv)); > --> > DebugOnly<nsresult rv> = Fn(); > NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Fn failed");
devtools/shared/heapsnapshot/AutoMemMap.cpp
devtools/shared/heapsnapshot/HeapSnapshot.cpp
devtools/shared/heapsnapshot/ZeroCopyNSIOutputStream.cpp
dom/audiochannel/AudioChannelService.cpp
dom/base/MultipartBlobImpl.cpp
dom/base/ScreenOrientation.cpp
dom/base/nsContentIterator.cpp
dom/base/nsContentUtils.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsHostObjectProtocolHandler.cpp
dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
dom/bluetooth/bluez/BluetoothSocket.cpp
dom/bluetooth/common/BluetoothUtils.cpp
dom/camera/GonkCameraControl.cpp
dom/camera/TestGonkCameraHardware.cpp
dom/console/Console.cpp
dom/events/DataTransferItem.cpp
dom/fetch/FetchDriver.cpp
dom/filesystem/CreateDirectoryTask.cpp
dom/filesystem/DeviceStorageFileSystem.cpp
dom/filesystem/FileSystemBase.cpp
dom/filesystem/FileSystemTaskBase.cpp
dom/filesystem/compat/CallbackRunnables.cpp
dom/filesystem/compat/FileSystemDirectoryReader.cpp
dom/filesystem/compat/FileSystemFileEntry.cpp
dom/filesystem/compat/FileSystemRootDirectoryEntry.cpp
dom/filesystem/compat/FileSystemRootDirectoryReader.cpp
dom/flyweb/FlyWebService.cpp
dom/gamepad/ipc/GamepadEventChannelChild.cpp
dom/html/HTMLInputElement.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ContentProcess.cpp
dom/ipc/TabParent.cpp
dom/media/AudioStream.cpp
dom/media/MediaStreamGraph.cpp
dom/media/TextTrackList.cpp
dom/network/TCPSocket.cpp
dom/network/UDPSocket.cpp
dom/network/UDPSocketParent.cpp
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginWidgetChild.cpp
dom/presentation/PresentationAvailability.cpp
dom/presentation/PresentationConnection.cpp
dom/presentation/PresentationReceiver.cpp
dom/presentation/PresentationService.cpp
dom/presentation/PresentationSessionInfo.cpp
dom/presentation/PresentationSessionInfo.h
dom/presentation/PresentationTCPSessionTransport.cpp
dom/presentation/ipc/PresentationBuilderChild.cpp
dom/presentation/ipc/PresentationBuilderParent.cpp
dom/presentation/ipc/PresentationChild.cpp
dom/presentation/ipc/PresentationIPCService.cpp
dom/presentation/ipc/PresentationParent.cpp
dom/presentation/provider/LegacyMDNSDeviceProvider.cpp
dom/presentation/provider/MulticastDNSDeviceProvider.cpp
dom/system/gonk/AudioChannelManager.cpp
dom/u2f/U2F.cpp
dom/url/URL.cpp
dom/workers/ServiceWorkerClients.cpp
dom/workers/ServiceWorkerPrivate.cpp
dom/workers/ServiceWorkerRegistration.cpp
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerRunnable.cpp
dom/xbl/nsXBLWindowKeyHandler.cpp
extensions/cookie/nsPermissionManager.cpp
hal/gonk/SystemService.cpp
image/decoders/nsGIFDecoder2.cpp
ipc/mscom/EnsureMTA.cpp
ipc/mscom/InterceptorLog.cpp
ipc/mscom/MainThreadInvoker.cpp
ipc/ril/RilSocket.cpp
ipc/unixfd/UnixFdWatcher.cpp
ipc/unixsocket/ListenSocket.cpp
layout/printing/ipc/RemotePrintJobParent.cpp
layout/style/nsStyleContext.h
media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
netwerk/base/NetworkInfoServiceCocoa.cpp
netwerk/base/NetworkInfoServiceLinux.cpp
netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp
netwerk/dns/mdns/libmdns/nsDNSServiceInfo.cpp
netwerk/ipc/ChannelEventQueue.cpp
netwerk/protocol/http/PackagedAppService.cpp
netwerk/protocol/websocket/WebSocketEventService.cpp
netwerk/streamconv/converters/nsFTPDirListingConv.cpp
toolkit/components/terminator/nsTerminator.cpp
toolkit/components/url-classifier/ProtocolParser.cpp
tools/profiler/gecko/ProfileGatherer.cpp
uriloader/base/nsDocLoader.cpp
uriloader/exthandler/mac/nsOSHelperAppService.mm
widget/ContentCache.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/base/nsMemoryInfoDumper.cpp
xpcom/glue/nsDebug.h
--- a/devtools/shared/heapsnapshot/AutoMemMap.cpp
+++ b/devtools/shared/heapsnapshot/AutoMemMap.cpp
@@ -1,34 +1,36 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/devtools/AutoMemMap.h"
+
+#include "mozilla/Unused.h"
 #include "nsDebug.h"
 
 namespace mozilla {
 namespace devtools {
 
 AutoMemMap::~AutoMemMap()
 {
   if (addr) {
-    NS_WARN_IF(PR_MemUnmap(addr, size()) != PR_SUCCESS);
+    Unused << NS_WARN_IF(PR_MemUnmap(addr, size()) != PR_SUCCESS);
     addr = nullptr;
   }
 
   if (fileMap) {
-    NS_WARN_IF(PR_CloseFileMap(fileMap) != PR_SUCCESS);
+    Unused << NS_WARN_IF(PR_CloseFileMap(fileMap) != PR_SUCCESS);
     fileMap = nullptr;
   }
 
   if (fd) {
-    NS_WARN_IF(PR_Close(fd) != PR_SUCCESS);
+    Unused << NS_WARN_IF(PR_Close(fd) != PR_SUCCESS);
     fd = nullptr;
   }
 }
 
 nsresult
 AutoMemMap::init(const char* filePath, int flags, int mode, PRFileMapProtect prot)
 {
   MOZ_ASSERT(!fd);
--- a/devtools/shared/heapsnapshot/HeapSnapshot.cpp
+++ b/devtools/shared/heapsnapshot/HeapSnapshot.cpp
@@ -24,16 +24,17 @@
 #include "mozilla/devtools/FileDescriptorOutputStream.h"
 #include "mozilla/devtools/HeapSnapshotTempFileHelperChild.h"
 #include "mozilla/devtools/ZeroCopyNSIOutputStream.h"
 #include "mozilla/dom/ChromeUtils.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/HeapSnapshotBinding.h"
 #include "mozilla/RangedPtr.h"
 #include "mozilla/Telemetry.h"
+#include "mozilla/Unused.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCRTGlue.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIFile.h"
 #include "nsIOutputStream.h"
@@ -1468,17 +1469,17 @@ HeapSnapshot::CreateUniqueCoreDumpFile(E
 
 // Deletion policy for cleaning up PHeapSnapshotTempFileHelperChild pointers.
 class DeleteHeapSnapshotTempFileHelperChild
 {
 public:
   constexpr DeleteHeapSnapshotTempFileHelperChild() { }
 
   void operator()(PHeapSnapshotTempFileHelperChild* ptr) const {
-    NS_WARN_IF(!HeapSnapshotTempFileHelperChild::Send__delete__(ptr));
+    Unused << NS_WARN_IF(!HeapSnapshotTempFileHelperChild::Send__delete__(ptr));
   }
 };
 
 // A UniquePtr alias to automatically manage PHeapSnapshotTempFileHelperChild
 // pointers.
 using UniqueHeapSnapshotTempFileHelperChild = UniquePtr<PHeapSnapshotTempFileHelperChild,
                                                         DeleteHeapSnapshotTempFileHelperChild>;
 
--- a/devtools/shared/heapsnapshot/ZeroCopyNSIOutputStream.cpp
+++ b/devtools/shared/heapsnapshot/ZeroCopyNSIOutputStream.cpp
@@ -1,16 +1,17 @@
 /* -*-  Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/devtools/ZeroCopyNSIOutputStream.h"
 
 #include "mozilla/DebugOnly.h"
+#include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace devtools {
 
 ZeroCopyNSIOutputStream::ZeroCopyNSIOutputStream(nsCOMPtr<nsIOutputStream>& out)
   : out(out)
   , result_(NS_OK)
   , amountUsed(0)
@@ -19,17 +20,17 @@ ZeroCopyNSIOutputStream::ZeroCopyNSIOutp
   DebugOnly<bool> nonBlocking = false;
   MOZ_ASSERT(out->IsNonBlocking(&nonBlocking) == NS_OK);
   MOZ_ASSERT(!nonBlocking);
 }
 
 ZeroCopyNSIOutputStream::~ZeroCopyNSIOutputStream()
 {
   if (!failed())
-    NS_WARN_IF(NS_FAILED(writeBuffer()));
+    Unused << NS_WARN_IF(NS_FAILED(writeBuffer()));
 }
 
 nsresult
 ZeroCopyNSIOutputStream::writeBuffer()
 {
   if (failed())
     return result_;
 
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -1344,22 +1344,22 @@ AudioChannelService::AudioChannelWindow:
 
 void
 AudioChannelService::AudioChannelWindow::NotifyAudioAudibleChanged(nsPIDOMWindowOuter* aWindow,
                                                                    AudibleState aAudible,
                                                                    AudibleChangedReasons aReason)
 {
   RefPtr<AudioPlaybackRunnable> runnable =
     new AudioPlaybackRunnable(aWindow, aAudible, aReason);
-  nsresult rv = NS_DispatchToCurrentThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToCurrentThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToCurrentThread failed");
 }
 
 void
 AudioChannelService::AudioChannelWindow::NotifyChannelActive(uint64_t aWindowID,
                                                              AudioChannel aChannel,
                                                              bool aActive)
 {
   RefPtr<NotifyChannelActiveRunnable> runnable =
     new NotifyChannelActiveRunnable(aWindowID, aChannel, aActive);
-  nsresult rv = NS_DispatchToCurrentThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToCurrentThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToCurrentThread failed");
 }
--- a/dom/base/MultipartBlobImpl.cpp
+++ b/dom/base/MultipartBlobImpl.cpp
@@ -162,17 +162,17 @@ MultipartBlobImpl::CreateSlice(uint64_t 
 
   return impl.forget();
 }
 
 void
 MultipartBlobImpl::InitializeBlob(ErrorResult& aRv)
 {
   SetLengthAndModifiedDate(aRv);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "SetLengthAndModifiedDate failed");
 }
 
 void
 MultipartBlobImpl::InitializeBlob(JSContext* aCx,
                                   const Sequence<Blob::BlobPart>& aData,
                                   const nsAString& aContentType,
                                   bool aNativeEOL,
                                   ErrorResult& aRv)
@@ -216,17 +216,17 @@ MultipartBlobImpl::InitializeBlob(JSCont
     else {
       MOZ_CRASH("Impossible blob data type.");
     }
   }
 
 
   mBlobImpls = blobSet.GetBlobImpls();
   SetLengthAndModifiedDate(aRv);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "SetLengthAndModifiedDate failed");
 }
 
 void
 MultipartBlobImpl::SetLengthAndModifiedDate(ErrorResult& aRv)
 {
   MOZ_ASSERT(mLength == UINT64_MAX);
   MOZ_ASSERT(mLastModificationDate == INT64_MAX);
 
@@ -347,17 +347,17 @@ MultipartBlobImpl::InitializeChromeFile(
   }
 
 
   BlobSet blobSet;
   blobSet.AppendBlobImpl(aBlob.Impl());
   mBlobImpls = blobSet.GetBlobImpls();
 
   SetLengthAndModifiedDate(aRv);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "SetLengthAndModifiedDate failed");
 }
 
 void
 MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindowInner* aWindow,
                                         nsIFile* aFile,
                                         const ChromeFilePropertyBag& aBag,
                                         bool aIsFromNsIFile,
                                         ErrorResult& aRv)
@@ -419,17 +419,17 @@ MultipartBlobImpl::InitializeChromeFile(
     blob->GetType(mContentType);
   }
 
   BlobSet blobSet;
   blobSet.AppendBlobImpl(static_cast<File*>(blob.get())->Impl());
   mBlobImpls = blobSet.GetBlobImpls();
 
   SetLengthAndModifiedDate(aRv);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "SetLengthAndModifiedDate failed");
 }
 
 void
 MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindowInner* aWindow,
                                         const nsAString& aData,
                                         const ChromeFilePropertyBag& aBag,
                                         ErrorResult& aRv)
 {
--- a/dom/base/ScreenOrientation.cpp
+++ b/dom/base/ScreenOrientation.cpp
@@ -394,19 +394,21 @@ ScreenOrientation::UnlockDeviceOrientati
   if (!mFullScreenListener || !GetOwner()) {
     mFullScreenListener = nullptr;
     return;
   }
 
   // Remove event listener in case of fullscreen lock.
   nsCOMPtr<EventTarget> target = do_QueryInterface(GetOwner()->GetDoc());
   if (target) {
-    nsresult rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
-                                                    mFullScreenListener, /* useCapture */ true);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv =
+      target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
+                                        mFullScreenListener,
+                                        /* useCapture */ true);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RemoveSystemEventListener failed");
   }
 
   mFullScreenListener = nullptr;
 }
 
 OrientationType
 ScreenOrientation::DeviceType() const
 {
@@ -525,63 +527,63 @@ ScreenOrientation::Notify(const hal::Scr
     // the values we care about.
     return;
   }
 
   OrientationType previousOrientation = mType;
   mAngle = aConfiguration.angle();
   mType = InternalOrientationToType(orientation);
 
-  nsresult rv;
+  DebugOnly<nsresult> rv;
   if (mScreen && mType != previousOrientation) {
     // Use of mozorientationchange is deprecated.
     rv = mScreen->DispatchTrustedEvent(NS_LITERAL_STRING("mozorientationchange"));
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
   }
 
   if (doc->Hidden() && !mVisibleListener) {
     mVisibleListener = new VisibleEventListener();
     rv = doc->AddSystemEventListener(NS_LITERAL_STRING("visibilitychange"),
                                      mVisibleListener, /* useCapture = */ true);
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "AddSystemEventListener failed");
     return;
   }
 
   if (mType != doc->CurrentOrientationType()) {
     doc->SetCurrentOrientation(mType, mAngle);
 
     Promise* pendingPromise = doc->GetOrientationPendingPromise();
     if (pendingPromise) {
       pendingPromise->MaybeResolveWithUndefined();
       doc->SetOrientationPendingPromise(nullptr);
     }
 
     nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(this,
       &ScreenOrientation::DispatchChangeEvent);
     rv = NS_DispatchToMainThread(runnable);
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
   }
 }
 
 void
 ScreenOrientation::UpdateActiveOrientationLock(ScreenOrientationInternal aOrientation)
 {
   if (aOrientation == eScreenOrientation_None) {
     hal::UnlockScreenOrientation();
   } else {
-    bool rv = hal::LockScreenOrientation(aOrientation);
-    NS_WARN_IF(!rv);
+    DebugOnly<bool> ok = hal::LockScreenOrientation(aOrientation);
+    NS_WARNING_ASSERTION(ok, "hal::LockScreenOrientation failed");
   }
 }
 
 void
 ScreenOrientation::DispatchChangeEvent()
 {
-  nsresult rv = DispatchTrustedEvent(NS_LITERAL_STRING("change"));
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = DispatchTrustedEvent(NS_LITERAL_STRING("change"));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
 }
 
 JSObject*
 ScreenOrientation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return ScreenOrientationBinding::Wrap(aCx, this, aGivenProto);
 }
 
--- a/dom/base/nsContentIterator.cpp
+++ b/dom/base/nsContentIterator.cpp
@@ -11,32 +11,34 @@
 #include "nsRange.h"
 #include "nsIContent.h"
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 #include "nsContentUtils.h"
 #include "nsINode.h"
 #include "nsCycleCollectionParticipant.h"
 
+using mozilla::DebugOnly;
+
 // couple of utility static functs
 
 ///////////////////////////////////////////////////////////////////////////
 // NodeToParentOffset: returns the node's parent and offset.
 //
 
 static nsINode*
 NodeToParentOffset(nsINode* aNode, int32_t* aOffset)
 {
   *aOffset = 0;
 
   nsINode* parent = aNode->GetParentNode();
 
   if (parent) {
     *aOffset = parent->IndexOf(aNode);
-    NS_WARN_IF(*aOffset < 0);
+    NS_WARNING_ASSERTION(*aOffset >= 0, "bad offset");
   }
 
   return parent;
 }
 
 ///////////////////////////////////////////////////////////////////////////
 // NodeIsInTraversalRange: returns true if content is visited during
 // the traversal of the range in the specified mode.
@@ -68,17 +70,17 @@ NodeIsInTraversalRange(nsINode* aNode, b
   }
 
   nsINode* parent = aNode->GetParentNode();
   if (!parent) {
     return false;
   }
 
   int32_t indx = parent->IndexOf(aNode);
-  NS_WARN_IF(indx == -1);
+  NS_WARNING_ASSERTION(indx != -1, "bad indx");
 
   if (!aIsPreMode) {
     ++indx;
   }
 
   return nsContentUtils::ComparePoints(aStartNode, aStartOffset,
                                        parent, indx) <= 0 &&
          nsContentUtils::ComparePoints(aEndNode, aEndOffset,
@@ -270,20 +272,20 @@ nsContentIterator::Init(nsINode* aRoot)
   }
 
   mIsDone = false;
   mIndexes.Clear();
 
   if (mPre) {
     mFirst = aRoot;
     mLast  = GetDeepLastChild(aRoot);
-    NS_WARN_IF(!mLast);
+    NS_WARNING_ASSERTION(mLast, "GetDeepLastChild returned null");
   } else {
     mFirst = GetDeepFirstChild(aRoot);
-    NS_WARN_IF(!mFirst);
+    NS_WARNING_ASSERTION(mFirst, "GetDeepFirstChild returned null");
     mLast  = aRoot;
   }
 
   mCommonParent = aRoot;
   mCurNode = mFirst;
   RebuildIndexStack();
   return NS_OK;
 }
@@ -301,25 +303,25 @@ nsContentIterator::Init(nsIDOMRange* aDO
   // get common content parent
   mCommonParent = range->GetCommonAncestor();
   if (NS_WARN_IF(!mCommonParent)) {
     return NS_ERROR_FAILURE;
   }
 
   // get the start node and offset
   int32_t startIndx = range->StartOffset();
-  NS_WARN_IF(startIndx < 0);
+  NS_WARNING_ASSERTION(startIndx >= 0, "bad startIndx");
   nsINode* startNode = range->GetStartParent();
   if (NS_WARN_IF(!startNode)) {
     return NS_ERROR_FAILURE;
   }
 
   // get the end node and offset
   int32_t endIndx = range->EndOffset();
-  NS_WARN_IF(endIndx < 0);
+  NS_WARNING_ASSERTION(endIndx >= 0, "bad endIndx");
   nsINode* endNode = range->GetEndParent();
   if (NS_WARN_IF(!endNode)) {
     return NS_ERROR_FAILURE;
   }
 
   bool startIsData = startNode->IsNodeOfType(nsINode::eDATA_NODE);
 
   // short circuit when start node == end node
@@ -337,29 +339,29 @@ nsContentIterator::Init(nsIDOMRange* aDO
     }
 
     if (startIsData) {
       // It's a character data node.
       mFirst   = startNode->AsContent();
       mLast    = mFirst;
       mCurNode = mFirst;
 
-      nsresult rv = RebuildIndexStack();
-      NS_WARN_IF(NS_FAILED(rv));
+      DebugOnly<nsresult> rv = RebuildIndexStack();
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RebuildIndexStack failed");
       return NS_OK;
     }
   }
 
   // Find first node in range.
 
   nsIContent* cChild = nullptr;
 
   if (!startIsData && startNode->HasChildren()) {
     cChild = startNode->GetChildAt(startIndx);
-    NS_WARN_IF(!cChild);
+    NS_WARNING_ASSERTION(cChild, "GetChildAt returned null");
   }
 
   if (!cChild) {
     // no children, must be a text node
     //
     // XXXbz no children might also just mean no children.  So I'm not
     // sure what that comment above is talking about.
 
@@ -368,17 +370,17 @@ nsContentIterator::Init(nsIDOMRange* aDO
       //      character in the cdata node, should we set mFirst to
       //      the next sibling?
 
       // If the node has no child, the child may be <br> or something.
       // So, we shouldn't skip the empty node if the start offset is 0.
       // In other words, if the offset is 1, the node should be ignored.
       if (!startIsData && startIndx) {
         mFirst = GetNextSibling(startNode);
-        NS_WARN_IF(!mFirst);
+        NS_WARNING_ASSERTION(mFirst, "GetNextSibling returned null");
 
         // Does mFirst node really intersect the range?  The range could be
         // 'degenerate', i.e., not collapsed but still contain no content.
         if (mFirst &&
             NS_WARN_IF(!NodeIsInTraversalRange(mFirst, mPre, startNode,
                                                startIndx, endNode, endIndx))) {
           mFirst = nullptr;
         }
@@ -395,17 +397,17 @@ nsContentIterator::Init(nsIDOMRange* aDO
       }
     }
   } else {
     if (mPre) {
       mFirst = cChild;
     } else {
       // post-order
       mFirst = GetDeepFirstChild(cChild);
-      NS_WARN_IF(!mFirst);
+      NS_WARNING_ASSERTION(mFirst, "GetDeepFirstChild returned null");
 
       // Does mFirst node really intersect the range?  The range could be
       // 'degenerate', i.e., not collapsed but still contain no content.
 
       if (mFirst &&
           !NodeIsInTraversalRange(mFirst, mPre, startNode, startIndx,
                                   endNode, endIndx)) {
         mFirst = nullptr;
@@ -424,17 +426,17 @@ nsContentIterator::Init(nsIDOMRange* aDO
         // Not much else to do here...
         mLast = nullptr;
       } else {
         // If the end node is an empty element and the end offset is 0,
         // the last element should be the previous node (i.e., shouldn't
         // include the end node in the range).
         if (!endIsData && !endNode->HasChildren() && !endIndx) {
           mLast = GetPrevSibling(endNode);
-          NS_WARN_IF(!mLast);
+          NS_WARNING_ASSERTION(mLast, "GetPrevSibling returned null");
           if (NS_WARN_IF(!NodeIsInTraversalRange(mLast, mPre,
                                                  startNode, startIndx,
                                                  endNode, endIndx))) {
             mLast = nullptr;
           }
         } else {
           mLast = endNode->AsContent();
         }
@@ -442,17 +444,17 @@ nsContentIterator::Init(nsIDOMRange* aDO
     } else {
       // post-order
       //
       // XXX: In the future, if end offset is before the first character in the
       //      cdata node, should we set mLast to the prev sibling?
 
       if (!endIsData) {
         mLast = GetPrevSibling(endNode);
-        NS_WARN_IF(!mLast);
+        NS_WARNING_ASSERTION(mLast, "GetPrevSibling returned null");
 
         if (!NodeIsInTraversalRange(mLast, mPre,
                                     startNode, startIndx,
                                     endNode, endIndx)) {
           mLast = nullptr;
         }
       } else {
         mLast = endNode->AsContent();
@@ -466,17 +468,17 @@ nsContentIterator::Init(nsIDOMRange* aDO
     if (NS_WARN_IF(!cChild)) {
       // No child at offset!
       NS_NOTREACHED("nsContentIterator::nsContentIterator");
       return NS_ERROR_FAILURE;
     }
 
     if (mPre) {
       mLast  = GetDeepLastChild(cChild);
-      NS_WARN_IF(!mLast);
+      NS_WARNING_ASSERTION(mLast, "GetDeepLastChild returned null");
 
       if (NS_WARN_IF(!NodeIsInTraversalRange(mLast, mPre,
                                              startNode, startIndx,
                                              endNode, endIndx))) {
         mLast = nullptr;
       }
     } else {
       // post-order
@@ -492,18 +494,18 @@ nsContentIterator::Init(nsIDOMRange* aDO
   }
 
   mCurNode = mFirst;
   mIsDone  = !mCurNode;
 
   if (!mCurNode) {
     mIndexes.Clear();
   } else {
-    nsresult rv = RebuildIndexStack();
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = RebuildIndexStack();
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RebuildIndexStack failed");
   }
 
   return NS_OK;
 }
 
 
 /******************************************************
  * Helper routines
@@ -649,26 +651,26 @@ nsContentIterator::GetNextSibling(nsINod
   NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
                "ContentIterator stack underflow");
   if (aIndexes && !aIndexes->IsEmpty()) {
     // use the last entry on the Indexes array for the current index
     indx = (*aIndexes)[aIndexes->Length()-1];
   } else {
     indx = mCachedIndex;
   }
-  NS_WARN_IF(indx < 0);
+  NS_WARNING_ASSERTION(indx >= 0, "bad indx");
 
   // reverify that the index of the current node hasn't changed.
   // not super cheap, but a lot cheaper than IndexOf(), and still O(1).
   // ignore result this time - the index may now be out of range.
   nsIContent* sib = parent->GetChildAt(indx);
   if (sib != aNode) {
     // someone changed our index - find the new index the painful way
     indx = parent->IndexOf(aNode);
-    NS_WARN_IF(indx < 0);
+    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
   }
 
   // indx is now canonically correct
   if ((sib = parent->GetChildAt(++indx))) {
     // update index cache
     if (aIndexes && !aIndexes->IsEmpty()) {
       aIndexes->ElementAt(aIndexes->Length()-1) = indx;
     } else {
@@ -719,17 +721,17 @@ nsContentIterator::GetPrevSibling(nsINod
   }
 
   // reverify that the index of the current node hasn't changed
   // ignore result this time - the index may now be out of range.
   nsIContent* sib = parent->GetChildAt(indx);
   if (sib != aNode) {
     // someone changed our index - find the new index the painful way
     indx = parent->IndexOf(aNode);
-    NS_WARN_IF(indx < 0);
+    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
   }
 
   // indx is now canonically correct
   if (indx > 0 && (sib = parent->GetChildAt(--indx))) {
     // update index cache
     if (aIndexes && !aIndexes->IsEmpty()) {
       aIndexes->ElementAt(aIndexes->Length()-1) = indx;
     } else {
@@ -797,17 +799,17 @@ nsContentIterator::NextNode(nsINode* aNo
   // cheap, but a lot cheaper than IndexOf(), and still O(1).  ignore result
   // this time - the index may now be out of range.
   if (indx >= 0) {
     sibling = parent->GetChildAt(indx);
   }
   if (sibling != node) {
     // someone changed our index - find the new index the painful way
     indx = parent->IndexOf(node);
-    NS_WARN_IF(indx < 0);
+    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
   }
 
   // indx is now canonically correct
   sibling = parent->GetChildAt(++indx);
   if (sibling) {
     // update cache
     if (aIndexes && !aIndexes->IsEmpty()) {
       // replace an entry on the index stack
@@ -862,23 +864,23 @@ nsContentIterator::PrevNode(nsINode* aNo
       indx = mCachedIndex;
     }
 
     // reverify that the index of the current node hasn't changed.  not super
     // cheap, but a lot cheaper than IndexOf(), and still O(1).  ignore result
     // this time - the index may now be out of range.
     if (indx >= 0) {
       sibling = parent->GetChildAt(indx);
-      NS_WARN_IF(!sibling);
+      NS_WARNING_ASSERTION(sibling, "GetChildAt returned null");
     }
 
     if (sibling != node) {
       // someone changed our index - find the new index the painful way
       indx = parent->IndexOf(node);
-      NS_WARN_IF(indx < 0);
+      NS_WARNING_ASSERTION(indx >= 0, "bad indx");
     }
 
     // indx is now canonically correct
     if (indx && (sibling = parent->GetChildAt(--indx))) {
       // update cache
       if (aIndexes && !aIndexes->IsEmpty()) {
         // replace an entry on the index stack
         aIndexes->ElementAt(aIndexes->Length()-1) = indx;
@@ -898,22 +900,22 @@ nsContentIterator::PrevNode(nsINode* aNo
       // this might be wrong, but we are better off guessing
       mCachedIndex = 0;
     }
     return parent;
   }
 
   // post-order
   int32_t numChildren = node->GetChildCount();
-  NS_WARN_IF(numChildren < 0);
+  NS_WARNING_ASSERTION(numChildren >= 0, "no children");
 
   // if it has children then prev node is last child
   if (numChildren) {
     nsIContent* lastChild = node->GetLastChild();
-    NS_WARN_IF(!lastChild);
+    NS_WARNING_ASSERTION(lastChild, "GetLastChild returned null");
     numChildren--;
 
     // update cache
     if (aIndexes) {
       // push an entry on the index stack
       aIndexes->AppendElement(numChildren);
     } else {
       mCachedIndex = numChildren;
@@ -1021,42 +1023,42 @@ nsContentIterator::PositionAt(nsINode* a
 
   nsINode* firstNode = mFirst;
   nsINode* lastNode = mLast;
   int32_t firstOffset = 0, lastOffset = 0;
 
   if (firstNode && lastNode) {
     if (mPre) {
       firstNode = NodeToParentOffset(mFirst, &firstOffset);
-      NS_WARN_IF(!firstNode);
-      NS_WARN_IF(firstOffset < 0);
+      NS_WARNING_ASSERTION(firstNode, "NodeToParentOffset returned null");
+      NS_WARNING_ASSERTION(firstOffset >= 0, "bad firstOffset");
 
       if (lastNode->GetChildCount()) {
         lastOffset = 0;
       } else {
         lastNode = NodeToParentOffset(mLast, &lastOffset);
-        NS_WARN_IF(!lastNode);
-        NS_WARN_IF(lastOffset < 0);
+        NS_WARNING_ASSERTION(lastNode, "NodeToParentOffset returned null");
+        NS_WARNING_ASSERTION(lastOffset >= 0, "bad lastOffset");
         ++lastOffset;
       }
     } else {
       uint32_t numChildren = firstNode->GetChildCount();
 
       if (numChildren) {
         firstOffset = numChildren;
-        NS_WARN_IF(firstOffset < 0);
+        NS_WARNING_ASSERTION(firstOffset >= 0, "bad firstOffset");
       } else {
         firstNode = NodeToParentOffset(mFirst, &firstOffset);
-        NS_WARN_IF(!firstNode);
-        NS_WARN_IF(firstOffset < 0);
+        NS_WARNING_ASSERTION(firstNode, "NodeToParentOffset returned null");
+        NS_WARNING_ASSERTION(firstOffset >= 0, "bad firstOffset");
       }
 
       lastNode = NodeToParentOffset(mLast, &lastOffset);
-      NS_WARN_IF(!lastNode);
-      NS_WARN_IF(lastOffset < 0);
+      NS_WARNING_ASSERTION(lastNode, "NodeToParentOffset returned null");
+      NS_WARNING_ASSERTION(lastOffset >= 0, "bad lastOffset");
       ++lastOffset;
     }
   }
 
   // The end positions are always in the range even if it has no parent.  We
   // need to allow that or 'iter->Init(root)' would assert in Last() or First()
   // for example, bug 327694.
   if (mFirst != mCurNode && mLast != mCurNode &&
@@ -1113,17 +1115,17 @@ nsContentIterator::PositionAt(nsINode* a
     nsINode* parent = newCurNode->GetParentNode();
 
     if (NS_WARN_IF(!parent)) {
       // this node has no parent, and thus no index
       break;
     }
 
     int32_t indx = parent->IndexOf(newCurNode);
-    NS_WARN_IF(indx < 0);
+    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
 
     // insert at the head!
     newIndexes.InsertElementAt(0, indx);
 
     // look to see if the parent is in the stack
     indx = oldParentStack.IndexOf(parent);
     if (indx >= 0) {
       // ok, the parent IS on the old stack!  Rework things.  We want
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -9416,17 +9416,17 @@ nsContentUtils::HttpsStateIsModern(nsIDo
   if (principal->GetIsNullPrincipal()) {
     return false;
   }
 
   MOZ_ASSERT(principal->GetIsCodebasePrincipal());
 
   nsCOMPtr<nsIContentSecurityManager> csm =
     do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
-  NS_WARN_IF(!csm);
+  NS_WARNING_ASSERTION(csm, "csm is null");
   if (csm) {
     bool isTrustworthyOrigin = false;
     csm->IsOriginPotentiallyTrustworthy(principal, &isTrustworthyOrigin);
     if (isTrustworthyOrigin) {
       return true;
     }
   }
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2411,17 +2411,17 @@ nsGlobalWindow::ComputeIsSecureContext(n
     principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
     if (NS_WARN_IF(!principal)) {
       return false;
     }
   }
 
   nsCOMPtr<nsIContentSecurityManager> csm =
     do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
-  NS_WARN_IF(!csm);
+  NS_WARNING_ASSERTION(csm, "csm is null");
   if (csm) {
     bool isTrustworthyOrigin = false;
     csm->IsOriginPotentiallyTrustworthy(principal, &isTrustworthyOrigin);
     if (isTrustworthyOrigin) {
       return true;
     }
   }
 
--- a/dom/base/nsHostObjectProtocolHandler.cpp
+++ b/dom/base/nsHostObjectProtocolHandler.cpp
@@ -135,33 +135,34 @@ BroadcastBlobURLRegistration(const nsACS
   }
 
   ContentChild* cc = ContentChild::GetSingleton();
   BlobChild* actor = cc->GetOrCreateActorForBlobImpl(aBlobImpl);
   if (NS_WARN_IF(!actor)) {
     return;
   }
 
-  NS_WARN_IF(!cc->SendStoreAndBroadcastBlobURLRegistration(nsCString(aURI), actor,
-                                                           IPC::Principal(aPrincipal)));
+  Unused << NS_WARN_IF(!cc->SendStoreAndBroadcastBlobURLRegistration(
+    nsCString(aURI), actor, IPC::Principal(aPrincipal)));
 }
 
 void
 BroadcastBlobURLUnregistration(const nsACString& aURI, DataInfo* aInfo)
 {
   MOZ_ASSERT(aInfo);
   MOZ_ASSERT(NS_IsMainThread());
 
   if (XRE_IsParentProcess()) {
     ContentParent::BroadcastBlobURLUnregistration(aURI);
     return;
   }
 
   ContentChild* cc = ContentChild::GetSingleton();
-  NS_WARN_IF(!cc->SendUnstoreAndBroadcastBlobURLUnregistration(nsCString(aURI)));
+  Unused << NS_WARN_IF(!cc->SendUnstoreAndBroadcastBlobURLUnregistration(
+    nsCString(aURI)));
 }
 
 class HostObjectURLsReporter final : public nsIMemoryReporter
 {
   ~HostObjectURLsReporter() {}
 
  public:
   NS_DECL_ISUPPORTS
--- a/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothMapSmsManager.cpp
@@ -147,17 +147,17 @@ BluetoothMapSmsManager::Uninit()
     mMasSocket = nullptr;
   }
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   if (NS_WARN_IF(!obs)) {
     return;
   }
 
-  NS_WARN_IF(NS_FAILED(
+  Unused << NS_WARN_IF(NS_FAILED(
     obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID)));
 }
 
 // static
 void
 BluetoothMapSmsManager::InitMapSmsInterface(BluetoothProfileResultHandler* aRes)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
@@ -154,17 +154,17 @@ BluetoothPbapManager::Uninit()
     mSocket = nullptr;
   }
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   if (NS_WARN_IF(!obs)) {
     return;
   }
 
-  NS_WARN_IF(NS_FAILED(
+  Unused << NS_WARN_IF(NS_FAILED(
     obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID)));
 }
 
 // static
 void
 BluetoothPbapManager::InitPbapInterface(BluetoothProfileResultHandler* aRes)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/bluetooth/bluez/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluez/BluetoothSocket.cpp
@@ -4,20 +4,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "BluetoothSocket.h"
 #include <fcntl.h>
 #include "BluetoothSocketObserver.h"
 #include "BluetoothUnixSocketConnector.h"
 #include "BluetoothUtils.h"
+#include "mozilla/DebugOnly.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/Unused.h"
 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
 #include "nsXULAppAPI.h"
-#include "mozilla/Unused.h"
 
 using namespace mozilla::ipc;
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 static const size_t MAX_READ_SIZE = 1 << 16;
 
 //
@@ -237,17 +238,17 @@ BluetoothSocket::BluetoothSocketIO::List
       FireSocketError();
       return;
     }
     SetFd(fd);
 
     // calls OnListening on success, or OnError otherwise
     rv = UnixSocketWatcher::Listen(
       reinterpret_cast<struct sockaddr*>(&mAddress), mAddressLength);
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Listen failed");
   }
 }
 
 void
 BluetoothSocket::BluetoothSocketIO::Connect()
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
   MOZ_ASSERT(mConnector);
@@ -261,19 +262,19 @@ BluetoothSocket::BluetoothSocketIO::Conn
     if (NS_WARN_IF(NS_FAILED(rv))) {
       FireSocketError();
       return;
     }
     SetFd(fd);
   }
 
   // calls OnConnected() on success, or OnError() otherwise
-  nsresult rv = UnixSocketWatcher::Connect(
+  DebugOnly<nsresult> rv = UnixSocketWatcher::Connect(
     reinterpret_cast<struct sockaddr*>(&mAddress), mAddressLength);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Connect failed");
 }
 
 void
 BluetoothSocket::BluetoothSocketIO::Send(UnixSocketIOBuffer* aBuffer)
 {
   EnqueueData(aBuffer);
   AddWatchers(WRITE_WATCHER, false);
 }
--- a/dom/bluetooth/common/BluetoothUtils.cpp
+++ b/dom/bluetooth/common/BluetoothUtils.cpp
@@ -774,61 +774,61 @@ DispatchReplySuccess(BluetoothReplyRunna
                      const BluetoothValue& aValue)
 {
   MOZ_ASSERT(aRunnable);
   MOZ_ASSERT(aValue.type() != BluetoothValue::T__None);
 
   BluetoothReply* reply = new BluetoothReply(BluetoothReplySuccess(aValue));
 
   aRunnable->SetReply(reply); // runnable will delete reply after Run()
-  NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
+  Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
 }
 
 void
 DispatchReplyError(BluetoothReplyRunnable* aRunnable,
                    const nsAString& aErrorStr)
 {
   MOZ_ASSERT(aRunnable);
   MOZ_ASSERT(!aErrorStr.IsEmpty());
 
   // Reply will be deleted by the runnable after running on main thread
   BluetoothReply* reply =
     new BluetoothReply(BluetoothReplyError(STATUS_FAIL, nsString(aErrorStr)));
 
   aRunnable->SetReply(reply);
-  NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
+  Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
 }
 
 void
 DispatchReplyError(BluetoothReplyRunnable* aRunnable,
                    const enum BluetoothStatus aStatus)
 {
   MOZ_ASSERT(aRunnable);
   MOZ_ASSERT(aStatus != STATUS_SUCCESS);
 
   // Reply will be deleted by the runnable after running on main thread
   BluetoothReply* reply =
     new BluetoothReply(BluetoothReplyError(aStatus, EmptyString()));
 
   aRunnable->SetReply(reply);
-  NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
+  Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
 }
 
 void
 DispatchReplyError(BluetoothReplyRunnable* aRunnable,
                    const enum BluetoothGattStatus aGattStatus)
 {
   MOZ_ASSERT(aRunnable);
 
   // Reply will be deleted by the runnable after running on main thread
   BluetoothReply* reply =
     new BluetoothReply(BluetoothReplyError(aGattStatus, EmptyString()));
 
   aRunnable->SetReply(reply);
-  NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
+  Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(aRunnable)));
 }
 
 void
 DispatchStatusChangedEvent(const nsAString& aType,
                            const BluetoothAddress& aAddress,
                            bool aStatus)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -1444,20 +1444,20 @@ nsGonkCameraControl::OnAutoFocusMoving(b
     {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
       if (mAutoFocusCompleteTimer) {
         mAutoFocusCompleteTimer->Cancel();
 
         if (!mAutoFocusPending) {
           RefPtr<nsITimerCallback> timerCb = new AutoFocusMovingTimerCallback(this);
-          nsresult rv = mAutoFocusCompleteTimer->InitWithCallback(timerCb,
-                                                                  kAutoFocusCompleteTimeoutMs,
-                                                                  nsITimer::TYPE_ONE_SHOT);
-          NS_WARN_IF(NS_FAILED(rv));
+          DebugOnly<nsresult> rv =
+            mAutoFocusCompleteTimer->InitWithCallback(
+              timerCb, kAutoFocusCompleteTimeoutMs, nsITimer::TYPE_ONE_SHOT);
+          NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "InitWithCallback failed");
         }
         return;
       }
 
       if (!mAutoFocusPending) {
         expiredCount = mAutoFocusCompleteExpired;
       }
     }
--- a/dom/camera/TestGonkCameraHardware.cpp
+++ b/dom/camera/TestGonkCameraHardware.cpp
@@ -17,16 +17,17 @@
 #include "TestGonkCameraHardware.h"
 #include "CameraPreferences.h"
 #include "nsThreadUtils.h"
 #include "mozilla/dom/EventListenerBinding.h"
 #include "mozilla/dom/BlobEvent.h"
 #include "mozilla/dom/ErrorEvent.h"
 #include "mozilla/dom/CameraFacesDetectedEvent.h"
 #include "mozilla/dom/CameraStateChangeEvent.h"
+#include "mozilla/DebugOnly.h"
 #include "nsNetUtil.h"
 #include "DOMCameraDetectedFace.h"
 #include "nsServiceManagerUtils.h"
 #include "nsICameraTestHardware.h"
 
 using namespace android;
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -240,18 +241,18 @@ public:
   {
     if (NS_WARN_IF(!mTestHw)) {
       return NS_ERROR_INVALID_ARG;
     }
 
     MutexAutoLock lock(mTestHw->mMutex);
 
     mTestHw->mStatus = RunInline();
-    nsresult rv = mTestHw->mCondVar.Notify();
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = mTestHw->mCondVar.Notify();
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Notify failed");
     return NS_OK;
   }
 
   nsresult
   RunInline()
   {
     if (NS_WARN_IF(!mTestHw)) {
       return NS_ERROR_INVALID_ARG;
@@ -308,25 +309,25 @@ TestGonkCameraHardware::~TestGonkCameraH
     { }
 
   protected:
     NS_IMETHOD
     RunImpl() override
     {
       if (mTestHw->mDomListener) {
         mTestHw->mDomListener = nullptr;
-        nsresult rv = mJSTestWrapper->SetHandler(nullptr);
-        NS_WARN_IF(NS_FAILED(rv));
+        DebugOnly<nsresult> rv = mJSTestWrapper->SetHandler(nullptr);
+        NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetHandler failed");
       }
       return NS_OK;
     }
   };
 
-  nsresult rv = WaitWhileRunningOnMainThread(new Delegate(this));
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = WaitWhileRunningOnMainThread(new Delegate(this));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WaitWhileRunningOnMainThread failed");
   DOM_CAMERA_LOGA("^===== Destroyed TestGonkCameraHardware =====^\n");
 }
 
 nsresult
 TestGonkCameraHardware::WaitWhileRunningOnMainThread(RefPtr<ControlMessage> aRunnable)
 {
   MutexAutoLock lock(mMutex);
 
@@ -380,18 +381,18 @@ TestGonkCameraHardware::Init()
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       return NS_OK;
     }
   };
 
-  nsresult rv = WaitWhileRunningOnMainThread(new Delegate(this));
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = WaitWhileRunningOnMainThread(new Delegate(this));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WaitWhileRunningOnMainThread failed");
   return rv;
 }
 
 int
 TestGonkCameraHardware::AutoFocus()
 {
   class Delegate : public ControlMessage
   {
@@ -534,18 +535,18 @@ TestGonkCameraHardware::CancelTakePictur
     NS_IMETHOD
     RunImpl() override
     {
       return mJSTestWrapper->CancelTakePicture();
     }
   };
 
   DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
-  nsresult rv = WaitWhileRunningOnMainThread(new Delegate(this));
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = WaitWhileRunningOnMainThread(new Delegate(this));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WaitWhileRunningOnMainThread failed");
 }
 
 int
 TestGonkCameraHardware::StartPreview()
 {
   class Delegate : public ControlMessage
   {
   public:
@@ -583,18 +584,18 @@ TestGonkCameraHardware::StopPreview()
     NS_IMETHOD
     RunImpl() override
     {
       return mJSTestWrapper->StopPreview();
     }
   };
 
   DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
-  nsresult rv = WaitWhileRunningOnMainThread(new Delegate(this));
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = WaitWhileRunningOnMainThread(new Delegate(this));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WaitWhileRunningOnMainThread failed");
 }
 
 class TestGonkCameraHardware::PushParametersDelegate : public ControlMessage
 {
 public:
   PushParametersDelegate(TestGonkCameraHardware* aTestHw, String8* aParams)
     : ControlMessage(aTestHw)
     , mParams(aParams)
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -1376,17 +1376,17 @@ Console::MethodInternal(JSContext* aCx, 
     return;
   }
 
   // We do this only in workers for now.
   NotifyHandler(aCx, aData, callData);
 
   RefPtr<ConsoleCallDataRunnable> runnable =
     new ConsoleCallDataRunnable(this, callData);
-  NS_WARN_IF(!runnable->Dispatch(aCx));
+  Unused << NS_WARN_IF(!runnable->Dispatch(aCx));
 }
 
 // We store information to lazily compute the stack in the reserved slots of
 // LazyStackGetter.  The first slot always stores a JS object: it's either the
 // JS wrapper of the nsIStackFrame or the actual reified stack representation.
 // The second slot is a PrivateValue() holding an nsIStackFrame* when we haven't
 // reified the stack yet, or an UndefinedValue() otherwise.
 enum {
@@ -1473,18 +1473,18 @@ Console::ProcessCallData(JSContext* aCx,
     innerID = aData->mInnerIDString;
   } else {
     MOZ_ASSERT(aData->mIDType == ConsoleCallData::eNumber);
     outerID.AppendInt(aData->mOuterIDNumber);
     innerID.AppendInt(aData->mInnerIDNumber);
   }
 
   if (aData->mMethodName == MethodClear) {
-    nsresult rv = mStorage->ClearEvents(innerID);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = mStorage->ClearEvents(innerID);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "ClearEvents failed");
   }
 
   if (NS_FAILED(mStorage->RecordEvent(innerID, outerID, eventValue))) {
     NS_WARNING("Failed to record a console event.");
   }
 }
 
 bool
--- a/dom/events/DataTransferItem.cpp
+++ b/dom/events/DataTransferItem.cpp
@@ -421,17 +421,17 @@ DataTransferItem::GetAsString(FunctionSt
                 const nsAString& aStringData)
       : mCallback(aCallback), mStringData(aStringData)
     {}
 
     NS_IMETHOD Run() override
     {
       ErrorResult rv;
       mCallback->Call(mStringData, rv);
-      NS_WARN_IF(rv.Failed());
+      NS_WARNING_ASSERTION(!rv.Failed(), "callback failed");
       return rv.StealNSResult();
     }
   private:
     RefPtr<FunctionStringCallback> mCallback;
     nsString mStringData;
   };
 
   RefPtr<GASRunnable> runnable = new GASRunnable(aCallback, stringData);
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -602,17 +602,17 @@ FetchDriver::OnStartRequest(nsIRequest* 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     FailWithNetworkError();
     // Cancel request.
     return rv;
   }
 
   // Try to retarget off main thread.
   if (nsCOMPtr<nsIThreadRetargetableRequest> rr = do_QueryInterface(aRequest)) {
-    NS_WARN_IF(NS_FAILED(rr->RetargetDeliveryTo(sts)));
+    Unused << NS_WARN_IF(NS_FAILED(rr->RetargetDeliveryTo(sts)));
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FetchDriver::OnDataAvailable(nsIRequest* aRequest,
                              nsISupports* aContext,
                              nsIInputStream* aInputStream,
--- a/dom/filesystem/CreateDirectoryTask.cpp
+++ b/dom/filesystem/CreateDirectoryTask.cpp
@@ -95,17 +95,17 @@ CreateDirectoryTaskChild::SetSuccessRequ
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
 
   const FileSystemDirectoryResponse& r =
     aValue.get_FileSystemDirectoryResponse();
 
   aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(r.realPath()), true,
                               getter_AddRefs(mTargetPath));
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "NS_NewNativeLocalFile failed");
 }
 
 void
 CreateDirectoryTaskChild::HandlerCallback()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
   if (mFileSystem->IsShutdown()) {
     mPromise = nullptr;
--- a/dom/filesystem/DeviceStorageFileSystem.cpp
+++ b/dom/filesystem/DeviceStorageFileSystem.cpp
@@ -6,16 +6,17 @@
 
 #include "mozilla/dom/DeviceStorageFileSystem.h"
 
 #include "DeviceStorage.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileSystemUtils.h"
+#include "mozilla/Unused.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsDeviceStorage.h"
 #include "nsIFile.h"
 #include "nsPIDOMWindow.h"
 #include "nsGlobalWindow.h"
 
 namespace mozilla {
@@ -35,27 +36,29 @@ DeviceStorageFileSystem::DeviceStorageFi
     } else {
       mPermissionCheckType = ePermissionCheckRequired;
     }
   } else {
     AssertIsOnBackgroundThread();
   }
 
   // Get the permission name required to access the file system.
-  nsresult rv =
+  DebugOnly<nsresult> rv =
     DeviceStorageTypeChecker::GetPermissionForType(mStorageType, mPermission);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "GetPermissionForType failed");
 
   // Get the local path of the file system root.
   nsCOMPtr<nsIFile> rootFile;
   DeviceStorageFile::GetRootDirectoryForType(aStorageType,
                                              aStorageName,
                                              getter_AddRefs(rootFile));
 
-  NS_WARN_IF(!rootFile || NS_FAILED(rootFile->GetPath(mLocalOrDeviceStorageRootPath)));
+  Unused <<
+    NS_WARN_IF(!rootFile ||
+               NS_FAILED(rootFile->GetPath(mLocalOrDeviceStorageRootPath)));
 
   if (!XRE_IsParentProcess()) {
     return;
   }
 
   // DeviceStorageTypeChecker is a singleton object and must be initialized on
   // the main thread. We initialize it here so that we can use it on the worker
   // thread.
@@ -135,17 +138,17 @@ DeviceStorageFileSystem::GetDirectoryNam
   }
 
   if (equal) {
     aRetval = mStorageName;
     return;
   }
 
   FileSystemBase::GetDirectoryName(aFile, aRetval, aRv);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "GetDirectoryName failed");
 }
 
 bool
 DeviceStorageFileSystem::IsSafeFile(nsIFile* aFile) const
 {
   MOZ_ASSERT(XRE_IsParentProcess(), "Should be on parent process!");
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(aFile);
--- a/dom/filesystem/FileSystemBase.cpp
+++ b/dom/filesystem/FileSystemBase.cpp
@@ -115,17 +115,17 @@ FileSystemBase::IsSafeDirectory(Director
 void
 FileSystemBase::GetDirectoryName(nsIFile* aFile, nsAString& aRetval,
                                  ErrorResult& aRv) const
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aFile);
 
   aRv = aFile->GetLeafName(aRetval);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "GetLeafName failed");
 }
 
 void
 FileSystemBase::GetDOMPath(nsIFile* aFile,
                            nsAString& aRetval,
                            ErrorResult& aRv) const
 {
   AssertIsOnOwningThread();
--- a/dom/filesystem/FileSystemTaskBase.cpp
+++ b/dom/filesystem/FileSystemTaskBase.cpp
@@ -130,18 +130,18 @@ FileSystemTaskChildBase::GetFileSystem()
 void
 FileSystemTaskChildBase::Start()
 {
   mFileSystem->AssertIsOnOwningThread();
 
   if (HasError()) {
     // In this case we don't want to use IPC at all.
     RefPtr<ErrorRunnable> runnable = new ErrorRunnable(this);
-    nsresult rv = NS_DispatchToCurrentThread(runnable);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = NS_DispatchToCurrentThread(runnable);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToCurrentThread failed");
     return;
   }
 
   if (mFileSystem->IsShutdown()) {
     return;
   }
 
   nsAutoString serialization;
@@ -230,23 +230,23 @@ FileSystemTaskParentBase::~FileSystemTas
 
 void
 FileSystemTaskParentBase::Start()
 {
   AssertIsOnBackgroundThread();
   mFileSystem->AssertIsOnOwningThread();
 
   if (NeedToGoToMainThread()) {
-    nsresult rv = NS_DispatchToMainThread(this, NS_DISPATCH_NORMAL);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = NS_DispatchToMainThread(this, NS_DISPATCH_NORMAL);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToCurrentThread failed");
     return;
   }
 
-  nsresult rv = DispatchToIOThread(this);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = DispatchToIOThread(this);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchToIOThread failed");
 }
 
 void
 FileSystemTaskParentBase::HandleResult()
 {
   AssertIsOnBackgroundThread();
   mFileSystem->AssertIsOnOwningThread();
 
--- a/dom/filesystem/compat/CallbackRunnables.cpp
+++ b/dom/filesystem/compat/CallbackRunnables.cpp
@@ -7,16 +7,17 @@
 #include "CallbackRunnables.h"
 #include "mozilla/dom/DirectoryBinding.h"
 #include "mozilla/dom/DOMError.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileBinding.h"
 #include "mozilla/dom/FileSystemDirectoryReaderBinding.h"
 #include "mozilla/dom/FileSystemFileEntry.h"
 #include "mozilla/dom/Promise.h"
+#include "mozilla/Unused.h"
 #include "nsIGlobalObject.h"
 #include "nsPIDOMWindow.h"
 
 namespace mozilla {
 namespace dom {
 
 EntryCallbackRunnable::EntryCallbackRunnable(FileSystemEntryCallback* aCallback,
                                              FileSystemEntry* aEntry)
@@ -136,34 +137,34 @@ GetEntryHelper::RejectedCallback(JSConte
 void
 GetEntryHelper::Error(nsresult aError)
 {
   MOZ_ASSERT(NS_FAILED(aError));
 
   if (mErrorCallback) {
     RefPtr<ErrorCallbackRunnable> runnable =
       new ErrorCallbackRunnable(mGlobal, mErrorCallback, aError);
-    nsresult rv = NS_DispatchToMainThread(runnable);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
   }
 }
 
 NS_IMPL_ISUPPORTS0(GetEntryHelper);
 
 /* static */ void
 ErrorCallbackHelper::Call(nsIGlobalObject* aGlobal,
                           const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
                           nsresult aError)
 {
   MOZ_ASSERT(aGlobal);
   MOZ_ASSERT(NS_FAILED(aError));
 
   if (aErrorCallback.WasPassed()) {
     RefPtr<ErrorCallbackRunnable> runnable =
       new ErrorCallbackRunnable(aGlobal, &aErrorCallback.Value(), aError);
-    nsresult rv = NS_DispatchToMainThread(runnable);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
   }
 }
 
 } // dom namespace
 } // mozilla namespace
 
--- a/dom/filesystem/compat/FileSystemDirectoryReader.cpp
+++ b/dom/filesystem/compat/FileSystemDirectoryReader.cpp
@@ -93,18 +93,18 @@ public:
 
   virtual void
   RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
   {
     if (mErrorCallback) {
       RefPtr<ErrorCallbackRunnable> runnable =
         new ErrorCallbackRunnable(mGlobal, mErrorCallback,
                                   NS_ERROR_DOM_INVALID_STATE_ERR);
-      nsresult rv = NS_DispatchToMainThread(runnable);
-      NS_WARN_IF(NS_FAILED(rv));
+      DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
     }
   }
 
 private:
   ~PromiseHandler() {}
 
   nsCOMPtr<nsIGlobalObject> mGlobal;
   RefPtr<FileSystem> mFileSystem;
@@ -155,17 +155,17 @@ FileSystemDirectoryReader::ReadEntries(F
                                        ErrorResult& aRv)
 {
   MOZ_ASSERT(mDirectory);
 
   if (mAlreadyRead) {
     RefPtr<EmptyEntriesCallbackRunnable> runnable =
       new EmptyEntriesCallbackRunnable(&aSuccessCallback);
     aRv = NS_DispatchToMainThread(runnable);
-    NS_WARN_IF(aRv.Failed());
+    NS_WARNING_ASSERTION(!aRv.Failed(), "NS_DispatchToMainThread failed");
     return;
   }
 
   // This object can be used only once.
   mAlreadyRead = true;
 
   ErrorResult rv;
   RefPtr<Promise> promise = mDirectory->GetFilesAndDirectories(rv);
--- a/dom/filesystem/compat/FileSystemFileEntry.cpp
+++ b/dom/filesystem/compat/FileSystemFileEntry.cpp
@@ -98,14 +98,14 @@ FileSystemFileEntry::CreateWriter(VoidCa
 }
 
 void
 FileSystemFileEntry::GetFile(BlobCallback& aSuccessCallback,
                              const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
 {
   RefPtr<BlobCallbackRunnable> runnable =
     new BlobCallbackRunnable(&aSuccessCallback, mFile);
-  nsresult rv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
 }
 
 } // dom namespace
 } // mozilla namespace
--- a/dom/filesystem/compat/FileSystemRootDirectoryEntry.cpp
+++ b/dom/filesystem/compat/FileSystemRootDirectoryEntry.cpp
@@ -111,18 +111,18 @@ FileSystemRootDirectoryEntry::GetInterna
       ErrorCallbackHelper::Call(GetParentObject(), aErrorCallback,
                                 NS_ERROR_DOM_TYPE_MISMATCH_ERR);
       return;
     }
 
     if (aSuccessCallback.WasPassed()) {
       RefPtr<EntryCallbackRunnable> runnable =
         new EntryCallbackRunnable(&aSuccessCallback.Value(), entry);
-      nsresult rv = NS_DispatchToMainThread(runnable);
-      NS_WARN_IF(NS_FAILED(rv));
+      DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
     }
     return;
   }
 
   // Subdirectories, but this is a file.
   if (entry->IsFile()) {
     ErrorCallbackHelper::Call(GetParentObject(), aErrorCallback,
                               NS_ERROR_DOM_NOT_FOUND_ERR);
--- a/dom/filesystem/compat/FileSystemRootDirectoryReader.cpp
+++ b/dom/filesystem/compat/FileSystemRootDirectoryReader.cpp
@@ -74,23 +74,23 @@ void
 FileSystemRootDirectoryReader::ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
                                            const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
                                            ErrorResult& aRv)
 {
   if (mAlreadyRead) {
     RefPtr<EmptyEntriesCallbackRunnable> runnable =
       new EmptyEntriesCallbackRunnable(&aSuccessCallback);
     aRv = NS_DispatchToMainThread(runnable);
-    NS_WARN_IF(aRv.Failed());
+    NS_WARNING_ASSERTION(!aRv.Failed(), "NS_DispatchToMainThread failed");
     return;
   }
 
   // This object can be used only once.
   mAlreadyRead = true;
 
   RefPtr<EntriesCallbackRunnable> runnable =
     new EntriesCallbackRunnable(&aSuccessCallback, mEntries);
   aRv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "NS_DispatchToMainThread failed");
 }
 
 } // dom namespace
 } // mozilla namespace
--- a/dom/flyweb/FlyWebService.cpp
+++ b/dom/flyweb/FlyWebService.cpp
@@ -319,22 +319,22 @@ FlyWebMDNSService::OnDiscoveryStarted(co
   LOG_I("===========================================");
 
   // Clear the new service array.
   mNewServiceSet.Clear();
 
   // If service discovery is inactive, then stop network discovery immediately.
   if (!mDiscoveryActive) {
     // Set the stop timer to fire immediately.
-    NS_WARN_IF(NS_FAILED(mDiscoveryStopTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
+    Unused << NS_WARN_IF(NS_FAILED(mDiscoveryStopTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
     return NS_OK;
   }
 
   // Otherwise, set the stop timer to fire in 5 seconds.
-  NS_WARN_IF(NS_FAILED(mDiscoveryStopTimer->InitWithCallback(this, 5 * 1000, nsITimer::TYPE_ONE_SHOT)));
+  Unused << NS_WARN_IF(NS_FAILED(mDiscoveryStopTimer->InitWithCallback(this, 5 * 1000, nsITimer::TYPE_ONE_SHOT)));
 
   return NS_OK;
 }
 
 nsresult
 FlyWebMDNSService::OnDiscoveryStopped(const nsACString& aServiceType)
 {
   LOG_I("///////////////////////////////////////////");
@@ -358,17 +358,17 @@ FlyWebMDNSService::OnDiscoveryStopped(co
       iter.Remove();
     }
   }
 
   // Notify FlyWebService of changed service list.
   mService->NotifyDiscoveredServicesChanged();
 
   // Start discovery again immediately.
-  NS_WARN_IF(NS_FAILED(mDiscoveryStartTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
+  Unused << NS_WARN_IF(NS_FAILED(mDiscoveryStartTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
 
   return NS_OK;
 }
 
 nsresult
 FlyWebMDNSService::OnServiceFound(nsIDNSServiceInfo* aServiceInfo)
 {
   LogDNSInfo(aServiceInfo, "FlyWebMDNSService::OnServiceFound");
@@ -400,32 +400,32 @@ FlyWebMDNSService::OnStartDiscoveryFaile
   LOG_E("MDNSService::OnStartDiscoveryFailed(%s): %d", PromiseFlatCString(aServiceType).get(), (int) aErrorCode);
 
   MOZ_ASSERT(mDiscoveryState == DISCOVERY_STARTING);
   mDiscoveryState = DISCOVERY_IDLE;
   mNumConsecutiveStartDiscoveryFailures++;
 
   // If discovery is active, and the number of consecutive failures is < 3, try starting again.
   if (mDiscoveryActive && mNumConsecutiveStartDiscoveryFailures < 3) {
-    NS_WARN_IF(NS_FAILED(mDiscoveryStartTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
+    Unused << NS_WARN_IF(NS_FAILED(mDiscoveryStartTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
   }
 
   return NS_OK;
 }
 
 nsresult
 FlyWebMDNSService::OnStopDiscoveryFailed(const nsACString& aServiceType, int32_t aErrorCode)
 {
   LOG_E("MDNSService::OnStopDiscoveryFailed(%s)", PromiseFlatCString(aServiceType).get());
   MOZ_ASSERT(mDiscoveryState == DISCOVERY_STOPPING);
   mDiscoveryState = DISCOVERY_IDLE;
 
   // If discovery is active, start discovery again immediately.
   if (mDiscoveryActive) {
-    NS_WARN_IF(NS_FAILED(mDiscoveryStartTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
+    Unused << NS_WARN_IF(NS_FAILED(mDiscoveryStartTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT)));
   }
 
   return NS_OK;
 }
 
 static bool
 IsAcceptableServiceAddress(const nsCString& addr)
 {
--- a/dom/gamepad/ipc/GamepadEventChannelChild.cpp
+++ b/dom/gamepad/ipc/GamepadEventChannelChild.cpp
@@ -27,16 +27,16 @@ class GamepadUpdateRunnable final : publ
 };
 
 } // namespace
 
 bool
 GamepadEventChannelChild::RecvGamepadUpdate(
                                        const GamepadChangeEvent& aGamepadEvent)
 {
-  nsresult rv;
-  rv = NS_DispatchToMainThread(new GamepadUpdateRunnable(aGamepadEvent));
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv =
+    NS_DispatchToMainThread(new GamepadUpdateRunnable(aGamepadEvent));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
   return true;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -248,28 +248,28 @@ public:
   {
     nsTArray<OwningFileOrDirectory> array;
     for (uint32_t i = 0; i < aFiles.Length(); ++i) {
       OwningFileOrDirectory* element = array.AppendElement();
       element->SetAsFile() = aFiles[i];
     }
 
     mInputElement->SetFilesOrDirectories(array, true);
-    NS_WARN_IF(NS_FAILED(DispatchEvents()));
+    Unused << NS_WARN_IF(NS_FAILED(DispatchEvents()));
   }
 
   nsresult
   DispatchEvents()
   {
     nsresult rv = NS_OK;
     rv = nsContentUtils::DispatchTrustedEvent(mInputElement->OwnerDoc(),
                                               static_cast<nsIDOMHTMLInputElement*>(mInputElement.get()),
                                               NS_LITERAL_STRING("input"), true,
                                               false);
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
 
     rv = nsContentUtils::DispatchTrustedEvent(mInputElement->OwnerDoc(),
                                               static_cast<nsIDOMHTMLInputElement*>(mInputElement.get()),
                                               NS_LITERAL_STRING("change"), true,
                                               false);
 
     return rv;
   }
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -15,16 +15,17 @@
 #include "GeckoProfiler.h"
 #include "TabChild.h"
 #include "HandlerServiceChild.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ProcessHangMonitorIPC.h"
+#include "mozilla/Unused.h"
 #include "mozilla/devtools/HeapSnapshotTempFileHelperChild.h"
 #include "mozilla/docshell/OfflineCacheUpdateChild.h"
 #include "mozilla/dom/ContentBridgeChild.h"
 #include "mozilla/dom/ContentBridgeParent.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/DOMStorageIPC.h"
 #include "mozilla/dom/ExternalHelperAppChild.h"
@@ -1047,29 +1048,29 @@ ContentChild::RecvPMemoryReportRequestCo
   PMemoryReportRequestChild* aChild,
   const uint32_t& aGeneration,
   const bool& aAnonymize,
   const bool& aMinimizeMemoryUsage,
   const MaybeFileDesc& aDMDFile)
 {
   MemoryReportRequestChild *actor =
     static_cast<MemoryReportRequestChild*>(aChild);
-  nsresult rv;
+  DebugOnly<nsresult> rv;
 
   if (aMinimizeMemoryUsage) {
     nsCOMPtr<nsIMemoryReporterManager> mgr =
       do_GetService("@mozilla.org/memory-reporter-manager;1");
     rv = mgr->MinimizeMemoryUsage(actor);
     // mgr will eventually call actor->Run()
   } else {
     rv = actor->Run();
   }
 
   // Bug 1295622: don't kill the process just because this failed.
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "actor operation failed");
   return true;
 }
 
 NS_IMETHODIMP MemoryReportRequestChild::Run()
 {
   ContentChild *child = static_cast<ContentChild*>(Manager());
   nsCOMPtr<nsIMemoryReporterManager> mgr =
     do_GetService("@mozilla.org/memory-reporter-manager;1");
@@ -1084,17 +1085,18 @@ NS_IMETHODIMP MemoryReportRequestChild::
     new HandleReportCallback(this, process);
   RefPtr<FinishReportingCallback> finishReporting =
     new FinishReportingCallback(this);
 
   nsresult rv =
     mgr->GetReportsForThisProcessExtended(handleReport, nullptr, mAnonymize,
                                           FileDescriptorToFILE(mDMDFile, "wb"),
                                           finishReporting, nullptr);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                       "GetReportsForThisProcessExtended failed");
   return rv;
 }
 
 bool
 ContentChild::DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor)
 {
   static_cast<MemoryReportRequestChild*>(actor)->Release();
   return true;
@@ -1605,35 +1607,35 @@ ContentChild::DeallocPFlyWebPublishedSer
 }
 
 bool
 ContentChild::RecvNotifyPresentationReceiverLaunched(PBrowserChild* aIframe,
                                                      const nsString& aSessionId)
 {
   nsCOMPtr<nsIDocShell> docShell =
     do_GetInterface(static_cast<TabChild*>(aIframe)->WebNavigation());
-  NS_WARN_IF(!docShell);
+  NS_WARNING_ASSERTION(docShell, "WebNavigation failed");
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
-  NS_WARN_IF(!service);
-
-  NS_WARN_IF(NS_FAILED(static_cast<PresentationIPCService*>(service.get())->MonitorResponderLoading(aSessionId, docShell)));
+  NS_WARNING_ASSERTION(service, "presentation service is missing");
+
+  Unused << NS_WARN_IF(NS_FAILED(static_cast<PresentationIPCService*>(service.get())->MonitorResponderLoading(aSessionId, docShell)));
 
   return true;
 }
 
 bool
 ContentChild::RecvNotifyPresentationReceiverCleanUp(const nsString& aSessionId)
 {
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
-  NS_WARN_IF(!service);
-
-  NS_WARN_IF(NS_FAILED(service->UntrackSessionInfo(aSessionId, nsIPresentationService::ROLE_RECEIVER)));
+  NS_WARNING_ASSERTION(service, "presentation service is missing");
+
+  Unused << NS_WARN_IF(NS_FAILED(service->UntrackSessionInfo(aSessionId, nsIPresentationService::ROLE_RECEIVER)));
 
   return true;
 }
 
 bool
 ContentChild::RecvNotifyGMPsChanged()
 {
   GMPDecoderModule::UpdateUsableCodecs();
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -353,17 +353,17 @@ private:
   }
 };
 
 MemoryReportRequestParent::MemoryReportRequestParent(uint32_t aGeneration)
   : mGeneration(aGeneration)
 {
   MOZ_COUNT_CTOR(MemoryReportRequestParent);
   mReporterManager = nsMemoryReporterManager::GetOrCreate();
-  NS_WARN_IF(!mReporterManager);
+  NS_WARNING_ASSERTION(mReporterManager, "GetOrCreate failed");
 }
 
 bool
 MemoryReportRequestParent::RecvReport(const MemoryReport& aReport)
 {
   if (mReporterManager) {
     mReporterManager->HandleChildReport(mGeneration, aReport);
   }
--- a/dom/ipc/ContentProcess.cpp
+++ b/dom/ipc/ContentProcess.cpp
@@ -44,20 +44,20 @@ SetTmpEnvironmentVariable(nsIFile* aValu
   // Save the TMP environment variable so that is is picked up by GetTempPath().
   // Note that we specifically write to the TMP variable, as that is the first
   // variable that is checked by GetTempPath() to determine its output.
   nsAutoString fullTmpPath;
   nsresult rv = aValue->GetPath(fullTmpPath);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
-  NS_WARN_IF(!SetEnvironmentVariableW(L"TMP", fullTmpPath.get()));
+  Unused << NS_WARN_IF(!SetEnvironmentVariableW(L"TMP", fullTmpPath.get()));
   // We also set TEMP in case there is naughty third-party code that is
   // referencing the environment variable directly.
-  NS_WARN_IF(!SetEnvironmentVariableW(L"TEMP", fullTmpPath.get()));
+  Unused << NS_WARN_IF(!SetEnvironmentVariableW(L"TEMP", fullTmpPath.get()));
 }
 #endif
 
 #if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX)
 static bool
 IsSandboxTempDirRequired()
 {
   // On OSX, use the sandbox-writable temp when the pref level >= 1.
@@ -67,17 +67,17 @@ IsSandboxTempDirRequired()
 static void
 SetTmpEnvironmentVariable(nsIFile* aValue)
 {
   nsAutoCString fullTmpPath;
   nsresult rv = aValue->GetNativePath(fullTmpPath);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
-  NS_WARN_IF(setenv("TMPDIR", fullTmpPath.get(), 1) != 0);
+  Unused << NS_WARN_IF(setenv("TMPDIR", fullTmpPath.get(), 1) != 0);
 }
 #endif
 
 #if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX)
 static void
 SetUpSandboxEnvironment()
 {
   MOZ_ASSERT(nsDirectoryService::gService,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1968,18 +1968,19 @@ TabParent::RecvOnEventNeedingAckHandled(
   mContentCache.OnEventNeedingAckHandled(widget, aMessage);
   return true;
 }
 
 void
 TabParent::HandledWindowedPluginKeyEvent(const NativeEventData& aKeyEventData,
                                          bool aIsConsumed)
 {
-  bool ok = SendHandledWindowedPluginKeyEvent(aKeyEventData, aIsConsumed);
-  NS_WARN_IF(!ok);
+  DebugOnly<bool> ok =
+    SendHandledWindowedPluginKeyEvent(aKeyEventData, aIsConsumed);
+  NS_WARNING_ASSERTION(ok, "SendHandledWindowedPluginKeyEvent failed");
 }
 
 bool
 TabParent::RecvOnWindowedPluginKeyEvent(const NativeEventData& aKeyEventData)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (NS_WARN_IF(!widget)) {
     // Notifies the plugin process of the key event being not consumed by us.
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -525,17 +525,18 @@ AudioStream::GetUnprocessed(AudioBufferW
     auto timeStretcher = mTimeStretcher;
     aWriter.Write([timeStretcher] (AudioDataValue* aPtr, uint32_t aFrames) {
       return timeStretcher->receiveSamples(aPtr, aFrames);
     }, aWriter.Available());
 
     // TODO: There might be still unprocessed samples in the stretcher.
     // We should either remove or flush them so they won't be in the output
     // next time we switch a playback rate other than 1.0.
-    NS_WARN_IF(mTimeStretcher->numUnprocessedSamples() > 0);
+    NS_WARNING_ASSERTION(
+      mTimeStretcher->numUnprocessedSamples() == 0, "no samples");
   }
 
   while (aWriter.Available() > 0) {
     UniquePtr<Chunk> c = mDataSource.PopFrames(aWriter.Available());
     if (c->Frames() == 0) {
       break;
     }
     MOZ_ASSERT(c->Frames() <= aWriter.Available());
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -2606,17 +2606,17 @@ MediaStream::AddMainThreadListener(MainT
 
   private:
     ~NotifyRunnable() {}
 
     RefPtr<MediaStream> mStream;
   };
 
   nsCOMPtr<nsIRunnable> runnable = new NotifyRunnable(this);
-  NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable.forget())));
+  Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(runnable.forget())));
 }
 
 SourceMediaStream::SourceMediaStream() :
   MediaStream(),
   mMutex("mozilla::media::SourceMediaStream"),
   mUpdateKnownTracksTime(0),
   mPullEnabled(false),
   mUpdateFinished(false),
--- a/dom/media/TextTrackList.cpp
+++ b/dom/media/TextTrackList.cpp
@@ -183,17 +183,17 @@ TextTrackList::CreateAndDispatchTrackEve
   RefPtr<TrackEvent> event =
     TrackEvent::Constructor(this, aEventName, eventInit);
 
   // Dispatch the TrackEvent asynchronously.
   rv = thread->Dispatch(do_AddRef(new TrackEventRunner(this, event)),
                         NS_DISPATCH_NORMAL);
 
   // If we are shutting down this can file but it's still ok.
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Dispatch failed");
 }
 
 HTMLMediaElement*
 TextTrackList::GetMediaElement()
 {
   if (mTextTrackManager) {
     return mTextTrackManager->mMediaElement;
   }
--- a/dom/network/TCPSocket.cpp
+++ b/dom/network/TCPSocket.cpp
@@ -763,17 +763,17 @@ TCPSocket::MaybeReportErrorAndCloseIfOpe
           errName.AssignLiteral("NetworkInterruptError");
           break;
         default:
           errName.AssignLiteral("NetworkError");
           break;
       }
     }
 
-    NS_WARN_IF(NS_FAILED(FireErrorEvent(errName, errorType)));
+    Unused << NS_WARN_IF(NS_FAILED(FireErrorEvent(errName, errorType)));
   }
 
   return FireEvent(NS_LITERAL_STRING("close"));
 }
 
 void
 TCPSocket::Close()
 {
--- a/dom/network/UDPSocket.cpp
+++ b/dom/network/UDPSocket.cpp
@@ -225,25 +225,25 @@ UDPSocket::JoinMulticastGroup(const nsAS
   MOZ_ASSERT(mSocket || mSocketChild);
 
   NS_ConvertUTF16toUTF8 address(aMulticastGroupAddress);
 
   if (mSocket) {
     MOZ_ASSERT(!mSocketChild);
 
     aRv = mSocket->JoinMulticast(address, EmptyCString());
-    NS_WARN_IF(aRv.Failed());
+    NS_WARNING_ASSERTION(!aRv.Failed(), "JoinMulticast failed");
 
     return;
   }
 
   MOZ_ASSERT(mSocketChild);
 
   aRv = mSocketChild->JoinMulticast(address, EmptyCString());
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "JoinMulticast failed");
 }
 
 void
 UDPSocket::LeaveMulticastGroup(const nsAString& aMulticastGroupAddress,
                                ErrorResult& aRv)
 {
   if (mReadyState == SocketReadyState::Closed) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
@@ -258,24 +258,24 @@ UDPSocket::LeaveMulticastGroup(const nsA
 
   MOZ_ASSERT(mSocket || mSocketChild);
 
   nsCString address = NS_ConvertUTF16toUTF8(aMulticastGroupAddress);
   if (mSocket) {
     MOZ_ASSERT(!mSocketChild);
 
     aRv = mSocket->LeaveMulticast(address, EmptyCString());
-    NS_WARN_IF(aRv.Failed());
+    NS_WARNING_ASSERTION(!aRv.Failed(), "mSocket->LeaveMulticast failed");
     return;
   }
 
   MOZ_ASSERT(mSocketChild);
 
   aRv = mSocketChild->LeaveMulticast(address, EmptyCString());
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "mSocketChild->LeaveMulticast failed");
 }
 
 nsresult
 UDPSocket::DoPendingMcastCommand()
 {
   MOZ_ASSERT(mReadyState == SocketReadyState::Open, "Multicast command can only be executed after socket opened");
 
   for (uint32_t i = 0; i < mPendingMcastCommands.Length(); ++i) {
--- a/dom/network/UDPSocketParent.cpp
+++ b/dom/network/UDPSocketParent.cpp
@@ -288,42 +288,44 @@ static void CheckSTSThread()
 
 
 // Proxy the Connect() request to the STS thread, since it may block and
 // should be done there.
 bool
 UDPSocketParent::RecvConnect(const UDPAddressInfo& aAddressInfo)
 {
   nsCOMPtr<nsIEventTarget> thread(NS_GetCurrentThread());
-  NS_WARN_IF(NS_FAILED(GetSTSThread()->Dispatch(WrapRunnable(
-                                                  this,
-                                                  &UDPSocketParent::DoConnect,
-                                                  mSocket,
-                                                  thread,
-                                                  aAddressInfo),
-                                                NS_DISPATCH_NORMAL)));
+  Unused <<
+    NS_WARN_IF(NS_FAILED(GetSTSThread()->Dispatch(WrapRunnable(
+                                                    this,
+                                                    &UDPSocketParent::DoConnect,
+                                                    mSocket,
+                                                    thread,
+                                                    aAddressInfo),
+                                                  NS_DISPATCH_NORMAL)));
   return true;
 }
 
 void
 UDPSocketParent::DoSendConnectResponse(const UDPAddressInfo& aAddressInfo)
 {
   // can't use directly with WrapRunnable due to warnings
   mozilla::Unused << SendCallbackConnected(aAddressInfo);
 }
 
 void
 UDPSocketParent::SendConnectResponse(nsIEventTarget *aThread,
                                      const UDPAddressInfo& aAddressInfo)
 {
-  NS_WARN_IF(NS_FAILED(aThread->Dispatch(WrapRunnable(
-                                           this,
-                                           &UDPSocketParent::DoSendConnectResponse,
-                                           aAddressInfo),
-                                         NS_DISPATCH_NORMAL)));
+  Unused <<
+    NS_WARN_IF(NS_FAILED(aThread->Dispatch(WrapRunnable(
+                                             this,
+                                             &UDPSocketParent::DoSendConnectResponse,
+                                             aAddressInfo),
+                                           NS_DISPATCH_NORMAL)));
 }
 
 // Runs on STS thread
 void
 UDPSocketParent::DoConnect(nsCOMPtr<nsIUDPSocket>& aSocket,
                            nsCOMPtr<nsIEventTarget>& aReturnThread,
                            const UDPAddressInfo& aAddressInfo)
 {
@@ -618,17 +620,18 @@ UDPSocketParent::FireInternalError(uint3
                                        NS_LITERAL_CSTRING(__FILE__), aLineNo);
 }
 
 void
 UDPSocketParent::SendInternalError(nsIEventTarget *aThread,
                                    uint32_t aLineNo)
 {
   UDPSOCKET_LOG(("SendInternalError: %u", aLineNo));
-  NS_WARN_IF(NS_FAILED(aThread->Dispatch(WrapRunnable(
-                                           this,
-                                           &UDPSocketParent::FireInternalError,
-                                           aLineNo),
-                                         NS_DISPATCH_NORMAL)));
+  Unused <<
+    NS_WARN_IF(NS_FAILED(aThread->Dispatch(WrapRunnable(
+                                             this,
+                                             &UDPSocketParent::FireInternalError,
+                                             aLineNo),
+                                           NS_DISPATCH_NORMAL)));
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -1802,17 +1802,17 @@ nsNPAPIPluginInstance::GetOrCreateAudioC
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
 {
   // We just support mute/unmute
   nsresult rv = SetMuted(aMuted);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetMuted failed");
   return rv;
 }
 
 NS_IMETHODIMP
 nsNPAPIPluginInstance::WindowSuspendChanged(nsSuspendedTypes aSuspend)
 {
   // It doesn't support suspended, so we just do something like mute/unmute.
   WindowVolumeChanged(1.0, /* useless */
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -980,19 +980,19 @@ nsPluginInstanceOwner::RequestCommitOrCa
 void
 nsPluginInstanceOwner::HandledWindowedPluginKeyEvent(
                          const NativeEventData& aKeyEventData,
                          bool aIsConsumed)
 {
   if (NS_WARN_IF(!mInstance)) {
     return;
   }
-  nsresult rv =
+  DebugOnly<nsresult> rv =
     mInstance->HandledWindowedPluginKeyEvent(aKeyEventData, aIsConsumed);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "HandledWindowedPluginKeyEvent fail");
 }
 
 void
 nsPluginInstanceOwner::OnWindowedPluginKeyEvent(
                          const NativeEventData& aKeyEventData)
 {
   if (NS_WARN_IF(!mPluginFrame)) {
     // Notifies the plugin process of the key event being not consumed by us.
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -1672,17 +1672,18 @@ PluginInstanceChild::PluginWindowProcInt
             }
             break;
         }
 
         case WM_SETFOCUS:
             // If this gets focus, ensure that there is no pending key events.
             // Even if there were, we should ignore them for performance reason.
             // Although, such case shouldn't occur.
-            NS_WARN_IF(self->mPostingKeyEvents > 0);
+            NS_WARNING_ASSERTION(self->mPostingKeyEvents == 0,
+                                 "pending events");
             self->mPostingKeyEvents = 0;
             self->mLastKeyEventConsumed = false;
             break;
 
         case WM_KEYDOWN:
         case WM_SYSKEYDOWN:
         case WM_KEYUP:
         case WM_SYSKEYUP:
--- a/dom/plugins/ipc/PluginWidgetChild.cpp
+++ b/dom/plugins/ipc/PluginWidgetChild.cpp
@@ -38,17 +38,17 @@ PluginWidgetChild::~PluginWidgetChild()
 bool
 PluginWidgetChild::RecvSetScrollCaptureId(const uint64_t& aScrollCaptureId,
                                           const uintptr_t& aPluginInstanceId)
 {
 #if defined(XP_WIN)
   PluginInstanceParent* instance =
     PluginInstanceParent::LookupPluginInstanceByID(aPluginInstanceId);
   if (instance) {
-    NS_WARN_IF(NS_FAILED(instance->SetScrollCaptureId(aScrollCaptureId)));
+    Unused << NS_WARN_IF(NS_FAILED(instance->SetScrollCaptureId(aScrollCaptureId)));
   }
 
   return true;
 #else
   MOZ_ASSERT_UNREACHABLE(
     "PluginWidgetChild::RecvSetScrollCaptureId calls not expected.");
   return false;
 #endif
--- a/dom/presentation/PresentationAvailability.cpp
+++ b/dom/presentation/PresentationAvailability.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "PresentationAvailability.h"
 
 #include "mozilla/dom/PresentationAvailabilityBinding.h"
 #include "mozilla/dom/Promise.h"
+#include "mozilla/Unused.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIPresentationDeviceManager.h"
 #include "nsIPresentationService.h"
 #include "nsServiceManagerUtils.h"
 #include "PresentationLog.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -95,18 +96,18 @@ void PresentationAvailability::Shutdown(
   }
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return;
   }
 
-  nsresult rv = service->UnregisterAvailabilityListener(this);
-  NS_WARN_IF(NS_FAILED(rv));
+  Unused <<
+    NS_WARN_IF(NS_FAILED(service->UnregisterAvailabilityListener(this)));
 }
 
 /* virtual */ void
 PresentationAvailability::DisconnectFromOwner()
 {
   Shutdown();
   DOMEventTargetHelper::DisconnectFromOwner();
 }
@@ -181,11 +182,12 @@ PresentationAvailability::UpdateAvailabi
       }
       // more promises may have been added to mPromises, at least in theory
     } while (!mPromises.IsEmpty());
 
     return;
   }
 
   if (isChanged) {
-    NS_WARN_IF(NS_FAILED(DispatchTrustedEvent(NS_LITERAL_STRING("change"))));
+    Unused <<
+      NS_WARN_IF(NS_FAILED(DispatchTrustedEvent(NS_LITERAL_STRING("change"))));
   }
 }
--- a/dom/presentation/PresentationConnection.cpp
+++ b/dom/presentation/PresentationConnection.cpp
@@ -8,16 +8,17 @@
 
 #include "ControllerConnectionCollection.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/PresentationConnectionClosedEvent.h"
 #include "mozilla/ErrorNames.h"
+#include "mozilla/DebugOnly.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIPresentationService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStringStream.h"
 #include "PresentationConnectionList.h"
 #include "PresentationLog.h"
 
@@ -119,32 +120,32 @@ PresentationConnection::Shutdown()
              NS_ConvertUTF16toUTF8(mId).get(), mRole);
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return;
   }
 
-  nsresult rv = service->UnregisterSessionListener(mId, mRole);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = service->UnregisterSessionListener(mId, mRole);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "UnregisterSessionListener failed");
 
-  rv = RemoveFromLoadGroup();
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv2 = RemoveFromLoadGroup();
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv2), "RemoveFromLoadGroup failed");
 
   if (mRole == nsIPresentationService::ROLE_CONTROLLER) {
     ControllerConnectionCollection::GetSingleton()->RemoveConnection(this,
                                                                      mRole);
   }
 }
 
 /* virtual */ void
 PresentationConnection::DisconnectFromOwner()
 {
-  NS_WARN_IF(NS_FAILED(ProcessConnectionWentAway()));
+  Unused << NS_WARN_IF(NS_FAILED(ProcessConnectionWentAway()));
   DOMEventTargetHelper::DisconnectFromOwner();
 }
 
 /* virtual */ JSObject*
 PresentationConnection::WrapObject(JSContext* aCx,
                                    JS::Handle<JSObject*> aGivenProto)
 {
   return PresentationConnectionBinding::Wrap(aCx, this, aGivenProto);
@@ -202,17 +203,17 @@ PresentationConnection::Close(ErrorResul
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if(NS_WARN_IF(!service)) {
     aRv.Throw(NS_ERROR_DOM_OPERATION_ERR);
     return;
   }
 
-  NS_WARN_IF(NS_FAILED(
+  Unused << NS_WARN_IF(NS_FAILED(
     service->CloseSession(mId,
                           mRole,
                           nsIPresentationService::CLOSED_REASON_CLOSED)));
 }
 
 void
 PresentationConnection::Terminate(ErrorResult& aRv)
 {
@@ -223,17 +224,17 @@ PresentationConnection::Terminate(ErrorR
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if(NS_WARN_IF(!service)) {
     aRv.Throw(NS_ERROR_DOM_OPERATION_ERR);
     return;
   }
 
-  NS_WARN_IF(NS_FAILED(service->TerminateSession(mId, mRole)));
+  Unused << NS_WARN_IF(NS_FAILED(service->TerminateSession(mId, mRole)));
 }
 
 bool
 PresentationConnection::Equals(uint64_t aWindowId,
                                const nsAString& aId)
 {
   return GetOwner() &&
          aWindowId == GetOwner()->WindowID() &&
@@ -314,25 +315,26 @@ PresentationConnection::ProcessStateChan
                                                          name,
                                                          message))) {
           mozilla::GetErrorName(aReason, message);
           message.InsertLiteral("Internal error: ", 0);
         }
         CopyUTF8toUTF16(message, errorMsg);
       }
 
-      NS_WARN_IF(NS_FAILED(DispatchConnectionClosedEvent(reason, errorMsg)));
+      Unused <<
+        NS_WARN_IF(NS_FAILED(DispatchConnectionClosedEvent(reason, errorMsg)));
 
       return RemoveFromLoadGroup();
     }
     case PresentationConnectionState::Terminated: {
       // Ensure onterminate event is fired.
       RefPtr<AsyncEventDispatcher> asyncDispatcher =
         new AsyncEventDispatcher(this, NS_LITERAL_STRING("terminate"), false);
-      NS_WARN_IF(NS_FAILED(asyncDispatcher->PostDOMEvent()));
+      Unused << NS_WARN_IF(NS_FAILED(asyncDispatcher->PostDOMEvent()));
 
       nsCOMPtr<nsIPresentationService> service =
         do_GetService(PRESENTATION_SERVICE_CONTRACTID);
       if (NS_WARN_IF(!service)) {
         return NS_ERROR_NOT_AVAILABLE;
       }
 
       nsresult rv = service->UnregisterSessionListener(mId, mRole);
--- a/dom/presentation/PresentationReceiver.cpp
+++ b/dom/presentation/PresentationReceiver.cpp
@@ -71,18 +71,18 @@ void PresentationReceiver::Shutdown()
 
   // Unregister listener for incoming sessions.
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return;
   }
 
-  nsresult rv = service->UnregisterRespondingListener(mWindowId);
-  NS_WARN_IF(NS_FAILED(rv));
+  Unused <<
+    NS_WARN_IF(NS_FAILED(service->UnregisterRespondingListener(mWindowId)));
 }
 
 /* virtual */ JSObject*
 PresentationReceiver::WrapObject(JSContext* aCx,
                                  JS::Handle<JSObject*> aGivenProto)
 {
   return PresentationReceiverBinding::Wrap(aCx, this, aGivenProto);
 }
--- a/dom/presentation/PresentationService.cpp
+++ b/dom/presentation/PresentationService.cpp
@@ -604,17 +604,18 @@ PresentationService::HandleReconnectRequ
 }
 
 void
 PresentationService::NotifyAvailableChange(bool aIsAvailable)
 {
   nsTObserverArray<nsCOMPtr<nsIPresentationAvailabilityListener>>::ForwardIterator iter(mAvailabilityListeners);
   while (iter.HasMore()) {
     nsCOMPtr<nsIPresentationAvailabilityListener> listener = iter.GetNext();
-    NS_WARN_IF(NS_FAILED(listener->NotifyAvailableChange(aIsAvailable)));
+    Unused <<
+      NS_WARN_IF(NS_FAILED(listener->NotifyAvailableChange(aIsAvailable)));
   }
 }
 
 bool
 PresentationService::IsAppInstalled(nsIURI* aUri)
 {
   nsAutoCString prePath;
   nsresult rv = aUri->GetPrePath(prePath);
@@ -872,17 +873,18 @@ PresentationService::RegisterAvailabilit
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mAvailabilityListeners.Contains(aListener)) {
     mAvailabilityListeners.AppendElement(aListener);
   }
 
   // Leverage availablility change notification to assign
   // the initial value of availability object.
-  NS_WARN_IF(NS_FAILED(aListener->NotifyAvailableChange(mIsAvailable)));
+  Unused <<
+    NS_WARN_IF(NS_FAILED(aListener->NotifyAvailableChange(mIsAvailable)));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationService::UnregisterAvailabilityListener(nsIPresentationAvailabilityListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -932,17 +934,17 @@ PresentationService::UnregisterSessionLi
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
              aRole == nsIPresentationService::ROLE_RECEIVER);
 
   RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
   if (info) {
     // When content side decide not handling this session anymore, simply
     // close the connection. Session info is kept for reconnection.
-    NS_WARN_IF(NS_FAILED(info->Close(NS_OK, nsIPresentationSessionListener::STATE_CLOSED)));
+    Unused << NS_WARN_IF(NS_FAILED(info->Close(NS_OK, nsIPresentationSessionListener::STATE_CLOSED)));
     return info->SetListener(nullptr);
   }
   return NS_OK;
 }
 
 nsresult
 PresentationService::RegisterTransportBuilder(const nsAString& aSessionId,
                                               uint8_t aRole,
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -220,40 +220,40 @@ PresentationSessionInfo::Init(nsIPresent
 }
 
 /* virtual */ void
 PresentationSessionInfo::Shutdown(nsresult aReason)
 {
   PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
              NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
 
-  NS_WARN_IF(NS_FAILED(aReason));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(aReason), "bad reason");
 
   // Close the control channel if any.
   if (mControlChannel) {
-    NS_WARN_IF(NS_FAILED(mControlChannel->Disconnect(aReason)));
+    Unused << NS_WARN_IF(NS_FAILED(mControlChannel->Disconnect(aReason)));
   }
 
   // Close the data transport channel if any.
   if (mTransport) {
     // |mIsTransportReady| will be unset once |NotifyTransportClosed| is called.
-    NS_WARN_IF(NS_FAILED(mTransport->Close(aReason)));
+    Unused << NS_WARN_IF(NS_FAILED(mTransport->Close(aReason)));
   }
 
   mIsResponderReady = false;
   mIsOnTerminating = false;
 
   SetBuilder(nullptr);
 }
 
 nsresult
 PresentationSessionInfo::SetListener(nsIPresentationSessionListener* aListener)
 {
   if (mListener && aListener) {
-    NS_WARN_IF(NS_FAILED(mListener->NotifyReplaced()));
+    Unused << NS_WARN_IF(NS_FAILED(mListener->NotifyReplaced()));
   }
 
   mListener = aListener;
 
   if (mListener) {
     // Enable data notification for the transport channel if it's available.
     if (mTransport) {
       nsresult rv = mTransport->EnableDataNotification();
@@ -601,17 +601,17 @@ PresentationControllingInfo::Init(nsIPre
 
 void
 PresentationControllingInfo::Shutdown(nsresult aReason)
 {
   PresentationSessionInfo::Shutdown(aReason);
 
   // Close the server socket if any.
   if (mServerSocket) {
-    NS_WARN_IF(NS_FAILED(mServerSocket->Close()));
+    Unused << NS_WARN_IF(NS_FAILED(mServerSocket->Close()));
     mServerSocket = nullptr;
   }
 
   mIsReconnecting = false;
 }
 
 nsresult
 PresentationControllingInfo::GetAddress()
@@ -874,17 +874,17 @@ PresentationControllingInfo::NotifyDisco
              NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mTransportType == nsIPresentationChannelDescription::TYPE_DATACHANNEL) {
     nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder>
       builder = do_QueryInterface(mBuilder);
     if (builder) {
-      NS_WARN_IF(NS_FAILED(builder->NotifyDisconnected(aReason)));
+      Unused << NS_WARN_IF(NS_FAILED(builder->NotifyDisconnected(aReason)));
     }
   }
 
   // Unset control channel here so it won't try to re-close it in potential
   // subsequent |Shutdown| calls.
   SetControlChannel(nullptr);
 
   if (NS_WARN_IF(NS_FAILED(aReason) || !mIsResponderReady)) {
@@ -1147,17 +1147,17 @@ PresentationPresentingInfo::OnSessionTra
   if (mTransportType == nsIPresentationChannelDescription::TYPE_TCP) {
     // Prepare and send the answer.
     // In the current implementation of |PresentationSessionTransport|,
     // |GetSelfAddress| cannot return the real info when it's initialized via
     // |buildTCPReceiverTransport|. Yet this deficiency only affects the channel
     // description for the answer, which is not actually checked at requester side.
     nsCOMPtr<nsINetAddr> selfAddr;
     rv = mTransport->GetSelfAddress(getter_AddRefs(selfAddr));
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "GetSelfAddress failed");
 
     nsCString address;
     uint16_t port = 0;
     if (NS_SUCCEEDED(rv)) {
       selfAddr->GetAddress(address);
       selfAddr->GetPort(&port);
     }
     nsCOMPtr<nsIPresentationChannelDescription> description =
@@ -1277,17 +1277,17 @@ PresentationPresentingInfo::InitTranspor
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 PresentationPresentingInfo::UntrackFromService()
 {
   // Remove the OOP responding info (if it has never been used).
   if (mContentParent) {
-    NS_WARN_IF(!static_cast<ContentParent*>(mContentParent.get())->SendNotifyPresentationReceiverCleanUp(mSessionId));
+    Unused << NS_WARN_IF(!static_cast<ContentParent*>(mContentParent.get())->SendNotifyPresentationReceiverCleanUp(mSessionId));
   }
 
   // Remove the session info (and the in-process responding info if there's any).
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
@@ -1422,17 +1422,17 @@ PresentationPresentingInfo::NotifyDiscon
              NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mTransportType == nsIPresentationChannelDescription::TYPE_DATACHANNEL) {
     nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder>
       builder = do_QueryInterface(mBuilder);
     if (builder) {
-      NS_WARN_IF(NS_FAILED(builder->NotifyDisconnected(aReason)));
+      Unused << NS_WARN_IF(NS_FAILED(builder->NotifyDisconnected(aReason)));
     }
   }
 
   // Unset control channel here so it won't try to re-close it in potential
   // subsequent |Shutdown| calls.
   SetControlChannel(nullptr);
 
   if (NS_WARN_IF(NS_FAILED(aReason))) {
@@ -1497,17 +1497,17 @@ PresentationPresentingInfo::ResolvedCall
   }
 
   RefPtr<TabParent> tabParent = TabParent::GetFrom(frameLoader);
   if (tabParent) {
     // OOP frame
     // Notify the content process that a receiver page has launched, so it can
     // start monitoring the loading progress.
     mContentParent = tabParent->Manager();
-    NS_WARN_IF(!static_cast<ContentParent*>(mContentParent.get())->SendNotifyPresentationReceiverLaunched(tabParent, mSessionId));
+    Unused << NS_WARN_IF(!static_cast<ContentParent*>(mContentParent.get())->SendNotifyPresentationReceiverLaunched(tabParent, mSessionId));
   } else {
     // In-process frame
     nsCOMPtr<nsIDocShell> docShell;
     rv = frameLoader->GetDocShell(getter_AddRefs(docShell));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       ReplyError(NS_ERROR_DOM_OPERATION_ERR);
       return;
     }
--- a/dom/presentation/PresentationSessionInfo.h
+++ b/dom/presentation/PresentationSessionInfo.h
@@ -6,16 +6,17 @@
 
 #ifndef mozilla_dom_PresentationSessionInfo_h
 #define mozilla_dom_PresentationSessionInfo_h
 
 #include "base/process.h"
 #include "mozilla/dom/nsIContentParent.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/PromiseNativeHandler.h"
+#include "mozilla/DebugOnly.h"
 #include "mozilla/RefPtr.h"
 #include "nsCOMPtr.h"
 #include "nsINetworkInfoService.h"
 #include "nsIPresentationControlChannel.h"
 #include "nsIPresentationDevice.h"
 #include "nsIPresentationListener.h"
 #include "nsIPresentationService.h"
 #include "nsIPresentationSessionTransport.h"
@@ -135,18 +136,19 @@ protected:
       return;
     }
 
     mState = aState;
     mReason = aReason;
 
     // Notify session state change.
     if (mListener) {
-      nsresult rv = mListener->NotifyStateChange(mSessionId, mState, aReason);
-      NS_WARN_IF(NS_FAILED(rv));
+      DebugOnly<nsresult> rv =
+        mListener->NotifyStateChange(mSessionId, mState, aReason);
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NotifyStateChanged");
     }
   }
 
   void ContinueTermination();
 
   // Should be nsIPresentationChannelDescription::TYPE_TCP/TYPE_DATACHANNEL
   uint8_t mTransportType = 0;
 
--- a/dom/presentation/PresentationTCPSessionTransport.cpp
+++ b/dom/presentation/PresentationTCPSessionTransport.cpp
@@ -326,17 +326,17 @@ PresentationTCPSessionTransport::GetCall
 
 NS_IMETHODIMP
 PresentationTCPSessionTransport::SetCallback(nsIPresentationSessionTransportCallback* aCallback)
 {
   mCallback = aCallback;
 
   if (!!mCallback && ReadyState::OPEN == mReadyState) {
     // Notify the transport channel is ready.
-    NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportReady()));
+    Unused << NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportReady()));
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationTCPSessionTransport::GetSelfAddress(nsINetAddr** aSelfAddress)
 {
@@ -351,17 +351,17 @@ void
 PresentationTCPSessionTransport::EnsureCopying()
 {
   if (mAsyncCopierActive) {
     return;
   }
 
   mAsyncCopierActive = true;
   RefPtr<CopierCallbacks> callbacks = new CopierCallbacks(this);
-  NS_WARN_IF(NS_FAILED(mMultiplexStreamCopier->AsyncCopy(callbacks, nullptr)));
+  Unused << NS_WARN_IF(NS_FAILED(mMultiplexStreamCopier->AsyncCopy(callbacks, nullptr)));
 }
 
 void
 PresentationTCPSessionTransport::NotifyCopyComplete(nsresult aStatus)
 {
   mAsyncCopierActive = false;
   mMultiplexStream->RemoveStream(0);
   if (NS_WARN_IF(NS_FAILED(aStatus))) {
@@ -453,24 +453,25 @@ PresentationTCPSessionTransport::SetRead
       CreateInputStreamPump();
     }
 
     if (NS_WARN_IF(!mCallback)) {
       return;
     }
 
     // Notify the transport channel is ready.
-    NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportReady()));
+    Unused << NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportReady()));
   } else if (mReadyState == ReadyState::CLOSED && mCallback) {
     if (NS_WARN_IF(!mCallback)) {
       return;
     }
 
     // Notify the transport channel has been shut down.
-    NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportClosed(mCloseStatus)));
+    Unused <<
+      NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportClosed(mCloseStatus)));
     mCallback = nullptr;
   }
 }
 
 // nsITransportEventSink
 NS_IMETHODIMP
 PresentationTCPSessionTransport::OnTransportStatus(nsITransport* aTransport,
                                                    nsresult aStatus,
--- a/dom/presentation/ipc/PresentationBuilderChild.cpp
+++ b/dom/presentation/ipc/PresentationBuilderChild.cpp
@@ -5,16 +5,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DCPresentationChannelDescription.h"
 #include "nsComponentManagerUtils.h"
 #include "nsGlobalWindow.h"
 #include "PresentationBuilderChild.h"
 #include "PresentationIPCService.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS(PresentationBuilderChild,
                   nsIPresentationSessionTransportBuilderListener)
 
 PresentationBuilderChild::PresentationBuilderChild(const nsString& aSessionId,
@@ -105,20 +106,20 @@ NS_IMETHODIMP
 PresentationBuilderChild::OnSessionTransport(nsIPresentationSessionTransport* aTransport)
 {
   if (NS_WARN_IF(mActorDestroyed || !SendOnSessionTransport())){
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
-  NS_WARN_IF(!service);
+  NS_WARNING_ASSERTION(service, "no presentation service");
   if (service) {
-    NS_WARN_IF(NS_FAILED(static_cast<PresentationIPCService*>(service.get())->
-                           NotifySessionTransport(mSessionId, mRole, aTransport)));
+    Unused << NS_WARN_IF(NS_FAILED(static_cast<PresentationIPCService*>(service.get())->
+                                     NotifySessionTransport(mSessionId, mRole, aTransport)));
   }
   mBuilder = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationBuilderChild::OnError(nsresult reason)
 {
--- a/dom/presentation/ipc/PresentationBuilderParent.cpp
+++ b/dom/presentation/ipc/PresentationBuilderParent.cpp
@@ -21,17 +21,17 @@ PresentationBuilderParent::PresentationB
   MOZ_COUNT_CTOR(PresentationBuilderParent);
 }
 
 PresentationBuilderParent::~PresentationBuilderParent()
 {
   MOZ_COUNT_DTOR(PresentationBuilderParent);
 
   if (mNeedDestroyActor) {
-    NS_WARN_IF(!Send__delete__(this));
+    Unused << NS_WARN_IF(!Send__delete__(this));
   }
 }
 
 NS_IMETHODIMP
 PresentationBuilderParent::BuildDataChannelTransport(
                       uint8_t aRole,
                       mozIDOMWindow* aWindow, /* unused */
                       nsIPresentationSessionTransportBuilderListener* aListener)
@@ -147,18 +147,19 @@ PresentationBuilderParent::RecvClose(con
 }
 
 // Delegate to nsIPresentationSessionTransportBuilderListener
 bool
 PresentationBuilderParent::RecvOnSessionTransport()
 {
   // To avoid releasing |this| in this method
   NS_DispatchToMainThread(NS_NewRunnableFunction([this]() -> void {
-    NS_WARN_IF(!mBuilderListener ||
-               NS_FAILED(mBuilderListener->OnSessionTransport(nullptr)));
+    Unused <<
+      NS_WARN_IF(!mBuilderListener ||
+                 NS_FAILED(mBuilderListener->OnSessionTransport(nullptr)));
   }));
 
   nsCOMPtr<nsIPresentationSessionTransportCallback>
     callback(do_QueryInterface(mBuilderListener));
 
   callback->NotifyTransportReady();
   return true;
 }
--- a/dom/presentation/ipc/PresentationChild.cpp
+++ b/dom/presentation/ipc/PresentationChild.cpp
@@ -87,50 +87,50 @@ PresentationChild::DeallocPPresentationB
   return true;
 }
 
 
 bool
 PresentationChild::RecvNotifyAvailableChange(const bool& aAvailable)
 {
   if (mService) {
-    NS_WARN_IF(NS_FAILED(mService->NotifyAvailableChange(aAvailable)));
+    Unused << NS_WARN_IF(NS_FAILED(mService->NotifyAvailableChange(aAvailable)));
   }
   return true;
 }
 
 bool
 PresentationChild::RecvNotifySessionStateChange(const nsString& aSessionId,
                                                 const uint16_t& aState,
                                                 const nsresult& aReason)
 {
   if (mService) {
-    NS_WARN_IF(NS_FAILED(mService->NotifySessionStateChange(aSessionId,
-                                                            aState,
-                                                            aReason)));
+    Unused << NS_WARN_IF(NS_FAILED(mService->NotifySessionStateChange(aSessionId,
+                                                                      aState,
+                                                                      aReason)));
   }
   return true;
 }
 
 bool
 PresentationChild::RecvNotifyMessage(const nsString& aSessionId,
                                      const nsCString& aData)
 {
   if (mService) {
-    NS_WARN_IF(NS_FAILED(mService->NotifyMessage(aSessionId, aData)));
+    Unused << NS_WARN_IF(NS_FAILED(mService->NotifyMessage(aSessionId, aData)));
   }
   return true;
 }
 
 bool
 PresentationChild::RecvNotifySessionConnect(const uint64_t& aWindowId,
                                             const nsString& aSessionId)
 {
   if (mService) {
-    NS_WARN_IF(NS_FAILED(mService->NotifySessionConnect(aWindowId, aSessionId)));
+    Unused << NS_WARN_IF(NS_FAILED(mService->NotifySessionConnect(aWindowId, aSessionId)));
   }
   return true;
 }
 
 /*
  * Implementation of PresentationRequestChild
  */
 
@@ -159,21 +159,21 @@ bool
 PresentationRequestChild::Recv__delete__(const nsresult& aResult)
 {
   if (mActorDestroyed) {
     return true;
   }
 
   if (mCallback) {
     if (NS_FAILED(aResult)) {
-      NS_WARN_IF(NS_FAILED(mCallback->NotifyError(aResult)));
+      Unused << NS_WARN_IF(NS_FAILED(mCallback->NotifyError(aResult)));
     }
   }
 
   return true;
 }
 
 bool
 PresentationRequestChild::RecvNotifyRequestUrlSelected(const nsString& aUrl)
 {
-  NS_WARN_IF(NS_FAILED(mCallback->NotifySuccess(aUrl)));
+  Unused << NS_WARN_IF(NS_FAILED(mCallback->NotifySuccess(aUrl)));
   return true;
 }
--- a/dom/presentation/ipc/PresentationIPCService.cpp
+++ b/dom/presentation/ipc/PresentationIPCService.cpp
@@ -33,17 +33,18 @@ NS_IMPL_ISUPPORTS_INHERITED(Presentation
 
 PresentationIPCService::PresentationIPCService()
 {
   ContentChild* contentChild = ContentChild::GetSingleton();
   if (NS_WARN_IF(!contentChild)) {
     return;
   }
   sPresentationChild = new PresentationChild(this);
-  NS_WARN_IF(!contentChild->SendPPresentationConstructor(sPresentationChild));
+  Unused <<
+    NS_WARN_IF(!contentChild->SendPPresentationConstructor(sPresentationChild));
 }
 
 /* virtual */
 PresentationIPCService::~PresentationIPCService()
 {
   Shutdown();
 
   mAvailabilityListeners.Clear();
@@ -175,105 +176,114 @@ PresentationIPCService::BuildTransport(c
 }
 
 nsresult
 PresentationIPCService::SendRequest(nsIPresentationServiceCallback* aCallback,
                                     const PresentationIPCRequest& aRequest)
 {
   if (sPresentationChild) {
     PresentationRequestChild* actor = new PresentationRequestChild(aCallback);
-    NS_WARN_IF(!sPresentationChild->SendPPresentationRequestConstructor(actor, aRequest));
+    Unused << NS_WARN_IF(!sPresentationChild->SendPPresentationRequestConstructor(actor, aRequest));
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::RegisterAvailabilityListener(nsIPresentationAvailabilityListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aListener);
 
   mAvailabilityListeners.AppendElement(aListener);
   if (sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendRegisterAvailabilityHandler());
+    Unused <<
+      NS_WARN_IF(!sPresentationChild->SendRegisterAvailabilityHandler());
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::UnregisterAvailabilityListener(nsIPresentationAvailabilityListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aListener);
 
   mAvailabilityListeners.RemoveElement(aListener);
   if (mAvailabilityListeners.IsEmpty() && sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendUnregisterAvailabilityHandler());
+    Unused <<
+      NS_WARN_IF(!sPresentationChild->SendUnregisterAvailabilityHandler());
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::RegisterSessionListener(const nsAString& aSessionId,
                                                 uint8_t aRole,
                                                 nsIPresentationSessionListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aListener);
 
   nsCOMPtr<nsIPresentationSessionListener> listener;
   if (mSessionListeners.Get(aSessionId, getter_AddRefs(listener))) {
-    NS_WARN_IF(NS_FAILED(listener->NotifyReplaced()));
+    Unused << NS_WARN_IF(NS_FAILED(listener->NotifyReplaced()));
     mSessionListeners.Put(aSessionId, aListener);
     return NS_OK;
   }
 
   mSessionListeners.Put(aSessionId, aListener);
   if (sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendRegisterSessionHandler(nsString(aSessionId), aRole));
+    Unused <<
+      NS_WARN_IF(!sPresentationChild->SendRegisterSessionHandler(
+        nsString(aSessionId), aRole));
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::UnregisterSessionListener(const nsAString& aSessionId,
                                                   uint8_t aRole)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   UntrackSessionInfo(aSessionId, aRole);
 
   mSessionListeners.Remove(aSessionId);
   if (sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendUnregisterSessionHandler(nsString(aSessionId), aRole));
+    Unused <<
+      NS_WARN_IF(!sPresentationChild->SendUnregisterSessionHandler(
+        nsString(aSessionId), aRole));
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::RegisterRespondingListener(uint64_t aWindowId,
                                                    nsIPresentationRespondingListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mRespondingListeners.Put(aWindowId, aListener);
   if (sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendRegisterRespondingHandler(aWindowId));
+    Unused <<
+      NS_WARN_IF(!sPresentationChild->SendRegisterRespondingHandler(aWindowId));
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::UnregisterRespondingListener(uint64_t aWindowId)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mRespondingListeners.Remove(aWindowId);
   if (sPresentationChild) {
-    NS_WARN_IF(!sPresentationChild->SendUnregisterRespondingHandler(aWindowId));
+    Unused <<
+      NS_WARN_IF(!sPresentationChild->SendUnregisterRespondingHandler(
+        aWindowId));
   }
   return NS_OK;
 }
 
 nsresult
 PresentationIPCService::NotifySessionTransport(const nsString& aSessionId,
                                                const uint8_t& aRole,
                                                nsIPresentationSessionTransport* aTransport)
@@ -334,17 +344,17 @@ PresentationIPCService::NotifyMessage(co
 nsresult
 PresentationIPCService::NotifyTransportClosed(const nsAString& aSessionId,
                                               uint8_t aRole,
                                               nsresult aReason)
 {
   if (NS_WARN_IF(!mSessionInfos.Contains(aSessionId))) {
     return NS_ERROR_NOT_AVAILABLE;
   }
-  NS_WARN_IF(!sPresentationChild->SendNotifyTransportClosed(nsString(aSessionId), aRole, aReason));
+  Unused << NS_WARN_IF(!sPresentationChild->SendNotifyTransportClosed(nsString(aSessionId), aRole, aReason));
   return NS_OK;
 }
 
 nsresult
 PresentationIPCService::NotifySessionConnect(uint64_t aWindowId,
                                              const nsAString& aSessionId)
 {
   nsCOMPtr<nsIPresentationRespondingListener> listener;
@@ -356,17 +366,17 @@ PresentationIPCService::NotifySessionCon
 }
 
 nsresult
 PresentationIPCService::NotifyAvailableChange(bool aAvailable)
 {
   nsTObserverArray<nsCOMPtr<nsIPresentationAvailabilityListener>>::ForwardIterator iter(mAvailabilityListeners);
   while (iter.HasMore()) {
     nsIPresentationAvailabilityListener* listener = iter.GetNext();
-    NS_WARN_IF(NS_FAILED(listener->NotifyAvailableChange(aAvailable)));
+    Unused << NS_WARN_IF(NS_FAILED(listener->NotifyAvailableChange(aAvailable)));
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::NotifyReceiverReady(const nsAString& aSessionId,
                                             uint64_t aWindowId,
@@ -379,19 +389,19 @@ PresentationIPCService::NotifyReceiverRe
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Track the responding info for an OOP receiver page.
   AddRespondingSessionId(aWindowId,
                          aSessionId,
                          nsIPresentationService::ROLE_RECEIVER);
 
-  NS_WARN_IF(!sPresentationChild->SendNotifyReceiverReady(nsString(aSessionId),
-                                                          aWindowId,
-                                                          aIsLoading));
+  Unused << NS_WARN_IF(!sPresentationChild->SendNotifyReceiverReady(nsString(aSessionId),
+                                                                    aWindowId,
+                                                                    aIsLoading));
 
   // Release mCallback after using aSessionId
   // because aSessionId is held by mCallback.
   mCallback = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/dom/presentation/ipc/PresentationParent.cpp
+++ b/dom/presentation/ipc/PresentationParent.cpp
@@ -46,29 +46,31 @@ PresentationParent::Init(ContentParentId
 }
 
 void
 PresentationParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   mActorDestroyed = true;
 
   for (uint32_t i = 0; i < mSessionIdsAtController.Length(); i++) {
-    NS_WARN_IF(NS_FAILED(mService->
-      UnregisterSessionListener(mSessionIdsAtController[i], nsIPresentationService::ROLE_CONTROLLER)));
+    Unused << NS_WARN_IF(NS_FAILED(mService->
+      UnregisterSessionListener(mSessionIdsAtController[i],
+                                nsIPresentationService::ROLE_CONTROLLER)));
   }
   mSessionIdsAtController.Clear();
 
   for (uint32_t i = 0; i < mSessionIdsAtReceiver.Length(); i++) {
-    NS_WARN_IF(NS_FAILED(mService->
+    Unused << NS_WARN_IF(NS_FAILED(mService->
       UnregisterSessionListener(mSessionIdsAtReceiver[i], nsIPresentationService::ROLE_RECEIVER)));
   }
   mSessionIdsAtReceiver.Clear();
 
   for (uint32_t i = 0; i < mWindowIds.Length(); i++) {
-    NS_WARN_IF(NS_FAILED(mService->UnregisterRespondingListener(mWindowIds[i])));
+    Unused << NS_WARN_IF(NS_FAILED(mService->
+      UnregisterRespondingListener(mWindowIds[i])));
   }
   mWindowIds.Clear();
 
   mService->UnregisterAvailabilityListener(this);
   mService = nullptr;
 }
 
 bool
@@ -143,25 +145,25 @@ PresentationParent::Recv__delete__()
 {
   return true;
 }
 
 bool
 PresentationParent::RecvRegisterAvailabilityHandler()
 {
   MOZ_ASSERT(mService);
-  NS_WARN_IF(NS_FAILED(mService->RegisterAvailabilityListener(this)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->RegisterAvailabilityListener(this)));
   return true;
 }
 
 bool
 PresentationParent::RecvUnregisterAvailabilityHandler()
 {
   MOZ_ASSERT(mService);
-  NS_WARN_IF(NS_FAILED(mService->UnregisterAvailabilityListener(this)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->UnregisterAvailabilityListener(this)));
   return true;
 }
 
 /* virtual */ bool
 PresentationParent::RecvRegisterSessionHandler(const nsString& aSessionId,
                                                const uint8_t& aRole)
 {
   MOZ_ASSERT(mService);
@@ -173,62 +175,62 @@ PresentationParent::RecvRegisterSessionH
     return true;
   }
 
   if (nsIPresentationService::ROLE_CONTROLLER == aRole) {
     mSessionIdsAtController.AppendElement(aSessionId);
   } else {
     mSessionIdsAtReceiver.AppendElement(aSessionId);
   }
-  NS_WARN_IF(NS_FAILED(mService->RegisterSessionListener(aSessionId, aRole, this)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->RegisterSessionListener(aSessionId, aRole, this)));
   return true;
 }
 
 /* virtual */ bool
 PresentationParent::RecvUnregisterSessionHandler(const nsString& aSessionId,
                                                  const uint8_t& aRole)
 {
   MOZ_ASSERT(mService);
   if (nsIPresentationService::ROLE_CONTROLLER == aRole) {
     mSessionIdsAtController.RemoveElement(aSessionId);
   } else {
     mSessionIdsAtReceiver.RemoveElement(aSessionId);
   }
-  NS_WARN_IF(NS_FAILED(mService->UnregisterSessionListener(aSessionId, aRole)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->UnregisterSessionListener(aSessionId, aRole)));
   return true;
 }
 
 /* virtual */ bool
 PresentationParent::RecvRegisterRespondingHandler(const uint64_t& aWindowId)
 {
   MOZ_ASSERT(mService);
 
   mWindowIds.AppendElement(aWindowId);
-  NS_WARN_IF(NS_FAILED(mService->RegisterRespondingListener(aWindowId, this)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->RegisterRespondingListener(aWindowId, this)));
   return true;
 }
 
 /* virtual */ bool
 PresentationParent::RecvUnregisterRespondingHandler(const uint64_t& aWindowId)
 {
   MOZ_ASSERT(mService);
   mWindowIds.RemoveElement(aWindowId);
-  NS_WARN_IF(NS_FAILED(mService->UnregisterRespondingListener(aWindowId)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->UnregisterRespondingListener(aWindowId)));
   return true;
 }
 
 bool
 PresentationParent::RegisterTransportBuilder(const nsString& aSessionId,
                                              const uint8_t& aRole)
 {
   MOZ_ASSERT(mService);
 
   nsCOMPtr<nsIPresentationSessionTransportBuilder> builder =
     new PresentationBuilderParent(this);
-  NS_WARN_IF(NS_FAILED(static_cast<PresentationService*>(mService.get())->
+  Unused << NS_WARN_IF(NS_FAILED(static_cast<PresentationService*>(mService.get())->
                          RegisterTransportBuilder(aSessionId, aRole, builder)));
   return true;
 }
 
 NS_IMETHODIMP
 PresentationParent::NotifyAvailableChange(bool aAvailable)
 {
   if (NS_WARN_IF(mActorDestroyed || !SendNotifyAvailableChange(aAvailable))) {
@@ -284,30 +286,30 @@ PresentationParent::NotifySessionConnect
 bool
 PresentationParent::RecvNotifyReceiverReady(const nsString& aSessionId,
                                             const uint64_t& aWindowId,
                                             const bool& aIsLoading)
 {
   MOZ_ASSERT(mService);
 
   RegisterTransportBuilder(aSessionId, nsIPresentationService::ROLE_RECEIVER);
-  NS_WARN_IF(NS_FAILED(mService->NotifyReceiverReady(aSessionId,
-                                                     aWindowId,
-                                                     aIsLoading)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->NotifyReceiverReady(aSessionId,
+                                                               aWindowId,
+                                                               aIsLoading)));
   return true;
 }
 
 bool
 PresentationParent::RecvNotifyTransportClosed(const nsString& aSessionId,
                                               const uint8_t& aRole,
                                               const nsresult& aReason)
 {
   MOZ_ASSERT(mService);
 
-  NS_WARN_IF(NS_FAILED(mService->NotifyTransportClosed(aSessionId, aRole, aReason)));
+  Unused << NS_WARN_IF(NS_FAILED(mService->NotifyTransportClosed(aSessionId, aRole, aReason)));
   return true;
 }
 
 /*
  * Implementation of PresentationRequestParent
  */
 
 NS_IMPL_ISUPPORTS(PresentationRequestParent, nsIPresentationServiceCallback)
@@ -455,17 +457,17 @@ PresentationRequestParent::DoRequest(con
   return SendResponse(NS_OK);
 }
 
 NS_IMETHODIMP
 PresentationRequestParent::NotifySuccess(const nsAString& aUrl)
 {
   if (mNeedRegisterBuilder) {
     RefPtr<PresentationParent> parent = static_cast<PresentationParent*>(Manager());
-    NS_WARN_IF(!parent->RegisterTransportBuilder(
+    Unused << NS_WARN_IF(!parent->RegisterTransportBuilder(
                                       mSessionId,
                                       nsIPresentationService::ROLE_CONTROLLER));
   }
 
   Unused << SendNotifyRequestUrlSelected(nsString(aUrl));
   return SendResponse(NS_OK);
 }
 
--- a/dom/presentation/provider/LegacyMDNSDeviceProvider.cpp
+++ b/dom/presentation/provider/LegacyMDNSDeviceProvider.cpp
@@ -350,30 +350,30 @@ void
 LegacyMDNSDeviceProvider::ClearUnknownDevices()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   size_t i = mDevices.Length();
   while (i > 0) {
     --i;
     if (mDevices[i]->State() == DeviceState::eUnknown) {
-      NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
+      Unused << NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
     }
   }
 }
 
 void
 LegacyMDNSDeviceProvider::ClearDevices()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   size_t i = mDevices.Length();
   while (i > 0) {
     --i;
-    NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
+    Unused << NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
   }
 }
 
 // nsIPresentationDeviceProvider
 NS_IMETHODIMP
 LegacyMDNSDeviceProvider::GetListener(nsIPresentationDeviceListener** aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
+++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
@@ -561,30 +561,30 @@ void
 MulticastDNSDeviceProvider::ClearUnknownDevices()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   size_t i = mDevices.Length();
   while (i > 0) {
     --i;
     if (mDevices[i]->State() == DeviceState::eUnknown) {
-      NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
+      Unused << NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
     }
   }
 }
 
 void
 MulticastDNSDeviceProvider::ClearDevices()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   size_t i = mDevices.Length();
   while (i > 0) {
     --i;
-    NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
+    Unused << NS_WARN_IF(NS_FAILED(RemoveDevice(i)));
   }
 }
 
 // nsIPresentationDeviceProvider
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::GetListener(nsIPresentationDeviceListener** aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/system/gonk/AudioChannelManager.cpp
+++ b/dom/system/gonk/AudioChannelManager.cpp
@@ -168,14 +168,14 @@ AudioChannelManager::GetAllowedAudioChan
   nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
   if (NS_WARN_IF(!window)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   nsBrowserElement::GenerateAllowedAudioChannels(window, nullptr, nullptr,
                                                  aAudioChannels, aRv);
-  NS_WARN_IF(aRv.Failed());
+  NS_WARNING_ASSERTION(!aRv.Failed(), "GenerateAllowedAudioChannels failed");
 }
 
 } // namespace system
 } // namespace dom
 } // namespace mozilla
--- a/dom/u2f/U2F.cpp
+++ b/dom/u2f/U2F.cpp
@@ -45,17 +45,17 @@ template <class CB, class Rsp>
 void
 SendError(CB* aCallback, ErrorCode aErrorCode)
 {
   Rsp response;
   response.mErrorCode.Construct(static_cast<uint32_t>(aErrorCode));
 
   ErrorResult rv;
   aCallback->Call(response, rv);
-  NS_WARN_IF(rv.Failed());
+  NS_WARNING_ASSERTION(!rv.Failed(), "callback failed");
   // Useful exceptions already got reported.
   rv.SuppressException();
 }
 
 static nsresult
 AssembleClientData(const nsAString& aOrigin, const nsAString& aTyp,
                    const nsAString& aChallenge, CryptoBuffer& aClientData)
 {
@@ -272,17 +272,17 @@ U2FRegisterTask::Run()
 
     RegisterResponse response;
     response.mClientData.Construct(clientDataBase64);
     response.mRegistrationData.Construct(registrationDataBase64);
     response.mErrorCode.Construct(static_cast<uint32_t>(ErrorCode::OK));
 
     ErrorResult result;
     mCallback->Call(response, result);
-    NS_WARN_IF(result.Failed());
+    NS_WARNING_ASSERTION(!result.Failed(), "callback failed");
     // Useful exceptions already got reported.
     result.SuppressException();
     return NS_OK;
   }
 
   // Nothing could satisfy
   ReturnError(ErrorCode::BAD_REQUEST);
   return NS_ERROR_FAILURE;
@@ -449,17 +449,17 @@ U2FSignTask::Run()
     SignResponse response;
     response.mKeyHandle.Construct(request.mKeyHandle.Value());
     response.mClientData.Construct(clientDataBase64);
     response.mSignatureData.Construct(signatureDataBase64);
     response.mErrorCode.Construct(static_cast<uint32_t>(ErrorCode::OK));
 
     ErrorResult result;
     mCallback->Call(response, result);
-    NS_WARN_IF(result.Failed());
+    NS_WARNING_ASSERTION(!result.Failed(), "callback failed");
     // Useful exceptions already got reported.
     result.SuppressException();
     return NS_OK;
   }
 
   // Nothing could satisfy
   ReturnError(ErrorCode::DEVICE_INELIGIBLE);
   return NS_ERROR_FAILURE;
--- a/dom/url/URL.cpp
+++ b/dom/url/URL.cpp
@@ -1816,14 +1816,14 @@ URL::URLSearchParamsUpdated(URLSearchPar
   MOZ_ASSERT(mSearchParams);
   MOZ_ASSERT(mSearchParams == aSearchParams);
 
   nsAutoString search;
   mSearchParams->Serialize(search);
 
   ErrorResult rv;
   SetSearchInternal(search, rv);
-  NS_WARN_IF(rv.Failed());
+  NS_WARNING_ASSERTION(!rv.Failed(), "SetSearchInternal failed");
   rv.SuppressException();
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/workers/ServiceWorkerClients.cpp
+++ b/dom/workers/ServiceWorkerClients.cpp
@@ -549,17 +549,17 @@ public:
                                             nsIWebProgress::NOTIFY_STATE_DOCUMENT);
       MOZ_ASSERT(NS_SUCCEEDED(rv));
       return NS_OK;
     }
 
     RefPtr<ResolveOpenWindowRunnable> resolveRunnable =
       new ResolveOpenWindowRunnable(mPromiseProxy, nullptr, rv);
 
-    NS_WARN_IF(!resolveRunnable->Dispatch());
+    Unused << NS_WARN_IF(!resolveRunnable->Dispatch());
 
     return NS_OK;
   }
 
 private:
   nsresult
   OpenWindow(nsPIDOMWindowOuter** aWindow)
   {
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -1677,17 +1677,17 @@ ServiceWorkerPrivate::SpawnWorkerIfNeede
   if (NS_WARN_IF(!mInfo)) {
     NS_WARNING("Trying to wake up a dead service worker.");
     return NS_ERROR_FAILURE;
   }
 
   // TODO(catalinb): Bug 1192138 - Add telemetry for service worker wake-ups.
 
   // Ensure that the IndexedDatabaseManager is initialized
-  NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
+  Unused << NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
 
   WorkerLoadInfo info;
   nsresult rv = NS_NewURI(getter_AddRefs(info.mBaseURI), mInfo->ScriptSpec(),
                           nullptr, nullptr);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -1776,17 +1776,17 @@ ServiceWorkerPrivate::TerminateWorker()
   if (mWorkerPrivate) {
     if (Preferences::GetBool("dom.serviceWorkers.testing.enabled")) {
       nsCOMPtr<nsIObserverService> os = services::GetObserverService();
       if (os) {
         os->NotifyObservers(this, "service-worker-shutdown", nullptr);
       }
     }
 
-    NS_WARN_IF(!mWorkerPrivate->Terminate());
+    Unused << NS_WARN_IF(!mWorkerPrivate->Terminate());
     mWorkerPrivate = nullptr;
     mSupportsArray.Clear();
 
     // Any pending events are never going to fire on this worker.  Cancel
     // them so that intercepted channels can be reset and other resources
     // cleaned up.
     nsTArray<RefPtr<WorkerRunnable>> pendingEvents;
     mPendingFunctionalEvents.SwapElements(pendingEvents);
--- a/dom/workers/ServiceWorkerRegistration.cpp
+++ b/dom/workers/ServiceWorkerRegistration.cpp
@@ -1294,17 +1294,17 @@ public:
 
 void
 WorkerListener::UpdateFound()
 {
   AssertIsOnMainThread();
   if (mWorkerPrivate) {
     RefPtr<FireUpdateFoundRunnable> r =
       new FireUpdateFoundRunnable(mWorkerPrivate, this);
-    NS_WARN_IF(!r->Dispatch());
+    Unused << NS_WARN_IF(!r->Dispatch());
   }
 }
 
 // Notification API extension.
 already_AddRefed<Promise>
 ServiceWorkerRegistrationWorkerThread::ShowNotification(JSContext* aCx,
                                                         const nsAString& aTitle,
                                                         const NotificationOptions& aOptions,
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -3064,17 +3064,17 @@ WorkerPrivate::OfflineStatusChangeEventI
 template <class Derived>
 void
 WorkerPrivateParent<Derived>::MemoryPressure(bool aDummy)
 {
   AssertIsOnParentThread();
 
   RefPtr<MemoryPressureRunnable> runnable =
     new MemoryPressureRunnable(ParentAsWorkerPrivate());
-  NS_WARN_IF(!runnable->Dispatch());
+  Unused << NS_WARN_IF(!runnable->Dispatch());
 }
 
 template <class Derived>
 bool
 WorkerPrivateParent<Derived>::RegisterSharedWorker(SharedWorker* aSharedWorker,
                                                    MessagePort* aPort)
 {
   AssertIsOnMainThread();
@@ -4125,17 +4125,17 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
     loadInfo.mStorageAllowed = aParent->IsStorageAllowed();
     loadInfo.mPrivateBrowsing = aParent->IsInPrivateBrowsing();
     loadInfo.mServiceWorkersTestingInWindow =
       aParent->ServiceWorkersTestingInWindow();
   } else {
     AssertIsOnMainThread();
 
     // Make sure that the IndexedDatabaseManager is set up
-    NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
+    Unused << NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
 
     nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
     MOZ_ASSERT(ssm);
 
     bool isChrome = nsContentUtils::IsCallerChrome();
 
     // First check to make sure the caller has permission to make a privileged
     // worker if they called the ChromeWorker/ChromeSharedWorker constructor.
--- a/dom/workers/WorkerRunnable.cpp
+++ b/dom/workers/WorkerRunnable.cpp
@@ -743,17 +743,17 @@ WorkerProxyToMainThreadRunnable::PostDis
 
   private:
     ~ReleaseRunnable()
     {}
   };
 
   RefPtr<WorkerControlRunnable> runnable =
     new ReleaseRunnable(mWorkerPrivate, this);
-  NS_WARN_IF(!runnable->Dispatch());
+  Unused << NS_WARN_IF(!runnable->Dispatch());
 }
 
 bool
 WorkerProxyToMainThreadRunnable::HoldWorker()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(!mWorkerHolder);
 
--- a/dom/xbl/nsXBLWindowKeyHandler.cpp
+++ b/dom/xbl/nsXBLWindowKeyHandler.cpp
@@ -820,28 +820,28 @@ nsXBLWindowKeyHandler::GetElementForHand
 
   nsCOMPtr<nsIContent> keyContent = aHandler->GetHandlerElement();
   if (!keyContent) {
     return true; // XXX Even though no key element?
   }
 
   nsCOMPtr<Element> chromeHandlerElement = GetElement();
   if (!chromeHandlerElement) {
-    NS_WARN_IF(!keyContent->IsInUncomposedDoc());
+    NS_WARNING_ASSERTION(keyContent->IsInUncomposedDoc(), "uncomposed");
     nsCOMPtr<Element> keyElement = do_QueryInterface(keyContent);
     keyElement.swap(*aElementForHandler);
     return true;
   }
 
   // We are in a XUL doc.  Obtain our command attribute.
   nsAutoString command;
   keyContent->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
   if (command.IsEmpty()) {
     // There is no command element associated with the key element.
-    NS_WARN_IF(!keyContent->IsInUncomposedDoc());
+    NS_WARNING_ASSERTION(keyContent->IsInUncomposedDoc(), "uncomposed");
     nsCOMPtr<Element> keyElement = do_QueryInterface(keyContent);
     keyElement.swap(*aElementForHandler);
     return true;
   }
 
   // XXX Shouldn't we check this earlier?
   nsIDocument* doc = keyContent->GetUncomposedDoc();
   if (NS_WARN_IF(!doc)) {
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -535,17 +535,17 @@ UpgradeHostToOriginAndInsert(const nsACS
       // Ensure that we don't insert the same origin repeatedly
       if (insertedOrigins.Contains(origin)) {
         continue;
       }
 
       foundHistory = true;
       rv = aHelper->Insert(origin, aType, aPermission,
                            aExpireType, aExpireTime, aModificationTime);
-      NS_WARN_IF(NS_WARN_IF(NS_FAILED(rv)));
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Insert failed");
       insertedOrigins.PutEntry(origin);
     }
 
     rv = histResultContainer->SetContainerOpen(false);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // If we didn't find any origins for this host in the poermissions database,
--- a/hal/gonk/SystemService.cpp
+++ b/hal/gonk/SystemService.cpp
@@ -31,17 +31,17 @@ SystemServiceIsRunning(const char* aSvcN
     HAL_ERR("snprintf: %s", strerror(errno));
     return false;
   } else if (static_cast<size_t>(res) >= sizeof(key)) {
     HAL_ERR("snprintf: trunctated service name %s", aSvcName);
     return false;
   }
 
   char value[PROPERTY_VALUE_MAX];
-  NS_WARN_IF(property_get(key, value, "") < 0);
+  Unused << NS_WARN_IF(property_get(key, value, "") < 0);
 
   return !strcmp(value, "running");
 }
 
 class StartSystemServiceTimerCallback final : public nsITimerCallback
 {
   NS_DECL_THREADSAFE_ISUPPORTS;
 
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -1029,17 +1029,18 @@ nsGIFDecoder2::ReadLZWData(const char* a
     data += bytesRead;
     length -= bytesRead;
 
     switch (result) {
       case WriteState::NEED_MORE_DATA:
         continue;
 
       case WriteState::FINISHED:
-        NS_WARN_IF(mGIFStruct.pixels_remaining > 0);
+        NS_WARNING_ASSERTION(mGIFStruct.pixels_remaining <= 0,
+                             "too many pixels");
         mGIFStruct.pixels_remaining = 0;
         break;
 
       case WriteState::FAILURE:
         return Transition::TerminateFailure();
     }
   }
 
--- a/ipc/mscom/EnsureMTA.cpp
+++ b/ipc/mscom/EnsureMTA.cpp
@@ -29,17 +29,17 @@ public:
 class BackgroundMTAData
 {
 public:
   BackgroundMTAData()
   {
     nsCOMPtr<nsIRunnable> runnable = new EnterMTARunnable();
     nsresult rv = NS_NewNamedThread("COM MTA",
                                     getter_AddRefs(mThread), runnable);
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_NewNamedThread failed");
     MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
 
   ~BackgroundMTAData()
   {
     if (mThread) {
       mThread->Dispatch(NS_NewRunnableFunction(&::CoUninitialize),
                         NS_DISPATCH_NORMAL);
--- a/ipc/mscom/InterceptorLog.cpp
+++ b/ipc/mscom/InterceptorLog.cpp
@@ -9,16 +9,17 @@
 #include "MainThreadUtils.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/mscom/Registration.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/Unused.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsIFileStreams.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
@@ -35,16 +36,17 @@ using mozilla::mscom::ArrayData;
 using mozilla::mscom::FindArrayData;
 using mozilla::Mutex;
 using mozilla::MutexAutoLock;
 using mozilla::NewNonOwningRunnableMethod;
 using mozilla::services::GetObserverService;
 using mozilla::StaticAutoPtr;
 using mozilla::TimeDuration;
 using mozilla::TimeStamp;
+using mozilla::Unused;
 
 namespace {
 
 class ShutdownEvent final : public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
@@ -173,20 +175,20 @@ Logger::CloseFile()
 
 nsresult
 Logger::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
   nsresult rv = mThread->Dispatch(NewNonOwningRunnableMethod(this,
                                                              &Logger::CloseFile),
                                   NS_DISPATCH_NORMAL);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Dispatch failed");
 
   rv = mThread->Shutdown();
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Shutdown failed");
   return NS_OK;
 }
 
 bool
 Logger::VariantToString(const VARIANT& aVariant, nsACString& aOut, LONG aIndex)
 {
   switch (aVariant.vt) {
     case VT_DISPATCH: {
@@ -394,17 +396,17 @@ NS_IMETHODIMP
 ShutdownEvent::Observe(nsISupports* aSubject, const char* aTopic,
                        const char16_t* aData)
 {
   if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID)) {
     MOZ_ASSERT(false);
     return NS_ERROR_NOT_IMPLEMENTED;
   }
   MOZ_ASSERT(sLogger);
-  NS_WARN_IF(NS_FAILED(sLogger->Shutdown()));
+  Unused << NS_WARN_IF(NS_FAILED(sLogger->Shutdown()));
   nsCOMPtr<nsIObserver> kungFuDeathGrip(this);
   nsCOMPtr<nsIObserverService> obsSvc = GetObserverService();
   obsSvc->RemoveObserver(this, aTopic);
   return NS_OK;
 }
 } // anonymous namespace
 
 
--- a/ipc/mscom/MainThreadInvoker.cpp
+++ b/ipc/mscom/MainThreadInvoker.cpp
@@ -126,17 +126,17 @@ MainThreadInvoker::Invoke(already_AddRef
     // Enqueue failed so cancel the above AddRef
     wrappedRunnable->Release();
     return false;
   }
   // We should enqueue a call to NtTestAlert() so that the main thread will
   // check for APCs during event processing. If we omit this then the main
   // thread will not check its APC queue until it is idle. Note that failing to
   // dispatch this event is non-fatal, but it will delay execution of the APC.
-  NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(sAlertRunnable)));
+  Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(sAlertRunnable)));
   return WaitForCompletion(aTimeout);
 }
 
 /* static */ VOID CALLBACK
 MainThreadInvoker::MainThreadAPC(ULONG_PTR aParam)
 {
   MOZ_ASSERT(NS_IsMainThread());
   RefPtr<SyncRunnable> runnable(already_AddRefed<SyncRunnable>(
--- a/ipc/ril/RilSocket.cpp
+++ b/ipc/ril/RilSocket.cpp
@@ -214,17 +214,17 @@ private:
   RilSocketIO* mIO;
   UniquePtr<UnixSocketBuffer> mBuffer;
 };
 
 void
 RilSocketIO::ConsumeBuffer()
 {
   RefPtr<ReceiveTask> task = new ReceiveTask(this, mBuffer.release());
-  NS_WARN_IF(!mDispatcher->PostTask(task));
+  Unused << NS_WARN_IF(!mDispatcher->PostTask(task));
 }
 
 void
 RilSocketIO::DiscardBuffer()
 {
   // Nothing to do.
 }
 
--- a/ipc/unixfd/UnixFdWatcher.cpp
+++ b/ipc/unixfd/UnixFdWatcher.cpp
@@ -20,17 +20,17 @@
 #define CHROMIUM_LOG(args...) if (IODEBUG) printf(args);
 #endif
 
 namespace mozilla {
 namespace ipc {
 
 UnixFdWatcher::~UnixFdWatcher()
 {
-  NS_WARN_IF(IsOpen()); /* mFd should have been closed already */
+  NS_WARNING_ASSERTION(!IsOpen(), "mFd should have been closed already");
 }
 
 void
 UnixFdWatcher::Close()
 {
   MOZ_ASSERT(MessageLoopForIO::current() == mIOLoop);
 
   if (NS_WARN_IF(!IsOpen())) {
--- a/ipc/unixsocket/ListenSocket.cpp
+++ b/ipc/unixsocket/ListenSocket.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ListenSocket.h"
 #include <fcntl.h>
 #include "ConnectionOrientedSocket.h"
 #include "DataSocket.h"
 #include "ListenSocketConsumer.h"
+#include "mozilla/DebugOnly.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Unused.h"
 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
 #include "nsXULAppAPI.h"
 #include "UnixSocketConnector.h"
 
 namespace mozilla {
 namespace ipc {
@@ -148,18 +149,18 @@ ListenSocketIO::Listen(ConnectionOriente
       return;
     }
     SetFd(fd);
   }
 
   mCOSocketIO = aCOSocketIO;
 
   // calls OnListening on success, or OnError otherwise
-  nsresult rv = UnixSocketWatcher::Listen(address, mAddressLength);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = UnixSocketWatcher::Listen(address, mAddressLength);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Listen failed");
 }
 
 void
 ListenSocketIO::OnConnected()
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
 
   NS_NOTREACHED("Invalid call to |ListenSocketIO::OnConnected|");
--- a/layout/printing/ipc/RemotePrintJobParent.cpp
+++ b/layout/printing/ipc/RemotePrintJobParent.cpp
@@ -125,20 +125,20 @@ RemotePrintJobParent::PrintPage(const Sh
 }
 
 bool
 RemotePrintJobParent::RecvFinalizePrint()
 {
   // EndDocument is sometimes called in the child even when BeginDocument has
   // not been called. See bug 1223332.
   if (mPrintDeviceContext) {
-    nsresult rv = mPrintDeviceContext->EndDocument();
+    DebugOnly<nsresult> rv = mPrintDeviceContext->EndDocument();
 
     // Too late to abort the child just log.
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EndDocument failed");
   }
 
 
   Unused << Send__delete__(this);
   return true;
 }
 
 bool
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -690,18 +690,19 @@ private:
          *                                                              \
          * TODO(emilio): Convert to a strong assertion once we support  \
          * all kinds of random frames. In fact, this can be a great     \
          * assertion to debug them.                                     \
          */                                                             \
         if (mPseudoTag == nsCSSAnonBoxes::mozText) {                    \
           MOZ_ASSERT(mParent);                                          \
           newData = mParent->DoGetStyle##name_<true>();                 \
-          NS_WARN_IF(newData !=                                         \
-            Servo_GetStyle##name_(mSource.AsServoComputedValues()));    \
+          NS_WARNING_ASSERTION(                                         \
+            newData == Servo_GetStyle##name_(mSource.AsServoComputedValues()), \
+            "bad newData");                                             \
         } else {                                                        \
           newData =                                                     \
             Servo_GetStyle##name_(mSource.AsServoComputedValues());     \
         }                                                               \
         /* the Servo-backed StyleContextSource owns the struct */       \
         AddStyleBit(NS_STYLE_INHERIT_BIT(name_));                       \
       }                                                                 \
       /* always cache inherited data on the style context; the rule */  \
--- a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
@@ -1136,17 +1136,17 @@ WebrtcOMXH264VideoEncoder::SetRates(uint
   // XXX Limit bitrate for 8x10 devices to a specific level depending on fps and resolution
   // mBitRateKbps = LimitBitrate8x10(mWidth, mHeight, mFrameRate, aBitRateKbps);
   // Rely on global single setting (~720 kbps for HVGA@30fps) for now
   if (aBitRateKbps > 700) {
     aBitRateKbps = 700;
   }
   mBitRateKbps = aBitRateKbps;
   nsresult rv = mOMX->SetBitrate(mBitRateKbps);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetBitrate failed");
   return NS_FAILED(rv) ? WEBRTC_VIDEO_CODEC_OK : WEBRTC_VIDEO_CODEC_ERROR;
 }
 
 // Decoder.
 WebrtcOMXH264VideoDecoder::WebrtcOMXH264VideoDecoder()
   : mCallback(nullptr)
   , mOMX(nullptr)
 {
--- a/netwerk/base/NetworkInfoServiceCocoa.cpp
+++ b/netwerk/base/NetworkInfoServiceCocoa.cpp
@@ -7,16 +7,17 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <net/if.h>
 #include <netdb.h>
 
+#include "mozilla/DebugOnly.h"
 #include "mozilla/ScopeExit.h"
 
 #include "NetworkInfoServiceImpl.h"
 
 namespace mozilla {
 namespace net {
 
 static nsresult
@@ -47,18 +48,19 @@ DoListAddresses(AddrMapType& aAddrMap)
         return NS_ERROR_FAILURE;
     }
 
     struct ifreq* ifreq = ifconf.ifc_req;
     int i = 0;
     while (i < ifconf.ifc_len) {
         size_t len = IFNAMSIZ + ifreq->ifr_addr.sa_len;
 
-        nsresult rv = ListInterfaceAddresses(fd, ifreq->ifr_name, aAddrMap);
-        NS_WARN_IF(NS_FAILED(rv));
+        DebugOnly<nsresult> rv =
+          ListInterfaceAddresses(fd, ifreq->ifr_name, aAddrMap);
+        NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "ListInterfaceAddresses failed");
 
         ifreq = (struct ifreq*) ((char*)ifreq + len);
         i += len;
     }
 
     autoCloseSocket.release();
     return NS_OK;
 }
--- a/netwerk/base/NetworkInfoServiceLinux.cpp
+++ b/netwerk/base/NetworkInfoServiceLinux.cpp
@@ -7,16 +7,17 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <net/if.h>
 #include <netdb.h>
 
+#include "mozilla/DebugOnly.h"
 #include "mozilla/ScopeExit.h"
 
 #include "NetworkInfoServiceImpl.h"
 
 namespace mozilla {
 namespace net {
 
 static nsresult
@@ -47,18 +48,19 @@ DoListAddresses(AddrMapType& aAddrMap)
         return NS_ERROR_FAILURE;
     }
 
     struct ifreq* ifreq = ifconf.ifc_req;
     int i = 0;
     while (i < ifconf.ifc_len) {
         size_t len = sizeof(struct ifreq);
 
-        nsresult rv = ListInterfaceAddresses(fd, ifreq->ifr_name, aAddrMap);
-        NS_WARN_IF(NS_FAILED(rv));
+        DebugOnly<nsresult> rv =
+          ListInterfaceAddresses(fd, ifreq->ifr_name, aAddrMap);
+        NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "ListInterfaceAddresses failed");
 
         ifreq = (struct ifreq*) ((char*)ifreq + len);
         i += len;
     }
 
     autoCloseSocket.release();
     return NS_OK;
 }
--- a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp
+++ b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.cpp
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MDNSResponderOperator.h"
 #include "MDNSResponderReply.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/Logging.h"
 #include "mozilla/ScopeExit.h"
+#include "mozilla/Unused.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsDNSServiceInfo.h"
 #include "nsHashPropertyBag.h"
 #include "nsIProperty.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIVariant.h"
@@ -330,17 +331,17 @@ BrowseOperator::Start()
   DNSServiceRef service = nullptr;
   DNSServiceErrorType err = DNSServiceBrowse(&service,
                                              0,
                                              kDNSServiceInterfaceIndexAny,
                                              mServiceType.get(),
                                              nullptr,
                                              &BrowseReplyRunnable::Reply,
                                              this);
-  NS_WARN_IF(kDNSServiceErr_NoError != err);
+  NS_WARNING_ASSERTION(kDNSServiceErr_NoError == err, "DNSServiceBrowse fail");
 
   if (mListener) {
     if (kDNSServiceErr_NoError == err) {
       mListener->OnDiscoveryStarted(mServiceType);
     } else {
       mListener->OnStartDiscoveryFailed(mServiceType, err);
     }
   }
@@ -486,17 +487,18 @@ RegisterOperator::Start()
                          domain.get() : nullptr,
                        NS_SUCCEEDED(mServiceInfo->GetHost(host)) ?
                          host.get() : nullptr,
                        NativeEndian::swapToNetworkOrder(port),
                        TXTRecordGetLength(&txtRecord),
                        TXTRecordGetBytesPtr(&txtRecord),
                        &RegisterReplyRunnable::Reply,
                        this);
-  NS_WARN_IF(kDNSServiceErr_NoError != err);
+  NS_WARNING_ASSERTION(kDNSServiceErr_NoError == err,
+                       "DNSServiceRegister fail");
 
   TXTRecordDeallocate(&txtRecord);
 
   if (NS_WARN_IF(kDNSServiceErr_NoError != err)) {
     if (mListener) {
       mListener->OnRegistrationFailed(mServiceInfo, err);
     }
     return NS_ERROR_FAILURE;
@@ -615,17 +617,17 @@ ResolveOperator::Reply(DNSServiceRef aSd
                        const nsACString& aHostTarget,
                        uint16_t aPort,
                        uint16_t aTxtLen,
                        const unsigned char* aTxtRecord)
 {
   MOZ_ASSERT(GetThread() == NS_GetCurrentThread());
 
   auto guard = MakeScopeExit([this] {
-    NS_WARN_IF(NS_FAILED(Stop()));
+    Unused << NS_WARN_IF(NS_FAILED(Stop()));
   });
 
   if (NS_WARN_IF(kDNSServiceErr_NoError != aErrorCode)) {
     LOG_E("ResolveOperator::Reply (%d)", aErrorCode);
     return;
   }
 
   // Resolve TXT record
@@ -669,26 +671,26 @@ ResolveOperator::Reply(DNSServiceRef aSd
   if (NS_WARN_IF(NS_FAILED(info->SetPort(aPort)))) { return; }
   if (NS_WARN_IF(NS_FAILED(info->SetAttributes(attributes)))) { return; }
 
   if (kDNSServiceErr_NoError == aErrorCode) {
     GetAddrInfor(info);
   }
   else {
     mListener->OnResolveFailed(info, aErrorCode);
-    NS_WARN_IF(NS_FAILED(Stop()));
+    Unused << NS_WARN_IF(NS_FAILED(Stop()));
   }
 }
 
 void
 ResolveOperator::GetAddrInfor(nsIDNSServiceInfo* aServiceInfo)
 {
   RefPtr<GetAddrInfoOperator> getAddreOp = new GetAddrInfoOperator(aServiceInfo,
                                                                    mListener);
-  NS_WARN_IF(NS_FAILED(getAddreOp->Start()));
+  Unused << NS_WARN_IF(NS_FAILED(getAddreOp->Start()));
 }
 
 GetAddrInfoOperator::GetAddrInfoOperator(nsIDNSServiceInfo* aServiceInfo,
                                          nsIDNSServiceResolveListener* aListener)
   : MDNSResponderOperator()
   , mServiceInfo(aServiceInfo)
   , mListener(aListener)
 {
@@ -734,17 +736,17 @@ GetAddrInfoOperator::Reply(DNSServiceRef
                            DNSServiceErrorType aErrorCode,
                            const nsACString& aHostName,
                            const NetAddr& aAddress,
                            uint32_t aTTL)
 {
   MOZ_ASSERT(GetThread() == NS_GetCurrentThread());
 
   auto guard = MakeScopeExit([this] {
-    NS_WARN_IF(NS_FAILED(Stop()));
+    Unused << NS_WARN_IF(NS_FAILED(Stop()));
   });
 
   if (NS_WARN_IF(kDNSServiceErr_NoError != aErrorCode)) {
     LOG_E("GetAddrInfoOperator::Reply (%d)", aErrorCode);
     return;
   }
 
   if (!mListener) { return; }
--- a/netwerk/dns/mdns/libmdns/nsDNSServiceInfo.cpp
+++ b/netwerk/dns/mdns/libmdns/nsDNSServiceInfo.cpp
@@ -3,78 +3,80 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDNSServiceInfo.h"
 #include "nsHashPropertyBag.h"
 #include "nsIProperty.h"
 #include "nsISimpleEnumerator.h"
 #include "nsISupportsImpl.h"
+#include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ISUPPORTS(nsDNSServiceInfo, nsIDNSServiceInfo)
 
 nsDNSServiceInfo::nsDNSServiceInfo(nsIDNSServiceInfo* aServiceInfo)
 {
   if (NS_WARN_IF(!aServiceInfo)) {
     return;
   }
 
   nsAutoCString str;
   uint16_t value;
 
   if (NS_SUCCEEDED(aServiceInfo->GetHost(str))) {
-    NS_WARN_IF(NS_FAILED(SetHost(str)));
+    Unused << NS_WARN_IF(NS_FAILED(SetHost(str)));
   }
   if (NS_SUCCEEDED(aServiceInfo->GetAddress(str))) {
-    NS_WARN_IF(NS_FAILED(SetAddress(str)));
+    Unused << NS_WARN_IF(NS_FAILED(SetAddress(str)));
   }
   if (NS_SUCCEEDED(aServiceInfo->GetPort(&value))) {
-    NS_WARN_IF(NS_FAILED(SetPort(value)));
+    Unused << NS_WARN_IF(NS_FAILED(SetPort(value)));
   }
   if (NS_SUCCEEDED(aServiceInfo->GetServiceName(str))) {
-    NS_WARN_IF(NS_FAILED(SetServiceName(str)));
+    Unused << NS_WARN_IF(NS_FAILED(SetServiceName(str)));
   }
   if (NS_SUCCEEDED(aServiceInfo->GetServiceType(str))) {
-    NS_WARN_IF(NS_FAILED(SetServiceType(str)));
+    Unused << NS_WARN_IF(NS_FAILED(SetServiceType(str)));
   }
   if (NS_SUCCEEDED(aServiceInfo->GetDomainName(str))) {
-    NS_WARN_IF(NS_FAILED(SetDomainName(str)));
+    Unused << NS_WARN_IF(NS_FAILED(SetDomainName(str)));
   }
 
   nsCOMPtr<nsIPropertyBag2> attributes; // deep copy
   if (NS_SUCCEEDED(aServiceInfo->GetAttributes(getter_AddRefs(attributes)))) {
     nsCOMPtr<nsISimpleEnumerator> enumerator;
     if (NS_WARN_IF(NS_FAILED(attributes->GetEnumerator(getter_AddRefs(enumerator))))) {
       return;
     }
 
     nsCOMPtr<nsIWritablePropertyBag2> newAttributes = new nsHashPropertyBag();
 
     bool hasMoreElements;
     while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreElements)) &&
            hasMoreElements) {
       nsCOMPtr<nsISupports> element;
-      NS_WARN_IF(NS_FAILED(enumerator->GetNext(getter_AddRefs(element))));
+      Unused <<
+        NS_WARN_IF(NS_FAILED(enumerator->GetNext(getter_AddRefs(element))));
       nsCOMPtr<nsIProperty> property = do_QueryInterface(element);
       MOZ_ASSERT(property);
 
       nsAutoString name;
       nsCOMPtr<nsIVariant> value;
-      NS_WARN_IF(NS_FAILED(property->GetName(name)));
-      NS_WARN_IF(NS_FAILED(property->GetValue(getter_AddRefs(value))));
+      Unused << NS_WARN_IF(NS_FAILED(property->GetName(name)));
+      Unused << NS_WARN_IF(NS_FAILED(property->GetValue(getter_AddRefs(value))));
       nsAutoCString valueStr;
-      NS_WARN_IF(NS_FAILED(value->GetAsACString(valueStr)));
+      Unused << NS_WARN_IF(NS_FAILED(value->GetAsACString(valueStr)));
 
-      NS_WARN_IF(NS_FAILED(newAttributes->SetPropertyAsACString(name, valueStr)));
+      Unused << NS_WARN_IF(NS_FAILED(newAttributes->SetPropertyAsACString(name, valueStr)));
     }
 
-    NS_WARN_IF(NS_FAILED(SetAttributes(newAttributes)));
+    Unused << NS_WARN_IF(NS_FAILED(SetAttributes(newAttributes)));
   }
 }
 
 NS_IMETHODIMP
 nsDNSServiceInfo::GetHost(nsACString& aHost)
 {
   if (!mIsHostSet) {
     return NS_ERROR_NOT_INITIALIZED;
--- a/netwerk/ipc/ChannelEventQueue.cpp
+++ b/netwerk/ipc/ChannelEventQueue.cpp
@@ -2,16 +2,17 @@
  * vim: set sw=2 ts=8 et tw=80 :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.h"
 #include "mozilla/net/ChannelEventQueue.h"
+#include "mozilla/Unused.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace net {
 
 ChannelEvent*
 ChannelEventQueue::TakeEvent()
 {
@@ -68,17 +69,17 @@ ChannelEventQueue::Resume()
 
   if (!--mSuspendCount) {
     RefPtr<Runnable> event =
       NewRunnableMethod(this, &ChannelEventQueue::CompleteResume);
     if (mTargetThread) {
       mTargetThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
     } else {
       MOZ_RELEASE_ASSERT(NS_IsMainThread());
-      NS_WARN_IF(NS_FAILED(NS_DispatchToCurrentThread(event.forget())));
+      Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToCurrentThread(event.forget())));
     }
   }
 }
 
 nsresult
 ChannelEventQueue::RetargetDeliveryTo(nsIEventTarget* aTargetThread)
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
--- a/netwerk/protocol/http/PackagedAppService.cpp
+++ b/netwerk/protocol/http/PackagedAppService.cpp
@@ -460,17 +460,17 @@ PackagedAppService::PackagedAppDownloade
 
   rv = CacheEntryWriter::Create(uri, mCacheStorage, getter_AddRefs(mWriter));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return NS_OK;
   }
 
   MOZ_ASSERT(mWriter);
   rv = mWriter->OnStartRequest(aRequest, aContext);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "OnStartRequest failed");
 
   EnsureVerifier(aRequest);
 
   if (!mVerifier->WouldVerify()) {
     // It means there's no signature or the signed app is disabled.
     return NS_OK;
   }
 
--- a/netwerk/protocol/websocket/WebSocketEventService.cpp
+++ b/netwerk/protocol/websocket/WebSocketEventService.cpp
@@ -78,25 +78,24 @@ public:
     : WebSocketBaseRunnable(aWebSocketSerialID, aInnerWindowID)
     , mFrame(Move(aFrame))
     , mFrameSent(aFrameSent)
   {}
 
 private:
   virtual void DoWork(nsIWebSocketEventListener* aListener) override
   {
-    nsresult rv;
-
+    DebugOnly<nsresult> rv;
     if (mFrameSent) {
       rv = aListener->FrameSent(mWebSocketSerialID, mFrame);
     } else {
       rv = aListener->FrameReceived(mWebSocketSerialID, mFrame);
     }
 
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Frame op failed");
   }
 
   RefPtr<WebSocketFrame> mFrame;
   bool mFrameSent;
 };
 
 class WebSocketCreatedRunnable final : public WebSocketBaseRunnable
 {
@@ -108,19 +107,19 @@ public:
     : WebSocketBaseRunnable(aWebSocketSerialID, aInnerWindowID)
     , mURI(aURI)
     , mProtocols(aProtocols)
   {}
 
 private:
   virtual void DoWork(nsIWebSocketEventListener* aListener) override
   {
-    nsresult rv = aListener->WebSocketCreated(mWebSocketSerialID,
-                                             mURI, mProtocols);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv =
+      aListener->WebSocketCreated(mWebSocketSerialID, mURI, mProtocols);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WebSocketCreated failed");
   }
 
   const nsString mURI;
   const nsCString mProtocols;
 };
 
 class WebSocketOpenedRunnable final : public WebSocketBaseRunnable
 {
@@ -134,21 +133,21 @@ public:
     , mEffectiveURI(aEffectiveURI)
     , mProtocols(aProtocols)
     , mExtensions(aExtensions)
   {}
 
 private:
   virtual void DoWork(nsIWebSocketEventListener* aListener) override
   {
-    nsresult rv = aListener->WebSocketOpened(mWebSocketSerialID,
-                                             mEffectiveURI,
-                                             mProtocols,
-                                             mExtensions);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = aListener->WebSocketOpened(mWebSocketSerialID,
+                                                        mEffectiveURI,
+                                                        mProtocols,
+                                                        mExtensions);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WebSocketOpened failed");
   }
 
   const nsString mEffectiveURI;
   const nsCString mProtocols;
   const nsCString mExtensions;
 };
 
 class WebSocketMessageAvailableRunnable final : public WebSocketBaseRunnable
@@ -161,19 +160,20 @@ public:
     : WebSocketBaseRunnable(aWebSocketSerialID, aInnerWindowID)
     , mData(aData)
     , mMessageType(aMessageType)
   {}
 
 private:
   virtual void DoWork(nsIWebSocketEventListener* aListener) override
   {
-    nsresult rv = aListener->WebSocketMessageAvailable(mWebSocketSerialID,
-                                                       mData, mMessageType);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv =
+      aListener->WebSocketMessageAvailable(mWebSocketSerialID, mData,
+                                           mMessageType);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WebSocketMessageAvailable failed");
   }
 
   const nsCString mData;
   uint16_t mMessageType;
 };
 
 class WebSocketClosedRunnable final : public WebSocketBaseRunnable
 {
@@ -187,19 +187,19 @@ public:
     , mWasClean(aWasClean)
     , mCode(aCode)
     , mReason(aReason)
   {}
 
 private:
   virtual void DoWork(nsIWebSocketEventListener* aListener) override
   {
-    nsresult rv = aListener->WebSocketClosed(mWebSocketSerialID,
-                                             mWasClean, mCode, mReason);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv =
+      aListener->WebSocketClosed(mWebSocketSerialID, mWasClean, mCode, mReason);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "WebSocketClosed failed");
   }
 
   bool mWasClean;
   uint16_t mCode;
   const nsString mReason;
 };
 
 /* static */ already_AddRefed<WebSocketEventService>
@@ -250,18 +250,18 @@ WebSocketEventService::WebSocketCreated(
   // Let's continue only if we have some listeners.
   if (!HasListeners()) {
     return;
   }
 
   RefPtr<WebSocketCreatedRunnable> runnable =
     new WebSocketCreatedRunnable(aWebSocketSerialID, aInnerWindowID,
                                  aURI, aProtocols);
-  nsresult rv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
 }
 
 void
 WebSocketEventService::WebSocketOpened(uint32_t aWebSocketSerialID,
                                        uint64_t aInnerWindowID,
                                        const nsAString& aEffectiveURI,
                                        const nsACString& aProtocols,
                                        const nsACString& aExtensions)
@@ -269,36 +269,36 @@ WebSocketEventService::WebSocketOpened(u
   // Let's continue only if we have some listeners.
   if (!HasListeners()) {
     return;
   }
 
   RefPtr<WebSocketOpenedRunnable> runnable =
     new WebSocketOpenedRunnable(aWebSocketSerialID, aInnerWindowID,
                                 aEffectiveURI, aProtocols, aExtensions);
-  nsresult rv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
 }
 
 void
 WebSocketEventService::WebSocketMessageAvailable(uint32_t aWebSocketSerialID,
                                                  uint64_t aInnerWindowID,
                                                  const nsACString& aData,
                                                  uint16_t aMessageType)
 {
   // Let's continue only if we have some listeners.
   if (!HasListeners()) {
     return;
   }
 
   RefPtr<WebSocketMessageAvailableRunnable> runnable =
     new WebSocketMessageAvailableRunnable(aWebSocketSerialID, aInnerWindowID,
                                           aData, aMessageType);
-  nsresult rv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
 }
 
 void
 WebSocketEventService::WebSocketClosed(uint32_t aWebSocketSerialID,
                                        uint64_t aInnerWindowID,
                                        bool aWasClean,
                                        uint16_t aCode,
                                        const nsAString& aReason)
@@ -306,18 +306,18 @@ WebSocketEventService::WebSocketClosed(u
   // Let's continue only if we have some listeners.
   if (!HasListeners()) {
     return;
   }
 
   RefPtr<WebSocketClosedRunnable> runnable =
     new WebSocketClosedRunnable(aWebSocketSerialID, aInnerWindowID,
                                 aWasClean, aCode, aReason);
-  nsresult rv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
 }
 
 void
 WebSocketEventService::FrameReceived(uint32_t aWebSocketSerialID,
                                      uint64_t aInnerWindowID,
                                      already_AddRefed<WebSocketFrame> aFrame)
 {
   RefPtr<WebSocketFrame> frame(Move(aFrame));
@@ -326,18 +326,18 @@ WebSocketEventService::FrameReceived(uin
   // Let's continue only if we have some listeners.
   if (!HasListeners()) {
     return;
   }
 
   RefPtr<WebSocketFrameRunnable> runnable =
     new WebSocketFrameRunnable(aWebSocketSerialID, aInnerWindowID,
                                frame.forget(), false /* frameSent */);
-  nsresult rv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
 }
 
 void
 WebSocketEventService::FrameSent(uint32_t aWebSocketSerialID,
                                  uint64_t aInnerWindowID,
                                  already_AddRefed<WebSocketFrame> aFrame)
 {
   RefPtr<WebSocketFrame> frame(Move(aFrame));
@@ -347,18 +347,18 @@ WebSocketEventService::FrameSent(uint32_
   if (!HasListeners()) {
     return;
   }
 
   RefPtr<WebSocketFrameRunnable> runnable =
     new WebSocketFrameRunnable(aWebSocketSerialID, aInnerWindowID,
                                frame.forget(), true /* frameSent */);
 
-  nsresult rv = NS_DispatchToMainThread(runnable);
-  NS_WARN_IF(NS_FAILED(rv));
+  DebugOnly<nsresult> rv = NS_DispatchToMainThread(runnable);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NS_DispatchToMainThread failed");
 }
 
 NS_IMETHODIMP
 WebSocketEventService::AddListener(uint64_t aInnerWindowID,
                                    nsIWebSocketEventListener* aListener)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -14,16 +14,17 @@
 #include "nsCRT.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
 
 #include "ParseFTPList.h"
 #include <algorithm>
 
 #include "mozilla/UniquePtrExtensions.h"
+#include "mozilla/Unused.h"
 
 //
 // Log module for FTP dir listing stream converter logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set MOZ_LOG=nsFTPDirListConv:5
 //    set MOZ_LOG_FILE=network.log
@@ -290,17 +291,17 @@ nsFTPDirListingConv::DigestBufferLines(c
         // Note: The below is the RFC822/1123 format, as required by
         // the application/http-index-format specs
         // viewers of such a format can then reformat this into the
         // current locale (or anything else they choose)
         PR_FormatTimeUSEnglish(buffer, sizeof(buffer),
                                "%a, %d %b %Y %H:%M:%S", &result.fe_time );
 
         nsAutoCString escaped;
-        NS_WARN_IF(!NS_Escape(nsDependentCString(buffer), escaped, url_Path));
+        Unused << NS_WARN_IF(!NS_Escape(nsDependentCString(buffer), escaped, url_Path));
         aString.Append(escaped);
         aString.Append(' ');
 
         // ENTRY TYPE
         if (type == 'd')
             aString.AppendLiteral("DIRECTORY");
         else if (type == 'l')
             aString.AppendLiteral("SYMBOLIC-LINK");
--- a/toolkit/components/terminator/nsTerminator.cpp
+++ b/toolkit/components/terminator/nsTerminator.cpp
@@ -339,19 +339,17 @@ nsTerminator::SelfInit()
 {
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (!os) {
     return NS_ERROR_UNEXPECTED;
   }
 
   for (size_t i = 0; i < ArrayLength(sShutdownSteps); ++i) {
     DebugOnly<nsresult> rv = os->AddObserver(this, sShutdownSteps[i].mTopic, false);
-#if defined(DEBUG)
-    NS_WARN_IF(NS_FAILED(rv));
-#endif // defined(DEBUG)
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "AddObserver failed");
   }
 
   return NS_OK;
 }
 
 // Actually launch these threads. This takes place at the first sign of shutdown.
 void
 nsTerminator::Start()
--- a/toolkit/components/url-classifier/ProtocolParser.cpp
+++ b/toolkit/components/url-classifier/ProtocolParser.cpp
@@ -860,18 +860,18 @@ ProtocolParserProtobuf::ProcessOneRespon
   auto tuV4 = TableUpdate::Cast<TableUpdateV4>(tu);
   NS_ENSURE_TRUE(tuV4, NS_ERROR_FAILURE);
 
   // See Bug 1287059. We save the state to prefs until we support
   // "saving states to HashStore".
   nsCString state(aResponse.new_client_state().c_str(),
                   aResponse.new_client_state().size());
   NS_DispatchToMainThread(NS_NewRunnableFunction([listName, state] () {
-    nsresult rv = SaveStateToPref(listName, state);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = SaveStateToPref(listName, state);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SaveStateToPref failed");
   }));
 
   PARSER_LOG(("==== Update for threat type '%d' ====", aResponse.threat_type()));
   PARSER_LOG(("* listName: %s\n", listName.get()));
   PARSER_LOG(("* newState: %s\n", aResponse.new_client_state().c_str()));
   PARSER_LOG(("* isFullUpdate: %s\n", (isFullUpdate ? "yes" : "no")));
   ProcessAdditionOrRemoval(*tuV4, aResponse.additions(), true /*aIsAddition*/);
   ProcessAdditionOrRemoval(*tuV4, aResponse.removals(), false);
--- a/tools/profiler/gecko/ProfileGatherer.cpp
+++ b/tools/profiler/gecko/ProfileGatherer.cpp
@@ -79,20 +79,21 @@ ProfileGatherer::Start(double aSinceTime
 
   mSinceTime = aSinceTime;
   mPromise = aPromise;
   mGathering = true;
   mPendingProfiles = 0;
 
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
-    nsresult rv = os->AddObserver(this, "profiler-subprocess", false);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv =
+      os->AddObserver(this, "profiler-subprocess", false);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "AddObserver failed");
     rv = os->NotifyObservers(this, "profiler-subprocess-gather", nullptr);
-    NS_WARN_IF(NS_FAILED(rv));
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "NotifyObservers failed");
   }
 
   if (!mPendingProfiles) {
     Finish();
   }
 }
 
 void
@@ -105,18 +106,18 @@ ProfileGatherer::Finish()
     // be possible, but doing a belt-and-suspenders check to be sure.
     return;
   }
 
   UniquePtr<char[]> buf = mTicker->ToJSON(mSinceTime);
 
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
-    nsresult rv = os->RemoveObserver(this, "profiler-subprocess");
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = os->RemoveObserver(this, "profiler-subprocess");
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RemoveObserver failed");
   }
 
   AutoJSAPI jsapi;
   if (NS_WARN_IF(!jsapi.Init(mPromise->GlobalJSObject()))) {
     // We're really hosed if we can't get a JS context for some reason.
     Reset();
     return;
   }
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -30,16 +30,17 @@
 #include "nsITransport.h"
 #include "nsISocketTransport.h"
 #include "nsIDocShell.h"
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 
+using mozilla::DebugOnly;
 using mozilla::LogLevel;
 
 static NS_DEFINE_CID(kThisImplCID, NS_THIS_DOCLOADER_IMPL_CID);
 
 //
 // Log module for nsIDocumentLoader logging...
 //
 // To enable logging (see mozilla/Logging.h for full details):
@@ -340,18 +341,18 @@ nsDocLoader::GetLoadGroup(nsILoadGroup**
 void
 nsDocLoader::Destroy()
 {
   Stop();
 
   // Remove the document loader from the parent list of loaders...
   if (mParent)
   {
-    nsresult rv = mParent->RemoveChildLoader(this);
-    NS_WARN_IF(NS_FAILED(rv));
+    DebugOnly<nsresult> rv = mParent->RemoveChildLoader(this);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RemoveChildLoader failed");
   }
 
   // Release all the information about network requests...
   ClearRequestInfoHash();
 
   mListenerInfoList.Clear();
   mListenerInfoList.Compact();
 
@@ -372,18 +373,19 @@ nsDocLoader::DestroyChildren()
   // loader
   for (uint32_t i=0; i < count; i++)
   {
     nsIDocumentLoader* loader = ChildAt(i);
 
     if (loader) {
       // This is a safe cast, as we only put nsDocLoader objects into the
       // array
-      nsresult rv = static_cast<nsDocLoader*>(loader)->SetDocLoaderParent(nullptr);
-      NS_WARN_IF(NS_FAILED(rv));
+      DebugOnly<nsresult> rv =
+        static_cast<nsDocLoader*>(loader)->SetDocLoaderParent(nullptr);
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetDocLoaderParent failed");
     }
   }
   mChildList.Clear();
 }
 
 NS_IMETHODIMP
 nsDocLoader::OnStartRequest(nsIRequest *request, nsISupports *aCtxt)
 {
--- a/uriloader/exthandler/mac/nsOSHelperAppService.mm
+++ b/uriloader/exthandler/mac/nsOSHelperAppService.mm
@@ -556,14 +556,14 @@ nsOSHelperAppService::GetProtocolHandler
   if (!*found) {
     // Code that calls this requires an object regardless if the OS has
     // something for us, so we return the empty object.
     return NS_OK;
   }
 
   nsAutoString desc;
   rv = GetApplicationDescription(aScheme, desc);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "GetApplicationDescription failed");
   handlerInfo->SetDefaultDescription(desc);
 
   return NS_OK;
 }
 
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -494,17 +494,17 @@ ContentCacheInChild::SetSelection(nsIWid
     mSelection.mAnchor = aStartOffset + aLength;
     mSelection.mFocus = aStartOffset;
   }
   mSelection.mWritingMode = aWritingMode;
 
   if (NS_WARN_IF(!CacheCaret(aWidget))) {
     return;
   }
-  NS_WARN_IF(!CacheTextRects(aWidget));
+  Unused << NS_WARN_IF(!CacheTextRects(aWidget));
 }
 
 /*****************************************************************************
  * mozilla::ContentCacheInParent
  *****************************************************************************/
 
 ContentCacheInParent::ContentCacheInParent()
   : ContentCache()
@@ -523,20 +523,20 @@ ContentCacheInParent::AssignContent(cons
   mText = aOther.mText;
   mSelection = aOther.mSelection;
   mFirstCharRect = aOther.mFirstCharRect;
   mCaret = aOther.mCaret;
   mTextRectArray = aOther.mTextRectArray;
   mEditorRect = aOther.mEditorRect;
 
   if (mIsComposing) {
-    NS_WARN_IF(mCompositionStart == UINT32_MAX);
+    NS_WARNING_ASSERTION(mCompositionStart != UINT32_MAX, "mCompositionStart");
     IMEStateManager::MaybeStartOffsetUpdatedInChild(aWidget, mCompositionStart);
   } else {
-    NS_WARN_IF(mCompositionStart != UINT32_MAX);
+    NS_WARNING_ASSERTION(mCompositionStart == UINT32_MAX, "mCompositionStart");
   }
 
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p AssignContent(aNotification=%s), "
      "Succeeded, mText.Length()=%u, mSelection={ mAnchor=%u, mFocus=%u, "
      "mWritingMode=%s, mAnchorCharRects[eNextCharRect]=%s, "
      "mAnchorCharRects[ePrevCharRect]=%s, mFocusCharRects[eNextCharRect]=%s, "
      "mFocusCharRects[ePrevCharRect]=%s, mRect=%s }, "
@@ -831,37 +831,41 @@ ContentCacheInParent::GetTextRect(uint32
      "aRoundToExistingOffset=%s), "
      "mTextRectArray={ mStart=%u, mRects.Length()=%u }, "
      "mSelection={ mAnchor=%u, mFocus=%u }",
      this, aOffset, GetBoolName(aRoundToExistingOffset),
      mTextRectArray.mStart, mTextRectArray.mRects.Length(),
      mSelection.mAnchor, mSelection.mFocus));
 
   if (!aOffset) {
-    NS_WARN_IF(mFirstCharRect.IsEmpty());
+    NS_WARNING_ASSERTION(!mFirstCharRect.IsEmpty(), "empty rect");
     aTextRect = mFirstCharRect;
     return !aTextRect.IsEmpty();
   }
   if (aOffset == mSelection.mAnchor) {
-    NS_WARN_IF(mSelection.mAnchorCharRects[eNextCharRect].IsEmpty());
+    NS_WARNING_ASSERTION(!mSelection.mAnchorCharRects[eNextCharRect].IsEmpty(),
+                         "empty rect");
     aTextRect = mSelection.mAnchorCharRects[eNextCharRect];
     return !aTextRect.IsEmpty();
   }
   if (mSelection.mAnchor && aOffset == mSelection.mAnchor - 1) {
-    NS_WARN_IF(mSelection.mAnchorCharRects[ePrevCharRect].IsEmpty());
+    NS_WARNING_ASSERTION(!mSelection.mAnchorCharRects[ePrevCharRect].IsEmpty(),
+                         "empty rect");
     aTextRect = mSelection.mAnchorCharRects[ePrevCharRect];
     return !aTextRect.IsEmpty();
   }
   if (aOffset == mSelection.mFocus) {
-    NS_WARN_IF(mSelection.mFocusCharRects[eNextCharRect].IsEmpty());
+    NS_WARNING_ASSERTION(!mSelection.mFocusCharRects[eNextCharRect].IsEmpty(),
+                         "empty rect");
     aTextRect = mSelection.mFocusCharRects[eNextCharRect];
     return !aTextRect.IsEmpty();
   }
   if (mSelection.mFocus && aOffset == mSelection.mFocus - 1) {
-    NS_WARN_IF(mSelection.mFocusCharRects[ePrevCharRect].IsEmpty());
+    NS_WARNING_ASSERTION(!mSelection.mFocusCharRects[ePrevCharRect].IsEmpty(),
+                         "empty rect");
     aTextRect = mSelection.mFocusCharRects[ePrevCharRect];
     return !aTextRect.IsEmpty();
   }
 
   uint32_t offset = aOffset;
   if (!mTextRectArray.InRange(aOffset)) {
     if (!aRoundToExistingOffset) {
       aTextRect.SetEmpty();
@@ -903,44 +907,48 @@ ContentCacheInParent::GetUnionTextRects(
   CheckedInt<uint32_t> endOffset =
     CheckedInt<uint32_t>(aOffset) + aLength;
   if (!endOffset.isValid()) {
     return false;
   }
 
   if (!mSelection.Collapsed() &&
       aOffset == mSelection.StartOffset() && aLength == mSelection.Length()) {
-    NS_WARN_IF(mSelection.mRect.IsEmpty());
+    NS_WARNING_ASSERTION(!mSelection.mRect.IsEmpty(), "empty rect");
     aUnionTextRect = mSelection.mRect;
     return !aUnionTextRect.IsEmpty();
   }
 
   if (aLength == 1) {
     if (!aOffset) {
-      NS_WARN_IF(mFirstCharRect.IsEmpty());
+      NS_WARNING_ASSERTION(!mFirstCharRect.IsEmpty(), "empty rect");
       aUnionTextRect = mFirstCharRect;
       return !aUnionTextRect.IsEmpty();
     }
     if (aOffset == mSelection.mAnchor) {
-      NS_WARN_IF(mSelection.mAnchorCharRects[eNextCharRect].IsEmpty());
+      NS_WARNING_ASSERTION(
+        !mSelection.mAnchorCharRects[eNextCharRect].IsEmpty(), "empty rect");
       aUnionTextRect = mSelection.mAnchorCharRects[eNextCharRect];
       return !aUnionTextRect.IsEmpty();
     }
     if (mSelection.mAnchor && aOffset == mSelection.mAnchor - 1) {
-      NS_WARN_IF(mSelection.mAnchorCharRects[ePrevCharRect].IsEmpty());
+      NS_WARNING_ASSERTION(
+        !mSelection.mAnchorCharRects[ePrevCharRect].IsEmpty(), "empty rect");
       aUnionTextRect = mSelection.mAnchorCharRects[ePrevCharRect];
       return !aUnionTextRect.IsEmpty();
     }
     if (aOffset == mSelection.mFocus) {
-      NS_WARN_IF(mSelection.mFocusCharRects[eNextCharRect].IsEmpty());
+      NS_WARNING_ASSERTION(
+        !mSelection.mFocusCharRects[eNextCharRect].IsEmpty(), "empty rect");
       aUnionTextRect = mSelection.mFocusCharRects[eNextCharRect];
       return !aUnionTextRect.IsEmpty();
     }
     if (mSelection.mFocus && aOffset == mSelection.mFocus - 1) {
-      NS_WARN_IF(mSelection.mFocusCharRects[ePrevCharRect].IsEmpty());
+      NS_WARNING_ASSERTION(
+        !mSelection.mFocusCharRects[ePrevCharRect].IsEmpty(), "empty rect");
       aUnionTextRect = mSelection.mFocusCharRects[ePrevCharRect];
       return !aUnionTextRect.IsEmpty();
     }
   }
 
   // Even if some text rects are not cached of the queried range,
   // we should return union rect when the first character's rect is cached
   // since the first character rect is important and the others are not so
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -59,16 +59,17 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/Move.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimelineConsumers.h"
 #include "mozilla/TimelineMarker.h"
+#include "mozilla/Unused.h"
 #include "mozilla/DebuggerOnGCRunnable.h"
 #include "mozilla/dom/DOMJSClass.h"
 #include "mozilla/dom/ProfileTimelineMarkerBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/PromiseBinding.h"
 #include "mozilla/dom/PromiseDebugging.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "jsprf.h"
@@ -812,20 +813,21 @@ CycleCollectedJSRuntime::GCSliceCallback
                                          JS::GCProgress aProgress,
                                          const JS::GCDescription& aDesc)
 {
   CycleCollectedJSRuntime* self = CycleCollectedJSRuntime::Get();
   MOZ_ASSERT(self->Context() == aContext);
 
   if (aProgress == JS::GC_CYCLE_END) {
     JS::gcreason::Reason reason = aDesc.reason_;
-    NS_WARN_IF(NS_FAILED(DebuggerOnGCRunnable::Enqueue(aContext, aDesc)) &&
-               reason != JS::gcreason::SHUTDOWN_CC &&
-               reason != JS::gcreason::DESTROY_RUNTIME &&
-               reason != JS::gcreason::XPCONNECT_SHUTDOWN);
+    Unused <<
+      NS_WARN_IF(NS_FAILED(DebuggerOnGCRunnable::Enqueue(aContext, aDesc)) &&
+                 reason != JS::gcreason::SHUTDOWN_CC &&
+                 reason != JS::gcreason::DESTROY_RUNTIME &&
+                 reason != JS::gcreason::XPCONNECT_SHUTDOWN);
   }
 
   if (self->mPrevGCSliceCallback) {
     self->mPrevGCSliceCallback(aContext, aProgress, aDesc);
   }
 }
 
 class MinorGCMarker : public TimelineMarker
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1943,17 +1943,17 @@ public:
       d->mType = CCGraphDescriber::eGarbage;
       d->mAddress.AppendInt(aAddress, 16);
     }
   }
   void End()
   {
     if (!mDisableLog) {
       mCCLog = nullptr;
-      NS_WARN_IF(NS_FAILED(mLogSink->CloseCCLog()));
+      Unused << NS_WARN_IF(NS_FAILED(mLogSink->CloseCCLog()));
     }
   }
   NS_IMETHOD ProcessNext(nsICycleCollectorHandler* aHandler,
                          bool* aCanContinue) override
   {
     if (NS_WARN_IF(!aHandler) || NS_WARN_IF(!mWantAfterProcessing)) {
       return NS_ERROR_UNEXPECTED;
     }
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -792,17 +792,17 @@ nsMemoryInfoDumper::OpenDMDFile(const ns
   nsCOMPtr<nsIFile> dmdFile;
   rv = nsDumpUtils::OpenTempFile(dmdFilename,
                                  getter_AddRefs(dmdFile),
                                  NS_LITERAL_CSTRING("memory-reports"));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   rv = dmdFile->OpenANSIFileDesc("wb", aOutFile);
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "OpenANSIFileDesc failed");
 
   // Print the path, because on some platforms (e.g. Mac) it's not obvious.
   nsCString path;
   rv = dmdFile->GetNativePath(path);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   dmd::StatusMsg("opened %s for writing\n", path.get());
@@ -818,13 +818,13 @@ nsMemoryInfoDumper::DumpDMDToFile(FILE* 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Dump DMD's memory reports analysis to the file.
   dmd::Analyze(MakeUnique<GZWriterWrapper>(gzWriter));
 
   rv = gzWriter->Finish();
-  NS_WARN_IF(NS_FAILED(rv));
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Finish failed");
   return rv;
 }
 #endif  // MOZ_DMD
 
--- a/xpcom/glue/nsDebug.h
+++ b/xpcom/glue/nsDebug.h
@@ -19,28 +19,42 @@
 #include "prprf.h"
 #endif
 
 /**
  * Warn if the given condition is true. The condition is evaluated in both
  * release and debug builds, and the result is an expression which can be
  * used in subsequent expressions, such as:
  *
- * if (NS_WARN_IF(NS_FAILED(rv))
+ * if (NS_WARN_IF(NS_FAILED(rv)) {
  *   return rv;
+ * }
  *
  * This explicit warning and return is preferred to the NS_ENSURE_* macros
  * which hide the warning and the return control flow.
  *
+ * This macro can also be used outside of conditions just to issue a warning,
+ * like so:
+ *
+ *   Unused << NS_WARN_IF(NS_FAILED(FnWithSideEffects());
+ *
+ * (The |Unused <<| is necessary because of the MOZ_MUST_USE annotation.)
+ *
+ * However, note that the argument to this macro is evaluated in all builds. If
+ * you just want a warning assertion, it is better to use NS_WARNING_ASSERTION
+ * (which evaluates the condition only in debug builds) like so:
+ *
+ *   NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "operation failed");
+ *
  * @note This is C++-only
  */
 #ifdef __cplusplus
 #ifdef DEBUG
-inline bool NS_warn_if_impl(bool aCondition, const char* aExpr,
-                            const char* aFile, int32_t aLine)
+inline MOZ_MUST_USE bool NS_warn_if_impl(bool aCondition, const char* aExpr,
+                                         const char* aFile, int32_t aLine)
 {
   if (MOZ_UNLIKELY(aCondition)) {
     NS_DebugBreak(NS_DEBUG_WARNING, nullptr, aExpr, aFile, aLine);
   }
   return aCondition;
 }
 #define NS_WARN_IF(condition) \
   NS_warn_if_impl(condition, #condition, __FILE__, __LINE__)