Bug 1157898 part 1. Make code of the form "return rv.ErrorCode();" where rv is an ErrorResult use StealNSResult instead. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 27 Apr 2015 09:18:51 -0400
changeset 241196 ca1ae21cc8e0bac03349cf7a1c7b3979fb60c3f3
parent 241195 c5bada9c3efe6713cf60397b5e26aa5255eea96a
child 241197 29bac3547929ef55f7ff9867a85310928f507ffa
push id59043
push userbzbarsky@mozilla.com
push dateMon, 27 Apr 2015 13:19:08 +0000
treeherdermozilla-inbound@6ba4bb455c23 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1157898
milestone40.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 1157898 part 1. Make code of the form "return rv.ErrorCode();" where rv is an ErrorResult use StealNSResult instead. r=peterv This patch was generated with the following command: find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 's/return ([a-zA-Z0-9]+)\.ErrorCode\(\);/return \1.StealNSResult();/'
dom/archivereader/ArchiveReader.cpp
dom/archivereader/ArchiveZipFile.cpp
dom/base/Attr.cpp
dom/base/DOMCursor.cpp
dom/base/DOMImplementation.cpp
dom/base/DocumentType.cpp
dom/base/Element.cpp
dom/base/Element.h
dom/base/File.cpp
dom/base/NodeIterator.h
dom/base/TreeWalker.cpp
dom/base/TreeWalker.h
dom/base/nsContentUtils.cpp
dom/base/nsDOMAttributeMap.cpp
dom/base/nsDOMFileReader.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsDocument.cpp
dom/base/nsGenericDOMDataNode.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsHostObjectProtocolHandler.cpp
dom/base/nsINode.cpp
dom/base/nsINode.h
dom/base/nsImageLoadingContent.cpp
dom/base/nsJSTimeoutHandler.cpp
dom/base/nsRange.cpp
dom/base/nsScreen.cpp
dom/base/nsXMLHttpRequest.cpp
dom/cache/DBSchema.cpp
dom/datastore/DataStoreDB.cpp
dom/datastore/DataStoreRevision.cpp
dom/datastore/DataStoreService.cpp
dom/devicestorage/nsDeviceStorage.cpp
dom/events/ClipboardEvent.cpp
dom/events/DataTransfer.cpp
dom/events/JSEventHandler.cpp
dom/events/MessageEvent.cpp
dom/fetch/FetchDriver.cpp
dom/filehandle/FileHandle.cpp
dom/html/HTMLBodyElement.cpp
dom/html/HTMLCanvasElement.cpp
dom/html/HTMLFormElement.cpp
dom/html/HTMLFrameSetElement.cpp
dom/html/HTMLImageElement.cpp
dom/html/HTMLInputElement.cpp
dom/html/HTMLLabelElement.cpp
dom/html/HTMLMediaElement.cpp
dom/html/HTMLOptionsCollection.cpp
dom/html/HTMLScriptElement.cpp
dom/html/HTMLSelectElement.cpp
dom/html/HTMLTableCellElement.cpp
dom/html/HTMLTextAreaElement.cpp
dom/html/ImageDocument.cpp
dom/html/TimeRanges.cpp
dom/html/nsGenericHTMLElement.cpp
dom/html/nsGenericHTMLElement.h
dom/html/nsHTMLDocument.cpp
dom/inputport/InputPortManager.cpp
dom/ipc/Blob.cpp
dom/network/UDPSocket.cpp
dom/notification/Notification.cpp
dom/offline/nsDOMOfflineResourceList.cpp
dom/power/PowerManagerService.cpp
dom/svg/DOMSVGLength.cpp
dom/system/gonk/nsVolumeMountLock.cpp
dom/workers/ScriptLoader.cpp
dom/workers/ServiceWorkerClient.cpp
dom/workers/ServiceWorkerManager.cpp
dom/workers/ServiceWorkerScriptCache.cpp
dom/workers/XMLHttpRequest.cpp
dom/xml/XMLDocument.cpp
dom/xslt/xpath/XPathEvaluator.cpp
dom/xul/XULDocument.cpp
dom/xul/nsXULElement.cpp
dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
editor/libeditor/CreateElementTxn.cpp
editor/libeditor/DeleteNodeTxn.cpp
editor/libeditor/InsertNodeTxn.cpp
editor/libeditor/JoinNodeTxn.cpp
editor/libeditor/SplitNodeTxn.cpp
editor/libeditor/nsEditor.cpp
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/nsHTMLEditor.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
layout/generic/nsSelection.cpp
layout/inspector/inDOMUtils.cpp
layout/style/CSSStyleSheet.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsICSSDeclaration.h
layout/style/nsROCSSPrimitiveValue.cpp
xpfe/appshell/nsContentTreeOwner.cpp
--- a/dom/archivereader/ArchiveReader.cpp
+++ b/dom/archivereader/ArchiveReader.cpp
@@ -100,17 +100,17 @@ ArchiveReader::GetInputStream(nsIInputSt
   return NS_OK;
 }
 
 nsresult
 ArchiveReader::GetSize(uint64_t* aSize)
 {
   ErrorResult rv;
   *aSize = mFileImpl->GetSize(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 // Here we open the archive:
 nsresult
 ArchiveReader::OpenArchive()
 {
   mStatus = WORKING;
   nsresult rv;
--- a/dom/archivereader/ArchiveZipFile.cpp
+++ b/dom/archivereader/ArchiveZipFile.cpp
@@ -360,17 +360,17 @@ ArchiveZipFileImpl::GetInternalStream(ns
 {
   if (mLength > INT32_MAX) {
     return NS_ERROR_FAILURE;
   }
 
   ErrorResult rv;
   uint64_t size = mFileImpl->GetSize(rv);
   if (NS_WARN_IF(rv.Failed())) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   nsCOMPtr<nsIInputStream> inputStream;
   rv = mFileImpl->GetInternalStream(getter_AddRefs(inputStream));
   if (NS_WARN_IF(rv.Failed()) || !inputStream) {
     return NS_ERROR_UNEXPECTED;
   }
 
--- a/dom/base/Attr.cpp
+++ b/dom/base/Attr.cpp
@@ -210,17 +210,17 @@ Attr::SetValue(const nsAString& aValue, 
                          true);
 }
 
 NS_IMETHODIMP
 Attr::SetValue(const nsAString& aValue)
 {
   ErrorResult rv;
   SetValue(aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 Attr::Specified() const
 {
   return true;
 }
 
--- a/dom/base/DOMCursor.cpp
+++ b/dom/base/DOMCursor.cpp
@@ -52,17 +52,17 @@ DOMCursor::GetDone(bool *aDone)
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DOMCursor::Continue()
 {
   ErrorResult rv;
   Continue(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DOMCursor::Continue(ErrorResult& aRv)
 {
   MOZ_ASSERT(mCallback, "If you're creating your own cursor class with no callback, you should override Continue()");
 
   // We need to have a result here because we must be in a 'success' state.
--- a/dom/base/DOMImplementation.cpp
+++ b/dom/base/DOMImplementation.cpp
@@ -85,17 +85,17 @@ NS_IMETHODIMP
 DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
                                       const nsAString& aPublicId,
                                       const nsAString& aSystemId,
                                       nsIDOMDocumentType** aReturn)
 {
   ErrorResult rv;
   *aReturn =
     CreateDocumentType(aQualifiedName, aPublicId, aSystemId, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsresult
 DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
                                   const nsAString& aQualifiedName,
                                   nsIDOMDocumentType* aDoctype,
                                   nsIDocument** aDocument,
                                   nsIDOMDocument** aDOMDocument)
--- a/dom/base/DocumentType.cpp
+++ b/dom/base/DocumentType.cpp
@@ -24,17 +24,17 @@ NS_NewDOMDocumentType(nsIDOMDocumentType
                       const nsAString& aPublicId,
                       const nsAString& aSystemId,
                       const nsAString& aInternalSubset)
 {
   NS_ENSURE_ARG_POINTER(aDocType);
   mozilla::ErrorResult rv;
   *aDocType = NS_NewDOMDocumentType(aNodeInfoManager, aName, aPublicId,
                                     aSystemId, aInternalSubset, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<mozilla::dom::DocumentType>
 NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
                       nsIAtom *aName,
                       const nsAString& aPublicId,
                       const nsAString& aSystemId,
                       const nsAString& aInternalSubset,
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1351,17 +1351,17 @@ nsresult
 Element::GetElementsByTagNameNS(const nsAString& namespaceURI,
                                 const nsAString& localName,
                                 nsIDOMHTMLCollection** aResult)
 {
   mozilla::ErrorResult rv;
   nsCOMPtr<nsIHTMLCollection> list =
     GetElementsByTagNameNS(namespaceURI, localName, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   list.forget(aResult);
   return NS_OK;
 }
 
 bool
 Element::HasAttributeNS(const nsAString& aNamespaceURI,
                         const nsAString& aLocalName) const
@@ -3004,17 +3004,17 @@ Element::GetTokenList(nsIAtom* aAtom, ns
 nsresult
 Element::SetTokenList(nsIAtom* aAtom, nsIVariant* aValue)
 {
   nsDOMSettableTokenList* itemType = GetTokenList(aAtom);
   nsAutoString string;
   aValue->GetAsAString(string);
   ErrorResult rv;
   itemType->SetValue(string, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 Element*
 Element::Closest(const nsAString& aSelector, ErrorResult& aResult)
 {
   nsCSSSelectorList* selectorList = ParseSelectorList(aSelector, aResult);
   if (!selectorList) {
     // Either we failed (and aResult already has the exception), or this
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1513,39 +1513,39 @@ NS_IMETHOD GetAttributeNS(const nsAStrin
   Element::GetAttributeNS(namespaceURI, localName, _retval);                  \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD SetAttribute(const nsAString& name,                                \
                         const nsAString& value) override                      \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   Element::SetAttribute(name, value, rv);                                     \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                  \
 }                                                                             \
 NS_IMETHOD SetAttributeNS(const nsAString& namespaceURI,                      \
                           const nsAString& qualifiedName,                     \
                           const nsAString& value) final override              \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   Element::SetAttributeNS(namespaceURI, qualifiedName, value, rv);            \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 using Element::RemoveAttribute;                                               \
 NS_IMETHOD RemoveAttribute(const nsAString& name) final override              \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   RemoveAttribute(name, rv);                                                  \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 NS_IMETHOD RemoveAttributeNS(const nsAString& namespaceURI,                   \
                              const nsAString& localName) final override       \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   Element::RemoveAttributeNS(namespaceURI, localName, rv);                    \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 using Element::HasAttribute;                                                  \
 NS_IMETHOD HasAttribute(const nsAString& name,                                \
                            bool* _retval) final override                      \
 {                                                                             \
   *_retval = HasAttribute(name);                                              \
   return NS_OK;                                                               \
 }                                                                             \
@@ -1571,44 +1571,44 @@ NS_IMETHOD SetAttributeNode(nsIDOMAttr* 
                             nsIDOMAttr** _retval) final override              \
 {                                                                             \
   if (!newAttr) {                                                             \
     return NS_ERROR_INVALID_POINTER;                                          \
   }                                                                           \
   mozilla::ErrorResult rv;                                                    \
   mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(newAttr);       \
   *_retval = Element::SetAttributeNode(*attr, rv).take();                     \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* oldAttr,                           \
                                nsIDOMAttr** _retval) final override           \
 {                                                                             \
   if (!oldAttr) {                                                             \
     return NS_ERROR_INVALID_POINTER;                                          \
   }                                                                           \
   mozilla::ErrorResult rv;                                                    \
   mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(oldAttr);       \
   *_retval = Element::RemoveAttributeNode(*attr, rv).take();                  \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 NS_IMETHOD GetAttributeNodeNS(const nsAString& namespaceURI,                  \
                               const nsAString& localName,                     \
                               nsIDOMAttr** _retval) final override            \
 {                                                                             \
   NS_IF_ADDREF(*_retval = Element::GetAttributeNodeNS(namespaceURI,           \
                                                       localName));            \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD SetAttributeNodeNS(nsIDOMAttr* newAttr,                            \
                               nsIDOMAttr** _retval) final override            \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(newAttr);       \
   *_retval = Element::SetAttributeNodeNS(*attr, rv).take();                   \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 NS_IMETHOD GetElementsByTagName(const nsAString& name,                        \
                                 nsIDOMHTMLCollection** _retval) final         \
                                                                 override      \
 {                                                                             \
   Element::GetElementsByTagName(name, _retval);                               \
   return NS_OK;                                                               \
 }                                                                             \
@@ -1751,33 +1751,33 @@ NS_IMETHOD GetScrollTopMax(int32_t* aScr
   *aScrollTopMax = Element::ScrollTopMax();                                   \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD MozMatchesSelector(const nsAString& selector,                      \
                               bool* _retval) final override                   \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   *_retval = Element::MozMatchesSelector(selector, rv);                       \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 NS_IMETHOD SetCapture(bool retargetToElement) final override                  \
 {                                                                             \
   Element::SetCapture(retargetToElement);                                     \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD ReleaseCapture(void) final override                                \
 {                                                                             \
   Element::ReleaseCapture();                                                  \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD MozRequestFullScreen(void) final override                          \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   Element::MozRequestFullScreen(nullptr, JS::UndefinedHandleValue, rv);       \
-  return rv.ErrorCode();                                                      \
+  return rv.StealNSResult();                                                      \
 }                                                                             \
 NS_IMETHOD MozRequestPointerLock(void) final override                         \
 {                                                                             \
   Element::MozRequestPointerLock();                                           \
   return NS_OK;                                                               \
 }                                                                             \
 using nsINode::QuerySelector;                                                 \
 NS_IMETHOD QuerySelector(const nsAString& aSelector,                          \
--- a/dom/base/File.cpp
+++ b/dom/base/File.cpp
@@ -342,17 +342,17 @@ File::GetPath(nsAString& aPath)
 
 NS_IMETHODIMP
 File::GetLastModifiedDate(JSContext* aCx,
                           JS::MutableHandle<JS::Value> aDate)
 {
   ErrorResult rv;
   Date value = GetLastModifiedDate(rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   if (!value.ToDateObject(aCx, aDate)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
@@ -374,41 +374,41 @@ File::GetLastModified(ErrorResult& aRv)
   return mImpl->GetLastModified(aRv);
 }
 
 NS_IMETHODIMP
 File::GetMozFullPath(nsAString& aFileName)
 {
   ErrorResult rv;
   GetMozFullPath(aFileName, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 File::GetMozFullPath(nsAString& aFilename, ErrorResult& aRv)
 {
   mImpl->GetMozFullPath(aFilename, aRv);
 }
 
 NS_IMETHODIMP
 File::GetMozFullPathInternal(nsAString& aFileName)
 {
   ErrorResult rv;
   mImpl->GetMozFullPathInternal(aFileName, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 File::GetSize(uint64_t* aSize)
 {
   MOZ_ASSERT(aSize);
 
   ErrorResult rv;
   *aSize = GetSize(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 uint64_t
 File::GetSize(ErrorResult& aRv)
 {
   return mImpl->GetSize(aRv);
 }
 
@@ -421,17 +421,17 @@ File::GetType(nsAString &aType)
 
 NS_IMETHODIMP
 File::GetMozLastModifiedDate(int64_t* aDate)
 {
   MOZ_ASSERT(aDate);
 
   ErrorResult rv;
   *aDate = GetLastModified(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 // Makes sure that aStart and aEnd is less then or equal to aSize and greater
 // than 0
 static void
 ParseSize(int64_t aSize, int64_t& aStart, int64_t& aEnd)
 {
   CheckedInt64 newStartOffset = aStart;
@@ -479,17 +479,17 @@ File::Slice(int64_t aStart, int64_t aEnd
   Optional<int64_t> end;
   if (aArgc > 1) {
     end.Construct(aEnd);
   }
 
   ErrorResult rv;
   nsRefPtr<File> file = Slice(start, end, aContentType, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   file.forget(aBlob);
   return NS_OK;
 }
 
 already_AddRefed<File>
 File::Slice(const Optional<int64_t>& aStart,
@@ -898,17 +898,17 @@ FileImplBase::GetSendInfo(nsIInputStream
 
   nsCOMPtr<nsIInputStream> stream;
   rv = GetInternalStream(getter_AddRefs(stream));
   NS_ENSURE_SUCCESS(rv, rv);
 
   ErrorResult error;
   *aContentLength = GetSize(error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   nsAutoString contentType;
   GetType(contentType);
 
   CopyUTF16toUTF8(contentType, aContentType);
 
   aCharset.Truncate();
@@ -934,17 +934,17 @@ FileImplBase::SetMutable(bool aMutable)
   if (!mImmutable && !aMutable) {
     // Force the content type and size to be cached
     nsAutoString dummyString;
     GetType(dummyString);
 
     ErrorResult error;
     GetSize(error);
     if (NS_WARN_IF(error.Failed())) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
   }
 
   mImmutable = !aMutable;
   return rv;
 }
 
 ////////////////////////////////////////////////////////////////////////////
--- a/dom/base/NodeIterator.h
+++ b/dom/base/NodeIterator.h
@@ -95,17 +95,17 @@ private:
 
     // Implementation for some of our XPCOM getters
     typedef already_AddRefed<nsINode> (NodeIterator::*NodeGetter)(ErrorResult&);
     inline nsresult ImplNodeGetter(NodeGetter aGetter, nsIDOMNode** aRetval)
     {
         mozilla::ErrorResult rv;
         nsCOMPtr<nsINode> node = (this->*aGetter)(rv);
         if (rv.Failed()) {
-            return rv.ErrorCode();
+            return rv.StealNSResult();
         }
         *aRetval = node ? node.forget().take()->AsDOMNode() : nullptr;
         return NS_OK;
     }
 
     // Have to return a strong ref, because the act of testing the node can
     // remove it from the DOM so we're holding the only ref to it.
     already_AddRefed<nsINode>
--- a/dom/base/TreeWalker.cpp
+++ b/dom/base/TreeWalker.cpp
@@ -101,17 +101,17 @@ NS_IMETHODIMP TreeWalker::SetCurrentNode
     NS_ENSURE_TRUE(aCurrentNode, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     NS_ENSURE_TRUE(mRoot, NS_ERROR_UNEXPECTED);
 
     nsCOMPtr<nsINode> node = do_QueryInterface(aCurrentNode);
     NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
 
     ErrorResult rv;
     SetCurrentNode(*node, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 void
 TreeWalker::SetCurrentNode(nsINode& aNode, ErrorResult& aResult)
 {
     aResult = nsContentUtils::CheckSameOrigin(mRoot, &aNode);
     if (aResult.Failed()) {
         return;
--- a/dom/base/TreeWalker.h
+++ b/dom/base/TreeWalker.h
@@ -92,17 +92,17 @@ private:
 
     // Implementation for our various XPCOM getters
     typedef already_AddRefed<nsINode> (TreeWalker::*NodeGetter)(ErrorResult&);
     inline nsresult ImplNodeGetter(NodeGetter aGetter, nsIDOMNode** aRetval)
     {
         mozilla::ErrorResult rv;
         nsCOMPtr<nsINode> node = (this->*aGetter)(rv);
         if (rv.Failed()) {
-            return rv.ErrorCode();
+            return rv.StealNSResult();
         }
         *aRetval = node ? node.forget().take()->AsDOMNode() : nullptr;
         return NS_OK;
     }
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3769,17 +3769,17 @@ nsContentUtils::ConvertStringFromEncodin
   }
 
   ErrorResult rv;
   nsAutoPtr<TextDecoder> decoder(new TextDecoder());
   decoder->InitWithEncoding(encoding, false);
 
   decoder->Decode(aInput.BeginReading(), aInput.Length(), false,
                   aOutput, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* static */
 bool
 nsContentUtils::CheckForBOM(const unsigned char* aBuffer, uint32_t aLength,
                             nsACString& aCharset)
 {
   bool found = true;
@@ -4106,17 +4106,17 @@ nsresult
 nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
                                          const nsAString& aFragment,
                                          bool aPreventScriptExecution,
                                          nsIDOMDocumentFragment** aReturn)
 {
   ErrorResult rv;
   *aReturn = CreateContextualFragment(aContextNode, aFragment,
                                       aPreventScriptExecution, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DocumentFragment>
 nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
                                          const nsAString& aFragment,
                                          bool aPreventScriptExecution,
                                          ErrorResult& aRv)
 {
--- a/dom/base/nsDOMAttributeMap.cpp
+++ b/dom/base/nsDOMAttributeMap.cpp
@@ -245,28 +245,28 @@ nsDOMAttributeMap::GetNamedItem(const ns
 NS_IMETHODIMP
 nsDOMAttributeMap::SetNamedItem(nsIDOMAttr* aAttr, nsIDOMAttr** aReturn)
 {
   Attr* attribute = static_cast<Attr*>(aAttr);
   NS_ENSURE_ARG(attribute);
 
   ErrorResult rv;
   *aReturn = SetNamedItem(*attribute, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsDOMAttributeMap::SetNamedItemNS(nsIDOMAttr* aAttr, nsIDOMAttr** aReturn)
 {
   Attr* attribute = static_cast<Attr*>(aAttr);
   NS_ENSURE_ARG(attribute);
 
   ErrorResult rv;
   *aReturn = SetNamedItemNS(*attribute, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<Attr>
 nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
                                         bool aWithNS,
                                         ErrorResult& aError)
 {
   NS_ENSURE_TRUE(mContent, nullptr);
@@ -373,17 +373,17 @@ nsDOMAttributeMap::RemoveNamedItem(NodeI
 NS_IMETHODIMP
 nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName,
                                    nsIDOMAttr** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
 
   ErrorResult rv;
   *aReturn = RemoveNamedItem(aName, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<Attr>
 nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, ErrorResult& aError)
 {
   if (!mContent) {
     aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
     return nullptr;
@@ -511,17 +511,17 @@ nsDOMAttributeMap::GetAttrNodeInfo(const
 NS_IMETHODIMP
 nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
                                      const nsAString& aLocalName,
                                      nsIDOMAttr** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   ErrorResult rv;
   *aReturn = RemoveNamedItemNS(aNamespaceURI, aLocalName, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<Attr>
 nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
                                      const nsAString& aLocalName,
                                      ErrorResult& aError)
 {
   nsRefPtr<mozilla::dom::NodeInfo> ni = GetAttrNodeInfo(aNamespaceURI, aLocalName);
--- a/dom/base/nsDOMFileReader.cpp
+++ b/dom/base/nsDOMFileReader.cpp
@@ -183,56 +183,56 @@ nsDOMFileReader::GetError(nsISupports** 
 
 NS_IMETHODIMP
 nsDOMFileReader::ReadAsArrayBuffer(nsIDOMBlob* aFile, JSContext* aCx)
 {
   NS_ENSURE_TRUE(aFile, NS_ERROR_NULL_POINTER);
   ErrorResult rv;
   nsRefPtr<File> file = static_cast<File*>(aFile);
   ReadAsArrayBuffer(aCx, *file, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsDOMFileReader::ReadAsBinaryString(nsIDOMBlob* aFile)
 {
   NS_ENSURE_TRUE(aFile, NS_ERROR_NULL_POINTER);
   ErrorResult rv;
   nsRefPtr<File> file = static_cast<File*>(aFile);
   ReadAsBinaryString(*file, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsDOMFileReader::ReadAsText(nsIDOMBlob* aFile,
                             const nsAString &aCharset)
 {
   NS_ENSURE_TRUE(aFile, NS_ERROR_NULL_POINTER);
   ErrorResult rv;
   nsRefPtr<File> file = static_cast<File*>(aFile);
   ReadAsText(*file, aCharset, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsDOMFileReader::ReadAsDataURL(nsIDOMBlob* aFile)
 {
   NS_ENSURE_TRUE(aFile, NS_ERROR_NULL_POINTER);
   ErrorResult rv;
   nsRefPtr<File> file = static_cast<File*>(aFile);
   ReadAsDataURL(*file, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsDOMFileReader::Abort()
 {
   ErrorResult rv;
   FileIOObject::Abort(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* virtual */ void
 nsDOMFileReader::DoAbort(nsAString& aEvent)
 {
   // Revert status and result attributes
   SetDOMStringToNull(mResult);
   mResultArrayBuffer = nullptr;
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3467,17 +3467,17 @@ nsDOMWindowUtils::GetOMTAStyle(nsIDOMEle
     }
   }
 
   if (cssValue) {
     nsString text;
     ErrorResult rv;
     cssValue->GetCssText(text, rv);
     aResult.Assign(text);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   } else {
     aResult.Truncate();
   }
 
   return NS_OK;
 }
 
 namespace {
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -3335,17 +3335,17 @@ nsDocument::Timeline()
 
 /* Return true if the document is in the focused top-level window, and is an
  * ancestor of the focused DOMWindow. */
 NS_IMETHODIMP
 nsDocument::HasFocus(bool* aResult)
 {
   ErrorResult rv;
   *aResult = nsIDocument::HasFocus(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsIDocument::HasFocus(ErrorResult& rv) const
 {
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   if (!fm) {
     rv.Throw(NS_ERROR_NOT_AVAILABLE);
@@ -5456,17 +5456,17 @@ nsDocument::GetDoctype(nsIDOMDocumentTyp
 
 NS_IMETHODIMP
 nsDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
 {
   ErrorResult rv;
   *aImplementation = GetImplementation(rv);
   if (rv.Failed()) {
     MOZ_ASSERT(!*aImplementation);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_ADDREF(*aImplementation);
   return NS_OK;
 }
 
 DOMImplementation*
 nsDocument::GetImplementation(ErrorResult& rv)
 {
@@ -5728,17 +5728,17 @@ nsIDocument::CreateComment(const nsAStri
 
 NS_IMETHODIMP
 nsDocument::CreateCDATASection(const nsAString& aData,
                                nsIDOMCDATASection** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   ErrorResult rv;
   *aReturn = nsIDocument::CreateCDATASection(aData, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<CDATASection>
 nsIDocument::CreateCDATASection(const nsAString& aData,
                                 ErrorResult& rv)
 {
   if (IsHTMLDocument()) {
     rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
@@ -5761,17 +5761,17 @@ nsIDocument::CreateCDATASection(const ns
 NS_IMETHODIMP
 nsDocument::CreateProcessingInstruction(const nsAString& aTarget,
                                         const nsAString& aData,
                                         nsIDOMProcessingInstruction** aReturn)
 {
   ErrorResult rv;
   *aReturn =
     nsIDocument::CreateProcessingInstruction(aTarget, aData, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<ProcessingInstruction>
 nsIDocument::CreateProcessingInstruction(const nsAString& aTarget,
                                          const nsAString& aData,
                                          ErrorResult& rv) const
 {
   nsresult res = nsContentUtils::CheckQName(aTarget, false);
@@ -5792,17 +5792,17 @@ nsIDocument::CreateProcessingInstruction
 }
 
 NS_IMETHODIMP
 nsDocument::CreateAttribute(const nsAString& aName,
                             nsIDOMAttr** aReturn)
 {
   ErrorResult rv;
   *aReturn = nsIDocument::CreateAttribute(aName, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<Attr>
 nsIDocument::CreateAttribute(const nsAString& aName, ErrorResult& rv)
 {
   WarnOnceAbout(eCreateAttribute);
 
   if (!mNodeInfoManager) {
@@ -5833,17 +5833,17 @@ nsIDocument::CreateAttribute(const nsASt
 NS_IMETHODIMP
 nsDocument::CreateAttributeNS(const nsAString & aNamespaceURI,
                               const nsAString & aQualifiedName,
                               nsIDOMAttr **aResult)
 {
   ErrorResult rv;
   *aResult =
     nsIDocument::CreateAttributeNS(aNamespaceURI, aQualifiedName, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<Attr>
 nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
                                const nsAString& aQualifiedName,
                                ErrorResult& rv)
 {
   WarnOnceAbout(eCreateAttributeNS);
@@ -6527,17 +6527,17 @@ NS_IMETHODIMP
 nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
                                    const nsAString& aLocalName,
                                    nsIDOMNodeList** aReturn)
 {
   ErrorResult rv;
   nsRefPtr<nsContentList> list =
     nsIDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   // transfer ref to aReturn
   list.forget(aReturn);
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -6751,17 +6751,17 @@ nsDocument::ImportNode(nsIDOMNode* aImpo
   *aResult = nullptr;
 
   nsCOMPtr<nsINode> imported = do_QueryInterface(aImportedNode);
   NS_ENSURE_TRUE(imported, NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   nsCOMPtr<nsINode> result = nsIDocument::ImportNode(*imported, aDeep, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   NS_ADDREF(*aResult = result->AsDOMNode());
   return NS_OK;
 }
 
 already_AddRefed<nsINode>
 nsIDocument::ImportNode(nsINode& aNode, bool aDeep, ErrorResult& rv) const
@@ -6798,17 +6798,17 @@ nsIDocument::ImportNode(nsINode& aNode, 
   return nullptr;
 }
 
 NS_IMETHODIMP
 nsDocument::LoadBindingDocument(const nsAString& aURI)
 {
   ErrorResult rv;
   nsIDocument::LoadBindingDocument(aURI, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsIDocument::LoadBindingDocument(const nsAString& aURI, ErrorResult& rv)
 {
   nsCOMPtr<nsIURI> uri;
   rv = NS_NewURI(getter_AddRefs(uri), aURI,
                  mCharacterSet.get(),
@@ -6941,17 +6941,17 @@ nsIDocument::GetAnonymousNodes(Element& 
   return BindingManager()->GetAnonymousNodesFor(&aElement);
 }
 
 NS_IMETHODIMP
 nsDocument::CreateRange(nsIDOMRange** aReturn)
 {
   ErrorResult rv;
   *aReturn = nsIDocument::CreateRange(rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<nsRange>
 nsIDocument::CreateRange(ErrorResult& rv)
 {
   nsRefPtr<nsRange> range = new nsRange(this);
   nsresult res = range->Set(this, 0, this, 0);
   if (NS_FAILED(res)) {
@@ -6981,17 +6981,17 @@ nsDocument::CreateNodeIterator(nsIDOMNod
 
   nsCOMPtr<nsINode> root = do_QueryInterface(aRoot);
   NS_ENSURE_TRUE(root, NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   NodeFilterHolder holder(aFilter);
   *_retval = nsIDocument::CreateNodeIterator(*root, aWhatToShow, holder,
                                              rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<NodeIterator>
 nsIDocument::CreateNodeIterator(nsINode& aRoot, uint32_t aWhatToShow,
                                 NodeFilter* aFilter,
                                 ErrorResult& rv) const
 {
   NodeFilterHolder holder(aFilter);
@@ -7024,17 +7024,17 @@ nsDocument::CreateTreeWalker(nsIDOMNode 
 
   nsCOMPtr<nsINode> root = do_QueryInterface(aRoot);
   NS_ENSURE_TRUE(root, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 
   ErrorResult rv;
   NodeFilterHolder holder(aFilter);
   *_retval = nsIDocument::CreateTreeWalker(*root, aWhatToShow, holder,
                                            rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<TreeWalker>
 nsIDocument::CreateTreeWalker(nsINode& aRoot, uint32_t aWhatToShow,
                               NodeFilter* aFilter,
                               ErrorResult& rv) const
 {
   NodeFilterHolder holder(aFilter);
@@ -7746,17 +7746,17 @@ nsDocument::AdoptNode(nsIDOMNode *aAdopt
   *aResult = nullptr;
 
   nsCOMPtr<nsINode> adoptedNode = do_QueryInterface(aAdoptedNode);
   NS_ENSURE_TRUE(adoptedNode, NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   nsINode* result = nsIDocument::AdoptNode(*adoptedNode, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   NS_ADDREF(*aResult = result->AsDOMNode());
   return NS_OK;
 }
 
 nsINode*
 nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
@@ -8191,17 +8191,17 @@ nsDocument::PreHandleEvent(EventChainPre
 }
 
 NS_IMETHODIMP
 nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   ErrorResult rv;
   *aReturn = nsIDocument::CreateEvent(aEventType, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<Event>
 nsIDocument::CreateEvent(const nsAString& aEventType, ErrorResult& rv) const
 {
   nsIPresShell *shell = GetShell();
 
   nsPresContext *presContext = nullptr;
@@ -11904,17 +11904,17 @@ nsDocument::RequestFullScreen(Element* a
 }
 
 NS_IMETHODIMP
 nsDocument::GetMozFullScreenElement(nsIDOMElement **aFullScreenElement)
 {
   ErrorResult rv;
   Element* el = GetMozFullScreenElement(rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   nsCOMPtr<nsIDOMElement> retval = do_QueryInterface(el);
   retval.forget(aFullScreenElement);
   return NS_OK;
 }
 
 Element*
 nsDocument::GetMozFullScreenElement(ErrorResult& rv)
--- a/dom/base/nsGenericDOMDataNode.cpp
+++ b/dom/base/nsGenericDOMDataNode.cpp
@@ -197,17 +197,17 @@ nsGenericDOMDataNode::GetLength(uint32_t
 }
 
 nsresult
 nsGenericDOMDataNode::SubstringData(uint32_t aStart, uint32_t aCount,
                                     nsAString& aReturn)
 {
   ErrorResult rv;
   SubstringData(aStart, aCount, aReturn, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGenericDOMDataNode::SubstringData(uint32_t aStart, uint32_t aCount,
                                     nsAString& aReturn, ErrorResult& rv)
 {
   aReturn.Truncate();
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3543,17 +3543,17 @@ nsGlobalWindow::GetSelf(ErrorResult& aEr
 
 NS_IMETHODIMP
 nsGlobalWindow::GetSelf(nsIDOMWindow** aWindow)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMWindow> window = GetSelf(rv);
   window.forget(aWindow);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 Navigator*
 nsGlobalWindow::GetNavigator(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetNavigator, (aError), aError, nullptr);
 
   if (!mNavigator) {
@@ -3565,17 +3565,17 @@ nsGlobalWindow::GetNavigator(ErrorResult
 
 NS_IMETHODIMP
 nsGlobalWindow::GetNavigator(nsIDOMNavigator** aNavigator)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMNavigator> navigator = GetNavigator(rv);
   navigator.forget(aNavigator);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsScreen*
 nsGlobalWindow::GetScreen(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetScreen, (aError), aError, nullptr);
 
   if (!mScreen) {
@@ -3591,17 +3591,17 @@ nsGlobalWindow::GetScreen(ErrorResult& a
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreen(nsIDOMScreen** aScreen)
 {
   ErrorResult rv;
   nsRefPtr<nsScreen> screen = GetScreen(rv);
   screen.forget(aScreen);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsHistory*
 nsGlobalWindow::GetHistory(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetHistory, (aError), aError, nullptr);
 
   if (!mHistory) {
@@ -3613,17 +3613,17 @@ nsGlobalWindow::GetHistory(ErrorResult& 
 
 NS_IMETHODIMP
 nsGlobalWindow::GetHistory(nsISupports** aHistory)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> history = GetHistory(rv);
   history.forget(aHistory);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsPerformance*
 nsGlobalWindow::GetPerformance()
 {
   FORWARD_TO_INNER(GetPerformance, (), nullptr);
 
   return nsPIDOMWindow::GetPerformance();
@@ -3809,17 +3809,17 @@ nsGlobalWindow::GetParent(ErrorResult& a
  */
 NS_IMETHODIMP
 nsGlobalWindow::GetScriptableParent(nsIDOMWindow** aParent)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMWindow> parent = GetParent(rv);
   parent.forget(aParent);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /**
  * nsIDOMWindow::GetParent (when called from C++) is just a wrapper around
  * GetRealParent.
  */
 NS_IMETHODIMP
 nsGlobalWindow::GetRealParent(nsIDOMWindow** aParent)
@@ -3996,17 +3996,17 @@ nsGlobalWindow::GetContentInternal(Error
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
 {
   ErrorResult rv;
   *aContent = GetContentInternal(rv).take();
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 MozSelfSupport*
 nsGlobalWindow::GetMozSelfSupport(ErrorResult& aError)
 {
   if (mMozSelfSupport) {
     return mMozSelfSupport;
   }
@@ -4022,17 +4022,17 @@ nsGlobalWindow::GetScriptableContent(JSC
 {
   ErrorResult rv;
   JS::Rooted<JSObject*> content(aCx);
   GetContent(aCx, &content, rv);
   if (!rv.Failed()) {
     aVal.setObjectOrNull(content);
   }
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetPrompter(nsIPrompt** aPrompt)
 {
   if (IsInnerWindow()) {
     nsGlobalWindow* outer = GetOuterWindowInternal();
     if (!outer) {
@@ -4066,17 +4066,17 @@ nsGlobalWindow::GetMenubar(ErrorResult& 
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMenubar(nsISupports** aMenubar)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> menubar = GetMenubar(rv);
   menubar.forget(aMenubar);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 BarProp*
 nsGlobalWindow::GetToolbar(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetToolbar, (aError), aError, nullptr);
 
   if (!mToolbar) {
@@ -4088,17 +4088,17 @@ nsGlobalWindow::GetToolbar(ErrorResult& 
 
 NS_IMETHODIMP
 nsGlobalWindow::GetToolbar(nsISupports** aToolbar)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> toolbar = GetToolbar(rv);
   toolbar.forget(aToolbar);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 BarProp*
 nsGlobalWindow::GetLocationbar(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetLocationbar, (aError), aError, nullptr);
 
   if (!mLocationbar) {
@@ -4109,17 +4109,17 @@ nsGlobalWindow::GetLocationbar(ErrorResu
 
 NS_IMETHODIMP
 nsGlobalWindow::GetLocationbar(nsISupports** aLocationbar)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> locationbar = GetLocationbar(rv);
   locationbar.forget(aLocationbar);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 BarProp*
 nsGlobalWindow::GetPersonalbar(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetPersonalbar, (aError), aError, nullptr);
 
   if (!mPersonalbar) {
@@ -4130,17 +4130,17 @@ nsGlobalWindow::GetPersonalbar(ErrorResu
 
 NS_IMETHODIMP
 nsGlobalWindow::GetPersonalbar(nsISupports** aPersonalbar)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> personalbar = GetPersonalbar(rv);
   personalbar.forget(aPersonalbar);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 BarProp*
 nsGlobalWindow::GetStatusbar(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetStatusbar, (aError), aError, nullptr);
 
   if (!mStatusbar) {
@@ -4151,17 +4151,17 @@ nsGlobalWindow::GetStatusbar(ErrorResult
 
 NS_IMETHODIMP
 nsGlobalWindow::GetStatusbar(nsISupports** aStatusbar)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> statusbar = GetStatusbar(rv);
   statusbar.forget(aStatusbar);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 BarProp*
 nsGlobalWindow::GetScrollbars(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetScrollbars, (aError), aError, nullptr);
 
   if (!mScrollbars) {
@@ -4173,17 +4173,17 @@ nsGlobalWindow::GetScrollbars(ErrorResul
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollbars(nsISupports** aScrollbars)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> scrollbars = GetScrollbars(rv);
   scrollbars.forget(aScrollbars);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsGlobalWindow::GetClosed(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetClosed, (aError), aError, false);
 
   // If someone called close(), or if we don't have a docshell, we're closed.
@@ -4191,17 +4191,17 @@ nsGlobalWindow::GetClosed(ErrorResult& a
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetClosed(bool* aClosed)
 {
   ErrorResult rv;
   *aClosed = GetClosed(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsDOMWindowList*
 nsGlobalWindow::GetWindowList()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mFrames && mDocShell) {
@@ -4377,17 +4377,17 @@ nsGlobalWindow::GetApplicationCache(Erro
 NS_IMETHODIMP
 nsGlobalWindow::GetApplicationCache(nsIDOMOfflineResourceList **aApplicationCache)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMOfflineResourceList> applicationCache =
     GetApplicationCache(rv);
   applicationCache.forget(aApplicationCache);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 Crypto*
 nsGlobalWindow::GetCrypto(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetCrypto, (aError), aError, nullptr);
 
   if (!mCrypto) {
@@ -4399,17 +4399,17 @@ nsGlobalWindow::GetCrypto(ErrorResult& a
 
 NS_IMETHODIMP
 nsGlobalWindow::GetCrypto(nsIDOMCrypto** aCrypto)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMCrypto> crypto = GetCrypto(rv);
   crypto.forget(aCrypto);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIControllers*
 nsGlobalWindow::GetControllers(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetControllers, (aError), aError, nullptr);
 
   if (!mControllers) {
@@ -4443,17 +4443,17 @@ nsGlobalWindow::GetControllers(ErrorResu
 
 NS_IMETHODIMP
 nsGlobalWindow::GetControllers(nsIControllers** aResult)
 {
   ErrorResult rv;
   nsCOMPtr<nsIControllers> controllers = GetControllers(rv);
   controllers.forget(aResult);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIDOMWindow*
 nsGlobalWindow::GetOpenerWindow(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetOpenerWindow, (aError), aError, nullptr);
 
   nsCOMPtr<nsPIDOMWindow> opener = do_QueryReferent(mOpener);
@@ -4514,26 +4514,26 @@ nsGlobalWindow::GetOpener(JSContext* aCx
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScriptableOpener(JSContext* aCx,
                                     JS::MutableHandle<JS::Value> aOpener)
 {
   ErrorResult rv;
   GetOpener(aCx, aOpener, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetOpener(nsIDOMWindow** aOpener)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMWindow> opener = GetOpenerWindow(rv);
   opener.forget(aOpener);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
                           ErrorResult& aError)
 {
   // Check if we were called from a privileged chrome script.  If not, and if
   // aOpener is not null, just define aOpener on our inner window's JS object,
@@ -4582,17 +4582,17 @@ nsGlobalWindow::SetOpener(JSContext* aCx
 
 NS_IMETHODIMP
 nsGlobalWindow::SetScriptableOpener(JSContext* aCx,
                                     JS::Handle<JS::Value> aOpener)
 {
   ErrorResult rv;
   SetOpener(aCx, aOpener, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetOpener(nsIDOMWindow* aOpener)
 {
   SetOpenerWindow(aOpener, false);
   return NS_OK;
 }
@@ -4606,17 +4606,17 @@ nsGlobalWindow::GetStatus(nsAString& aSt
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetStatus(nsAString& aStatus)
 {
   ErrorResult rv;
   GetStatus(aStatus, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetStatus(const nsAString& aStatus, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetStatus, (aStatus, aError), aError, );
 
   mStatus = aStatus;
@@ -4638,17 +4638,17 @@ nsGlobalWindow::SetStatus(const nsAStrin
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetStatus(const nsAString& aStatus)
 {
   ErrorResult rv;
   SetStatus(aStatus, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::GetName(nsAString& aName, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetName, (aName, aError), aError, );
 
   if (mDocShell) {
@@ -4657,17 +4657,17 @@ nsGlobalWindow::GetName(nsAString& aName
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetName(nsAString& aName)
 {
   ErrorResult rv;
   GetName(aName, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetName(const nsAString& aName, mozilla::ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetName, (aName, aError), aError, );
 
   if (mDocShell) {
@@ -4676,17 +4676,17 @@ nsGlobalWindow::SetName(const nsAString&
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetName(const nsAString& aName)
 {
   ErrorResult rv;
   SetName(aName, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 // Helper functions used by many methods below.
 int32_t
 nsGlobalWindow::DevToCSSIntPixels(int32_t px)
 {
   if (!mDocShell)
     return px; // assume 1:1
@@ -4804,17 +4804,17 @@ nsGlobalWindow::GetInnerWidth(JSContext*
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth)
 {
   ErrorResult rv;
   *aInnerWidth = GetInnerWidth(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetInnerWidth, (aInnerWidth, aError), aError, );
 
   if (!mDocShell) {
@@ -4861,17 +4861,17 @@ nsGlobalWindow::SetInnerWidth(int32_t aI
 {
   if (IsFrame()) {
     return NS_OK;
   }
 
   ErrorResult rv;
   SetInnerWidth(aInnerWidth, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 nsGlobalWindow::GetInnerHeight(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetInnerHeight, (aError), aError, 0);
 
   CSSIntSize size;
@@ -4889,17 +4889,17 @@ nsGlobalWindow::GetInnerHeight(JSContext
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetInnerHeight(int32_t* aInnerHeight)
 {
   ErrorResult rv;
   *aInnerHeight = GetInnerHeight(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetInnerHeight, (aInnerHeight, aError), aError, );
 
   if (!mDocShell) {
@@ -4945,17 +4945,17 @@ nsGlobalWindow::SetInnerHeight(int32_t a
 {
   if (IsFrame()) {
     return NS_OK;
   }
 
   ErrorResult rv;
   SetInnerHeight(aInnerHeight, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIntSize
 nsGlobalWindow::GetOuterSize(ErrorResult& aError)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
@@ -4996,17 +4996,17 @@ nsGlobalWindow::GetOuterWidth(JSContext*
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetOuterWidth(int32_t* aOuterWidth)
 {
   ErrorResult rv;
   *aOuterWidth = GetOuterWidth(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 nsGlobalWindow::GetOuterHeight(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetOuterHeight, (aError), aError, 0);
   return GetOuterSize(aError).height;
 }
@@ -5021,17 +5021,17 @@ nsGlobalWindow::GetOuterHeight(JSContext
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetOuterHeight(int32_t* aOuterHeight)
 {
   ErrorResult rv;
   *aOuterHeight = GetOuterHeight(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
                              ErrorResult& aError)
 {
   MOZ_ASSERT(IsOuterWindow());
 
@@ -5080,17 +5080,17 @@ nsGlobalWindow::SetOuterWidth(int32_t aO
 {
   if (IsFrame()) {
     return NS_OK;
   }
 
   ErrorResult rv;
   SetOuterWidth(aOuterWidth, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetOuterHeight(int32_t aOuterHeight, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetOuterHeight, (aOuterHeight, aError), aError, );
 
   SetOuterSize(aOuterHeight, false, aError);
@@ -5109,17 +5109,17 @@ nsGlobalWindow::SetOuterHeight(int32_t a
 {
   if (IsFrame()) {
     return NS_OK;
   }
 
   ErrorResult rv;
   SetOuterHeight(aOuterHeight, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIntPoint
 nsGlobalWindow::GetScreenXY(ErrorResult& aError)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
@@ -5151,17 +5151,17 @@ nsGlobalWindow::GetScreenX(JSContext* aC
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreenX(int32_t* aScreenX)
 {
   ErrorResult rv;
   *aScreenX = GetScreenX(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsRect
 nsGlobalWindow::GetInnerScreenRect()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
@@ -5200,17 +5200,17 @@ nsGlobalWindow::GetMozInnerScreenX(Error
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMozInnerScreenX(float* aScreenX)
 {
   ErrorResult rv;
   *aScreenX = GetMozInnerScreenX(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 float
 nsGlobalWindow::GetMozInnerScreenY(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetMozInnerScreenY, (aError), aError, 0);
 
   nsRect r = GetInnerScreenRect();
@@ -5218,17 +5218,17 @@ nsGlobalWindow::GetMozInnerScreenY(Error
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMozInnerScreenY(float* aScreenY)
 {
   ErrorResult rv;
   *aScreenY = GetMozInnerScreenY(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 float
 nsGlobalWindow::GetDevicePixelRatio(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetDevicePixelRatio, (aError), aError, 0.0);
 
   if (!mDocShell) {
@@ -5246,17 +5246,17 @@ nsGlobalWindow::GetDevicePixelRatio(Erro
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetDevicePixelRatio(float* aRatio)
 {
   ErrorResult rv;
   *aRatio = GetDevicePixelRatio(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 uint64_t
 nsGlobalWindow::GetMozPaintCount(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetMozPaintCount, (aError), aError, 0);
 
   if (!mDocShell) {
@@ -5268,17 +5268,17 @@ nsGlobalWindow::GetMozPaintCount(ErrorRe
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMozPaintCount(uint64_t* aResult)
 {
   ErrorResult rv;
   *aResult = GetMozPaintCount(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::MozRequestAnimationFrame(nsIFrameRequestCallback* aCallback,
                                          int32_t *aHandle)
 {
   if (!aCallback) {
     if (mDoc) {
@@ -5286,17 +5286,17 @@ nsGlobalWindow::MozRequestAnimationFrame
     }
     return NS_ERROR_XPC_BAD_CONVERT_JS;
   }
 
   ErrorResult rv;
   nsIDocument::FrameRequestCallbackHolder holder(aCallback);
   *aHandle = RequestAnimationFrame(holder, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 nsGlobalWindow::RequestAnimationFrame(FrameRequestCallback& aCallback,
                                       ErrorResult& aError)
 {
   nsIDocument::FrameRequestCallbackHolder holder(&aCallback);
   return RequestAnimationFrame(holder, aError);
@@ -5341,17 +5341,17 @@ nsGlobalWindow::RequestAnimationFrame(JS
 
   JS::Rooted<JSObject*> callbackObj(cx, &aCallback.toObject());
   nsRefPtr<FrameRequestCallback> callback =
     new FrameRequestCallback(callbackObj, GetIncumbentGlobal());
 
   ErrorResult rv;
   *aHandle = RequestAnimationFrame(*callback, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::MozCancelRequestAnimationFrame(int32_t aHandle)
 {
   return CancelAnimationFrame(aHandle);
 }
 
@@ -5374,17 +5374,17 @@ nsGlobalWindow::CancelAnimationFrame(int
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::CancelAnimationFrame(int32_t aHandle)
 {
   ErrorResult rv;
   CancelAnimationFrame(aHandle, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int64_t
 nsGlobalWindow::GetMozAnimationStartTime(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetMozAnimationStartTime, (aError), aError, 0);
 
   if (mDoc) {
@@ -5400,17 +5400,17 @@ nsGlobalWindow::GetMozAnimationStartTime
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetMozAnimationStartTime(int64_t *aTime)
 {
   ErrorResult rv;
   *aTime = GetMozAnimationStartTime(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<MediaQueryList>
 nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
                            ErrorResult& aError)
 {
   // FIXME: This whole forward-to-outer and then get a pres
   // shell/context off the docshell dance is sort of silly; it'd make
@@ -5429,17 +5429,17 @@ nsGlobalWindow::MatchMedia(const nsAStri
 NS_IMETHODIMP
 nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
                            nsISupports** aResult)
 {
   ErrorResult rv;
   nsRefPtr<MediaQueryList> mediaQueryList = MatchMedia(aMediaQueryList, rv);
   mediaQueryList.forget(aResult);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetScreenX(int32_t aScreenX, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetScreenX, (aScreenX, aError), aError, );
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
@@ -5473,34 +5473,34 @@ nsGlobalWindow::SetScreenX(int32_t aScre
 {
   if (IsFrame()) {
     return NS_OK;
   }
 
   ErrorResult rv;
   SetScreenX(aScreenX, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 nsGlobalWindow::GetScreenY(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetScreenY, (aError), aError, 0);
 
   return DevToCSSIntPixels(GetScreenXY(aError).y);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreenY(int32_t* aScreenY)
 {
   ErrorResult rv;
   *aScreenY = GetScreenY(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::GetScreenY(JSContext* aCx,
                            JS::MutableHandle<JS::Value> aValue,
                            ErrorResult& aError)
 {
   GetReplaceableWindowCoord(aCx, &nsGlobalWindow::GetScreenY, aValue,
@@ -5543,17 +5543,17 @@ nsGlobalWindow::SetScreenY(int32_t aScre
 {
   if (IsFrame()) {
     return NS_OK;
   }
 
   ErrorResult rv;
   SetScreenY(aScreenY, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 // NOTE: Arguments to this function should have values scaled to
 // CSS pixels, not device pixels.
 void
 nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight)
 {
   MOZ_ASSERT(IsOuterWindow());
@@ -5743,17 +5743,17 @@ nsGlobalWindow::GetScrollMaxX(ErrorResul
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollMaxX(int32_t* aScrollMaxX)
 {
   NS_ENSURE_ARG_POINTER(aScrollMaxX);
   ErrorResult rv;
   *aScrollMaxX = GetScrollMaxX(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 nsGlobalWindow::GetScrollMaxY(ErrorResult& aError)
 {
   int32_t scrollMaxY = 0;
   GetScrollMaxXY(nullptr, &scrollMaxY, aError);
   return scrollMaxY;
@@ -5761,17 +5761,17 @@ nsGlobalWindow::GetScrollMaxY(ErrorResul
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollMaxY(int32_t* aScrollMaxY)
 {
   NS_ENSURE_ARG_POINTER(aScrollMaxY);
   ErrorResult rv;
   *aScrollMaxY = GetScrollMaxY(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 CSSIntPoint
 nsGlobalWindow::GetScrollXY(bool aDoFlush)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (aDoFlush) {
@@ -5804,33 +5804,33 @@ nsGlobalWindow::GetScrollX(ErrorResult& 
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollX(int32_t* aScrollX)
 {
   NS_ENSURE_ARG_POINTER(aScrollX);
   ErrorResult rv;
   *aScrollX = GetScrollX(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 nsGlobalWindow::GetScrollY(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetScrollY, (aError), aError, 0);
   return GetScrollXY(false).y;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScrollY(int32_t* aScrollY)
 {
   NS_ENSURE_ARG_POINTER(aScrollY);
   ErrorResult rv;
   *aScrollY = GetScrollY(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 uint32_t
 nsGlobalWindow::Length()
 {
   FORWARD_TO_OUTER(Length, (), 0);
 
   nsDOMWindowList* windows = GetWindowList();
@@ -6079,17 +6079,17 @@ nsGlobalWindow::SetFullScreenInternal(bo
     nsRefPtr<power::PowerManagerService> pmService =
       power::PowerManagerService::GetInstance();
     NS_ENSURE_TRUE(pmService, NS_OK);
 
     ErrorResult rv;
     mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("DOM_Fullscreen"),
                                        this, rv);
     if (rv.Failed()) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
 
   } else if (mWakeLock && !mFullScreen) {
     ErrorResult rv;
     mWakeLock->Unlock(rv);
     NS_WARN_IF_FALSE(!rv.Failed(), "Failed to unlock the wakelock.");
     mWakeLock = nullptr;
   }
@@ -6127,17 +6127,17 @@ nsGlobalWindow::GetFullScreen(ErrorResul
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetFullScreen(bool* aFullScreen)
 {
   ErrorResult rv;
   *aFullScreen = GetFullScreen(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Dump(const nsAString& aStr)
 {
   if (!nsContentUtils::DOMWindowDumpEnabled()) {
     return NS_OK;
   }
@@ -6427,34 +6427,34 @@ nsGlobalWindow::Alert(const nsAString& a
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Alert(const nsAString& aString)
 {
   ErrorResult rv;
   Alert(aString, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsGlobalWindow::Confirm(const nsAString& aMessage, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(Confirm, (aMessage, aError), aError, false);
 
   return AlertOrConfirm(/* aAlert = */ false, aMessage, aError);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Confirm(const nsAString& aString, bool* aReturn)
 {
   ErrorResult rv;
   *aReturn = Confirm(aString, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<Promise>
 nsGlobalWindow::Fetch(const RequestOrUSVString& aInput,
                       const RequestInit& aInit, ErrorResult& aRv)
 {
   return FetchRequest(this, aInput, aInit, aRv);
 }
@@ -6545,17 +6545,17 @@ nsGlobalWindow::Prompt(const nsAString& 
 
 NS_IMETHODIMP
 nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
                        nsAString& aReturn)
 {
   ErrorResult rv;
   Prompt(aMessage, aInitial, aReturn, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Focus(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(Focus, (aError), aError, );
 
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
@@ -6665,17 +6665,17 @@ nsGlobalWindow::Focus(ErrorResult& aErro
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Focus()
 {
   ErrorResult rv;
   Focus(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Blur(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(Blur, (aError), aError, );
 
   // If dom.disable_window_flip == true, then content should not be allowed
@@ -6706,17 +6706,17 @@ nsGlobalWindow::Blur(ErrorResult& aError
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Blur()
 {
   ErrorResult rv;
   Blur(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Back(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(Back, (aError), aError, );
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
@@ -6729,17 +6729,17 @@ nsGlobalWindow::Back(ErrorResult& aError
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Back()
 {
   ErrorResult rv;
   Back(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Forward(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(Forward, (aError), aError, );
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
@@ -6752,17 +6752,17 @@ nsGlobalWindow::Forward(ErrorResult& aEr
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Forward()
 {
   ErrorResult rv;
   Forward(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Home(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(Home, (aError), aError, );
 
   if (!mDocShell) {
@@ -6813,17 +6813,17 @@ nsGlobalWindow::Home(ErrorResult& aError
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Home()
 {
   ErrorResult rv;
   Home(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Stop(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(Stop, (aError), aError, );
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
@@ -6833,17 +6833,17 @@ nsGlobalWindow::Stop(ErrorResult& aError
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Stop()
 {
   ErrorResult rv;
   Stop(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Print(ErrorResult& aError)
 {
 #ifdef NS_PRINTING
   FORWARD_TO_OUTER_OR_THROW(Print, (aError), aError, );
 
@@ -6919,17 +6919,17 @@ nsGlobalWindow::Print(ErrorResult& aErro
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Print()
 {
   ErrorResult rv;
   Print(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::MoveTo(int32_t aXPos, int32_t aYPos, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(MoveTo, (aXPos, aYPos, aError), aError, );
 
   /*
@@ -6957,17 +6957,17 @@ nsGlobalWindow::MoveTo(int32_t aXPos, in
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::MoveTo(int32_t aXPos, int32_t aYPos)
 {
   ErrorResult rv;
   MoveTo(aXPos, aYPos, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(MoveBy, (aXDif, aYDif, aError), aError, );
 
   /*
@@ -7009,17 +7009,17 @@ nsGlobalWindow::MoveBy(int32_t aXDif, in
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif)
 {
   ErrorResult rv;
   MoveBy(aXDif, aYDif, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::ResizeTo(int32_t aWidth, int32_t aHeight, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(ResizeTo, (aWidth, aHeight, aError), aError, );
 
   /*
@@ -7059,17 +7059,17 @@ nsGlobalWindow::ResizeTo(int32_t aWidth,
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::ResizeTo(int32_t aWidth, int32_t aHeight)
 {
   ErrorResult rv;
   ResizeTo(aWidth, aHeight, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
                          ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(ResizeBy, (aWidthDif, aHeightDif, aError), aError, );
 
@@ -7131,17 +7131,17 @@ nsGlobalWindow::ResizeBy(int32_t aWidthD
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif)
 {
   ErrorResult rv;
   ResizeBy(aWidthDif, aHeightDif, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SizeToContent(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SizeToContent, (aError), aError, );
 
   if (!mDocShell) {
@@ -7190,17 +7190,17 @@ nsGlobalWindow::SizeToContent(ErrorResul
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SizeToContent()
 {
   ErrorResult rv;
   SizeToContent(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetWindowRoot(nsIDOMEventTarget **aWindowRoot)
 {
   nsCOMPtr<nsPIWindowRoot> root = GetTopWindowRoot();
   return CallQueryInterface(root, aWindowRoot);
 }
@@ -7439,34 +7439,34 @@ nsGlobalWindow::ClearTimeout(int32_t aHa
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::ClearTimeout(int32_t aHandle)
 {
   ErrorResult rv;
   ClearTimeout(aHandle, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::ClearInterval(int32_t aHandle, ErrorResult& aError)
 {
   if (aHandle > 0) {
     ClearTimeoutOrInterval(aHandle, aError);
   }
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::ClearInterval(int32_t aHandle)
 {
   ErrorResult rv;
   ClearInterval(aHandle, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetTimeout(int32_t *_retval)
 {
   return SetTimeoutOrInterval(false, _retval);
 }
 
@@ -7863,17 +7863,17 @@ nsGlobalWindow::GetFrames(ErrorResult& a
 
 NS_IMETHODIMP
 nsGlobalWindow::GetFrames(nsIDOMWindow** aFrames)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMWindow> frames = GetFrames(rv);
   frames.forget(aFrames);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsGlobalWindow*
 nsGlobalWindow::CallerInnerWindow()
 {
   JSContext *cx = nsContentUtils::GetCurrentJSContext();
   NS_ENSURE_TRUE(cx, nullptr);
   nsIGlobalObject* global = GetIncumbentGlobal();
@@ -8443,17 +8443,17 @@ NS_IMETHODIMP
 nsGlobalWindow::PostMessageMoz(JS::Handle<JS::Value> aMessage,
                                const nsAString& aOrigin,
                                JS::Handle<JS::Value> aTransfer,
                                JSContext* aCx)
 {
   ErrorResult rv;
   PostMessageMoz(aCx, aMessage, aOrigin, aTransfer, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 class nsCloseEvent : public nsRunnable {
 
   nsRefPtr<nsGlobalWindow> mWindow;
   bool mIndirect;
 
   nsCloseEvent(nsGlobalWindow *aWindow, bool aIndirect)
@@ -8589,17 +8589,17 @@ nsGlobalWindow::Close(ErrorResult& aErro
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Close()
 {
   ErrorResult rv;
   Close(rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::ForceClose()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (IsFrame() || !mDocShell) {
@@ -9037,17 +9037,17 @@ nsGlobalWindow::CacheXBLPrototypeHandler
  * boundary).
  */
 NS_IMETHODIMP
 nsGlobalWindow::GetScriptableFrameElement(nsIDOMElement** aFrameElement)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMElement> frameElement = do_QueryInterface(GetFrameElement(rv));
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   frameElement.forget(aFrameElement);
 
   return NS_OK;
 }
 
 Element*
@@ -9099,17 +9099,17 @@ nsGlobalWindow::GetRealFrameElement(Erro
 NS_IMETHODIMP
 nsGlobalWindow::GetRealFrameElement(nsIDOMElement** aFrameElement)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMElement> frameElement =
     do_QueryInterface(GetRealFrameElement(rv));
   frameElement.forget(aFrameElement);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 // Helper for converting window.showModalDialog() options (list of ';'
 // separated name (:|=) value pairs) to a format that's parsable by
 // our normal window opening code.
 
 void
 ConvertDialogOptions(const nsAString& aOptions, nsAString& aResult)
@@ -9346,17 +9346,17 @@ nsGlobalWindow::ShowModalDialog(const ns
   if (aArgc < 1) {
     aArgs = CreateVoidVariant();
   }
 
   ErrorResult rv;
   nsCOMPtr<nsIVariant> retVal = ShowModalDialog(aURI, aArgs, aOptions, rv);
   retVal.forget(aRetVal);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 class ChildCommandDispatcher : public nsRunnable
 {
 public:
   ChildCommandDispatcher(nsGlobalWindow* aWindow,
                          nsITabChild* aTabChild,
                          const nsAString& aAction)
@@ -9450,17 +9450,17 @@ nsGlobalWindow::GetSelection(ErrorResult
 
 NS_IMETHODIMP
 nsGlobalWindow::GetSelection(nsISelection** aSelection)
 {
   ErrorResult rv;
   nsCOMPtr<nsISelection> selection = GetSelection(rv);
   selection.forget(aSelection);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsGlobalWindow::Find(const nsAString& aString, bool aCaseSensitive,
                      bool aBackwards, bool aWrapAround, bool aWholeWord,
                      bool aSearchInFrames, bool aShowDialog,
                      ErrorResult& aError)
 {
@@ -9540,51 +9540,51 @@ nsGlobalWindow::Find(const nsAString& aS
                      bool aBackwards, bool aWrapAround, bool aWholeWord,
                      bool aSearchInFrames, bool aShowDialog,
                      bool *aDidFind)
 {
   ErrorResult rv;
   *aDidFind = Find(aStr, aCaseSensitive, aBackwards, aWrapAround, aWholeWord,
                    aSearchInFrames, aShowDialog, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Atob(const nsAString& aAsciiBase64String,
                      nsAString& aBinaryData, ErrorResult& aError)
 {
   aError = nsContentUtils::Atob(aAsciiBase64String, aBinaryData);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Atob(const nsAString& aAsciiBase64String,
                      nsAString& aBinaryData)
 {
   ErrorResult rv;
   Atob(aAsciiBase64String, aBinaryData, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Btoa(const nsAString& aBinaryData,
                      nsAString& aAsciiBase64String, ErrorResult& aError)
 {
   aError = nsContentUtils::Btoa(aBinaryData, aAsciiBase64String);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::Btoa(const nsAString& aBinaryData,
                      nsAString& aAsciiBase64String)
 {
   ErrorResult rv;
   Btoa(aBinaryData, aAsciiBase64String, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 //*****************************************************************************
 // nsGlobalWindow::nsIDOMEventTarget
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsGlobalWindow::RemoveEventListener(const nsAString& aType,
@@ -9823,17 +9823,17 @@ nsGlobalWindow::GetLocation(ErrorResult&
 
 NS_IMETHODIMP
 nsGlobalWindow::GetLocation(nsIDOMLocation ** aLocation)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMLocation> location = GetLocation(rv);
   location.forget(aLocation);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::ActivateOrDeactivate(bool aActivate)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mDoc) {
@@ -10435,17 +10435,17 @@ nsGlobalWindow::GetComputedStyleHelper(n
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   ErrorResult rv;
   nsCOMPtr<nsIDOMCSSStyleDeclaration> declaration =
     GetComputedStyleHelper(*element, aPseudoElt, aDefaultStylesOnly, rv);
   declaration.forget(aReturn);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<nsICSSDeclaration>
 nsGlobalWindow::GetComputedStyleHelper(Element& aElt,
                                        const nsAString& aPseudoElt,
                                        bool aDefaultStylesOnly,
                                        ErrorResult& aError)
 {
@@ -10578,17 +10578,17 @@ nsGlobalWindow::GetSessionStorage(ErrorR
 
 NS_IMETHODIMP
 nsGlobalWindow::GetSessionStorage(nsISupports** aSessionStorage)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMStorage> storage = GetSessionStorage(rv);
   storage.forget(aSessionStorage);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 DOMStorage*
 nsGlobalWindow::GetLocalStorage(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetLocalStorage, (aError), aError, nullptr);
 
   if (!Preferences::GetBool(kStorageEnabled)) {
@@ -10648,17 +10648,17 @@ NS_IMETHODIMP
 nsGlobalWindow::GetLocalStorage(nsISupports** aLocalStorage)
 {
   NS_ENSURE_ARG(aLocalStorage);
 
   ErrorResult rv;
   nsCOMPtr<nsIDOMStorage> storage = GetLocalStorage(rv);
   storage.forget(aLocalStorage);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 IDBFactory*
 nsGlobalWindow::GetIndexedDB(ErrorResult& aError)
 {
   if (!mIndexedDB) {
     // This may keep mIndexedDB null without setting an error.
     aError = IDBFactory::CreateForWindow(this, getter_AddRefs(mIndexedDB));
@@ -10669,17 +10669,17 @@ nsGlobalWindow::GetIndexedDB(ErrorResult
 
 NS_IMETHODIMP
 nsGlobalWindow::GetIndexedDB(nsISupports** _retval)
 {
   ErrorResult rv;
   nsCOMPtr<nsISupports> request(GetIndexedDB(rv));
   request.forget(_retval);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 //*****************************************************************************
 // nsGlobalWindow::nsIInterfaceRequestor
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
@@ -11522,17 +11522,17 @@ nsGlobalWindow::Observe(nsISupports* aSu
     // to dispatch clones rather than the original event.
     ErrorResult error;
     nsRefPtr<StorageEvent> newEvent =
       CloneStorageEvent(fireMozStorageChanged ?
                           NS_LITERAL_STRING("MozStorageChanged") :
                           NS_LITERAL_STRING("storage"),
                         event, error);
     if (error.Failed()) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
 
     newEvent->SetTrusted(true);
 
     if (fireMozStorageChanged) {
       WidgetEvent* internalEvent = newEvent->GetInternalNSEvent();
       internalEvent->mFlags.mOnlyChromeDispatch = true;
     }
@@ -13553,17 +13553,17 @@ nsGlobalWindow::WindowState()
   return nsIDOMChromeWindow::STATE_NORMAL;
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::Maximize()
 {
   ErrorResult rv;
   Maximize(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Maximize(ErrorResult& aError)
 {
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   if (widget) {
@@ -13571,17 +13571,17 @@ nsGlobalWindow::Maximize(ErrorResult& aE
   }
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::Minimize()
 {
   ErrorResult rv;
   Minimize(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Minimize(ErrorResult& aError)
 {
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   if (widget) {
@@ -13589,17 +13589,17 @@ nsGlobalWindow::Minimize(ErrorResult& aE
   }
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::Restore()
 {
   ErrorResult rv;
   Restore(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::Restore(ErrorResult& aError)
 {
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   if (widget) {
@@ -13607,31 +13607,31 @@ nsGlobalWindow::Restore(ErrorResult& aEr
   }
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::GetAttention()
 {
   ErrorResult rv;
   GetAttention(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::GetAttention(ErrorResult& aResult)
 {
   return GetAttentionWithCycleCount(-1, aResult);
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::GetAttentionWithCycleCount(int32_t aCycleCount)
 {
   ErrorResult rv;
   GetAttentionWithCycleCount(aCycleCount, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::GetAttentionWithCycleCount(int32_t aCycleCount,
                                            ErrorResult& aError)
 {
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
@@ -13647,17 +13647,17 @@ nsGlobalChromeWindow::BeginWindowMove(ns
   Event* mouseDownEvent = aMouseDownEvent->InternalDOMEvent();
   NS_ENSURE_TRUE(mouseDownEvent, NS_ERROR_FAILURE);
 
   nsCOMPtr<Element> panel = do_QueryInterface(aPanel);
   NS_ENSURE_TRUE(panel || !aPanel, NS_ERROR_FAILURE);
 
   ErrorResult rv;
   BeginWindowMove(*mouseDownEvent, panel, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::BeginWindowMove(Event& aMouseDownEvent, Element* aPanel,
                                 ErrorResult& aError)
 {
   nsCOMPtr<nsIWidget> widget;
 
@@ -13702,17 +13702,17 @@ nsGlobalWindow::GetWindowRoot(mozilla::E
 
 //Note: This call will lock the cursor, it will not change as it moves.
 //To unlock, the cursor must be set back to CURSOR_AUTO.
 NS_IMETHODIMP
 nsGlobalChromeWindow::SetCursor(const nsAString& aCursor)
 {
   ErrorResult rv;
   SetCursor(aCursor, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetCursor(const nsAString& aCursor, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetCursor, (aCursor, aError), aError, );
 
   int32_t cursor;
@@ -13765,34 +13765,34 @@ nsGlobalWindow::SetCursor(const nsAStrin
   }
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::GetBrowserDOMWindow(nsIBrowserDOMWindow **aBrowserWindow)
 {
   ErrorResult rv;
   NS_IF_ADDREF(*aBrowserWindow = GetBrowserDOMWindow(rv));
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIBrowserDOMWindow*
 nsGlobalWindow::GetBrowserDOMWindow(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetBrowserDOMWindow, (aError), aError, nullptr);
 
   MOZ_ASSERT(IsChromeWindow());
   return static_cast<nsGlobalChromeWindow*>(this)->mBrowserDOMWindow;
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::SetBrowserDOMWindow(nsIBrowserDOMWindow *aBrowserWindow)
 {
   ErrorResult rv;
   SetBrowserDOMWindow(aBrowserWindow, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserWindow,
                                     ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetBrowserDOMWindow, (aBrowserWindow, aError),
                             aError, );
@@ -13803,17 +13803,17 @@ nsGlobalWindow::SetBrowserDOMWindow(nsIB
 NS_IMETHODIMP
 nsGlobalChromeWindow::NotifyDefaultButtonLoaded(nsIDOMElement* aDefaultButton)
 {
   nsCOMPtr<Element> defaultButton = do_QueryInterface(aDefaultButton);
   NS_ENSURE_ARG(defaultButton);
 
   ErrorResult rv;
   NotifyDefaultButtonLoaded(*defaultButton, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsGlobalWindow::NotifyDefaultButtonLoaded(Element& aDefaultButton,
                                           ErrorResult& aError)
 {
 #ifdef MOZ_XUL
   // Don't snap to a disabled button.
@@ -13860,17 +13860,17 @@ nsGlobalWindow::NotifyDefaultButtonLoade
 #endif
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::GetMessageManager(nsIMessageBroadcaster** aManager)
 {
   ErrorResult rv;
   NS_IF_ADDREF(*aManager = GetMessageManager(rv));
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIMessageBroadcaster*
 nsGlobalWindow::GetMessageManager(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetMessageManager, (aError), aError, nullptr);
   MOZ_ASSERT(IsChromeWindow());
   nsGlobalChromeWindow* myself = static_cast<nsGlobalChromeWindow*>(this);
@@ -13886,17 +13886,17 @@ nsGlobalWindow::GetMessageManager(ErrorR
 }
 
 NS_IMETHODIMP
 nsGlobalChromeWindow::GetGroupMessageManager(const nsAString& aGroup,
                                              nsIMessageBroadcaster** aManager)
 {
   ErrorResult rv;
   NS_IF_ADDREF(*aManager = GetGroupMessageManager(aGroup, rv));
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIMessageBroadcaster*
 nsGlobalWindow::GetGroupMessageManager(const nsAString& aGroup,
                                        ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetGroupMessageManager, (aGroup, aError), aError, nullptr);
   MOZ_ASSERT(IsChromeWindow());
@@ -14062,32 +14062,32 @@ nsGlobalWindow::IsModalContentWindow(JSC
 
 NS_IMETHODIMP
 nsGlobalWindow::GetConsole(JSContext* aCx,
                            JS::MutableHandle<JS::Value> aConsole)
 {
   ErrorResult rv;
   nsRefPtr<Console> console = GetConsole(rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   if (!GetOrCreateDOMReflector(aCx, console, aConsole)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::SetConsole(JSContext* aCx, JS::Handle<JS::Value> aValue)
 {
   ErrorResult rv;
   RedefineProperty(aCx, "console", aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 Console*
 nsGlobalWindow::GetConsole(ErrorResult& aRv)
 {
   FORWARD_TO_INNER_OR_THROW(GetConsole, (aRv), aRv, nullptr);
 
   if (!mConsole) {
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1301,17 +1301,17 @@ public:
                                int32_t aTimeout, bool aIsInterval,
                                mozilla::ErrorResult& aError);
   void ClearTimeoutOrInterval(int32_t aTimerID,
                                   mozilla::ErrorResult& aError);
   nsresult ClearTimeoutOrInterval(int32_t aTimerID) override
   {
     mozilla::ErrorResult rv;
     ClearTimeoutOrInterval(aTimerID, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   // JS specific timeout functions (JS args grabbed from context).
   nsresult SetTimeoutOrInterval(bool aIsInterval, int32_t* aReturn);
   nsresult ResetTimersForNonBackgroundWindow();
 
   // The timeout implementation functions.
   void RunTimeout(nsTimeout *aTimeout);
--- a/dom/base/nsHostObjectProtocolHandler.cpp
+++ b/dom/base/nsHostObjectProtocolHandler.cpp
@@ -564,17 +564,17 @@ nsHostObjectProtocolHandler::NewChannel2
     nsString filename;
     blob->GetName(filename);
     channel->SetContentDispositionFilename(filename);
   }
 
   ErrorResult error;
   uint64_t size = blob->GetSize(error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   channel->SetOriginalURI(uri);
   channel->SetContentType(NS_ConvertUTF16toUTF8(type));
   channel->SetContentLength(size);
 
   channel.forget(result);
 
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -546,17 +546,17 @@ nsINode::RemoveChild(nsIDOMNode* aOldChi
     return NS_ERROR_NULL_POINTER;
   }
 
   ErrorResult rv;
   RemoveChild(*oldChild, rv);
   if (!rv.Failed()) {
     NS_ADDREF(*aReturn = aOldChild);
   }
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsINode::Normalize()
 {
   // First collect list of nodes to be removed
   nsAutoTArray<nsCOMPtr<nsIContent>, 50> nodes;
 
@@ -2220,17 +2220,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
     return NS_NOINTERFACE;
   }
 
   ErrorResult rv;
   nsINode* result = ReplaceOrInsertBefore(aReplace, newChild, refChild, rv);
   if (result) {
     NS_ADDREF(*aReturn = result->AsDOMNode());
   }
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsresult
 nsINode::CompareDocumentPosition(nsIDOMNode* aOther, uint16_t* aReturn)
 {
   nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
   NS_ENSURE_ARG(other);
   *aReturn = CompareDocumentPosition(*other);
@@ -2615,29 +2615,29 @@ nsINode::QuerySelectorAll(const nsAStrin
 }
 
 nsresult
 nsINode::QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn)
 {
   ErrorResult rv;
   Element* result = nsINode::QuerySelector(aSelector, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   nsCOMPtr<nsIDOMElement> elt = do_QueryInterface(result);
   elt.forget(aReturn);
   return NS_OK;
 }
 
 nsresult
 nsINode::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn)
 {
   ErrorResult rv;
   *aReturn = nsINode::QuerySelectorAll(aSelector, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 Element*
 nsINode::GetElementById(const nsAString& aId)
 {
   MOZ_ASSERT(IsElement() || IsNodeOfType(eDOCUMENT_FRAGMENT),
              "Bogus this object for GetElementById call");
   if (IsInDoc()) {
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -1792,17 +1792,17 @@ public:
   // Helper method to remove this node from its parent. This is not exposed
   // through WebIDL.
   // Only call this if the node has a parent node.
   nsresult RemoveFromParent()
   {
     nsINode* parent = GetParentNode();
     mozilla::ErrorResult rv;
     parent->RemoveChild(*this, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   // ChildNode methods
   mozilla::dom::Element* GetPreviousElementSibling() const;
   mozilla::dom::Element* GetNextElementSibling() const;
   /**
    * Remove this node from its parent, if any.
    */
@@ -2044,17 +2044,17 @@ ToCanonicalSupports(nsINode* aPointer)
   { \
     nsINode::GetNodeValue(aNodeValue); \
     return NS_OK; \
   } \
   NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) __VA_ARGS__ override \
   { \
     mozilla::ErrorResult rv; \
     nsINode::SetNodeValue(aNodeValue, rv); \
-    return rv.ErrorCode(); \
+    return rv.StealNSResult(); \
   } \
   NS_IMETHOD GetNodeType(uint16_t* aNodeType) __VA_ARGS__ override \
   { \
     *aNodeType = nsINode::NodeType(); \
     return NS_OK; \
   } \
   NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) __VA_ARGS__ override \
   { \
@@ -2112,17 +2112,17 @@ ToCanonicalSupports(nsINode* aPointer)
   NS_IMETHOD CloneNode(bool aDeep, uint8_t aArgc, nsIDOMNode** aResult) __VA_ARGS__ override \
   { \
     if (aArgc == 0) { \
       aDeep = true; \
     } \
     mozilla::ErrorResult rv; \
     nsCOMPtr<nsINode> clone = nsINode::CloneNode(aDeep, rv); \
     if (rv.Failed()) { \
-      return rv.ErrorCode(); \
+      return rv.StealNSResult(); \
     } \
     *aResult = clone.forget().take()->AsDOMNode(); \
     return NS_OK; \
   } \
   NS_IMETHOD Normalize() __VA_ARGS__ override \
   { \
     nsINode::Normalize(); \
     return NS_OK; \
@@ -2155,23 +2155,23 @@ ToCanonicalSupports(nsINode* aPointer)
   NS_IMETHOD CompareDocumentPosition(nsIDOMNode* aOther, uint16_t* aResult) __VA_ARGS__ override \
   { \
     return nsINode::CompareDocumentPosition(aOther, aResult); \
   } \
   NS_IMETHOD GetTextContent(nsAString& aTextContent) __VA_ARGS__ override \
   { \
     mozilla::ErrorResult rv; \
     nsINode::GetTextContent(aTextContent, rv); \
-    return rv.ErrorCode(); \
+    return rv.StealNSResult(); \
   } \
   NS_IMETHOD SetTextContent(const nsAString& aTextContent) __VA_ARGS__ override \
   { \
     mozilla::ErrorResult rv; \
     nsINode::SetTextContent(aTextContent, rv); \
-    return rv.ErrorCode(); \
+    return rv.StealNSResult(); \
   } \
   NS_IMETHOD LookupPrefix(const nsAString& aNamespaceURI, nsAString& aResult) __VA_ARGS__ override \
   { \
     nsINode::LookupPrefix(aNamespaceURI, aResult); \
     return NS_OK; \
   } \
   NS_IMETHOD IsDefaultNamespace(const nsAString& aNamespaceURI, bool* aResult) __VA_ARGS__ override \
   { \
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -485,17 +485,17 @@ NS_IMETHODIMP
 nsImageLoadingContent::GetRequest(int32_t aRequestType,
                                   imgIRequest** aRequest)
 {
   NS_ENSURE_ARG_POINTER(aRequest);
 
   ErrorResult result;
   *aRequest = GetRequest(aRequestType, result).take();
 
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 NS_IMETHODIMP_(bool)
 nsImageLoadingContent::CurrentRequestHasSize()
 {
   return HaveSize(mCurrentRequest);
 }
 
@@ -597,17 +597,17 @@ nsImageLoadingContent::GetRequestType(im
 NS_IMETHODIMP
 nsImageLoadingContent::GetRequestType(imgIRequest* aRequest,
                                       int32_t* aRequestType)
 {
   NS_PRECONDITION(aRequestType, "Null out param");
 
   ErrorResult result;
   *aRequestType = GetRequestType(aRequest, result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 already_AddRefed<nsIURI>
 nsImageLoadingContent::GetCurrentURI(ErrorResult& aError)
 {
   nsCOMPtr<nsIURI> uri;
   if (mCurrentRequest) {
     mCurrentRequest->GetURI(getter_AddRefs(uri));
@@ -623,17 +623,17 @@ nsImageLoadingContent::GetCurrentURI(Err
 
 NS_IMETHODIMP
 nsImageLoadingContent::GetCurrentURI(nsIURI** aURI)
 {
   NS_ENSURE_ARG_POINTER(aURI);
 
   ErrorResult result;
   *aURI = GetCurrentURI(result).take();
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 already_AddRefed<nsIStreamListener>
 nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
                                             ErrorResult& aError)
 {
   imgLoader* loader =
     nsContentUtils::GetImgLoaderForChannel(aChannel, GetOurOwnerDoc());
@@ -680,17 +680,17 @@ nsImageLoadingContent::LoadImageWithChan
 NS_IMETHODIMP
 nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
                                             nsIStreamListener** aListener)
 {
   NS_ENSURE_ARG_POINTER(aListener);
 
   ErrorResult result;
   *aListener = LoadImageWithChannel(aChannel, result).take();
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 nsImageLoadingContent::ForceReload(const mozilla::dom::Optional<bool>& aNotify,
                                    mozilla::ErrorResult& aError)
 {
   nsCOMPtr<nsIURI> currentURI;
   GetCurrentURI(getter_AddRefs(currentURI));
@@ -720,17 +720,17 @@ nsImageLoadingContent::ForceReload(bool 
 {
   mozilla::dom::Optional<bool> notify;
   if (aArgc >= 1) {
     notify.Construct() = aNotify;
   }
 
   ErrorResult result;
   ForceReload(notify, result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsImageLoadingContent::BlockOnload(imgIRequest* aRequest)
 {
   if (aRequest == mCurrentRequest) {
     NS_ASSERTION(!(mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD),
                  "Double BlockOnload!?");
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -335,17 +335,17 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
   }
 
   if (expr) {
     // if CSP is enabled, and setTimeout/setInterval was called with a string,
     // disable the registration and log an error
     ErrorResult error;
     *aAllowEval = CheckCSPForEval(cx, aWindow, error);
     if (error.Failed() || !*aAllowEval) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
 
     MOZ_ASSERT(mExpr.IsEmpty());
     AssignJSFlatString(mExpr, expr);
 
     // Get the calling location.
     nsJSUtils::GetCallingLocation(cx, mFileName, &mLineNo);
   } else if (funobj) {
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -711,17 +711,17 @@ nsRange::IsPointInRange(nsIDOMNode* aPar
 {
   nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
   if (!parent) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   *aResult = IsPointInRange(*parent, aOffset, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsRange::IsPointInRange(nsINode& aParent, uint32_t aOffset, ErrorResult& aRv)
 {
   uint16_t compareResult = ComparePoint(aParent, aOffset, aRv);
   // If the node isn't in the range's document, it clearly isn't in the range.
   if (aRv.ErrorCode() == NS_ERROR_DOM_WRONG_DOCUMENT_ERR) {
@@ -737,17 +737,17 @@ nsRange::IsPointInRange(nsINode& aParent
 NS_IMETHODIMP
 nsRange::ComparePoint(nsIDOMNode* aParent, int32_t aOffset, int16_t* aResult)
 {
   nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
   NS_ENSURE_TRUE(parent, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
 
   ErrorResult rv;
   *aResult = ComparePoint(*parent, aOffset, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int16_t
 nsRange::ComparePoint(nsINode& aParent, uint32_t aOffset, ErrorResult& aRv)
 {
   // our range is in a good state?
   if (!mIsPositioned) {
     aRv.Throw(NS_ERROR_NOT_INITIALIZED);
@@ -789,17 +789,17 @@ nsRange::IntersectsNode(nsIDOMNode* aNod
   *aResult = false;
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   // TODO: This should throw a TypeError.
   NS_ENSURE_ARG(node);
 
   ErrorResult rv;
   *aResult = IntersectsNode(*node, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsRange::IntersectsNode(nsINode& aNode, ErrorResult& aRv)
 {
   if (!mIsPositioned) {
     aRv.Throw(NS_ERROR_NOT_INITIALIZED);
     return false;
@@ -1045,17 +1045,17 @@ nsRange::GetCommonAncestorContainer(nsID
   ErrorResult rv;
   nsINode* commonAncestor = GetCommonAncestorContainer(rv);
   if (commonAncestor) {
     NS_ADDREF(*aCommonParent = commonAncestor->AsDOMNode());
   } else {
     *aCommonParent = nullptr;
   }
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsINode*
 nsRange::IsValidBoundary(nsINode* aNode)
 {
   if (!aNode) {
     return nullptr;
   }
@@ -1116,17 +1116,17 @@ nsRange::SetStart(nsIDOMNode* aParent, i
 {
   nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
   if (!parent) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   SetStart(*parent, aOffset, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* virtual */ nsresult
 nsRange::SetStart(nsINode* aParent, int32_t aOffset)
 {
   nsINode* newRoot = IsValidBoundary(aParent);
   NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
 
@@ -1166,17 +1166,17 @@ nsRange::SetStartBefore(nsIDOMNode* aSib
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   SetStartBefore(*sibling, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsRange::SetStartAfter(nsINode& aNode, ErrorResult& aRv)
 {
   if (!nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
@@ -1191,17 +1191,17 @@ nsRange::SetStartAfter(nsIDOMNode* aSibl
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   SetStartAfter(*sibling, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsRange::SetEnd(nsINode& aNode, uint32_t aOffset, ErrorResult& aRv)
 {
  if (!nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
@@ -1215,17 +1215,17 @@ nsRange::SetEnd(nsIDOMNode* aParent, int
 {
   nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
   if (!parent) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   SetEnd(*parent, aOffset, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* virtual */ nsresult
 nsRange::SetEnd(nsINode* aParent, int32_t aOffset)
 {
   nsINode* newRoot = IsValidBoundary(aParent);
   NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
 
@@ -1265,17 +1265,17 @@ nsRange::SetEndBefore(nsIDOMNode* aSibli
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   SetEndBefore(*sibling, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsRange::SetEndAfter(nsINode& aNode, ErrorResult& aRv)
 {
   if (!nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
@@ -1290,17 +1290,17 @@ nsRange::SetEndAfter(nsIDOMNode* aSiblin
 {
   nsCOMPtr<nsINode> sibling = do_QueryInterface(aSibling);
   if (!sibling) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   SetEndAfter(*sibling, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsRange::Collapse(bool aToStart)
 {
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
@@ -1316,17 +1316,17 @@ nsRange::Collapse(bool aToStart)
 NS_IMETHODIMP
 nsRange::SelectNode(nsIDOMNode* aN)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aN);
   NS_ENSURE_TRUE(node, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
 
   ErrorResult rv;
   SelectNode(*node, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsRange::SelectNode(nsINode& aNode, ErrorResult& aRv)
 {
   if (!nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
@@ -1352,17 +1352,17 @@ nsRange::SelectNode(nsINode& aNode, Erro
 NS_IMETHODIMP
 nsRange::SelectNodeContents(nsIDOMNode* aN)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aN);
   NS_ENSURE_TRUE(node, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
 
   ErrorResult rv;
   SelectNodeContents(*node, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsRange::SelectNodeContents(nsINode& aNode, ErrorResult& aRv)
 {
   if (!nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
@@ -1647,22 +1647,22 @@ CollapseRangeAfterDelete(nsRange* aRange
     return NS_OK;
   }
 
   // aRange isn't collapsed so figure out the appropriate place to collapse!
   // First get both end points and their common ancestor.
 
   ErrorResult rv;
   nsCOMPtr<nsINode> commonAncestor = aRange->GetCommonAncestorContainer(rv);
-  if (rv.Failed()) return rv.ErrorCode();
+  if (rv.Failed()) return rv.StealNSResult();
 
   nsCOMPtr<nsINode> startContainer = aRange->GetStartContainer(rv);
-  if (rv.Failed()) return rv.ErrorCode();
+  if (rv.Failed()) return rv.StealNSResult();
   nsCOMPtr<nsINode> endContainer = aRange->GetEndContainer(rv);
-  if (rv.Failed()) return rv.ErrorCode();
+  if (rv.Failed()) return rv.StealNSResult();
 
   // Collapse to one of the end points if they are already in the
   // commonAncestor. This should work ok since this method is called
   // immediately after a delete or extract that leaves no content
   // between the 2 end points!
 
   if (startContainer == commonAncestor)
     return aRange->Collapse(true);
@@ -1683,17 +1683,17 @@ CollapseRangeAfterDelete(nsRange* aRange
 
     nodeToSelect = parent;
   }
 
   if (!nodeToSelect)
     return NS_ERROR_FAILURE; // This should never happen!
 
   aRange->SelectNode(*nodeToSelect, rv);
-  if (rv.Failed()) return rv.ErrorCode();
+  if (rv.Failed()) return rv.StealNSResult();
 
   return aRange->Collapse(false);
 }
 
 /**
  * Split a data node into two parts.
  *
  * @param aStartNode          The original node we are trying to split.
@@ -1720,17 +1720,17 @@ static nsresult SplitDataNode(nsIDOMChar
 }
 
 NS_IMETHODIMP
 PrependChild(nsINode* aParent, nsINode* aChild)
 {
   nsCOMPtr<nsINode> first = aParent->GetFirstChild();
   ErrorResult rv;
   aParent->InsertBefore(*aChild, first, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 // Helper function for CutContents, making sure that the current node wasn't
 // removed by mutation events (bug 766426)
 static bool
 ValidateCurrentNode(nsRange* aRange, RangeSubtreeIterator& aIter)
 {
   bool before, after;
@@ -2054,17 +2054,17 @@ NS_IMETHODIMP
 nsRange::CompareBoundaryPoints(uint16_t aHow, nsIDOMRange* aOtherRange,
                                int16_t* aCmpRet)
 {
   nsRange* otherRange = static_cast<nsRange*>(aOtherRange);
   NS_ENSURE_TRUE(otherRange, NS_ERROR_NULL_POINTER);
 
   ErrorResult rv;
   *aCmpRet = CompareBoundaryPoints(aHow, *otherRange, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int16_t
 nsRange::CompareBoundaryPoints(uint16_t aHow, nsRange& aOtherRange,
                                ErrorResult& rv)
 {
   if (!mIsPositioned || !aOtherRange.IsPositioned()) {
     rv.Throw(NS_ERROR_NOT_INITIALIZED);
@@ -2132,27 +2132,27 @@ nsRange::CloneParentsBetween(nsINode *aA
   nsCOMPtr<nsINode> parent = aNode->GetParentNode();
 
   while(parent && parent != aAncestor)
   {
     ErrorResult rv;
     nsCOMPtr<nsINode> clone = parent->CloneNode(false, rv);
 
     if (rv.Failed()) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
     if (!clone) {
       return NS_ERROR_FAILURE;
     }
 
     if (! firstParent) {
       firstParent = lastParent = clone;
     } else {
       clone->AppendChild(*lastParent, rv);
-      if (rv.Failed()) return rv.ErrorCode();
+      if (rv.Failed()) return rv.StealNSResult();
 
       lastParent = clone;
     }
 
     parent = parent->GetParentNode();
   }
 
   *aClosestAncestor  = firstParent;
@@ -2164,17 +2164,17 @@ nsRange::CloneParentsBetween(nsINode *aA
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
 {
   ErrorResult rv;
   *aReturn = CloneContents(rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DocumentFragment>
 nsRange::CloneContents(ErrorResult& aRv)
 {
   nsCOMPtr<nsINode> commonAncestor = GetCommonAncestorContainer(aRv);
   MOZ_ASSERT(!aRv.Failed(), "GetCommonAncestorContainer() shouldn't fail!");
 
@@ -2400,17 +2400,17 @@ nsRange::InsertNode(nsIDOMNode* aNode)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   if (!node) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
   ErrorResult rv;
   InsertNode(*node, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsRange::InsertNode(nsINode& aNode, ErrorResult& aRv)
 {
   if (!nsContentUtils::CanCallerAccess(&aNode)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
@@ -2497,17 +2497,17 @@ NS_IMETHODIMP
 nsRange::SurroundContents(nsIDOMNode* aNewParent)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNewParent);
   if (!node) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
   ErrorResult rv;
   SurroundContents(*node, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsRange::SurroundContents(nsINode& aNewParent, ErrorResult& aRv)
 {
   if (!nsContentUtils::CanCallerAccess(&aNewParent)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -80,17 +80,17 @@ nsScreen::GetPixelDepth(ErrorResult& aRv
 }
 
 #define FORWARD_LONG_GETTER(_name)                                              \
   NS_IMETHODIMP                                                                 \
   nsScreen::Get ## _name(int32_t* aOut)                                         \
   {                                                                             \
     ErrorResult rv;                                                             \
     *aOut = Get ## _name(rv);                                                   \
-    return rv.ErrorCode();                                                      \
+    return rv.StealNSResult();                                                  \
   }
 
 FORWARD_LONG_GETTER(AvailWidth)
 FORWARD_LONG_GETTER(AvailHeight)
 FORWARD_LONG_GETTER(Width)
 FORWARD_LONG_GETTER(Height)
 
 FORWARD_LONG_GETTER(Top)
--- a/dom/base/nsXMLHttpRequest.cpp
+++ b/dom/base/nsXMLHttpRequest.cpp
@@ -593,17 +593,17 @@ static void LogMessage(const char* aWarn
 
 /* readonly attribute nsIDOMDocument responseXML; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
 {
   ErrorResult rv;
   nsIDocument* responseXML = GetResponseXML(rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   if (!responseXML) {
     *aResponseXML = nullptr;
     return NS_OK;
   }
 
   return CallQueryInterface(responseXML, aResponseXML);
@@ -701,17 +701,17 @@ nsXMLHttpRequest::AppendToResponseText(c
 /* readonly attribute AString responseText; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
 {
   ErrorResult rv;
   nsString responseText;
   GetResponseText(responseText, rv);
   aResponseText = responseText;
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsXMLHttpRequest::GetResponseText(nsString& aResponseText, ErrorResult& aRv)
 {
   aResponseText.Truncate();
 
   if (mResponseType != XML_HTTP_RESPONSE_TYPE_DEFAULT &&
@@ -900,17 +900,17 @@ NS_IMETHODIMP nsXMLHttpRequest::SetRespo
   } else if (aResponseType.EqualsLiteral("moz-blob")) {
     responseType = XML_HTTP_RESPONSE_TYPE_MOZ_BLOB;
   } else {
     return NS_OK;
   }
 
   ErrorResult rv;
   SetResponseType(responseType, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsXMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aType,
                                   ErrorResult& aRv)
 {
   SetResponseType(ResponseTypeEnum(static_cast<int>(aType)), aRv);
 }
@@ -947,17 +947,17 @@ nsXMLHttpRequest::SetResponseType(nsXMLH
 }
 
 /* readonly attribute jsval response; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponse(JSContext *aCx, JS::MutableHandle<JS::Value> aResult)
 {
   ErrorResult rv;
   GetResponse(aCx, aResult, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsXMLHttpRequest::GetResponse(JSContext* aCx,
                               JS::MutableHandle<JS::Value> aResponse,
                               ErrorResult& aRv)
 {
   switch (mResponseType) {
@@ -1358,17 +1358,17 @@ nsXMLHttpRequest::GetAllResponseHeaders(
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::GetResponseHeader(const nsACString& aHeader,
                                     nsACString& aResult)
 {
   ErrorResult rv;
   GetResponseHeader(aHeader, aResult, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsXMLHttpRequest::GetResponseHeader(const nsACString& header,
                                     nsACString& _retval, ErrorResult& aRv)
 {
   _retval.SetIsVoid(true);
 
@@ -3179,17 +3179,17 @@ nsXMLHttpRequest::GetTimeout(uint32_t *a
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::SetTimeout(uint32_t aTimeout)
 {
   ErrorResult rv;
   SetTimeout(aTimeout, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsXMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
 {
   if (!(mState & (XML_HTTP_REQUEST_ASYNC | XML_HTTP_REQUEST_UNSENT)) &&
       HasOrHasHadOwner()) {
     /* Timeout is not supported for synchronous requests with an owning window,
@@ -3328,17 +3328,17 @@ nsXMLHttpRequest::WithCredentials()
   return !!(mState & XML_HTTP_REQUEST_AC_WITH_CREDENTIALS);
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::SetWithCredentials(bool aWithCredentials)
 {
   ErrorResult rv;
   SetWithCredentials(aWithCredentials, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsXMLHttpRequest::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
 {
   // Return error if we're already processing a request.  Note that we can't use
   // ReadyState() here, because it can't differentiate between "opened" and
   // "sent", so we use mState directly.
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -951,17 +951,17 @@ MatchByVaryHeader(mozIStorageConnection*
     rv = state->GetUTF8String(0, name);
     if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
     rv = state->GetUTF8String(1, value);
     if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
     ErrorResult errorResult;
 
     cachedHeaders->Append(name, value, errorResult);
-    if (errorResult.Failed()) { return errorResult.ErrorCode(); };
+    if (errorResult.Failed()) { return errorResult.StealNSResult(); };
   }
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   nsRefPtr<InternalHeaders> queryHeaders =
     TypeUtils::ToInternalHeaders(aRequest.headers());
 
   // Assume the vary headers match until we find a conflict
   bool varyHeadersMatch = true;
--- a/dom/datastore/DataStoreDB.cpp
+++ b/dom/datastore/DataStoreDB.cpp
@@ -149,17 +149,17 @@ DataStoreDB::Open(IDBTransactionMode aMo
   nsresult rv = CreateFactoryIfNeeded();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   ErrorResult error;
   mRequest = mFactory->Open(mDatabaseName, DATASTOREDB_VERSION, error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   rv = AddEventListeners();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   mState = Active;
@@ -229,17 +229,17 @@ DataStoreDB::UpgradeSchema(nsIDOMEvent* 
 #endif
 
   AutoSafeJSContext cx;
 
   ErrorResult error;
   JS::Rooted<JS::Value> result(cx);
   mRequest->GetResult(&result, error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   MOZ_ASSERT(result.isObject());
 
   IDBDatabase* database = nullptr;
   nsresult rv = UNWRAP_OBJECT(IDBDatabase, &result.toObject(), database);
   if (NS_FAILED(rv)) {
     NS_WARNING("Didn't get the object we expected!");
@@ -248,42 +248,42 @@ DataStoreDB::UpgradeSchema(nsIDOMEvent* 
 
   {
     IDBObjectStoreParameters params;
     params.Init(NS_LITERAL_STRING("{ \"autoIncrement\": true }"));
     nsRefPtr<IDBObjectStore> store =
       database->CreateObjectStore(NS_LITERAL_STRING(DATASTOREDB_NAME),
                                   params, error);
     if (NS_WARN_IF(error.Failed())) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
   }
 
   nsRefPtr<IDBObjectStore> store;
 
   {
     IDBObjectStoreParameters params;
     params.Init(NS_LITERAL_STRING("{ \"autoIncrement\": true, \"keyPath\": \"internalRevisionId\" }"));
 
     store =
       database->CreateObjectStore(NS_LITERAL_STRING(DATASTOREDB_REVISION),
                                   params, error);
     if (NS_WARN_IF(error.Failed())) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
   }
 
   {
     IDBIndexParameters params;
     params.Init(NS_LITERAL_STRING("{ \"unique\": true }"));
     nsRefPtr<IDBIndex> index =
       store->CreateIndex(NS_LITERAL_STRING(DATASTOREDB_REVISION_INDEX),
                          NS_LITERAL_STRING("revisionId"), params, error);
     if (NS_WARN_IF(error.Failed())) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
   }
 
   return NS_OK;
 }
 
 nsresult
 DataStoreDB::DatabaseOpened()
@@ -291,17 +291,17 @@ DataStoreDB::DatabaseOpened()
   MOZ_ASSERT(NS_IsMainThread());
 
   AutoSafeJSContext cx;
 
   ErrorResult error;
   JS::Rooted<JS::Value> result(cx);
   mRequest->GetResult(&result, error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   MOZ_ASSERT(result.isObject());
 
   nsresult rv = UNWRAP_OBJECT(IDBDatabase, &result.toObject(), mDatabase);
   if (NS_FAILED(rv)) {
     NS_WARNING("Didn't get the object we expected!");
     return rv;
@@ -318,17 +318,17 @@ DataStoreDB::DatabaseOpened()
   StringOrStringSequence objectStores;
   objectStores.RawSetAsStringSequence().AppendElements(mObjectStores);
 
   nsRefPtr<IDBTransaction> txn;
   error = mDatabase->Transaction(objectStores,
                                  mTransactionMode,
                                  getter_AddRefs(txn));
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   mTransaction = txn.forget();
   return NS_OK;
 }
 
 nsresult
 DataStoreDB::Delete()
@@ -346,17 +346,17 @@ DataStoreDB::Delete()
     mDatabase->Close();
     mDatabase = nullptr;
   }
 
   ErrorResult error;
   nsRefPtr<IDBOpenDBRequest> request =
     mFactory->DeleteDatabase(mDatabaseName, IDBOpenDBOptions(), error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   return NS_OK;
 }
 
 indexedDB::IDBTransaction*
 DataStoreDB::Transaction() const
 {
--- a/dom/datastore/DataStoreRevision.cpp
+++ b/dom/datastore/DataStoreRevision.cpp
@@ -60,17 +60,17 @@ DataStoreRevision::AddRevision(JSContext
   JS::Rooted<JS::Value> value(aCx);
   if (!ToJSValue(aCx, data, &value)) {
     return NS_ERROR_FAILURE;
   }
 
   ErrorResult error;
   mRequest = aStore->Put(aCx, value, JS::UndefinedHandleValue, error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   rv = mRequest->EventTarget::AddEventListener(NS_LITERAL_STRING("success"),
                                                this, false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
--- a/dom/datastore/DataStoreService.cpp
+++ b/dom/datastore/DataStoreService.cpp
@@ -610,17 +610,17 @@ public:
   CreateFirstRevision(IDBTransaction* aTxn)
   {
     MOZ_ASSERT(aTxn);
 
     ErrorResult error;
     nsRefPtr<IDBObjectStore> store =
       aTxn->ObjectStore(NS_LITERAL_STRING(DATASTOREDB_REVISION), error);
     if (NS_WARN_IF(error.Failed())) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
     MOZ_ASSERT(store);
 
     nsRefPtr<RevisionAddedEnableStoreCallback> callback =
       new RevisionAddedEnableStoreCallback(mAppId, mName, mManifestURL);
 
     // Note: this cx is only used for rooting and AddRevision, neither of which
     // actually care which compartment we're in.
@@ -664,17 +664,17 @@ public:
 #endif
 
     AutoSafeJSContext cx;
 
     ErrorResult error;
     JS::Rooted<JS::Value> result(cx);
     request->GetResult(cx, &result, error);
     if (NS_WARN_IF(error.Failed())) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
 
     // This means that the content is a IDBCursor, so the first revision already
     // exists.
     if (result.isObject()) {
 #ifdef DEBUG
       IDBCursor* cursor = nullptr;
       error = UNWRAP_OBJECT(IDBCursor, &result.toObject(), cursor);
@@ -955,17 +955,17 @@ DataStoreService::GetDataStores(nsIDOMWi
   if (!window) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(window);
   ErrorResult rv;
   nsRefPtr<Promise> promise = Promise::Create(global, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   nsCOMPtr<nsIDocument> document = window->GetDoc();
   MOZ_ASSERT(document);
 
   nsCOMPtr<nsIPrincipal> principal = document->NodePrincipal();
   MOZ_ASSERT(principal);
 
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -3700,17 +3700,17 @@ nsDOMDeviceStorage::IsAvailable()
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::Add(nsIDOMBlob *aBlob, nsIDOMDOMRequest * *_retval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = Add(aBlob, rv);
   request.forget(_retval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMRequest>
 nsDOMDeviceStorage::Add(nsIDOMBlob* aBlob, ErrorResult& aRv)
 {
   if (!aBlob) {
     return nullptr;
   }
@@ -3749,17 +3749,17 @@ nsDOMDeviceStorage::Add(nsIDOMBlob* aBlo
 NS_IMETHODIMP
 nsDOMDeviceStorage::AddNamed(nsIDOMBlob *aBlob,
                              const nsAString & aPath,
                              nsIDOMDOMRequest * *_retval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = AddNamed(aBlob, aPath, rv);
   request.forget(_retval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMRequest>
 nsDOMDeviceStorage::AddNamed(nsIDOMBlob* aBlob, const nsAString& aPath,
                              ErrorResult& aRv)
 {
   return AddOrAppendNamed(aBlob, aPath,
                           DEVICE_STORAGE_REQUEST_CREATE, aRv);
@@ -3845,27 +3845,27 @@ nsDOMDeviceStorage::AddOrAppendNamed(nsI
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::Get(const nsAString& aPath, nsIDOMDOMRequest** aRetval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = Get(aPath, rv);
   request.forget(aRetval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::GetEditable(const nsAString& aPath,
                                 nsIDOMDOMRequest** aRetval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = GetEditable(aPath, rv);
   request.forget(aRetval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMRequest>
 nsDOMDeviceStorage::GetInternal(const nsAString& aPath, bool aEditable,
                                 ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -3922,17 +3922,17 @@ nsDOMDeviceStorage::GetInternal(nsPIDOMW
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::Delete(const nsAString& aPath, nsIDOMDOMRequest** aRetval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = Delete(aPath, rv);
   request.forget(aRetval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMRequest>
 nsDOMDeviceStorage::Delete(const nsAString& aPath, ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
@@ -3984,17 +3984,17 @@ nsDOMDeviceStorage::DeleteInternal(nsPID
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::FreeSpace(nsIDOMDOMRequest** aRetval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = FreeSpace(rv);
   request.forget(aRetval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMRequest>
 nsDOMDeviceStorage::FreeSpace(ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
@@ -4018,17 +4018,17 @@ nsDOMDeviceStorage::FreeSpace(ErrorResul
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::UsedSpace(nsIDOMDOMRequest** aRetval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = UsedSpace(rv);
   request.forget(aRetval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMRequest>
 nsDOMDeviceStorage::UsedSpace(ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
@@ -4056,17 +4056,17 @@ nsDOMDeviceStorage::UsedSpace(ErrorResul
 }
 
 NS_IMETHODIMP
 nsDOMDeviceStorage::Available(nsIDOMDOMRequest** aRetval)
 {
   ErrorResult rv;
   nsRefPtr<DOMRequest> request = Available(rv);
   request.forget(aRetval);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMRequest>
 nsDOMDeviceStorage::Available(ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
--- a/dom/events/ClipboardEvent.cpp
+++ b/dom/events/ClipboardEvent.cpp
@@ -39,17 +39,17 @@ ClipboardEvent::InitClipboardEvent(const
                                    nsIDOMDataTransfer* aClipboardData)
 {
   nsCOMPtr<DataTransfer> clipboardData = do_QueryInterface(aClipboardData);
   // Null clipboardData is OK
 
   ErrorResult rv;
   InitClipboardEvent(aType, aCanBubble, aCancelable, clipboardData, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 ClipboardEvent::InitClipboardEvent(const nsAString& aType, bool aCanBubble,
                                    bool aCancelable,
                                    DataTransfer* aClipboardData,
                                    ErrorResult& aError)
 {
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -321,17 +321,17 @@ DataTransfer::GetFiles(ErrorResult& aRv)
   return mFiles;
 }
 
 NS_IMETHODIMP
 DataTransfer::GetFiles(nsIDOMFileList** aFileList)
 {
   ErrorResult rv;
   NS_IF_ADDREF(*aFileList = GetFiles(rv));
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<DOMStringList>
 DataTransfer::Types()
 {
   nsRefPtr<DOMStringList> types = new DOMStringList();
   if (mItems.Length()) {
     bool addFile = false;
@@ -414,17 +414,17 @@ DataTransfer::GetData(const nsAString& a
   }
 }
 
 NS_IMETHODIMP
 DataTransfer::GetData(const nsAString& aFormat, nsAString& aData)
 {
   ErrorResult rv;
   GetData(aFormat, aData, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DataTransfer::SetData(const nsAString& aFormat, const nsAString& aData,
                       ErrorResult& aRv)
 {
   nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID);
   if (!variant) {
@@ -437,17 +437,17 @@ DataTransfer::SetData(const nsAString& a
   aRv = MozSetDataAt(aFormat, variant, 0);
 }
 
 NS_IMETHODIMP
 DataTransfer::SetData(const nsAString& aFormat, const nsAString& aData)
 {
   ErrorResult rv;
   SetData(aFormat, aData, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DataTransfer::ClearData(const Optional<nsAString>& aFormat, ErrorResult& aRv)
 {
   if (mReadOnly) {
     aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     return;
@@ -466,17 +466,17 @@ DataTransfer::ClearData(const Optional<n
 
 NS_IMETHODIMP
 DataTransfer::ClearData(const nsAString& aFormat)
 {
   Optional<nsAString> format;
   format = &aFormat;
   ErrorResult rv;
   ClearData(format, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 DataTransfer::GetMozItemCount(uint32_t* aCount)
 {
   *aCount = MozItemCount();
   return NS_OK;
 }
@@ -551,17 +551,17 @@ DataTransfer::MozTypesAt(uint32_t aIndex
 }
 
 NS_IMETHODIMP
 DataTransfer::MozTypesAt(uint32_t aIndex, nsISupports** aTypes)
 {
   ErrorResult rv;
   nsRefPtr<DOMStringList> types = MozTypesAt(aIndex, rv);
   types.forget(aTypes);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
                            nsIVariant** aData)
 {
   *aData = nullptr;
 
@@ -784,17 +784,17 @@ DataTransfer::MozClearDataAtHelper(const
      mItems.RemoveElementAt(aIndex);
 }
 
 NS_IMETHODIMP
 DataTransfer::MozClearDataAt(const nsAString& aFormat, uint32_t aIndex)
 {
   ErrorResult rv;
   MozClearDataAt(aFormat, aIndex, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DataTransfer::SetDragImage(Element& aImage, int32_t aX, int32_t aY,
                            ErrorResult& aRv)
 {
   if (mReadOnly) {
     aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
@@ -809,17 +809,17 @@ DataTransfer::SetDragImage(Element& aIma
 NS_IMETHODIMP
 DataTransfer::SetDragImage(nsIDOMElement* aImage, int32_t aX, int32_t aY)
 {
   ErrorResult rv;
   nsCOMPtr<Element> image = do_QueryInterface(aImage);
   if (image) {
     SetDragImage(*image, aX, aY, rv);
   }
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DataTransfer::AddElement(Element& aElement, ErrorResult& aRv)
 {
   if (mReadOnly) {
     aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     return;
@@ -833,17 +833,17 @@ DataTransfer::AddElement(nsIDOMElement* 
 {
   NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_TRUE(element, NS_ERROR_INVALID_ARG);
 
   ErrorResult rv;
   AddElement(*element, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsresult
 DataTransfer::Clone(nsISupports* aParent, uint32_t aEventType,
                     bool aUserCancelled, bool aIsCrossDomainSubFrameDrop,
                     DataTransfer** aNewDataTransfer)
 {
   DataTransfer* newDataTransfer =
--- a/dom/events/JSEventHandler.cpp
+++ b/dom/events/JSEventHandler.cpp
@@ -161,17 +161,17 @@ JSEventHandler::HandleEvent(nsIDOMEvent*
     }
 
     nsRefPtr<OnErrorEventHandlerNonNull> handler =
       mTypedHandler.OnErrorEventHandler();
     ErrorResult rv;
     bool handled = handler->Call(mTarget, msgOrEvent, fileName, lineNumber,
                                  columnNumber, error, rv);
     if (rv.Failed()) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
 
     if (handled) {
       event->PreventDefaultInternal(isChromeHandler);
     }
     return NS_OK;
   }
 
@@ -179,17 +179,17 @@ JSEventHandler::HandleEvent(nsIDOMEvent*
     MOZ_ASSERT(mEventName == nsGkAtoms::onbeforeunload);
 
     nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handler =
       mTypedHandler.OnBeforeUnloadEventHandler();
     ErrorResult rv;
     nsString retval;
     handler->Call(mTarget, *(aEvent->InternalDOMEvent()), retval, rv);
     if (rv.Failed()) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
 
     nsCOMPtr<nsIDOMBeforeUnloadEvent> beforeUnload = do_QueryInterface(aEvent);
     NS_ENSURE_STATE(beforeUnload);
 
     if (!DOMStringIsNull(retval)) {
       event->PreventDefaultInternal(isChromeHandler);
 
@@ -208,17 +208,17 @@ JSEventHandler::HandleEvent(nsIDOMEvent*
   }
 
   MOZ_ASSERT(mTypedHandler.Type() == TypedEventHandler::eNormal);
   ErrorResult rv;
   nsRefPtr<EventHandlerNonNull> handler = mTypedHandler.NormalEventHandler();
   JS::Rooted<JS::Value> retval(CycleCollectedJSRuntime::Get()->Runtime());
   handler->Call(mTarget, *(aEvent->InternalDOMEvent()), &retval, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   // If the handler returned false and its sense is not reversed,
   // or the handler returned true and its sense is reversed from
   // the usual (false means cancel), then prevent default.
   if (retval.isBoolean() &&
       retval.toBoolean() == (mEventName == nsGkAtoms::onerror ||
                              mEventName == nsGkAtoms::onmouseover)) {
--- a/dom/events/MessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -65,17 +65,17 @@ MessageEvent::WrapObjectInternal(JSConte
   return mozilla::dom::MessageEventBinding::Wrap(aCx, this, aGivenProto);
 }
 
 NS_IMETHODIMP
 MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
 {
   ErrorResult rv;
   GetData(aCx, aData, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
                       ErrorResult& aRv)
 {
   JS::ExposeValueToActiveJS(mData);
   aData.set(mData);
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -215,33 +215,33 @@ FetchDriver::BasicFetch()
     }
 
     nsRefPtr<InternalResponse> response = new InternalResponse(200, NS_LITERAL_CSTRING("OK"));
     {
       ErrorResult result;
       uint64_t size = blob->GetSize(result);
       if (NS_WARN_IF(result.Failed())) {
         FailWithNetworkError();
-        return result.ErrorCode();
+        return result.StealNSResult();
       }
 
       nsAutoString sizeStr;
       sizeStr.AppendInt(size);
       response->Headers()->Append(NS_LITERAL_CSTRING("Content-Length"), NS_ConvertUTF16toUTF8(sizeStr), result);
       if (NS_WARN_IF(result.Failed())) {
         FailWithNetworkError();
-        return result.ErrorCode();
+        return result.StealNSResult();
       }
 
       nsAutoString type;
       blob->GetType(type);
       response->Headers()->Append(NS_LITERAL_CSTRING("Content-Type"), NS_ConvertUTF16toUTF8(type), result);
       if (NS_WARN_IF(result.Failed())) {
         FailWithNetworkError();
-        return result.ErrorCode();
+        return result.StealNSResult();
       }
     }
 
     nsCOMPtr<nsIInputStream> stream;
     rv = blob->GetInternalStream(getter_AddRefs(stream));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       FailWithNetworkError();
       return rv;
--- a/dom/filehandle/FileHandle.cpp
+++ b/dom/filehandle/FileHandle.cpp
@@ -469,17 +469,17 @@ FileHandleBase::OpenInputStream(bool aWh
 {
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
   MOZ_ASSERT(mRequestMode == PARALLEL,
              "Don't call me in other than parallel mode!");
 
   // Common state checking
   ErrorResult error;
   if (!CheckState(error)) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   // Do nothing if the window is closed
   if (!CheckWindow()) {
     return NS_OK;
   }
 
   nsRefPtr<OpenStreamHelper> helper =
--- a/dom/html/HTMLBodyElement.cpp
+++ b/dom/html/HTMLBodyElement.cpp
@@ -199,102 +199,102 @@ NS_IMPL_ISUPPORTS_INHERITED(HTMLBodyElem
 
 NS_IMPL_ELEMENT_CLONE(HTMLBodyElement)
 
 NS_IMETHODIMP 
 HTMLBodyElement::SetBackground(const nsAString& aBackground)
 {
   ErrorResult rv;
   SetBackground(aBackground, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLBodyElement::GetBackground(nsAString& aBackground)
 {
   DOMString background;
   GetBackground(background);
   background.ToString(aBackground);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 HTMLBodyElement::SetVLink(const nsAString& aVLink)
 {
   ErrorResult rv;
   SetVLink(aVLink, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLBodyElement::GetVLink(nsAString& aVLink)
 {
   DOMString vLink;
   GetVLink(vLink);
   vLink.ToString(aVLink);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 HTMLBodyElement::SetALink(const nsAString& aALink)
 {
   ErrorResult rv;
   SetALink(aALink, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLBodyElement::GetALink(nsAString& aALink)
 {
   DOMString aLink;
   GetALink(aLink);
   aLink.ToString(aALink);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 HTMLBodyElement::SetLink(const nsAString& aLink)
 {
   ErrorResult rv;
   SetLink(aLink, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLBodyElement::GetLink(nsAString& aLink)
 {
   DOMString link;
   GetLink(link);
   link.ToString(aLink);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 HTMLBodyElement::SetText(const nsAString& aText)
 {
   ErrorResult rv;
   SetText(aText, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLBodyElement::GetText(nsAString& aText)
 {
   DOMString text;
   GetText(text);
   text.ToString(aText);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 HTMLBodyElement::SetBgColor(const nsAString& aBgColor)
 {
   ErrorResult rv;
   SetBgColor(aBgColor, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLBodyElement::GetBgColor(nsAString& aBgColor)
 {
   DOMString bgColor;
   GetBgColor(bgColor);
   bgColor.ToString(aBgColor);
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -569,17 +569,17 @@ HTMLCanvasElement::ToBlob(JSContext* aCx
       nsRefPtr<File> newBlob = new File(mGlobal, blob->Impl());
 
       mozilla::ErrorResult error;
       mFileCallback->Call(*newBlob, error);
 
       mGlobal = nullptr;
       mFileCallback = nullptr;
 
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
 
     nsCOMPtr<nsIGlobalObject> mGlobal;
     nsRefPtr<FileCallback> mFileCallback;
   };
 
   nsCOMPtr<nsIGlobalObject> global = OwnerDoc()->GetScopeObject();
   MOZ_ASSERT(global);
@@ -723,17 +723,17 @@ CreateContextForCanvas(CanvasContextType
 }
 
 nsresult
 HTMLCanvasElement::GetContext(const nsAString& aContextId,
                               nsISupports** aContext)
 {
   ErrorResult rv;
   *aContext = GetContext(nullptr, aContextId, JS::NullHandleValue, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<nsISupports>
 HTMLCanvasElement::GetContext(JSContext* aCx,
                               const nsAString& aContextId,
                               JS::Handle<JS::Value> aContextOptions,
                               ErrorResult& rv)
 {
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -265,17 +265,17 @@ HTMLFormElement::Submit(ErrorResult& aRv
   aRv = DoSubmitOrReset(nullptr, NS_FORM_SUBMIT);
 }
 
 NS_IMETHODIMP
 HTMLFormElement::Submit()
 {
   ErrorResult rv;
   Submit(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLFormElement::Reset()
 {
   InternalFormEvent event(true, NS_FORM_RESET);
   EventDispatcher::Dispatch(static_cast<nsIContent*>(this), nullptr, &event);
   return NS_OK;
--- a/dom/html/HTMLFrameSetElement.cpp
+++ b/dom/html/HTMLFrameSetElement.cpp
@@ -28,34 +28,34 @@ NS_IMPL_ISUPPORTS_INHERITED(HTMLFrameSet
 
 NS_IMPL_ELEMENT_CLONE(HTMLFrameSetElement)
 
 NS_IMETHODIMP 
 HTMLFrameSetElement::SetCols(const nsAString& aCols)
 {
   ErrorResult rv;
   SetCols(aCols, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLFrameSetElement::GetCols(nsAString& aCols)
 {
   DOMString cols;
   GetCols(cols);
   cols.ToString(aCols);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 HTMLFrameSetElement::SetRows(const nsAString& aRows)
 {
   ErrorResult rv;
   SetRows(aRows, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLFrameSetElement::GetRows(nsAString& aRows)
 {
   DOMString rows;
   GetRows(rows);
   rows.ToString(aRows);
--- a/dom/html/HTMLImageElement.cpp
+++ b/dom/html/HTMLImageElement.cpp
@@ -275,33 +275,33 @@ HTMLImageElement::GetHeight(uint32_t* aH
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLImageElement::SetHeight(uint32_t aHeight)
 {
   ErrorResult rv;
   SetHeight(aHeight, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLImageElement::GetWidth(uint32_t* aWidth)
 {
   *aWidth = Width();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLImageElement::SetWidth(uint32_t aWidth)
 {
   ErrorResult rv;
   SetWidth(aWidth, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 HTMLImageElement::ParseAttribute(int32_t aNamespaceID,
                                  nsIAtom* aAttribute,
                                  const nsAString& aValue,
                                  nsAttrValue& aResult)
 {
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -1605,17 +1605,17 @@ HTMLInputElement::GetHeight(uint32_t* aH
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLInputElement::SetHeight(uint32_t aHeight)
 {
   ErrorResult rv;
   SetHeight(aHeight, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLInputElement::GetIndeterminate(bool* aValue)
 {
   *aValue = Indeterminate();
   return NS_OK;
 }
@@ -1659,17 +1659,17 @@ HTMLInputElement::GetWidth(uint32_t* aWi
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLInputElement::SetWidth(uint32_t aWidth)
 {
   ErrorResult rv;
   SetWidth(aWidth, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLInputElement::GetValue(nsAString& aValue)
 {
   GetValueInternal(aValue);
 
   // Don't return non-sanitized value for types that are experimental on mobile.
@@ -1870,17 +1870,17 @@ HTMLInputElement::SetValue(const nsAStri
   }
 }
 
 NS_IMETHODIMP
 HTMLInputElement::SetValue(const nsAString& aValue)
 {
   ErrorResult rv;
   SetValue(aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsGenericHTMLElement*
 HTMLInputElement::GetList() const
 {
   nsAutoString dataListId;
   GetAttr(kNameSpaceID_None, nsGkAtoms::list, dataListId);
   if (dataListId.IsEmpty()) {
@@ -2084,17 +2084,17 @@ HTMLInputElement::SetValueAsNumber(doubl
   SetValue(Decimal::fromDouble(aValueAsNumber));
 }
 
 NS_IMETHODIMP
 HTMLInputElement::SetValueAsNumber(double aValueAsNumber)
 {
   ErrorResult rv;
   SetValueAsNumber(aValueAsNumber, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 Decimal
 HTMLInputElement::GetMinimum() const
 {
   MOZ_ASSERT(DoesValueAsNumberApply(),
              "GetMinimum() should only be used for types that allow .valueAsNumber");
 
@@ -2400,17 +2400,17 @@ HTMLInputElement::MozSetFileNameArray(co
 
   Sequence<nsString> list;
   for (uint32_t i = 0; i < aLength; ++i) {
     list.AppendElement(nsDependentString(aFileNames[i]));
   }
 
   ErrorResult rv;
   MozSetFileNameArray(list, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 HTMLInputElement::MozIsTextField(bool aExcludePassword)
 {
   // TODO: temporary until bug 773205 is fixed.
   if (IsExperimentalMobileType(mType)) {
     return false;
@@ -2449,17 +2449,17 @@ HTMLInputElement::SetUserInput(const nsA
   }
 
   if (mType == NS_FORM_INPUT_FILE)
   {
     Sequence<nsString> list;
     list.AppendElement(aValue);
     ErrorResult rv;
     MozSetFileNameArray(list, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   } else {
     nsresult rv = SetValueInternal(aValue, true, true);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                        static_cast<nsIDOMHTMLInputElement*>(this),
                                        NS_LITERAL_STRING("input"), true,
@@ -5182,33 +5182,33 @@ HTMLInputElement::GetControllers(ErrorRe
 NS_IMETHODIMP
 HTMLInputElement::GetControllers(nsIControllers** aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
   ErrorResult rv;
   nsRefPtr<nsIControllers> controller = GetControllers(rv);
   controller.forget(aResult);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 HTMLInputElement::GetTextLength(ErrorResult& aRv)
 {
   nsAutoString val;
   GetValue(val);
   return val.Length();
 }
 
 NS_IMETHODIMP
 HTMLInputElement::GetTextLength(int32_t* aTextLength)
 {
   ErrorResult rv;
   *aTextLength = GetTextLength(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLInputElement::SetSelectionRange(int32_t aSelectionStart,
                                     int32_t aSelectionEnd,
                                     const Optional<nsAString>& aDirection,
                                     ErrorResult& aRv)
 {
@@ -5239,17 +5239,17 @@ HTMLInputElement::SetSelectionRange(int3
                                     int32_t aSelectionEnd,
                                     const nsAString& aDirection)
 {
   ErrorResult rv;
   Optional<nsAString> direction;
   direction = &aDirection;
 
   SetSelectionRange(aSelectionStart, aSelectionEnd, direction, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLInputElement::SetRangeText(const nsAString& aReplacement, ErrorResult& aRv)
 {
   if (!SupportsSetRangeText()) {
     aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return;
@@ -5381,17 +5381,17 @@ HTMLInputElement::GetSelectionStart(Erro
 
 NS_IMETHODIMP
 HTMLInputElement::GetSelectionStart(int32_t* aSelectionStart)
 {
   NS_ENSURE_ARG_POINTER(aSelectionStart);
 
   ErrorResult rv;
   *aSelectionStart = GetSelectionStart(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLInputElement::SetSelectionStart(int32_t aSelectionStart, ErrorResult& aRv)
 {
   nsTextEditorState* state = GetEditorState();
   if (state && state->IsSelectionCached()) {
     state->GetSelectionProperties().mStart = aSelectionStart;
@@ -5418,17 +5418,17 @@ HTMLInputElement::SetSelectionStart(int3
   aRv = SetSelectionRange(start, end, direction);
 }
 
 NS_IMETHODIMP
 HTMLInputElement::SetSelectionStart(int32_t aSelectionStart)
 {
   ErrorResult rv;
   SetSelectionStart(aSelectionStart, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 int32_t
 HTMLInputElement::GetSelectionEnd(ErrorResult& aRv)
 {
   int32_t selStart, selEnd;
   aRv = GetSelectionRange(&selStart, &selEnd);
 
@@ -5445,17 +5445,17 @@ HTMLInputElement::GetSelectionEnd(ErrorR
 
 NS_IMETHODIMP
 HTMLInputElement::GetSelectionEnd(int32_t* aSelectionEnd)
 {
   NS_ENSURE_ARG_POINTER(aSelectionEnd);
 
   ErrorResult rv;
   *aSelectionEnd = GetSelectionEnd(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLInputElement::SetSelectionEnd(int32_t aSelectionEnd, ErrorResult& aRv)
 {
   nsTextEditorState* state = GetEditorState();
   if (state && state->IsSelectionCached()) {
     state->GetSelectionProperties().mEnd = aSelectionEnd;
@@ -5482,17 +5482,17 @@ HTMLInputElement::SetSelectionEnd(int32_
   aRv = SetSelectionRange(start, end, direction);
 }
 
 NS_IMETHODIMP
 HTMLInputElement::SetSelectionEnd(int32_t aSelectionEnd)
 {
   ErrorResult rv;
   SetSelectionEnd(aSelectionEnd, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLInputElement::GetFiles(nsIDOMFileList** aFileList)
 {
   nsRefPtr<FileList> list = GetFiles();
   list.forget(aFileList);
   return NS_OK;
@@ -5552,17 +5552,17 @@ HTMLInputElement::GetSelectionDirection(
   }
 }
 
 NS_IMETHODIMP
 HTMLInputElement::GetSelectionDirection(nsAString& aDirection)
 {
   ErrorResult rv;
   GetSelectionDirection(aDirection, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLInputElement::SetSelectionDirection(const nsAString& aDirection, ErrorResult& aRv)
 {
   nsTextEditorState* state = GetEditorState();
   if (state && state->IsSelectionCached()) {
     nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eNone;
@@ -5582,17 +5582,17 @@ HTMLInputElement::SetSelectionDirection(
   }
 }
 
 NS_IMETHODIMP
 HTMLInputElement::SetSelectionDirection(const nsAString& aDirection)
 {
   ErrorResult rv;
   SetSelectionDirection(aDirection, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLInputElement::GetPhonetic(nsAString& aPhonetic)
 {
   aPhonetic.Truncate();
   nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
   nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
--- a/dom/html/HTMLLabelElement.cpp
+++ b/dom/html/HTMLLabelElement.cpp
@@ -54,17 +54,17 @@ HTMLLabelElement::GetControl(nsIDOMHTMLE
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLLabelElement::SetHtmlFor(const nsAString& aHtmlFor)
 {
   ErrorResult rv;
   SetHtmlFor(aHtmlFor, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLLabelElement::GetHtmlFor(nsAString& aHtmlFor)
 {
   nsString htmlFor;
   GetHtmlFor(htmlFor);
   aHtmlFor = htmlFor;
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1570,17 +1570,17 @@ NS_IMETHODIMP HTMLMediaElement::SetCurre
   // Detect for a NaN and invalid values.
   if (mozilla::IsNaN(aCurrentTime)) {
     LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: bad time", this, aCurrentTime));
     return NS_ERROR_FAILURE;
   }
 
   ErrorResult rv;
   SetCurrentTime(aCurrentTime, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* readonly attribute double duration; */
 double
 HTMLMediaElement::Duration() const
 {
   if (mSrcStream) {
     return std::numeric_limits<double>::infinity();
@@ -1693,17 +1693,17 @@ HTMLMediaElement::Pause(ErrorResult& aRv
     DispatchAsyncEvent(NS_LITERAL_STRING("pause"));
   }
 }
 
 NS_IMETHODIMP HTMLMediaElement::Pause()
 {
   ErrorResult rv;
   Pause(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* attribute double volume; */
 NS_IMETHODIMP HTMLMediaElement::GetVolume(double* aVolume)
 {
   *aVolume = Volume();
   return NS_OK;
 }
@@ -1726,17 +1726,17 @@ HTMLMediaElement::SetVolume(double aVolu
 
   DispatchAsyncEvent(NS_LITERAL_STRING("volumechange"));
 }
 
 NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume)
 {
   ErrorResult rv;
   SetVolume(aVolume, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 // Helper struct with arguments for our hash iterator.
 typedef struct MOZ_STACK_CLASS {
   JSContext* cx;
   JS::Handle<JSObject*> tags;
   bool error;
 } MetadataIterCx;
@@ -1798,17 +1798,17 @@ HTMLMediaElement::MozGetMetadata(JSConte
   ErrorResult rv;
   JS::Rooted<JSObject*> obj(cx);
   MozGetMetadata(cx, &obj, rv);
   if (!rv.Failed()) {
     MOZ_ASSERT(obj);
     aValue.setObject(*obj);
   }
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* attribute boolean muted; */
 NS_IMETHODIMP HTMLMediaElement::GetMuted(bool* aMuted)
 {
   *aMuted = Muted();
   return NS_OK;
 }
@@ -2267,17 +2267,17 @@ HTMLMediaElement::Play(ErrorResult& aRv)
   AddRemoveSelfReference();
   UpdatePreloadAction();
 }
 
 NS_IMETHODIMP HTMLMediaElement::Play()
 {
   ErrorResult rv;
   Play(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 HTMLMediaElement::WakeLockBoolWrapper&
 HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val)
 {
   if (mValue == val) {
     return *this;
   }
@@ -4314,17 +4314,17 @@ HTMLMediaElement::SetDefaultPlaybackRate
   mDefaultPlaybackRate = ClampPlaybackRate(aDefaultPlaybackRate);
   DispatchAsyncEvent(NS_LITERAL_STRING("ratechange"));
 }
 
 NS_IMETHODIMP HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate)
 {
   ErrorResult rv;
   SetDefaultPlaybackRate(aDefaultPlaybackRate, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* attribute double playbackRate; */
 NS_IMETHODIMP HTMLMediaElement::GetPlaybackRate(double* aPlaybackRate)
 {
   *aPlaybackRate = PlaybackRate();
   return NS_OK;
 }
@@ -4354,17 +4354,17 @@ HTMLMediaElement::SetPlaybackRate(double
   }
   DispatchAsyncEvent(NS_LITERAL_STRING("ratechange"));
 }
 
 NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate)
 {
   ErrorResult rv;
   SetPlaybackRate(aPlaybackRate, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 /* attribute bool mozPreservesPitch; */
 NS_IMETHODIMP HTMLMediaElement::GetMozPreservesPitch(bool* aPreservesPitch)
 {
   *aPreservesPitch = MozPreservesPitch();
   return NS_OK;
 }
--- a/dom/html/HTMLOptionsCollection.cpp
+++ b/dom/html/HTMLOptionsCollection.cpp
@@ -196,17 +196,17 @@ HTMLOptionsCollection::GetSelectedIndex(
   return selectedIndex;
 }
 
 NS_IMETHODIMP
 HTMLOptionsCollection::GetSelectedIndex(int32_t* aSelectedIndex)
 {
   ErrorResult rv;
   *aSelectedIndex = GetSelectedIndex(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex,
                                         ErrorResult& aError)
 {
   if (!mSelect) {
     aError.Throw(NS_ERROR_UNEXPECTED);
@@ -216,17 +216,17 @@ HTMLOptionsCollection::SetSelectedIndex(
   aError = mSelect->SetSelectedIndex(aSelectedIndex);
 }
 
 NS_IMETHODIMP
 HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex)
 {
   ErrorResult rv;
   SetSelectedIndex(aSelectedIndex, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLOptionsCollection::Item(uint32_t aIndex, nsIDOMNode** aReturn)
 {
   nsISupports* item = GetElementAt(aIndex);
   if (!item) {
     *aReturn = nullptr;
@@ -366,13 +366,13 @@ HTMLOptionsCollection::Remove(int32_t aI
   aError = mSelect->Remove(aIndex);
 }
 
 NS_IMETHODIMP
 HTMLOptionsCollection::Remove(int32_t aIndex)
 {
   ErrorResult rv;
   Remove(aIndex, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/html/HTMLScriptElement.cpp
+++ b/dom/html/HTMLScriptElement.cpp
@@ -116,17 +116,17 @@ HTMLScriptElement::GetText(nsAString& aV
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLScriptElement::SetText(const nsAString& aValue)
 {
   ErrorResult rv;
   SetText(aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& rv)
 {
   rv = nsContentUtils::SetNodeTextContent(this, aValue, true);
 }
 
@@ -193,17 +193,17 @@ HTMLScriptElement::Async()
   return mForceAsync || GetBoolAttr(nsGkAtoms::async);
 }
 
 nsresult
 HTMLScriptElement::SetAsync(bool aValue)
 {
   ErrorResult rv;
   SetAsync(aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLScriptElement::SetAsync(bool aValue, ErrorResult& rv)
 {
   mForceAsync = false;
   SetHTMLBoolAttr(nsGkAtoms::async, aValue, rv);
 }
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -657,42 +657,42 @@ HTMLSelectElement::Add(nsIDOMHTMLElement
     return NS_ERROR_NULL_POINTER;
   }
 
   // aBefore is omitted, undefined or null
   if (dataType == nsIDataType::VTYPE_EMPTY ||
       dataType == nsIDataType::VTYPE_VOID) {
     ErrorResult error;
     Add(*htmlElement, (nsGenericHTMLElement*)nullptr, error);
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   nsCOMPtr<nsISupports> supports;
   nsCOMPtr<nsIDOMHTMLElement> beforeElement;
 
   // whether aBefore is nsIDOMHTMLElement...
   if (NS_SUCCEEDED(aBefore->GetAsISupports(getter_AddRefs(supports)))) {
     nsCOMPtr<nsIContent> beforeElement = do_QueryInterface(supports);
     nsGenericHTMLElement* beforeHTMLElement =
       nsGenericHTMLElement::FromContentOrNull(beforeElement);
 
     NS_ENSURE_TRUE(beforeHTMLElement, NS_ERROR_DOM_SYNTAX_ERR);
 
     ErrorResult error;
     Add(*htmlElement, beforeHTMLElement, error);
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   // otherwise, whether aBefore is long
   int32_t index;
   NS_ENSURE_SUCCESS(aBefore->GetAsInt32(&index), NS_ERROR_DOM_SYNTAX_ERR);
 
   ErrorResult error;
   Add(*htmlElement, index, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLSelectElement::Remove(int32_t aIndex)
 {
   nsCOMPtr<nsINode> option = Item(static_cast<uint32_t>(aIndex));
   if (!option) {
     return NS_OK;
@@ -731,17 +731,17 @@ HTMLSelectElement::GetLength(uint32_t* a
 
 #define MAX_DYNAMIC_SELECT_LENGTH 10000
 
 NS_IMETHODIMP
 HTMLSelectElement::SetLength(uint32_t aLength)
 {
   ErrorResult rv;
   SetLength(aLength, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 HTMLSelectElement::SetLength(uint32_t aLength, ErrorResult& aRv)
 {
   uint32_t curlen = Length();
 
   if (curlen > aLength) { // Remove extra options
--- a/dom/html/HTMLTableCellElement.cpp
+++ b/dom/html/HTMLTableCellElement.cpp
@@ -116,234 +116,234 @@ HTMLTableCellElement::WalkContentStyleRu
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetAbbr(const nsAString& aAbbr)
 {
   ErrorResult rv;
   SetAbbr(aAbbr, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetAbbr(nsAString& aAbbr)
 {
   DOMString abbr;
   GetAbbr(abbr);
   abbr.ToString(aAbbr);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetAxis(const nsAString& aAxis)
 {
   ErrorResult rv;
   SetAxis(aAxis, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetAxis(nsAString& aAxis)
 {
   DOMString axis;
   GetAxis(axis);
   axis.ToString(aAxis);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetAlign(const nsAString& aAlign)
 {
   ErrorResult rv;
   SetAlign(aAlign, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetAlign(nsAString& aAlign)
 {
   DOMString align;
   GetAlign(align);
   align.ToString(aAlign);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetVAlign(const nsAString& aVAlign)
 {
   ErrorResult rv;
   SetVAlign(aVAlign, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetVAlign(nsAString& aVAlign)
 {
   DOMString vAlign;
   GetVAlign(vAlign);
   vAlign.ToString(aVAlign);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetCh(const nsAString& aCh)
 {
   ErrorResult rv;
   SetCh(aCh, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetCh(nsAString& aCh)
 {
   DOMString ch;
   GetCh(ch);
   ch.ToString(aCh);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetChOff(const nsAString& aChOff)
 {
   ErrorResult rv;
   SetChOff(aChOff, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetChOff(nsAString& aChOff)
 {
   DOMString chOff;
   GetChOff(chOff);
   chOff.ToString(aChOff);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetBgColor(const nsAString& aBgColor)
 {
   ErrorResult rv;
   SetBgColor(aBgColor, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetBgColor(nsAString& aBgColor)
 {
   DOMString bgColor;
   GetBgColor(bgColor);
   bgColor.ToString(aBgColor);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetHeight(const nsAString& aHeight)
 {
   ErrorResult rv;
   SetHeight(aHeight, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetHeight(nsAString& aHeight)
 {
   DOMString height;
   GetHeight(height);
   height.ToString(aHeight);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetWidth(const nsAString& aWidth)
 {
   ErrorResult rv;
   SetWidth(aWidth, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetWidth(nsAString& aWidth)
 {
   DOMString width;
   GetWidth(width);
   width.ToString(aWidth);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetNoWrap(bool aNoWrap)
 {
   ErrorResult rv;
   SetNoWrap(aNoWrap, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetNoWrap(bool* aNoWrap)
 {
   *aNoWrap = NoWrap();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetScope(const nsAString& aScope)
 {
   ErrorResult rv;
   SetScope(aScope, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetScope(nsAString& aScope)
 {
   DOMString scope;
   GetScope(scope);
   scope.ToString(aScope);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetHeaders(const nsAString& aHeaders)
 {
   ErrorResult rv;
   SetHeaders(aHeaders, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetHeaders(nsAString& aHeaders)
 {
   DOMString headers;
   GetHeaders(headers);
   headers.ToString(aHeaders);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetColSpan(int32_t aColSpan)
 {
   ErrorResult rv;
   SetColSpan(aColSpan, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetColSpan(int32_t* aColSpan)
 {
   *aColSpan = ColSpan();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::SetRowSpan(int32_t aRowSpan)
 {
   ErrorResult rv;
   SetRowSpan(aRowSpan, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 HTMLTableCellElement::GetRowSpan(int32_t* aRowSpan)
 {
   *aRowSpan = RowSpan();
   return NS_OK;
 }
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -368,17 +368,17 @@ HTMLTextAreaElement::GetDefaultValue(nsA
   return NS_OK;
 }  
 
 NS_IMETHODIMP
 HTMLTextAreaElement::SetDefaultValue(const nsAString& aDefaultValue)
 {
   ErrorResult error;
   SetDefaultValue(aDefaultValue, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 void
 HTMLTextAreaElement::SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError)
 {
   nsresult rv = nsContentUtils::SetNodeTextContent(this, aDefaultValue, true);
   if (NS_SUCCEEDED(rv) && !mValueChanged) {
     Reset();
@@ -627,17 +627,17 @@ NS_IMETHODIMP
 HTMLTextAreaElement::GetControllers(nsIControllers** aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
   ErrorResult error;
   *aResult = GetControllers(error);
   NS_IF_ADDREF(*aResult);
 
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 uint32_t
 HTMLTextAreaElement::GetTextLength()
 {
   nsAutoString val;
   GetValue(val);
   return val.Length();
@@ -654,17 +654,17 @@ HTMLTextAreaElement::GetTextLength(int32
 
 NS_IMETHODIMP
 HTMLTextAreaElement::GetSelectionStart(int32_t *aSelectionStart)
 {
   NS_ENSURE_ARG_POINTER(aSelectionStart);
 
   ErrorResult error;
   *aSelectionStart = GetSelectionStart(error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 uint32_t
 HTMLTextAreaElement::GetSelectionStart(ErrorResult& aError)
 {
   int32_t selStart, selEnd;
   nsresult rv = GetSelectionRange(&selStart, &selEnd);
 
@@ -677,17 +677,17 @@ HTMLTextAreaElement::GetSelectionStart(E
   return selStart;
 }
 
 NS_IMETHODIMP
 HTMLTextAreaElement::SetSelectionStart(int32_t aSelectionStart)
 {
   ErrorResult error;
   SetSelectionStart(aSelectionStart, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 void
 HTMLTextAreaElement::SetSelectionStart(uint32_t aSelectionStart, ErrorResult& aError)
 {
   if (mState.IsSelectionCached()) {
     mState.GetSelectionProperties().mStart = aSelectionStart;
     return;
@@ -717,17 +717,17 @@ HTMLTextAreaElement::SetSelectionStart(u
 
 NS_IMETHODIMP
 HTMLTextAreaElement::GetSelectionEnd(int32_t *aSelectionEnd)
 {
   NS_ENSURE_ARG_POINTER(aSelectionEnd);
 
   ErrorResult error;
   *aSelectionEnd = GetSelectionEnd(error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 uint32_t
 HTMLTextAreaElement::GetSelectionEnd(ErrorResult& aError)
 {
   int32_t selStart, selEnd;
   nsresult rv = GetSelectionRange(&selStart, &selEnd);
 
@@ -740,17 +740,17 @@ HTMLTextAreaElement::GetSelectionEnd(Err
   return selEnd;
 }
 
 NS_IMETHODIMP
 HTMLTextAreaElement::SetSelectionEnd(int32_t aSelectionEnd)
 {
   ErrorResult error;
   SetSelectionEnd(aSelectionEnd, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 void
 HTMLTextAreaElement::SetSelectionEnd(uint32_t aSelectionEnd, ErrorResult& aError)
 {
   if (mState.IsSelectionCached()) {
     mState.GetSelectionProperties().mEnd = aSelectionEnd;
     return;
@@ -805,17 +805,17 @@ DirectionToName(nsITextControlFrame::Sel
   }
 }
 
 nsresult
 HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection)
 {
   ErrorResult error;
   GetSelectionDirection(aDirection, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 void
 HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection, ErrorResult& aError)
 {
   nsresult rv = NS_ERROR_FAILURE;
   nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
   nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
@@ -836,17 +836,17 @@ HTMLTextAreaElement::GetSelectionDirecti
   }
 }
 
 NS_IMETHODIMP
 HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection)
 {
   ErrorResult error;
   SetSelectionDirection(aDirection, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 void
 HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection, ErrorResult& aError)
 {
   if (mState.IsSelectionCached()) {
     nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eNone;
     if (aDirection.EqualsLiteral("forward")) {
@@ -872,17 +872,17 @@ NS_IMETHODIMP
 HTMLTextAreaElement::SetSelectionRange(int32_t aSelectionStart,
                                        int32_t aSelectionEnd,
                                        const nsAString& aDirection)
 {
   ErrorResult error;
   Optional<nsAString> dir;
   dir = &aDirection;
   SetSelectionRange(aSelectionStart, aSelectionEnd, dir, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 void
 HTMLTextAreaElement::SetSelectionRange(uint32_t aSelectionStart,
                                        uint32_t aSelectionEnd,
                                        const Optional<nsAString>& aDirection,
                                        ErrorResult& aError)
 {
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -320,17 +320,17 @@ ImageDocument::GetImageRequest(ErrorResu
   return imageRequest.forget();
 }
 
 NS_IMETHODIMP
 ImageDocument::GetImageRequest(imgIRequest** aImageRequest)
 {
   ErrorResult rv;
   *aImageRequest = GetImageRequest(rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 ImageDocument::ShrinkToFit()
 {
   if (!mImageContent) {
     return;
   }
--- a/dom/html/TimeRanges.cpp
+++ b/dom/html/TimeRanges.cpp
@@ -42,17 +42,17 @@ TimeRanges::Start(uint32_t aIndex, Error
   return mRanges[aIndex].mStart;
 }
 
 NS_IMETHODIMP
 TimeRanges::Start(uint32_t aIndex, double* aTime)
 {
   ErrorResult rv;
   *aTime = Start(aIndex, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 double
 TimeRanges::End(uint32_t aIndex, ErrorResult& aRv)
 {
   if (aIndex >= mRanges.Length()) {
     aRv = NS_ERROR_DOM_INDEX_SIZE_ERR;
     return 0;
@@ -61,17 +61,17 @@ TimeRanges::End(uint32_t aIndex, ErrorRe
   return mRanges[aIndex].mEnd;
 }
 
 NS_IMETHODIMP
 TimeRanges::End(uint32_t aIndex, double* aTime)
 {
   ErrorResult rv;
   *aTime = End(aIndex, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 TimeRanges::Add(double aStart, double aEnd)
 {
   if (aStart > aEnd) {
     NS_WARNING("Can't add a range if the end is older that the start.");
     return;
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -148,17 +148,17 @@ public:
       return NS_OK;
     }
 
     // If something is focused in the same document, ignore autofocus.
     if (!fm->GetFocusedContent() ||
         fm->GetFocusedContent()->OwnerDoc() != document) {
       mozilla::ErrorResult rv;
       mElement->Focus(rv);
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
 
     return NS_OK;
   }
 private:
   // NOTE: nsGenericHTMLFormElement is saved as a nsGenericHTMLElement
   // because AddRef/Release are ambiguous with nsGenericHTMLFormElement
   // and Focus() is declared (and defined) in nsGenericHTMLElement class.
@@ -426,17 +426,17 @@ nsGenericHTMLElement::GetOffsetRect(CSSI
 }
 
 NS_IMETHODIMP
 nsGenericHTMLElement::InsertAdjacentHTML(const nsAString& aPosition,
                                          const nsAString& aText)
 {
   ErrorResult rv;
   Element::InsertAdjacentHTML(aPosition, aText, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsGenericHTMLElement::Spellcheck()
 {
   // Has the state has been explicitly set?
   nsIContent* node;
   for (node = this; node; node = node->GetParent()) {
@@ -1854,22 +1854,22 @@ nsGenericHTMLElement::SetUndoScopeIntern
     }
   } else {
     nsDOMSlots* slots = GetExistingDOMSlots();
     if (slots && slots->mUndoManager) {
       // Clear transaction history and disconnect.
       ErrorResult rv;
       slots->mUndoManager->ClearRedo(rv);
       if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
       }
 
       slots->mUndoManager->ClearUndo(rv);
       if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
       }
 
       slots->mUndoManager->Disconnect();
       slots->mUndoManager = nullptr;
     }
   }
   return NS_OK;
 }
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -352,17 +352,17 @@ public:
     mozilla::dom::DOMString dir;
     GetDir(dir);
     dir.ToString(aDir);
     return NS_OK;
   }
   NS_IMETHOD SetDir(const nsAString& aDir) final override {
     mozilla::ErrorResult rv;
     SetDir(aDir, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetDOMClassName(nsAString& aClassName) final {
     GetHTMLAttr(nsGkAtoms::_class, aClassName);
     return NS_OK;
   }
   NS_IMETHOD SetDOMClassName(const nsAString& aClassName) final {
     SetClassName(aClassName);
     return NS_OK;
@@ -370,31 +370,31 @@ public:
   NS_IMETHOD GetDataset(nsISupports** aDataset) final override;
   NS_IMETHOD GetHidden(bool* aHidden) final override {
     *aHidden = Hidden();
     return NS_OK;
   }
   NS_IMETHOD SetHidden(bool aHidden) final override {
     mozilla::ErrorResult rv;
     SetHidden(aHidden, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD DOMBlur() final override {
     mozilla::ErrorResult rv;
     Blur(rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetItemScope(bool* aItemScope) final override {
     *aItemScope = ItemScope();
     return NS_OK;
   }
   NS_IMETHOD SetItemScope(bool aItemScope) final override {
     mozilla::ErrorResult rv;
     SetItemScope(aItemScope, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetItemType(nsIVariant** aType) final override {
     GetTokenList(nsGkAtoms::itemtype, aType);
     return NS_OK;
   }
   NS_IMETHOD SetItemType(nsIVariant* aType) final override {
     return SetTokenList(nsGkAtoms::itemtype, aType);
   }
@@ -402,17 +402,17 @@ public:
     nsString id;
     GetItemId(id);
     aId.Assign(aId);
     return NS_OK;
   }
   NS_IMETHOD SetItemId(const nsAString& aId) final override {
     mozilla::ErrorResult rv;
     SetItemId(aId, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetProperties(nsISupports** aReturn) final override;
   NS_IMETHOD GetItemValue(nsIVariant** aValue) final override;
   NS_IMETHOD SetItemValue(nsIVariant* aValue) final override;
   NS_IMETHOD GetItemRef(nsIVariant** aRef) final override {
     GetTokenList(nsGkAtoms::itemref, aRef);
     return NS_OK;
   }
@@ -430,68 +430,68 @@ public:
     nsString accessKey;
     GetAccessKey(accessKey);
     aAccessKey.Assign(accessKey);
     return NS_OK;
   }
   NS_IMETHOD SetAccessKey(const nsAString& aAccessKey) final override {
     mozilla::ErrorResult rv;
     SetAccessKey(aAccessKey, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetAccessKeyLabel(nsAString& aAccessKeyLabel)
     final override {
     nsString accessKeyLabel;
     GetAccessKeyLabel(accessKeyLabel);
     aAccessKeyLabel.Assign(accessKeyLabel);
     return NS_OK;
   }
   NS_IMETHOD SetDraggable(bool aDraggable) final override {
     mozilla::ErrorResult rv;
     SetDraggable(aDraggable, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetContentEditable(nsAString& aContentEditable)
     final override {
     nsString contentEditable;
     GetContentEditable(contentEditable);
     aContentEditable.Assign(contentEditable);
     return NS_OK;
   }
   NS_IMETHOD SetContentEditable(const nsAString& aContentEditable)
     final override {
     mozilla::ErrorResult rv;
     SetContentEditable(aContentEditable, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetIsContentEditable(bool* aIsContentEditable)
     final override {
     *aIsContentEditable = IsContentEditable();
     return NS_OK;
   }
   NS_IMETHOD GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu)
     final override;
   NS_IMETHOD GetSpellcheck(bool* aSpellcheck) final override {
     *aSpellcheck = Spellcheck();
     return NS_OK;
   }
   NS_IMETHOD SetSpellcheck(bool aSpellcheck) final override {
     mozilla::ErrorResult rv;
     SetSpellcheck(aSpellcheck, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetOuterHTML(nsAString& aOuterHTML) final override {
     mozilla::dom::Element::GetOuterHTML(aOuterHTML);
     return NS_OK;
   }
   NS_IMETHOD SetOuterHTML(const nsAString& aOuterHTML) final override {
     mozilla::ErrorResult rv;
     mozilla::dom::Element::SetOuterHTML(aOuterHTML, rv);
-    return rv.ErrorCode();
-  }                                                                            \
+    return rv.StealNSResult();
+  }
   NS_IMETHOD InsertAdjacentHTML(const nsAString& position,
                                 const nsAString& text) final override;
   NS_IMETHOD ScrollIntoView(bool top, uint8_t _argc) final override {
     if (!_argc) {
       top = true;
     }
     mozilla::dom::Element::ScrollIntoView(top);
     return NS_OK;
@@ -527,35 +527,35 @@ public:
   }
   NS_IMETHOD GetTabIndex(int32_t* aTabIndex) final override {
     *aTabIndex = TabIndex();
     return NS_OK;
   }
   NS_IMETHOD SetTabIndex(int32_t aTabIndex) final override {
     mozilla::ErrorResult rv;
     SetTabIndex(aTabIndex, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD Focus() final override {
     mozilla::ErrorResult rv;
     Focus(rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
   NS_IMETHOD GetDraggable(bool* aDraggable) final override {
     *aDraggable = Draggable();
     return NS_OK;
   }
   NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) override {
     return mozilla::dom::Element::GetInnerHTML(aInnerHTML);
   }
   using mozilla::dom::Element::SetInnerHTML;
   NS_IMETHOD SetInnerHTML(const nsAString& aInnerHTML) final override {
     mozilla::ErrorResult rv;
     SetInnerHTML(aInnerHTML, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   using nsGenericHTMLElementBase::GetOwnerDocument;
 
   virtual nsIDOMNode* AsDOMNode() override { return this; }
 
 public:
   // Implementation for nsIContent
@@ -1522,17 +1522,17 @@ protected:
     *aValue = GetUnsignedIntAttr(nsGkAtoms::_atom, _default);             \
     return NS_OK;                                                         \
   }                                                                       \
   NS_IMETHODIMP                                                           \
   _class::Set##_method(uint32_t aValue)                                   \
   {                                                                       \
     mozilla::ErrorResult rv;                                              \
     SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, rv);                     \
-    return rv.ErrorCode();                                                \
+    return rv.StealNSResult();                                            \
   }
 
 /**
  * A macro to implement the getter and setter for a given unsigned integer
  * valued content property. The method uses GetUnsignedIntAttr and
  * SetUnsignedIntAttr methods. This macro is similar to NS_IMPL_UINT_ATTR except
  * that it throws an exception if the set value is null.
  */
@@ -1549,17 +1549,17 @@ protected:
   NS_IMETHODIMP                                                           \
   _class::Set##_method(uint32_t aValue)                                   \
   {                                                                       \
     if (aValue == 0) {                                                    \
       return NS_ERROR_DOM_INDEX_SIZE_ERR;                                 \
     }                                                                     \
     mozilla::ErrorResult rv;                                              \
     SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, rv);                     \
-    return rv.ErrorCode();                                                \
+    return rv.StealNSResult();                                            \
   }
 
 /**
  * A macro to implement the getter and setter for a given content
  * property that needs to return a URI in string form.  The method
  * uses the generic GetAttr and SetAttr methods.  This macro is much
  * like the NS_IMPL_STRING_ATTR macro, except we make sure the URI is
  * absolute.
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -921,17 +921,17 @@ nsHTMLDocument::GetDomain(nsAString& aDo
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::SetDomain(const nsAString& aDomain)
 {
   ErrorResult rv;
   SetDomain(aDomain, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsHTMLDocument::SetDomain(const nsAString& aDomain, ErrorResult& rv)
 {
   if (mSandboxFlags & SANDBOXED_DOMAIN) {
     // We're sandboxed; disallow setting domain
     rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
@@ -1042,17 +1042,17 @@ nsHTMLDocument::GetBody(nsIDOMHTMLElemen
 NS_IMETHODIMP
 nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
 {
   nsCOMPtr<nsIContent> newBody = do_QueryInterface(aBody);
   MOZ_ASSERT(!newBody || newBody->IsHTMLElement(),
              "How could we be an nsIContent but not actually HTML here?");
   ErrorResult rv;
   SetBody(static_cast<nsGenericHTMLElement*>(newBody.get()), rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsHTMLDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv)
 {
   Element* root = GetRootElement();
 
   // The body element must be either a body tag or a frameset tag. And we must
@@ -1221,17 +1221,17 @@ nsHTMLDocument::Scripts()
   return mScripts;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetCookie(nsAString& aCookie)
 {
   ErrorResult rv;
   GetCookie(aCookie, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<nsIChannel>
 nsHTMLDocument::CreateDummyChannelForCookies(nsIURI* aCodebaseURI)
 {
   // The cookie service reads the privacy status of the channel we pass to it in
   // order to determine which cookie database to query.  In some cases we don't
   // have a proper channel to hand it to the cookie service though.  This
@@ -1304,17 +1304,17 @@ nsHTMLDocument::GetCookie(nsAString& aCo
   }
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::SetCookie(const nsAString& aCookie)
 {
   ErrorResult rv;
   SetCookie(aCookie, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsHTMLDocument::SetCookie(const nsAString& aCookie, ErrorResult& rv)
 {
   if (mDisableCookieAccess) {
     return;
   }
@@ -1360,32 +1360,32 @@ nsHTMLDocument::Open(const nsAString& aC
                      JSContext* cx, uint8_t aOptionalArgCount,
                      nsISupports** aReturn)
 {
   // When called with 3 or more arguments, document.open() calls window.open().
   if (aOptionalArgCount > 2) {
     ErrorResult rv;
     *aReturn = Open(cx, aContentTypeOrUrl, aReplaceOrName, aFeatures,
                     false, rv).take();
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   nsString type;
   if (aOptionalArgCount > 0) {
     type = aContentTypeOrUrl;
   } else {
     type.AssignLiteral("text/html");
   }
   nsString replace;
   if (aOptionalArgCount > 1) {
     replace = aReplaceOrName;
   }
   ErrorResult rv;
   *aReturn = Open(cx, type, replace, rv).take();
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 already_AddRefed<nsIDOMWindow>
 nsHTMLDocument::Open(JSContext* /* unused */,
                      const nsAString& aURL,
                      const nsAString& aName,
                      const nsAString& aFeatures,
                      bool aReplace,
@@ -1749,17 +1749,17 @@ nsHTMLDocument::Clear()
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::Close()
 {
   ErrorResult rv;
   Close(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsHTMLDocument::Close(ErrorResult& rv)
 {
   if (!IsHTMLDocument()) {
     // No calling document.close() on XHTML!
 
@@ -2223,17 +2223,17 @@ nsHTMLDocument::Embeds()
   return mEmbeds;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetSelection(nsISelection** aReturn)
 {
   ErrorResult rv;
   NS_IF_ADDREF(*aReturn = GetSelection(rv));
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 Selection*
 nsHTMLDocument::GetSelection(ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(GetScopeObject());
   if (!window) {
     return nullptr;
@@ -2952,17 +2952,17 @@ nsHTMLDocument::EditingStateChanged()
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode)
 {
   ErrorResult rv;
   SetDesignMode(aDesignMode, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsHTMLDocument::SetDesignMode(const nsAString& aDesignMode, ErrorResult& rv)
 {
   if (!nsContentUtils::SubjectPrincipal()->Subsumes(NodePrincipal())) {
     rv.Throw(NS_ERROR_DOM_PROP_ACCESS_DENIED);
     return;
@@ -3233,17 +3233,17 @@ ConvertToMidasInternalCommand(const nsAS
 NS_IMETHODIMP
 nsHTMLDocument::ExecCommand(const nsAString& commandID,
                             bool doShowUI,
                             const nsAString& value,
                             bool* _retval)
 {
   ErrorResult rv;
   *_retval = ExecCommand(commandID, doShowUI, value, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsHTMLDocument::ExecCommand(const nsAString& commandID,
                             bool doShowUI,
                             const nsAString& value,
                             ErrorResult& rv)
 {
@@ -3344,17 +3344,17 @@ nsHTMLDocument::ExecCommand(const nsAStr
 
 /* boolean queryCommandEnabled(in DOMString commandID); */
 NS_IMETHODIMP
 nsHTMLDocument::QueryCommandEnabled(const nsAString& commandID,
                                     bool* _retval)
 {
   ErrorResult rv;
   *_retval = QueryCommandEnabled(commandID, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsHTMLDocument::QueryCommandEnabled(const nsAString& commandID, ErrorResult& rv)
 {
   nsAutoCString cmdToDispatch;
   if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch)) {
     return false;
@@ -3387,17 +3387,17 @@ nsHTMLDocument::QueryCommandEnabled(cons
 
 /* boolean queryCommandIndeterm (in DOMString commandID); */
 NS_IMETHODIMP
 nsHTMLDocument::QueryCommandIndeterm(const nsAString & commandID,
                                      bool *_retval)
 {
   ErrorResult rv;
   *_retval = QueryCommandIndeterm(commandID, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsHTMLDocument::QueryCommandIndeterm(const nsAString& commandID, ErrorResult& rv)
 {
   nsAutoCString cmdToDispatch;
   if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch)) {
     return false;
@@ -3445,17 +3445,17 @@ nsHTMLDocument::QueryCommandIndeterm(con
 }
 
 /* boolean queryCommandState(in DOMString commandID); */
 NS_IMETHODIMP
 nsHTMLDocument::QueryCommandState(const nsAString & commandID, bool *_retval)
 {
   ErrorResult rv;
   *_retval = QueryCommandState(commandID, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 nsHTMLDocument::QueryCommandState(const nsAString& commandID, ErrorResult& rv)
 {
   nsAutoCString cmdToDispatch, paramToCheck;
   bool dummy, dummy2;
   if (!ConvertToMidasInternalCommand(commandID, commandID,
@@ -3548,17 +3548,17 @@ nsHTMLDocument::QueryCommandSupported(co
 
 /* DOMString queryCommandValue(in DOMString commandID); */
 NS_IMETHODIMP
 nsHTMLDocument::QueryCommandValue(const nsAString & commandID,
                                   nsAString &_retval)
 {
   ErrorResult rv;
   QueryCommandValue(commandID, _retval, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 nsHTMLDocument::QueryCommandValue(const nsAString& commandID,
                                   nsAString& aValue,
                                   ErrorResult& rv)
 {
   aValue.Truncate();
--- a/dom/inputport/InputPortManager.cpp
+++ b/dom/inputport/InputPortManager.cpp
@@ -181,22 +181,22 @@ InputPortManager::NotifySuccess(nsIArray
       break;
     }
     MOZ_ASSERT(port);
 
     ports.AppendElement(port);
   }
 
   if (NS_WARN_IF(erv.Failed())) {
-    return erv.ErrorCode();
+    return erv.StealNSResult();
   }
 
   erv = SetInputPorts(ports);
 
-  return erv.ErrorCode();
+  return erv.StealNSResult();
 }
 
 NS_IMETHODIMP
 InputPortManager::NotifyError(uint16_t aErrorCode)
 {
   switch (aErrorCode) {
   case nsIInputPortServiceCallback::INPUTPORT_ERROR_FAILURE:
   case nsIInputPortServiceCallback::INPUTPORT_ERROR_INVALID_ARG:
--- a/dom/ipc/Blob.cpp
+++ b/dom/ipc/Blob.cpp
@@ -1337,17 +1337,17 @@ RemoteInputStream::Available(uint64_t* a
 
   // Otherwise fake it...
   NS_WARNING("Available() called before real stream has been delivered, "
               "guessing the amount of data available!");
 
   ErrorResult error;
   *aAvailable = mBlobImpl->GetSize(error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemoteInputStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aResult)
 {
--- a/dom/network/UDPSocket.cpp
+++ b/dom/network/UDPSocket.cpp
@@ -287,17 +287,17 @@ UDPSocket::DoPendingMcastCommand()
       }
       case MulticastCommand::Leave: {
         LeaveMulticastGroup(command.mAddress, rv);
         break;
       }
     }
 
     if (NS_WARN_IF(rv.Failed())) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
   }
 
   mPendingMcastCommands.Clear();
   return NS_OK;
 }
 
 bool
@@ -522,22 +522,22 @@ UDPSocket::Init(const nsString& aLocalAd
   mAddressReuse = aAddressReuse;
   mLoopback = aLoopback;
 
   ErrorResult rv;
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
 
   mOpened = Promise::Create(global, rv);
   if (NS_WARN_IF(rv.Failed())) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   mClosed = Promise::Create(global, rv);
   if (NS_WARN_IF(rv.Failed())) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   class OpenSocketRunnable final : public nsRunnable
   {
   public:
     explicit OpenSocketRunnable(UDPSocket* aSocket) : mSocket(aSocket)
     { }
 
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -78,17 +78,17 @@ public:
     nsRefPtr<Notification> notification;
     notification = Notification::CreateInternal(mWindow,
                                                 aID,
                                                 aTitle,
                                                 options);
     ErrorResult rv;
     notification->InitFromBase64(aCx, aData, rv);
     if (rv.Failed()) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
 
     notification->SetStoredState(true);
 
     JSAutoCompartment ac(aCx, mGlobal);
     JS::Rooted<JSObject*> element(aCx, notification->WrapObject(aCx, JS::NullPtr()));
     NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
 
@@ -333,17 +333,17 @@ NotificationPermissionRequest::DispatchC
   return NS_DispatchToMainThread(callbackRunnable);
 }
 
 nsresult
 NotificationPermissionRequest::CallCallback()
 {
   ErrorResult rv;
   mCallback->Call(mPermission, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 NotificationPermissionRequest::GetTypes(nsIArray** aTypes)
 {
   nsTArray<nsString> emptyOptions;
   return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("desktop-notification"),
 							 NS_LITERAL_CSTRING("unused"),
--- a/dom/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/offline/nsDOMOfflineResourceList.cpp
@@ -219,17 +219,17 @@ nsDOMOfflineResourceList::GetMozItems(Er
 }
 
 NS_IMETHODIMP
 nsDOMOfflineResourceList::GetMozItems(nsISupports** aItems)
 {
   ErrorResult rv;
   nsRefPtr<DOMStringList> items = GetMozItems(rv);
   items.forget(aItems);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 nsDOMOfflineResourceList::MozHasItem(const nsAString& aURI, bool* aExists)
 {
   if (IS_CHILD_PROCESS()) 
     return NS_ERROR_NOT_IMPLEMENTED;
 
--- a/dom/power/PowerManagerService.cpp
+++ b/dom/power/PowerManagerService.cpp
@@ -224,17 +224,17 @@ PowerManagerService::NewWakeLock(const n
 NS_IMETHODIMP
 PowerManagerService::NewWakeLock(const nsAString &aTopic,
                                  nsIDOMWindow *aWindow,
                                  nsISupports **aWakeLock)
 {
   mozilla::ErrorResult rv;
   nsRefPtr<WakeLock> wakelock = NewWakeLock(aTopic, aWindow, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   nsCOMPtr<nsIDOMEventListener> eventListener = wakelock.get();
   eventListener.forget(aWakeLock);
   return NS_OK;
 }
 
 already_AddRefed<WakeLock>
--- a/dom/svg/DOMSVGLength.cpp
+++ b/dom/svg/DOMSVGLength.cpp
@@ -240,17 +240,17 @@ DOMSVGLength::GetValue(ErrorResult& aRv)
   return 0.0f;
 }
 
 NS_IMETHODIMP
 DOMSVGLength::GetValue(float* aValue)
 {
   ErrorResult rv;
   *aValue = GetValue(rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv)
 {
   if (mIsAnimValItem) {
     aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     return;
@@ -294,17 +294,17 @@ NS_IMETHODIMP
 DOMSVGLength::SetValue(float aUserUnitValue)
 {
   if (!IsFinite(aUserUnitValue)) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
   ErrorResult rv;
   SetValue(aUserUnitValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 float
 DOMSVGLength::ValueInSpecifiedUnits()
 {
   if (mVal) {
     if (mIsAnimValItem) {
       mSVGElement->FlushAnimations();
@@ -354,17 +354,17 @@ NS_IMETHODIMP
 DOMSVGLength::SetValueInSpecifiedUnits(float aValue)
 {
   if (!IsFinite(aValue)) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
   ErrorResult rv;
   SetValueInSpecifiedUnits(aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DOMSVGLength::SetValueAsString(const nsAString& aValue, ErrorResult& aRv)
 {
   if (mIsAnimValItem) {
     aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     return;
@@ -392,17 +392,17 @@ DOMSVGLength::SetValueAsString(const nsA
   mUnit = value.GetUnit();
 }
 
 NS_IMETHODIMP
 DOMSVGLength::SetValueAsString(const nsAString& aValue)
 {
   ErrorResult rv;
   SetValueAsString(aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 DOMSVGLength::GetValueAsString(nsAString& aValue)
 {
   if (mVal) {
     if (mIsAnimValItem) {
       mSVGElement->FlushAnimations();
@@ -459,17 +459,17 @@ NS_IMETHODIMP
 DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue)
 {
   if (!IsFinite(aValue)) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
   ErrorResult rv;
   NewValueSpecifiedUnits(aUnit, aValue, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 void
 DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv)
 {
   if (mIsAnimValItem) {
     aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     return;
@@ -509,17 +509,17 @@ DOMSVGLength::ConvertToSpecifiedUnits(ui
   aRv.Throw(NS_ERROR_FAILURE);
 }
 
 NS_IMETHODIMP
 DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit)
 {
   ErrorResult rv;
   ConvertToSpecifiedUnits(aUnit, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 JSObject*
 DOMSVGLength::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return dom::SVGLengthBinding::Wrap(aCx, this, aGivenProto);
 }
 
--- a/dom/system/gonk/nsVolumeMountLock.cpp
+++ b/dom/system/gonk/nsVolumeMountLock.cpp
@@ -155,17 +155,17 @@ nsVolumeMountLock::Lock(nsIVolume* aVolu
   NS_ENSURE_TRUE(pmService, NS_ERROR_FAILURE);
 
   nsString mountLockName;
   aVolume->GetMountLockName(mountLockName);
 
   ErrorResult err;
   mWakeLock = pmService->NewWakeLock(mountLockName, nullptr, err);
   if (err.Failed()) {
-    return err.ErrorCode();
+    return err.StealNSResult();
   }
 
   LOG("nsVolumeMountLock acquired for '%s' gen %d",
       NS_LossyConvertUTF16toASCII(mVolumeName).get(), mVolumeGeneration);
   return NS_OK;
 }
 
 } // namespace system
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -811,17 +811,17 @@ private:
       request.SetAsUSVString().Rebind(loadInfo.mFullURL.Data(),
                                       loadInfo.mFullURL.Length());
 
       ErrorResult error;
       nsRefPtr<Promise> cachePromise =
         mCacheCreator->Cache_()->Put(request, *response, error);
       if (NS_WARN_IF(error.Failed())) {
         channel->Cancel(error.ErrorCode());
-        return error.ErrorCode();
+        return error.StealNSResult();
       }
 
       nsRefPtr<CachePromiseHandler> promiseHandler =
         new CachePromiseHandler(this, loadInfo, aIndex);
       cachePromise->AppendNativeHandler(promiseHandler);
 
       loadInfo.mCachePromise.swap(cachePromise);
       loadInfo.mCacheStatus = ScriptLoadInfo::WritingToCache;
@@ -1161,17 +1161,17 @@ CacheCreator::CreateCacheStorage(nsIPrin
   }
 
   ErrorResult error;
   mCacheStorage =
     CacheStorage::CreateOnMainThread(cache::CHROME_ONLY_NAMESPACE,
                                      mSandboxGlobalObject,
                                      aPrincipal, error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   return NS_OK;
 }
 
 nsresult
 CacheCreator::Load(nsIPrincipal* aPrincipal)
 {
@@ -1182,17 +1182,17 @@ CacheCreator::Load(nsIPrincipal* aPrinci
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   ErrorResult error;
   MOZ_ASSERT(!mCacheName.IsEmpty());
   nsRefPtr<Promise> promise = mCacheStorage->Open(mCacheName, error);
   if (NS_WARN_IF(error.Failed())) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   promise->AppendNativeHandler(this);
   return NS_OK;
 }
 
 void
 CacheCreator::FailLoaders(nsresult aRv)
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -87,17 +87,17 @@ public:
     nsGlobalWindow* window = nsGlobalWindow::GetOuterWindowWithId(mWindowId);
     if (!window) {
       return NS_ERROR_FAILURE;
     }
 
     ErrorResult result;
     dom::Navigator* navigator = window->GetNavigator(result);
     if (NS_WARN_IF(result.Failed())) {
-      return result.ErrorCode();
+      return result.StealNSResult();
     }
 
     nsRefPtr<ServiceWorkerContainer> container = navigator->ServiceWorker();
     AutoJSAPI jsapi;
     jsapi.Init(window);
     JSContext* cx = jsapi.cx();
 
     return DispatchDOMEvent(cx, container);
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -991,17 +991,17 @@ ServiceWorkerManager::Register(nsIDOMWin
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
   ErrorResult result;
   nsRefPtr<Promise> promise = Promise::Create(sgo, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
 
   ServiceWorkerJobQueue* queue = GetOrCreateJobQueue(cleanedScope);
   MOZ_ASSERT(queue);
 
   nsRefPtr<ServiceWorkerResolveWindowPromiseOnUpdateCallback> cb =
     new ServiceWorkerResolveWindowPromiseOnUpdateCallback(window, promise);
 
@@ -1312,17 +1312,17 @@ ServiceWorkerManager::GetRegistrations(n
   if (!window) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
   ErrorResult result;
   nsRefPtr<Promise> promise = Promise::Create(sgo, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
 
   nsCOMPtr<nsIRunnable> runnable =
     new GetRegistrationsRunnable(window, promise);
   promise.forget(aPromise);
   return NS_DispatchToCurrentThread(runnable);
 }
 
@@ -1413,17 +1413,17 @@ ServiceWorkerManager::GetRegistration(ns
   if (!window) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
   ErrorResult result;
   nsRefPtr<Promise> promise = Promise::Create(sgo, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
 
   nsCOMPtr<nsIRunnable> runnable =
     new GetRegistrationRunnable(window, promise, aDocumentURL);
   promise.forget(aPromise);
   return NS_DispatchToCurrentThread(runnable);
 }
 
@@ -1624,17 +1624,17 @@ ServiceWorkerManager::GetReadyPromise(ns
   }
 
   MOZ_ASSERT(!mPendingReadyPromises.Contains(window));
 
   nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
   ErrorResult result;
   nsRefPtr<Promise> promise = Promise::Create(sgo, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
 
   nsCOMPtr<nsIRunnable> runnable =
     new GetReadyPromiseRunnable(window, promise);
   promise.forget(aPromise);
   return NS_DispatchToCurrentThread(runnable);
 }
 
--- a/dom/workers/ServiceWorkerScriptCache.cpp
+++ b/dom/workers/ServiceWorkerScriptCache.cpp
@@ -178,22 +178,22 @@ public:
     MOZ_ASSERT(aPrincipal);
     AssertIsOnMainThread();
 
     mURL = aURL;
 
     ErrorResult rv;
     nsRefPtr<CacheStorage> cacheStorage = CreateCacheStorage(aPrincipal, rv);
     if (NS_WARN_IF(rv.Failed())) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
 
     nsRefPtr<Promise> promise = cacheStorage->Open(aCacheName, rv);
     if (NS_WARN_IF(rv.Failed())) {
-      return rv.ErrorCode();
+      return rv.StealNSResult();
     }
 
     promise->AppendNativeHandler(this);
     return NS_OK;
   }
 
   void
   Abort()
@@ -612,24 +612,24 @@ PurgeCache(nsIPrincipal* aPrincipal, con
 
   if (aCacheName.IsEmpty()) {
     return NS_OK;
   }
 
   ErrorResult rv;
   nsRefPtr<CacheStorage> cacheStorage = CreateCacheStorage(aPrincipal, rv);
   if (NS_WARN_IF(rv.Failed())) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   // We use the ServiceWorker scope as key for the cacheStorage.
   nsRefPtr<Promise> promise =
     cacheStorage->Delete(aCacheName, rv);
   if (NS_WARN_IF(rv.Failed())) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   // We don't actually care about the result of the delete operation.
   return NS_OK;
 }
 
 nsresult
 GenerateCacheName(nsAString& aName)
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1488,17 +1488,17 @@ OpenRunnable::MainThreadRunInternal()
 
   ErrorResult rv2;
   mProxy->mXHR->Open(mMethod, mURL, true, mUser, mPassword, rv2);
 
   MOZ_ASSERT(mProxy->mInOpen);
   mProxy->mInOpen = false;
 
   if (rv2.Failed()) {
-    return rv2.ErrorCode();
+    return rv2.StealNSResult();
   }
 
   return mProxy->mXHR->SetResponseType(NS_LITERAL_STRING("text"));
 }
 
 
 nsresult
 SendRunnable::MainThreadRun()
--- a/dom/xml/XMLDocument.cpp
+++ b/dom/xml/XMLDocument.cpp
@@ -280,17 +280,17 @@ XMLDocument::SetAsync(bool aAsync)
   return NS_OK;
 }
 
 NS_IMETHODIMP
 XMLDocument::Load(const nsAString& aUrl, bool *aReturn)
 {
   ErrorResult rv;
   *aReturn = Load(aUrl, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 bool
 XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
 {
   bool hasHadScriptObject = true;
   nsIScriptGlobalObject* scriptObject =
     GetScriptHandlingObject(hasHadScriptObject);
--- a/dom/xslt/xpath/XPathEvaluator.cpp
+++ b/dom/xslt/xpath/XPathEvaluator.cpp
@@ -90,30 +90,30 @@ XPathEvaluator::Evaluate(const nsAString
                          nsISupports *aInResult,
                          nsISupports **aResult)
 {
     nsCOMPtr<nsINode> resolver = do_QueryInterface(aResolver);
     ErrorResult rv;
     nsAutoPtr<XPathExpression> expression(CreateExpression(aExpression,
                                                            resolver, rv));
     if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
     }
 
     nsCOMPtr<nsINode> node = do_QueryInterface(aContextNode);
     if (!node) {
         return NS_ERROR_FAILURE;
     }
 
     nsCOMPtr<nsIXPathResult> inResult = do_QueryInterface(aInResult);
     nsRefPtr<XPathResult> result =
         expression->Evaluate(*node, aType,
                              static_cast<XPathResult*>(inResult.get()), rv);
     if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
     }
 
     *aResult = ToSupports(result.forget().take());
 
     return NS_OK;
 }
 
 XPathExpression*
@@ -211,17 +211,17 @@ nsresult XPathEvaluatorParseContext::res
         aPrefix->ToString(prefix);
     }
 
     nsVoidableString ns;
     if (mResolver) {
         ErrorResult rv;
         mResolver->LookupNamespaceURI(prefix, ns, rv);
         if (rv.Failed()) {
-            return rv.ErrorCode();
+            return rv.StealNSResult();
         }
     } else {
         if (aPrefix == nsGkAtoms::xml) {
             ns.AssignLiteral("http://www.w3.org/XML/1998/namespace");
         } else {
             mResolverNode->LookupNamespaceURI(prefix, ns);
         }
     }
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -732,17 +732,17 @@ XULDocument::AddBroadcastListenerFor(nsI
                                      nsIDOMElement* aListener,
                                      const nsAString& aAttr)
 {
     ErrorResult rv;
     nsCOMPtr<Element> broadcaster = do_QueryInterface(aBroadcaster);
     nsCOMPtr<Element> listener = do_QueryInterface(aListener);
     NS_ENSURE_ARG(broadcaster && listener);
     AddBroadcastListenerFor(*broadcaster, *listener, aAttr, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 void
 XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
                                      const nsAString& aAttr, ErrorResult& aRv)
 {
     nsresult rv =
         nsContentUtils::CheckSameOrigin(this, &aBroadcaster);
@@ -1215,17 +1215,17 @@ NS_IMETHODIMP
 XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                       const nsAString& aAttribute,
                                       const nsAString& aValue,
                                       nsIDOMNodeList** aReturn)
 {
     ErrorResult rv;
     *aReturn = GetElementsByAttributeNS(aNamespaceURI, aAttribute,
                                         aValue, rv).take();
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 already_AddRefed<nsINodeList>
 XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                       const nsAString& aAttribute,
                                       const nsAString& aValue,
                                       ErrorResult& aRv)
 {
@@ -1521,17 +1521,17 @@ XULDocument::GetPopupRangeParent(ErrorRe
 
 // Returns the rangeOffset element from the XUL Popup Manager. We check the
 // rangeParent to determine if the caller has rights to access to the data.
 NS_IMETHODIMP
 XULDocument::GetPopupRangeOffset(int32_t* aRangeOffset)
 {
     ErrorResult rv;
     *aRangeOffset = GetPopupRangeOffset(rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 int32_t
 XULDocument::GetPopupRangeOffset(ErrorResult& aRv)
 {
     nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
     if (!pm) {
         aRv.Throw(NS_ERROR_FAILURE);
@@ -4301,17 +4301,17 @@ XULDocument::CheckBroadcasterHookup(Elem
         default:
             return rv;
     }
 
     NS_ENSURE_ARG(broadcaster && listener);
     ErrorResult domRv;
     AddBroadcastListenerFor(*broadcaster, *listener, attribute, domRv);
     if (domRv.Failed()) {
-        return domRv.ErrorCode();
+        return domRv.StealNSResult();
     }
 
 #ifdef PR_LOGGING
     // Tell the world we succeeded
     if (PR_LOG_TEST(gXULLog, PR_LOG_NOTICE)) {
         nsCOMPtr<nsIContent> content =
             do_QueryInterface(listener);
 
@@ -4652,17 +4652,17 @@ XULDocument::GetDocumentLWTheme()
 }
 
 NS_IMETHODIMP
 XULDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
 {
     ErrorResult rv;
     nsCOMPtr<Element> el = do_QueryInterface(aElement);
     *aResult = GetBoxObjectFor(el, rv).take();
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 JSObject*
 XULDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return XULDocumentBinding::Wrap(aCx, this, aGivenProto);
 }
 
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -460,17 +460,17 @@ NS_IMETHODIMP
 nsXULElement::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                        const nsAString& aAttribute,
                                        const nsAString& aValue,
                                        nsIDOMNodeList** aReturn)
 {
     ErrorResult rv;
     *aReturn =
         GetElementsByAttributeNS(aNamespaceURI, aAttribute, aValue, rv).take();
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 already_AddRefed<nsINodeList>
 nsXULElement::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                        const nsAString& aAttribute,
                                        const nsAString& aValue,
                                        ErrorResult& rv)
 {
@@ -1365,17 +1365,17 @@ nsXULElement::PreHandleEvent(EventChainP
 }
 
 // XXX This _should_ be an implementation method, _not_ publicly exposed :-(
 NS_IMETHODIMP
 nsXULElement::GetResource(nsIRDFResource** aResource)
 {
     ErrorResult rv;
     *aResource = GetResource(rv).take();
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 already_AddRefed<nsIRDFResource>
 nsXULElement::GetResource(ErrorResult& rv)
 {
     nsAutoString id;
     GetAttr(kNameSpaceID_None, nsGkAtoms::ref, id);
     if (id.IsEmpty()) {
@@ -1478,17 +1478,17 @@ nsXULElement::IsAttributeMapped(const ns
 }
 
 // Controllers Methods
 NS_IMETHODIMP
 nsXULElement::GetControllers(nsIControllers** aResult)
 {
     ErrorResult rv;
     NS_IF_ADDREF(*aResult = GetControllers(rv));
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 nsIControllers*
 nsXULElement::GetControllers(ErrorResult& rv)
 {
     if (! Controllers()) {
         nsDOMSlots* slots = DOMSlots();
 
@@ -1505,17 +1505,17 @@ nsXULElement::GetControllers(ErrorResult
     return Controllers();
 }
 
 NS_IMETHODIMP
 nsXULElement::GetBoxObject(nsIBoxObject** aResult)
 {
     ErrorResult rv;
     *aResult = GetBoxObject(rv).take();
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 already_AddRefed<BoxObject>
 nsXULElement::GetBoxObject(ErrorResult& rv)
 {
     // XXX sXBL/XBL2 issue! Owner or current document?
     return OwnerDoc()->GetBoxObjectFor(this, rv);
 }
@@ -1643,17 +1643,17 @@ nsXULElement::SwapFrameLoaders(nsIFrameL
     nsCOMPtr<nsIContent> otherContent(do_QueryInterface(aOtherOwner));
     NS_ENSURE_TRUE(otherContent, NS_ERROR_NOT_IMPLEMENTED);
 
     nsXULElement* otherEl = FromContent(otherContent);
     NS_ENSURE_TRUE(otherEl, NS_ERROR_NOT_IMPLEMENTED);
 
     ErrorResult rv;
     SwapFrameLoaders(*otherEl, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 void
 nsXULElement::SwapFrameLoaders(nsXULElement& aOtherElement, ErrorResult& rv)
 {
     if (&aOtherElement == this) {
         // nothing to do
         return;
@@ -1692,17 +1692,17 @@ nsXULElement::GetParentTree(nsIDOMXULMul
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXULElement::Focus()
 {
     ErrorResult rv;
     Focus(rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 void
 nsXULElement::Focus(ErrorResult& rv)
 {
     nsIFocusManager* fm = nsFocusManager::GetFocusManager();
     nsCOMPtr<nsIDOMElement> elem = do_QueryObject(this);
     if (fm) {
@@ -1710,17 +1710,17 @@ nsXULElement::Focus(ErrorResult& rv)
     }
 }
 
 NS_IMETHODIMP
 nsXULElement::Blur()
 {
     ErrorResult rv;
     Blur(rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
 }
 
 void
 nsXULElement::Blur(ErrorResult& rv)
 {
     if (!ShouldBlur(this))
       return;
 
--- a/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
@@ -50,17 +50,17 @@ nsXULTemplateResultSetXML::HasMoreElemen
 }
 
 NS_IMETHODIMP
 nsXULTemplateResultSetXML::GetNext(nsISupports **aResult)
 {
     ErrorResult rv;
     nsINode* node = mResults->SnapshotItem(mPosition, rv);
     if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
     }
 
     nsXULTemplateResultXML* result =
         new nsXULTemplateResultXML(mQuery, node->AsContent(), mBindingSet);
 
     ++mPosition;
     *aResult = result;
     NS_ADDREF(result);
@@ -247,17 +247,17 @@ nsXULTemplateQueryProcessorXML::CompileQ
     if (expr.IsEmpty())
         expr.Assign('*');
 
     ErrorResult rv;
     nsAutoPtr<XPathExpression> compiledexpr;
     compiledexpr = CreateExpression(expr, content, rv);
     if (rv.Failed()) {
         nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_BAD_XPATH);
-        return rv.ErrorCode();
+        return rv.StealNSResult();
     }
 
     nsRefPtr<nsXMLQuery> query =
         new nsXMLQuery(this, aMemberVariable, Move(compiledexpr));
 
     for (nsIContent* condition = content->GetFirstChild();
          condition;
          condition = condition->GetNextSibling()) {
@@ -270,17 +270,17 @@ nsXULTemplateQueryProcessorXML::CompileQ
             nsAutoString expr;
             condition->GetAttr(kNameSpaceID_None, nsGkAtoms::expr, expr);
 
             // ignore assignments without a variable or an expression
             if (!var.IsEmpty() && !expr.IsEmpty()) {
                 compiledexpr = CreateExpression(expr, condition, rv);
                 if (rv.Failed()) {
                     nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_BAD_ASSIGN_XPATH);
-                    return rv.ErrorCode();
+                    return rv.StealNSResult();
                 }
 
                 nsCOMPtr<nsIAtom> varatom = do_GetAtom(var);
 
                 query->AddBinding(varatom, Move(compiledexpr));
             }
         }
     }
@@ -318,17 +318,17 @@ nsXULTemplateQueryProcessorXML::Generate
     if (!expr)
         return NS_ERROR_FAILURE;
 
     ErrorResult rv;
     nsRefPtr<XPathResult> exprresults =
         expr->Evaluate(*context, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE,
                        nullptr, rv);
     if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
     }
 
     nsRefPtr<nsXULTemplateResultSetXML> results =
         new nsXULTemplateResultSetXML(xmlquery, exprresults.forget(),
                                       xmlquery->GetBindingSet());
 
     results.forget(aResults);
 
--- a/editor/libeditor/CreateElementTxn.cpp
+++ b/editor/libeditor/CreateElementTxn.cpp
@@ -68,17 +68,17 @@ CreateElementTxn::DoTransaction()
 
   // Try to insert formatting whitespace for the new node:
   mEditor->MarkNodeDirty(GetAsDOMNode(mNewNode));
 
   // Insert the new node
   ErrorResult rv;
   if (mOffsetInParent == -1) {
     mParent->AppendChild(*mNewNode, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   mOffsetInParent = std::min(mOffsetInParent,
                              static_cast<int32_t>(mParent->GetChildCount()));
 
   // Note, it's ok for mRefNode to be null. That means append
   mRefNode = mParent->GetChildAt(mOffsetInParent);
 
@@ -103,32 +103,32 @@ CreateElementTxn::DoTransaction()
 NS_IMETHODIMP
 CreateElementTxn::UndoTransaction()
 {
   MOZ_ASSERT(mEditor && mParent);
 
   ErrorResult rv;
   mParent->RemoveChild(*mNewNode, rv);
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 CreateElementTxn::RedoTransaction()
 {
   MOZ_ASSERT(mEditor && mParent);
 
   // First, reset mNewNode so it has no attributes or content
   // XXX We never actually did this, we only cleared mNewNode's contents if it
   // was a CharacterData node (which it's not, it's an Element)
 
   // Now, reinsert mNewNode
   ErrorResult rv;
   mParent->InsertBefore(*mNewNode, mRefNode, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 CreateElementTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("CreateElementTxn: ");
   aString += nsDependentAtomString(mTag);
   return NS_OK;
--- a/editor/libeditor/DeleteNodeTxn.cpp
+++ b/editor/libeditor/DeleteNodeTxn.cpp
@@ -67,33 +67,33 @@ DeleteNodeTxn::DoTransaction()
   // *before* we do the action, unlike some of the other nsRangeStore update
   // methods.
   if (mRangeUpdater) {
     mRangeUpdater->SelAdjDeleteNode(mNode->AsDOMNode());
   }
 
   ErrorResult error;
   mParent->RemoveChild(*mNode, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 NS_IMETHODIMP
 DeleteNodeTxn::UndoTransaction()
 {
   if (!mParent) {
     // this is a legal state, the txn is a no-op
     return NS_OK;
   }
   if (!mNode) {
     return NS_ERROR_NULL_POINTER;
   }
 
   ErrorResult error;
   mParent->InsertBefore(*mNode, mRefNode, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 NS_IMETHODIMP
 DeleteNodeTxn::RedoTransaction()
 {
   if (!mParent) {
     // this is a legal state, the txn is a no-op
     return NS_OK;
@@ -103,17 +103,17 @@ DeleteNodeTxn::RedoTransaction()
   }
 
   if (mRangeUpdater) {
     mRangeUpdater->SelAdjDeleteNode(mNode->AsDOMNode());
   }
 
   ErrorResult error;
   mParent->RemoveChild(*mNode, error);
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 NS_IMETHODIMP
 DeleteNodeTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("DeleteNodeTxn");
   return NS_OK;
 }
--- a/editor/libeditor/InsertNodeTxn.cpp
+++ b/editor/libeditor/InsertNodeTxn.cpp
@@ -76,17 +76,17 @@ InsertNodeTxn::DoTransaction()
 
 NS_IMETHODIMP
 InsertNodeTxn::UndoTransaction()
 {
   MOZ_ASSERT(mNode && mParent);
 
   ErrorResult rv;
   mParent->RemoveChild(*mNode, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 InsertNodeTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("InsertNodeTxn");
   return NS_OK;
 }
--- a/editor/libeditor/JoinNodeTxn.cpp
+++ b/editor/libeditor/JoinNodeTxn.cpp
@@ -77,29 +77,29 @@ JoinNodeTxn::UndoTransaction()
   // First, massage the existing node so it is in its post-split state
   ErrorResult rv;
   if (mRightNode->GetAsText()) {
     rv = mRightNode->GetAsText()->DeleteData(0, mOffset);
   } else {
     nsCOMPtr<nsIContent> child = mRightNode->GetFirstChild();
     for (uint32_t i = 0; i < mOffset; i++) {
       if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
       }
       if (!child) {
         return NS_ERROR_NULL_POINTER;
       }
       nsCOMPtr<nsIContent> nextSibling = child->GetNextSibling();
       mLeftNode->AppendChild(*child, rv);
       child = nextSibling;
     }
   }
   // Second, re-insert the left node into the tree
   mParent->InsertBefore(*mLeftNode, mRightNode, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 JoinNodeTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("JoinNodeTxn");
   return NS_OK;
 }
--- a/editor/libeditor/SplitNodeTxn.cpp
+++ b/editor/libeditor/SplitNodeTxn.cpp
@@ -58,17 +58,17 @@ SplitNodeTxn::DoTransaction()
 
   // Insert the new node
   rv = mEditor.SplitNodeImpl(*mExistingRightNode, mOffset, *mNewLeftNode);
   if (mEditor.GetShouldTxnSetSelection()) {
     nsRefPtr<Selection> selection = mEditor.GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     rv = selection->Collapse(mNewLeftNode, mOffset);
   }
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 NS_IMETHODIMP
 SplitNodeTxn::UndoTransaction()
 {
   MOZ_ASSERT(mNewLeftNode && mParent);
 
   // This assumes Do inserted the new node in front of the prior existing node
@@ -89,32 +89,32 @@ SplitNodeTxn::RedoTransaction()
   if (mExistingRightNode->GetAsText()) {
     rv = mExistingRightNode->GetAsText()->DeleteData(0, mOffset);
     NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
   } else {
     nsCOMPtr<nsIContent> child = mExistingRightNode->GetFirstChild();
     nsCOMPtr<nsIContent> nextSibling;
     for (int32_t i=0; i < mOffset; i++) {
       if (rv.Failed()) {
-        return rv.ErrorCode();
+        return rv.StealNSResult();
       }
       if (!child) {
         return NS_ERROR_NULL_POINTER;
       }
       nextSibling = child->GetNextSibling();
       mExistingRightNode->RemoveChild(*child, rv);
       if (!rv.Failed()) {
         mNewLeftNode->AppendChild(*child, rv);
       }
       child = nextSibling;
     }
   }
   // Second, re-insert the left node into the tree
   mParent->InsertBefore(*mNewLeftNode, mExistingRightNode, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 
 NS_IMETHODIMP
 SplitNodeTxn::GetTxnDescription(nsAString& aString)
 {
   aString.AssignLiteral("SplitNodeTxn");
   return NS_OK;
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -1419,17 +1419,17 @@ nsEditor::SplitNode(nsIDOMNode* aNode,
                     int32_t aOffset,
                     nsIDOMNode** aNewLeftNode)
 {
   nsCOMPtr<nsIContent> node = do_QueryInterface(aNode);
   NS_ENSURE_STATE(node);
   ErrorResult rv;
   nsCOMPtr<nsIContent> newNode = SplitNode(*node, aOffset, rv);
   *aNewLeftNode = GetAsDOMNode(newNode.forget().take());
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 nsIContent*
 nsEditor::SplitNode(nsIContent& aNode, int32_t aOffset, ErrorResult& aResult)
 {
   nsAutoRules beginRulesSniffing(this, EditAction::splitNode,
                                  nsIEditor::eNext);
 
@@ -2868,17 +2868,17 @@ nsEditor::JoinNodesImpl(nsINode* aNodeTo
 
   if (shouldSetSelection) {
     // Editor wants us to set selection at join point.
     nsRefPtr<Selection> selection = GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
     selection->Collapse(aNodeToKeep, AssertedCast<int32_t>(firstNodeLength));
   }
 
-  return err.ErrorCode();
+  return err.StealNSResult();
 }
 
 
 int32_t
 nsEditor::GetChildOffset(nsIDOMNode* aChild, nsIDOMNode* aParent)
 {
   MOZ_ASSERT(aChild && aParent);
 
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -1217,17 +1217,17 @@ nsresult nsHTMLEditor::InsertFromDataTra
                                               nsIDOMDocument *aSourceDoc,
                                               nsIDOMNode *aDestinationNode,
                                               int32_t aDestOffset,
                                               bool aDoDeleteSelection)
 {
   ErrorResult rv;
   nsRefPtr<DOMStringList> types = aDataTransfer->MozTypesAt(aIndex, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   bool hasPrivateHTMLFlavor = types->Contains(NS_LITERAL_STRING(kHTMLContext));
 
   bool isText = IsPlaintextEditor();
   bool isSafe = IsSafeToInsertData(aSourceDoc);
 
   uint32_t length = types->Length();
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -1206,17 +1206,17 @@ nsHTMLEditor::ReplaceHeadContentsWithHTM
   // XXXX BUG 50965: This is not returning the text between <title>...</title>
   // Special code is needed in JS to handle title anyway, so it doesn't matter!
 
   if (err.Failed()) {
 #ifdef DEBUG
     printf("Couldn't create contextual fragment: error was %X\n",
            static_cast<uint32_t>(err.ErrorCode()));
 #endif
-    return err.ErrorCode();
+    return err.StealNSResult();
   }
   NS_ENSURE_TRUE(docfrag, NS_ERROR_NULL_POINTER);
 
   // First delete all children in head
   while (nsCOMPtr<nsIContent> child = headNode->GetFirstChild()) {
     nsresult res = DeleteNode(child);
     NS_ENSURE_SUCCESS(res, res);
   }
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -1747,17 +1747,17 @@ mozInlineSpellChecker::RemoveRange(Selec
   NS_ENSURE_ARG_POINTER(aSpellCheckSelection);
   NS_ENSURE_ARG_POINTER(aRange);
 
   ErrorResult rv;
   aSpellCheckSelection->RemoveRange(*aRange, rv);
   if (!rv.Failed() && mNumWordsInSpellSelection)
     mNumWordsInSpellSelection--;
 
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 
 // mozInlineSpellChecker::AddRange
 //
 //    For performance reasons, we have an upper bound on the number of word
 //    ranges we'll add to the spell check selection. Once we reach that upper
 //    bound, stop adding the ranges
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -1079,17 +1079,17 @@ Selection::Stringify(nsAString& aResult)
 NS_IMETHODIMP
 Selection::ToStringWithFormat(const char* aFormatType, uint32_t aFlags,
                               int32_t aWrapCol, nsAString& aReturn)
 {
   ErrorResult result;
   NS_ConvertUTF8toUTF16 format(aFormatType);
   ToStringWithFormat(format, aFlags, aWrapCol, aReturn, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
   return NS_OK;
 }
 
 void
 Selection::ToStringWithFormat(const nsAString& aFormatType, uint32_t aFlags,
                               int32_t aWrapCol, nsAString& aReturn,
                               ErrorResult& aRv)
@@ -1136,17 +1136,17 @@ Selection::ToStringWithFormat(const nsAS
 }
 
 NS_IMETHODIMP
 Selection::SetInterlinePosition(bool aHintRight)
 {
   ErrorResult result;
   SetInterlinePosition(aHintRight, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
   return NS_OK;
 }
 
 void
 Selection::SetInterlinePosition(bool aHintRight, ErrorResult& aRv)
 {
   if (!mFrameSelection) {
@@ -1157,17 +1157,17 @@ Selection::SetInterlinePosition(bool aHi
 }
 
 NS_IMETHODIMP
 Selection::GetInterlinePosition(bool* aHintRight)
 {
   ErrorResult result;
   *aHintRight = GetInterlinePosition(result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
   return NS_OK;
 }
 
 bool
 Selection::GetInterlinePosition(ErrorResult& aRv)
 {
   if (!mFrameSelection) {
@@ -3866,17 +3866,17 @@ Selection::GetRangesForInterval(nsIDOMNo
   nsTArray<nsRefPtr<nsRange>> results;
   ErrorResult result;
   nsCOMPtr<nsINode> beginNode = do_QueryInterface(aBeginNode);
   nsCOMPtr<nsINode> endNode = do_QueryInterface(aEndNode);
   NS_ENSURE_TRUE(beginNode && endNode, NS_ERROR_NULL_POINTER);
   GetRangesForInterval(*beginNode, aBeginOffset, *endNode, aEndOffset,
                        aAllowAdjacent, results, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
   *aResultCount = results.Length();
   if (*aResultCount == 0) {
     return NS_OK;
   }
 
   *aResults = static_cast<nsIDOMRange**>
                          (moz_xmalloc(sizeof(nsIDOMRange*) * *aResultCount));
@@ -4569,17 +4569,17 @@ Selection::DoAutoScroll(nsIFrame* aFrame
 
 /** RemoveAllRanges zeroes the selection
  */
 NS_IMETHODIMP
 Selection::RemoveAllRanges()
 {
   ErrorResult result;
   RemoveAllRanges(result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::RemoveAllRanges(ErrorResult& aRv)
 {
   if (!mFrameSelection)
     return; // nothing to do
   nsRefPtr<nsPresContext>  presContext = GetPresContext();
@@ -4607,17 +4607,17 @@ NS_IMETHODIMP
 Selection::AddRange(nsIDOMRange* aDOMRange)
 {
   if (!aDOMRange) {
     return NS_ERROR_NULL_POINTER;
   }
   nsRange* range = static_cast<nsRange*>(aDOMRange);
   ErrorResult result;
   AddRange(*range, result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::AddRange(nsRange& aRange, ErrorResult& aRv)
 {
   // This inserts a table cell range in proper document order
   // and returns NS_OK if range doesn't contain just one table cell
   bool didAddRange;
@@ -4674,17 +4674,17 @@ nsresult
 Selection::RemoveRange(nsIDOMRange* aDOMRange)
 {
   if (!aDOMRange) {
     return NS_ERROR_INVALID_ARG;
   }
   nsRange* range = static_cast<nsRange*>(aDOMRange);
   ErrorResult result;
   RemoveRange(*range, result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::RemoveRange(nsRange& aRange, ErrorResult& aRv)
 {
   nsresult rv = RemoveItem(&aRange);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
@@ -4772,17 +4772,17 @@ Selection::CollapseNative(nsINode* aPare
 nsresult
 Selection::Collapse(nsINode* aParentNode, int32_t aOffset)
 {
   if (!aParentNode)
     return NS_ERROR_INVALID_ARG;
 
   ErrorResult result;
   Collapse(*aParentNode, static_cast<uint32_t>(aOffset), result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::Collapse(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
 {
   if (!mFrameSelection) {
     aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection
     return;
@@ -4848,17 +4848,17 @@ Selection::Collapse(nsINode& aParentNode
  * Sets the whole selection to be one point
  * at the start of the current selection
  */
 NS_IMETHODIMP
 Selection::CollapseToStart()
 {
   ErrorResult result;
   CollapseToStart(result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::CollapseToStart(ErrorResult& aRv)
 {
   int32_t cnt;
   nsresult rv = GetRangeCount(&cnt);
   if (NS_FAILED(rv) || cnt <= 0) {
@@ -4889,17 +4889,17 @@ Selection::CollapseToStart(ErrorResult& 
  * Sets the whole selection to be one point
  * at the end of the current selection
  */
 NS_IMETHODIMP
 Selection::CollapseToEnd()
 {
   ErrorResult result;
   CollapseToEnd(result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::CollapseToEnd(ErrorResult& aRv)
 {
   int32_t cnt;
   nsresult rv = GetRangeCount(&cnt);
   if (NS_FAILED(rv) || cnt <= 0) {
@@ -4969,17 +4969,17 @@ Selection::GetRangeCount(int32_t* aRange
 }
 
 NS_IMETHODIMP
 Selection::GetRangeAt(int32_t aIndex, nsIDOMRange** aReturn)
 {
   ErrorResult result;
   *aReturn = GetRangeAt(aIndex, result);
   NS_IF_ADDREF(*aReturn);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 nsRange*
 Selection::GetRangeAt(uint32_t aIndex, ErrorResult& aRv)
 {
   nsRange* range = GetRangeAt(aIndex);
   if (!range) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
@@ -5100,17 +5100,17 @@ Selection::ExtendNative(nsINode* aParent
 nsresult
 Selection::Extend(nsINode* aParentNode, int32_t aOffset)
 {
   if (!aParentNode)
     return NS_ERROR_INVALID_ARG;
 
   ErrorResult result;
   Extend(*aParentNode, static_cast<uint32_t>(aOffset), result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::Extend(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
 {
   // First, find the range containing the old focus point:
   if (!mAnchorFocusRange) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
@@ -5400,17 +5400,17 @@ Selection::Extend(nsINode& aParentNode, 
 
 NS_IMETHODIMP
 Selection::SelectAllChildren(nsIDOMNode* aParentNode)
 {
   ErrorResult result;
   nsCOMPtr<nsINode> node = do_QueryInterface(aParentNode);
   NS_ENSURE_TRUE(node, NS_ERROR_INVALID_ARG);
   SelectAllChildren(*node, result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::SelectAllChildren(nsINode& aNode, ErrorResult& aRv)
 {
   if (mFrameSelection)
   {
     mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON);
@@ -5436,17 +5436,17 @@ Selection::ContainsNode(nsIDOMNode* aNod
   *aYes = false;
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   if (!node) {
     return NS_ERROR_NULL_POINTER;
   }
   ErrorResult result;
   *aYes = ContainsNode(*node, aAllowPartial, result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 bool
 Selection::ContainsNode(nsINode& aNode, bool aAllowPartial, ErrorResult& aRv)
 {
   nsresult rv;
   if (mRanges.Length() == 0) {
     return false;
@@ -5678,17 +5678,17 @@ Selection::PostScrollSelectionIntoViewEv
 
 NS_IMETHODIMP
 Selection::ScrollIntoView(SelectionRegion aRegion, bool aIsSynchronous,
                           int16_t aVPercent, int16_t aHPercent)
 {
   ErrorResult result;
   ScrollIntoView(aRegion, aIsSynchronous, aVPercent, aHPercent, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
   return NS_OK;
 }
 
 void
 Selection::ScrollIntoView(int16_t aRegion, bool aIsSynchronous,
                           int16_t aVPercent, int16_t aHPercent,
                           ErrorResult& aRv)
@@ -5774,17 +5774,17 @@ Selection::ScrollIntoView(SelectionRegio
 NS_IMETHODIMP
 Selection::AddSelectionListener(nsISelectionListener* aNewListener)
 {
   if (!aNewListener)
     return NS_ERROR_NULL_POINTER;
   ErrorResult result;
   AddSelectionListener(aNewListener, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
   return NS_OK;
 }
 
 void
 Selection::AddSelectionListener(nsISelectionListener* aNewListener,
                                 ErrorResult& aRv)
 {
@@ -5797,17 +5797,17 @@ Selection::AddSelectionListener(nsISelec
 NS_IMETHODIMP
 Selection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove)
 {
   if (!aListenerToRemove)
     return NS_ERROR_NULL_POINTER;
   ErrorResult result;
   RemoveSelectionListener(aListenerToRemove, result);
   if (result.Failed()) {
-    return result.ErrorCode();
+    return result.StealNSResult();
   }
   return NS_OK;
 }
 
 void
 Selection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove,
                                    ErrorResult& aRv)
 {
@@ -5868,17 +5868,17 @@ Selection::EndBatchChanges()
 
 
 
 NS_IMETHODIMP
 Selection::DeleteFromDocument()
 {
   ErrorResult result;
   DeleteFromDocument(result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::DeleteFromDocument(ErrorResult& aRv)
 {
   if (!mFrameSelection)
     return;//nothing to do
   nsresult rv = mFrameSelection->DeleteFromDocument();
@@ -5888,17 +5888,17 @@ Selection::DeleteFromDocument(ErrorResul
 }
 
 NS_IMETHODIMP
 Selection::Modify(const nsAString& aAlter, const nsAString& aDirection,
                   const nsAString& aGranularity)
 {
   ErrorResult result;
   Modify(aAlter, aDirection, aGranularity, result);
-  return result.ErrorCode();
+  return result.StealNSResult();
 }
 
 void
 Selection::Modify(const nsAString& aAlter, const nsAString& aDirection,
                   const nsAString& aGranularity, ErrorResult& aRv)
 {
   // Silently exit if there's no selection or no focus node.
   if (!mFrameSelection || !GetAnchorFocusRange() || !GetFocusNode()) {
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -290,17 +290,17 @@ inDOMUtils::GetRuleColumn(nsIDOMCSSRule*
 }
 
 NS_IMETHODIMP
 inDOMUtils::GetSelectorCount(nsIDOMCSSStyleRule* aRule, uint32_t *aCount)
 {
   ErrorResult rv;
   nsRefPtr<StyleRule> rule = GetRuleFromDOMRule(aRule, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   uint32_t count = 0;
   for (nsCSSSelectorList* sel = rule->Selector(); sel; sel = sel->mNext) {
     ++count;
   }
   *aCount = count;
   return NS_OK;
@@ -329,17 +329,17 @@ GetSelectorAtIndex(nsIDOMCSSStyleRule* a
 NS_IMETHODIMP
 inDOMUtils::GetSelectorText(nsIDOMCSSStyleRule* aRule,
                             uint32_t aSelectorIndex,
                             nsAString& aText)
 {
   ErrorResult rv;
   nsCSSSelectorList* sel = GetSelectorAtIndex(aRule, aSelectorIndex, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   nsRefPtr<StyleRule> rule = GetRuleFromDOMRule(aRule, rv);
   MOZ_ASSERT(!rv.Failed(), "How could we get a selector but not a rule?");
 
   sel->mSelectors->ToString(aText, rule->GetStyleSheet(), false);
   return NS_OK;
 }
@@ -347,17 +347,17 @@ inDOMUtils::GetSelectorText(nsIDOMCSSSty
 NS_IMETHODIMP
 inDOMUtils::GetSpecificity(nsIDOMCSSStyleRule* aRule,
                             uint32_t aSelectorIndex,
                             uint64_t* aSpecificity)
 {
   ErrorResult rv;
   nsCSSSelectorList* sel = GetSelectorAtIndex(aRule, aSelectorIndex, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   *aSpecificity = sel->mWeight;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 inDOMUtils::SelectorMatchesElement(nsIDOMElement* aElement,
@@ -367,17 +367,17 @@ inDOMUtils::SelectorMatchesElement(nsIDO
                                    bool* aMatches)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_ARG_POINTER(element);
 
   ErrorResult rv;
   nsCSSSelectorList* tail = GetSelectorAtIndex(aRule, aSelectorIndex, rv);
   if (rv.Failed()) {
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   // We want just the one list item, not the whole list tail
   nsAutoPtr<nsCSSSelectorList> sel(tail->Clone(false));
 
   // Do not attempt to match if a pseudo element is requested and this is not
   // a pseudo element selector, or vice versa.
   if (aPseudo.IsEmpty() == sel->mSelectors->IsPseudoElement()) {
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -1765,17 +1765,17 @@ CSSStyleSheet::GetDOMOwnerRule() const
 }
 
 NS_IMETHODIMP    
 CSSStyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules)
 {
   ErrorResult rv;
   nsCOMPtr<nsIDOMCSSRuleList> rules = GetCssRules(rv);
   rules.forget(aCssRules);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 CSSRuleList*
 CSSStyleSheet::GetCssRules(ErrorResult& aRv)
 {
   // No doing this on incomplete sheets!
   if (!mInner->mComplete) {
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -360,24 +360,24 @@ NS_IMETHODIMP
 nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
                                      nsAString& aReturn)
 {
   aReturn.Truncate();
 
   ErrorResult error;
   nsRefPtr<CSSValue> val = GetPropertyCSSValue(aPropertyName, error);
   if (error.Failed()) {
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   if (val) {
     nsString text;
     val->GetCssText(text, error);
     aReturn.Assign(text);
-    return error.ErrorCode();
+    return error.StealNSResult();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComputedDOMStyle::GetAuthoredPropertyValue(const nsAString& aPropertyName,
                                              nsAString& aReturn)
--- a/layout/style/nsICSSDeclaration.h
+++ b/layout/style/nsICSSDeclaration.h
@@ -73,17 +73,17 @@ public:
   virtual already_AddRefed<mozilla::dom::CSSValue>
     GetPropertyCSSValue(const nsAString& aPropertyName,
                         mozilla::ErrorResult& aRv) = 0;
   NS_IMETHOD GetPropertyCSSValue(const nsAString& aProp, nsIDOMCSSValue** aVal) override
   {
     mozilla::ErrorResult error;
     nsRefPtr<mozilla::dom::CSSValue> val = GetPropertyCSSValue(aProp, error);
     if (error.Failed()) {
-      return error.ErrorCode();
+      return error.StealNSResult();
     }
 
     nsCOMPtr<nsIDOMCSSValue> xpVal = do_QueryInterface(val);
     xpVal.forget(aVal);
     return NS_OK;
   }
   NS_IMETHOD RemoveProperty(const nsAString& aPropertyName,
                             nsAString& aReturn) override = 0;
--- a/layout/style/nsROCSSPrimitiveValue.cpp
+++ b/layout/style/nsROCSSPrimitiveValue.cpp
@@ -423,17 +423,17 @@ nsROCSSPrimitiveValue::GetFloatValue(uin
   return 0;
 }
 
 NS_IMETHODIMP
 nsROCSSPrimitiveValue::GetFloatValue(uint16_t aType, float *aVal)
 {
   ErrorResult rv;
   *aVal = GetFloatValue(aType, rv);
-  return rv.ErrorCode();
+  return rv.StealNSResult();
 }
 
 
 NS_IMETHODIMP
 nsROCSSPrimitiveValue::SetStringValue(uint16_t aStringType,
                                       const nsAString& aStringValue)
 {
   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -503,17 +503,17 @@ nsROCSSPrimitiveValue::GetRectValue(Erro
   return mValue.mRect;
 }
 
 NS_IMETHODIMP
 nsROCSSPrimitiveValue::GetRectValue(nsIDOMRect** aRect)
 {
   ErrorResult error;
   NS_IF_ADDREF(*aRect = GetRectValue(error));
-  return error.ErrorCode();
+  return error.StealNSResult();
 }
 
 nsDOMCSSRGBColor*
 nsROCSSPrimitiveValue::GetRGBColorValue(ErrorResult& aRv)
 {
   if (mType != CSS_RGBCOLOR) {
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return nullptr;
--- a/xpfe/appshell/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/nsContentTreeOwner.cpp
@@ -804,17 +804,17 @@ NS_IMETHODIMP nsContentTreeOwner::SetTit
             }
           }
         }
       }
     }
     nsIDocument* document = docShellElement->OwnerDoc();
     ErrorResult rv;
     document->SetTitle(title, rv);
-    return rv.ErrorCode();
+    return rv.StealNSResult();
   }
 
   return mXULWindow->SetTitle(title.get());
 }
 
 //*****************************************************************************
 // nsContentTreeOwner: nsIWindowProvider
 //*****************************************************************************