Bug 1288736 - Add some missing rv.SuppressException(), r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 22 Jul 2016 16:50:10 +0200
changeset 331442 bafc5c504506a1795adb94bfe54700fe254b61d6
parent 331441 2e8cfd225f0419a552edc4d9f5942927344eef7c
child 331443 6d5aca780e2d4627974e755cf0fe451ee67a83c4
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1288736
milestone50.0a1
Bug 1288736 - Add some missing rv.SuppressException(), r=smaug
dom/base/BodyUtil.cpp
dom/base/File.cpp
dom/base/nsContentUtils.cpp
dom/base/nsFrameMessageManager.cpp
dom/broadcastchannel/BroadcastChannelChild.cpp
dom/canvas/ImageBitmap.cpp
dom/devicestorage/nsDeviceStorage.cpp
dom/events/BeforeAfterKeyboardEvent.cpp
dom/events/DataTransfer.cpp
dom/filehandle/ActorsParent.cpp
dom/filesystem/FileSystemBase.cpp
dom/filesystem/FileSystemRequestParent.cpp
dom/filesystem/FileSystemTaskBase.cpp
dom/html/HTMLInputElement.cpp
dom/ipc/Blob.cpp
dom/ipc/ContentParent.cpp
dom/ipc/TabChild.cpp
dom/media/webaudio/AudioDestinationNode.cpp
dom/media/webaudio/ScriptProcessorNode.cpp
dom/network/TCPSocketParent.cpp
dom/performance/PerformanceObserver.cpp
dom/telephony/MMICall.cpp
dom/tv/TVTuner.cpp
dom/workers/ScriptLoader.cpp
dom/workers/WorkerPrivate.cpp
dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
embedding/components/windowwatcher/nsAutoWindowStateHelper.cpp
layout/forms/nsFileControlFrame.cpp
--- a/dom/base/BodyUtil.cpp
+++ b/dom/base/BodyUtil.cpp
@@ -319,16 +319,17 @@ private:
         File::CreateMemoryFile(mParentObject,
                                reinterpret_cast<void *>(copy), body.Length(),
                                NS_ConvertUTF8toUTF16(mFilename),
                                NS_ConvertUTF8toUTF16(mContentType), /* aLastModifiedDate */ 0);
       Optional<nsAString> dummy;
       ErrorResult rv;
       mFormData->Append(name, *file, dummy, rv);
       if (NS_WARN_IF(rv.Failed())) {
+        rv.SuppressException();
         return false;
       }
     }
 
     return true;
   }
 
 public:
--- a/dom/base/File.cpp
+++ b/dom/base/File.cpp
@@ -919,17 +919,19 @@ BlobImplFile::GetType(nsAString& aType)
         return;
       }
 
       RefPtr<GetTypeRunnable> runnable =
         new GetTypeRunnable(workerPrivate, this);
 
       ErrorResult rv;
       runnable->Dispatch(rv);
-      NS_WARN_IF(rv.Failed());
+      if (NS_WARN_IF(rv.Failed())) {
+        rv.SuppressException();
+      }
       return;
     }
 
     nsresult rv;
     nsCOMPtr<nsIMIMEService> mimeService =
       do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return;
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -1798,19 +1798,22 @@ nsContentUtils::IsControlledByServiceWor
   }
 
   RefPtr<workers::ServiceWorkerManager> swm =
     workers::ServiceWorkerManager::GetInstance();
   MOZ_ASSERT(swm);
 
   ErrorResult rv;
   bool controlled = swm->IsControlled(aDocument, rv);
-  NS_WARN_IF(rv.Failed());
-
-  return !rv.Failed() && controlled;
+  if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
+    return false;
+  }
+
+  return controlled;
 }
 
 /* static */
 void
 nsContentUtils::GetOfflineAppManifest(nsIDocument *aDocument, nsIURI **aURI)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aDocument);
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -787,16 +787,17 @@ nsFrameMessageManager::SendMessage(const
   NS_ENSURE_TRUE(dataArray, NS_ERROR_OUT_OF_MEMORY);
 
   for (uint32_t i = 0; i < len; ++i) {
     JS::Rooted<JS::Value> ret(aCx);
     ErrorResult rv;
     retval[i].Read(aCx, &ret, rv);
     if (rv.Failed()) {
       MOZ_ASSERT(false, "Unable to read structured clone in SendMessage");
+      rv.SuppressException();
       return NS_ERROR_UNEXPECTED;
     }
 
     NS_ENSURE_TRUE(JS_DefineElement(aCx, dataArray, i, ret, JSPROP_ENUMERATE),
                    NS_ERROR_OUT_OF_MEMORY);
   }
 
   aRetval.setObject(*dataArray);
--- a/dom/broadcastchannel/BroadcastChannelChild.cpp
+++ b/dom/broadcastchannel/BroadcastChannelChild.cpp
@@ -94,31 +94,32 @@ BroadcastChannelChild::RecvNotify(const 
   cloneData.UseExternalData(buffer.data, buffer.dataLength);
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> value(cx, JS::NullValue());
   if (buffer.dataLength) {
     ErrorResult rv;
     cloneData.Read(cx, &value, rv);
     if (NS_WARN_IF(rv.Failed())) {
+      rv.SuppressException();
       return true;
     }
   }
 
   RootedDictionary<MessageEventInit> init(cx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mOrigin.Construct(mOrigin);
   init.mData = value;
 
   ErrorResult rv;
   RefPtr<MessageEvent> event =
     MessageEvent::Constructor(mBC, NS_LITERAL_STRING("message"), init, rv);
-  if (rv.Failed()) {
-    NS_WARNING("Failed to create a MessageEvent object.");
+  if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return true;
   }
 
   event->SetTrusted(true);
 
   bool status;
   mBC->DispatchEvent(static_cast<Event*>(event.get()), &status);
 
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -86,16 +86,17 @@ static already_AddRefed<DataSourceSurfac
 CropAndCopyDataSourceSurface(DataSourceSurface* aSurface, const IntRect& aCropRect)
 {
   MOZ_ASSERT(aSurface);
 
   // Check the aCropRect
   ErrorResult error;
   const IntRect positiveCropRect = FixUpNegativeDimension(aCropRect, error);
   if (NS_WARN_IF(error.Failed())) {
+    error.SuppressException();
     return nullptr;
   }
 
   // Calculate the size of the new SourceSurface.
   // We cannot keep using aSurface->GetFormat() to create new DataSourceSurface,
   // since it might be SurfaceFormat::B8G8R8X8 which does not handle opacity,
   // however the specification explicitly define that "If any of the pixels on
   // this rectangle are outside the area where the input bitmap was placed, then
@@ -1101,16 +1102,17 @@ AsyncFulfillImageBitmapPromise(Promise* 
 static already_AddRefed<SourceSurface>
 DecodeBlob(Blob& aBlob)
 {
   // Get the internal stream of the blob.
   nsCOMPtr<nsIInputStream> stream;
   ErrorResult error;
   aBlob.Impl()->GetInternalStream(getter_AddRefs(stream), error);
   if (NS_WARN_IF(error.Failed())) {
+    error.SuppressException();
     return nullptr;
   }
 
   // Get the MIME type string of the blob.
   // The type will be checked in the DecodeImage() method.
   nsAutoString mimeTypeUTF16;
   aBlob.GetType(mimeTypeUTF16);
 
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -1953,16 +1953,17 @@ public:
   }
 
   NS_IMETHOD Run() override
   {
     ErrorResult rv;
     nsCOMPtr<nsIInputStream> stream;
     mBlob->GetInternalStream(getter_AddRefs(stream), rv);
     if (NS_WARN_IF(rv.Failed())) {
+      rv.SuppressException();
       return Reject(POST_ERROR_EVENT_UNKNOWN);
     }
 
     bool check = false;
     mFile->mFile->Exists(&check);
     if (check) {
       return Reject(POST_ERROR_EVENT_FILE_EXISTS);
     }
@@ -2065,16 +2066,17 @@ public:
   }
 
   NS_IMETHOD Run() override
   {
     ErrorResult rv;
     nsCOMPtr<nsIInputStream> stream;
     mBlob->GetInternalStream(getter_AddRefs(stream), rv);
     if (NS_WARN_IF(rv.Failed())) {
+      rv.SuppressException();
       return Reject(POST_ERROR_EVENT_UNKNOWN);
     }
 
     bool check = false;
     mFile->mFile->Exists(&check);
     if (!check) {
       return Reject(POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
     }
--- a/dom/events/BeforeAfterKeyboardEvent.cpp
+++ b/dom/events/BeforeAfterKeyboardEvent.cpp
@@ -36,17 +36,19 @@ BeforeAfterKeyboardEvent::Constructor(
                             EventTarget* aOwner,
                             const nsAString& aType,
                             const BeforeAfterKeyboardEventInit& aParam)
 {
   RefPtr<BeforeAfterKeyboardEvent> event =
     new BeforeAfterKeyboardEvent(aOwner, nullptr, nullptr);
   ErrorResult rv;
   event->InitWithKeyboardEventInit(aOwner, aType, aParam, rv);
-  NS_WARN_IF(rv.Failed());
+  if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
+  }
 
   event->mEvent->AsBeforeAfterKeyboardEvent()->mEmbeddedCancelled =
     aParam.mEmbeddedCancelled;
 
   return event.forget();
 }
 
 // static
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -1281,17 +1281,19 @@ DataTransfer::SetDataWithPrincipalFromOt
   } else {
     nsAutoString format;
     GetRealFormat(aFormat, format);
 
     ErrorResult rv;
     RefPtr<DataTransferItem> item =
       mItems->SetDataWithPrincipal(format, aData, aIndex, aPrincipal,
                                    /* aInsertOnly = */ false, aHidden, rv);
-    NS_WARN_IF(rv.Failed());
+    if (NS_WARN_IF(rv.Failed())) {
+      rv.SuppressException();
+    }
   }
 }
 
 void
 DataTransfer::GetRealFormat(const nsAString& aInFormat,
                             nsAString& aOutFormat) const
 {
   // treat text/unicode as equivalent to text/plain
--- a/dom/filehandle/ActorsParent.cpp
+++ b/dom/filehandle/ActorsParent.cpp
@@ -2531,16 +2531,17 @@ WriteOp::Init(FileHandle* aFileHandle)
 
       auto blobActor = static_cast<BlobParent*>(blobData.blobParent());
 
       RefPtr<BlobImpl> blobImpl = blobActor->GetBlobImpl();
 
       ErrorResult rv;
       blobImpl->GetInternalStream(getter_AddRefs(inputStream), rv);
       if (NS_WARN_IF(rv.Failed())) {
+        rv.SuppressException();
         return false;
       }
 
       break;
     }
 
     default:
       MOZ_CRASH("Should never get here!");
--- a/dom/filesystem/FileSystemBase.cpp
+++ b/dom/filesystem/FileSystemBase.cpp
@@ -79,22 +79,24 @@ FileSystemBase::GetRealPath(BlobImpl* aF
   AssertIsOnOwningThread();
   MOZ_ASSERT(aFile, "aFile Should not be null.");
   MOZ_ASSERT(aPath);
 
   nsAutoString filePath;
   ErrorResult rv;
   aFile->GetMozFullPathInternal(filePath, rv);
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return false;
   }
 
   rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(filePath),
                              true, aPath);
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return false;
   }
 
   return true;
 }
 
 bool
 FileSystemBase::IsSafeFile(nsIFile* aFile) const
--- a/dom/filesystem/FileSystemRequestParent.cpp
+++ b/dom/filesystem/FileSystemRequestParent.cpp
@@ -30,16 +30,17 @@ FileSystemRequestParent::~FileSystemRequ
 
 #define FILESYSTEM_REQUEST_PARENT_DISPATCH_ENTRY(name)                         \
     case FileSystemParams::TFileSystem##name##Params: {                        \
       const FileSystem##name##Params& p = aParams;                             \
       mFileSystem = FileSystemBase::DeserializeDOMPath(p.filesystem());        \
       MOZ_ASSERT(mFileSystem);                                                 \
       mTask = name##TaskParent::Create(mFileSystem, p, this, rv);              \
       if (NS_WARN_IF(rv.Failed())) {                                           \
+        rv.SuppressException();                                                \
         return false;                                                          \
       }                                                                        \
       break;                                                                   \
     }
 
 bool
 FileSystemRequestParent::Initialize(const FileSystemParams& aParams)
 {
--- a/dom/filesystem/FileSystemTaskBase.cpp
+++ b/dom/filesystem/FileSystemTaskBase.cpp
@@ -145,16 +145,17 @@ FileSystemTaskChildBase::Start()
   }
 
   nsAutoString serialization;
   mFileSystem->SerializeDOMPath(serialization);
 
   ErrorResult rv;
   FileSystemParams params = GetRequestParams(serialization, rv);
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return;
   }
 
   // Retain a reference so the task object isn't deleted without IPDL's
   // knowledge. The reference will be released by
   // mozilla::ipc::BackgroundChildImpl::DeallocPFileSystemRequestChild.
   NS_ADDREF_THIS();
 
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -503,17 +503,19 @@ GetDOMFileOrDirectoryName(const OwningFi
                           nsAString& aName)
 {
   if (aData.IsFile()) {
     aData.GetAsFile()->GetName(aName);
   } else {
     MOZ_ASSERT(aData.IsDirectory());
     ErrorResult rv;
     aData.GetAsDirectory()->GetName(aName, rv);
-    NS_WARN_IF(rv.Failed());
+    if (NS_WARN_IF(rv.Failed())) {
+      rv.SuppressException();
+    }
   }
 }
 
 void
 GetDOMFileOrDirectoryPath(const OwningFileOrDirectory& aData,
                           nsAString& aPath,
                           ErrorResult& aRv)
 {
--- a/dom/ipc/Blob.cpp
+++ b/dom/ipc/Blob.cpp
@@ -854,16 +854,17 @@ CreateBlobImpl(const nsTArray<BlobData>&
   if (!hasRecursed && aMetadata.IsFile()) {
     blobImpl = MultipartBlobImpl::Create(blobImpls, aMetadata.mName,
                                          aMetadata.mContentType, rv);
   } else {
     blobImpl = MultipartBlobImpl::Create(blobImpls, aMetadata.mContentType, rv);
   }
 
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return nullptr;
   }
 
   MOZ_ALWAYS_SUCCEEDS(blobImpl->SetMutable(false));
 
   return blobImpl.forget();
 }
 
@@ -4389,16 +4390,17 @@ BlobParent::RecvGetFilePath(nsString* aF
   MOZ_ASSERT(mOwnsBlobImpl);
 
   // In desktop e10s the file picker code sends this message.
 
   nsString filePath;
   ErrorResult rv;
   mBlobImpl->GetMozFullPathInternal(filePath, rv);
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return false;
   }
 
   *aFilePath = filePath;
   return true;
 }
 
 /*******************************************************************************
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3330,16 +3330,17 @@ ContentParent::RecvGetXPCOMProcessAttrib
     nsresult result = mm->GetInitialProcessData(jsapi.cx(), &init);
     if (NS_FAILED(result)) {
       return false;
     }
 
     ErrorResult rv;
     aInitialData->Write(jsapi.cx(), init, rv);
     if (NS_WARN_IF(rv.Failed())) {
+      rv.SuppressException();
       return false;
     }
   }
 
   return true;
 }
 
 mozilla::jsipc::PJavaScriptParent *
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -215,16 +215,17 @@ TabChildBase::DispatchMessageManagerMess
     StructuredCloneData data;
     if (JS_ParseJSON(cx,
                       static_cast<const char16_t*>(aJSONData.BeginReading()),
                       aJSONData.Length(),
                       &json)) {
         ErrorResult rv;
         data.Write(cx, json, rv);
         if (NS_WARN_IF(rv.Failed())) {
+            rv.SuppressException();
             return;
         }
     }
 
     nsCOMPtr<nsIXPConnectJSObjectHolder> kungFuDeathGrip(GetGlobal());
     // Let the BrowserElementScrolling helper (if it exists) for this
     // content manipulate the frame state.
     RefPtr<nsFrameMessageManager> mm =
--- a/dom/media/webaudio/AudioDestinationNode.cpp
+++ b/dom/media/webaudio/AudioDestinationNode.cpp
@@ -152,16 +152,17 @@ public:
     // AudioDestinationNode::FireOfflineCompletionEvent.
 
     // Create the input buffer
     ErrorResult rv;
     RefPtr<AudioBuffer> renderedBuffer =
       AudioBuffer::Create(context, mNumberOfChannels, mLength, mSampleRate,
                           mBuffer.forget(), rv);
     if (rv.Failed()) {
+      rv.SuppressException();
       return;
     }
 
     aNode->ResolvePromise(renderedBuffer);
 
     RefPtr<OnCompleteTask> onCompleteTask =
       new OnCompleteTask(context, renderedBuffer);
     NS_DispatchToMainThread(onCompleteTask);
--- a/dom/media/webaudio/ScriptProcessorNode.cpp
+++ b/dom/media/webaudio/ScriptProcessorNode.cpp
@@ -427,16 +427,17 @@ private:
         RefPtr<AudioBuffer> inputBuffer;
         if (mInputBuffer) {
           ErrorResult rv;
           inputBuffer =
             AudioBuffer::Create(context, inputChannelCount,
                                 aNode->BufferSize(), context->SampleRate(),
                                 mInputBuffer.forget(), rv);
           if (rv.Failed()) {
+            rv.SuppressException();
             return nullptr;
           }
         }
 
         // Ask content to produce data in the output buffer
         // Note that we always avoid creating the output buffer here, and we try to
         // avoid creating the input buffer as well.  The AudioProcessingEvent class
         // knows how to lazily create them if needed once the script tries to access
--- a/dom/network/TCPSocketParent.cpp
+++ b/dom/network/TCPSocketParent.cpp
@@ -269,17 +269,20 @@ TCPSocketParent::RecvOpenBind(const nsCS
 }
 
 bool
 TCPSocketParent::RecvStartTLS()
 {
   NS_ENSURE_TRUE(mSocket, true);
   ErrorResult rv;
   mSocket->UpgradeToSecure(rv);
-  NS_ENSURE_FALSE(rv.Failed(), true);
+  if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
+  }
+
   return true;
 }
 
 bool
 TCPSocketParent::RecvSuspend()
 {
   NS_ENSURE_TRUE(mSocket, true);
   mSocket->Suspend();
@@ -287,17 +290,20 @@ TCPSocketParent::RecvSuspend()
 }
 
 bool
 TCPSocketParent::RecvResume()
 {
   NS_ENSURE_TRUE(mSocket, true);
   ErrorResult rv;
   mSocket->Resume(rv);
-  NS_ENSURE_FALSE(rv.Failed(), true);
+  if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
+  }
+
   return true;
 }
 
 bool
 TCPSocketParent::RecvData(const SendableData& aData,
                           const uint32_t& aTrackingNumber)
 {
   ErrorResult rv;
--- a/dom/performance/PerformanceObserver.cpp
+++ b/dom/performance/PerformanceObserver.cpp
@@ -111,17 +111,19 @@ PerformanceObserver::Notify()
   if (mQueuedEntries.IsEmpty()) {
     return;
   }
   RefPtr<PerformanceObserverEntryList> list =
     new PerformanceObserverEntryList(this, mQueuedEntries);
 
   ErrorResult rv;
   mCallback->Call(this, *list, *this, rv);
-  NS_WARN_IF(rv.Failed());
+  if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
+  }
   mQueuedEntries.Clear();
 }
 
 void
 PerformanceObserver::QueueEntry(PerformanceEntry* aEntry)
 {
   MOZ_ASSERT(aEntry);
 
--- a/dom/telephony/MMICall.cpp
+++ b/dom/telephony/MMICall.cpp
@@ -26,16 +26,17 @@ MMICall::MMICall(nsPIDOMWindowInner* aWi
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
   if (!global) {
     return;
   }
 
   ErrorResult rv;
   RefPtr<Promise> promise = Promise::Create(global, rv);
   if (rv.Failed()) {
+    rv.SuppressException();
     return;
   }
 
   mPromise = promise;
 }
 
 MMICall::~MMICall()
 {
--- a/dom/tv/TVTuner.cpp
+++ b/dom/tv/TVTuner.cpp
@@ -233,36 +233,39 @@ TVTuner::CreateSimulatedMediaStream()
   if (NS_WARN_IF(!doc)) {
     return nullptr;
   }
 
   ErrorResult error;
   ElementCreationOptions options;
   RefPtr<Element> element = doc->CreateElement(VIDEO_TAG, options, error);
   if (NS_WARN_IF(error.Failed())) {
+    error.SuppressException();
     return nullptr;
   }
 
   nsCOMPtr<nsIContent> content(do_QueryInterface(element));
   if (NS_WARN_IF(!content)) {
     return nullptr;
   }
 
   HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(content.get());
   if (NS_WARN_IF(!mediaElement)) {
     return nullptr;
   }
 
   mediaElement->SetAutoplay(true, error);
   if (NS_WARN_IF(error.Failed())) {
+    error.SuppressException();
     return nullptr;
   }
 
   mediaElement->SetLoop(true, error);
   if (NS_WARN_IF(error.Failed())) {
+    error.SuppressException();
     return nullptr;
   }
 
   nsCOMPtr<nsITVSimulatorService> simService(do_QueryInterface(mTVService));
   if (NS_WARN_IF(!simService)) {
     return nullptr;
   }
 
@@ -288,23 +291,25 @@ TVTuner::CreateSimulatedMediaStream()
                                                      domWin,
                                                      currentVideoBlobUrl);
   if (NS_WARN_IF(NS_FAILED(rv) || currentVideoBlobUrl.IsEmpty())) {
     return nullptr;
   }
 
   mediaElement->SetSrc(currentVideoBlobUrl, error);
   if (NS_WARN_IF(error.Failed())) {
+    error.SuppressException();
     return nullptr;
   }
 
   // See Media Capture from DOM Elements spec.
   // http://www.w3.org/TR/mediacapture-fromelement/
   RefPtr<DOMMediaStream> stream = mediaElement->MozCaptureStream(error);
   if (NS_WARN_IF(error.Failed())) {
+    error.SuppressException();
     return nullptr;
   }
 
   return stream.forget();
 }
 
 nsresult
 TVTuner::DispatchCurrentSourceChangedEvent(TVSource* aSource)
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -1560,16 +1560,17 @@ CacheCreator::DeleteCache()
   AssertIsOnMainThread();
 
   ErrorResult rv;
 
   // It's safe to do this while Cache::Match() and Cache::Put() calls are
   // running.
   RefPtr<Promise> promise = mCacheStorage->Delete(mCacheName, rv);
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return;
   }
 
   // We don't care to know the result of the promise object.
   FailLoaders(NS_ERROR_FAILURE);
 }
 
 void
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -755,16 +755,17 @@ public:
       init.mData = messageData;
       init.mPorts.Construct();
       init.mPorts.Value().SetNull();
 
       ErrorResult rv;
       RefPtr<ExtendableMessageEvent> event = ExtendableMessageEvent::Constructor(
         aTarget, NS_LITERAL_STRING("message"), init, rv);
       if (NS_WARN_IF(rv.Failed())) {
+        rv.SuppressException();
         return false;
       }
       event->SetSource(client);
       event->SetPorts(new MessagePortList(static_cast<dom::Event*>(event.get()),
                                           ports));
       domEvent = do_QueryObject(event);
     } else {
       RefPtr<MessageEvent> event = new MessageEvent(aTarget, nullptr, nullptr);
@@ -6566,16 +6567,17 @@ WorkerPrivate::ConnectMessagePort(JSCont
   JS::Rooted<JSObject*> jsGlobal(aCx, globalScope->GetWrapper());
   MOZ_ASSERT(jsGlobal);
 
   // This MessagePortIdentifier is used to create a new port, still connected
   // with the other one, but in the worker thread.
   ErrorResult rv;
   RefPtr<MessagePort> port = MessagePort::Create(globalScope, aIdentifier, rv);
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return false;
   }
 
   GlobalObject globalObject(aCx, jsGlobal);
   if (globalObject.Failed()) {
     return false;
   }
 
--- a/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
@@ -40,17 +40,23 @@ NS_IMPL_ISUPPORTS(nsXULTemplateResultSet
 
 NS_IMETHODIMP
 nsXULTemplateResultSetXML::HasMoreElements(bool *aResult)
 {
     // if GetSnapshotLength failed, then the return type was not a set of
     // nodes, so just return false in this case.
     ErrorResult rv;
     uint32_t length = mResults->GetSnapshotLength(rv);
-    *aResult = !rv.Failed() && mPosition < length;
+    if (NS_WARN_IF(rv.Failed())) {
+      rv.SuppressException();
+      *aResult = false;
+      return NS_OK;
+    }
+
+    *aResult = mPosition < length;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXULTemplateResultSetXML::GetNext(nsISupports **aResult)
 {
     ErrorResult rv;
     nsINode* node = mResults->SnapshotItem(mPosition, rv);
--- a/embedding/components/windowwatcher/nsAutoWindowStateHelper.cpp
+++ b/embedding/components/windowwatcher/nsAutoWindowStateHelper.cpp
@@ -54,16 +54,17 @@ nsAutoWindowStateHelper::DispatchEventTo
   nsIDocument* doc = mWindow->GetExtantDoc();
   if (!doc) {
     return true;
   }
 
   ErrorResult rv;
   RefPtr<Event> event = doc->CreateEvent(NS_LITERAL_STRING("Events"), rv);
   if (rv.Failed()) {
+    rv.SuppressException();
     return false;
   }
   event->InitEvent(NS_ConvertASCIItoUTF16(aEventName), true, true);
   event->SetTrusted(true);
   event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
 
   nsCOMPtr<EventTarget> target = do_QueryInterface(mWindow);
   bool defaultActionEnabled;
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -262,16 +262,17 @@ nsFileControlFrame::DnDListener::IsValid
 {
   nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(aDOMDataTransfer);
   NS_ENSURE_TRUE(dataTransfer, false);
 
   // We only support dropping files onto a file upload control
   ErrorResult rv;
   RefPtr<DOMStringList> types = dataTransfer->GetTypes(rv);
   if (NS_WARN_IF(rv.Failed())) {
+    rv.SuppressException();
     return false;
   }
 
   return types->Contains(NS_LITERAL_STRING("Files"));
 }
 
 /* static */ bool
 nsFileControlFrame::DnDListener::CanDropTheseFiles(nsIDOMDataTransfer* aDOMDataTransfer,