Bug 1457813 - Part 2: Replace non-asserting NS_ASSERTIONs with MOZ_ASSERTs. r?froydnj draft
authorChris Peterson <cpeterson@mozilla.com>
Sat, 28 Apr 2018 12:50:58 -0700
changeset 790928 3445d700a73bdbf8596c28f04ce862e5657d39e9
parent 790927 d35d23c2ce73d431889ceb9b841c94d6a5b1be9f
child 790929 99faa5ba5a2d074f83d7aa46a62eff148926c13e
push id108649
push usercpeterson@mozilla.com
push dateThu, 03 May 2018 06:11:06 +0000
reviewersfroydnj
bugs1457813
milestone61.0a1
Bug 1457813 - Part 2: Replace non-asserting NS_ASSERTIONs with MOZ_ASSERTs. r?froydnj s/NS_PRECONDITION/MOZ_ASSERT/ without whitespace or reindenting changes MozReview-Commit-ID: KuUsnVe2h8L
accessible/base/FocusManager.cpp
accessible/base/TextAttrs.cpp
accessible/generic/Accessible.cpp
accessible/generic/Accessible.h
accessible/mac/mozTextAccessible.mm
accessible/xpcom/xpcAccessibleSelectable.cpp
accessible/xul/XULTreeGridAccessible.cpp
caps/ContentPrincipal.cpp
caps/nsJSPrincipals.cpp
caps/nsScriptSecurityManager.cpp
chrome/nsChromeProtocolHandler.cpp
docshell/base/nsDSURIContentListener.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsWebNavigationInfo.cpp
docshell/build/nsDocShellModule.cpp
docshell/shistory/nsSHEntryShared.cpp
docshell/shistory/nsSHistory.cpp
dom/base/CharacterData.cpp
dom/base/Element.cpp
dom/base/Element.h
dom/base/EventSource.cpp
dom/base/FragmentOrElement.cpp
dom/base/IDTracker.h
dom/base/Selection.cpp
dom/base/nsAttrAndChildArray.cpp
dom/base/nsAttrAndChildArray.h
dom/base/nsAttrValue.cpp
dom/base/nsAttrValueInlines.h
dom/base/nsContentAreaDragDrop.cpp
dom/base/nsContentList.cpp
dom/base/nsContentList.h
dom/base/nsContentPolicy.cpp
dom/base/nsContentSink.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsDocument.cpp
dom/base/nsDocumentEncoder.cpp
dom/base/nsFocusManager.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsGenConImageContent.cpp
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsImageLoadingContent.cpp
dom/base/nsJSEnvironment.cpp
dom/base/nsMappedAttributes.cpp
dom/base/nsNameSpaceManager.cpp
dom/base/nsNodeInfoManager.cpp
dom/base/nsNodeUtils.cpp
dom/base/nsPropertyTable.cpp
dom/base/nsRange.cpp
dom/base/nsSyncLoadService.cpp
dom/base/nsTextNode.cpp
dom/base/nsTreeSanitizer.cpp
dom/canvas/CanvasUtils.cpp
dom/commandhandler/nsControllerCommandTable.cpp
dom/events/ContentEventHandler.cpp
dom/events/EventListenerService.cpp
dom/events/EventStateManager.cpp
dom/events/WheelHandlingHelper.cpp
dom/html/HTMLFormElement.cpp
dom/html/HTMLFrameSetElement.cpp
dom/html/HTMLImageElement.cpp
dom/html/HTMLInputElement.cpp
dom/html/HTMLSharedElement.cpp
dom/html/nsGenericHTMLElement.cpp
dom/html/nsGenericHTMLFrameElement.cpp
dom/html/nsHTMLContentSink.cpp
dom/jsurl/nsJSProtocolHandler.cpp
dom/script/nsIScriptElement.h
dom/security/nsCSPContext.cpp
dom/smil/SMILBoolType.cpp
dom/smil/SMILEnumType.cpp
dom/smil/SMILIntegerType.cpp
dom/smil/SMILStringType.cpp
dom/smil/nsSMILFloatType.cpp
dom/smil/nsSMILNullType.cpp
dom/svg/SVGIntegerPairSMILType.cpp
dom/svg/SVGLengthListSMILType.cpp
dom/svg/SVGNumberListSMILType.cpp
dom/svg/SVGNumberPairSMILType.cpp
dom/svg/SVGOrientSMILType.cpp
dom/svg/SVGPathSegListSMILType.cpp
dom/svg/SVGPointListSMILType.cpp
dom/svg/SVGTransformListSMILType.cpp
dom/svg/SVGViewBoxSMILType.cpp
dom/xbl/nsBindingManager.cpp
dom/xbl/nsXBLContentSink.cpp
dom/xbl/nsXBLProtoImplField.cpp
dom/xbl/nsXBLProtoImplMethod.cpp
dom/xbl/nsXBLProtoImplProperty.cpp
dom/xbl/nsXBLService.cpp
dom/xhr/XMLHttpRequestMainThread.cpp
dom/xml/ProcessingInstruction.cpp
dom/xml/nsXMLContentSink.cpp
dom/xml/nsXMLFragmentContentSink.cpp
dom/xslt/xpath/txXPathTreeWalker.h
dom/xslt/xslt/txExecutionState.cpp
dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
dom/xslt/xslt/txMozillaXMLOutput.cpp
dom/xslt/xslt/txStylesheetCompiler.cpp
dom/xul/XULDocument.cpp
dom/xul/nsXULCommandDispatcher.cpp
dom/xul/nsXULContentSink.cpp
dom/xul/nsXULContentUtils.cpp
dom/xul/nsXULControllers.cpp
dom/xul/nsXULElement.cpp
dom/xul/nsXULPrototypeDocument.cpp
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorEventListener.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/TextEditRules.cpp
editor/libeditor/TextEditor.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
gfx/thebes/gfxDWriteCommon.cpp
gfx/thebes/gfxFT2FontBase.cpp
gfx/thebes/gfxFT2Utils.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxFontEntry.h
gfx/thebes/gfxTextRun.cpp
gfx/thebes/gfxXlibSurface.cpp
image/ImageURL.h
image/decoders/icon/nsIconURI.cpp
image/imgLoader.h
image/imgRequest.cpp
image/imgRequestProxy.cpp
intl/lwbrk/WordBreaker.cpp
intl/uconv/nsConverterOutputStream.cpp
ipc/glue/MessageChannel.cpp
ipc/glue/MessageLink.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCMaps.h
js/xpconnect/src/XPCWrappedJS.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/nsXPConnect.cpp
layout/base/PresShell.cpp
layout/base/RestyleManager.cpp
layout/base/nsBidiPresUtils.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsDocumentViewer.cpp
layout/base/nsFrameManager.cpp
layout/base/nsLayoutDebugger.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsPresContext.cpp
layout/base/nsRefreshDriver.cpp
layout/base/nsStyleSheetService.cpp
layout/build/nsContentDLF.cpp
layout/build/nsLayoutModule.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFieldSetFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/forms/nsTextControlFrame.cpp
layout/generic/BlockReflowInput.cpp
layout/generic/ReflowInput.cpp
layout/generic/TextOverflow.cpp
layout/generic/nsAbsoluteContainingBlock.cpp
layout/generic/nsBlockFrame.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsContainerFrame.cpp
layout/generic/nsContainerFrame.h
layout/generic/nsFirstLetterFrame.cpp
layout/generic/nsFloatManager.cpp
layout/generic/nsFrame.cpp
layout/generic/nsFrameList.cpp
layout/generic/nsFrameList.h
layout/generic/nsFrameSelection.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsHTMLCanvasFrame.cpp
layout/generic/nsIFrame.h
layout/generic/nsImageFrame.cpp
layout/generic/nsLineBox.cpp
layout/generic/nsLineLayout.cpp
layout/generic/nsPageFrame.cpp
layout/generic/nsPlaceholderFrame.cpp
layout/generic/nsPlaceholderFrame.h
layout/generic/nsPluginFrame.cpp
layout/generic/nsSimplePageSequenceFrame.cpp
layout/generic/nsSubDocumentFrame.cpp
layout/generic/nsTextFrame.cpp
layout/generic/nsVideoFrame.cpp
layout/mathml/nsMathMLContainerFrame.cpp
layout/painting/nsCSSRendering.cpp
layout/painting/nsDisplayList.cpp
layout/printing/nsPrintJob.cpp
layout/style/Loader.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsROCSSPrimitiveValue.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleTransformMatrix.cpp
layout/style/nsStyleUtil.cpp
layout/svg/SVGTextFrame.cpp
layout/svg/nsSVGOuterSVGFrame.cpp
layout/tables/nsCellMap.cpp
layout/tables/nsCellMap.h
layout/tables/nsTableFrame.cpp
layout/tables/nsTableRowGroupFrame.cpp
layout/tables/nsTableWrapperFrame.cpp
layout/xul/nsBoxFrame.cpp
layout/xul/nsListBoxBodyFrame.cpp
layout/xul/nsPopupSetFrame.cpp
layout/xul/nsRepeatService.cpp
layout/xul/nsSprocketLayout.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
modules/libjar/nsJAR.cpp
modules/libjar/nsJARChannel.cpp
netwerk/base/nsBaseChannel.h
netwerk/base/nsDirectoryIndexStream.cpp
netwerk/base/nsNetUtil.cpp
netwerk/base/nsNetUtil.h
netwerk/base/nsProtocolProxyService.cpp
netwerk/base/nsRequestObserverProxy.cpp
netwerk/base/nsSimpleStreamListener.cpp
netwerk/base/nsSimpleURI.cpp
netwerk/base/nsStandardURL.cpp
netwerk/base/nsURLParsers.cpp
netwerk/cache/nsCacheEntryDescriptor.cpp
netwerk/cache2/CacheFileChunk.cpp
netwerk/cache2/CacheFileIOManager.cpp
netwerk/cache2/CacheFileInputStream.cpp
netwerk/cache2/CacheFileOutputStream.cpp
netwerk/protocol/about/nsAboutProtocolUtils.h
netwerk/protocol/http/AltDataOutputStreamChild.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpChunkedDecoder.cpp
netwerk/protocol/http/nsHttpTransaction.cpp
netwerk/protocol/websocket/WebSocketChannelChild.cpp
netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
netwerk/streamconv/converters/nsFTPDirListingConv.cpp
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
netwerk/streamconv/converters/nsMultiMixedConv.cpp
netwerk/streamconv/nsStreamConverterService.cpp
parser/html/nsHtml5Highlighter.cpp
parser/html/nsHtml5OwningUTF16Buffer.cpp
parser/html/nsHtml5Parser.cpp
parser/html/nsHtml5Portability.cpp
parser/html/nsHtml5SpeculativeLoad.h
parser/html/nsHtml5StreamParser.cpp
parser/html/nsHtml5StreamParser.h
parser/html/nsHtml5StreamParserPtr.h
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/html/nsHtml5TreeOpExecutor.cpp
parser/html/nsHtml5TreeOperation.cpp
parser/html/nsHtml5TreeOperation.h
parser/htmlparser/nsExpatDriver.cpp
parser/htmlparser/nsParser.cpp
parser/xml/nsSAXXMLReader.cpp
rdf/base/nsCompositeDataSource.cpp
rdf/base/nsContainerEnumerator.cpp
rdf/base/nsDefaultResourceFactory.cpp
rdf/base/nsInMemoryDataSource.cpp
rdf/base/nsRDFContainer.cpp
rdf/base/nsRDFContainerUtils.cpp
rdf/base/nsRDFContentSink.cpp
rdf/base/nsRDFResource.cpp
rdf/base/nsRDFService.cpp
rdf/base/nsRDFXMLDataSource.cpp
rdf/datasource/nsLocalStore.cpp
storage/StorageBaseStatementInternal.cpp
storage/mozStorageConnection.cpp
storage/mozStorageStatementData.h
toolkit/components/browser/nsWebBrowserContentPolicy.cpp
toolkit/components/places/History.cpp
toolkit/components/places/PlaceInfo.cpp
toolkit/components/places/SQLFunctions.cpp
toolkit/components/places/nsNavHistoryResult.cpp
uriloader/base/nsURILoader.cpp
uriloader/exthandler/nsExternalHelperAppService.cpp
uriloader/exthandler/unix/nsOSHelperAppService.cpp
view/nsView.cpp
view/nsViewManager.cpp
widget/cocoa/TextInputHandler.h
widget/cocoa/nsChildView.mm
widget/cocoa/nsMenuUtilsX.mm
widget/cocoa/nsPrintDialogX.mm
widget/gtk/IMContextWrapper.cpp
widget/gtk/nsPrintDialogGTK.cpp
widget/gtk/nsWindow.cpp
widget/nsBaseFilePicker.cpp
widget/nsNativeTheme.cpp
widget/windows/IMMHandler.cpp
widget/windows/WinUtils.cpp
widget/windows/nsColorPicker.cpp
widget/windows/nsWindow.cpp
xpcom/base/nsAutoPtr.h
xpcom/base/nsCycleCollectionParticipant.h
xpcom/base/nsIInterfaceRequestorUtils.h
xpcom/base/nsISupportsImpl.h
xpcom/base/nsISupportsUtils.h
xpcom/base/nsIWeakReferenceUtils.h
xpcom/components/nsComponentManagerUtils.h
xpcom/components/nsServiceManagerUtils.h
xpcom/ds/nsArrayEnumerator.cpp
xpcom/ds/nsEnumeratorUtils.cpp
xpcom/ds/nsTObserverArray.cpp
xpcom/io/nsBinaryStream.cpp
xpcom/io/nsStringStream.cpp
xpfe/components/directory/nsDirectoryViewer.cpp
--- a/accessible/base/FocusManager.cpp
+++ b/accessible/base/FocusManager.cpp
@@ -234,17 +234,17 @@ FocusManager::ForceFocusEvent()
     }
   }
 }
 
 void
 FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
                                  Accessible* aTarget)
 {
-  NS_PRECONDITION(aDocument, "No document for focused accessible!");
+  MOZ_ASSERT(aDocument, "No document for focused accessible!");
   if (aDocument) {
     RefPtr<AccEvent> event =
       new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget,
                    eAutoDetect, AccEvent::eCoalesceOfSameType);
     aDocument->FireDelayedEvent(event);
 
 #ifdef A11Y_LOG
     if (logging::IsEnabled(logging::eFocus))
@@ -287,17 +287,17 @@ FocusManager::ProcessDOMFocus(nsINode* a
 
     DispatchFocusEvent(document, target);
   }
 }
 
 void
 FocusManager::ProcessFocusEvent(AccEvent* aEvent)
 {
-  NS_PRECONDITION(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
+  MOZ_ASSERT(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
                   "Focus event is expected!");
 
   // Emit focus event if event target is the active item. Otherwise then check
   // if it's still focused and then update active item and emit focus event.
   Accessible* target = aEvent->GetAccessible();
   if (target != mActiveItem) {
 
     // Check if still focused. Otherwise we can end up with storing the active
--- a/accessible/base/TextAttrs.cpp
+++ b/accessible/base/TextAttrs.cpp
@@ -32,17 +32,17 @@ TextAttrsMgr::GetAttributes(nsIPersisten
                             uint32_t* aEndOffset)
 {
   // 1. Hyper text accessible must be specified always.
   // 2. Offset accessible and result hyper text offsets must be specified in
   // the case of text attributes.
   // 3. Offset accessible and result hyper text offsets must not be specified
   // but include default text attributes flag and attributes list must be
   // specified in the case of default text attributes.
-  NS_PRECONDITION(mHyperTextAcc &&
+  MOZ_ASSERT(mHyperTextAcc &&
                   ((mOffsetAcc && mOffsetAccIdx != -1 &&
                     aStartOffset && aEndOffset) ||
                   (!mOffsetAcc && mOffsetAccIdx == -1 &&
                     !aStartOffset && !aEndOffset &&
                    mIncludeDefAttrs && aAttributes)),
                   "Wrong usage of TextAttrsMgr!");
 
   // Embedded objects are combined into own range with empty attributes set.
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -2351,49 +2351,49 @@ Accessible::IsLink()
   // Every embedded accessible within hypertext accessible implements
   // hyperlink interface.
   return mParent && mParent->IsHyperText() && !IsText();
 }
 
 uint32_t
 Accessible::StartOffset()
 {
-  NS_PRECONDITION(IsLink(), "StartOffset is called not on hyper link!");
+  MOZ_ASSERT(IsLink(), "StartOffset is called not on hyper link!");
 
   HyperTextAccessible* hyperText = mParent ? mParent->AsHyperText() : nullptr;
   return hyperText ? hyperText->GetChildOffset(this) : 0;
 }
 
 uint32_t
 Accessible::EndOffset()
 {
-  NS_PRECONDITION(IsLink(), "EndOffset is called on not hyper link!");
+  MOZ_ASSERT(IsLink(), "EndOffset is called on not hyper link!");
 
   HyperTextAccessible* hyperText = mParent ? mParent->AsHyperText() : nullptr;
   return hyperText ? (hyperText->GetChildOffset(this) + 1) : 0;
 }
 
 uint32_t
 Accessible::AnchorCount()
 {
-  NS_PRECONDITION(IsLink(), "AnchorCount is called on not hyper link!");
+  MOZ_ASSERT(IsLink(), "AnchorCount is called on not hyper link!");
   return 1;
 }
 
 Accessible*
 Accessible::AnchorAt(uint32_t aAnchorIndex)
 {
-  NS_PRECONDITION(IsLink(), "GetAnchor is called on not hyper link!");
+  MOZ_ASSERT(IsLink(), "GetAnchor is called on not hyper link!");
   return aAnchorIndex == 0 ? this : nullptr;
 }
 
 already_AddRefed<nsIURI>
 Accessible::AnchorURIAt(uint32_t aAnchorIndex)
 {
-  NS_PRECONDITION(IsLink(), "AnchorURIAt is called on not hyper link!");
+  MOZ_ASSERT(IsLink(), "AnchorURIAt is called on not hyper link!");
   return nullptr;
 }
 
 void
 Accessible::ToTextPoint(HyperTextAccessible** aContainer, int32_t* aOffset,
                         bool aIsBefore) const
 {
   if (IsHyperText()) {
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -738,17 +738,17 @@ public:
    */
   virtual uint32_t EndOffset();
 
   /**
    * Return true if the link is valid (e. g. points to a valid URL).
    */
   inline bool IsLinkValid()
   {
-    NS_PRECONDITION(IsLink(), "IsLinkValid is called on not hyper link!");
+    MOZ_ASSERT(IsLink(), "IsLinkValid is called on not hyper link!");
 
     // XXX In order to implement this we would need to follow every link
     // Perhaps we can get information about invalid links from the cache
     // In the mean time authors can use role="link" aria-invalid="true"
     // to force it for links they internally know to be invalid
     return (0 == (State() & mozilla::a11y::states::INVALID));
   }
 
--- a/accessible/mac/mozTextAccessible.mm
+++ b/accessible/mac/mozTextAccessible.mm
@@ -12,17 +12,17 @@
 
 #import "mozTextAccessible.h"
 
 using namespace mozilla::a11y;
 
 inline bool
 ToNSRange(id aValue, NSRange* aRange)
 {
-  NS_PRECONDITION(aRange, "aRange is nil");
+  MOZ_ASSERT(aRange, "aRange is nil");
 
   if ([aValue isKindOfClass:[NSValue class]] &&
       strcmp([(NSValue*)aValue objCType], @encode(NSRange)) == 0) {
     *aRange = [aValue rangeValue];
     return true;
   }
 
   return false;
@@ -542,17 +542,17 @@ ToNSString(id aValue)
 - (void)selectedTextDidChange
 {
   NSAccessibilityPostNotification(GetObjectOrRepresentedView(self),
                                   NSAccessibilitySelectedTextChangedNotification);
 }
 
 - (NSString*)stringFromRange:(NSRange*)range
 {
-  NS_PRECONDITION(range, "no range");
+  MOZ_ASSERT(range, "no range");
 
   AccessibleWrap* accWrap = [self getGeckoAccessible];
   ProxyAccessible* proxy = [self getProxyAccessible];
   HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
   if (!textAcc && !proxy)
     return nil;
 
   nsAutoString text;
--- a/accessible/xpcom/xpcAccessibleSelectable.cpp
+++ b/accessible/xpcom/xpcAccessibleSelectable.cpp
@@ -14,17 +14,17 @@ using namespace mozilla::a11y;
 NS_IMETHODIMP
 xpcAccessibleSelectable::GetSelectedItems(nsIArray** aSelectedItems)
 {
   NS_ENSURE_ARG_POINTER(aSelectedItems);
   *aSelectedItems = nullptr;
 
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   AutoTArray<Accessible*, 10> items;
   Intl()->SelectedItems(&items);
 
   uint32_t itemCount = items.Length();
   if (itemCount == 0)
     return NS_OK;
 
@@ -43,32 +43,32 @@ xpcAccessibleSelectable::GetSelectedItem
 NS_IMETHODIMP
 xpcAccessibleSelectable::GetSelectedItemCount(uint32_t* aSelectionCount)
 {
   NS_ENSURE_ARG_POINTER(aSelectionCount);
   *aSelectionCount = 0;
 
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   *aSelectionCount = Intl()->SelectedItemCount();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleSelectable::GetSelectedItemAt(uint32_t aIndex,
                                            nsIAccessible** aSelected)
 {
   NS_ENSURE_ARG_POINTER(aSelected);
   *aSelected = nullptr;
 
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   *aSelected = ToXPC(Intl()->GetSelectedItem(aIndex));
   if (*aSelected) {
     NS_ADDREF(*aSelected);
     return NS_OK;
   }
 
   return NS_ERROR_INVALID_ARG;
@@ -77,58 +77,58 @@ xpcAccessibleSelectable::GetSelectedItem
 NS_IMETHODIMP
 xpcAccessibleSelectable::IsItemSelected(uint32_t aIndex, bool* aIsSelected)
 {
   NS_ENSURE_ARG_POINTER(aIsSelected);
   *aIsSelected = false;
 
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   *aIsSelected = Intl()->IsItemSelected(aIndex);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleSelectable::AddItemToSelection(uint32_t aIndex)
 {
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   return Intl()->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
 }
 
 NS_IMETHODIMP
 xpcAccessibleSelectable::RemoveItemFromSelection(uint32_t aIndex)
 {
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   return Intl()->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
 }
 
 NS_IMETHODIMP
 xpcAccessibleSelectable::SelectAll(bool* aIsMultiSelect)
 {
   NS_ENSURE_ARG_POINTER(aIsMultiSelect);
   *aIsMultiSelect = false;
 
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   *aIsMultiSelect = Intl()->SelectAll();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleSelectable::UnselectAll()
 {
   if (!Intl())
     return NS_ERROR_FAILURE;
-  NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
+  MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
 
   Intl()->UnselectAll();
   return NS_OK;
 }
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -366,17 +366,17 @@ XULTreeGridRowAccessible::ChildCount() c
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridRowAccessible: XULTreeItemAccessibleBase implementation
 
 XULTreeGridCellAccessible*
 XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const
 {
-  NS_PRECONDITION(aColumn, "No tree column!");
+  MOZ_ASSERT(aColumn, "No tree column!");
 
   void* key = static_cast<void*>(aColumn);
   XULTreeGridCellAccessible* cachedCell = mAccessibleCache.GetWeak(key);
   if (cachedCell)
     return cachedCell;
 
   RefPtr<XULTreeGridCellAccessible> cell =
     new XULTreeGridCellAccessibleWrap(mContent, mDoc,
--- a/caps/ContentPrincipal.cpp
+++ b/caps/ContentPrincipal.cpp
@@ -325,17 +325,17 @@ ContentPrincipal::MayLoadInternal(nsIURI
   }
 
   return false;
 }
 
 NS_IMETHODIMP
 ContentPrincipal::GetHashValue(uint32_t* aValue)
 {
-  NS_PRECONDITION(mCodebase, "Need a codebase");
+  MOZ_ASSERT(mCodebase, "Need a codebase");
 
   *aValue = nsScriptSecurityManager::HashPrincipalByOrigin(this);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ContentPrincipal::GetDomain(nsIURI** aDomain)
 {
--- a/caps/nsJSPrincipals.cpp
+++ b/caps/nsJSPrincipals.cpp
@@ -23,27 +23,27 @@
 
 using namespace mozilla;
 using namespace mozilla::ipc;
 
 NS_IMETHODIMP_(MozExternalRefCountType)
 nsJSPrincipals::AddRef()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
+  MOZ_ASSERT(int32_t(refcount) >= 0, "illegal refcnt");
   nsrefcnt count = ++refcount;
   NS_LOG_ADDREF(this, count, "nsJSPrincipals", sizeof(*this));
   return count;
 }
 
 NS_IMETHODIMP_(MozExternalRefCountType)
 nsJSPrincipals::Release()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  NS_PRECONDITION(0 != refcount, "dup release");
+  MOZ_ASSERT(0 != refcount, "dup release");
   nsrefcnt count = --refcount;
   NS_LOG_RELEASE(this, count, "nsJSPrincipals");
   if (count == 0) {
     delete this;
   }
 
   return count;
 }
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -255,17 +255,18 @@ InheritAndSetCSPOnPrincipalIfNeeded(nsIC
   aPrincipal->SetCsp(originalCSP);
 }
 
 nsresult
 nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
                                                    nsIPrincipal** aPrincipal,
                                                    bool aIgnoreSandboxing)
 {
-  NS_PRECONDITION(aChannel, "Must have channel!");
+  MOZ_ASSERT(aChannel, "Must have channel!");
+
   // Check whether we have an nsILoadInfo that says what we should do.
   nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
   if (loadInfo && loadInfo->GetForceInheritPrincipalOverruleOwner()) {
     nsCOMPtr<nsIPrincipal> principalToInherit =
       loadInfo->FindPrincipalToInherit(aChannel);
     principalToInherit.forget(aPrincipal);
     return NS_OK;
   }
@@ -344,17 +345,17 @@ nsScriptSecurityManager::GetChannelResul
  * sandboxed or when the load could be a blob or data uri (i.e even when
  * you encounter loads that may or may not be sandboxed and loads
  * that may or may not inherit)."
  */
 NS_IMETHODIMP
 nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
                                                 nsIPrincipal** aPrincipal)
 {
-    NS_PRECONDITION(aChannel, "Must have channel!");
+    MOZ_ASSERT(aChannel, "Must have channel!");
 
     // Get the principal from the URI.  Make sure this does the same thing
     // as nsDocument::Reset and XULDocument::StartDocumentLoad.
     nsCOMPtr<nsIURI> uri;
     nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsILoadInfo> loadInfo;
@@ -512,17 +513,17 @@ nsScriptSecurityManager::CheckLoadURIFro
  * Helper method to handle cases where a flag passed to
  * CheckLoadURIWithPrincipal means denying loading if the given URI has certain
  * nsIProtocolHandler flags set.
  * @return if success, access is allowed. Otherwise, deny access
  */
 static nsresult
 DenyAccessIfURIHasFlags(nsIURI* aURI, uint32_t aURIFlags)
 {
-    NS_PRECONDITION(aURI, "Must have URI!");
+    MOZ_ASSERT(aURI, "Must have URI!");
 
     bool uriHasFlags;
     nsresult rv =
         NS_URIChainHasFlags(aURI, aURIFlags, &uriHasFlags);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (uriHasFlags) {
         return NS_ERROR_DOM_BAD_URI;
@@ -560,17 +561,18 @@ EqualOrSubdomain(nsIURI* aProbeArg, nsIU
     }
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
                                                    nsIURI *aTargetURI,
                                                    uint32_t aFlags)
 {
-    NS_PRECONDITION(aPrincipal, "CheckLoadURIWithPrincipal must have a principal");
+    MOZ_ASSERT(aPrincipal, "CheckLoadURIWithPrincipal must have a principal");
+
     // If someone passes a flag that we don't understand, we should
     // fail, because they may need a security check that we don't
     // provide.
     NS_ENSURE_FALSE(aFlags & ~(nsIScriptSecurityManager::LOAD_IS_AUTOMATIC_DOCUMENT_REPLACEMENT |
                                nsIScriptSecurityManager::ALLOW_CHROME |
                                nsIScriptSecurityManager::DISALLOW_SCRIPT |
                                nsIScriptSecurityManager::DISALLOW_INHERIT_PRINCIPAL |
                                nsIScriptSecurityManager::DONT_REPORT_ERRORS),
--- a/chrome/nsChromeProtocolHandler.cpp
+++ b/chrome/nsChromeProtocolHandler.cpp
@@ -108,17 +108,17 @@ nsChromeProtocolHandler::NewChannel2(nsI
                                      nsILoadInfo* aLoadInfo,
                                      nsIChannel** aResult)
 {
     nsresult rv;
 
     NS_ENSURE_ARG_POINTER(aURI);
     NS_ENSURE_ARG_POINTER(aLoadInfo);
 
-    NS_PRECONDITION(aResult, "Null out param");
+    MOZ_ASSERT(aResult, "Null out param");
 
 #ifdef DEBUG
     // Check that the uri we got is already canonified
     nsresult debug_rv;
     nsCOMPtr<nsIURI> debugURL = aURI;
     debug_rv = nsChromeRegistry::Canonify(debugURL);
     if (NS_SUCCEEDED(debug_rv)) {
         bool same;
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -256,17 +256,17 @@ nsDSURIContentListener::IsPreferred(cons
 }
 
 NS_IMETHODIMP
 nsDSURIContentListener::CanHandleContent(const char* aContentType,
                                          bool aIsContentPreferred,
                                          char** aDesiredContentType,
                                          bool* aCanHandleContent)
 {
-  NS_PRECONDITION(aCanHandleContent, "Null out param?");
+  MOZ_ASSERT(aCanHandleContent, "Null out param?");
   NS_ENSURE_ARG_POINTER(aDesiredContentType);
 
   *aCanHandleContent = false;
   *aDesiredContentType = nullptr;
 
   nsresult rv = NS_OK;
   if (aContentType) {
     uint32_t canHandle = nsIWebNavigationInfo::UNSUPPORTED;
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -532,17 +532,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsINetworkInterceptController,
                                      mInterceptController)
   NS_INTERFACE_MAP_ENTRY(nsIDeprecationWarner)
 NS_INTERFACE_MAP_END_INHERITING(nsDocLoader)
 
 NS_IMETHODIMP
 nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
 {
-  NS_PRECONDITION(aSink, "null out param");
+  MOZ_ASSERT(aSink, "null out param");
 
   *aSink = nullptr;
 
   if (aIID.Equals(NS_GET_IID(nsICommandManager))) {
     NS_ENSURE_SUCCESS(EnsureCommandHandler(), NS_ERROR_FAILURE);
     *aSink = mCommandManager;
   } else if (aIID.Equals(NS_GET_IID(nsIURIContentListener))) {
     *aSink = mContentListener;
@@ -663,19 +663,19 @@ nsDocShell::GetInterface(const nsIID& aI
 }
 
 NS_IMETHODIMP
 nsDocShell::LoadURI(nsIURI* aURI,
                     nsIDocShellLoadInfo* aLoadInfo,
                     uint32_t aLoadFlags,
                     bool aFirstParty)
 {
-  NS_PRECONDITION(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0,
+  MOZ_ASSERT(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0,
                   "Unexpected flags");
-  NS_PRECONDITION((aLoadFlags & 0xf) == 0, "Should not have these flags set");
+  MOZ_ASSERT((aLoadFlags & 0xf) == 0, "Should not have these flags set");
 
   // Note: we allow loads to get through here even if mFiredUnloadEvent is
   // true; that case will get handled in LoadInternal or LoadHistoryEntry,
   // so we pass false as the second parameter to IsNavigationAllowed.
   // However, we don't allow the page to change location *in the middle of*
   // firing beforeunload, so we do need to check if *beforeunload* is currently
   // firing, so we call IsNavigationAllowed rather than just IsPrintingOrPP.
   if (!IsNavigationAllowed(true, false)) {
@@ -3122,17 +3122,17 @@ nsDocShell::GetSameTypeRootTreeItemIgnor
 }
 
 /* static */
 bool
 nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
                           nsIDocShellTreeItem* aAccessingItem,
                           bool aConsiderOpener)
 {
-  NS_PRECONDITION(aTargetItem, "Must have target item!");
+  MOZ_ASSERT(aTargetItem, "Must have target item!");
 
   if (!gValidateOrigin || !aAccessingItem) {
     // Good to go
     return true;
   }
 
   // XXXbz should we care if aAccessingItem or the document therein is
   // chrome?  Should those get extra privileges?
@@ -5286,17 +5286,17 @@ nsDocShell::LoadPage(nsISupports* aPageD
 
   rv = LoadHistoryEntry(shEntry, LOAD_HISTORY);
   return rv;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetCurrentDescriptor(nsISupports** aPageDescriptor)
 {
-  NS_PRECONDITION(aPageDescriptor, "Null out param?");
+  MOZ_ASSERT(aPageDescriptor, "Null out param?");
 
   *aPageDescriptor = nullptr;
 
   nsISHEntry* src = mOSHE ? mOSHE : mLSHE;
   if (src) {
     nsCOMPtr<nsISHEntry> dest;
 
     nsresult rv = src->Clone(getter_AddRefs(dest));
@@ -6340,17 +6340,17 @@ nsDocShell::RefreshURI(nsIURI* aURI, nsI
 
 nsresult
 nsDocShell::ForceRefreshURIFromTimer(nsIURI* aURI,
                                      nsIPrincipal* aPrincipal,
                                      int32_t aDelay,
                                      bool aMetaRefresh,
                                      nsITimer* aTimer)
 {
-  NS_PRECONDITION(aTimer, "Must have a timer here");
+  MOZ_ASSERT(aTimer, "Must have a timer here");
 
   // Remove aTimer from mRefreshURIList if needed
   if (mRefreshURIList) {
     uint32_t n = 0;
     mRefreshURIList->GetLength(&n);
 
     for (uint32_t i = 0; i < n; ++i) {
       nsCOMPtr<nsITimer> timer = do_QueryElementAt(mRefreshURIList, i);
@@ -9753,17 +9753,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
 
   rv = CheckLoadingPermissions();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   if (mFiredUnloadEvent) {
     if (IsOKToLoadURI(aURI)) {
-      NS_PRECONDITION(aWindowTarget.IsEmpty(),
+      MOZ_ASSERT(aWindowTarget.IsEmpty(),
                       "Shouldn't have a window target here!");
 
       // If this is a replace load, make whatever load triggered
       // the unload event also a replace load, so we don't
       // create extra history entries.
       if (LOAD_TYPE_HAS_FLAGS(aLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {
         mLoadType = LOAD_NORMAL_REPLACE;
       }
@@ -11335,18 +11335,18 @@ nsDocShell::SetupReferrerFromChannel(nsI
 
 bool
 nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
                      nsIPrincipal* aTriggeringPrincipal,
                      nsIPrincipal* aPrincipalToInherit,
                      uint32_t aLoadType, bool aFireOnLocationChange,
                      bool aAddToGlobalHistory, bool aCloneSHChildren)
 {
-  NS_PRECONDITION(aURI, "uri is null");
-  NS_PRECONDITION(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set");
+  MOZ_ASSERT(aURI, "uri is null");
+  MOZ_ASSERT(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set");
 
   MOZ_ASSERT(!aPrincipalToInherit || (aPrincipalToInherit && aTriggeringPrincipal));
 
 #if defined(DEBUG)
   if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
     nsAutoCString chanName;
     if (aChannel) {
       aChannel->GetName(chanName);
@@ -11987,18 +11987,18 @@ nsDocShell::ShouldAddToSessionHistory(ns
 
 nsresult
 nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
                                 nsIPrincipal* aTriggeringPrincipal,
                                 nsIPrincipal* aPrincipalToInherit,
                                 bool aCloneChildren,
                                 nsISHEntry** aNewEntry)
 {
-  NS_PRECONDITION(aURI, "uri is null");
-  NS_PRECONDITION(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set");
+  MOZ_ASSERT(aURI, "uri is null");
+  MOZ_ASSERT(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set");
 
 #if defined(DEBUG)
   if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
     nsAutoCString chanName;
     if (aChannel) {
       aChannel->GetName(chanName);
     } else {
       chanName.AssignLiteral("<no channel>");
@@ -13148,17 +13148,17 @@ nsDocShell::GetIsContent(bool* aIsConten
 {
   *aIsContent = (mItemType == typeContent);
   return NS_OK;
 }
 
 bool
 nsDocShell::IsOKToLoadURI(nsIURI* aURI)
 {
-  NS_PRECONDITION(aURI, "Must have a URI!");
+  MOZ_ASSERT(aURI, "Must have a URI!");
 
   if (!mFiredUnloadEvent) {
     return true;
   }
 
   if (!mLoadingURI) {
     return false;
   }
--- a/docshell/base/nsWebNavigationInfo.cpp
+++ b/docshell/base/nsWebNavigationInfo.cpp
@@ -26,17 +26,17 @@ nsWebNavigationInfo::Init()
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
                                      nsIWebNavigation* aWebNav,
                                      uint32_t* aIsTypeSupported)
 {
-  NS_PRECONDITION(aIsTypeSupported, "null out param?");
+  MOZ_ASSERT(aIsTypeSupported, "null out param?");
 
   // Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or
   // an nsSHistory, but not much we can do with that).  So if we start using
   // it here, we need to be careful to get to the docshell correctly.
 
   // For now just report what the Gecko-Content-Viewers category has
   // to say for itself.
   *aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED;
@@ -89,17 +89,17 @@ nsWebNavigationInfo::IsTypeSupported(con
 
   return NS_OK;
 }
 
 nsresult
 nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
                                              uint32_t* aIsSupported)
 {
-  NS_PRECONDITION(aIsSupported, "Null out param?");
+  MOZ_ASSERT(aIsSupported, "Null out param?");
 
   nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
 
   nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
     nsContentUtils::FindInternalContentViewer(aType, &vtype);
 
   switch (vtype) {
     case nsContentUtils::TYPE_UNSUPPORTED:
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -48,17 +48,17 @@
 using mozilla::dom::ContentHandlerService;
 
 static bool gInitialized = false;
 
 // The one time initialization for this module
 static nsresult
 Initialize()
 {
-  NS_PRECONDITION(!gInitialized, "docshell module already initialized");
+  MOZ_ASSERT(!gInitialized, "docshell module already initialized");
   if (gInitialized) {
     return NS_OK;
   }
   gInitialized = true;
 
   nsresult rv = nsSHistory::Startup();
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/docshell/shistory/nsSHEntryShared.cpp
+++ b/docshell/shistory/nsSHEntryShared.cpp
@@ -134,17 +134,17 @@ nsSHEntryShared::DropPresentationState()
   mChildShells.Clear();
   mRefreshURIList = nullptr;
   mEditorData = nullptr;
 }
 
 nsresult
 nsSHEntryShared::SetContentViewer(nsIContentViewer* aViewer)
 {
-  NS_PRECONDITION(!aViewer || !mContentViewer,
+  MOZ_ASSERT(!aViewer || !mContentViewer,
                   "SHEntryShared already contains viewer");
 
   if (mContentViewer || !aViewer) {
     DropPresentationState();
   }
 
   // If we're setting mContentViewer to null, state should already be cleared
   // in the DropPresentationState() call above; If we're setting it to a
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -684,26 +684,26 @@ nsSHistory::GetCount(int32_t* aResult)
   *aResult = mLength;
   return NS_OK;
 }
 
 /* Get index of the history list */
 NS_IMETHODIMP
 nsSHistory::GetIndex(int32_t* aResult)
 {
-  NS_PRECONDITION(aResult, "null out param?");
+  MOZ_ASSERT(aResult, "null out param?");
   *aResult = mIndex;
   return NS_OK;
 }
 
 /* Get the requestedIndex */
 NS_IMETHODIMP
 nsSHistory::GetRequestedIndex(int32_t* aResult)
 {
-  NS_PRECONDITION(aResult, "null out param?");
+  MOZ_ASSERT(aResult, "null out param?");
   *aResult = mRequestedIndex;
   return NS_OK;
 }
 
 /* Get the entry at a given index */
 NS_IMETHODIMP
 nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex,
                             nsISHEntry** aResult)
--- a/dom/base/CharacterData.cpp
+++ b/dom/base/CharacterData.cpp
@@ -61,17 +61,17 @@ CharacterData::CharacterData(already_Add
              mNodeInfo->NodeType() == COMMENT_NODE ||
              mNodeInfo->NodeType() == PROCESSING_INSTRUCTION_NODE ||
              mNodeInfo->NodeType() == DOCUMENT_TYPE_NODE,
              "Bad NodeType in aNodeInfo");
 }
 
 CharacterData::~CharacterData()
 {
-  NS_PRECONDITION(!IsInUncomposedDoc(),
+  MOZ_ASSERT(!IsInUncomposedDoc(),
                   "Please remove this from the document properly");
   if (GetParent()) {
     NS_RELEASE(mParent);
   }
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(CharacterData)
 
@@ -241,17 +241,17 @@ CharacterData::ReplaceData(uint32_t aOff
 }
 
 nsresult
 CharacterData::SetTextInternal(uint32_t aOffset, uint32_t aCount,
                                const char16_t* aBuffer,
                                uint32_t aLength, bool aNotify,
                                CharacterDataChangeInfo::Details* aDetails)
 {
-  NS_PRECONDITION(aBuffer || !aLength,
+  MOZ_ASSERT(aBuffer || !aLength,
                   "Null buffer passed to SetTextInternal!");
 
   // sanitize arguments
   uint32_t textLength = mText.GetLength();
   if (aOffset > textLength) {
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   }
 
@@ -441,35 +441,35 @@ CharacterData::ToCString(nsAString& aBuf
 #endif
 
 
 nsresult
 CharacterData::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                           nsIContent* aBindingParent,
                           bool aCompileEventHandlers)
 {
-  NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
-  NS_PRECONDITION(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
+  MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!");
+  MOZ_ASSERT(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
                   "Must have the same owner document");
-  NS_PRECONDITION(!aParent || aDocument == aParent->GetUncomposedDoc(),
+  MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(),
                   "aDocument must be current doc of aParent");
-  NS_PRECONDITION(!GetUncomposedDoc() && !IsInUncomposedDoc(),
+  MOZ_ASSERT(!GetUncomposedDoc() && !IsInUncomposedDoc(),
                   "Already have a document.  Unbind first!");
   // Note that as we recurse into the kids, they'll have a non-null parent.  So
   // only assert if our parent is _changing_ while we have a parent.
-  NS_PRECONDITION(!GetParent() || aParent == GetParent(),
+  MOZ_ASSERT(!GetParent() || aParent == GetParent(),
                   "Already have a parent.  Unbind first!");
-  NS_PRECONDITION(!GetBindingParent() ||
+  MOZ_ASSERT(!GetBindingParent() ||
                   aBindingParent == GetBindingParent() ||
                   (!aBindingParent && aParent &&
                    aParent->GetBindingParent() == GetBindingParent()),
                   "Already have a binding parent.  Unbind first!");
-  NS_PRECONDITION(aBindingParent != this,
+  MOZ_ASSERT(aBindingParent != this,
                   "Content must not be its own binding parent");
-  NS_PRECONDITION(!IsRootOfNativeAnonymousSubtree() ||
+  MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() ||
                   aBindingParent == aParent,
                   "Native anonymous content must have its parent as its "
                   "own binding parent");
 
   if (!aBindingParent && aParent) {
     aBindingParent = aParent->GetBindingParent();
   }
 
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1529,38 +1529,38 @@ EditableInclusiveDescendantCount(nsICont
   return aContent->EditableDescendantCount();
 }
 
 nsresult
 Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                     nsIContent* aBindingParent,
                     bool aCompileEventHandlers)
 {
-  NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
-  NS_PRECONDITION((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()),
+  MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!");
+  MOZ_ASSERT((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()),
                   "Must have the same owner document");
-  NS_PRECONDITION(!aParent || aDocument == aParent->GetUncomposedDoc(),
+  MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(),
                   "aDocument must be current doc of aParent");
-  NS_PRECONDITION(!GetUncomposedDoc(), "Already have a document.  Unbind first!");
+  MOZ_ASSERT(!GetUncomposedDoc(), "Already have a document.  Unbind first!");
   // Note that as we recurse into the kids, they'll have a non-null parent.  So
   // only assert if our parent is _changing_ while we have a parent.
-  NS_PRECONDITION(!GetParent() || aParent == GetParent(),
+  MOZ_ASSERT(!GetParent() || aParent == GetParent(),
                   "Already have a parent.  Unbind first!");
-  NS_PRECONDITION(!GetBindingParent() ||
+  MOZ_ASSERT(!GetBindingParent() ||
                   aBindingParent == GetBindingParent() ||
                   (!aBindingParent && aParent &&
                    aParent->GetBindingParent() == GetBindingParent()),
                   "Already have a binding parent.  Unbind first!");
-  NS_PRECONDITION(aBindingParent != this,
+  MOZ_ASSERT(aBindingParent != this,
                   "Content must not be its own binding parent");
-  NS_PRECONDITION(!IsRootOfNativeAnonymousSubtree() ||
+  MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() ||
                   aBindingParent == aParent,
                   "Native anonymous content must have its parent as its "
                   "own binding parent");
-  NS_PRECONDITION(aBindingParent || !aParent ||
+  MOZ_ASSERT(aBindingParent || !aParent ||
                   aBindingParent == aParent->GetBindingParent(),
                   "We should be passed the right binding parent");
 
 #ifdef MOZ_XUL
   // First set the binding parent
   nsXULElement* xulElem = nsXULElement::FromNode(this);
   if (xulElem) {
     xulElem->SetXULBindingParent(aBindingParent);
@@ -1836,17 +1836,17 @@ RemoveFromBindingManagerRunnable::Run()
 
   return NS_OK;
 }
 
 
 void
 Element::UnbindFromTree(bool aDeep, bool aNullParent)
 {
-  NS_PRECONDITION(aDeep || (!GetUncomposedDoc() && !GetBindingParent()),
+  MOZ_ASSERT(aDeep || (!GetUncomposedDoc() && !GetBindingParent()),
                   "Shallow unbind won't clear document and binding parent on "
                   "kids!");
 
   RemoveFromIdTable();
 
   // Make sure to unbind this node before doing the kids
   nsIDocument* document = GetComposedDoc();
 
@@ -2213,19 +2213,19 @@ Element::IsNodeOfType(uint32_t aFlags) c
 /* static */
 nsresult
 Element::DispatchEvent(nsPresContext* aPresContext,
                        WidgetEvent* aEvent,
                        nsIContent* aTarget,
                        bool aFullDispatch,
                        nsEventStatus* aStatus)
 {
-  NS_PRECONDITION(aTarget, "Must have target");
-  NS_PRECONDITION(aEvent, "Must have source event");
-  NS_PRECONDITION(aStatus, "Null out param?");
+  MOZ_ASSERT(aTarget, "Must have target");
+  MOZ_ASSERT(aEvent, "Must have source event");
+  MOZ_ASSERT(aStatus, "Null out param?");
 
   if (!aPresContext) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIPresShell> shell = aPresContext->GetPresShell();
   if (!shell) {
     return NS_OK;
@@ -2242,19 +2242,19 @@ Element::DispatchEvent(nsPresContext* aP
 nsresult
 Element::DispatchClickEvent(nsPresContext* aPresContext,
                             WidgetInputEvent* aSourceEvent,
                             nsIContent* aTarget,
                             bool aFullDispatch,
                             const EventFlags* aExtraEventFlags,
                             nsEventStatus* aStatus)
 {
-  NS_PRECONDITION(aTarget, "Must have target");
-  NS_PRECONDITION(aSourceEvent, "Must have source event");
-  NS_PRECONDITION(aStatus, "Null out param?");
+  MOZ_ASSERT(aTarget, "Must have target");
+  MOZ_ASSERT(aSourceEvent, "Must have source event");
+  MOZ_ASSERT(aStatus, "Null out param?");
 
   WidgetMouseEvent event(aSourceEvent->IsTrusted(), eMouseClick,
                          aSourceEvent->mWidget, WidgetMouseEvent::eReal);
   event.mRefPoint = aSourceEvent->mRefPoint;
   uint32_t clickCount = 1;
   float pressure = 0;
   uint32_t pointerId = 0; // Use the default value here.
   uint16_t inputSource = 0;
@@ -2317,17 +2317,17 @@ Element::SetEventHandler(nsAtom* aEventN
 {
   nsIDocument *ownerDoc = OwnerDoc();
   if (ownerDoc->IsLoadedAsData()) {
     // Make this a no-op rather than throwing an error to avoid
     // the error causing problems setting the attribute.
     return NS_OK;
   }
 
-  NS_PRECONDITION(aEventName, "Must have event name!");
+  MOZ_ASSERT(aEventName, "Must have event name!");
   bool defer = true;
   EventListenerManager* manager =
     GetEventListenerManagerForAttr(aEventName, &defer);
   if (!manager) {
     return NS_OK;
   }
 
   defer = defer && aDefer; // only defer if everyone agrees...
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -598,31 +598,31 @@ private:
 
 protected:
   // Methods for the ESM, nsGlobalWindow and focus manager to manage state bits.
   // These will handle setting up script blockers when they notify, so no need
   // to do it in the callers unless desired.  States passed here must only be
   // those in EXTERNALLY_MANAGED_STATES.
   virtual void AddStates(EventStates aStates)
   {
-    NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
+    MOZ_ASSERT(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
                     "Should only be adding externally-managed states here");
     AddStatesSilently(aStates);
     NotifyStateChange(aStates);
   }
   virtual void RemoveStates(EventStates aStates)
   {
-    NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
+    MOZ_ASSERT(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
                     "Should only be removing externally-managed states here");
     RemoveStatesSilently(aStates);
     NotifyStateChange(aStates);
   }
   virtual void ToggleStates(EventStates aStates, bool aNotify)
   {
-    NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
+    MOZ_ASSERT(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
                     "Should only be removing externally-managed states here");
     mState ^= aStates;
     if (aNotify) {
       NotifyStateChange(aStates);
     }
   }
 
 public:
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -830,22 +830,22 @@ EventSourceImpl::AsyncOnChannelRedirect(
                                         uint32_t aFlags,
                                         nsIAsyncVerifyRedirectCallback* aCallback)
 {
   AssertIsOnMainThread();
   if (IsClosed()) {
     return NS_ERROR_ABORT;
   }
   nsCOMPtr<nsIRequest> aOldRequest = do_QueryInterface(aOldChannel);
-  NS_PRECONDITION(aOldRequest, "Redirect from a null request?");
+  MOZ_ASSERT(aOldRequest, "Redirect from a null request?");
 
   nsresult rv = CheckHealthOfRequestCallback(aOldRequest);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_PRECONDITION(aNewChannel, "Redirect without a channel?");
+  MOZ_ASSERT(aNewChannel, "Redirect without a channel?");
 
   nsCOMPtr<nsIURI> newURI;
   rv = NS_GetFinalChannelURI(aNewChannel, getter_AddRefs(newURI));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool isValidScheme =
     (NS_SUCCEEDED(newURI->SchemeIs("http", &isValidScheme)) && isValidScheme) ||
     (NS_SUCCEEDED(newURI->SchemeIs("https", &isValidScheme)) && isValidScheme);
@@ -1368,17 +1368,17 @@ EventSourceImpl::TimerCallback(nsITimer*
 {
   AssertIsOnMainThread();
   RefPtr<EventSourceImpl> thisObject = static_cast<EventSourceImpl*>(aClosure);
 
   if (thisObject->IsClosed()) {
     return;
   }
 
-  NS_PRECONDITION(!thisObject->mHttpChannel,
+  MOZ_ASSERT(!thisObject->mHttpChannel,
                   "the channel hasn't been cancelled!!");
 
   if (!thisObject->IsFrozen()) {
     nsresult rv = thisObject->InitChannelAndRequestEventSource();
     if (NS_FAILED(rv)) {
       NS_WARNING("thisObject->InitChannelAndRequestEventSource() failed");
       return;
     }
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -809,17 +809,17 @@ FragmentOrElement::FragmentOrElement(alr
 
 FragmentOrElement::FragmentOrElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
   : nsIContent(aNodeInfo)
 {
 }
 
 FragmentOrElement::~FragmentOrElement()
 {
-  NS_PRECONDITION(!IsInUncomposedDoc(),
+  MOZ_ASSERT(!IsInUncomposedDoc(),
                   "Please remove this from the document properly");
   if (GetParent()) {
     NS_RELEASE(mParent);
   }
 }
 
 already_AddRefed<nsINodeList>
 FragmentOrElement::GetChildren(uint32_t aFilter)
@@ -1178,30 +1178,30 @@ nsIContent::SetXBLInsertionPoint(nsICont
   }
 }
 
 nsresult
 FragmentOrElement::InsertChildBefore(nsIContent* aKid,
                                      nsIContent* aBeforeThis,
                                      bool aNotify)
 {
-  NS_PRECONDITION(aKid, "null ptr");
+  MOZ_ASSERT(aKid, "null ptr");
 
   int32_t index = aBeforeThis ? ComputeIndexOf(aBeforeThis) : GetChildCount();
   MOZ_ASSERT(index >= 0);
 
   return doInsertChildAt(aKid, index, aNotify, mAttrsAndChildren);
 }
 
 nsresult
 FragmentOrElement::InsertChildAt_Deprecated(nsIContent* aKid,
                                             uint32_t aIndex,
                                             bool aNotify)
 {
-  NS_PRECONDITION(aKid, "null ptr");
+  MOZ_ASSERT(aKid, "null ptr");
 
   return doInsertChildAt(aKid, aIndex, aNotify, mAttrsAndChildren);
 }
 
 void
 FragmentOrElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
 {
   nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
--- a/dom/base/IDTracker.h
+++ b/dom/base/IDTracker.h
@@ -117,17 +117,17 @@ private:
   public:
     virtual void SetTo(Element* aTo) = 0;
     virtual void Clear() { mTarget = nullptr; }
     virtual ~Notification() {}
   protected:
     explicit Notification(IDTracker* aTarget)
       : mTarget(aTarget)
     {
-      NS_PRECONDITION(aTarget, "Must have a target");
+      MOZ_ASSERT(aTarget, "Must have a target");
     }
     IDTracker* mTarget;
   };
 
   class ChangeNotification : public mozilla::Runnable,
                              public Notification
   {
   public:
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -2117,17 +2117,17 @@ Selection::SetTextRangeStyle(nsRange* aR
   }
   return NS_OK;
 }
 
 nsresult
 Selection::StartAutoScrollTimer(nsIFrame* aFrame, const nsPoint& aPoint,
                                 uint32_t aDelay)
 {
-  NS_PRECONDITION(aFrame, "Need a frame");
+  MOZ_ASSERT(aFrame, "Need a frame");
 
   nsresult result;
   if (!mFrameSelection) {
     return NS_OK;//nothing to do
   }
 
   if (!mAutoScrollTimer) {
     mAutoScrollTimer = new nsAutoScrollTimer();
@@ -2155,17 +2155,17 @@ Selection::StopAutoScrollTimer()
     return mAutoScrollTimer->Stop();
   }
   return NS_OK;
 }
 
 nsresult
 Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint)
 {
-  NS_PRECONDITION(aFrame, "Need a frame");
+  MOZ_ASSERT(aFrame, "Need a frame");
 
   if (mAutoScrollTimer) {
     (void)mAutoScrollTimer->Stop();
   }
 
   nsPresContext* presContext = aFrame->PresContext();
   nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
   nsRootPresContext* rootPC = presContext->GetRootPresContext();
--- a/dom/base/nsAttrAndChildArray.cpp
+++ b/dom/base/nsAttrAndChildArray.cpp
@@ -609,17 +609,17 @@ nsAttrAndChildArray::SetAndSwapMappedAtt
   mapped->SetAndSwapAttr(aLocalName, aValue, aHadValue);
 
   return MakeMappedUnique(mapped);
 }
 
 nsresult
 nsAttrAndChildArray::DoSetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet)
 {
-  NS_PRECONDITION(mImpl && mImpl->mMappedAttrs,
+  MOZ_ASSERT(mImpl && mImpl->mMappedAttrs,
                   "Should have mapped attrs here!");
   if (aSheet == mImpl->mMappedAttrs->GetStyleSheet()) {
     return NS_OK;
   }
 
   RefPtr<nsMappedAttributes> mapped =
     GetModifiableMapped(nullptr, nullptr, false);
 
@@ -795,17 +795,17 @@ const nsMappedAttributes*
 nsAttrAndChildArray::GetMapped() const
 {
   return mImpl ? mImpl->mMappedAttrs : nullptr;
 }
 
 nsresult nsAttrAndChildArray::EnsureCapacityToClone(const nsAttrAndChildArray& aOther,
                                                     bool aAllocateChildren)
 {
-  NS_PRECONDITION(!mImpl, "nsAttrAndChildArray::EnsureCapacityToClone requires the array be empty when called");
+  MOZ_ASSERT(!mImpl, "nsAttrAndChildArray::EnsureCapacityToClone requires the array be empty when called");
 
   uint32_t attrCount = aOther.NonMappedAttrCount();
   uint32_t childCount = 0;
   if (aAllocateChildren) {
     childCount = aOther.ChildCount();
   }
 
   if (attrCount == 0 && childCount == 0) {
@@ -925,18 +925,18 @@ nsAttrAndChildArray::AddAttrSlot()
 
   return true;
 }
 
 inline void
 nsAttrAndChildArray::SetChildAtPos(void** aPos, nsIContent* aChild,
                                    uint32_t aIndex, uint32_t aChildCount)
 {
-  NS_PRECONDITION(!aChild->GetNextSibling(), "aChild with next sibling?");
-  NS_PRECONDITION(!aChild->GetPreviousSibling(), "aChild with prev sibling?");
+  MOZ_ASSERT(!aChild->GetNextSibling(), "aChild with next sibling?");
+  MOZ_ASSERT(!aChild->GetPreviousSibling(), "aChild with prev sibling?");
 
   *aPos = aChild;
   NS_ADDREF(aChild);
   if (aIndex != 0) {
     nsIContent* previous = static_cast<nsIContent*>(*(aPos - 1));
     aChild->mPreviousSibling = previous;
     previous->mNextSibling = aChild;
   }
--- a/dom/base/nsAttrAndChildArray.h
+++ b/dom/base/nsAttrAndChildArray.h
@@ -179,17 +179,17 @@ private:
 
   uint32_t AttrSlotCount() const
   {
     return mImpl ? mImpl->mAttrAndChildCount & ATTRCHILD_ARRAY_ATTR_SLOTS_COUNT_MASK : 0;
   }
 
   bool AttrSlotIsTaken(uint32_t aSlot) const
   {
-    NS_PRECONDITION(aSlot < AttrSlotCount(), "out-of-bounds");
+    MOZ_ASSERT(aSlot < AttrSlotCount(), "out-of-bounds");
     return mImpl->mBuffer[aSlot * ATTRSIZE];
   }
 
   void SetChildCount(uint32_t aCount)
   {
     mImpl->mAttrAndChildCount =
         (mImpl->mAttrAndChildCount & ATTRCHILD_ARRAY_ATTR_SLOTS_COUNT_MASK) |
         (aCount << ATTRCHILD_ARRAY_ATTR_SLOTS_BITS);
--- a/dom/base/nsAttrValue.cpp
+++ b/dom/base/nsAttrValue.cpp
@@ -732,17 +732,17 @@ nsAttrValue::GetAsAtom() const
         return NS_AtomizeMainThread(val);
       }
   }
 }
 
 const nsCheapString
 nsAttrValue::GetStringValue() const
 {
-  NS_PRECONDITION(Type() == eString, "wrong type");
+  MOZ_ASSERT(Type() == eString, "wrong type");
 
   return nsCheapString(static_cast<nsStringBuffer*>(GetPtr()));
 }
 
 bool
 nsAttrValue::GetColorValue(nscolor& aColor) const
 {
   if (Type() != eColor) {
@@ -753,17 +753,17 @@ nsAttrValue::GetColorValue(nscolor& aCol
 
   aColor = GetMiscContainer()->mValue.mColor;
   return true;
 }
 
 void
 nsAttrValue::GetEnumString(nsAString& aResult, bool aRealTag) const
 {
-  NS_PRECONDITION(Type() == eEnum, "wrong type");
+  MOZ_ASSERT(Type() == eEnum, "wrong type");
 
   uint32_t allEnumBits =
     (BaseType() == eIntegerBase) ? static_cast<uint32_t>(GetIntInternal())
                                    : GetMiscContainer()->mValue.mEnumValue;
   int16_t val = allEnumBits >> NS_ATTRVALUE_ENUMTABLEINDEX_BITS;
   const EnumTable* table = sEnumTableArray->
     ElementAt(allEnumBits & NS_ATTRVALUE_ENUMTABLEINDEX_MASK);
 
@@ -795,18 +795,18 @@ nsAttrValue::GetAtomCount() const
   }
 
   return 0;
 }
 
 nsAtom*
 nsAttrValue::AtomAt(int32_t aIndex) const
 {
-  NS_PRECONDITION(aIndex >= 0, "Index must not be negative");
-  NS_PRECONDITION(GetAtomCount() > uint32_t(aIndex), "aIndex out of range");
+  MOZ_ASSERT(aIndex >= 0, "Index must not be negative");
+  MOZ_ASSERT(GetAtomCount() > uint32_t(aIndex), "aIndex out of range");
 
   if (BaseType() == eAtomBase) {
     return GetAtomValue();
   }
 
   NS_ASSERTION(Type() == eAtomArray, "GetAtomCount must be confused");
 
   return GetAtomArrayValue()->ElementAt(aIndex);
@@ -1395,17 +1395,17 @@ nsAttrValue::ParseEnumValue(const nsAStr
                    "failed to store enum properly");
 
       return true;
     }
     tableEntry++;
   }
 
   if (aDefaultValue) {
-    NS_PRECONDITION(aTable <= aDefaultValue && aDefaultValue < tableEntry,
+    MOZ_ASSERT(aTable <= aDefaultValue && aDefaultValue < tableEntry,
                     "aDefaultValue not inside aTable?");
     SetIntValueAndType(EnumTableEntryToValue(aTable, aDefaultValue),
                        eEnum, &aValue);
     return true;
   }
 
   return false;
 }
@@ -1438,17 +1438,17 @@ nsAttrValue::ParseSpecialIntValue(const 
                      nonStrict ? &aString : nullptr);
   return true;
 }
 
 bool
 nsAttrValue::ParseIntWithBounds(const nsAString& aString,
                                 int32_t aMin, int32_t aMax)
 {
-  NS_PRECONDITION(aMin < aMax, "bad boundaries");
+  MOZ_ASSERT(aMin < aMax, "bad boundaries");
 
   ResetIfSet();
 
   nsContentUtils::ParseHTMLIntegerResultFlags result;
   int32_t originalVal = nsContentUtils::ParseHTMLInteger(aString, &result);
   if (result & nsContentUtils::eParseHTMLInteger_Error) {
     return false;
   }
--- a/dom/base/nsAttrValueInlines.h
+++ b/dom/base/nsAttrValueInlines.h
@@ -123,77 +123,77 @@ public:
 
 /**
  * Implementation of inline methods
  */
 
 inline int32_t
 nsAttrValue::GetIntegerValue() const
 {
-  NS_PRECONDITION(Type() == eInteger, "wrong type");
+  MOZ_ASSERT(Type() == eInteger, "wrong type");
   return (BaseType() == eIntegerBase)
          ? GetIntInternal()
          : GetMiscContainer()->mValue.mInteger;
 }
 
 inline int16_t
 nsAttrValue::GetEnumValue() const
 {
-  NS_PRECONDITION(Type() == eEnum, "wrong type");
+  MOZ_ASSERT(Type() == eEnum, "wrong type");
   // We don't need to worry about sign extension here since we're
   // returning an int16_t which will cut away the top bits.
   return static_cast<int16_t>((
     (BaseType() == eIntegerBase)
     ? static_cast<uint32_t>(GetIntInternal())
     : GetMiscContainer()->mValue.mEnumValue)
       >> NS_ATTRVALUE_ENUMTABLEINDEX_BITS);
 }
 
 inline float
 nsAttrValue::GetPercentValue() const
 {
-  NS_PRECONDITION(Type() == ePercent, "wrong type");
+  MOZ_ASSERT(Type() == ePercent, "wrong type");
   return ((BaseType() == eIntegerBase)
           ? GetIntInternal()
           : GetMiscContainer()->mValue.mPercent)
             / 100.0f;
 }
 
 inline mozilla::AtomArray*
 nsAttrValue::GetAtomArrayValue() const
 {
-  NS_PRECONDITION(Type() == eAtomArray, "wrong type");
+  MOZ_ASSERT(Type() == eAtomArray, "wrong type");
   return GetMiscContainer()->mValue.mAtomArray;
 }
 
 inline mozilla::DeclarationBlock*
 nsAttrValue::GetCSSDeclarationValue() const
 {
-  NS_PRECONDITION(Type() == eCSSDeclaration, "wrong type");
+  MOZ_ASSERT(Type() == eCSSDeclaration, "wrong type");
   return GetMiscContainer()->mValue.mCSSDeclaration;
 }
 
 inline nsIURI*
 nsAttrValue::GetURLValue() const
 {
-  NS_PRECONDITION(Type() == eURL, "wrong type");
+  MOZ_ASSERT(Type() == eURL, "wrong type");
   return GetMiscContainer()->mValue.mURL;
 }
 
 inline double
 nsAttrValue::GetDoubleValue() const
 {
-  NS_PRECONDITION(Type() == eDoubleValue, "wrong type");
+  MOZ_ASSERT(Type() == eDoubleValue, "wrong type");
   return GetMiscContainer()->mDoubleValue;
 }
 
 inline bool
 nsAttrValue::GetIntMarginValue(nsIntMargin& aMargin) const
 {
-  NS_PRECONDITION(Type() == eIntMarginValue, "wrong type");
+  MOZ_ASSERT(Type() == eIntMarginValue, "wrong type");
   nsIntMargin* m = GetMiscContainer()->mValue.mIntMargin;
   if (!m)
     return false;
   aMargin = *m;
   return true;
 }
 
 inline bool
@@ -264,17 +264,17 @@ nsAttrValue::Type() const
       return static_cast<ValueType>(static_cast<uint16_t>(BaseType()));
     }
   }
 }
 
 inline nsAtom*
 nsAttrValue::GetAtomValue() const
 {
-  NS_PRECONDITION(Type() == eAtom, "wrong type");
+  MOZ_ASSERT(Type() == eAtom, "wrong type");
   return reinterpret_cast<nsAtom*>(GetPtr());
 }
 
 inline void
 nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const
 {
   switch (Type()) {
     case eString:
--- a/dom/base/nsContentAreaDragDrop.cpp
+++ b/dom/base/nsContentAreaDragDrop.cpp
@@ -537,17 +537,17 @@ DragDataProducer::GetImageData(imgIConta
 
 nsresult
 DragDataProducer::Produce(DataTransfer* aDataTransfer,
                           bool* aCanDrag,
                           nsISelection** aSelection,
                           nsIContent** aDragNode,
                           nsACString& aPrincipalURISpec)
 {
-  NS_PRECONDITION(aCanDrag && aSelection && aDataTransfer && aDragNode,
+  MOZ_ASSERT(aCanDrag && aSelection && aDataTransfer && aDragNode,
                   "null pointer passed to Produce");
   NS_ASSERTION(mWindow, "window not set");
   NS_ASSERTION(mSelectionTargetNode, "selection target node should have been set");
 
   *aDragNode = nullptr;
 
   nsresult rv;
   nsIContent* dragNode = nullptr;
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -623,17 +623,17 @@ nsContentList::Item(uint32_t aIndex)
 
 void
 nsContentList::AttributeChanged(Element* aElement,
                                 int32_t aNameSpaceID,
                                 nsAtom* aAttribute,
                                 int32_t aModType,
                                 const nsAttrValue* aOldValue)
 {
-  NS_PRECONDITION(aElement, "Must have a content node to work with");
+  MOZ_ASSERT(aElement, "Must have a content node to work with");
 
   if (!mFunc || !mFuncMayDependOnAttr || mState == LIST_DIRTY ||
       !MayContainRelevantNodes(aElement->GetParentNode()) ||
       !nsContentUtils::IsInSameAnonymousTree(mRootNode, aElement)) {
     // Either we're already dirty or this notification doesn't affect
     // whether we might match aElement.
     return;
   }
@@ -653,17 +653,17 @@ nsContentList::AttributeChanged(Element*
     mElements.RemoveElement(aElement);
   }
 }
 
 void
 nsContentList::ContentAppended(nsIContent* aFirstNewContent)
 {
   nsIContent* container = aFirstNewContent->GetParent();
-  NS_PRECONDITION(container, "Can't get at the new content if no container!");
+  MOZ_ASSERT(container, "Can't get at the new content if no container!");
 
   /*
    * If the state is LIST_DIRTY then we have no useful information in our list
    * and we want to put off doing work as much as possible.
    *
    * Also, if container is anonymous from our point of view, we know that we
    * can't possibly be matching any of the kids.
    *
@@ -822,18 +822,18 @@ nsContentList::Match(Element *aElement)
 
   return matchHTML ? ni->Equals(mHTMLMatchAtom, mMatchNameSpaceId) :
                      ni->Equals(mXMLMatchAtom, mMatchNameSpaceId);
 }
 
 bool
 nsContentList::MatchSelf(nsIContent *aContent)
 {
-  NS_PRECONDITION(aContent, "Can't match null stuff, you know");
-  NS_PRECONDITION(mDeep || aContent->GetParentNode() == mRootNode,
+  MOZ_ASSERT(aContent, "Can't match null stuff, you know");
+  MOZ_ASSERT(mDeep || aContent->GetParentNode() == mRootNode,
                   "MatchSelf called on a node that we can't possibly match");
 
   if (!aContent->IsElement()) {
     return false;
   }
 
   if (Match(aContent->AsElement()))
     return true;
--- a/dom/base/nsContentList.h
+++ b/dom/base/nsContentList.h
@@ -382,17 +382,17 @@ public:
   }
 
   bool MatchesKey(const nsContentListKey& aKey) const
   {
     // The root node is most commonly the same: the document.  And the
     // most common namespace id is kNameSpaceID_Unknown.  So check the
     // string first.  Cases in which whether our root's ownerDocument
     // is HTML changes are extremely rare, so check those last.
-    NS_PRECONDITION(mXMLMatchAtom,
+    MOZ_ASSERT(mXMLMatchAtom,
                     "How did we get here with a null match atom on our list?");
     return
       mXMLMatchAtom->Equals(aKey.mTagname) &&
       mRootNode == aKey.mRootNode &&
       mMatchNameSpaceId == aKey.mMatchNameSpaceId &&
       mIsHTMLDocument == aKey.mIsHTMLDocument;
   }
 
--- a/dom/base/nsContentPolicy.cpp
+++ b/dom/base/nsContentPolicy.cpp
@@ -83,17 +83,17 @@ nsContentPolicy::CheckPolicy(CPMethod   
     nsCOMPtr<nsIPrincipal> requestPrincipal = loadInfo->TriggeringPrincipal();
     nsCOMPtr<nsIURI> requestingLocation;
     nsCOMPtr<nsIPrincipal> loadingPrincipal = loadInfo->LoadingPrincipal();
     if (loadingPrincipal) {
       loadingPrincipal->GetURI(getter_AddRefs(requestingLocation));
     }
 
     //sanity-check passed-through parameters
-    NS_PRECONDITION(decision, "Null out pointer");
+    MOZ_ASSERT(decision, "Null out pointer");
     WARN_IF_URI_UNINITIALIZED(contentLocation, "Request URI");
     WARN_IF_URI_UNINITIALIZED(requestingLocation, "Requesting URI");
 
 #ifdef DEBUG
     {
         nsCOMPtr<nsIDOMNode> node(do_QueryInterface(requestingContext));
         nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(requestingContext));
         nsCOMPtr<nsITabChild> tabChild(do_QueryInterface(requestingContext));
@@ -203,17 +203,17 @@ nsContentPolicy::CheckPolicy(CPMethod   
 
 NS_IMETHODIMP
 nsContentPolicy::ShouldLoad(nsIURI           *contentLocation,
                             nsILoadInfo      *loadInfo,
                             const nsACString &mimeType,
                             int16_t          *decision)
 {
     // ShouldProcess does not need a content location, but we do
-    NS_PRECONDITION(contentLocation, "Must provide request location");
+    MOZ_ASSERT(contentLocation, "Must provide request location");
     nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldLoad,
                               contentLocation, loadInfo,
                               mimeType, decision);
     LOG_CHECK("ShouldLoad");
 
     return rv;
 }
 
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -190,18 +190,18 @@ nsContentSink::InitializeStatics()
 }
 
 nsresult
 nsContentSink::Init(nsIDocument* aDoc,
                     nsIURI* aURI,
                     nsISupports* aContainer,
                     nsIChannel* aChannel)
 {
-  NS_PRECONDITION(aDoc, "null ptr");
-  NS_PRECONDITION(aURI, "null ptr");
+  MOZ_ASSERT(aDoc, "null ptr");
+  MOZ_ASSERT(aURI, "null ptr");
 
   if (!aDoc || !aURI) {
     return NS_ERROR_NULL_POINTER;
   }
 
   mDocument = aDoc;
 
   mDocumentURI = aURI;
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -765,17 +765,17 @@ nsContentUtils::Init()
   return NS_OK;
 }
 
 nsresult nsContentUtils::RemoveWyciwygScheme(nsIURI* aURI, nsIURI** aReturn)
 {
 #ifdef DEBUG
   bool isWyciwyg = false;
   aURI->SchemeIs("wyciwyg", &isWyciwyg);
-  NS_PRECONDITION(isWyciwyg, "Scheme should be wyciwyg");
+  MOZ_ASSERT(isWyciwyg, "Scheme should be wyciwyg");
 #endif
   nsAutoCString path;
   nsresult rv = aURI->GetPathQueryRef(path);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t pathLength = path.Length();
   if (pathLength <= 2) {
     return NS_ERROR_FAILURE;
@@ -1056,17 +1056,17 @@ nsContentUtils::Atob(const nsAString& aA
     return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
   }
   return rv;
 }
 
 bool
 nsContentUtils::IsAutocompleteEnabled(mozilla::dom::HTMLInputElement* aInput)
 {
-  NS_PRECONDITION(aInput, "aInput should not be null!");
+  MOZ_ASSERT(aInput, "aInput should not be null!");
 
   nsAutoString autocomplete;
   aInput->GetAutocomplete(autocomplete);
 
   if (autocomplete.IsEmpty()) {
     auto* form = aInput->GetForm();
     if (!form) {
       return true;
@@ -2188,17 +2188,17 @@ nsContentUtils::IsAbsoluteURL(const nsAC
 
   return false;
 }
 
 //static
 bool
 nsContentUtils::InProlog(nsINode *aNode)
 {
-  NS_PRECONDITION(aNode, "missing node to nsContentUtils::InProlog");
+  MOZ_ASSERT(aNode, "missing node to nsContentUtils::InProlog");
 
   nsINode* parent = aNode->GetParentNode();
   if (!parent || !parent->IsDocument()) {
     return false;
   }
 
   nsIDocument* doc = parent->AsDocument();
   nsIContent* root = doc->GetRootElement();
@@ -2386,17 +2386,17 @@ nsContentUtils::LookupBindingMember(JSCo
     return true;
   return binding->LookupMember(aCx, aId, aDesc);
 }
 
 // static
 nsINode*
 nsContentUtils::GetCrossDocParentNode(nsINode* aChild)
 {
-  NS_PRECONDITION(aChild, "The child is null!");
+  MOZ_ASSERT(aChild, "The child is null!");
 
   nsINode* parent = aChild->GetParentNode();
   if (parent && parent->IsContent() && aChild->IsContent()) {
     parent = aChild->AsContent()->GetFlattenedTreeParent();
   }
 
   if (parent || !aChild->IsDocument()) {
     return parent;
@@ -2407,34 +2407,34 @@ nsContentUtils::GetCrossDocParentNode(ns
   return parentDoc ? parentDoc->FindContentForSubDocument(doc) : nullptr;
 }
 
 // static
 bool
 nsContentUtils::ContentIsDescendantOf(const nsINode* aPossibleDescendant,
                                       const nsINode* aPossibleAncestor)
 {
-  NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
-  NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
+  MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!");
+  MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!");
 
   do {
     if (aPossibleDescendant == aPossibleAncestor)
       return true;
     aPossibleDescendant = aPossibleDescendant->GetParentNode();
   } while (aPossibleDescendant);
 
   return false;
 }
 
 bool
 nsContentUtils::ContentIsHostIncludingDescendantOf(
   const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor)
 {
-  NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
-  NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
+  MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!");
+  MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!");
 
   do {
     if (aPossibleDescendant == aPossibleAncestor)
       return true;
     if (aPossibleDescendant->IsDocumentFragment()) {
       aPossibleDescendant =
         aPossibleDescendant->AsDocumentFragment()->GetHost();
     } else {
@@ -2473,18 +2473,18 @@ nsContentUtils::ContentIsShadowIncluding
   return false;
 }
 
 // static
 bool
 nsContentUtils::ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
                                               nsINode* aPossibleAncestor)
 {
-  NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
-  NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
+  MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!");
+  MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!");
 
   do {
     if (aPossibleDescendant == aPossibleAncestor)
       return true;
 
     aPossibleDescendant = GetCrossDocParentNode(aPossibleDescendant);
   } while (aPossibleDescendant);
 
@@ -2492,18 +2492,18 @@ nsContentUtils::ContentIsCrossDocDescend
 }
 
 // static
 bool
 nsContentUtils::ContentIsFlattenedTreeDescendantOf(
   const nsINode* aPossibleDescendant,
   const nsINode* aPossibleAncestor)
 {
-  NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
-  NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
+  MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!");
+  MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!");
 
   do {
     if (aPossibleDescendant == aPossibleAncestor) {
       return true;
     }
     aPossibleDescendant = aPossibleDescendant->GetFlattenedTreeParentNode();
   } while (aPossibleDescendant);
 
@@ -2511,18 +2511,18 @@ nsContentUtils::ContentIsFlattenedTreeDe
 }
 
 // static
 bool
 nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(
   const nsINode* aPossibleDescendant,
   const nsINode* aPossibleAncestor)
 {
-  NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
-  NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
+  MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!");
+  MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!");
 
   do {
     if (aPossibleDescendant == aPossibleAncestor) {
       return true;
     }
     aPossibleDescendant =
       aPossibleDescendant->GetFlattenedTreeParentNodeForStyle();
   } while (aPossibleDescendant);
@@ -3446,19 +3446,19 @@ nsContentUtils::GetContextForContent(con
 // static
 bool
 nsContentUtils::CanLoadImage(nsIURI* aURI, nsINode* aNode,
                              nsIDocument* aLoadingDocument,
                              nsIPrincipal* aLoadingPrincipal,
                              int16_t* aImageBlockingStatus,
                              uint32_t aContentType)
 {
-  NS_PRECONDITION(aURI, "Must have a URI");
-  NS_PRECONDITION(aLoadingDocument, "Must have a document");
-  NS_PRECONDITION(aLoadingPrincipal, "Must have a loading principal");
+  MOZ_ASSERT(aURI, "Must have a URI");
+  MOZ_ASSERT(aLoadingDocument, "Must have a document");
+  MOZ_ASSERT(aLoadingPrincipal, "Must have a loading principal");
 
   nsresult rv;
 
   uint32_t appType = nsIDocShell::APP_TYPE_UNKNOWN;
 
   {
     nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = aLoadingDocument->GetDocShell();
     if (docShellTreeItem) {
@@ -3671,21 +3671,21 @@ nsContentUtils::LoadImage(nsIURI* aURI, 
                           nsIURI* aReferrer,
                           net::ReferrerPolicy aReferrerPolicy,
                           imgINotificationObserver* aObserver, int32_t aLoadFlags,
                           const nsAString& initiatorType,
                           imgRequestProxy** aRequest,
                           uint32_t aContentPolicyType,
                           bool aUseUrgentStartForChannel)
 {
-  NS_PRECONDITION(aURI, "Must have a URI");
-  NS_PRECONDITION(aContext, "Must have a context");
-  NS_PRECONDITION(aLoadingDocument, "Must have a document");
-  NS_PRECONDITION(aLoadingPrincipal, "Must have a principal");
-  NS_PRECONDITION(aRequest, "Null out param");
+  MOZ_ASSERT(aURI, "Must have a URI");
+  MOZ_ASSERT(aContext, "Must have a context");
+  MOZ_ASSERT(aLoadingDocument, "Must have a document");
+  MOZ_ASSERT(aLoadingPrincipal, "Must have a principal");
+  MOZ_ASSERT(aRequest, "Null out param");
 
   imgLoader* imgLoader = GetImgLoaderForDocument(aLoadingDocument);
   if (!imgLoader) {
     // nothing we can do here
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsILoadGroup> loadGroup = aLoadingDocument->GetDocumentLoadGroup();
@@ -3783,17 +3783,17 @@ nsContentUtils::ContentIsDraggable(nsICo
   // special handling for content area image and link dragging
   return IsDraggableImage(aContent) || IsDraggableLink(aContent);
 }
 
 // static
 bool
 nsContentUtils::IsDraggableImage(nsIContent* aContent)
 {
-  NS_PRECONDITION(aContent, "Must have content node to test");
+  MOZ_ASSERT(aContent, "Must have content node to test");
 
   nsCOMPtr<nsIImageLoadingContent> imageContent(do_QueryInterface(aContent));
   if (!imageContent) {
     return false;
   }
 
   nsCOMPtr<imgIRequest> imgRequest;
   imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
@@ -4585,17 +4585,17 @@ nsContentUtils::MatchElementId(nsIConten
 
   return nullptr;
 }
 
 /* static */
 Element *
 nsContentUtils::MatchElementId(nsIContent *aContent, const nsAString& aId)
 {
-  NS_PRECONDITION(!aId.IsEmpty(), "Will match random elements");
+  MOZ_ASSERT(!aId.IsEmpty(), "Will match random elements");
 
   // ID attrs are generally stored as atoms, so just atomize this up front
   RefPtr<nsAtom> id(NS_Atomize(aId));
   if (!id) {
     // OOM, so just bail
     return nullptr;
   }
 
@@ -4732,19 +4732,19 @@ nsContentUtils::HasMutationListeners(nsI
   // all mutation bits when there is a listener for DOMSubtreeModified event.
   return !window || window->HasMutationListeners(aType);
 }
 
 void
 nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent,
                                      nsIDocument* aOwnerDoc)
 {
-  NS_PRECONDITION(aChild, "Missing child");
-  NS_PRECONDITION(aChild->GetParentNode() == aParent, "Wrong parent");
-  NS_PRECONDITION(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc");
+  MOZ_ASSERT(aChild, "Missing child");
+  MOZ_ASSERT(aChild->GetParentNode() == aParent, "Wrong parent");
+  MOZ_ASSERT(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc");
 
   // Having an explicit check here since it's an easy mistake to fall into,
   // and there might be existing code with problems. We'd rather be safe
   // than fire DOMNodeRemoved in all corner cases. We also rely on it for
   // nsAutoScriptBlockerSuppressNodeRemoved.
   if (!IsSafeToRunScript()) {
     // This checks that IsSafeToRunScript is true since we don't want to fire
     // events when that is false. We can't rely on EventDispatcher to assert
@@ -5402,19 +5402,19 @@ nsContentUtils::HasNonEmptyTextContent(n
   return false;
 }
 
 /* static */
 bool
 nsContentUtils::IsInSameAnonymousTree(const nsINode* aNode,
                                       const nsIContent* aContent)
 {
-  NS_PRECONDITION(aNode,
+  MOZ_ASSERT(aNode,
                   "Must have a node to work with");
-  NS_PRECONDITION(aContent,
+  MOZ_ASSERT(aContent,
                   "Must have a content to work with");
 
   if (!aNode->IsContent()) {
     /**
      * The root isn't an nsIContent, so it's a document or attribute.  The only
      * nodes in the same anonymous subtree as it will have a null
      * bindingParent.
      *
@@ -5490,17 +5490,17 @@ nsContentUtils::CombineResourcePrincipal
 /* static */
 void
 nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
                             nsIURI *aLinkURI, const nsString &aTargetSpec,
                             bool aClick, bool aIsUserTriggered,
                             bool aIsTrusted)
 {
   NS_ASSERTION(aPresContext, "Need a nsPresContext");
-  NS_PRECONDITION(aLinkURI, "No link URI");
+  MOZ_ASSERT(aLinkURI, "No link URI");
 
   if (aContent->IsEditable()) {
     return;
   }
 
   nsILinkHandler *handler = aPresContext->GetLinkHandler();
   if (!handler) {
     return;
@@ -6278,17 +6278,17 @@ NS_IMPL_ISUPPORTS(SameOriginCheckerImpl,
                   nsIInterfaceRequestor)
 
 NS_IMETHODIMP
 SameOriginCheckerImpl::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
                                               nsIChannel* aNewChannel,
                                               uint32_t aFlags,
                                               nsIAsyncVerifyRedirectCallback* cb)
 {
-  NS_PRECONDITION(aNewChannel, "Redirecting to null channel?");
+  MOZ_ASSERT(aNewChannel, "Redirecting to null channel?");
 
   nsresult rv = nsContentUtils::CheckSameOrigin(aOldChannel, aNewChannel);
   if (NS_SUCCEEDED(rv)) {
     cb->OnRedirectVerifyCallback(NS_OK);
   }
 
   return rv;
 }
@@ -6298,17 +6298,17 @@ SameOriginCheckerImpl::GetInterface(cons
 {
   return QueryInterface(aIID, aResult);
 }
 
 /* static */
 nsresult
 nsContentUtils::GetASCIIOrigin(nsIPrincipal* aPrincipal, nsACString& aOrigin)
 {
-  NS_PRECONDITION(aPrincipal, "missing principal");
+  MOZ_ASSERT(aPrincipal, "missing principal");
 
   aOrigin.Truncate();
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (uri) {
@@ -6319,17 +6319,17 @@ nsContentUtils::GetASCIIOrigin(nsIPrinci
 
   return NS_OK;
 }
 
 /* static */
 nsresult
 nsContentUtils::GetASCIIOrigin(nsIURI* aURI, nsACString& aOrigin)
 {
-  NS_PRECONDITION(aURI, "missing uri");
+  MOZ_ASSERT(aURI, "missing uri");
 
   // For Blob URI we have to return the origin of page using its principal.
   nsCOMPtr<nsIURIWithPrincipal> uriWithPrincipal = do_QueryInterface(aURI);
   if (uriWithPrincipal) {
     nsCOMPtr<nsIPrincipal> principal;
     uriWithPrincipal->GetPrincipal(getter_AddRefs(principal));
 
     if (principal) {
@@ -6373,17 +6373,17 @@ nsContentUtils::GetASCIIOrigin(nsIURI* a
 
   return NS_OK;
 }
 
 /* static */
 nsresult
 nsContentUtils::GetUTFOrigin(nsIPrincipal* aPrincipal, nsAString& aOrigin)
 {
-  NS_PRECONDITION(aPrincipal, "missing principal");
+  MOZ_ASSERT(aPrincipal, "missing principal");
 
   aOrigin.Truncate();
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (uri) {
@@ -6394,17 +6394,17 @@ nsContentUtils::GetUTFOrigin(nsIPrincipa
 
   return NS_OK;
 }
 
 /* static */
 nsresult
 nsContentUtils::GetUTFOrigin(nsIURI* aURI, nsAString& aOrigin)
 {
-  NS_PRECONDITION(aURI, "missing uri");
+  MOZ_ASSERT(aURI, "missing uri");
 
   bool isBlobURL = false;
   nsresult rv = aURI->SchemeIs(BLOBURI_SCHEME, &isBlobURL);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // For Blob URI, the path is the URL of the owning page.
   if (isBlobURL) {
     nsAutoCString path;
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2190,17 +2190,17 @@ public:
 
   /**
    * Utility method for getElementsByClassName.  aRootNode is the node (either
    * document or element), which getElementsByClassName was called on.
    */
   static already_AddRefed<nsContentList>
   GetElementsByClassName(nsINode* aRootNode, const nsAString& aClasses)
   {
-    NS_PRECONDITION(aRootNode, "Must have root node");
+    MOZ_ASSERT(aRootNode, "Must have root node");
 
     return GetFuncStringContentList<nsCacheableFuncStringHTMLCollection>(aRootNode,
                                                                          MatchClassNames,
                                                                          DestroyClassNameArray,
                                                                          AllocClassMatchingInfo,
                                                                          aClasses);
   }
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -500,18 +500,18 @@ struct PositionComparator
   }
 };
 
 } // namespace
 
 bool
 nsIdentifierMapEntry::AddIdElement(Element* aElement)
 {
-  NS_PRECONDITION(aElement, "Must have element");
-  NS_PRECONDITION(!mIdContentList.Contains(nullptr),
+  MOZ_ASSERT(aElement, "Must have element");
+  MOZ_ASSERT(!mIdContentList.Contains(nullptr),
                   "Why is null in our list?");
 
 #ifdef DEBUG
   Element* currentElement = mIdContentList.SafeElementAt(0);
 #endif
 
   // Common case
   if (mIdContentList.IsEmpty()) {
@@ -544,17 +544,17 @@ nsIdentifierMapEntry::AddIdElement(Eleme
     FireChangeCallbacks(oldElement, aElement);
   }
   return true;
 }
 
 void
 nsIdentifierMapEntry::RemoveIdElement(Element* aElement)
 {
-  NS_PRECONDITION(aElement, "Missing element");
+  MOZ_ASSERT(aElement, "Missing element");
 
   // This should only be called while the document is in an update.
   // Assertions near the call to this method guarantee this.
 
   // This could fire in OOM situations
   // Only assert this in HTML documents for now as XUL does all sorts of weird
   // crap.
   NS_ASSERTION(!aElement->OwnerDoc()->IsHTMLDocument() ||
@@ -815,18 +815,18 @@ nsIDocument*
 nsExternalResourceMap::RequestResource(nsIURI* aURI,
                                        nsINode* aRequestingNode,
                                        nsIDocument* aDisplayDocument,
                                        ExternalResourceLoad** aPendingLoad)
 {
   // If we ever start allowing non-same-origin loads here, we might need to do
   // something interesting with aRequestingPrincipal even for the hashtable
   // gets.
-  NS_PRECONDITION(aURI, "Must have a URI");
-  NS_PRECONDITION(aRequestingNode, "Must have a node");
+  MOZ_ASSERT(aURI, "Must have a URI");
+  MOZ_ASSERT(aRequestingNode, "Must have a node");
   *aPendingLoad = nullptr;
   if (mHaveShutDown) {
     return nullptr;
   }
 
   // First, make sure we strip the ref from aURI.
   nsCOMPtr<nsIURI> clone;
   nsresult rv = aURI->CloneIgnoringRef(getter_AddRefs(clone));
@@ -953,18 +953,18 @@ TransferShowingState(nsIDocument* aFromD
 }
 
 nsresult
 nsExternalResourceMap::AddExternalResource(nsIURI* aURI,
                                            nsIContentViewer* aViewer,
                                            nsILoadGroup* aLoadGroup,
                                            nsIDocument* aDisplayDocument)
 {
-  NS_PRECONDITION(aURI, "Unexpected call");
-  NS_PRECONDITION((aViewer && aLoadGroup) || (!aViewer && !aLoadGroup),
+  MOZ_ASSERT(aURI, "Unexpected call");
+  MOZ_ASSERT((aViewer && aLoadGroup) || (!aViewer && !aLoadGroup),
                   "Must have both or neither");
 
   RefPtr<PendingLoad> load;
   mPendingLoads.Remove(aURI, getter_AddRefs(load));
 
   nsresult rv = NS_OK;
 
   nsCOMPtr<nsIDocument> doc;
@@ -1045,17 +1045,17 @@ nsExternalResourceMap::PendingLoad::OnSt
   return mTargetListener->OnStartRequest(aRequest, aContext);
 }
 
 nsresult
 nsExternalResourceMap::PendingLoad::SetupViewer(nsIRequest* aRequest,
                                                 nsIContentViewer** aViewer,
                                                 nsILoadGroup** aLoadGroup)
 {
-  NS_PRECONDITION(!mTargetListener, "Unexpected call to OnStartRequest");
+  MOZ_ASSERT(!mTargetListener, "Unexpected call to OnStartRequest");
   *aViewer = nullptr;
   *aLoadGroup = nullptr;
 
   nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
   NS_ENSURE_TRUE(chan, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
   if (httpChannel) {
@@ -1156,18 +1156,18 @@ nsExternalResourceMap::PendingLoad::OnSt
 
   return NS_OK;
 }
 
 nsresult
 nsExternalResourceMap::PendingLoad::StartLoad(nsIURI* aURI,
                                               nsINode* aRequestingNode)
 {
-  NS_PRECONDITION(aURI, "Must have a URI");
-  NS_PRECONDITION(aRequestingNode, "Must have a node");
+  MOZ_ASSERT(aURI, "Must have a URI");
+  MOZ_ASSERT(aRequestingNode, "Must have a node");
 
   nsCOMPtr<nsILoadGroup> loadGroup =
     aRequestingNode->OwnerDoc()->GetDocumentLoadGroup();
 
   nsresult rv = NS_OK;
   nsCOMPtr<nsIChannel> channel;
   rv = NS_NewChannel(getter_AddRefs(channel),
                      aURI,
@@ -1749,17 +1749,17 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsDocument)
 NS_INTERFACE_MAP_END
 
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocument)
 NS_IMETHODIMP_(MozExternalRefCountType)
 nsDocument::Release()
 {
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   NS_ASSERT_OWNINGTHREAD(nsDocument);
   nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(nsDocument)::Upcast(this);
   bool shouldDelete = false;
   nsrefcnt count = mRefCnt.decr(base, &shouldDelete);
   NS_LOG_RELEASE(this, count, "nsDocument");
   if (count == 0) {
     if (mStackRefCnt && !mNeedsReleaseAfterStackRefCntRelease) {
       mNeedsReleaseAfterStackRefCntRelease = true;
@@ -2222,17 +2222,17 @@ nsIDocument::Reset(nsIChannel* aChannel,
   mChannel = aChannel;
 }
 
 void
 nsIDocument::ResetToURI(nsIURI* aURI,
                         nsILoadGroup* aLoadGroup,
                         nsIPrincipal* aPrincipal)
 {
-  NS_PRECONDITION(aURI, "Null URI passed to ResetToURI");
+  MOZ_ASSERT(aURI, "Null URI passed to ResetToURI");
 
   MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
           ("DOCUMENT %p ResetToURI %s", this, aURI->GetSpecOrDefault().get()));
 
   mSecurityInfo = nullptr;
 
   mDocumentLoadGroup = nullptr;
 
@@ -2525,18 +2525,18 @@ AppendSheetsToStyleSet(ServoStyleSet* aS
     aStyleSet->AppendStyleSheet(aType, sheet);
   }
 }
 
 
 void
 nsIDocument::FillStyleSet(ServoStyleSet* aStyleSet)
 {
-  NS_PRECONDITION(aStyleSet, "Must have a style set");
-  NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0,
+  MOZ_ASSERT(aStyleSet, "Must have a style set");
+  MOZ_ASSERT(aStyleSet->SheetCount(SheetType::Doc) == 0,
                   "Style set already has document sheets?");
 
   MOZ_ASSERT(!mStyleSetFilled);
 
   for (StyleSheet* sheet : Reversed(mStyleSheets)) {
     if (sheet->IsApplicable()) {
       aStyleSet->AddDocStyleSheet(sheet, this);
     }
@@ -4383,17 +4383,17 @@ nsIDocument::RemoveStyleSheetFromStyleSe
   if (shell) {
     shell->StyleSet()->RemoveDocStyleSheet(aSheet);
   }
 }
 
 void
 nsIDocument::RemoveStyleSheet(StyleSheet* aSheet)
 {
-  NS_PRECONDITION(aSheet, "null arg");
+  MOZ_ASSERT(aSheet, "null arg");
   RefPtr<StyleSheet> sheet = aSheet; // hold ref so it won't die too soon
 
   if (!mStyleSheets.RemoveElement(aSheet)) {
     NS_ASSERTION(mInUnlinkOrDeletion, "stylesheet not found");
     return;
   }
 
   if (!mIsGoingAway) {
@@ -4409,17 +4409,17 @@ nsIDocument::RemoveStyleSheet(StyleSheet
 
 void
 nsIDocument::UpdateStyleSheets(nsTArray<RefPtr<StyleSheet>>& aOldSheets,
                                nsTArray<RefPtr<StyleSheet>>& aNewSheets)
 {
   BeginUpdate(UPDATE_STYLE);
 
   // XXX Need to set the sheet on the ownernode, if any
-  NS_PRECONDITION(aOldSheets.Length() == aNewSheets.Length(),
+  MOZ_ASSERT(aOldSheets.Length() == aNewSheets.Length(),
                   "The lists must be the same length!");
   int32_t count = aOldSheets.Length();
 
   RefPtr<StyleSheet> oldSheet;
   int32_t i;
   for (i = 0; i < count; ++i) {
     oldSheet = aOldSheets[i];
 
@@ -4461,17 +4461,17 @@ nsIDocument::InsertStyleSheetAt(StyleShe
 
   NotifyStyleSheetAdded(aSheet, true);
 }
 
 
 void
 nsIDocument::SetStyleSheetApplicableState(StyleSheet* aSheet, bool aApplicable)
 {
-  NS_PRECONDITION(aSheet, "null arg");
+  MOZ_ASSERT(aSheet, "null arg");
 
   // If we're actually in the document style sheet list
   if (mStyleSheets.IndexOf(aSheet) != mStyleSheets.NoIndex) {
     if (aApplicable) {
       AddStyleSheetToStyleSets(aSheet);
     } else {
       RemoveStyleSheetFromStyleSets(aSheet);
     }
@@ -4545,17 +4545,17 @@ FindSheet(const nsTArray<RefPtr<StyleShe
 
   return -1;
 }
 
 nsresult
 nsIDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
                                       nsIURI* aSheetURI)
 {
-  NS_PRECONDITION(aSheetURI, "null arg");
+  MOZ_ASSERT(aSheetURI, "null arg");
 
   // Checking if we have loaded this one already.
   if (FindSheet(mAdditionalSheets[aType], aSheetURI) >= 0)
     return NS_ERROR_INVALID_ARG;
 
   // Loading the sheet sync.
   RefPtr<css::Loader> loader = new css::Loader(GetDocGroup());
 
@@ -5480,17 +5480,17 @@ nsIDocument::UnblockDOMContentLoaded()
   } else {
     DispatchContentLoadedEvents();
   }
 }
 
 void
 nsIDocument::ContentStateChanged(nsIContent* aContent, EventStates aStateMask)
 {
-  NS_PRECONDITION(!nsContentUtils::IsSafeToRunScript(),
+  MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(),
                   "Someone forgot a scriptblocker");
   NS_DOCUMENT_NOTIFY_OBSERVERS(ContentStateChanged,
                                (this, aContent, aStateMask));
 }
 
 void
 nsIDocument::DocumentStatesChanged(EventStates aStateMask)
 {
@@ -6744,18 +6744,18 @@ nsIDocument::TryCancelFrameLoaderInitial
   }
 }
 
 nsIDocument*
 nsIDocument::RequestExternalResource(nsIURI* aURI,
                                      nsINode* aRequestingNode,
                                      ExternalResourceLoad** aPendingLoad)
 {
-  NS_PRECONDITION(aURI, "Must have a URI");
-  NS_PRECONDITION(aRequestingNode, "Must have a node");
+  MOZ_ASSERT(aURI, "Must have a URI");
+  MOZ_ASSERT(aRequestingNode, "Must have a node");
   if (mDisplayDocument) {
     return mDisplayDocument->RequestExternalResource(aURI,
                                                      aRequestingNode,
                                                      aPendingLoad);
   }
 
   return mExternalResourceMap.RequestResource(aURI, aRequestingNode,
                                               this, aPendingLoad);
@@ -6919,17 +6919,17 @@ nsIDocument::Anchors()
   return mAnchors;
 }
 
 /* static */
 bool
 nsIDocument::MatchNameAttribute(Element* aElement, int32_t aNamespaceID,
                                 nsAtom* aAtom, void* aData)
 {
-  NS_PRECONDITION(aElement, "Must have element to work with!");
+  MOZ_ASSERT(aElement, "Must have element to work with!");
 
   if (!aElement->HasName()) {
     return false;
   }
 
   nsString* elementName = static_cast<nsString*>(aData);
   return
     aElement->GetNameSpaceID() == kNameSpaceID_XHTML &&
@@ -8390,19 +8390,19 @@ nsIDocument::PostUnblockOnloadEvent()
   } else {
     NS_WARNING("failed to dispatch nsUnblockOnloadEvent");
   }
 }
 
 void
 nsIDocument::DoUnblockOnload()
 {
-  NS_PRECONDITION(!mDisplayDocument,
+  MOZ_ASSERT(!mDisplayDocument,
                   "Shouldn't get here for resource document");
-  NS_PRECONDITION(mOnloadBlockCount != 0,
+  MOZ_ASSERT(mOnloadBlockCount != 0,
                   "Shouldn't have a count of zero here, since we stabilized in "
                   "PostUnblockOnloadEvent");
 
   --mOnloadBlockCount;
 
   if (mOnloadBlockCount != 0) {
     // We blocked again after the last unblock.  Nothing to do here.  We'll
     // post a new event when we unblock again.
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -94,17 +94,17 @@ protected:
   {
     return -1;
   }
 
   nsresult FlushText(nsAString& aString, bool aForce);
 
   bool IsVisibleNode(nsINode* aNode)
   {
-    NS_PRECONDITION(aNode, "");
+    MOZ_ASSERT(aNode, "null node");
 
     if (mFlags & SkipInvisibleContent) {
       // Treat the visibility of the ShadowRoot as if it were
       // the host content.
       //
       // FIXME(emilio): I suspect instead of this a bunch of the GetParent()
       // calls here should be doing GetFlattenedTreeParent, then this condition
       // should be unreachable...
@@ -1749,17 +1749,17 @@ nsCOMPtr<nsINode>
 nsHTMLCopyEncoder::GetChildAt(nsINode *aParent, int32_t aOffset)
 {
   nsCOMPtr<nsINode> resultNode;
 
   if (!aParent)
     return resultNode;
 
   nsCOMPtr<nsIContent> content = do_QueryInterface(aParent);
-  NS_PRECONDITION(content, "null content in nsHTMLCopyEncoder::GetChildAt");
+  MOZ_ASSERT(content, "null content in nsHTMLCopyEncoder::GetChildAt");
 
   resultNode = content->GetChildAt_Deprecated(aOffset);
 
   return resultNode;
 }
 
 bool
 nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode)
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -1558,18 +1558,18 @@ nsFocusManager::IsWindowVisible(nsPIDOMW
   bool visible = false;
   baseWin->GetVisibility(&visible);
   return visible;
 }
 
 bool
 nsFocusManager::IsNonFocusableRoot(nsIContent* aContent)
 {
-  NS_PRECONDITION(aContent, "aContent must not be NULL");
-  NS_PRECONDITION(aContent->IsInComposedDoc(), "aContent must be in a document");
+  MOZ_ASSERT(aContent, "aContent must not be NULL");
+  MOZ_ASSERT(aContent->IsInComposedDoc(), "aContent must be in a document");
 
   // If aContent is in designMode, the root element is not focusable.
   // NOTE: in designMode, most elements are not focusable, just the document is
   //       focusable.
   // Also, if aContent is not editable but it isn't in designMode, it's not
   // focusable.
   // And in userfocusignored context nothing is focusable.
   nsIDocument* doc = aContent->GetComposedDoc();
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -625,17 +625,17 @@ nsFrameLoader::GetDocShell(ErrorResult& 
   return mDocShell;
 }
 
 static void
 SetTreeOwnerAndChromeEventHandlerOnDocshellTree(nsIDocShellTreeItem* aItem,
                                                 nsIDocShellTreeOwner* aOwner,
                                                 EventTarget* aHandler)
 {
-  NS_PRECONDITION(aItem, "Must have item");
+  MOZ_ASSERT(aItem, "Must have item");
 
   aItem->SetTreeOwner(aOwner);
 
   int32_t childCount = 0;
   aItem->GetChildCount(&childCount);
   for (int32_t i = 0; i < childCount; ++i) {
     nsCOMPtr<nsIDocShellTreeItem> item;
     aItem->GetChildAt(i, getter_AddRefs(item));
@@ -657,18 +657,18 @@ SetTreeOwnerAndChromeEventHandlerOnDocsh
  * @return whether aItem is top-level content
  */
 bool
 nsFrameLoader::AddTreeItemToTreeOwner(nsIDocShellTreeItem* aItem,
                                       nsIDocShellTreeOwner* aOwner,
                                       int32_t aParentType,
                                       nsIDocShell* aParentNode)
 {
-  NS_PRECONDITION(aItem, "Must have docshell treeitem");
-  NS_PRECONDITION(mOwnerContent, "Must have owning content");
+  MOZ_ASSERT(aItem, "Must have docshell treeitem");
+  MOZ_ASSERT(mOwnerContent, "Must have owning content");
 
   nsAutoString value;
   bool isContent = mOwnerContent->AttrValueIs(
     kNameSpaceID_None, TypeAttrName(), nsGkAtoms::content, eIgnoreCase);
 
   // Force mozbrowser frames to always be typeContent, even if the
   // mozbrowser interfaces are disabled.
   nsCOMPtr<nsIDOMMozBrowserFrame> mozbrowser =
--- a/dom/base/nsGenConImageContent.cpp
+++ b/dom/base/nsGenConImageContent.cpp
@@ -86,17 +86,17 @@ NS_IMPL_ISUPPORTS_INHERITED(nsGenConImag
 NS_IMPL_ELEMENT_CLONE(nsGenConImageContent)
 
 namespace mozilla {
 namespace dom {
 
 already_AddRefed<nsIContent>
 CreateGenConImageContent(nsIDocument* aDocument, imgRequestProxy* aImageRequest)
 {
-  NS_PRECONDITION(aImageRequest, "Must have request!");
+  MOZ_ASSERT(aImageRequest, "Must have request!");
   RefPtr<NodeInfo> nodeInfo =
     aDocument->NodeInfoManager()->
       GetNodeInfo(nsGkAtoms::mozgeneratedcontentimage,
                   nullptr,
                   kNameSpaceID_XHTML,
                   nsINode::ELEMENT_NODE);
   // Work around not being able to bind a non-const lvalue reference
   // to an rvalue of non-reference type by just creating an rvalue
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -1662,17 +1662,17 @@ nsGlobalWindowInner::GetPopupControlStat
   return nsContentUtils::GetPopupControlState();
 }
 
 nsresult
 nsGlobalWindowInner::SetNewDocument(nsIDocument* aDocument,
                                     nsISupports* aState,
                                     bool aForceReuseInnerWindow)
 {
-  NS_PRECONDITION(mDocumentPrincipal == nullptr,
+  MOZ_ASSERT(mDocumentPrincipal == nullptr,
                   "mDocumentPrincipal prematurely set!");
   MOZ_ASSERT(aDocument);
 
   if (!mOuterWindow) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Refuse to set a new document if the call came from an inner
@@ -4775,17 +4775,17 @@ public:
   {
     MOZ_ASSERT(mWindow);
     mOldURL.Assign(aOldURL);
     mNewURL.Assign(aNewURL);
   }
 
   NS_IMETHOD Run() override
   {
-    NS_PRECONDITION(NS_IsMainThread(), "Should be called on the main thread.");
+    MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread.");
     return mWindow->FireHashchange(mOldURL, mNewURL);
   }
 
 private:
   nsString mOldURL;
   nsString mNewURL;
   RefPtr<nsGlobalWindowInner> mWindow;
 };
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -1410,17 +1410,17 @@ protected:
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(WindowStateHolder, WINDOWSTATEHOLDER_IID)
 
 WindowStateHolder::WindowStateHolder(nsGlobalWindowInner* aWindow)
   : mInnerWindow(aWindow),
     mInnerWindowReflector(RootingCx(), aWindow->GetWrapper())
 {
-  NS_PRECONDITION(aWindow, "null window");
+  MOZ_ASSERT(aWindow, "null window");
 
   aWindow->Suspend();
 
   // When a global goes into the bfcache, we disable script.
   xpc::Scriptability::Get(mInnerWindowReflector).SetDocShellAllowsScript(false);
 }
 
 WindowStateHolder::~WindowStateHolder()
@@ -1635,17 +1635,17 @@ CreateNativeGlobalForInner(JSContext* aC
   return NS_OK;
 }
 
 nsresult
 nsGlobalWindowOuter::SetNewDocument(nsIDocument* aDocument,
                                     nsISupports* aState,
                                     bool aForceReuseInnerWindow)
 {
-  NS_PRECONDITION(mDocumentPrincipal == nullptr,
+  MOZ_ASSERT(mDocumentPrincipal == nullptr,
                   "mDocumentPrincipal prematurely set!");
   MOZ_ASSERT(aDocument);
 
   // Bail out early if we're in process of closing down the window.
   NS_ENSURE_STATE(!mCleanedUp);
 
   NS_ASSERTION(!GetCurrentInnerWindow() ||
                GetCurrentInnerWindow()->GetExtantDoc() == mDoc,
@@ -3845,17 +3845,17 @@ GetCallerDocShellTreeItem()
   return callerItem.forget();
 }
 
 bool
 nsGlobalWindowOuter::WindowExists(const nsAString& aName,
                                   bool aForceNoOpener,
                                   bool aLookForCallerOnJSStack)
 {
-  NS_PRECONDITION(mDocShell, "Must have docshell");
+  MOZ_ASSERT(mDocShell, "Must have docshell");
 
   if (aForceNoOpener) {
     return aName.LowerCaseEqualsLiteral("_self") ||
            aName.LowerCaseEqualsLiteral("_top") ||
            aName.LowerCaseEqualsLiteral("_parent");
   }
 
   nsCOMPtr<nsIDocShellTreeItem> caller;
@@ -6896,19 +6896,20 @@ nsGlobalWindowOuter::OpenInternal(const 
                                   bool aForceNoOpener,
                                   nsPIDOMWindowOuter **aReturn)
 {
 #ifdef DEBUG
   uint32_t argc = 0;
   if (argv)
       argv->GetLength(&argc);
 #endif
-  NS_PRECONDITION(!aExtraArgument || (!argv && argc == 0),
+
+  MOZ_ASSERT(!aExtraArgument || (!argv && argc == 0),
                   "Can't pass in arguments both ways");
-  NS_PRECONDITION(!aCalledNoScript || (!argv && argc == 0),
+  MOZ_ASSERT(!aCalledNoScript || (!argv && argc == 0),
                   "Can't pass JS args when called via the noscript methods");
 
   mozilla::Maybe<AutoUnblockScriptClosing> closeUnblocker;
 
   // Calls to window.open from script should navigate.
   MOZ_ASSERT(aCalledNoScript || aNavigate);
 
   *aReturn = nullptr;
@@ -7726,9 +7727,8 @@ nsAutoPopupStatePusherInternal::nsAutoPo
   : mOldState(nsContentUtils::PushPopupControlState(aState, aForce))
 {
 }
 
 nsAutoPopupStatePusherInternal::~nsAutoPopupStatePusherInternal()
 {
   nsContentUtils::PopPopupControlState(mOldState);
 }
-
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -143,17 +143,17 @@ nsImageLoadingContent::Notify(imgIReques
     OnUnlockedDraw();
     return NS_OK;
   }
 
   if (aType == imgINotificationObserver::LOAD_COMPLETE) {
     // We should definitely have a request here
     MOZ_ASSERT(aRequest, "no request?");
 
-    NS_PRECONDITION(aRequest == mCurrentRequest || aRequest == mPendingRequest,
+    MOZ_ASSERT(aRequest == mCurrentRequest || aRequest == mPendingRequest,
                     "Unknown request");
   }
 
   {
     // Calling Notify on observers can modify the list of observers so make
     // a local copy.
     AutoTArray<nsCOMPtr<imgINotificationObserver>, 2> observers;
     for (ImageObserver* observer = &mObserverList, *next; observer;
@@ -337,17 +337,17 @@ nsImageLoadingContent::SetLoadingEnabled
   if (nsContentUtils::GetImgLoaderForChannel(nullptr, nullptr)) {
     mLoadingEnabled = aLoadingEnabled;
   }
 }
 
 NS_IMETHODIMP
 nsImageLoadingContent::GetImageBlockingStatus(int16_t* aStatus)
 {
-  NS_PRECONDITION(aStatus, "Null out param");
+  MOZ_ASSERT(aStatus, "Null out param");
   *aStatus = ImageBlockingStatus();
   return NS_OK;
 }
 
 static void
 ReplayImageStatus(imgIRequest* aRequest, imgINotificationObserver* aObserver)
 {
   if (!aRequest) {
@@ -714,17 +714,17 @@ nsImageLoadingContent::GetRequestType(im
   aError.Throw(NS_ERROR_UNEXPECTED);
   return UNKNOWN_REQUEST;
 }
 
 NS_IMETHODIMP
 nsImageLoadingContent::GetRequestType(imgIRequest* aRequest,
                                       int32_t* aRequestType)
 {
-  NS_PRECONDITION(aRequestType, "Null out param");
+  MOZ_ASSERT(aRequestType, "Null out param");
 
   ErrorResult result;
   *aRequestType = GetRequestType(aRequest, result);
   return result.StealNSResult();
 }
 
 already_AddRefed<nsIURI>
 nsImageLoadingContent::GetCurrentURI(ErrorResult& aError)
@@ -1234,18 +1234,18 @@ nsPresContext* nsImageLoadingContent::Ge
   return frame->PresContext();
 }
 
 nsresult
 nsImageLoadingContent::StringToURI(const nsAString& aSpec,
                                    nsIDocument* aDocument,
                                    nsIURI** aURI)
 {
-  NS_PRECONDITION(aDocument, "Must have a document");
-  NS_PRECONDITION(aURI, "Null out param");
+  MOZ_ASSERT(aDocument, "Must have a document");
+  MOZ_ASSERT(aURI, "Null out param");
 
   // (1) Get the base URI
   nsIContent* thisContent = AsContent();
   nsCOMPtr<nsIURI> baseURL = thisContent->GetBaseURI();
 
   // (2) Get the charset
   auto encoding = aDocument->GetDocumentCharacterSet();
 
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -809,17 +809,17 @@ nsJSContext::ConvertSupportsTojsvals(nsI
   }
   return rv;
 }
 
 // This really should go into xpconnect somewhere...
 nsresult
 nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
 {
-  NS_PRECONDITION(aArg, "Empty arg");
+  MOZ_ASSERT(aArg, "Empty arg");
 
   nsCOMPtr<nsISupportsPrimitive> argPrimitive(do_QueryInterface(aArg));
   if (!argPrimitive)
     return NS_ERROR_NO_INTERFACE;
 
   AutoJSContext cx;
   uint16_t type;
   argPrimitive->GetType(&type);
--- a/dom/base/nsMappedAttributes.cpp
+++ b/dom/base/nsMappedAttributes.cpp
@@ -147,17 +147,17 @@ nsMappedAttributes::LastRelease()
   delete this;
 }
 
 
 void
 nsMappedAttributes::SetAndSwapAttr(nsAtom* aAttrName, nsAttrValue& aValue,
                                    bool* aValueWasSet)
 {
-  NS_PRECONDITION(aAttrName, "null name");
+  MOZ_ASSERT(aAttrName, "null name");
   *aValueWasSet = false;
   uint32_t i;
   for (i = 0; i < mAttrCount && !Attrs()[i].mName.IsSmaller(aAttrName); ++i) {
     if (Attrs()[i].mName.Equals(aAttrName)) {
       Attrs()[i].mValue.SwapValueWith(aValue);
       *aValueWasSet = true;
       return;
     }
@@ -173,17 +173,17 @@ nsMappedAttributes::SetAndSwapAttr(nsAto
   new (&Attrs()[i].mValue) nsAttrValue();
   Attrs()[i].mValue.SwapValueWith(aValue);
   ++mAttrCount;
 }
 
 const nsAttrValue*
 nsMappedAttributes::GetAttr(nsAtom* aAttrName) const
 {
-  NS_PRECONDITION(aAttrName, "null name");
+  MOZ_ASSERT(aAttrName, "null name");
 
   for (uint32_t i = 0; i < mAttrCount; ++i) {
     if (Attrs()[i].mName.Equals(aAttrName)) {
       return &Attrs()[i].mValue;
     }
   }
 
   return nullptr;
--- a/dom/base/nsNameSpaceManager.cpp
+++ b/dom/base/nsNameSpaceManager.cpp
@@ -121,17 +121,17 @@ nsNameSpaceManager::RegisterNameSpace(al
   MOZ_ASSERT(aNameSpaceID >= -1, "Bogus namespace ID");
 
   return rv;
 }
 
 nsresult
 nsNameSpaceManager::GetNameSpaceURI(int32_t aNameSpaceID, nsAString& aURI)
 {
-  NS_PRECONDITION(aNameSpaceID >= 0, "Bogus namespace ID");
+  MOZ_ASSERT(aNameSpaceID >= 0, "Bogus namespace ID");
 
   // We have historically treated GetNameSpaceURI calls for kNameSpaceID_None
   // as erroneous.
   if (aNameSpaceID <= 0 || aNameSpaceID >= int32_t(mURIArray.Length())) {
     aURI.Truncate();
 
     return NS_ERROR_ILLEGAL_VALUE;
   }
--- a/dom/base/nsNodeInfoManager.cpp
+++ b/dom/base/nsNodeInfoManager.cpp
@@ -102,17 +102,17 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_B
   if (tmp->mDocument) {
     return NS_CYCLE_COLLECTION_PARTICIPANT(nsDocument)->CanSkipThis(tmp->mDocument);
   }
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
 
 nsresult
 nsNodeInfoManager::Init(nsIDocument *aDocument)
 {
-  NS_PRECONDITION(!mPrincipal,
+  MOZ_ASSERT(!mPrincipal,
                   "Being inited when we already have a principal?");
 
   mPrincipal = NullPrincipal::CreateWithoutOriginAttributes();
 
   if (aDocument) {
     mBindingManager = new nsBindingManager(aDocument);
   }
 
@@ -314,17 +314,17 @@ nsNodeInfoManager::SetDocumentPrincipal(
                         "Documents shouldn't have an expanded principal");
 
   mPrincipal = aPrincipal;
 }
 
 void
 nsNodeInfoManager::RemoveNodeInfo(NodeInfo *aNodeInfo)
 {
-  NS_PRECONDITION(aNodeInfo, "Trying to remove null nodeinfo from manager!");
+  MOZ_ASSERT(aNodeInfo, "Trying to remove null nodeinfo from manager!");
 
   if (aNodeInfo == mDocumentNodeInfo) {
     mDocumentNodeInfo = nullptr;
     mDocument = nullptr;
   } else {
     if (--mNonDocumentNodeInfos == 0) {
       if (mDocument) {
         // Note, whoever calls this method should keep NodeInfoManager alive,
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -205,29 +205,29 @@ nsNodeUtils::NativeAnonymousChildListCha
                             (aContent, aIsRemove),
                             isRemove);
 }
 
 void
 nsNodeUtils::ContentInserted(nsINode* aContainer,
                              nsIContent* aChild)
 {
-  NS_PRECONDITION(aContainer->IsContent() || aContainer->IsDocument(),
+  MOZ_ASSERT(aContainer->IsContent() || aContainer->IsDocument(),
                   "container must be an nsIContent or an nsIDocument");
   nsIDocument* doc = aContainer->OwnerDoc();
   IMPL_MUTATION_NOTIFICATION(ContentInserted, aContainer, (aChild),
                              IsRemoveNotification::No);
 }
 
 void
 nsNodeUtils::ContentRemoved(nsINode* aContainer,
                             nsIContent* aChild,
                             nsIContent* aPreviousSibling)
 {
-  NS_PRECONDITION(aContainer->IsContent() || aContainer->IsDocument(),
+  MOZ_ASSERT(aContainer->IsContent() || aContainer->IsDocument(),
                   "container must be an nsIContent or an nsIDocument");
   nsIDocument* doc = aContainer->OwnerDoc();
   MOZ_ASSERT(aChild->GetParentNode() == aContainer,
              "We expect the parent link to be still around at this point");
   IMPL_MUTATION_NOTIFICATION(ContentRemoved, aContainer,
                              (aChild, aPreviousSibling),
                              IsRemoveNotification::Yes);
 }
@@ -378,20 +378,20 @@ nsNodeUtils::CloneNodeImpl(nsINode *aNod
 /* static */
 already_AddRefed<nsINode>
 nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
                            nsNodeInfoManager *aNewNodeInfoManager,
                            JS::Handle<JSObject*> aReparentScope,
                            nsCOMArray<nsINode> *aNodesWithProperties,
                            nsINode* aParent, ErrorResult& aError)
 {
-  NS_PRECONDITION((!aClone && aNewNodeInfoManager) || !aReparentScope,
+  MOZ_ASSERT((!aClone && aNewNodeInfoManager) || !aReparentScope,
                   "If cloning or not getting a new nodeinfo we shouldn't "
                   "rewrap");
-  NS_PRECONDITION(!aParent || aNode->IsContent(),
+  MOZ_ASSERT(!aParent || aNode->IsContent(),
                   "Can't insert document or attribute nodes into a parent");
 
   // First deal with aNode and walk its attributes (and their children). Then,
   // if aDeep is true, deal with aNode's children (and recurse into their
   // attributes and children).
 
   nsAutoScriptBlocker scriptBlocker;
 
--- a/dom/base/nsPropertyTable.cpp
+++ b/dom/base/nsPropertyTable.cpp
@@ -135,17 +135,17 @@ nsPropertyTable::EnumerateAll(NSProperty
 }
 
 void*
 nsPropertyTable::GetPropertyInternal(nsPropertyOwner aObject,
                                      nsAtom* aPropertyName,
                                      bool aRemove,
                                      nsresult* aResult)
 {
-  NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
+  MOZ_ASSERT(aPropertyName && aObject, "unexpected null param");
   nsresult rv = NS_PROPTABLE_PROP_NOT_THERE;
   void *propValue = nullptr;
 
   PropertyList* propertyList = GetPropertyListFor(aPropertyName);
   if (propertyList) {
     auto entry = static_cast<PropertyListMapEntry*>
                             (propertyList->mObjectValueMap.Search(aObject));
     if (entry) {
@@ -167,17 +167,17 @@ nsPropertyTable::GetPropertyInternal(nsP
 nsresult
 nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject,
                                      nsAtom* aPropertyName,
                                      void* aPropertyValue,
                                      NSPropertyDtorFunc aPropDtorFunc,
                                      void* aPropDtorData,
                                      bool aTransfer)
 {
-  NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
+  MOZ_ASSERT(aPropertyName && aObject, "unexpected null param");
 
   PropertyList* propertyList = GetPropertyListFor(aPropertyName);
 
   if (propertyList) {
     // Make sure the dtor function and data and the transfer flag match
     if (aPropDtorFunc != propertyList->mDtorFunc ||
         aPropDtorData != propertyList->mDtorData ||
         aTransfer != propertyList->mTransfer) {
@@ -213,17 +213,17 @@ nsPropertyTable::SetPropertyInternal(nsP
 
   return result;
 }
 
 nsresult
 nsPropertyTable::DeleteProperty(nsPropertyOwner aObject,
                                 nsAtom* aPropertyName)
 {
-  NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
+  MOZ_ASSERT(aPropertyName && aObject, "unexpected null param");
 
   PropertyList* propertyList = GetPropertyListFor(aPropertyName);
   if (propertyList) {
     if (propertyList->DeletePropertyFor(aObject))
       return NS_OK;
   }
 
   return NS_PROPTABLE_PROP_NOT_THERE;
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -55,17 +55,17 @@ nsRange::GetDocGroup() const
 }
 
 /******************************************************
  * stack based utilty class for managing monitor
  ******************************************************/
 
 static void InvalidateAllFrames(nsINode* aNode)
 {
-  NS_PRECONDITION(aNode, "bad arg");
+  MOZ_ASSERT(aNode, "bad arg");
 
   nsIFrame* frame = nullptr;
   switch (aNode->NodeType()) {
     case nsINode::TEXT_NODE:
     case nsINode::ELEMENT_NODE:
     {
       nsIContent* content = static_cast<nsIContent*>(aNode);
       frame = content->GetPrimaryFrame();
@@ -194,17 +194,17 @@ struct IsItemInRangeComparator
     return -1;
   }
 };
 
 /* static */ bool
 nsRange::IsNodeSelected(nsINode* aNode, uint32_t aStartOffset,
                         uint32_t aEndOffset)
 {
-  NS_PRECONDITION(aNode, "bad arg");
+  MOZ_ASSERT(aNode, "bad arg");
 
   nsINode* n = GetNextRangeCommonAncestor(aNode);
   NS_ASSERTION(n || !aNode->IsSelectionDescendant(),
                "orphan selection descendant");
 
   // Collect the selection objects for potential ranges.
   nsTHashtable<nsPtrHashKey<Selection>> ancestorSelections;
   Selection* prevSelection = nullptr;
@@ -456,17 +456,17 @@ static void UnmarkDescendants(nsINode* a
       }
     }
   }
 }
 
 void
 nsRange::RegisterCommonAncestor(nsINode* aNode)
 {
-  NS_PRECONDITION(aNode, "bad arg");
+  MOZ_ASSERT(aNode, "bad arg");
 
   MOZ_DIAGNOSTIC_ASSERT(IsInSelection(), "registering range not in selection");
 
   mRegisteredCommonAncestor = aNode;
 
   MarkDescendants(aNode);
 
   UniquePtr<LinkedList<nsRange>>& ranges = aNode->GetCommonAncestorRangesPtr();
@@ -477,17 +477,17 @@ nsRange::RegisterCommonAncestor(nsINode*
   MOZ_DIAGNOSTIC_ASSERT(!isInList());
   ranges->insertBack(this);
   aNode->SetCommonAncestorForRangeInSelection();
 }
 
 void
 nsRange::UnregisterCommonAncestor(nsINode* aNode, bool aIsUnlinking)
 {
-  NS_PRECONDITION(aNode, "bad arg");
+  MOZ_ASSERT(aNode, "bad arg");
   NS_ASSERTION(aNode->IsCommonAncestorForRangeInSelection(), "wrong node");
   MOZ_DIAGNOSTIC_ASSERT(aNode == mRegisteredCommonAncestor, "wrong node");
   LinkedList<nsRange>* ranges = aNode->GetExistingCommonAncestorRanges();
   MOZ_ASSERT(ranges);
 
   mRegisteredCommonAncestor = nullptr;
 
 #ifdef DEBUG
@@ -959,26 +959,26 @@ nsRange::NotifySelectionListenersAfterRa
 // for content notification of range ownership.
 // Calling DoSetRange with either parent argument null will collapse
 // the range to have both endpoints point to the other node
 void
 nsRange::DoSetRange(const RawRangeBoundary& aStart,
                     const RawRangeBoundary& aEnd,
                     nsINode* aRoot, bool aNotInsertedYet)
 {
-  NS_PRECONDITION((aStart.IsSet() && aEnd.IsSet() && aRoot) ||
+  MOZ_ASSERT((aStart.IsSet() && aEnd.IsSet() && aRoot) ||
                   (!aStart.IsSet() && !aEnd.IsSet() && !aRoot),
                   "Set all or none");
-  NS_PRECONDITION(!aRoot || aNotInsertedYet ||
+  MOZ_ASSERT(!aRoot || aNotInsertedYet ||
                   (nsContentUtils::ContentIsDescendantOf(aStart.Container(), aRoot) &&
                    nsContentUtils::ContentIsDescendantOf(aEnd.Container(), aRoot) &&
                    aRoot == IsValidBoundary(aStart.Container()) &&
                    aRoot == IsValidBoundary(aEnd.Container())),
                   "Wrong root");
-  NS_PRECONDITION(!aRoot ||
+  MOZ_ASSERT(!aRoot ||
                   (aStart.Container()->IsContent() &&
                    aEnd.Container()->IsContent() &&
                    aRoot ==
                     static_cast<nsIContent*>(aStart.Container())->GetBindingParent() &&
                    aRoot ==
                     static_cast<nsIContent*>(aEnd.Container())->GetBindingParent()) ||
                   (!aRoot->GetParentNode() &&
                    (aRoot->IsDocument() ||
--- a/dom/base/nsSyncLoadService.cpp
+++ b/dom/base/nsSyncLoadService.cpp
@@ -284,17 +284,17 @@ nsSyncLoader::OnStopRequest(nsIRequest *
 }
 
 NS_IMETHODIMP
 nsSyncLoader::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
                                      nsIChannel *aNewChannel,
                                      uint32_t aFlags,
                                      nsIAsyncVerifyRedirectCallback *callback)
 {
-    NS_PRECONDITION(aNewChannel, "Redirecting to null channel?");
+    MOZ_ASSERT(aNewChannel, "Redirecting to null channel?");
 
     mChannel = aNewChannel;
 
     callback->OnRedirectVerifyCallback(NS_OK);
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/dom/base/nsTextNode.cpp
+++ b/dom/base/nsTextNode.cpp
@@ -210,19 +210,19 @@ nsTextNode::DumpContent(FILE* out, int32
 }
 #endif
 
 nsresult
 NS_NewAttributeContent(nsNodeInfoManager *aNodeInfoManager,
                        int32_t aNameSpaceID, nsAtom* aAttrName,
                        nsIContent** aResult)
 {
-  NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager");
-  NS_PRECONDITION(aAttrName, "Must have an attr name");
-  NS_PRECONDITION(aNameSpaceID != kNameSpaceID_Unknown, "Must know namespace");
+  MOZ_ASSERT(aNodeInfoManager, "Missing nodeInfoManager");
+  MOZ_ASSERT(aAttrName, "Must have an attr name");
+  MOZ_ASSERT(aNameSpaceID != kNameSpaceID_Unknown, "Must know namespace");
 
   *aResult = nullptr;
 
   already_AddRefed<mozilla::dom::NodeInfo> ni = aNodeInfoManager->GetTextNodeInfo();
 
   nsAttributeTextNode* textNode = new nsAttributeTextNode(ni,
                                                           aNameSpaceID,
                                                           aAttrName);
@@ -234,17 +234,17 @@ NS_NewAttributeContent(nsNodeInfoManager
 NS_IMPL_ISUPPORTS_INHERITED(nsAttributeTextNode, nsTextNode,
                             nsIMutationObserver)
 
 nsresult
 nsAttributeTextNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                                 nsIContent* aBindingParent,
                                 bool aCompileEventHandlers)
 {
-  NS_PRECONDITION(aParent && aParent->GetParent(),
+  MOZ_ASSERT(aParent && aParent->GetParent(),
                   "This node can't be a child of the document or of the document root");
 
   nsresult rv = nsTextNode::BindToTree(aDocument, aParent,
                                        aBindingParent, aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(!mGrandparent, "We were already bound!");
   mGrandparent = aParent->GetParent()->AsElement();
--- a/dom/base/nsTreeSanitizer.cpp
+++ b/dom/base/nsTreeSanitizer.cpp
@@ -1352,32 +1352,32 @@ nsTreeSanitizer::SanitizeURL(mozilla::do
 }
 
 void
 nsTreeSanitizer::Sanitize(DocumentFragment* aFragment)
 {
   // If you want to relax these preconditions, be sure to check the code in
   // here that notifies / does not notify or that fires mutation events if
   // in tree.
-  NS_PRECONDITION(!aFragment->IsInUncomposedDoc(), "The fragment is in doc?");
+  MOZ_ASSERT(!aFragment->IsInUncomposedDoc(), "The fragment is in doc?");
 
   mFullDocument = false;
   SanitizeChildren(aFragment);
 }
 
 void
 nsTreeSanitizer::Sanitize(nsIDocument* aDocument)
 {
   // If you want to relax these preconditions, be sure to check the code in
   // here that notifies / does not notify or that fires mutation events if
   // in tree.
 #ifdef DEBUG
-  NS_PRECONDITION(!aDocument->GetContainer(), "The document is in a shell.");
+  MOZ_ASSERT(!aDocument->GetContainer(), "The document is in a shell.");
   RefPtr<mozilla::dom::Element> root = aDocument->GetRootElement();
-  NS_PRECONDITION(root->IsHTMLElement(nsGkAtoms::html), "Not HTML root.");
+  MOZ_ASSERT(root->IsHTMLElement(nsGkAtoms::html), "Not HTML root.");
 #endif
 
   mFullDocument = true;
   SanitizeChildren(aDocument);
 }
 
 void
 nsTreeSanitizer::SanitizeChildren(nsINode* aRoot)
@@ -1537,17 +1537,17 @@ nsTreeSanitizer::LogMessage(const char* 
     nsContentUtils::ReportToConsoleNonLocalized(
         msg, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("DOM"), aDoc);
   }
 }
 
 void
 nsTreeSanitizer::InitializeStatics()
 {
-  NS_PRECONDITION(!sElementsHTML, "Initializing a second time.");
+  MOZ_ASSERT(!sElementsHTML, "Initializing a second time.");
 
   sElementsHTML = new AtomsTable(ArrayLength(kElementsHTML));
   for (uint32_t i = 0; kElementsHTML[i]; i++) {
     sElementsHTML->PutEntry(kElementsHTML[i]);
   }
 
   sAttributesHTML = new AtomsTable(ArrayLength(kAttributesHTML));
   for (uint32_t i = 0; kAttributesHTML[i]; i++) {
--- a/dom/canvas/CanvasUtils.cpp
+++ b/dom/canvas/CanvasUtils.cpp
@@ -252,17 +252,17 @@ DoDrawImageSecurityCheck(dom::HTMLCanvas
         aCanvasElement->SetWriteOnly();
         return;
     }
 
     // No need to do a security check if the image used CORS for the load
     if (CORSUsed)
         return;
 
-    NS_PRECONDITION(aPrincipal, "Must have a principal here");
+    MOZ_ASSERT(aPrincipal, "Must have a principal here");
 
     if (aCanvasElement->NodePrincipal()->Subsumes(aPrincipal)) {
         // This canvas has access to that image anyway
         return;
     }
 
     aCanvasElement->SetWriteOnly();
 }
--- a/dom/commandhandler/nsControllerCommandTable.cpp
+++ b/dom/commandhandler/nsControllerCommandTable.cpp
@@ -192,17 +192,17 @@ nsControllerCommandTable::GetSupportedCo
     commands++;
   }
   return NS_OK;
 }
 
 nsresult
 NS_NewControllerCommandTable(nsIControllerCommandTable** aResult)
 {
-  NS_PRECONDITION(aResult != nullptr, "null ptr");
+  MOZ_ASSERT(aResult != nullptr, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   nsControllerCommandTable* newCommandTable = new nsControllerCommandTable();
   NS_ADDREF(newCommandTable);
   *aResult = newCommandTable;
   return NS_OK;
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -498,17 +498,17 @@ ContentEventHandler::IsPlugin(nsIContent
   return aContent &&
          aContent->GetDesiredIMEState().mEnabled == IMEState::PLUGIN;
 }
 
 nsresult
 ContentEventHandler::QueryContentRect(nsIContent* aContent,
                                       WidgetQueryContentEvent* aEvent)
 {
-  NS_PRECONDITION(aContent, "aContent must not be null");
+  MOZ_ASSERT(aContent, "aContent must not be null");
 
   nsIFrame* frame = aContent->GetPrimaryFrame();
   NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
 
   // get rect for first frame
   nsRect resultRect(nsPoint(0, 0), frame->GetRect().Size());
   nsresult rv = ConvertToRootRelativeOffset(frame, resultRect);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -2694,17 +2694,17 @@ ContentEventHandler::OnQueryCharacterAtP
   nsIFrame* rootFrame = shell->GetRootFrame();
   NS_ENSURE_TRUE(rootFrame, NS_ERROR_FAILURE);
   nsIWidget* rootWidget = rootFrame->GetNearestWidget();
   NS_ENSURE_TRUE(rootWidget, NS_ERROR_FAILURE);
 
   // The root frame's widget might be different, e.g., the event was fired on
   // a popup but the rootFrame is the document root.
   if (rootWidget != aEvent->mWidget) {
-    NS_PRECONDITION(aEvent->mWidget, "The event must have the widget");
+    MOZ_ASSERT(aEvent->mWidget, "The event must have the widget");
     nsView* view = nsView::GetViewFor(aEvent->mWidget);
     NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
     rootFrame = view->GetFrame();
     NS_ENSURE_TRUE(rootFrame, NS_ERROR_FAILURE);
     rootWidget = rootFrame->GetNearestWidget();
     NS_ENSURE_TRUE(rootWidget, NS_ERROR_FAILURE);
   }
 
--- a/dom/events/EventListenerService.cpp
+++ b/dom/events/EventListenerService.cpp
@@ -298,17 +298,17 @@ ToEventListener(JSContext* aCx, JS::Hand
 
 NS_IMETHODIMP
 EventListenerService::AddSystemEventListener(EventTarget *aTarget,
                                              const nsAString& aType,
                                              JS::Handle<JS::Value> aListener,
                                              bool aUseCapture,
                                              JSContext* aCx)
 {
-  NS_PRECONDITION(aTarget, "Missing target");
+  MOZ_ASSERT(aTarget, "Missing target");
 
   NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED);
 
   RefPtr<EventListener> listener = ToEventListener(aCx, aListener);
   if (!listener) {
     return NS_ERROR_UNEXPECTED;
   }
 
@@ -324,17 +324,17 @@ EventListenerService::AddSystemEventList
 
 NS_IMETHODIMP
 EventListenerService::RemoveSystemEventListener(EventTarget *aTarget,
                                                 const nsAString& aType,
                                                 JS::Handle<JS::Value> aListener,
                                                 bool aUseCapture,
                                                 JSContext* aCx)
 {
-  NS_PRECONDITION(aTarget, "Missing target");
+  MOZ_ASSERT(aTarget, "Missing target");
 
   NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED);
 
   RefPtr<EventListener> listener = ToEventListener(aCx, aListener);
   if (!listener) {
     return NS_ERROR_UNEXPECTED;
   }
 
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -5267,17 +5267,17 @@ EventStateManager::UpdateAncestorState(n
   }
 }
 
 bool
 EventStateManager::SetContentState(nsIContent* aContent, EventStates aState)
 {
   // We manage 4 states here: ACTIVE, HOVER, DRAGOVER, URLTARGET
   // The input must be exactly one of them.
-  NS_PRECONDITION(aState == NS_EVENT_STATE_ACTIVE ||
+  MOZ_ASSERT(aState == NS_EVENT_STATE_ACTIVE ||
                   aState == NS_EVENT_STATE_HOVER ||
                   aState == NS_EVENT_STATE_DRAGOVER ||
                   aState == NS_EVENT_STATE_URLTARGET,
                   "Unexpected state");
 
   nsCOMPtr<nsIContent> notifyContent1;
   nsCOMPtr<nsIContent> notifyContent2;
   bool updateAncestors;
@@ -5511,17 +5511,17 @@ EventStateManager::EnsureDocument(nsPres
 {
   if (!mDocument)
     mDocument = aPresContext->Document();
 }
 
 void
 EventStateManager::FlushPendingEvents(nsPresContext* aPresContext)
 {
-  NS_PRECONDITION(nullptr != aPresContext, "nullptr ptr");
+  MOZ_ASSERT(nullptr != aPresContext, "nullptr ptr");
   nsIPresShell *shell = aPresContext->GetPresShell();
   if (shell) {
     shell->FlushPendingNotifications(FlushType::InterruptibleLayout);
   }
 }
 
 nsIContent*
 EventStateManager::GetFocusedContent()
--- a/dom/events/WheelHandlingHelper.cpp
+++ b/dom/events/WheelHandlingHelper.cpp
@@ -305,17 +305,17 @@ WheelTransaction::OnEvent(WidgetEvent* a
 WheelTransaction::Shutdown()
 {
   NS_IF_RELEASE(sTimer);
 }
 
 /* static */ void
 WheelTransaction::OnFailToScrollTarget()
 {
-  NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction");
+  MOZ_ASSERT(sTargetFrame, "We don't have mouse scrolling transaction");
 
   if (Prefs::sTestMouseScroll) {
     // This event is used for automated tests, see bug 442774.
     nsContentUtils::DispatchTrustedEvent(
                       sTargetFrame->GetContent()->OwnerDoc(),
                       sTargetFrame->GetContent(),
                       NS_LITERAL_STRING("MozMouseScrollFailed"),
                       true, true);
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -1757,27 +1757,27 @@ HTMLFormElement::GetActionURL(nsIURI** a
   actionURL.forget(aActionURL);
 
   return rv;
 }
 
 NS_IMETHODIMP_(nsIFormControl*)
 HTMLFormElement::GetDefaultSubmitElement() const
 {
-  NS_PRECONDITION(mDefaultSubmitElement == mFirstSubmitInElements ||
+  MOZ_ASSERT(mDefaultSubmitElement == mFirstSubmitInElements ||
                   mDefaultSubmitElement == mFirstSubmitNotInElements,
                   "What happened here?");
 
   return mDefaultSubmitElement;
 }
 
 bool
 HTMLFormElement::IsDefaultSubmitElement(const nsIFormControl* aControl) const
 {
-  NS_PRECONDITION(aControl, "Unexpected call");
+  MOZ_ASSERT(aControl, "Unexpected call");
 
   if (aControl == mDefaultSubmitElement) {
     // Yes, it is
     return true;
   }
 
   if (mDefaultSubmitElement ||
       (aControl != mFirstSubmitInElements &&
@@ -1816,17 +1816,17 @@ HTMLFormElement::ImplicitSubmissionIsDis
     }
   }
   return numDisablingControlsFound != 1;
 }
 
 bool
 HTMLFormElement::IsLastActiveElement(const nsIFormControl* aControl) const
 {
-  NS_PRECONDITION(aControl, "Unexpected call");
+  MOZ_ASSERT(aControl, "Unexpected call");
 
   for (auto* element : Reversed(mControls->mElements)) {
     if (element->IsSingleLineTextOrNumberControl(false) &&
         !element->IsDisabled()) {
       return element == aControl;
     }
   }
   return false;
--- a/dom/html/HTMLFrameSetElement.cpp
+++ b/dom/html/HTMLFrameSetElement.cpp
@@ -69,18 +69,18 @@ HTMLFrameSetElement::BeforeSetAttr(int32
 
   return nsGenericHTMLElement::BeforeSetAttr(aNamespaceID, aName, aValue, aNotify);
 }
 
 nsresult
 HTMLFrameSetElement::GetRowSpec(int32_t *aNumValues,
                                 const nsFramesetSpec** aSpecs)
 {
-  NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!");
-  NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
+  MOZ_ASSERT(aNumValues, "Must have a pointer to an integer here!");
+  MOZ_ASSERT(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
   *aNumValues = 0;
   *aSpecs = nullptr;
 
   if (!mRowSpecs) {
     const nsAttrValue* value = GetParsedAttr(nsGkAtoms::rows);
     if (value && value->Type() == nsAttrValue::eString) {
       nsresult rv = ParseRowCol(value->GetStringValue(), mNumRows,
                                 &mRowSpecs);
@@ -99,18 +99,18 @@ HTMLFrameSetElement::GetRowSpec(int32_t 
   *aNumValues = mNumRows;
   return NS_OK;
 }
 
 nsresult
 HTMLFrameSetElement::GetColSpec(int32_t *aNumValues,
                                 const nsFramesetSpec** aSpecs)
 {
-  NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!");
-  NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
+  MOZ_ASSERT(aNumValues, "Must have a pointer to an integer here!");
+  MOZ_ASSERT(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
   *aNumValues = 0;
   *aSpecs = nullptr;
 
   if (!mColSpecs) {
     const nsAttrValue* value = GetParsedAttr(nsGkAtoms::cols);
     if (value && value->Type() == nsAttrValue::eString) {
       nsresult rv = ParseRowCol(value->GetStringValue(), mNumCols,
                                 &mColSpecs);
--- a/dom/html/HTMLImageElement.cpp
+++ b/dom/html/HTMLImageElement.cpp
@@ -860,17 +860,17 @@ HTMLImageElement::GetForm() const
 {
   return mForm;
 }
 #endif
 
 void
 HTMLImageElement::SetForm(HTMLFormElement* aForm)
 {
-  NS_PRECONDITION(aForm, "Don't pass null here");
+  MOZ_ASSERT(aForm, "Don't pass null here");
   NS_ASSERTION(!mForm,
                "We don't support switching from one non-null form to another.");
 
   mForm = aForm;
 }
 
 void
 HTMLImageElement::ClearForm(bool aRemoveFromForm)
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -871,22 +871,22 @@ HTMLInputElement::DestroyUploadLastDir()
   NS_IF_RELEASE(gUploadLastDir);
 }
 
 nsresult
 UploadLastDir::FetchDirectoryAndDisplayPicker(nsIDocument* aDoc,
                                               nsIFilePicker* aFilePicker,
                                               nsIFilePickerShownCallback* aFpCallback)
 {
-  NS_PRECONDITION(aDoc, "aDoc is null");
-  NS_PRECONDITION(aFilePicker, "aFilePicker is null");
-  NS_PRECONDITION(aFpCallback, "aFpCallback is null");
+  MOZ_ASSERT(aDoc, "aDoc is null");
+  MOZ_ASSERT(aFilePicker, "aFilePicker is null");
+  MOZ_ASSERT(aFpCallback, "aFpCallback is null");
 
   nsIURI* docURI = aDoc->GetDocumentURI();
-  NS_PRECONDITION(docURI, "docURI is null");
+  MOZ_ASSERT(docURI, "docURI is null");
 
   nsCOMPtr<nsILoadContext> loadContext = aDoc->GetLoadContext();
   nsCOMPtr<nsIContentPrefCallback2> prefCallback =
     new UploadLastDir::ContentPrefCallback(aFilePicker, aFpCallback);
 
   // Attempt to get the CPS, if it's not present we'll fallback to use the Desktop folder
   nsCOMPtr<nsIContentPrefService2> contentPrefService =
     do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
@@ -901,23 +901,23 @@ UploadLastDir::FetchDirectoryAndDisplayP
 
   contentPrefService->GetByDomainAndName(spec, CPS_PREF_NAME, loadContext, prefCallback);
   return NS_OK;
 }
 
 nsresult
 UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir)
 {
-  NS_PRECONDITION(aDoc, "aDoc is null");
+  MOZ_ASSERT(aDoc, "aDoc is null");
   if (!aDir) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIURI> docURI = aDoc->GetDocumentURI();
-  NS_PRECONDITION(docURI, "docURI is null");
+  MOZ_ASSERT(docURI, "docURI is null");
 
   // Attempt to get the CPS, if it's not present we'll just return
   nsCOMPtr<nsIContentPrefService2> contentPrefService =
     do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
   if (!contentPrefService)
     return NS_ERROR_NOT_AVAILABLE;
 
   nsAutoCString cstrSpec;
@@ -2789,17 +2789,17 @@ HTMLInputElement::UpdateFileList()
   }
 }
 
 nsresult
 HTMLInputElement::SetValueInternal(const nsAString& aValue,
                                    const nsAString* aOldValue,
                                    uint32_t aFlags)
 {
-  NS_PRECONDITION(GetValueMode() != VALUE_MODE_FILENAME,
+  MOZ_ASSERT(GetValueMode() != VALUE_MODE_FILENAME,
                   "Don't call SetValueInternal for file inputs");
 
   // We want to remember if the SetValueInternal() call is being made for a XUL
   // element.  We do that by looking at the parent node here, and if that node
   // is a XUL node, we consider our control a XUL control.
   nsIContent* parent = GetParent();
   if (parent && parent->IsXULElement()) {
     aFlags |= nsTextEditorState::eSetValue_ForXUL;
--- a/dom/html/HTMLSharedElement.cpp
+++ b/dom/html/HTMLSharedElement.cpp
@@ -115,17 +115,17 @@ HTMLSharedElement::IsAttributeMapped(con
   }
 
   return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
 }
 
 static void
 SetBaseURIUsingFirstBaseWithHref(nsIDocument* aDocument, nsIContent* aMustMatch)
 {
-  NS_PRECONDITION(aDocument, "Need a document!");
+  MOZ_ASSERT(aDocument, "Need a document!");
 
   for (nsIContent* child = aDocument->GetFirstChild(); child;
        child = child->GetNextNode()) {
     if (child->IsHTMLElement(nsGkAtoms::base) &&
         child->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
       if (aMustMatch && child != aMustMatch) {
         return;
       }
@@ -168,17 +168,17 @@ SetBaseURIUsingFirstBaseWithHref(nsIDocu
 
   aDocument->SetBaseURI(nullptr);
 }
 
 static void
 SetBaseTargetUsingFirstBaseWithTarget(nsIDocument* aDocument,
                                       nsIContent* aMustMatch)
 {
-  NS_PRECONDITION(aDocument, "Need a document!");
+  MOZ_ASSERT(aDocument, "Need a document!");
 
   for (nsIContent* child = aDocument->GetFirstChild(); child;
        child = child->GetNextNode()) {
     if (child->IsHTMLElement(nsGkAtoms::base) &&
         child->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
       if (aMustMatch && child != aMustMatch) {
         return;
       }
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -539,17 +539,17 @@ nsGenericHTMLElement::FindAncestorForm(H
 
   return nullptr;
 }
 
 bool
 nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(
                         EventChainVisitor& aVisitor)
 {
-  NS_PRECONDITION(nsCOMPtr<Link>(do_QueryObject(this)),
+  MOZ_ASSERT(nsCOMPtr<Link>(do_QueryObject(this)),
                   "should be called only when |this| implements |Link|");
 
   if (!aVisitor.mPresContext) {
     // We need a pres context to do link stuff. Some events (e.g. mutation
     // events) don't have one.
     // XXX: ideally, shouldn't we be able to do what we need without one?
     return false;
   }
@@ -584,17 +584,17 @@ nsGenericHTMLElement::PostHandleEventFor
   }
 
   return PostHandleEventForLinks(aVisitor);
 }
 
 bool
 nsGenericHTMLElement::IsHTMLLink(nsIURI** aURI) const
 {
-  NS_PRECONDITION(aURI, "Must provide aURI out param");
+  MOZ_ASSERT(aURI, "Must provide aURI out param");
 
   *aURI = GetHrefURIForAnchors().take();
   // We promise out param is non-null if we return true, so base rv on it
   return *aURI != nullptr;
 }
 
 already_AddRefed<nsIURI>
 nsGenericHTMLElement::GetHrefURIForAnchors() const
@@ -1678,17 +1678,17 @@ nsGenericHTMLFormElement::SaveSubtreeSta
   SaveState();
 
   nsGenericHTMLElement::SaveSubtreeState();
 }
 
 void
 nsGenericHTMLFormElement::SetForm(HTMLFormElement* aForm)
 {
-  NS_PRECONDITION(aForm, "Don't pass null here");
+  MOZ_ASSERT(aForm, "Don't pass null here");
   NS_ASSERTION(!mForm,
                "We don't support switching from one non-null form to another.");
 
   SetForm(aForm, false);
 }
 
 void nsGenericHTMLFormElement::SetForm(HTMLFormElement* aForm, bool aBindToTree)
 {
@@ -2218,17 +2218,17 @@ nsGenericHTMLFormElement::IsElementDisab
 
   return IsDisabled();
 }
 
 void
 nsGenericHTMLFormElement::UpdateFormOwner(bool aBindToTree,
                                           Element* aFormIdElement)
 {
-  NS_PRECONDITION(!aBindToTree || !aFormIdElement,
+  MOZ_ASSERT(!aBindToTree || !aFormIdElement,
                   "aFormIdElement shouldn't be set if aBindToTree is true!");
 
   bool needStateUpdate = false;
   if (!aBindToTree) {
     needStateUpdate = mForm && mForm->IsDefaultSubmitElement(this);
     ClearForm(true, false);
   }
 
--- a/dom/html/nsGenericHTMLFrameElement.cpp
+++ b/dom/html/nsGenericHTMLFrameElement.cpp
@@ -79,17 +79,17 @@ nsGenericHTMLFrameElement::~nsGenericHTM
   if (mFrameLoader) {
     mFrameLoader->Destroy();
   }
 }
 
 nsresult
 nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
 {
-  NS_PRECONDITION(aContentDocument, "Null out param");
+  MOZ_ASSERT(aContentDocument, "Null out param");
   nsCOMPtr<nsIDOMDocument> document =
     do_QueryInterface(GetContentDocument(*nsContentUtils::SubjectPrincipal()));
   document.forget(aContentDocument);
   return NS_OK;
 }
 
 nsIDocument*
 nsGenericHTMLFrameElement::GetContentDocument(nsIPrincipal& aSubjectPrincipal)
--- a/dom/html/nsHTMLContentSink.cpp
+++ b/dom/html/nsHTMLContentSink.cpp
@@ -780,17 +780,17 @@ HTMLContentSink::DidBuildModel(bool aTer
   DropParserAndPerfHint();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLContentSink::SetParser(nsParserBase* aParser)
 {
-  NS_PRECONDITION(aParser, "Should have a parser here!");
+  MOZ_ASSERT(aParser, "Should have a parser here!");
   mParser = aParser;
   return NS_OK;
 }
 
 nsresult
 HTMLContentSink::CloseHTML()
 {
   if (mHeadContext) {
@@ -963,17 +963,17 @@ HTMLContentSink::NotifyInsert(nsIContent
   }
 
   mInNotification--;
 }
 
 void
 HTMLContentSink::NotifyRootInsertion()
 {
-  NS_PRECONDITION(!mNotifiedRootInsertion, "Double-notifying on root?");
+  MOZ_ASSERT(!mNotifiedRootInsertion, "Double-notifying on root?");
   NS_ASSERTION(!mLayoutStarted,
                "How did we start layout without notifying on root?");
   // Now make sure to notify that we have now inserted our root.  If
   // there has been no initial reflow yet it'll be a no-op, but if
   // there has been one we need this to get its frames constructed.
   // Note that if mNotifiedRootInsertion is true we don't notify here,
   // since that just means there are multiple <html> tags in the
   // document; in those cases we just want to put all the attrs on one
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -1410,17 +1410,17 @@ nsJSURI::Mutate(nsIURIMutator** aMutator
 }
 
 /* virtual */ nsresult
 nsJSURI::EqualsInternal(nsIURI* aOther,
                         mozilla::net::nsSimpleURI::RefHandlingEnum aRefHandlingMode,
                         bool* aResult)
 {
     NS_ENSURE_ARG_POINTER(aOther);
-    NS_PRECONDITION(aResult, "null pointer for outparam");
+    MOZ_ASSERT(aResult, "null pointer for outparam");
 
     RefPtr<nsJSURI> otherJSURI;
     nsresult rv = aOther->QueryInterface(kJSURICID,
                                          getter_AddRefs(otherJSURI));
     if (NS_FAILED(rv)) {
         *aResult = false; // aOther is not a nsJSURI --> not equal.
         return NS_OK;
     }
--- a/dom/script/nsIScriptElement.h
+++ b/dom/script/nsIScriptElement.h
@@ -59,23 +59,23 @@ public:
   virtual bool GetScriptType(nsAString& type) = 0;
 
   /**
    * Location of script source text. Can return null, in which case
    * this is assumed to be an inline script element.
    */
   nsIURI* GetScriptURI()
   {
-    NS_PRECONDITION(mFrozen, "Not ready for this call yet!");
+    MOZ_ASSERT(mFrozen, "Not ready for this call yet!");
     return mUri;
   }
 
   nsIPrincipal* GetScriptURITriggeringPrincipal()
   {
-    NS_PRECONDITION(mFrozen, "Not ready for this call yet!");
+    MOZ_ASSERT(mFrozen, "Not ready for this call yet!");
     return mSrcTriggeringPrincipal;
   }
 
   /**
    * Script source text for inline script elements.
    */
   virtual void GetScriptText(nsAString& text) = 0;
 
@@ -92,44 +92,44 @@ public:
    */
   virtual void FreezeExecutionAttrs(nsIDocument* aOwnerDoc) = 0;
 
   /**
    * Is the script a module script. Currently only supported by HTML scripts.
    */
   bool GetScriptIsModule()
   {
-    NS_PRECONDITION(mFrozen, "Not ready for this call yet!");
+    MOZ_ASSERT(mFrozen, "Not ready for this call yet!");
     return mIsModule;
   }
 
   /**
    * Is the script deferred. Currently only supported by HTML scripts.
    */
   bool GetScriptDeferred()
   {
-    NS_PRECONDITION(mFrozen, "Not ready for this call yet!");
+    MOZ_ASSERT(mFrozen, "Not ready for this call yet!");
     return mDefer;
   }
 
   /**
    * Is the script async. Currently only supported by HTML scripts.
    */
   bool GetScriptAsync()
   {
-    NS_PRECONDITION(mFrozen, "Not ready for this call yet!");
+    MOZ_ASSERT(mFrozen, "Not ready for this call yet!");
     return mAsync;
   }
 
   /**
    * Is the script an external script?
    */
   bool GetScriptExternal()
   {
-    NS_PRECONDITION(mFrozen, "Not ready for this call yet!");
+    MOZ_ASSERT(mFrozen, "Not ready for this call yet!");
     return mExternal;
   }
 
   /**
    * Returns how the element was created.
    */
   mozilla::dom::FromParser GetParserCreated()
   {
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -729,17 +729,17 @@ nsCSPContext::LogViolationDetails(uint16
 }
 
 #undef CASE_CHECK_AND_REPORT
 
 NS_IMETHODIMP
 nsCSPContext::SetRequestContext(nsIDOMDocument* aDOMDocument,
                                 nsIPrincipal* aPrincipal)
 {
-  NS_PRECONDITION(aDOMDocument || aPrincipal,
+  MOZ_ASSERT(aDOMDocument || aPrincipal,
                   "Can't set context without doc or principal");
   NS_ENSURE_ARG(aDOMDocument || aPrincipal);
 
   if (aDOMDocument) {
     nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDocument);
     mLoadingContext = do_GetWeakReference(doc);
     mSelfURI = doc->GetDocumentURI();
     mLoadingPrincipal = doc->NodePrincipal();
--- a/dom/smil/SMILBoolType.cpp
+++ b/dom/smil/SMILBoolType.cpp
@@ -9,75 +9,75 @@
 #include "nsDebug.h"
 #include <math.h>
 
 namespace mozilla {
 
 void
 SMILBoolType::Init(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
+  MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mBool = false;
   aValue.mType = this;
 }
 
 void
 SMILBoolType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mBool = false;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mBool = aSrc.mU.mBool;
   return NS_OK;
 }
 
 bool
 SMILBoolType::IsEqual(const nsSMILValue& aLeft,
                       const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return aLeft.mU.mBool == aRight.mU.mBool;
 }
 
 nsresult
 SMILBoolType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                   uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
   return NS_ERROR_FAILURE; // bool values can't be added to each other
 }
 
 nsresult
 SMILBoolType::ComputeDistance(const nsSMILValue& aFrom,
                               const nsSMILValue& aTo,
                               double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
   return NS_ERROR_FAILURE; // there is no concept of distance between bool values
 }
 
 nsresult
 SMILBoolType::Interpolate(const nsSMILValue& aStartVal,
                           const nsSMILValue& aEndVal,
                           double aUnitDistance,
                           nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
       "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
       "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType   == this, "Unexpected result type");
   return NS_ERROR_FAILURE; // bool values do not interpolate
 }
 
 } // namespace mozilla
--- a/dom/smil/SMILEnumType.cpp
+++ b/dom/smil/SMILEnumType.cpp
@@ -9,75 +9,75 @@
 #include "nsDebug.h"
 #include <math.h>
 
 namespace mozilla {
 
 void
 SMILEnumType::Init(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
+  MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mUint = 0;
   aValue.mType = this;
 }
 
 void
 SMILEnumType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mUint = 0;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILEnumType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mUint = aSrc.mU.mUint;
   return NS_OK;
 }
 
 bool
 SMILEnumType::IsEqual(const nsSMILValue& aLeft,
                       const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return aLeft.mU.mUint == aRight.mU.mUint;
 }
 
 nsresult
 SMILEnumType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                   uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
   return NS_ERROR_FAILURE; // enum values can't be added to each other
 }
 
 nsresult
 SMILEnumType::ComputeDistance(const nsSMILValue& aFrom,
                               const nsSMILValue& aTo,
                               double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
   return NS_ERROR_FAILURE; // there is no concept of distance between enum values
 }
 
 nsresult
 SMILEnumType::Interpolate(const nsSMILValue& aStartVal,
                           const nsSMILValue& aEndVal,
                           double aUnitDistance,
                           nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
       "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
       "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType   == this, "Unexpected result type");
   return NS_ERROR_FAILURE; // enum values do not interpolate
 }
 
 } // namespace mozilla
--- a/dom/smil/SMILIntegerType.cpp
+++ b/dom/smil/SMILIntegerType.cpp
@@ -17,73 +17,73 @@ SMILIntegerType::Init(nsSMILValue& aValu
   MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mInt = 0;
   aValue.mType = this;
 }
 
 void
 SMILIntegerType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mInt = 0;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILIntegerType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mInt = aSrc.mU.mInt;
   return NS_OK;
 }
 
 bool
 SMILIntegerType::IsEqual(const nsSMILValue& aLeft,
                          const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return aLeft.mU.mInt == aRight.mU.mInt;
 }
 
 nsresult
 SMILIntegerType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                      uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
   aDest.mU.mInt += aValueToAdd.mU.mInt * aCount;
   return NS_OK;
 }
 
 nsresult
 SMILIntegerType::ComputeDistance(const nsSMILValue& aFrom,
                                  const nsSMILValue& aTo,
                                  double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
   aDistance = fabs(double(aTo.mU.mInt - aFrom.mU.mInt));
   return NS_OK;
 }
 
 nsresult
 SMILIntegerType::Interpolate(const nsSMILValue& aStartVal,
                              const nsSMILValue& aEndVal,
                              double aUnitDistance,
                              nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType   == this, "Unexpected result type");
 
   const double startVal   = double(aStartVal.mU.mInt);
   const double endVal     = double(aEndVal.mU.mInt);
   const double currentVal = startVal + (endVal - startVal) * aUnitDistance;
 
   // When currentVal is exactly midway between its two nearest integers, we
   // jump to the "next" integer to provide simple, easy to remember and
   // consistent behaviour (from the SMIL author's point of view).
--- a/dom/smil/SMILStringType.cpp
+++ b/dom/smil/SMILStringType.cpp
@@ -9,83 +9,83 @@
 #include "nsDebug.h"
 #include "nsString.h"
 
 namespace mozilla {
 
 void
 SMILStringType::Init(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
+  MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mPtr = new nsString();
   aValue.mType = this;
 }
 
 void
 SMILStringType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   delete static_cast<nsAString*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILStringType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   const nsAString* src = static_cast<const nsAString*>(aSrc.mU.mPtr);
   nsAString* dst = static_cast<nsAString*>(aDest.mU.mPtr);
   *dst = *src;
   return NS_OK;
 }
 
 bool
 SMILStringType::IsEqual(const nsSMILValue& aLeft,
                         const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   const nsAString* leftString =
     static_cast<const nsAString*>(aLeft.mU.mPtr);
   const nsAString* rightString =
     static_cast<nsAString*>(aRight.mU.mPtr);
   return *leftString == *rightString;
 }
 
 nsresult
 SMILStringType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                     uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
   return NS_ERROR_FAILURE; // string values can't be added to each other
 }
 
 nsresult
 SMILStringType::ComputeDistance(const nsSMILValue& aFrom,
                                 const nsSMILValue& aTo,
                                 double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
   return NS_ERROR_FAILURE; // there is no concept of distance between string values
 }
 
 nsresult
 SMILStringType::Interpolate(const nsSMILValue& aStartVal,
                             const nsSMILValue& aEndVal,
                             double aUnitDistance,
                             nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
       "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
       "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType   == this, "Unexpected result type");
   return NS_ERROR_FAILURE; // string values do not interpolate
 }
 
 } // namespace mozilla
--- a/dom/smil/nsSMILFloatType.cpp
+++ b/dom/smil/nsSMILFloatType.cpp
@@ -7,86 +7,86 @@
 #include "nsSMILFloatType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include <math.h>
 
 void
 nsSMILFloatType::Init(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
+  MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mDouble = 0.0;
   aValue.mType = this;
 }
 
 void
 nsSMILFloatType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mDouble = 0.0;
   aValue.mType      = nsSMILNullType::Singleton();
 }
 
 nsresult
 nsSMILFloatType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mDouble = aSrc.mU.mDouble;
   return NS_OK;
 }
 
 bool
 nsSMILFloatType::IsEqual(const nsSMILValue& aLeft,
                          const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return aLeft.mU.mDouble == aRight.mU.mDouble;
 }
 
 nsresult
 nsSMILFloatType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                      uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
   aDest.mU.mDouble += aValueToAdd.mU.mDouble * aCount;
   return NS_OK;
 }
 
 nsresult
 nsSMILFloatType::ComputeDistance(const nsSMILValue& aFrom,
                                  const nsSMILValue& aTo,
                                  double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
 
   const double &from = aFrom.mU.mDouble;
   const double &to   = aTo.mU.mDouble;
 
   aDistance = fabs(to - from);
 
   return NS_OK;
 }
 
 nsresult
 nsSMILFloatType::Interpolate(const nsSMILValue& aStartVal,
                              const nsSMILValue& aEndVal,
                              double aUnitDistance,
                              nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
       "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
       "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType   == this, "Unexpected result type");
 
   const double &startVal = aStartVal.mU.mDouble;
   const double &endVal   = aEndVal.mU.mDouble;
 
   aResult.mU.mDouble = (startVal + (endVal - startVal) * aUnitDistance);
 
   return NS_OK;
 }
--- a/dom/smil/nsSMILNullType.cpp
+++ b/dom/smil/nsSMILNullType.cpp
@@ -13,29 +13,29 @@ nsSMILNullType::Singleton()
 {
   static nsSMILNullType sSingleton;
   return &sSingleton;
 }
 
 nsresult
 nsSMILNullType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aSrc.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aSrc.mType == this, "Unexpected source type");
   aDest.mU    = aSrc.mU;
   aDest.mType = Singleton();
   return NS_OK;
 }
 
 bool
 nsSMILNullType::IsEqual(const nsSMILValue& aLeft,
                         const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return true;  // All null-typed values are equivalent.
 }
 
 nsresult
 nsSMILNullType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                     uint32_t aCount) const
 {
--- a/dom/svg/SVGIntegerPairSMILType.cpp
+++ b/dom/svg/SVGIntegerPairSMILType.cpp
@@ -19,85 +19,85 @@ SVGIntegerPairSMILType::Init(nsSMILValue
   aValue.mU.mIntPair[0] = 0;
   aValue.mU.mIntPair[1] = 0;
   aValue.mType = this;
 }
 
 void
 SVGIntegerPairSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mIntPair[0] = 0;
   aValue.mU.mIntPair[1] = 0;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGIntegerPairSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   aDest.mU.mIntPair[0] = aSrc.mU.mIntPair[0];
   aDest.mU.mIntPair[1] = aSrc.mU.mIntPair[1];
   return NS_OK;
 }
 
 bool
 SVGIntegerPairSMILType::IsEqual(const nsSMILValue& aLeft,
                                 const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return aLeft.mU.mIntPair[0] == aRight.mU.mIntPair[0] &&
          aLeft.mU.mIntPair[1] == aRight.mU.mIntPair[1];
 }
 
 nsresult
 SVGIntegerPairSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                             uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
 
   aDest.mU.mIntPair[0] += aValueToAdd.mU.mIntPair[0] * aCount;
   aDest.mU.mIntPair[1] += aValueToAdd.mU.mIntPair[1] * aCount;
 
   return NS_OK;
 }
 
 nsresult
 SVGIntegerPairSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                         const nsSMILValue& aTo,
                                         double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
 
   double delta[2];
   delta[0] = aTo.mU.mIntPair[0] - aFrom.mU.mIntPair[0];
   delta[1] = aTo.mU.mIntPair[1] - aFrom.mU.mIntPair[1];
 
   aDistance = NS_hypot(delta[0], delta[1]);
   return NS_OK;
 }
 
 nsresult
 SVGIntegerPairSMILType::Interpolate(const nsSMILValue& aStartVal,
                                     const nsSMILValue& aEndVal,
                                     double aUnitDistance,
                                     nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   double currentVal[2];
   currentVal[0] = aStartVal.mU.mIntPair[0] +
                   (aEndVal.mU.mIntPair[0] - aStartVal.mU.mIntPair[0]) * aUnitDistance;
   currentVal[1] = aStartVal.mU.mIntPair[1] +
                   (aEndVal.mU.mIntPair[1] - aStartVal.mU.mIntPair[1]) * aUnitDistance;
 
   aResult.mU.mIntPair[0] = NS_lround(currentVal[0]);
--- a/dom/svg/SVGLengthListSMILType.cpp
+++ b/dom/svg/SVGLengthListSMILType.cpp
@@ -31,55 +31,55 @@ SVGLengthListSMILType::Init(nsSMILValue 
 
   aValue.mU.mPtr = lengthList;
   aValue.mType = this;
 }
 
 void
 SVGLengthListSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGLengthListAndInfo*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGLengthListSMILType::Assign(nsSMILValue& aDest,
                               const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   const SVGLengthListAndInfo* src =
     static_cast<const SVGLengthListAndInfo*>(aSrc.mU.mPtr);
   SVGLengthListAndInfo* dest =
     static_cast<SVGLengthListAndInfo*>(aDest.mU.mPtr);
 
   return dest->CopyFrom(*src);
 }
 
 bool
 SVGLengthListSMILType::IsEqual(const nsSMILValue& aLeft,
                                const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return *static_cast<const SVGLengthListAndInfo*>(aLeft.mU.mPtr) ==
          *static_cast<const SVGLengthListAndInfo*>(aRight.mU.mPtr);
 }
 
 nsresult
 SVGLengthListSMILType::Add(nsSMILValue& aDest,
                            const nsSMILValue& aValueToAdd,
                            uint32_t aCount) const
 {
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type");
 
   SVGLengthListAndInfo& dest =
     *static_cast<SVGLengthListAndInfo*>(aDest.mU.mPtr);
   const SVGLengthListAndInfo& valueToAdd =
     *static_cast<const SVGLengthListAndInfo*>(aValueToAdd.mU.mPtr);
 
   // To understand this code, see the comments documenting our Init() method,
   // and documenting SVGLengthListAndInfo::CanZeroPadList().
@@ -156,18 +156,18 @@ SVGLengthListSMILType::Add(nsSMILValue& 
   return NS_OK;
 }
 
 nsresult
 SVGLengthListSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                        const nsSMILValue& aTo,
                                        double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type");
 
   const SVGLengthListAndInfo& from =
     *static_cast<const SVGLengthListAndInfo*>(aFrom.mU.mPtr);
   const SVGLengthListAndInfo& to =
     *static_cast<const SVGLengthListAndInfo*>(aTo.mU.mPtr);
 
   // To understand this code, see the comments documenting our Init() method,
   // and documenting SVGLengthListAndInfo::CanZeroPadList().
@@ -226,21 +226,21 @@ SVGLengthListSMILType::ComputeDistance(c
 }
 
 nsresult
 SVGLengthListSMILType::Interpolate(const nsSMILValue& aStartVal,
                                    const nsSMILValue& aEndVal,
                                    double aUnitDistance,
                                    nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   const SVGLengthListAndInfo& start =
     *static_cast<const SVGLengthListAndInfo*>(aStartVal.mU.mPtr);
   const SVGLengthListAndInfo& end =
     *static_cast<const SVGLengthListAndInfo*>(aEndVal.mU.mPtr);
   SVGLengthListAndInfo& result =
     *static_cast<SVGLengthListAndInfo*>(aResult.mU.mPtr);
 
--- a/dom/svg/SVGNumberListSMILType.cpp
+++ b/dom/svg/SVGNumberListSMILType.cpp
@@ -44,55 +44,55 @@ SVGNumberListSMILType::Init(nsSMILValue 
 
   aValue.mU.mPtr = numberList;
   aValue.mType = this;
 }
 
 void
 SVGNumberListSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGNumberListAndInfo*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGNumberListSMILType::Assign(nsSMILValue& aDest,
                               const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   const SVGNumberListAndInfo* src =
     static_cast<const SVGNumberListAndInfo*>(aSrc.mU.mPtr);
   SVGNumberListAndInfo* dest =
     static_cast<SVGNumberListAndInfo*>(aDest.mU.mPtr);
 
   return dest->CopyFrom(*src);
 }
 
 bool
 SVGNumberListSMILType::IsEqual(const nsSMILValue& aLeft,
                                const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return *static_cast<const SVGNumberListAndInfo*>(aLeft.mU.mPtr) ==
          *static_cast<const SVGNumberListAndInfo*>(aRight.mU.mPtr);
 }
 
 nsresult
 SVGNumberListSMILType::Add(nsSMILValue& aDest,
                            const nsSMILValue& aValueToAdd,
                            uint32_t aCount) const
 {
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type");
 
   SVGNumberListAndInfo& dest =
     *static_cast<SVGNumberListAndInfo*>(aDest.mU.mPtr);
   const SVGNumberListAndInfo& valueToAdd =
     *static_cast<const SVGNumberListAndInfo*>(aValueToAdd.mU.mPtr);
 
   MOZ_ASSERT(dest.Element() || valueToAdd.Element(),
              "Target element propagation failure");
@@ -128,18 +128,18 @@ SVGNumberListSMILType::Add(nsSMILValue& 
   return NS_OK;
 }
 
 nsresult
 SVGNumberListSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                        const nsSMILValue& aTo,
                                        double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type");
 
   const SVGNumberListAndInfo& from =
     *static_cast<const SVGNumberListAndInfo*>(aFrom.mU.mPtr);
   const SVGNumberListAndInfo& to =
     *static_cast<const SVGNumberListAndInfo*>(aTo.mU.mPtr);
 
   if (from.Length() != to.Length()) {
     // Lists in the 'values' attribute must have the same length.
@@ -166,21 +166,21 @@ SVGNumberListSMILType::ComputeDistance(c
 }
 
 nsresult
 SVGNumberListSMILType::Interpolate(const nsSMILValue& aStartVal,
                                    const nsSMILValue& aEndVal,
                                    double aUnitDistance,
                                    nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   const SVGNumberListAndInfo& start =
     *static_cast<const SVGNumberListAndInfo*>(aStartVal.mU.mPtr);
   const SVGNumberListAndInfo& end =
     *static_cast<const SVGNumberListAndInfo*>(aEndVal.mU.mPtr);
   SVGNumberListAndInfo& result =
     *static_cast<SVGNumberListAndInfo*>(aResult.mU.mPtr);
 
--- a/dom/svg/SVGNumberPairSMILType.cpp
+++ b/dom/svg/SVGNumberPairSMILType.cpp
@@ -21,85 +21,85 @@ SVGNumberPairSMILType::Init(nsSMILValue&
   aValue.mU.mNumberPair[0] = 0;
   aValue.mU.mNumberPair[1] = 0;
   aValue.mType = this;
 }
 
 void
 SVGNumberPairSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mNumberPair[0] = 0;
   aValue.mU.mNumberPair[1] = 0;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGNumberPairSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   aDest.mU.mNumberPair[0] = aSrc.mU.mNumberPair[0];
   aDest.mU.mNumberPair[1] = aSrc.mU.mNumberPair[1];
   return NS_OK;
 }
 
 bool
 SVGNumberPairSMILType::IsEqual(const nsSMILValue& aLeft,
                                const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return aLeft.mU.mNumberPair[0] == aRight.mU.mNumberPair[0] &&
          aLeft.mU.mNumberPair[1] == aRight.mU.mNumberPair[1];
 }
 
 nsresult
 SVGNumberPairSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                            uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
 
   aDest.mU.mNumberPair[0] += aValueToAdd.mU.mNumberPair[0] * aCount;
   aDest.mU.mNumberPair[1] += aValueToAdd.mU.mNumberPair[1] * aCount;
 
   return NS_OK;
 }
 
 nsresult
 SVGNumberPairSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                        const nsSMILValue& aTo,
                                        double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
 
   double delta[2];
   delta[0] = aTo.mU.mNumberPair[0] - aFrom.mU.mNumberPair[0];
   delta[1] = aTo.mU.mNumberPair[1] - aFrom.mU.mNumberPair[1];
 
   aDistance = NS_hypot(delta[0], delta[1]);
   return NS_OK;
 }
 
 nsresult
 SVGNumberPairSMILType::Interpolate(const nsSMILValue& aStartVal,
                                    const nsSMILValue& aEndVal,
                                    double aUnitDistance,
                                    nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   aResult.mU.mNumberPair[0] =
     float(aStartVal.mU.mNumberPair[0] +
           (aEndVal.mU.mNumberPair[0] - aStartVal.mU.mNumberPair[0]) * aUnitDistance);
   aResult.mU.mNumberPair[1] =
     float(aStartVal.mU.mNumberPair[1] +
           (aEndVal.mU.mNumberPair[1] - aStartVal.mU.mNumberPair[1]) * aUnitDistance);
   return NS_OK;
--- a/dom/svg/SVGOrientSMILType.cpp
+++ b/dom/svg/SVGOrientSMILType.cpp
@@ -27,53 +27,53 @@ SVGOrientSMILType::Init(nsSMILValue& aVa
   aValue.mU.mOrient.mUnit = SVG_ANGLETYPE_UNSPECIFIED;
   aValue.mU.mOrient.mOrientType = SVG_MARKER_ORIENT_ANGLE;
   aValue.mType = this;
 }
 
 void
 SVGOrientSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value.");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value.");
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGOrientSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types.");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value.");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types.");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value.");
 
   aDest.mU.mOrient.mAngle = aSrc.mU.mOrient.mAngle;
   aDest.mU.mOrient.mUnit = aSrc.mU.mOrient.mUnit;
   aDest.mU.mOrient.mOrientType = aSrc.mU.mOrient.mOrientType;
   return NS_OK;
 }
 
 bool
 SVGOrientSMILType::IsEqual(const nsSMILValue& aLeft,
                            const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return
     aLeft.mU.mOrient.mAngle == aRight.mU.mOrient.mAngle &&
     aLeft.mU.mOrient.mUnit == aRight.mU.mOrient.mUnit &&
     aLeft.mU.mOrient.mOrientType == aRight.mU.mOrient.mOrientType;
 }
 
 nsresult
 SVGOrientSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                        uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
 
   if (aDest.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE ||
       aValueToAdd.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE) {
     // TODO: it would be nice to be able to add to auto angles
     return NS_ERROR_FAILURE;
   }
 
   // We may be dealing with two different angle units, so we normalize to
@@ -93,18 +93,18 @@ SVGOrientSMILType::Add(nsSMILValue& aDes
   return NS_OK;
 }
 
 nsresult
 SVGOrientSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                    const nsSMILValue& aTo,
                                    double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
 
   if (aFrom.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE ||
       aTo.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE) {
     // TODO: it would be nice to be able to compute distance with auto angles
     return NS_ERROR_FAILURE;
   }
 
   // Normalize both to degrees in case they're different angle units:
@@ -119,21 +119,21 @@ SVGOrientSMILType::ComputeDistance(const
 }
 
 nsresult
 SVGOrientSMILType::Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation.");
-  NS_PRECONDITION(aResult.mType   == this, "Unexpected result type.");
+  MOZ_ASSERT(aResult.mType   == this, "Unexpected result type.");
 
   if (aStartVal.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE ||
       aEndVal.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE) {
     // TODO: it would be nice to be able to handle auto angles too.
     return NS_ERROR_FAILURE;
   }
 
   float start  = aStartVal.mU.mOrient.mAngle *
--- a/dom/svg/SVGPathSegListSMILType.cpp
+++ b/dom/svg/SVGPathSegListSMILType.cpp
@@ -27,43 +27,43 @@ SVGPathSegListSMILType::Init(nsSMILValue
   MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mPtr = new SVGPathDataAndInfo();
   aValue.mType = this;
 }
 
 void
 SVGPathSegListSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGPathDataAndInfo*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGPathSegListSMILType::Assign(nsSMILValue& aDest,
                                const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   const SVGPathDataAndInfo* src =
     static_cast<const SVGPathDataAndInfo*>(aSrc.mU.mPtr);
   SVGPathDataAndInfo* dest =
     static_cast<SVGPathDataAndInfo*>(aDest.mU.mPtr);
 
   return dest->CopyFrom(*src);
 }
 
 bool
 SVGPathSegListSMILType::IsEqual(const nsSMILValue& aLeft,
                                 const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return *static_cast<const SVGPathDataAndInfo*>(aLeft.mU.mPtr) ==
          *static_cast<const SVGPathDataAndInfo*>(aRight.mU.mPtr);
 }
 
 static bool
 ArcFlagsDiffer(SVGPathDataAndInfo::const_iterator aPathData1,
                SVGPathDataAndInfo::const_iterator aPathData2)
@@ -395,18 +395,18 @@ ConvertAllPathSegmentData(SVGPathDataAnd
              "Failed to convert all path segment data! (Corrupt?)");
 }
 
 nsresult
 SVGPathSegListSMILType::Add(nsSMILValue& aDest,
                             const nsSMILValue& aValueToAdd,
                             uint32_t aCount) const
 {
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type");
 
   SVGPathDataAndInfo& dest =
     *static_cast<SVGPathDataAndInfo*>(aDest.mU.mPtr);
   const SVGPathDataAndInfo& valueToAdd =
     *static_cast<const SVGPathDataAndInfo*>(aValueToAdd.mU.mPtr);
 
   if (valueToAdd.IsIdentity()) { // Adding identity value - no-op
     return NS_OK;
@@ -435,36 +435,36 @@ SVGPathSegListSMILType::Add(nsSMILValue&
   return AddWeightedPathSegLists(1.0, dest, aCount, valueToAdd, dest);
 }
 
 nsresult
 SVGPathSegListSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                         const nsSMILValue& aTo,
                                         double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type");
 
   // See https://bugzilla.mozilla.org/show_bug.cgi?id=522306#c18
 
   // SVGContentUtils::ReportToConsole
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 nsresult
 SVGPathSegListSMILType::Interpolate(const nsSMILValue& aStartVal,
                                     const nsSMILValue& aEndVal,
                                     double aUnitDistance,
                                     nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   const SVGPathDataAndInfo& start =
     *static_cast<const SVGPathDataAndInfo*>(aStartVal.mU.mPtr);
   const SVGPathDataAndInfo& end =
     *static_cast<const SVGPathDataAndInfo*>(aEndVal.mU.mPtr);
   SVGPathDataAndInfo& result =
     *static_cast<SVGPathDataAndInfo*>(aResult.mU.mPtr);
   MOZ_ASSERT(result.IsIdentity(),
--- a/dom/svg/SVGPointListSMILType.cpp
+++ b/dom/svg/SVGPointListSMILType.cpp
@@ -27,55 +27,55 @@ SVGPointListSMILType::Init(nsSMILValue &
 
   aValue.mU.mPtr = pointList;
   aValue.mType = this;
 }
 
 void
 SVGPointListSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGPointListAndInfo*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGPointListSMILType::Assign(nsSMILValue& aDest,
                               const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   const SVGPointListAndInfo* src =
     static_cast<const SVGPointListAndInfo*>(aSrc.mU.mPtr);
   SVGPointListAndInfo* dest =
     static_cast<SVGPointListAndInfo*>(aDest.mU.mPtr);
 
   return dest->CopyFrom(*src);
 }
 
 bool
 SVGPointListSMILType::IsEqual(const nsSMILValue& aLeft,
                                const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   return *static_cast<const SVGPointListAndInfo*>(aLeft.mU.mPtr) ==
          *static_cast<const SVGPointListAndInfo*>(aRight.mU.mPtr);
 }
 
 nsresult
 SVGPointListSMILType::Add(nsSMILValue& aDest,
                           const nsSMILValue& aValueToAdd,
                           uint32_t aCount) const
 {
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type");
 
   SVGPointListAndInfo& dest =
     *static_cast<SVGPointListAndInfo*>(aDest.mU.mPtr);
   const SVGPointListAndInfo& valueToAdd =
     *static_cast<const SVGPointListAndInfo*>(aValueToAdd.mU.mPtr);
 
   MOZ_ASSERT(dest.Element() || valueToAdd.Element(),
              "Target element propagation failure");
@@ -107,18 +107,18 @@ SVGPointListSMILType::Add(nsSMILValue& a
   return NS_OK;
 }
 
 nsresult
 SVGPointListSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                       const nsSMILValue& aTo,
                                       double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type");
 
   const SVGPointListAndInfo& from =
     *static_cast<const SVGPointListAndInfo*>(aFrom.mU.mPtr);
   const SVGPointListAndInfo& to =
     *static_cast<const SVGPointListAndInfo*>(aTo.mU.mPtr);
 
   if (from.Length() != to.Length()) {
     // Lists in the 'values' attribute must have the same length.
@@ -146,21 +146,21 @@ SVGPointListSMILType::ComputeDistance(co
 }
 
 nsresult
 SVGPointListSMILType::Interpolate(const nsSMILValue& aStartVal,
                                   const nsSMILValue& aEndVal,
                                   double aUnitDistance,
                                   nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   const SVGPointListAndInfo& start =
     *static_cast<const SVGPointListAndInfo*>(aStartVal.mU.mPtr);
   const SVGPointListAndInfo& end =
     *static_cast<const SVGPointListAndInfo*>(aEndVal.mU.mPtr);
   SVGPointListAndInfo& result =
     *static_cast<SVGPointListAndInfo*>(aResult.mU.mPtr);
 
--- a/dom/svg/SVGTransformListSMILType.cpp
+++ b/dom/svg/SVGTransformListSMILType.cpp
@@ -17,56 +17,56 @@ using namespace dom::SVGTransformBinding
 typedef FallibleTArray<SVGTransformSMILData> TransformArray;
 
 //----------------------------------------------------------------------
 // nsISMILType implementation
 
 void
 SVGTransformListSMILType::Init(nsSMILValue &aValue) const
 {
-  NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
+  MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
 
   TransformArray* transforms = new TransformArray(1);
   aValue.mU.mPtr = transforms;
   aValue.mType = this;
 }
 
 void
 SVGTransformListSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type");
   TransformArray* params = static_cast<TransformArray*>(aValue.mU.mPtr);
   delete params;
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGTransformListSMILType::Assign(nsSMILValue& aDest,
                                const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   const TransformArray* srcTransforms =
     static_cast<const TransformArray*>(aSrc.mU.mPtr);
   TransformArray* dstTransforms = static_cast<TransformArray*>(aDest.mU.mPtr);
   if (!dstTransforms->Assign(*srcTransforms, fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
 
 bool
 SVGTransformListSMILType::IsEqual(const nsSMILValue& aLeft,
                                   const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected SMIL type");
 
   const TransformArray& leftArr
     (*static_cast<const TransformArray*>(aLeft.mU.mPtr));
   const TransformArray& rightArr
     (*static_cast<const TransformArray*>(aRight.mU.mPtr));
 
   // If array-lengths don't match, we're trivially non-equal.
   if (leftArr.Length() != rightArr.Length()) {
@@ -85,18 +85,18 @@ SVGTransformListSMILType::IsEqual(const 
   return true;
 }
 
 nsresult
 SVGTransformListSMILType::Add(nsSMILValue& aDest,
                               const nsSMILValue& aValueToAdd,
                               uint32_t aCount) const
 {
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types");
 
   TransformArray& dstTransforms(*static_cast<TransformArray*>(aDest.mU.mPtr));
   const TransformArray& srcTransforms
     (*static_cast<const TransformArray*>(aValueToAdd.mU.mPtr));
 
   // We're doing a simple add here (as opposed to a sandwich add below).
   // We only do this when we're accumulating a repeat result or calculating
   // a by-animation value.
@@ -137,18 +137,18 @@ SVGTransformListSMILType::Add(nsSMILValu
 
   return NS_OK;
 }
 
 nsresult
 SVGTransformListSMILType::SandwichAdd(nsSMILValue& aDest,
                                       const nsSMILValue& aValueToAdd) const
 {
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type");
-  NS_PRECONDITION(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types");
 
   // For <animateTransform> a sandwich add means a matrix post-multiplication
   // which just means to put the additional transform on the end of the array
 
   TransformArray& dstTransforms(*static_cast<TransformArray*>(aDest.mU.mPtr));
   const TransformArray& srcTransforms
     (*static_cast<const TransformArray*>(aValueToAdd.mU.mPtr));
 
@@ -175,19 +175,19 @@ SVGTransformListSMILType::SandwichAdd(ns
   return NS_OK;
 }
 
 nsresult
 SVGTransformListSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                           const nsSMILValue& aTo,
                                           double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,
+  MOZ_ASSERT(aFrom.mType == aTo.mType,
       "Can't compute difference between different SMIL types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type");
 
   const TransformArray* fromTransforms =
     static_cast<const TransformArray*>(aFrom.mU.mPtr);
   const TransformArray* toTransforms =
     static_cast<const TransformArray*>(aTo.mU.mPtr);
 
   // ComputeDistance is only used for calculating distances between single
   // values in a values array which necessarily have the same type
@@ -240,21 +240,21 @@ SVGTransformListSMILType::ComputeDistanc
 }
 
 nsresult
 SVGTransformListSMILType::Interpolate(const nsSMILValue& aStartVal,
                                       const nsSMILValue& aEndVal,
                                       double aUnitDistance,
                                       nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
       "Can't interpolate between different SMIL types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
       "Unexpected type for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   const TransformArray& startTransforms =
     (*static_cast<const TransformArray*>(aStartVal.mU.mPtr));
   const TransformArray& endTransforms
     (*static_cast<const TransformArray*>(aEndVal.mU.mPtr));
 
   // We may have 0..n transforms in the start transform array (the base
   // value) but we should only have 1 transform in the end transform array
@@ -314,29 +314,29 @@ SVGTransformListSMILType::Interpolate(co
 // Transform array accessors
 
 // static
 nsresult
 SVGTransformListSMILType::AppendTransform(
   const SVGTransformSMILData& aTransform,
   nsSMILValue& aValue)
 {
-  NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == Singleton(), "Unexpected SMIL value type");
 
   TransformArray& transforms = *static_cast<TransformArray*>(aValue.mU.mPtr);
   return transforms.AppendElement(aTransform, fallible) ?
     NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 // static
 bool
 SVGTransformListSMILType::AppendTransforms(const SVGTransformList& aList,
                                            nsSMILValue& aValue)
 {
-  NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == Singleton(), "Unexpected SMIL value type");
 
   TransformArray& transforms = *static_cast<TransformArray*>(aValue.mU.mPtr);
 
   if (!transforms.SetCapacity(transforms.Length() + aList.Length(), fallible))
     return false;
 
   for (uint32_t i = 0; i < aList.Length(); ++i) {
     // No need to check the return value below since we have already allocated
@@ -347,17 +347,17 @@ SVGTransformListSMILType::AppendTransfor
   return true;
 }
 
 // static
 bool
 SVGTransformListSMILType::GetTransforms(const nsSMILValue& aValue,
                                         FallibleTArray<nsSVGTransform>& aTransforms)
 {
-  NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type");
+  MOZ_ASSERT(aValue.mType == Singleton(), "Unexpected SMIL value type");
 
   const TransformArray& smilTransforms =
     *static_cast<const TransformArray*>(aValue.mU.mPtr);
 
   aTransforms.Clear();
   if (!aTransforms.SetCapacity(smilTransforms.Length(), fallible))
       return false;
 
--- a/dom/svg/SVGViewBoxSMILType.cpp
+++ b/dom/svg/SVGViewBoxSMILType.cpp
@@ -21,70 +21,70 @@ SVGViewBoxSMILType::Init(nsSMILValue& aV
 
   aValue.mU.mPtr = new nsSVGViewBoxRect();
   aValue.mType = this;
 }
 
 void
 SVGViewBoxSMILType::Destroy(nsSMILValue& aValue) const
 {
-  NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
   delete static_cast<nsSVGViewBoxRect*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
   aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGViewBoxSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
-  NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
+  MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
 
   const nsSVGViewBoxRect* src = static_cast<const nsSVGViewBoxRect*>(aSrc.mU.mPtr);
   nsSVGViewBoxRect* dst = static_cast<nsSVGViewBoxRect*>(aDest.mU.mPtr);
   *dst = *src;
   return NS_OK;
 }
 
 bool
 SVGViewBoxSMILType::IsEqual(const nsSMILValue& aLeft,
                             const nsSMILValue& aRight) const
 {
-  NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
-  NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
+  MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
+  MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
 
   const nsSVGViewBoxRect* leftBox =
     static_cast<const nsSVGViewBoxRect*>(aLeft.mU.mPtr);
   const nsSVGViewBoxRect* rightBox =
     static_cast<nsSVGViewBoxRect*>(aRight.mU.mPtr);
   return *leftBox == *rightBox;
 }
 
 nsresult
 SVGViewBoxSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                         uint32_t aCount) const
 {
-  NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
+  MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
                   "Trying to add invalid types");
-  NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
 
   // See https://bugzilla.mozilla.org/show_bug.cgi?id=541884#c3 and the two
   // comments that follow that one for arguments for and against allowing
   // viewBox to be additive.
 
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 SVGViewBoxSMILType::ComputeDistance(const nsSMILValue& aFrom,
                                     const nsSMILValue& aTo,
                                     double& aDistance) const
 {
-  NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
-  NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
+  MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types");
+  MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
 
   const nsSVGViewBoxRect* from = static_cast<const nsSVGViewBoxRect*>(aFrom.mU.mPtr);
   const nsSVGViewBoxRect* to = static_cast<const nsSVGViewBoxRect*>(aTo.mU.mPtr);
 
   if (from->none || to->none) {
     return NS_ERROR_FAILURE;
   }
 
@@ -105,21 +105,21 @@ SVGViewBoxSMILType::ComputeDistance(cons
 }
 
 nsresult
 SVGViewBoxSMILType::Interpolate(const nsSMILValue& aStartVal,
                                 const nsSMILValue& aEndVal,
                                 double aUnitDistance,
                                 nsSMILValue& aResult) const
 {
-  NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
+  MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
                   "Trying to interpolate different types");
-  NS_PRECONDITION(aStartVal.mType == this,
+  MOZ_ASSERT(aStartVal.mType == this,
                   "Unexpected types for interpolation");
-  NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
+  MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
 
   const nsSVGViewBoxRect* start = static_cast<const nsSVGViewBoxRect*>(aStartVal.mU.mPtr);
   const nsSVGViewBoxRect* end = static_cast<const nsSVGViewBoxRect*>(aEndVal.mU.mPtr);
 
   if (start->none || end->none) {
     return NS_ERROR_FAILURE;
   }
 
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -197,17 +197,17 @@ nsBindingManager::SetWrappedJS(nsIConten
   return NS_OK;
 }
 
 void
 nsBindingManager::RemovedFromDocumentInternal(nsIContent* aContent,
                                               nsIDocument* aOldDocument,
                                               DestructorHandling aDestructorHandling)
 {
-  NS_PRECONDITION(aOldDocument != nullptr, "no old document");
+  MOZ_ASSERT(aOldDocument != nullptr, "no old document");
 
   RefPtr<nsXBLBinding> binding = aContent->GetXBLBinding();
   if (binding) {
     // The binding manager may have been destroyed before a runnable
     // has had a chance to reach this point. If so, we bail out on calling
     // BindingDetached (which may invoke a XBL destructor) and
     // ChangeDocument, but we still want to clear out the binding
     // and insertion parent that may hold references.
@@ -293,17 +293,17 @@ nsBindingManager::ClearBinding(Element* 
   return NS_OK;
 }
 
 nsresult
 nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc,
                                       nsIURI* aURL,
                                       nsIPrincipal* aOriginPrincipal)
 {
-  NS_PRECONDITION(aURL, "Must have a URI to load!");
+  MOZ_ASSERT(aURL, "Must have a URI to load!");
 
   // First we need to load our binding.
   nsXBLService* xblService = nsXBLService::GetInstance();
   if (!xblService)
     return NS_ERROR_FAILURE;
 
   // Load the binding doc.
   RefPtr<nsXBLDocumentInfo> info;
@@ -466,17 +466,17 @@ nsBindingManager::ExecuteDetachedHandler
   for (i = 0; i < count; ++i) {
     bindings[i]->ExecuteDetachedHandler();
   }
 }
 
 nsresult
 nsBindingManager::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
 {
-  NS_PRECONDITION(aDocumentInfo, "Must have a non-null documentinfo!");
+  MOZ_ASSERT(aDocumentInfo, "Must have a non-null documentinfo!");
 
   if (!mDocumentTable) {
     mDocumentTable = new nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo>();
   }
 
   mDocumentTable->Put(aDocumentInfo->DocumentURI(), aDocumentInfo);
 
   return NS_OK;
@@ -497,17 +497,17 @@ nsBindingManager::GetXBLDocumentInfo(nsI
     return nullptr;
 
   return mDocumentTable->GetWeak(aURL);
 }
 
 nsresult
 nsBindingManager::PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener)
 {
-  NS_PRECONDITION(aListener, "Must have a non-null listener!");
+  MOZ_ASSERT(aListener, "Must have a non-null listener!");
 
   if (!mLoadingDocTable) {
     mLoadingDocTable =
       new nsInterfaceHashtable<nsURIHashKey,nsIStreamListener>();
   }
   mLoadingDocTable->Put(aURL, aListener);
 
   return NS_OK;
--- a/dom/xbl/nsXBLContentSink.cpp
+++ b/dom/xbl/nsXBLContentSink.cpp
@@ -165,17 +165,17 @@ nsXBLContentSink::FlushText(bool aReleas
 }
 
 NS_IMETHODIMP
 nsXBLContentSink::ReportError(const char16_t* aErrorText,
                               const char16_t* aSourceText,
                               nsIScriptError *aError,
                               bool *_retval)
 {
-  NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
+  MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!");
 
   // XXX FIXME This function overrides and calls on
   // nsXMLContentSink::ReportError, and probably should die.  See bug 347826.
 
   // XXX We should make sure the binding has no effect, but that it also
   // gets destroyed properly without leaking.  Perhaps we should even
   // ensure that the content that was bound is displayed with no
   // binding.
--- a/dom/xbl/nsXBLProtoImplField.cpp
+++ b/dom/xbl/nsXBLProtoImplField.cpp
@@ -370,17 +370,17 @@ nsXBLProtoImplField::InstallAccessors(JS
   return NS_OK;
 }
 
 nsresult
 nsXBLProtoImplField::InstallField(JS::Handle<JSObject*> aBoundNode,
                                   const nsXBLPrototypeBinding& aProtoBinding,
                                   bool* aDidInstall) const
 {
-  NS_PRECONDITION(aBoundNode,
+  MOZ_ASSERT(aBoundNode,
                   "uh-oh, bound node should NOT be null or bad things will "
                   "happen");
 
   *aDidInstall = false;
 
   // Empty fields are treated as not actually present.
   if (IsEmpty()) {
     return NS_OK;
--- a/dom/xbl/nsXBLProtoImplMethod.cpp
+++ b/dom/xbl/nsXBLProtoImplMethod.cpp
@@ -39,32 +39,32 @@ nsXBLProtoImplMethod::~nsXBLProtoImplMet
   if (!IsCompiled()) {
     delete GetUncompiledMethod();
   }
 }
 
 void
 nsXBLProtoImplMethod::AppendBodyText(const nsAString& aText)
 {
-  NS_PRECONDITION(!IsCompiled(),
+  MOZ_ASSERT(!IsCompiled(),
                   "Must not be compiled when accessing uncompiled method");
 
   nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
   if (!uncompiledMethod) {
     uncompiledMethod = new nsXBLUncompiledMethod();
     SetUncompiledMethod(uncompiledMethod);
   }
 
   uncompiledMethod->AppendBodyText(aText);
 }
 
 void
 nsXBLProtoImplMethod::AddParameter(const nsAString& aText)
 {
-  NS_PRECONDITION(!IsCompiled(),
+  MOZ_ASSERT(!IsCompiled(),
                   "Must not be compiled when accessing uncompiled method");
 
   if (aText.IsEmpty()) {
     NS_WARNING("Empty name attribute in xbl:parameter!");
     return;
   }
 
   nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
@@ -74,33 +74,33 @@ nsXBLProtoImplMethod::AddParameter(const
   }
 
   uncompiledMethod->AddParameter(aText);
 }
 
 void
 nsXBLProtoImplMethod::SetLineNumber(uint32_t aLineNumber)
 {
-  NS_PRECONDITION(!IsCompiled(),
+  MOZ_ASSERT(!IsCompiled(),
                   "Must not be compiled when accessing uncompiled method");
 
   nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
   if (!uncompiledMethod) {
     uncompiledMethod = new nsXBLUncompiledMethod();
     SetUncompiledMethod(uncompiledMethod);
   }
 
   uncompiledMethod->SetLineNumber(aLineNumber);
 }
 
 nsresult
 nsXBLProtoImplMethod::InstallMember(JSContext* aCx,
                                     JS::Handle<JSObject*> aTargetClassObject)
 {
-  NS_PRECONDITION(IsCompiled(),
+  MOZ_ASSERT(IsCompiled(),
                   "Should not be installing an uncompiled method");
   MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx));
 
 #ifdef DEBUG
   {
     JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject));
     MOZ_ASSERT(xpc::IsInContentXBLScope(globalObject) ||
                globalObject == xpc::GetXBLScope(aCx, globalObject));
@@ -125,19 +125,19 @@ nsXBLProtoImplMethod::InstallMember(JSCo
   return NS_OK;
 }
 
 nsresult
 nsXBLProtoImplMethod::CompileMember(AutoJSAPI& jsapi, const nsString& aClassStr,
                                     JS::Handle<JSObject*> aClassObject)
 {
   AssertInCompilationScope();
-  NS_PRECONDITION(!IsCompiled(),
+  MOZ_ASSERT(!IsCompiled(),
                   "Trying to compile an already-compiled method");
-  NS_PRECONDITION(aClassObject,
+  MOZ_ASSERT(aClassObject,
                   "Must have class object to compile");
 
   nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
 
   // No parameters or body was supplied, so don't install method.
   if (!uncompiledMethod) {
     // Early return after which we consider ourselves compiled.
     SetCompiledMethod(nullptr);
@@ -258,17 +258,17 @@ nsXBLProtoImplMethod::Write(nsIObjectOut
   return NS_OK;
 }
 
 nsresult
 nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement,
                                        const nsXBLPrototypeBinding& aProtoBinding)
 {
   MOZ_ASSERT(aBoundElement->IsElement());
-  NS_PRECONDITION(IsCompiled(), "Can't execute uncompiled method");
+  MOZ_ASSERT(IsCompiled(), "Can't execute uncompiled method");
 
   if (!GetCompiledMethod()) {
     // Nothing to do here
     return NS_OK;
   }
 
   // Get the script context the same way
   // nsXBLProtoImpl::InstallImplementation does.
--- a/dom/xbl/nsXBLProtoImplProperty.cpp
+++ b/dom/xbl/nsXBLProtoImplProperty.cpp
@@ -81,57 +81,52 @@ void nsXBLProtoImplProperty::EnsureUncom
     nsXBLTextWithLineNumber* text = new nsXBLTextWithLineNumber();
     aPropertyOp.SetUncompiled(text);
   }
 }
 
 void
 nsXBLProtoImplProperty::AppendGetterText(const nsAString& aText)
 {
-  NS_PRECONDITION(!mIsCompiled,
-                  "Must not be compiled when accessing getter text");
+  MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing getter text");
   EnsureUncompiledText(mGetter);
   mGetter.GetUncompiled()->AppendText(aText);
 }
 
 void
 nsXBLProtoImplProperty::AppendSetterText(const nsAString& aText)
 {
-  NS_PRECONDITION(!mIsCompiled,
-                  "Must not be compiled when accessing setter text");
+  MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing setter text");
   EnsureUncompiledText(mSetter);
   mSetter.GetUncompiled()->AppendText(aText);
 }
 
 void
 nsXBLProtoImplProperty::SetGetterLineNumber(uint32_t aLineNumber)
 {
-  NS_PRECONDITION(!mIsCompiled,
-                  "Must not be compiled when accessing getter text");
+  MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing getter text");
   EnsureUncompiledText(mGetter);
   mGetter.GetUncompiled()->SetLineNumber(aLineNumber);
 }
 
 void
 nsXBLProtoImplProperty::SetSetterLineNumber(uint32_t aLineNumber)
 {
-  NS_PRECONDITION(!mIsCompiled,
-                  "Must not be compiled when accessing setter text");
+  MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing setter text");
   EnsureUncompiledText(mSetter);
   mSetter.GetUncompiled()->SetLineNumber(aLineNumber);
 }
 
 const char* gPropertyArgs[] = { "val" };
 
 nsresult
 nsXBLProtoImplProperty::InstallMember(JSContext *aCx,
                                       JS::Handle<JSObject*> aTargetClassObject)
 {
-  NS_PRECONDITION(mIsCompiled,
-                  "Should not be installing an uncompiled property");
+  MOZ_ASSERT(mIsCompiled, "Should not be installing an uncompiled property");
   MOZ_ASSERT(mGetter.IsCompiled() && mSetter.IsCompiled());
   MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx));
 
 #ifdef DEBUG
   {
     JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject));
     MOZ_ASSERT(xpc::IsInContentXBLScope(globalObject) ||
                globalObject == xpc::GetXBLScope(aCx, globalObject));
@@ -164,20 +159,18 @@ nsXBLProtoImplProperty::InstallMember(JS
   return NS_OK;
 }
 
 nsresult
 nsXBLProtoImplProperty::CompileMember(AutoJSAPI& jsapi, const nsString& aClassStr,
                                       JS::Handle<JSObject*> aClassObject)
 {
   AssertInCompilationScope();
-  NS_PRECONDITION(!mIsCompiled,
-                  "Trying to compile an already-compiled property");
-  NS_PRECONDITION(aClassObject,
-                  "Must have class object to compile");
+  MOZ_ASSERT(!mIsCompiled, "Trying to compile an already-compiled property");
+  MOZ_ASSERT(aClassObject, "Must have class object to compile");
   MOZ_ASSERT(!mGetter.IsCompiled() && !mSetter.IsCompiled());
   JSContext *cx = jsapi.cx();
 
   if (!mName)
     return NS_ERROR_FAILURE; // Without a valid name, we can't install the member.
 
   // We have a property.
   nsresult rv = NS_OK;
--- a/dom/xbl/nsXBLService.cpp
+++ b/dom/xbl/nsXBLService.cpp
@@ -475,17 +475,17 @@ private:
 
 // This function loads a particular XBL file and installs all of the bindings
 // onto the element.
 nsresult
 nsXBLService::LoadBindings(Element* aElement, nsIURI* aURL,
                            nsIPrincipal* aOriginPrincipal,
                            nsXBLBinding** aBinding, bool* aResolveStyle)
 {
-  NS_PRECONDITION(aOriginPrincipal, "Must have an origin principal");
+  MOZ_ASSERT(aOriginPrincipal, "Must have an origin principal");
 
   *aBinding = nullptr;
   *aResolveStyle = false;
 
   AutoEnsureSubtreeStyled subtreeStyled(aElement);
 
   if (MOZ_UNLIKELY(!aURL)) {
     return NS_OK;
@@ -895,18 +895,18 @@ IsSystemOrChromeURLPrincipal(nsIPrincipa
 nsresult
 nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
                                       nsIDocument* aBoundDocument,
                                       nsIURI* aBindingURI,
                                       nsIPrincipal* aOriginPrincipal,
                                       bool aForceSyncLoad,
                                       nsXBLDocumentInfo** aResult)
 {
-  NS_PRECONDITION(aBindingURI, "Must have a binding URI");
-  NS_PRECONDITION(!aOriginPrincipal || aBoundDocument,
+  MOZ_ASSERT(aBindingURI, "Must have a binding URI");
+  MOZ_ASSERT(!aOriginPrincipal || aBoundDocument,
                   "If we're doing a security check, we better have a document!");
 
   *aResult = nullptr;
   // Allow XBL in unprivileged documents if it's specified in a privileged or
   // chrome: stylesheet. This allows themes to specify XBL bindings.
   if (aOriginPrincipal && !IsSystemOrChromeURLPrincipal(aOriginPrincipal)) {
     NS_ENSURE_TRUE(!aBoundDocument || aBoundDocument->AllowXULXBL(),
                    NS_ERROR_XBL_BLOCKED);
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -3212,17 +3212,17 @@ XMLHttpRequestMainThread::ChangeState(ui
 // nsIChannelEventSink methods:
 //
 NS_IMETHODIMP
 XMLHttpRequestMainThread::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
                                                  nsIChannel *aNewChannel,
                                                  uint32_t    aFlags,
                                                  nsIAsyncVerifyRedirectCallback *callback)
 {
-  NS_PRECONDITION(aNewChannel, "Redirect without a channel?");
+  MOZ_ASSERT(aNewChannel, "Redirect without a channel?");
 
   // Prepare to receive callback
   mRedirectCallback = callback;
   mNewRedirectChannel = aNewChannel;
 
   if (mChannelEventSink) {
     nsCOMPtr<nsIAsyncVerifyRedirectCallback> fwd =
       EnsureXPCOMifier();
--- a/dom/xml/ProcessingInstruction.cpp
+++ b/dom/xml/ProcessingInstruction.cpp
@@ -15,17 +15,17 @@
 already_AddRefed<mozilla::dom::ProcessingInstruction>
 NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager,
                                const nsAString& aTarget,
                                const nsAString& aData)
 {
   using mozilla::dom::ProcessingInstruction;
   using mozilla::dom::XMLStylesheetProcessingInstruction;
 
-  NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager");
+  MOZ_ASSERT(aNodeInfoManager, "Missing nodeinfo manager");
 
   RefPtr<nsAtom> target = NS_Atomize(aTarget);
   MOZ_ASSERT(target);
 
   if (target == nsGkAtoms::xml_stylesheet) {
     RefPtr<XMLStylesheetProcessingInstruction> pi =
       new XMLStylesheetProcessingInstruction(aNodeInfoManager, aData);
     return pi.forget();
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -74,17 +74,17 @@ using namespace mozilla::dom;
 
 nsresult
 NS_NewXMLContentSink(nsIXMLContentSink** aResult,
                      nsIDocument* aDoc,
                      nsIURI* aURI,
                      nsISupports* aContainer,
                      nsIChannel* aChannel)
 {
-  NS_PRECONDITION(nullptr != aResult, "null ptr");
+  MOZ_ASSERT(nullptr != aResult, "null ptr");
   if (nullptr == aResult) {
     return NS_ERROR_NULL_POINTER;
   }
   RefPtr<nsXMLContentSink> it = new nsXMLContentSink();
 
   nsresult rv = it->Init(aDoc, aURI, aContainer, aChannel);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -451,17 +451,17 @@ NS_IMETHODIMP
 nsXMLContentSink::WillResume(void)
 {
   return WillResumeImpl();
 }
 
 NS_IMETHODIMP
 nsXMLContentSink::SetParser(nsParserBase* aParser)
 {
-  NS_PRECONDITION(aParser, "Should have a parser here!");
+  MOZ_ASSERT(aParser, "Should have a parser here!");
   mParser = aParser;
   return NS_OK;
 }
 
 nsresult
 nsXMLContentSink::CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
                                 mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
                                 nsIContent** aResult, bool* aAppendContent,
@@ -839,17 +839,17 @@ nsXMLContentSink::GetCurrentStackNode()
   int32_t count = mContentStack.Length();
   return count != 0 ? &mContentStack[count-1] : nullptr;
 }
 
 
 nsresult
 nsXMLContentSink::PushContent(nsIContent *aContent)
 {
-  NS_PRECONDITION(aContent, "Null content being pushed!");
+  MOZ_ASSERT(aContent, "Null content being pushed!");
   StackNode *sn = mContentStack.AppendElement();
   NS_ENSURE_TRUE(sn, NS_ERROR_OUT_OF_MEMORY);
 
   nsIContent* contentToPush = aContent;
 
   // When an XML parser would append a node to a template element, it
   // must instead append it to the template element's template contents.
   if (contentToPush->IsHTMLElement(nsGkAtoms::_template)) {
@@ -968,17 +968,17 @@ nsXMLContentSink::HandleStartElement(con
 
 nsresult
 nsXMLContentSink::HandleStartElement(const char16_t *aName,
                                      const char16_t **aAtts,
                                      uint32_t aAttsCount,
                                      uint32_t aLineNumber,
                                      bool aInterruptable)
 {
-  NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount");
+  MOZ_ASSERT(aAttsCount % 2 == 0, "incorrect aAttsCount");
   // Adjust aAttsCount so it's the actual number of attributes
   aAttsCount /= 2;
 
   nsresult result = NS_OK;
   bool appendContent = true;
   nsCOMPtr<nsIContent> content;
 
   // XXX Hopefully the parser will flag this before we get
@@ -1353,17 +1353,17 @@ nsXMLContentSink::HandleXMLDeclaration(c
 }
 
 NS_IMETHODIMP
 nsXMLContentSink::ReportError(const char16_t* aErrorText,
                               const char16_t* aSourceText,
                               nsIScriptError *aError,
                               bool *_retval)
 {
-  NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
+  MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!");
   nsresult rv = NS_OK;
 
   // The expat driver should report the error.  We're just cleaning up the mess.
   *_retval = true;
 
   mPrettyPrintXML = false;
 
   mState = eXMLContentSinkState_InProlog;
--- a/dom/xml/nsXMLFragmentContentSink.cpp
+++ b/dom/xml/nsXMLFragmentContentSink.cpp
@@ -291,17 +291,17 @@ nsXMLFragmentContentSink::HandleXMLDecla
 }
 
 NS_IMETHODIMP
 nsXMLFragmentContentSink::ReportError(const char16_t* aErrorText,
                                       const char16_t* aSourceText,
                                       nsIScriptError *aError,
                                       bool *_retval)
 {
-  NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
+  MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!");
 
   // The expat driver should report the error.
   *_retval = true;
 
   mParseError = true;
 
 #ifdef DEBUG
   // Report the error to stderr.
--- a/dom/xslt/xpath/txXPathTreeWalker.h
+++ b/dom/xslt/xpath/txXPathTreeWalker.h
@@ -172,17 +172,17 @@ txXPathTreeWalker::isOnNode(const txXPat
 {
     return (mPosition == aNode);
 }
 
 /* static */
 inline int32_t
 txXPathNodeUtils::getUniqueIdentifier(const txXPathNode& aNode)
 {
-    NS_PRECONDITION(!aNode.isAttribute(),
+    MOZ_ASSERT(!aNode.isAttribute(),
                     "Not implemented for attributes.");
     return NS_PTR_TO_INT32(aNode.mNode);
 }
 
 /* static */
 inline void
 txXPathNodeUtils::release(txXPathNode* aNode)
 {
--- a/dom/xslt/xslt/txExecutionState.cpp
+++ b/dom/xslt/xslt/txExecutionState.cpp
@@ -390,17 +390,17 @@ txExecutionState::pushTemplateRule(txSty
     rule->mModeNsId = aMode.mNamespaceID;
     rule->mModeLocalName = aMode.mLocalName;
     rule->mParams = aParams;
 }
 
 void
 txExecutionState::popTemplateRule()
 {
-    NS_PRECONDITION(!mTemplateRules.IsEmpty(), "No rules to pop");
+    MOZ_ASSERT(!mTemplateRules.IsEmpty(), "No rules to pop");
     mTemplateRules.RemoveLastElement();
 }
 
 txIEvalContext*
 txExecutionState::getEvalContext()
 {
     return mEvalContext;
 }
@@ -452,17 +452,17 @@ txExecutionState::getKeyNodes(const txEx
 {
     return mKeyHash.getKeyNodes(aKeyName, aRoot, aKeyValue,
                                 aIndexIfNotFound, *this, aResult);
 }
 
 txExecutionState::TemplateRule*
 txExecutionState::getCurrentTemplateRule()
 {
-    NS_PRECONDITION(!mTemplateRules.IsEmpty(), "No current rule!");
+    MOZ_ASSERT(!mTemplateRules.IsEmpty(), "No current rule!");
     return &mTemplateRules[mTemplateRules.Length() - 1];
 }
 
 txInstruction*
 txExecutionState::getNextInstruction()
 {
     txInstruction* instr = mNextInstruction;
     if (instr) {
--- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
+++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
@@ -120,17 +120,17 @@ NS_IMPL_ISUPPORTS(txStylesheetSink,
                   nsIInterfaceRequestor)
 
 NS_IMETHODIMP
 txStylesheetSink::HandleStartElement(const char16_t *aName,
                                      const char16_t **aAtts,
                                      uint32_t aAttsCount,
                                      uint32_t aLineNumber)
 {
-    NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount");
+    MOZ_ASSERT(aAttsCount % 2 == 0, "incorrect aAttsCount");
 
     nsresult rv =
         mCompiler->startElement(aName, aAtts, aAttsCount / 2);
     if (NS_FAILED(rv)) {
         mCompiler->cancel(rv);
 
         return rv;
     }
@@ -203,17 +203,17 @@ txStylesheetSink::HandleXMLDeclaration(c
 }
 
 NS_IMETHODIMP
 txStylesheetSink::ReportError(const char16_t *aErrorText,
                               const char16_t *aSourceText,
                               nsIScriptError *aError,
                               bool *_retval)
 {
-    NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
+    MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!");
 
     // The expat driver should report the error.
     *_retval = true;
 
     mCompiler->cancel(NS_ERROR_FAILURE, aErrorText, aSourceText);
 
     return NS_OK;
 }
--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
+++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
@@ -427,17 +427,17 @@ txMozillaXMLOutput::startDocument()
     return NS_OK;
 }
 
 nsresult
 txMozillaXMLOutput::startElement(nsAtom* aPrefix, nsAtom* aLocalName,
                                  nsAtom* aLowercaseLocalName,
                                  const int32_t aNsID)
 {
-    NS_PRECONDITION(aNsID != kNameSpaceID_None || !aPrefix,
+    MOZ_ASSERT(aNsID != kNameSpaceID_None || !aPrefix,
                     "Can't have prefix without namespace");
 
     if (mOutputFormat.mMethod == eHTMLOutput && aNsID == kNameSpaceID_None) {
         RefPtr<nsAtom> owner;
         if (!aLowercaseLocalName) {
             owner = TX_ToLowerCaseAtom(aLocalName);
             NS_ENSURE_TRUE(owner, NS_ERROR_OUT_OF_MEMORY);
 
--- a/dom/xslt/xslt/txStylesheetCompiler.cpp
+++ b/dom/xslt/xslt/txStylesheetCompiler.cpp
@@ -698,34 +698,34 @@ nsresult
 txStylesheetCompilerState::addToplevelItem(txToplevelItem* aItem)
 {
     return mToplevelIterator.addBefore(aItem);
 }
 
 nsresult
 txStylesheetCompilerState::openInstructionContainer(txInstructionContainer* aContainer)
 {
-    NS_PRECONDITION(!mNextInstrPtr, "can't nest instruction-containers");
+    MOZ_ASSERT(!mNextInstrPtr, "can't nest instruction-containers");
 
     mNextInstrPtr = aContainer->mFirstInstruction.StartAssignment();
     return NS_OK;
 }
 
 void
 txStylesheetCompilerState::closeInstructionContainer()
 {
     NS_ASSERTION(mGotoTargetPointers.IsEmpty(),
                  "GotoTargets still exists, did you forget to add txReturn?");
     mNextInstrPtr = 0;
 }
 
 nsresult
 txStylesheetCompilerState::addInstruction(nsAutoPtr<txInstruction>&& aInstruction)
 {
-    NS_PRECONDITION(mNextInstrPtr, "adding instruction outside container");
+    MOZ_ASSERT(mNextInstrPtr, "adding instruction outside container");
 
     txInstruction* newInstr = aInstruction;
 
     *mNextInstrPtr = aInstruction.forget();
     mNextInstrPtr = newInstr->mNext.StartAssignment();
 
     uint32_t i, count = mGotoTargetPointers.Length();
     for (i = 0; i < count; ++i) {
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -214,17 +214,17 @@ XULDocument::~XULDocument()
 }
 
 } // namespace dom
 } // namespace mozilla
 
 nsresult
 NS_NewXULDocument(nsIDocument** result)
 {
-    NS_PRECONDITION(result != nullptr, "null ptr");
+    MOZ_ASSERT(result != nullptr, "null ptr");
     if (! result)
         return NS_ERROR_NULL_POINTER;
 
     RefPtr<XULDocument> doc = new XULDocument();
 
     nsresult rv;
     if (NS_FAILED(rv = doc->Init())) {
         return rv;
@@ -1617,17 +1617,17 @@ XULDocument::StartLayout(void)
 
 /* static */
 bool
 XULDocument::MatchAttribute(Element* aElement,
                             int32_t aNamespaceID,
                             nsAtom* aAttrName,
                             void* aData)
 {
-    NS_PRECONDITION(aElement, "Must have content node to work with!");
+    MOZ_ASSERT(aElement, "Must have content node to work with!");
     nsString* attrValue = static_cast<nsString*>(aData);
     if (aNamespaceID != kNameSpaceID_Unknown &&
         aNamespaceID != kNameSpaceID_Wildcard) {
         return attrValue->EqualsLiteral("*") ?
             aElement->HasAttr(aNamespaceID, aAttrName) :
             aElement->AttrValueIs(aNamespaceID, aAttrName, *attrValue,
                                   eCaseMatters);
     }
@@ -2043,18 +2043,18 @@ XULDocument::PrepareToWalk()
 
     return NS_OK;
 }
 
 nsresult
 XULDocument::CreateAndInsertPI(const nsXULPrototypePI* aProtoPI,
                                nsINode* aParent, nsINode* aBeforeThis)
 {
-    NS_PRECONDITION(aProtoPI, "null ptr");
-    NS_PRECONDITION(aParent, "null ptr");
+    MOZ_ASSERT(aProtoPI, "null ptr");
+    MOZ_ASSERT(aParent, "null ptr");
 
     RefPtr<ProcessingInstruction> node =
         NS_NewXMLProcessingInstruction(mNodeInfoManager, aProtoPI->mTarget,
                                        aProtoPI->mData);
 
     nsresult rv;
     if (aProtoPI->mTarget.EqualsLiteral("xml-stylesheet")) {
         rv = InsertXMLStylesheetPI(aProtoPI, aParent, aBeforeThis, node);
@@ -2734,18 +2734,18 @@ XULDocument::GetXULWindowIfToplevelChrom
         return nullptr;
     }
     return xulWin.forget();
 }
 
 nsresult
 XULDocument::DoneWalking()
 {
-    NS_PRECONDITION(mPendingSheets == 0, "there are sheets to be loaded");
-    NS_PRECONDITION(!mStillWalking, "walk not done");
+    MOZ_ASSERT(mPendingSheets == 0, "there are sheets to be loaded");
+    MOZ_ASSERT(!mStillWalking, "walk not done");
 
     // XXXldb This is where we should really be setting the chromehidden
     // attribute.
 
     {
         mozAutoDocUpdate updateBatch(this, UPDATE_STYLE, true);
         uint32_t count = mOverlaySheets.Length();
         for (uint32_t i = 0; i < count; ++i) {
@@ -2954,17 +2954,17 @@ XULDocument::EndUpdate(nsUpdateType aUpd
     XMLDocument::EndUpdate(aUpdateType);
 
     MaybeBroadcast();
 }
 
 void
 XULDocument::ReportMissingOverlay(nsIURI* aURI)
 {
-    NS_PRECONDITION(aURI, "Must have a URI");
+    MOZ_ASSERT(aURI, "Must have a URI");
 
     NS_ConvertUTF8toUTF16 utfSpec(aURI->GetSpecOrDefault());
     const char16_t* params[] = { utfSpec.get() };
     nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                     NS_LITERAL_CSTRING("XUL Document"), this,
                                     nsContentUtils::eXUL_PROPERTIES,
                                     "MissingOverlay",
                                     params, ArrayLength(params));
@@ -3260,17 +3260,17 @@ XULDocument::OnScriptCompileComplete(JSS
     }
 
     return rv;
 }
 
 nsresult
 XULDocument::ExecuteScript(nsXULPrototypeScript *aScript)
 {
-    NS_PRECONDITION(aScript != nullptr, "null ptr");
+    MOZ_ASSERT(aScript != nullptr, "null ptr");
     NS_ENSURE_TRUE(aScript, NS_ERROR_NULL_POINTER);
     NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
 
     nsresult rv;
     rv = mScriptGlobalObject->EnsureScriptEnvironment();
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Execute the precompiled script with the given version
@@ -3301,17 +3301,17 @@ XULDocument::ExecuteScript(nsXULPrototyp
 
 
 nsresult
 XULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
                                         Element** aResult,
                                         bool aIsRoot)
 {
     // Create a content model element from a prototype element.
-    NS_PRECONDITION(aPrototype != nullptr, "null ptr");
+    MOZ_ASSERT(aPrototype != nullptr, "null ptr");
     if (! aPrototype)
         return NS_ERROR_NULL_POINTER;
 
     *aResult = nullptr;
     nsresult rv = NS_OK;
 
     if (MOZ_LOG_TEST(gXULLog, LogLevel::Debug)) {
         MOZ_LOG(gXULLog, LogLevel::Debug,
--- a/dom/xul/nsXULCommandDispatcher.cpp
+++ b/dom/xul/nsXULCommandDispatcher.cpp
@@ -238,17 +238,17 @@ nsXULCommandDispatcher::AdvanceFocusInto
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXULCommandDispatcher::AddCommandUpdater(Element* aElement,
                                           const nsAString& aEvents,
                                           const nsAString& aTargets)
 {
-  NS_PRECONDITION(aElement != nullptr, "null ptr");
+  MOZ_ASSERT(aElement != nullptr, "null ptr");
   if (! aElement)
     return NS_ERROR_NULL_POINTER;
 
   NS_ENSURE_TRUE(mDocument, NS_ERROR_UNEXPECTED);
 
   nsresult rv = nsContentUtils::CheckSameOrigin(mDocument, aElement);
 
   if (NS_FAILED(rv)) {
@@ -306,17 +306,17 @@ nsXULCommandDispatcher::AddCommandUpdate
   // If we get here, this is a new updater. Append it to the list.
   *link = new Updater(aElement, aEvents, aTargets);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXULCommandDispatcher::RemoveCommandUpdater(Element* aElement)
 {
-  NS_PRECONDITION(aElement != nullptr, "null ptr");
+  MOZ_ASSERT(aElement != nullptr, "null ptr");
   if (! aElement)
     return NS_ERROR_NULL_POINTER;
 
   Updater* updater = mUpdaters;
   Updater** link = &mUpdaters;
 
   while (updater) {
     if (updater->mElement == aElement) {
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -270,17 +270,17 @@ XULContentSinkImpl::GetTarget()
 }
 
 //----------------------------------------------------------------------
 
 nsresult
 XULContentSinkImpl::Init(nsIDocument* aDocument,
                          nsXULPrototypeDocument* aPrototype)
 {
-    NS_PRECONDITION(aDocument != nullptr, "null ptr");
+    MOZ_ASSERT(aDocument != nullptr, "null ptr");
     if (! aDocument)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     mDocument    = do_GetWeakReference(aDocument);
     mPrototype   = aPrototype;
 
@@ -430,18 +430,18 @@ XULContentSinkImpl::CreateElement(mozill
 NS_IMETHODIMP
 XULContentSinkImpl::HandleStartElement(const char16_t *aName,
                                        const char16_t **aAtts,
                                        uint32_t aAttsCount,
                                        uint32_t aLineNumber)
 {
   // XXX Hopefully the parser will flag this before we get here. If
   // we're in the epilog, there should be no new elements
-  NS_PRECONDITION(mState != eInEpilog, "tag in XUL doc epilog");
-  NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount");
+  MOZ_ASSERT(mState != eInEpilog, "tag in XUL doc epilog");
+  MOZ_ASSERT(aAttsCount % 2 == 0, "incorrect aAttsCount");
   // Adjust aAttsCount so it's the actual number of attributes
   aAttsCount /= 2;
 
   if (mState == eInEpilog)
       return NS_ERROR_UNEXPECTED;
 
   if (mState != eInScript) {
       FlushText();
@@ -644,17 +644,17 @@ XULContentSinkImpl::HandleXMLDeclaration
 
 
 NS_IMETHODIMP
 XULContentSinkImpl::ReportError(const char16_t* aErrorText,
                                 const char16_t* aSourceText,
                                 nsIScriptError *aError,
                                 bool *_retval)
 {
-  NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
+  MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!");
 
   // The expat driver should report the error.
   *_retval = true;
 
   nsresult rv = NS_OK;
 
   // make sure to empty the context stack so that
   // <parsererror> could become the root element.
--- a/dom/xul/nsXULContentUtils.cpp
+++ b/dom/xul/nsXULContentUtils.cpp
@@ -105,21 +105,21 @@ nsXULContentUtils::FindChildByTag(nsICon
 }
 
 nsresult
 nsXULContentUtils::SetCommandUpdater(nsIDocument* aDocument, Element* aElement)
 {
     // Deal with setting up a 'commandupdater'. Pulls the 'events' and
     // 'targets' attributes off of aElement, and adds it to the
     // document's command dispatcher.
-    NS_PRECONDITION(aDocument != nullptr, "null ptr");
+    MOZ_ASSERT(aDocument != nullptr, "null ptr");
     if (! aDocument)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aElement != nullptr, "null ptr");
+    MOZ_ASSERT(aElement != nullptr, "null ptr");
     if (! aElement)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     NS_ASSERTION(aDocument->IsXULDocument(), "not a xul document");
     if (! aDocument->IsXULDocument())
         return NS_ERROR_UNEXPECTED;
--- a/dom/xul/nsXULControllers.cpp
+++ b/dom/xul/nsXULControllers.cpp
@@ -40,17 +40,17 @@ nsXULControllers::DeleteControllers()
 
   mControllers.Clear();
 }
 
 
 nsresult
 NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult)
 {
-  NS_PRECONDITION(aOuter == nullptr, "no aggregation");
+  MOZ_ASSERT(aOuter == nullptr, "no aggregation");
   if (aOuter)
     return NS_ERROR_NO_AGGREGATION;
 
   nsXULControllers* controllers = new nsXULControllers();
   nsresult rv;
   NS_ADDREF(controllers);
   rv = controllers->QueryInterface(aIID, aResult);
   NS_RELEASE(controllers);
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -234,21 +234,21 @@ nsXULElement::CreateFromPrototype(nsXULP
 nsresult
 nsXULElement::CreateFromPrototype(nsXULPrototypeElement* aPrototype,
                                   nsIDocument* aDocument,
                                   bool aIsScriptable,
                                   bool aIsRoot,
                                   Element** aResult)
 {
     // Create an nsXULElement from a prototype
-    NS_PRECONDITION(aPrototype != nullptr, "null ptr");
+    MOZ_ASSERT(aPrototype != nullptr, "null ptr");
     if (! aPrototype)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     RefPtr<mozilla::dom::NodeInfo> nodeInfo;
     if (aDocument) {
         mozilla::dom::NodeInfo* ni = aPrototype->mNodeInfo;
         nodeInfo = aDocument->NodeInfoManager()->
           GetNodeInfo(ni->NameAtom(), ni->GetPrefixAtom(), ni->NamespaceID(),
@@ -265,17 +265,17 @@ nsXULElement::CreateFromPrototype(nsXULP
 }
 
 nsresult
 NS_NewXULElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                  FromParser aFromParser)
 {
     RefPtr<mozilla::dom::NodeInfo> nodeInfo = aNodeInfo;
 
-    NS_PRECONDITION(nodeInfo, "need nodeinfo for non-proto Create");
+    MOZ_ASSERT(nodeInfo, "need nodeinfo for non-proto Create");
 
     NS_ASSERTION(nodeInfo->NamespaceEquals(kNameSpaceID_XUL),
                  "Trying to create XUL elements that don't have the XUL namespace");
 
     nsIDocument* doc = nodeInfo->GetDocument();
     if (doc && !doc->AllowXULXBL()) {
         return NS_ERROR_NOT_AVAILABLE;
     }
@@ -283,17 +283,17 @@ NS_NewXULElement(Element** aResult, alre
     return nsContentUtils::NewXULOrHTMLElement(aResult, nodeInfo, aFromParser, nullptr, nullptr);
 }
 
 void
 NS_TrustedNewXULElement(Element** aResult,
                         already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
 {
     RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
-    NS_PRECONDITION(ni, "need nodeinfo for non-proto Create");
+    MOZ_ASSERT(ni, "need nodeinfo for non-proto Create");
 
     // Create an nsXULElement with the specified namespace and tag.
     NS_ADDREF(*aResult = nsXULElement::Construct(ni.forget()));
 }
 
 //----------------------------------------------------------------------
 // nsISupports interface
 
@@ -2140,17 +2140,17 @@ nsXULPrototypeElement::Serialize(nsIObje
 }
 
 nsresult
 nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
                                    nsXULPrototypeDocument* aProtoDoc,
                                    nsIURI* aDocumentURI,
                                    const nsTArray<RefPtr<mozilla::dom::NodeInfo>> *aNodeInfos)
 {
-    NS_PRECONDITION(aNodeInfos, "missing nodeinfo array");
+    MOZ_ASSERT(aNodeInfos, "missing nodeinfo array");
 
     // Read Node Info
     uint32_t number = 0;
     nsresult rv = aStream->Read32(&number);
     if (NS_WARN_IF(NS_FAILED(rv))) return rv;
     mNodeInfo = aNodeInfos->SafeElementAt(number, nullptr);
     if (!mNodeInfo) {
         return NS_ERROR_UNEXPECTED;
@@ -2267,17 +2267,17 @@ nsXULPrototypeElement::Deserialize(nsIOb
 
     return rv;
 }
 
 nsresult
 nsXULPrototypeElement::SetAttrAt(uint32_t aPos, const nsAString& aValue,
                                  nsIURI* aDocumentURI)
 {
-    NS_PRECONDITION(aPos < mNumAttributes, "out-of-bounds");
+    MOZ_ASSERT(aPos < mNumAttributes, "out-of-bounds");
 
     // WARNING!!
     // This code is largely duplicated in nsXULElement::SetAttr.
     // Any changes should be made to both functions.
 
     if (!mNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) {
         mAttributes[aPos].mValue.ParseStringOrAtom(aValue);
 
--- a/dom/xul/nsXULPrototypeDocument.cpp
+++ b/dom/xul/nsXULPrototypeDocument.cpp
@@ -404,33 +404,33 @@ void
 nsXULPrototypeDocument::SetRootElement(nsXULPrototypeElement* aElement)
 {
     mRoot = aElement;
 }
 
 nsresult
 nsXULPrototypeDocument::AddProcessingInstruction(nsXULPrototypePI* aPI)
 {
-    NS_PRECONDITION(aPI, "null ptr");
+    MOZ_ASSERT(aPI, "null ptr");
     if (!mProcessingInstructions.AppendElement(aPI)) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
     return NS_OK;
 }
 
 const nsTArray<RefPtr<nsXULPrototypePI> >&
 nsXULPrototypeDocument::GetProcessingInstructions() const
 {
     return mProcessingInstructions;
 }
 
 void
 nsXULPrototypeDocument::AddStyleSheetReference(nsIURI* aURI)
 {
-    NS_PRECONDITION(aURI, "null ptr");
+    MOZ_ASSERT(aURI, "null ptr");
     if (!mStyleSheetReferences.AppendObject(aURI)) {
         NS_WARNING("mStyleSheetReferences->AppendElement() failed."
                    "Stylesheet overlay dropped.");
     }
 }
 
 const nsCOMArray<nsIURI>&
 nsXULPrototypeDocument::GetStyleSheetReferences() const
@@ -454,17 +454,17 @@ nsXULPrototypeDocument::SetHeaderData(ns
     return NS_OK;
 }
 
 
 
 nsIPrincipal*
 nsXULPrototypeDocument::DocumentPrincipal()
 {
-    NS_PRECONDITION(mNodeInfoManager, "missing nodeInfoManager");
+    MOZ_ASSERT(mNodeInfoManager, "missing nodeInfoManager");
     return mNodeInfoManager->DocumentPrincipal();
 }
 
 void
 nsXULPrototypeDocument::SetDocumentPrincipal(nsIPrincipal* aPrincipal)
 {
     mNodeInfoManager->SetDocumentPrincipal(aPrincipal);
 }
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -3544,17 +3544,17 @@ EditorBase::GetNextNodeInternal(const Ed
 }
 
 nsIContent*
 EditorBase::FindNextLeafNode(nsINode* aCurrentNode,
                              bool aGoForward,
                              bool bNoBlockCrossing)
 {
   // called only by GetPriorNode so we don't need to check params.
-  NS_PRECONDITION(IsDescendantOfEditorRoot(aCurrentNode) &&
+  MOZ_ASSERT(IsDescendantOfEditorRoot(aCurrentNode) &&
                   !IsEditorRoot(aCurrentNode),
                   "Bogus arguments");
 
   nsINode* cur = aCurrentNode;
   for (;;) {
     // if aCurrentNode has a sibling in the right direction, return
     // that sibling's closest child (or itself if it has no children)
     nsIContent* sibling =
@@ -4141,33 +4141,33 @@ EditorBase::JoinNodesDeepWithTransaction
   }
 
   return ret;
 }
 
 void
 EditorBase::BeginUpdateViewBatch()
 {
-  NS_PRECONDITION(mUpdateCount >= 0, "bad state");
+  MOZ_ASSERT(mUpdateCount >= 0, "bad state");
 
   if (!mUpdateCount) {
     // Turn off selection updates and notifications.
     RefPtr<Selection> selection = GetSelection();
     if (selection) {
       selection->StartBatchChanges();
     }
   }
 
   mUpdateCount++;
 }
 
 nsresult
 EditorBase::EndUpdateViewBatch()
 {
-  NS_PRECONDITION(mUpdateCount > 0, "bad state");
+  MOZ_ASSERT(mUpdateCount > 0, "bad state");
 
   if (mUpdateCount <= 0) {
     mUpdateCount = 0;
     return NS_ERROR_FAILURE;
   }
 
   mUpdateCount--;
 
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -133,17 +133,17 @@ EditorEventListener::Connect(EditorBase*
     Disconnect();
   }
   return rv;
 }
 
 nsresult
 EditorEventListener::InstallToEditor()
 {
-  NS_PRECONDITION(mEditorBase, "The caller must set mEditorBase");
+  MOZ_ASSERT(mEditorBase, "The caller must set mEditorBase");
 
   EventTarget* piTarget = mEditorBase->GetDOMEventTarget();
   NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
 
   // register the event listeners with the listener manager
   EventListenerManager* elmP = piTarget->GetOrCreateListenerManager();
   NS_ENSURE_STATE(elmP);
 
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -386,17 +386,17 @@ HTMLEditor::UpdateRootElement()
 
 already_AddRefed<nsIContent>
 HTMLEditor::FindSelectionRoot(nsINode* aNode)
 {
   if (NS_WARN_IF(!aNode)) {
     return nullptr;
   }
 
-  NS_PRECONDITION(aNode->IsDocument() || aNode->IsContent(),
+  MOZ_ASSERT(aNode->IsDocument() || aNode->IsContent(),
                   "aNode must be content or document node");
 
   nsCOMPtr<nsIDocument> doc = aNode->GetComposedDoc();
   if (!doc) {
     return nullptr;
   }
 
   nsCOMPtr<nsIContent> content;
@@ -3644,17 +3644,17 @@ HTMLEditor::GetEnclosingTable(nsINode* a
     }
   }
   return nullptr;
 }
 
 nsIDOMNode*
 HTMLEditor::GetEnclosingTable(nsIDOMNode* aNode)
 {
-  NS_PRECONDITION(aNode, "null node passed to HTMLEditor::GetEnclosingTable");
+  MOZ_ASSERT(aNode, "null node passed to HTMLEditor::GetEnclosingTable");
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(node, nullptr);
   nsCOMPtr<Element> table = GetEnclosingTable(node);
   nsCOMPtr<nsIDOMNode> ret = do_QueryInterface(table);
   return ret;
 }
 
 
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -225,17 +225,17 @@ TextEditRules::AfterEdit(EditAction aAct
                          nsIEditor::EDirection aDirection)
 {
   if (mLockRulesSniffing) {
     return NS_OK;
   }
 
   AutoLockRulesSniffing lockIt(this);
 
-  NS_PRECONDITION(mActionNesting>0, "bad action nesting!");
+  MOZ_ASSERT(mActionNesting>0, "bad action nesting!");
   if (!--mActionNesting) {
     NS_ENSURE_STATE(mTextEditor);
     RefPtr<Selection> selection = mTextEditor->GetSelection();
     NS_ENSURE_STATE(selection);
 
     NS_ENSURE_STATE(mTextEditor);
     nsresult rv =
       mTextEditor->HandleInlineSpellCheck(aAction, *selection,
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -202,17 +202,17 @@ void
 TextEditor::BeginEditorInit()
 {
   mInitTriggerCounter++;
 }
 
 nsresult
 TextEditor::EndEditorInit()
 {
-  NS_PRECONDITION(mInitTriggerCounter > 0, "ended editor init before we began?");
+  MOZ_ASSERT(mInitTriggerCounter > 0, "ended editor init before we began?");
   mInitTriggerCounter--;
   if (mInitTriggerCounter) {
     return NS_OK;
   }
 
   nsresult rv = InitRules();
   if (NS_FAILED(rv)) {
     return rv;
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -1753,18 +1753,18 @@ mozInlineSpellChecker::SaveCurrentSelect
 }
 
 // This is a copy of nsContentUtils::ContentIsDescendantOf. Another crime
 // for XPCOM's rap sheet
 bool // static
 ContentIsDescendantOf(nsINode* aPossibleDescendant,
                       nsINode* aPossibleAncestor)
 {
-  NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
-  NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
+  MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!");
+  MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!");
 
   do {
     if (aPossibleDescendant == aPossibleAncestor)
       return true;
     aPossibleDescendant = aPossibleDescendant->GetParentNode();
   } while (aPossibleDescendant);
 
   return false;
--- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
@@ -82,17 +82,17 @@ typedef void (* OnLeaveNodeFunPtr)(nsINo
 
 // Find the next node in the DOM tree in preorder.
 // Calls OnLeaveNodeFunPtr when the traversal leaves a node, which is
 // why we can't just use GetNextNode here, sadly.
 static nsINode*
 FindNextNode(nsINode* aNode, nsINode* aRoot,
              OnLeaveNodeFunPtr aOnLeaveNode, void* aClosure)
 {
-  NS_PRECONDITION(aNode, "Null starting node?");
+  MOZ_ASSERT(aNode, "Null starting node?");
 
   nsINode* next = aNode->GetFirstChild();
   if (next)
     return next;
 
   // Don't look at siblings or otherwise outside of aRoot
   if (aNode == aRoot)
     return nullptr;
@@ -118,17 +118,17 @@ FindNextNode(nsINode* aNode, nsINode* aR
   }
 }
 
 // aNode is not a text node. Find the first text node starting at aNode/aOffset
 // in a preorder DOM traversal.
 static nsINode*
 FindNextTextNode(nsINode* aNode, int32_t aOffset, nsINode* aRoot)
 {
-  NS_PRECONDITION(aNode, "Null starting node?");
+  MOZ_ASSERT(aNode, "Null starting node?");
   NS_ASSERTION(!IsSpellCheckingTextNode(aNode), "FindNextTextNode should start with a non-text node");
 
   nsINode* checkNode;
   // Need to start at the aOffset'th child
   nsIContent* child = aNode->GetChildAt_Deprecated(aOffset);
 
   if (child) {
     checkNode = child;
@@ -160,17 +160,17 @@ FindNextTextNode(nsINode* aNode, int32_t
 //    There is no beginning soft boundary. This is because we only go to the
 //    previous node once, when finding the previous word boundary in
 //    SetPosition(). You might think of the soft boundary as being this initial
 //    position.
 
 nsresult
 mozInlineSpellWordUtil::SetEnd(nsINode* aEndNode, int32_t aEndOffset)
 {
-  NS_PRECONDITION(aEndNode, "Null end node?");
+  MOZ_ASSERT(aEndNode, "Null end node?");
 
   NS_ASSERTION(mRootNode, "Not initialized");
 
   InvalidateWords();
 
   if (!IsSpellCheckingTextNode(aEndNode)) {
     // End at the start of the first text node after aEndNode/aEndOffset.
     aEndNode = FindNextTextNode(aEndNode, aEndOffset, mRootNode);
--- a/gfx/thebes/gfxDWriteCommon.cpp
+++ b/gfx/thebes/gfxDWriteCommon.cpp
@@ -46,24 +46,24 @@ public:
     }
     else {
       return E_NOINTERFACE;
     }
   }
 
   IFACEMETHOD_(ULONG, AddRef)()
   {
-    NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
+    MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");
     ++mRefCnt;
     return mRefCnt;
   }
 
   IFACEMETHOD_(ULONG, Release)()
   {
-    NS_PRECONDITION(0 != mRefCnt, "dup release");
+    MOZ_ASSERT(0 != mRefCnt, "dup release");
     --mRefCnt;
     if (mRefCnt == 0) {
       delete this;
       return 0;
     }
     return mRefCnt;
   }
 
--- a/gfx/thebes/gfxFT2FontBase.cpp
+++ b/gfx/thebes/gfxFT2FontBase.cpp
@@ -102,17 +102,17 @@ gfxFT2FontBase::GetGlyph(uint32_t aCharC
     }
 
     return slot->mGlyphIndex;
 }
 
 void
 gfxFT2FontBase::GetGlyphExtents(uint32_t aGlyph, cairo_text_extents_t* aExtents)
 {
-    NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL");
+    MOZ_ASSERT(aExtents != nullptr, "aExtents must not be NULL");
 
     cairo_glyph_t glyphs[1];
     glyphs[0].index = aGlyph;
     glyphs[0].x = 0.0;
     glyphs[0].y = 0.0;
     // cairo does some caching for us here but perhaps a small gain could be
     // made by caching more.  It is usually only the advance that is needed,
     // so caching only the advance could allow many requests to be cached with
--- a/gfx/thebes/gfxFT2Utils.cpp
+++ b/gfx/thebes/gfxFT2Utils.cpp
@@ -42,17 +42,17 @@ gfxFT2LockedFace::GetGlyph(uint32_t aCha
 
 typedef FT_UInt (*GetCharVariantFunction)(FT_Face  face,
                                           FT_ULong charcode,
                                           FT_ULong variantSelector);
 
 uint32_t
 gfxFT2LockedFace::GetUVSGlyph(uint32_t aCharCode, uint32_t aVariantSelector)
 {
-    NS_PRECONDITION(aVariantSelector, "aVariantSelector should not be NULL");
+    MOZ_ASSERT(aVariantSelector, "aVariantSelector should not be NULL");
 
     if (MOZ_UNLIKELY(!mFace))
         return 0;
 
     // This function is available from FreeType 2.3.6 (June 2008).
     static CharVariantFunction sGetCharVariantPtr = FindCharVariantFunction();
     if (!sGetCharVariantPtr)
         return 0;
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -4184,17 +4184,17 @@ gfxFontStyle::Hash() const
             uint32_t(size*1000) + int32_t(sizeAdjust*1000)) ^
             nsRefPtrHashKey<nsAtom>::HashKey(language);
     */
 }
 
 void
 gfxFontStyle::AdjustForSubSuperscript(int32_t aAppUnitsPerDevPixel)
 {
-    NS_PRECONDITION(variantSubSuper != NS_FONT_VARIANT_POSITION_NORMAL &&
+    MOZ_ASSERT(variantSubSuper != NS_FONT_VARIANT_POSITION_NORMAL &&
                     baselineOffset == 0,
                     "can't adjust this style for sub/superscript");
 
     // calculate the baseline offset (before changing the size)
     if (variantSubSuper == NS_FONT_VARIANT_POSITION_SUPER) {
         baselineOffset = size * -NS_FONT_SUPERSCRIPT_OFFSET_RATIO;
     } else {
         baselineOffset = size * NS_FONT_SUBSCRIPT_OFFSET_RATIO;
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -1460,26 +1460,26 @@ protected:
     typedef mozilla::SVGContextPaint SVGContextPaint;
 
     typedef gfxFontShaper::RoundingFlags RoundingFlags;
 
 public:
     typedef mozilla::FontSlantStyle FontSlantStyle;
 
     nsrefcnt AddRef(void) {
-        NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
+        MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");
         if (mExpirationState.IsTracked()) {
             gfxFontCache::GetCache()->RemoveObject(this);
         }
         ++mRefCnt;
         NS_LOG_ADDREF(this, mRefCnt, "gfxFont", sizeof(*this));
         return mRefCnt;
     }
     nsrefcnt Release(void) {
-        NS_PRECONDITION(0 != mRefCnt, "dup release");
+        MOZ_ASSERT(0 != mRefCnt, "dup release");
         --mRefCnt;
         NS_LOG_RELEASE(this, mRefCnt, "gfxFont");
         if (mRefCnt == 0) {
             NotifyReleased();
             // |this| may have been deleted.
             return 0;
         }
         return mRefCnt;
--- a/gfx/thebes/gfxFontEntry.h
+++ b/gfx/thebes/gfxFontEntry.h
@@ -45,24 +45,24 @@ namespace mozilla {
 class SVGContextPaint;
 };
 
 #define NO_FONT_LANGUAGE_OVERRIDE      0
 
 class gfxCharacterMap : public gfxSparseBitSet {
 public:
     nsrefcnt AddRef() {
-        NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
+        MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");
         ++mRefCnt;
         NS_LOG_ADDREF(this, mRefCnt, "gfxCharacterMap", sizeof(*this));
         return mRefCnt;
     }
 
     nsrefcnt Release() {
-        NS_PRECONDITION(0 != mRefCnt, "dup release");
+        MOZ_ASSERT(0 != mRefCnt, "dup release");
         --mRefCnt;
         NS_LOG_RELEASE(this, mRefCnt, "gfxCharacterMap");
         if (mRefCnt == 0) {
             NotifyReleased();
             // |this| has been deleted.
             return 0;
         }
         return mRefCnt;
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -861,17 +861,17 @@ gfxTextRun::MeasureText(Range aRange,
 
 #define MEASUREMENT_BUFFER_SIZE 100
 
 void
 gfxTextRun::ClassifyAutoHyphenations(uint32_t aStart, Range aRange,
                                      nsTArray<HyphenType>& aHyphenBuffer,
                                      HyphenationState* aWordState)
 {
-  NS_PRECONDITION(aRange.end - aStart <= aHyphenBuffer.Length() &&
+  MOZ_ASSERT(aRange.end - aStart <= aHyphenBuffer.Length() &&
                   aRange.start >= aStart, "Range out of bounds");
   MOZ_ASSERT(aWordState->mostRecentBoundary >= aStart,
              "Unexpected aMostRecentWordBoundary!!");
 
   uint32_t start = std::min<uint32_t>(aRange.start, aWordState->mostRecentBoundary);
 
   for (uint32_t i = start; i < aRange.end; ++i) {
     if (aHyphenBuffer[i - aStart] == HyphenType::Explicit &&
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -66,17 +66,17 @@ gfxXlibSurface::gfxXlibSurface(Screen *s
 }
 
 gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
     : mPixmapTaken(false)
 #if defined(GL_PROVIDER_GLX)
       , mGLXPixmap(X11None)
 #endif
 {
-    NS_PRECONDITION(cairo_surface_status(csurf) == 0,
+    MOZ_ASSERT(cairo_surface_status(csurf) == 0,
                     "Not expecting an error surface");
 
     mDrawable = cairo_xlib_surface_get_drawable(csurf);
     mDisplay = cairo_xlib_surface_get_display(csurf);
 
     Init(csurf, true);
 }
 
--- a/image/ImageURL.h
+++ b/image/ImageURL.h
@@ -79,18 +79,18 @@ public:
   nsresult GetScheme(nsACString& result)
   {
     result = mScheme;
     return NS_OK;
   }
 
   nsresult SchemeIs(const char* scheme, bool* result)
   {
-    NS_PRECONDITION(scheme, "scheme is null");
-    NS_PRECONDITION(result, "result is null");
+    MOZ_ASSERT(scheme, "scheme is null");
+    MOZ_ASSERT(result, "result is null");
 
     *result = mScheme.Equals(scheme);
     return NS_OK;
   }
 
   nsresult GetRef(nsACString& result)
   {
     result = mRef;
--- a/image/decoders/icon/nsIconURI.cpp
+++ b/image/decoders/icon/nsIconURI.cpp
@@ -466,17 +466,17 @@ nsMozIconURI::SetRef(const nsACString& a
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsMozIconURI::Equals(nsIURI* other, bool* result)
 {
   *result = false;
   NS_ENSURE_ARG_POINTER(other);
-  NS_PRECONDITION(result, "null pointer");
+  MOZ_ASSERT(result, "null pointer");
 
   nsAutoCString spec1;
   nsAutoCString spec2;
 
   nsresult rv = GetSpec(spec1);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = other->GetSpec(spec2);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/image/imgLoader.h
+++ b/image/imgLoader.h
@@ -44,26 +44,26 @@ public:
   static uint32_t SecondsFromPRTime(PRTime prTime);
 
   imgCacheEntry(imgLoader* loader, imgRequest* request,
                 bool aForcePrincipalCheck);
   ~imgCacheEntry();
 
   nsrefcnt AddRef()
   {
-    NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
+    MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");
     NS_ASSERT_OWNINGTHREAD(imgCacheEntry);
     ++mRefCnt;
     NS_LOG_ADDREF(this, mRefCnt, "imgCacheEntry", sizeof(*this));
     return mRefCnt;
   }
 
   nsrefcnt Release()
   {
-    NS_PRECONDITION(0 != mRefCnt, "dup release");
+    MOZ_ASSERT(0 != mRefCnt, "dup release");
     NS_ASSERT_OWNINGTHREAD(imgCacheEntry);
     --mRefCnt;
     NS_LOG_RELEASE(this, mRefCnt, "imgCacheEntry");
     if (mRefCnt == 0) {
       mRefCnt = 1; /* stabilize */
       delete this;
       return 0;
     }
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -209,17 +209,17 @@ imgRequest::ResetCacheEntry()
   if (HasCacheEntry()) {
     mCacheEntry->SetDataSize(0);
   }
 }
 
 void
 imgRequest::AddProxy(imgRequestProxy* proxy)
 {
-  NS_PRECONDITION(proxy, "null imgRequestProxy passed in");
+  MOZ_ASSERT(proxy, "null imgRequestProxy passed in");
   LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequest::AddProxy", "proxy", proxy);
 
   if (!mFirstProxy) {
     // Save a raw pointer to the first proxy we see, for use in the network
     // priority logic.
     mFirstProxy = proxy;
   }
 
--- a/image/imgRequestProxy.cpp
+++ b/image/imgRequestProxy.cpp
@@ -128,17 +128,17 @@ imgRequestProxy::imgRequestProxy() :
 {
   /* member initializers and constructor code */
   LOG_FUNC(gImgLog, "imgRequestProxy::imgRequestProxy");
 }
 
 imgRequestProxy::~imgRequestProxy()
 {
   /* destructor code */
-  NS_PRECONDITION(!mListener,
+  MOZ_ASSERT(!mListener,
                   "Someone forgot to properly cancel this request!");
 
   // If we had a listener, that means we would have issued notifications. With
   // bug 1359833, we added support for main thread scheduler groups. Each
   // imgRequestProxy may have its own associated listener, document and/or
   // scheduler group. Typically most imgRequestProxy belong to the same
   // document, or have no listener, which means we will want to execute all main
   // thread code in that shared scheduler group. Less frequently, there may be
@@ -179,17 +179,17 @@ imgRequestProxy::~imgRequestProxy()
 
 nsresult
 imgRequestProxy::Init(imgRequest* aOwner,
                       nsILoadGroup* aLoadGroup,
                       nsIDocument* aLoadingDocument,
                       ImageURL* aURI,
                       imgINotificationObserver* aObserver)
 {
-  NS_PRECONDITION(!GetOwner() && !mListener,
+  MOZ_ASSERT(!GetOwner() && !mListener,
                   "imgRequestProxy is already initialized");
 
   LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequestProxy::Init", "request",
                        aOwner);
 
   MOZ_ASSERT(mAnimationConsumers == 0, "Cannot have animation before Init");
 
   mBehaviour->SetOwner(aOwner);
@@ -209,17 +209,17 @@ imgRequestProxy::Init(imgRequest* aOwner
   AddToOwner(aLoadingDocument);
 
   return NS_OK;
 }
 
 nsresult
 imgRequestProxy::ChangeOwner(imgRequest* aNewOwner)
 {
-  NS_PRECONDITION(GetOwner(),
+  MOZ_ASSERT(GetOwner(),
                   "Cannot ChangeOwner on a proxy without an owner!");
 
   if (mCanceled) {
     // Ensure that this proxy has received all notifications to date
     // before we clean it up when removing it from the old owner below.
     SyncNotifyListener();
   }
 
@@ -858,17 +858,17 @@ nsresult imgRequestProxy::Clone(imgINoti
 }
 
 nsresult
 imgRequestProxy::PerformClone(imgINotificationObserver* aObserver,
                               nsIDocument* aLoadingDocument,
                               bool aSyncNotify,
                               imgRequestProxy** aClone)
 {
-  NS_PRECONDITION(aClone, "Null out param");
+  MOZ_ASSERT(aClone, "Null out param");
 
   LOG_SCOPE(gImgLog, "imgRequestProxy::Clone");
 
   *aClone = nullptr;
   RefPtr<imgRequestProxy> clone = NewClonedProxy();
 
   nsCOMPtr<nsILoadGroup> loadGroup;
   if (aLoadingDocument) {
@@ -1132,17 +1132,17 @@ imgRequestProxy::OnLoadComplete(bool aLa
     } else {
       // More data is coming, so change the request to be a background request
       // and put it back in the loadgroup.
       MoveToBackgroundInLoadGroup();
     }
   }
 
   if (mListenerIsStrongRef && aLastPart) {
-    NS_PRECONDITION(mListener, "How did that happen?");
+    MOZ_ASSERT(mListener, "How did that happen?");
     // Drop our strong ref to the listener now that we're done with
     // everything.  Note that this can cancel us and other fun things
     // like that.  Don't add anything in this method after this point.
     imgINotificationObserver* obs = mListener;
     mListenerIsStrongRef = false;
     NS_RELEASE(obs);
   }
 }
--- a/intl/lwbrk/WordBreaker.cpp
+++ b/intl/lwbrk/WordBreaker.cpp
@@ -17,18 +17,18 @@ WordBreaker::Create()
   return RefPtr<WordBreaker>(new WordBreaker()).forget();
 }
 
 
 bool WordBreaker::BreakInBetween(
   const char16_t* aText1 , uint32_t aTextLen1,
   const char16_t* aText2 , uint32_t aTextLen2)
 {
-  NS_PRECONDITION( nullptr != aText1, "null ptr");
-  NS_PRECONDITION( nullptr != aText2, "null ptr");
+  MOZ_ASSERT( nullptr != aText1, "null ptr");
+  MOZ_ASSERT( nullptr != aText2, "null ptr");
 
   if(!aText1 || !aText2 || (0 == aTextLen1) || (0 == aTextLen2))
     return false;
 
   return GetClass(aText1[aTextLen1-1]) != GetClass(aText2[0]);
 }
 
 
@@ -87,19 +87,19 @@ WordBreaker::GetClass(char16_t c)
   return static_cast<WordBreakClass>(0);
 }
 
 WordRange WordBreaker::FindWord(
   const char16_t* aText , uint32_t aTextLen,
   uint32_t aOffset)
 {
   WordRange range;
-  NS_PRECONDITION( nullptr != aText, "null ptr");
-  NS_PRECONDITION( 0 != aTextLen, "len = 0");
-  NS_PRECONDITION( aOffset <= aTextLen, "aOffset > aTextLen");
+  MOZ_ASSERT(nullptr != aText, "null ptr");
+  MOZ_ASSERT(0 != aTextLen, "len = 0");
+  MOZ_ASSERT(aOffset <= aTextLen, "aOffset > aTextLen");
 
   range.mBegin = aTextLen + 1;
   range.mEnd = aTextLen + 1;
 
   if(!aText || aOffset > aTextLen)
     return range;
 
   WordBreakClass c = GetClass(aText[aOffset]);
--- a/intl/uconv/nsConverterOutputStream.cpp
+++ b/intl/uconv/nsConverterOutputStream.cpp
@@ -22,17 +22,17 @@ nsConverterOutputStream::~nsConverterOut
 {
     Close();
 }
 
 NS_IMETHODIMP
 nsConverterOutputStream::Init(nsIOutputStream* aOutStream,
                               const char* aCharset)
 {
-    NS_PRECONDITION(aOutStream, "Null output stream!");
+    MOZ_ASSERT(aOutStream, "Null output stream!");
 
     const Encoding* encoding;
     if (!aCharset) {
       encoding = UTF_8_ENCODING;
     } else {
       encoding = Encoding::ForLabelNoReplacement(MakeStringSpan(aCharset));
       if (!encoding || encoding == UTF_16LE_ENCODING ||
           encoding == UTF_16BE_ENCODING) {
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -771,17 +771,17 @@ MessageChannel::Clear()
     while (!mDeferred.empty()) {
         mDeferred.pop();
     }
 }
 
 bool
 MessageChannel::Open(Transport* aTransport, MessageLoop* aIOLoop, Side aSide)
 {
-    NS_PRECONDITION(!mLink, "Open() called > once");
+    MOZ_ASSERT(!mLink, "Open() called > once");
 
     mMonitor = new RefCountedMonitor();
     mWorkerLoop = MessageLoop::current();
     mWorkerThread = GetCurrentVirtualThread();
     mWorkerLoop->AddDestructionObserver(this);
     mListener->SetIsMainThreadProtocol();
 
     ProcessLink *link = new ProcessLink(this);
@@ -803,18 +803,18 @@ MessageChannel::Open(MessageChannel *aTa
     //    Let PA be the one appropriate to A and PB the side for B.
     //  - A invokes PA->Open(PB, ...):
     //    - set state to mChannelOpening
     //    - this will place a work item in B's worker loop (see next bullet)
     //      and then spins until PB->mChannelState becomes mChannelConnected
     //    - meanwhile, on PB's worker loop, the work item is removed and:
     //      - invokes PB->SlaveOpen(PA, ...):
     //        - sets its state and that of PA to Connected
-    NS_PRECONDITION(aTargetChan, "Need a target channel");
-    NS_PRECONDITION(ChannelClosed == mChannelState, "Not currently closed");
+    MOZ_ASSERT(aTargetChan, "Need a target channel");
+    MOZ_ASSERT(ChannelClosed == mChannelState, "Not currently closed");
 
     CommonThreadOpenInit(aTargetChan, aSide);
 
     Side oppSide = UnknownSide;
     switch(aSide) {
       case ChildSide: oppSide = ParentSide; break;
       case ParentSide: oppSide = ChildSide; break;
       case UnknownSide: break;
@@ -836,19 +836,19 @@ MessageChannel::Open(MessageChannel *aTa
     MOZ_RELEASE_ASSERT(ChannelConnected == mChannelState, "not connected when awoken");
     return (ChannelConnected == mChannelState);
 }
 
 void
 MessageChannel::OnOpenAsSlave(MessageChannel *aTargetChan, Side aSide)
 {
     // Invoked when the other side has begun the open.
-    NS_PRECONDITION(ChannelClosed == mChannelState,
+    MOZ_ASSERT(ChannelClosed == mChannelState,
                     "Not currently closed");
-    NS_PRECONDITION(ChannelOpening == aTargetChan->mChannelState,
+    MOZ_ASSERT(ChannelOpening == aTargetChan->mChannelState,
                     "Target channel not in the process of opening");
 
     CommonThreadOpenInit(aTargetChan, aSide);
     mMonitor = aTargetChan->mMonitor;
 
     MonitorAutoLock lock(*mMonitor);
     MOZ_RELEASE_ASSERT(ChannelOpening == aTargetChan->mChannelState,
                           "Target channel not in the process of opening");
--- a/ipc/glue/MessageLink.cpp
+++ b/ipc/glue/MessageLink.cpp
@@ -67,32 +67,32 @@ ProcessLink::~ProcessLink()
 #endif
 }
 
 void
 ProcessLink::Open(mozilla::ipc::Transport* aTransport, MessageLoop *aIOLoop, Side aSide)
 {
     mChan->AssertWorkerThread();
 
-    NS_PRECONDITION(aTransport, "need transport layer");
+    MOZ_ASSERT(aTransport, "need transport layer");
 
     // FIXME need to check for valid channel
 
     mTransport = aTransport;
 
     // FIXME figure out whether we're in parent or child, grab IO loop
     // appropriately
     bool needOpen = true;
     if(aIOLoop) {
         // We're a child or using the new arguments.  Either way, we
         // need an open.
         needOpen = true;
         mChan->mSide = (aSide == UnknownSide) ? ChildSide : aSide;
     } else {
-        NS_PRECONDITION(aSide == UnknownSide, "expected default side arg");
+        MOZ_ASSERT(aSide == UnknownSide, "expected default side arg");
 
         // parent
         mChan->mSide = ParentSide;
         needOpen = false;
         aIOLoop = XRE_GetIOMessageLoop();
     }
 
     mIOLoop = aIOLoop;
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -96,17 +96,17 @@ XPCConvert::GetISupportsFromJSObject(JSO
 
 /***************************************************************************/
 
 // static
 bool
 XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
                           const nsXPTType& type, const nsID* iid, nsresult* pErr)
 {
-    NS_PRECONDITION(s, "bad param");
+    MOZ_ASSERT(s, "bad param");
 
     AutoJSContext cx;
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
     switch (type.TagPart()) {
     case nsXPTType::T_I8    :
         d.setInt32(*static_cast<const int8_t*>(s));
@@ -399,17 +399,17 @@ bool ConvertToPrimitive(JSContext* cx, H
 
 // static
 bool
 XPCConvert::JSData2Native(void* d, HandleValue s,
                           const nsXPTType& type,
                           const nsID* iid,
                           nsresult* pErr)
 {
-    NS_PRECONDITION(d, "bad param");
+    MOZ_ASSERT(d, "bad param");
 
     AutoJSContext cx;
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
 
     switch (type.TagPart()) {
     case nsXPTType::T_I8     :
         return ConvertToPrimitive(cx, s, static_cast<int8_t*>(d));
@@ -1237,17 +1237,17 @@ XPCConvert::JSValToXPCException(MutableH
 #endif
 
 // static
 bool
 XPCConvert::NativeArray2JS(MutableHandleValue d, const void** s,
                            const nsXPTType& type, const nsID* iid,
                            uint32_t count, nsresult* pErr)
 {
-    NS_PRECONDITION(s, "bad param");
+    MOZ_ASSERT(s, "bad param");
 
     AutoJSContext cx;
 
     // XXX add support for putting chars in a string rather than an array
 
     // XXX add support to indicate *which* array element was not convertable
 
     RootedObject array(cx, JS_NewArrayObject(cx, count));
@@ -1634,17 +1634,17 @@ failure:
 
 // static
 bool
 XPCConvert::NativeStringWithSize2JS(MutableHandleValue d, const void* s,
                                     const nsXPTType& type,
                                     uint32_t count,
                                     nsresult* pErr)
 {
-    NS_PRECONDITION(s, "bad param");
+    MOZ_ASSERT(s, "bad param");
 
     AutoJSContext cx;
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
     switch (type.TagPart()) {
         case nsXPTType::T_PSTRING_SIZE_IS:
         {
@@ -1676,18 +1676,18 @@ XPCConvert::NativeStringWithSize2JS(Muta
 }
 
 // static
 bool
 XPCConvert::JSStringWithSize2Native(void* d, HandleValue s,
                                     uint32_t count, const nsXPTType& type,
                                     nsresult* pErr)
 {
-    NS_PRECONDITION(!s.isNull(), "bad param");
-    NS_PRECONDITION(d, "bad param");
+    MOZ_ASSERT(!s.isNull(), "bad param");
+    MOZ_ASSERT(d, "bad param");
 
     AutoJSContext cx;
     uint32_t len;
 
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
     switch (type.TagPart()) {
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -40,44 +40,44 @@ public:
             // entry storage. The |2| is because on average the capacity is
             // twice the requested length.
             NS_ABORT_OOM(length * 2 * sizeof(Map::Entry));
         }
         return map;
     }
 
     inline nsXPCWrappedJS* Find(JSObject* Obj) {
-        NS_PRECONDITION(Obj,"bad param");
+        MOZ_ASSERT(Obj,"bad param");
         Map::Ptr p = mTable.lookup(Obj);
         return p ? p->value() : nullptr;
     }
 
 #ifdef DEBUG
     inline bool HasWrapper(nsXPCWrappedJS* wrapper) {
         for (auto r = mTable.all(); !r.empty(); r.popFront()) {
             if (r.front().value() == wrapper)
                 return true;
         }
         return false;
     }
 #endif
 
     inline nsXPCWrappedJS* Add(JSContext* cx, nsXPCWrappedJS* wrapper) {
-        NS_PRECONDITION(wrapper,"bad param");
+        MOZ_ASSERT(wrapper,"bad param");
         JSObject* obj = wrapper->GetJSObjectPreserveColor();
         Map::AddPtr p = mTable.lookupForAdd(obj);
         if (p)
             return p->value();
         if (!mTable.add(p, obj, wrapper))
             return nullptr;
         return wrapper;
     }
 
     inline void Remove(nsXPCWrappedJS* wrapper) {
-        NS_PRECONDITION(wrapper,"bad param");
+        MOZ_ASSERT(wrapper,"bad param");
         mTable.remove(wrapper->GetJSObjectPreserveColor());
     }
 
     inline uint32_t Count() {return mTable.count();}
 
     inline void Dump(int16_t depth) {
         for (Map::Range r = mTable.all(); !r.empty(); r.popFront())
             r.front().value()->DebugDump(depth);
@@ -109,39 +109,39 @@ public:
         nsISupports*      key;
         XPCWrappedNative* value;
     };
 
     static Native2WrappedNativeMap* newMap(int length);
 
     inline XPCWrappedNative* Find(nsISupports* Obj)
     {
-        NS_PRECONDITION(Obj,"bad param");
+        MOZ_ASSERT(Obj,"bad param");
         auto entry = static_cast<Entry*>(mTable.Search(Obj));
         return entry ? entry->value : nullptr;
     }
 
     inline XPCWrappedNative* Add(XPCWrappedNative* wrapper)
     {
-        NS_PRECONDITION(wrapper,"bad param");
+        MOZ_ASSERT(wrapper,"bad param");
         nsISupports* obj = wrapper->GetIdentityObject();
         MOZ_ASSERT(!Find(obj), "wrapper already in new scope!");
         auto entry = static_cast<Entry*>(mTable.Add(obj, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = obj;
         entry->value = wrapper;
         return wrapper;
     }
 
     inline void Remove(XPCWrappedNative* wrapper)
     {
-        NS_PRECONDITION(wrapper,"bad param");
+        MOZ_ASSERT(wrapper,"bad param");
 #ifdef DEBUG
         XPCWrappedNative* wrapperInMap = Find(wrapper->GetIdentityObject());
         MOZ_ASSERT(!wrapperInMap || wrapperInMap == wrapper,
                    "About to remove a different wrapper with the same "
                    "nsISupports identity! This will most likely cause serious "
                    "problems!");
 #endif
         mTable.Remove(wrapper->GetIdentityObject());
@@ -181,31 +181,31 @@ public:
     inline nsXPCWrappedJSClass* Find(REFNSIID iid)
     {
         auto entry = static_cast<Entry*>(mTable.Search(&iid));
         return entry ? entry->value : nullptr;
     }
 
     inline nsXPCWrappedJSClass* Add(nsXPCWrappedJSClass* clazz)
     {
-        NS_PRECONDITION(clazz,"bad param");
+        MOZ_ASSERT(clazz,"bad param");
         const nsIID* iid = &clazz->GetIID();
         auto entry = static_cast<Entry*>(mTable.Add(iid, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = iid;
         entry->value = clazz;
         return clazz;
     }
 
     inline void Remove(nsXPCWrappedJSClass* clazz)
     {
-        NS_PRECONDITION(clazz,"bad param");
+        MOZ_ASSERT(clazz,"bad param");
         mTable.Remove(&clazz->GetIID());
     }
 
     inline uint32_t Count() { return mTable.EntryCount(); }
 
 #ifdef DEBUG
     PLDHashTable::Iterator Iter() { return mTable.Iter(); }
 #endif
@@ -235,31 +235,31 @@ public:
     inline XPCNativeInterface* Find(REFNSIID iid)
     {
         auto entry = static_cast<Entry*>(mTable.Search(&iid));
         return entry ? entry->value : nullptr;
     }
 
     inline XPCNativeInterface* Add(XPCNativeInterface* iface)
     {
-        NS_PRECONDITION(iface,"bad param");
+        MOZ_ASSERT(iface,"bad param");
         const nsIID* iid = iface->GetIID();
         auto entry = static_cast<Entry*>(mTable.Add(iid, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = iid;
         entry->value = iface;
         return iface;
     }
 
     inline void Remove(XPCNativeInterface* iface)
     {
-        NS_PRECONDITION(iface,"bad param");
+        MOZ_ASSERT(iface,"bad param");
         mTable.Remove(iface->GetIID());
     }
 
     inline uint32_t Count() { return mTable.EntryCount(); }
 
     PLDHashTable::Iterator Iter() { return mTable.Iter(); }
 
     size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
@@ -293,30 +293,30 @@ public:
     inline XPCNativeSet* Find(nsIClassInfo* info)
     {
         auto entry = static_cast<Entry*>(mTable.Search(info));
         return entry ? entry->value : nullptr;
     }
 
     inline XPCNativeSet* Add(nsIClassInfo* info, XPCNativeSet* set)
     {
-        NS_PRECONDITION(info,"bad param");
+        MOZ_ASSERT(info,"bad param");
         auto entry = static_cast<Entry*>(mTable.Add(info, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = info;
         NS_ADDREF(entry->value = set);
         return set;
     }
 
     inline void Remove(nsIClassInfo* info)
     {
-        NS_PRECONDITION(info,"bad param");
+        MOZ_ASSERT(info,"bad param");
         mTable.Remove(info);
     }
 
     inline uint32_t Count() { return mTable.EntryCount(); }
 
     // ClassInfo2NativeSetMap holds pointers to *some* XPCNativeSets.
     // So we don't want to count those XPCNativeSets, because they are better
     // counted elsewhere (i.e. in XPCJSContext::mNativeSetMap, which holds
@@ -346,30 +346,30 @@ public:
     inline XPCWrappedNativeProto* Find(nsIClassInfo* info)
     {
         auto entry = static_cast<Entry*>(mTable.Search(info));
         return entry ? entry->value : nullptr;
     }
 
     inline XPCWrappedNativeProto* Add(nsIClassInfo* info, XPCWrappedNativeProto* proto)
     {
-        NS_PRECONDITION(info,"bad param");
+        MOZ_ASSERT(info,"bad param");
         auto entry = static_cast<Entry*>(mTable.Add(info, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = info;
         entry->value = proto;
         return proto;
     }
 
     inline void Remove(nsIClassInfo* info)
     {
-        NS_PRECONDITION(info,"bad param");
+        MOZ_ASSERT(info,"bad param");
         mTable.Remove(info);
     }
 
     inline void Clear() { mTable.Clear(); }
 
     inline uint32_t Count() { return mTable.EntryCount(); }
 
     PLDHashTable::Iterator Iter() { return mTable.Iter(); }
@@ -462,30 +462,30 @@ class XPCWrappedNativeProtoMap
 {
 public:
     typedef PLDHashEntryStub Entry;
 
     static XPCWrappedNativeProtoMap* newMap(int length);
 
     inline XPCWrappedNativeProto* Add(XPCWrappedNativeProto* proto)
     {
-        NS_PRECONDITION(proto,"bad param");
+        MOZ_ASSERT(proto,"bad param");
         auto entry = static_cast<PLDHashEntryStub*>
                                 (mTable.Add(proto, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return (XPCWrappedNativeProto*) entry->key;
         entry->key = proto;
         return proto;
     }
 
     inline void Remove(XPCWrappedNativeProto* proto)
     {
-        NS_PRECONDITION(proto,"bad param");
+        MOZ_ASSERT(proto,"bad param");
         mTable.Remove(proto);
     }
 
     inline uint32_t Count() { return mTable.EntryCount(); }
 
     PLDHashTable::Iterator Iter() { return mTable.Iter(); }
 
 private:
@@ -512,36 +512,36 @@ public:
             // entry storage. The |2| is because on average the capacity is
             // twice the requested length.
             NS_ABORT_OOM(length * 2 * sizeof(Map::Entry));
         }
         return map;
     }
 
     inline JSObject* Find(JSObject* key) {
-        NS_PRECONDITION(key, "bad param");
+        MOZ_ASSERT(key, "bad param");
         if (Map::Ptr p = mTable.lookup(key))
             return p->value();
         return nullptr;
     }
 
     /* Note: If the entry already exists, return the old value. */
     inline JSObject* Add(JSContext* cx, JSObject* key, JSObject* value) {
-        NS_PRECONDITION(key,"bad param");
+        MOZ_ASSERT(key,"bad param");
         Map::AddPtr p = mTable.lookupForAdd(key);
         if (p)
             return p->value();
         if (!mTable.add(p, key, value))
             return nullptr;
         MOZ_ASSERT(xpc::RealmPrivate::Get(key)->scope->mWaiverWrapperMap == this);
         return value;
     }
 
     inline void Remove(JSObject* key) {
-        NS_PRECONDITION(key,"bad param");
+        MOZ_ASSERT(key,"bad param");
         mTable.remove(key);
     }
 
     inline uint32_t Count() { return mTable.count(); }
 
     void Sweep() {
         mTable.sweep();
     }
--- a/js/xpconnect/src/XPCWrappedJS.cpp
+++ b/js/xpconnect/src/XPCWrappedJS.cpp
@@ -178,17 +178,17 @@ nsXPCWrappedJS::AggregatedQueryInterface
 
     return mClass->DelegatedQueryInterface(this, aIID, aInstancePtr);
 }
 
 NS_IMETHODIMP
 nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr)
 {
     if (nullptr == aInstancePtr) {
-        NS_PRECONDITION(false, "null pointer");
+        MOZ_ASSERT(false, "null pointer");
         return NS_ERROR_NULL_POINTER;
     }
 
     *aInstancePtr = nullptr;
 
     if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) {
         *aInstancePtr = NS_CYCLE_COLLECTION_PARTICIPANT(nsXPCWrappedJS);
         return NS_OK;
@@ -609,17 +609,17 @@ nsXPCWrappedJS::CallMethod(uint16_t meth
     if (!IsValid())
         return NS_ERROR_UNEXPECTED;
     return GetClass()->CallMethod(this, methodIndex, info, params);
 }
 
 NS_IMETHODIMP
 nsXPCWrappedJS::GetInterfaceIID(nsIID** iid)
 {
-    NS_PRECONDITION(iid, "bad param");
+    MOZ_ASSERT(iid, "bad param");
 
     *iid = GetIID().Clone();
     return NS_OK;
 }
 
 void
 nsXPCWrappedJS::SystemIsBeingShutDown()
 {
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -33,17 +33,17 @@ using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS(nsXPCWrappedJSClass, nsIXPCWrappedJSClass)
 
 // the value of this variable is never used - we use its address as a sentinel
 static uint32_t zero_methods_descriptor;
 
 bool AutoScriptEvaluate::StartEvaluating(HandleObject scope)
 {
-    NS_PRECONDITION(!mEvaluated, "AutoScriptEvaluate::Evaluate should only be called once");
+    MOZ_ASSERT(!mEvaluated, "AutoScriptEvaluate::Evaluate should only be called once");
 
     if (!mJSContext)
         return true;
 
     mEvaluated = true;
 
     JS_BeginRequest(mJSContext);
     mAutoCompartment.emplace(mJSContext, scope);
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -662,17 +662,17 @@ nsXPConnect::WrapJS(JSContext * aJSConte
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::JSValToVariant(JSContext* cx,
                             HandleValue aJSVal,
                             nsIVariant** aResult)
 {
-    NS_PRECONDITION(aResult, "bad param");
+    MOZ_ASSERT(aResult, "bad param");
 
     RefPtr<XPCVariant> variant = XPCVariant::newVariant(cx, aJSVal);
     variant.forget(aResult);
     NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
     return NS_OK;
 }
 
@@ -874,19 +874,19 @@ nsXPConnect::DebugDumpJSStack(bool showA
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::VariantToJS(JSContext* ctx, JSObject* scopeArg, nsIVariant* value,
                          MutableHandleValue _retval)
 {
-    NS_PRECONDITION(ctx, "bad param");
-    NS_PRECONDITION(scopeArg, "bad param");
-    NS_PRECONDITION(value, "bad param");
+    MOZ_ASSERT(ctx, "bad param");
+    MOZ_ASSERT(scopeArg, "bad param");
+    MOZ_ASSERT(value, "bad param");
 
     RootedObject scope(ctx, scopeArg);
     MOZ_ASSERT(js::IsObjectInContextCompartment(scope, ctx));
 
     nsresult rv = NS_OK;
     if (!XPCVariant::VariantDataToJS(value, &rv, _retval)) {
         if (NS_FAILED(rv))
             return rv;
@@ -894,18 +894,18 @@ nsXPConnect::VariantToJS(JSContext* ctx,
         return NS_ERROR_FAILURE;
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::JSToVariant(JSContext* ctx, HandleValue value, nsIVariant** _retval)
 {
-    NS_PRECONDITION(ctx, "bad param");
-    NS_PRECONDITION(_retval, "bad param");
+    MOZ_ASSERT(ctx, "bad param");
+    MOZ_ASSERT(_retval, "bad param");
 
     RefPtr<XPCVariant> variant = XPCVariant::newVariant(ctx, value);
     variant.forget(_retval);
     if (!(*_retval))
         return NS_ERROR_FAILURE;
 
     return NS_OK;
 }
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -906,20 +906,20 @@ PresShell::~PresShell()
  * calls AddRef() on us.
  */
 void
 PresShell::Init(nsIDocument* aDocument,
                 nsPresContext* aPresContext,
                 nsViewManager* aViewManager,
                 UniquePtr<ServoStyleSet> aStyleSet)
 {
-  NS_PRECONDITION(aDocument, "null ptr");
-  NS_PRECONDITION(aPresContext, "null ptr");
-  NS_PRECONDITION(aViewManager, "null ptr");
-  NS_PRECONDITION(!mDocument, "already initialized");
+  MOZ_ASSERT(aDocument, "null ptr");
+  MOZ_ASSERT(aPresContext, "null ptr");
+  MOZ_ASSERT(aViewManager, "null ptr");
+  MOZ_ASSERT(!mDocument, "already initialized");
 
   if (!aDocument || !aPresContext || !aViewManager || mDocument) {
     return;
   }
 
   mDocument = aDocument;
   mViewManager = aViewManager;
 
@@ -1927,17 +1927,17 @@ PresShell::ResizeReflow(nscoord aWidth, 
                                     aOldHeight, aOptions);
 }
 
 nsresult
 PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight,
                                       nscoord aOldWidth, nscoord aOldHeight,
                                       ResizeReflowOptions aOptions)
 {
-  NS_PRECONDITION(!mIsReflowing, "Shouldn't be in reflow here!");
+  MOZ_ASSERT(!mIsReflowing, "Shouldn't be in reflow here!");
 
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
   if (!rootFrame) {
     // If we don't have a root frame yet, that means we haven't had our initial
     // reflow... If that's the case, and aWidth or aHeight is unconstrained,
     // ignore them altogether.
     if (aHeight == NS_UNCONSTRAINEDSIZE || aWidth == NS_UNCONSTRAINEDSIZE) {
       // We can't do the work needed for SizeToContent without a root
@@ -2539,17 +2539,17 @@ PresShell::BeginUpdate(nsIDocument *aDoc
   if (aUpdateType & UPDATE_STYLE)
     mStyleSet->BeginUpdate();
 }
 
 void
 PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
 {
 #ifdef DEBUG
-  NS_PRECONDITION(0 != mUpdateCount, "too many EndUpdate's");
+  MOZ_ASSERT(0 != mUpdateCount, "too many EndUpdate's");
   --mUpdateCount;
 #endif
 
   if (aUpdateType & UPDATE_STYLE) {
     mStyleSet->EndUpdate();
     if (mStyleSet->StyleSheetsHaveChanged()) {
       RestyleForCSSRuleChanges();
     }
@@ -2599,17 +2599,17 @@ PresShell::BeginLoad(nsIDocument *aDocum
            ("(presshell) %p load begin [%s]\n",
             this, uri ? uri->GetSpecOrDefault().get() : ""));
   }
 }
 
 void
 PresShell::EndLoad(nsIDocument *aDocument)
 {
-  NS_PRECONDITION(aDocument == mDocument, "Wrong document");
+  MOZ_ASSERT(aDocument == mDocument, "Wrong document");
 
   RestoreRootScrollPosition();
 
   mDocumentLoading = false;
 }
 
 void
 PresShell::LoadComplete()
@@ -2672,17 +2672,17 @@ PresShell::VerifyHasDirtyRootAncestor(ns
 }
 #endif
 
 void
 PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
                             nsFrameState aBitToAdd,
                             ReflowRootHandling aRootHandling)
 {
-  NS_PRECONDITION(aBitToAdd == NS_FRAME_IS_DIRTY ||
+  MOZ_ASSERT(aBitToAdd == NS_FRAME_IS_DIRTY ||
                   aBitToAdd == NS_FRAME_HAS_DIRTY_CHILDREN ||
                   !aBitToAdd,
                   "Unexpected bits being added");
 
   // FIXME removeAttribute bug 478135
   NS_ASSERTION(!(aIntrinsicDirty == eStyleChange &&
                  aBitToAdd == NS_FRAME_HAS_DIRTY_CHILDREN),
                "bits don't correspond to style change reason");
@@ -2833,17 +2833,17 @@ PresShell::FrameNeedsReflow(nsIFrame *aF
 
   MaybeScheduleReflow();
 }
 
 void
 PresShell::FrameNeedsToContinueReflow(nsIFrame *aFrame)
 {
   NS_ASSERTION(mIsReflowing, "Must be in reflow when marking path dirty.");
-  NS_PRECONDITION(mCurrentReflowRoot, "Must have a current reflow root here");
+  MOZ_ASSERT(mCurrentReflowRoot, "Must have a current reflow root here");
   NS_ASSERTION(aFrame == mCurrentReflowRoot ||
                nsLayoutUtils::IsProperAncestorFrame(mCurrentReflowRoot, aFrame),
                "Frame passed in is not the descendant of mCurrentReflowRoot");
   NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_IN_REFLOW,
                "Frame passed in not in reflow?");
 
   mFramesToDirty.PutEntry(aFrame);
 }
@@ -3901,17 +3901,17 @@ nsIPresShell::ClearMouseCapture(nsIFrame
     gCaptureInfo.mContent = nullptr;
     gCaptureInfo.mAllowed = false;
   }
 }
 
 nsresult
 PresShell::CaptureHistoryState(nsILayoutHistoryState** aState)
 {
-  NS_PRECONDITION(nullptr != aState, "null state pointer");
+  MOZ_ASSERT(nullptr != aState, "null state pointer");
 
   // We actually have to mess with the docshell here, since we want to
   // store the state back in it.
   // XXXbz this isn't really right, since this is being called in the
   // content viewer's Hide() method...  by that point the docshell's
   // state could be wrong.  We should sort out a better ownership
   // model for the layout history state.
   nsCOMPtr<nsIDocShell> docShell(mPresContext->GetDocShell());
@@ -4375,44 +4375,44 @@ PresShell::DoFlushPendingNotifications(m
     SetNeedLayoutFlush();
   }
 }
 
 void
 PresShell::CharacterDataChanged(nsIContent* aContent,
                                 const CharacterDataChangeInfo& aInfo)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected CharacterDataChanged");
-  NS_PRECONDITION(aContent->OwnerDoc() == mDocument, "Unexpected document");
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected CharacterDataChanged");
+  MOZ_ASSERT(aContent->OwnerDoc() == mDocument, "Unexpected document");
 
   nsAutoCauseReflowNotifier crNotifier(this);
 
   mPresContext->RestyleManager()->CharacterDataChanged(aContent, aInfo);
   mFrameConstructor->CharacterDataChanged(aContent, aInfo);
 }
 
 void
 PresShell::ContentStateChanged(nsIDocument* aDocument,
                                nsIContent* aContent,
                                EventStates aStateMask)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentStateChanged");
-  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentStateChanged");
+  MOZ_ASSERT(aDocument == mDocument, "Unexpected aDocument");
 
   if (mDidInitialize) {
     nsAutoCauseReflowNotifier crNotifier(this);
     mPresContext->RestyleManager()->ContentStateChanged(aContent, aStateMask);
   }
 }
 
 void
 PresShell::DocumentStatesChanged(nsIDocument* aDocument, EventStates aStateMask)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected DocumentStatesChanged");
-  NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected DocumentStatesChanged");
+  MOZ_ASSERT(aDocument == mDocument, "Unexpected aDocument");
   MOZ_ASSERT(!aStateMask.IsEmpty());
 
   if (mDidInitialize) {
     mStyleSet->InvalidateStyleForDocumentStateChanges(aStateMask);
   }
 
   if (aStateMask.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
     if (nsIFrame* root = mFrameConstructor->GetRootFrame()) {
@@ -4423,18 +4423,18 @@ PresShell::DocumentStatesChanged(nsIDocu
 
 void
 PresShell::AttributeWillChange(Element* aElement,
                                int32_t aNameSpaceID,
                                nsAtom* aAttribute,
                                int32_t aModType,
                                const nsAttrValue* aNewValue)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeWillChange");
-  NS_PRECONDITION(aElement->OwnerDoc() == mDocument, "Unexpected document");
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected AttributeWillChange");
+  MOZ_ASSERT(aElement->OwnerDoc() == mDocument, "Unexpected document");
 
   // XXXwaterson it might be more elegant to wait until after the
   // initial reflow to begin observing the document. That would
   // squelch any other inappropriate notifications as well.
   if (mDidInitialize) {
     nsAutoCauseReflowNotifier crNotifier(this);
     mPresContext->RestyleManager()->AttributeWillChange(aElement, aNameSpaceID,
                                                         aAttribute, aModType,
@@ -4444,35 +4444,35 @@ PresShell::AttributeWillChange(Element* 
 
 void
 PresShell::AttributeChanged(Element* aElement,
                             int32_t aNameSpaceID,
                             nsAtom* aAttribute,
                             int32_t aModType,
                             const nsAttrValue* aOldValue)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeChanged");
-  NS_PRECONDITION(aElement->OwnerDoc() == mDocument, "Unexpected document");
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected AttributeChanged");
+  MOZ_ASSERT(aElement->OwnerDoc() == mDocument, "Unexpected document");
 
   // XXXwaterson it might be more elegant to wait until after the
   // initial reflow to begin observing the document. That would
   // squelch any other inappropriate notifications as well.
   if (mDidInitialize) {
     nsAutoCauseReflowNotifier crNotifier(this);
     mPresContext->RestyleManager()->AttributeChanged(aElement, aNameSpaceID,
                                                      aAttribute, aModType,
                                                      aOldValue);
   }
 }
 
 void
 PresShell::ContentAppended(nsIContent* aFirstNewContent)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentAppended");
-  NS_PRECONDITION(aFirstNewContent->OwnerDoc() == mDocument,
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentAppended");
+  MOZ_ASSERT(aFirstNewContent->OwnerDoc() == mDocument,
                   "Unexpected document");
 
   // We never call ContentAppended with a document as the container, so we can
   // assert that we have an nsIContent parent.
   MOZ_ASSERT(aFirstNewContent->GetParent());
   MOZ_ASSERT(aFirstNewContent->GetParent()->IsElement() ||
              aFirstNewContent->GetParent()->IsShadowRoot());
 
@@ -4490,18 +4490,18 @@ PresShell::ContentAppended(nsIContent* a
   mFrameConstructor->ContentAppended(
       aFirstNewContent,
       nsCSSFrameConstructor::InsertionKind::Async);
 }
 
 void
 PresShell::ContentInserted(nsIContent* aChild)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentInserted");
-  NS_PRECONDITION(aChild->OwnerDoc() == mDocument, "Unexpected document");
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentInserted");
+  MOZ_ASSERT(aChild->OwnerDoc() == mDocument, "Unexpected document");
 
   if (!mDidInitialize) {
     return;
   }
 
   nsAutoCauseReflowNotifier crNotifier(this);
 
   // Call this here so it only happens for real content mutations and
@@ -4513,18 +4513,18 @@ PresShell::ContentInserted(nsIContent* a
       aChild,
       nullptr,
       nsCSSFrameConstructor::InsertionKind::Async);
 }
 
 void
 PresShell::ContentRemoved(nsIContent* aChild, nsIContent* aPreviousSibling)
 {
-  NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentRemoved");
-  NS_PRECONDITION(aChild->OwnerDoc() == mDocument, "Unexpected document");
+  MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentRemoved");
+  MOZ_ASSERT(aChild->OwnerDoc() == mDocument, "Unexpected document");
   nsINode* container = aChild->GetParentNode();
 
   // Notify the ESM that the content has been removed, so that
   // it can clean up any state related to the content.
 
   mPresContext->EventStateManager()
     ->ContentRemoved(mDocument, aChild->GetParent(), aChild);
 
@@ -4565,17 +4565,17 @@ PresShell::NotifyCounterStylesAreDirty()
 {
   nsAutoCauseReflowNotifier reflowNotifier(this);
   mFrameConstructor->NotifyCounterStylesAreDirty();
 }
 
 void
 PresShell::ReconstructFrames()
 {
-  NS_PRECONDITION(!mFrameConstructor->GetRootFrame() || mDidInitialize,
+  MOZ_ASSERT(!mFrameConstructor->GetRootFrame() || mDidInitialize,
                   "Must not have root frame before initial reflow");
   if (!mDidInitialize || mIsDestroying) {
     // Nothing to do here
     return;
   }
 
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
 
@@ -8820,25 +8820,25 @@ PresShell::GetPerformanceNowUnclamped()
   return now;
 }
 
 void
 PresShell::sReflowContinueCallback(nsITimer* aTimer, void* aPresShell)
 {
   RefPtr<PresShell> self = static_cast<PresShell*>(aPresShell);
 
-  NS_PRECONDITION(aTimer == self->mReflowContinueTimer, "Unexpected timer");
+  MOZ_ASSERT(aTimer == self->mReflowContinueTimer, "Unexpected timer");
   self->mReflowContinueTimer = nullptr;
   self->ScheduleReflow();
 }
 
 bool
 PresShell::ScheduleReflowOffTimer()
 {
-  NS_PRECONDITION(!mObservingLayoutFlushes, "Shouldn't get here");
+  MOZ_ASSERT(!mObservingLayoutFlushes, "Shouldn't get here");
   ASSERT_REFLOW_SCHEDULED_STATE();
 
   if (!mReflowContinueTimer) {
     nsresult rv = NS_NewTimerWithFuncCallback(
         getter_AddRefs(mReflowContinueTimer),
         sReflowContinueCallback, this, 30,
         nsITimer::TYPE_ONE_SHOT,
         "sReflowContinueCallback",
@@ -10414,17 +10414,17 @@ SetPluginIsActive(nsISupports* aSupports
   if (objectFrame) {
     objectFrame->SetIsDocumentActive(*static_cast<bool*>(aClosure));
   }
 }
 
 nsresult
 PresShell::SetIsActive(bool aIsActive)
 {
-  NS_PRECONDITION(mDocument, "should only be called with a document");
+  MOZ_ASSERT(mDocument, "should only be called with a document");
 
   mIsActive = aIsActive;
 
   nsPresContext* presContext = GetPresContext();
   if (presContext &&
       presContext->RefreshDriver()->GetPresContext() == presContext) {
     presContext->RefreshDriver()->SetThrottled(!mIsActive);
   }
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -986,17 +986,17 @@ NeedToReframeForAddingOrRemovingTransfor
   }
   return false;
 }
 
 static void
 DoApplyRenderingChangeToTree(nsIFrame* aFrame,
                              nsChangeHint aChange)
 {
-  NS_PRECONDITION(gInApplyRenderingChangeToTree,
+  MOZ_ASSERT(gInApplyRenderingChangeToTree,
                   "should only be called within ApplyRenderingChangeToTree");
 
   for ( ; aFrame; aFrame = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(aFrame)) {
     // Invalidate and sync views on all descendant frames, following placeholders.
     // We don't need to update transforms in SyncViewsAndInvalidateDescendants, because
     // there can't be any out-of-flows or popups that need to be transformed;
     // all out-of-flow descendants of the transformed element must also be
     // descendants of the transformed frame.
@@ -1086,17 +1086,17 @@ DoApplyRenderingChangeToTree(nsIFrame* a
                             ? nsIFrame::PAINT_DEFAULT
                             : nsIFrame::PAINT_COMPOSITE_ONLY);
   }
 }
 
 static void
 SyncViewsAndInvalidateDescendants(nsIFrame* aFrame, nsChangeHint aChange)
 {
-  NS_PRECONDITION(gInApplyRenderingChangeToTree,
+  MOZ_ASSERT(gInApplyRenderingChangeToTree,
                   "should only be called within ApplyRenderingChangeToTree");
   NS_ASSERTION(nsChangeHint_size_t(aChange) ==
                           (aChange & (nsChangeHint_RepaintFrame |
                                       nsChangeHint_SyncFrameView |
                                       nsChangeHint_UpdateOpacityLayer |
                                       nsChangeHint_SchedulePaint)),
                "Invalid change flag");
 
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -622,18 +622,18 @@ JoinInlineAncestors(nsIFrame* aFrame)
   } while (frame && IsBidiSplittable(frame));
 }
 
 static nsresult
 CreateContinuation(nsIFrame*  aFrame,
                    nsIFrame** aNewFrame,
                    bool       aIsFluid)
 {
-  NS_PRECONDITION(aNewFrame, "null OUT ptr");
-  NS_PRECONDITION(aFrame, "null ptr");
+  MOZ_ASSERT(aNewFrame, "null OUT ptr");
+  MOZ_ASSERT(aFrame, "null ptr");
 
   *aNewFrame = nullptr;
 
   nsPresContext *presContext = aFrame->PresContext();
   nsIPresShell *presShell = presContext->PresShell();
   NS_ASSERTION(presShell, "PresShell must be set on PresContext before calling nsBidiPresUtils::CreateContinuation");
 
   nsContainerFrame* parent = aFrame->GetParent();
@@ -1862,18 +1862,18 @@ nsBidiPresUtils::GetFrameToLeftOf(const 
 }
 
 inline nsresult
 nsBidiPresUtils::EnsureBidiContinuation(nsIFrame*       aFrame,
                                         nsIFrame**      aNewFrame,
                                         int32_t         aStart,
                                         int32_t         aEnd)
 {
-  NS_PRECONDITION(aNewFrame, "null OUT ptr");
-  NS_PRECONDITION(aFrame, "aFrame is null");
+  MOZ_ASSERT(aNewFrame, "null OUT ptr");
+  MOZ_ASSERT(aFrame, "aFrame is null");
 
   aFrame->AdjustOffsetsForBidi(aStart, aEnd);
   return CreateContinuation(aFrame, aNewFrame, false);
 }
 
 void
 nsBidiPresUtils::RemoveBidiContinuation(BidiParagraphData *aBpd,
                                         nsIFrame*       aFrame,
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -540,27 +540,27 @@ IsFramePartOfIBSplit(nsIFrame* aFrame)
   MOZ_ASSERT(!result || static_cast<nsBlockFrame*>(do_QueryFrame(aFrame)) ||
                         static_cast<nsInlineFrame*>(do_QueryFrame(aFrame)),
              "only block/inline frames can have NS_FRAME_PART_OF_IBSPLIT");
   return result;
 }
 
 static nsContainerFrame* GetIBSplitSibling(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(IsFramePartOfIBSplit(aFrame), "Shouldn't call this");
+  MOZ_ASSERT(IsFramePartOfIBSplit(aFrame), "Shouldn't call this");
 
   // We only store the "ib-split sibling" annotation with the first
   // frame in the continuation chain. Walk back to find that frame now.
   return aFrame->FirstContinuation()->
            GetProperty(nsIFrame::IBSplitSibling());
 }
 
 static nsContainerFrame* GetIBSplitPrevSibling(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(IsFramePartOfIBSplit(aFrame), "Shouldn't call this");
+  MOZ_ASSERT(IsFramePartOfIBSplit(aFrame), "Shouldn't call this");
 
   // We only store the ib-split sibling annotation with the first
   // frame in the continuation chain. Walk back to find that frame now.
   return aFrame->FirstContinuation()->
            GetProperty(nsIFrame::IBSplitPrevSibling());
 }
 
 static nsContainerFrame*
@@ -574,17 +574,17 @@ GetLastIBSplitSibling(nsIFrame* aFrame)
   }
   NS_NOTREACHED("unreachable code");
   return nullptr;
 }
 
 static void
 SetFrameIsIBSplit(nsContainerFrame* aFrame, nsContainerFrame* aIBSplitSibling)
 {
-  NS_PRECONDITION(aFrame, "bad args!");
+  MOZ_ASSERT(aFrame, "bad args!");
 
   // We should be the only continuation
   NS_ASSERTION(!aFrame->GetPrevContinuation(),
                "assigning ib-split sibling to other than first continuation!");
   NS_ASSERTION(!aFrame->GetNextContinuation() ||
                IsFramePartOfIBSplit(aFrame->GetNextContinuation()),
                "should have no non-ib-split continuations here");
 
@@ -601,17 +601,17 @@ SetFrameIsIBSplit(nsContainerFrame* aFra
     aFrame->SetProperty(nsIFrame::IBSplitSibling(), aIBSplitSibling);
     aIBSplitSibling->SetProperty(nsIFrame::IBSplitPrevSibling(), aFrame);
   }
 }
 
 static nsIFrame*
 GetIBContainingBlockFor(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(IsFramePartOfIBSplit(aFrame),
+  MOZ_ASSERT(IsFramePartOfIBSplit(aFrame),
                   "GetIBContainingBlockFor() should only be called on known IB frames");
 
   // Get the first "normal" ancestor of the target frame.
   nsIFrame* parentFrame;
   do {
     parentFrame = aFrame->GetParent();
 
     if (! parentFrame) {
@@ -686,34 +686,34 @@ FindFirstNonBlock(const nsFrameList& aLi
     }
   }
   return link;
 }
 
 inline void
 SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame)
 {
-  NS_PRECONDITION(!aFrame->GetNextSibling(), "Should be using a frame list");
+  MOZ_ASSERT(!aFrame->GetNextSibling(), "Should be using a frame list");
   nsFrameList temp(aFrame, aFrame);
   aParent->SetInitialChildList(kPrincipalList, temp);
 }
 
 // -----------------------------------------------------------
 
 // Structure used when constructing formatting object trees.
 struct nsFrameItems : public nsFrameList
 {
   // Appends the frame to the end of the list
   void AddChild(nsIFrame* aChild);
 };
 
 void
 nsFrameItems::AddChild(nsIFrame* aChild)
 {
-  NS_PRECONDITION(aChild, "nsFrameItems::AddChild");
+  MOZ_ASSERT(aChild, "nsFrameItems::AddChild");
 
   // It'd be really nice if we could just AppendFrames(kPrincipalList, aChild) here,
   // but some of our callers put frames that have different
   // parents (caption, I'm looking at you) on the same framelist, and
   // nsFrameList asserts if you try to do that.
   if (IsEmpty()) {
     SetFrames(aChild);
   }
@@ -1143,17 +1143,17 @@ nsFrameConstructorState::PushAbsoluteCon
     aNewAbsoluteContainingBlock->MarkAsAbsoluteContainingBlock();
   }
 }
 
 void
 nsFrameConstructorState::PushFloatContainingBlock(nsContainerFrame* aNewFloatContainingBlock,
                                                   nsFrameConstructorSaveState& aSaveState)
 {
-  NS_PRECONDITION(!aNewFloatContainingBlock ||
+  MOZ_ASSERT(!aNewFloatContainingBlock ||
                   aNewFloatContainingBlock->IsFloatContainingBlock(),
                   "Please push a real float containing block!");
   NS_ASSERTION(!aNewFloatContainingBlock ||
                !ShouldSuppressFloatingOfDescendants(aNewFloatContainingBlock),
                "We should not push a frame that is supposed to _suppress_ "
                "floats as a float containing block!");
   aSaveState.mItems = &mFloatedItems;
   aSaveState.mSavedItems = mFloatedItems;
@@ -1161,17 +1161,17 @@ nsFrameConstructorState::PushFloatContai
   aSaveState.mState = this;
   mFloatedItems = nsAbsoluteItems(aNewFloatContainingBlock);
 }
 
 nsContainerFrame*
 nsFrameConstructorState::GetGeometricParent(const nsStyleDisplay* aStyleDisplay,
                                             nsContainerFrame* aContentParentFrame) const
 {
-  NS_PRECONDITION(aStyleDisplay, "Must have display struct!");
+  MOZ_ASSERT(aStyleDisplay, "Must have display struct!");
 
   // If there is no container for a fixed, absolute, or floating root
   // frame, we will ignore the positioning.  This hack is originally
   // brought to you by the letter T: tables, since other roots don't
   // even call into this code.  See bug 178855.
   //
   // XXX Disabling positioning in this case is a hack.  If one was so inclined,
   // one could support this either by (1) inserting a dummy block between the
@@ -1308,17 +1308,17 @@ nsFrameConstructorState::AddChild(nsIFra
                                   nsIContent* aContent,
                                   nsContainerFrame* aParentFrame,
                                   bool aCanBePositioned,
                                   bool aCanBeFloated,
                                   bool aIsOutOfFlowPopup,
                                   bool aInsertAfter,
                                   nsIFrame* aInsertAfterFrame)
 {
-  NS_PRECONDITION(!aNewFrame->GetNextSibling(), "Shouldn't happen");
+  MOZ_ASSERT(!aNewFrame->GetNextSibling(), "Shouldn't happen");
 
   nsFrameState placeholderType;
   nsAbsoluteItems* outOfFlowFrameItems =
     GetOutOfFlowFrameItems(aNewFrame, aCanBePositioned, aCanBeFloated,
                            aIsOutOfFlowPopup, &placeholderType);
 
   // The comments in GetGeometricParent regarding root table frames
   // all apply here, unfortunately. Thus, we need to check whether
@@ -1374,22 +1374,22 @@ nsFrameConstructorState::ProcessFrameIns
                              aChildListID == nsIFrame::kFloatList)    ||  \
                             ((&aFrameItems == &mAbsoluteItems ||          \
                               &aFrameItems == &mTopLayerAbsoluteItems) && \
                              aChildListID == nsIFrame::kAbsoluteList) ||  \
                             ((&aFrameItems == &mFixedItems ||             \
                               &aFrameItems == &mTopLayerFixedItems) &&    \
                              aChildListID == nsIFrame::kFixedList)
 #ifdef MOZ_XUL
-  NS_PRECONDITION(NS_NONXUL_LIST_TEST ||
+  MOZ_ASSERT(NS_NONXUL_LIST_TEST ||
                   (&aFrameItems == &mPopupItems &&
                    aChildListID == nsIFrame::kPopupList),
                   "Unexpected aFrameItems/aChildListID combination");
 #else
-  NS_PRECONDITION(NS_NONXUL_LIST_TEST,
+  MOZ_ASSERT(NS_NONXUL_LIST_TEST,
                   "Unexpected aFrameItems/aChildListID combination");
 #endif
 
   if (aFrameItems.IsEmpty()) {
     return;
   }
 
   nsContainerFrame* containingBlock = aFrameItems.containingBlock;
@@ -2040,18 +2040,18 @@ GetCaptionAdjustedParent(nsContainerFram
   return haveCaption;
 }
 
 void
 nsCSSFrameConstructor::AdjustParentFrame(nsContainerFrame**           aParentFrame,
                                          const FrameConstructionData* aFCData,
                                          ComputedStyle*              aComputedStyle)
 {
-  NS_PRECONDITION(aComputedStyle, "Must have child's style");
-  NS_PRECONDITION(aFCData, "Must have frame construction data");
+  MOZ_ASSERT(aComputedStyle, "Must have child's style");
+  MOZ_ASSERT(aFCData, "Must have frame construction data");
 
   bool tablePart = ((aFCData->mBits & FCDATA_IS_TABLE_PART) != 0);
 
   if (tablePart && aComputedStyle->StyleDisplay()->mDisplay ==
       StyleDisplay::TableCaption) {
     *aParentFrame = ::AdjustCaptionParentFrame(*aParentFrame);
   }
 }
@@ -2078,17 +2078,17 @@ PullOutCaptionFrames(nsFrameItems& aItem
 // of having frames handle page-break-before/after will solve the problem.
 nsIFrame*
 nsCSSFrameConstructor::ConstructTable(nsFrameConstructorState& aState,
                                       FrameConstructionItem&   aItem,
                                       nsContainerFrame*        aParentFrame,
                                       const nsStyleDisplay*    aDisplay,
                                       nsFrameItems&            aFrameItems)
 {
-  NS_PRECONDITION(aDisplay->mDisplay == StyleDisplay::Table ||
+  MOZ_ASSERT(aDisplay->mDisplay == StyleDisplay::Table ||
                   aDisplay->mDisplay == StyleDisplay::InlineTable,
                   "Unexpected call");
 
   nsIContent* const content = aItem.mContent;
   ComputedStyle* const computedStyle = aItem.mComputedStyle;
   const bool isMathMLContent = content->IsMathMLElement();
 
   // create the pseudo SC for the table wrapper as a child of the inner SC
@@ -2371,17 +2371,17 @@ nsCSSFrameConstructor::ConstructTableCel
 
 static inline bool
 NeedFrameFor(const nsFrameConstructorState& aState,
              nsIFrame*   aParentFrame,
              nsIContent* aChildContent)
 {
   // XXX the GetContent() != aChildContent check is needed due to bug 135040.
   // Remove it once that's fixed.
-  NS_PRECONDITION(!aChildContent->GetPrimaryFrame() ||
+  MOZ_ASSERT(!aChildContent->GetPrimaryFrame() ||
                   aState.mCreatingExtraFrames ||
                   aChildContent->GetPrimaryFrame()->GetContent() != aChildContent,
                   "Why did we get called?");
 
   // don't create a whitespace frame if aParentFrame doesn't want it.
   // always create frames for children in generated content. counter(),
   // quotes, and attr() content can easily change dynamically and we don't
   // want to be reconstructing frames. It's not even clear that these
@@ -2724,20 +2724,20 @@ nsCSSFrameConstructor::ConstructRootFram
   viewportFrame->MarkAsAbsoluteContainingBlock();
 
   return viewportFrame;
 }
 
 void
 nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement)
 {
-  NS_PRECONDITION(aDocElement, "No element?");
-  NS_PRECONDITION(!aDocElement->GetParent(), "Not root content?");
-  NS_PRECONDITION(aDocElement->GetUncomposedDoc(), "Not in a document?");
-  NS_PRECONDITION(aDocElement->GetUncomposedDoc()->GetRootElement() ==
+  MOZ_ASSERT(aDocElement, "No element?");
+  MOZ_ASSERT(!aDocElement->GetParent(), "Not root content?");
+  MOZ_ASSERT(aDocElement->GetUncomposedDoc(), "Not in a document?");
+  MOZ_ASSERT(aDocElement->GetUncomposedDoc()->GetRootElement() ==
                   aDocElement, "Not the root of the document?");
 
   /*
     how the root frame hierarchy should look
 
   Galley presentation, non-XUL, with scrolling:
 
       ViewportFrame [fixed-cb]
@@ -3052,17 +3052,17 @@ nsCSSFrameConstructor::CreatePlaceholder
 // aEndContent is null, that means to clear bits in all siblings starting with
 // aStartContent.  aStartContent must not be null unless aEndContent is also
 // null.  We do this so that when new children are inserted under elements whose
 // frame is a leaf the new children don't cause us to try to construct frames
 // for the existing children again.
 static inline void
 ClearLazyBits(nsIContent* aStartContent, nsIContent* aEndContent)
 {
-  NS_PRECONDITION(aStartContent || !aEndContent,
+  MOZ_ASSERT(aStartContent || !aEndContent,
                   "Must have start child if we have an end child");
   for (nsIContent* cur = aStartContent; cur != aEndContent;
        cur = cur->GetNextSibling()) {
     cur->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
   }
 }
 
 nsIFrame*
@@ -3468,17 +3468,17 @@ nsCSSFrameConstructor::FindTextData(nsIF
 void
 nsCSSFrameConstructor::ConstructTextFrame(const FrameConstructionData* aData,
                                           nsFrameConstructorState& aState,
                                           nsIContent*              aContent,
                                           nsContainerFrame*        aParentFrame,
                                           ComputedStyle*          aComputedStyle,
                                           nsFrameItems&            aFrameItems)
 {
-  NS_PRECONDITION(aData, "Must have frame construction data");
+  MOZ_ASSERT(aData, "Must have frame construction data");
 
   nsIFrame* newFrame = (*aData->mFunc.mCreationFunc)(mPresShell, aComputedStyle);
 
   InitAndRestoreFrame(aState, aContent, aParentFrame, newFrame);
 
   // We never need to create a view for a text frame.
 
   if (newFrame->IsGeneratedContentFrame()) {
@@ -5647,17 +5647,17 @@ nsCSSFrameConstructor::AddFrameConstruct
                                                          nsIContent* aContent,
                                                          nsContainerFrame* aParentFrame,
                                                          bool aSuppressWhiteSpaceOptimizations,
                                                          ComputedStyle* aComputedStyle,
                                                          uint32_t aFlags,
                                                          nsTArray<nsIAnonymousContentCreator::ContentInfo>* aAnonChildren,
                                                          FrameConstructionItemList& aItems)
 {
-  NS_PRECONDITION(aContent->IsText() || aContent->IsElement(),
+  MOZ_ASSERT(aContent->IsText() || aContent->IsElement(),
                   "Shouldn't get anything else here!");
   MOZ_ASSERT(aContent->IsInComposedDoc());
   MOZ_ASSERT(!aContent->GetPrimaryFrame() || aState.mCreatingExtraFrames ||
              aContent->NodeInfo()->NameAtom() == nsGkAtoms::area);
 
   // The following code allows the user to specify the base tag
   // of an element using XBL.  XUL and HTML objects (like boxes, menus, etc.)
   // can then be extended arbitrarily.
@@ -6271,21 +6271,21 @@ GetInsertNextSibling(nsIFrame* aParentFr
  */
 void
 nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState&       aState,
                                             nsContainerFrame*              aParentFrame,
                                             nsFrameItems&                  aFrameList,
                                             nsIFrame*                      aPrevSibling,
                                             bool                           aIsRecursiveCall)
 {
-  NS_PRECONDITION(!IsFramePartOfIBSplit(aParentFrame) ||
+  MOZ_ASSERT(!IsFramePartOfIBSplit(aParentFrame) ||
                   !GetIBSplitSibling(aParentFrame) ||
                   !GetIBSplitSibling(aParentFrame)->PrincipalChildList().FirstChild(),
                   "aParentFrame has a ib-split sibling with kids?");
-  NS_PRECONDITION(!aPrevSibling || aPrevSibling->GetParent() == aParentFrame,
+  MOZ_ASSERT(!aPrevSibling || aPrevSibling->GetParent() == aParentFrame,
                   "Parent and prevsibling don't match");
 
   nsIFrame* nextSibling = ::GetInsertNextSibling(aParentFrame, aPrevSibling);
 
   NS_ASSERTION(nextSibling ||
                !aParentFrame->GetNextContinuation() ||
                !aParentFrame->GetNextContinuation()->PrincipalChildList().FirstChild() ||
                aIsRecursiveCall,
@@ -6599,17 +6599,17 @@ nsCSSFrameConstructor::FindSibling(const
   return nullptr;
 }
 
 // For fieldsets, returns the area frame, if the child is not a legend.
 static nsContainerFrame*
 GetAdjustedParentFrame(nsContainerFrame* aParentFrame,
                        nsIContent* aChildContent)
 {
-  NS_PRECONDITION(!aParentFrame->IsTableWrapperFrame(),
+  MOZ_ASSERT(!aParentFrame->IsTableWrapperFrame(),
                   "Shouldn't be happening!");
 
   nsContainerFrame* newParent = nullptr;
 
   if (aParentFrame->IsFieldSetFrame()) {
     // If the parent is a fieldSet, use the fieldSet's area frame as the
     // parent unless the new content is a legend.
     if (!aChildContent->IsHTMLElement(nsGkAtoms::legend)) {
@@ -6622,17 +6622,17 @@ GetAdjustedParentFrame(nsContainerFrame*
 nsIFrame*
 nsCSSFrameConstructor::GetInsertionPrevSibling(InsertionPoint* aInsertion,
                                                nsIContent* aChild,
                                                bool*       aIsAppend,
                                                bool*       aIsRangeInsertSafe,
                                                nsIContent* aStartSkipChild,
                                                nsIContent* aEndSkipChild)
 {
-  NS_PRECONDITION(aInsertion->mParentFrame, "Must have parent frame to start with");
+  MOZ_ASSERT(aInsertion->mParentFrame, "Must have parent frame to start with");
 
   *aIsAppend = false;
 
   // Find the frame that precedes the insertion point. Walk backwards
   // from the parent frame to get the parent content, because if an
   // XBL insertion point is involved, we'll need to use _that_ to find
   // the preceding frame.
   FlattenedChildIterator iter(aInsertion->mContainer);
@@ -6733,17 +6733,17 @@ static void
 InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node);
 
 void
 nsCSSFrameConstructor::AddTextItemIfNeeded(nsFrameConstructorState& aState,
                                            const InsertionPoint& aInsertion,
                                            nsIContent* aPossibleTextContent,
                                            FrameConstructionItemList& aItems)
 {
-  NS_PRECONDITION(aPossibleTextContent, "Must have node");
+  MOZ_ASSERT(aPossibleTextContent, "Must have node");
   if (!aPossibleTextContent->IsText() ||
       !aPossibleTextContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE) ||
       aPossibleTextContent->HasFlag(NODE_NEEDS_FRAME)) {
     // Not text, or not suppressed due to being all-whitespace (if it were being
     // suppressed, it would have the NS_CREATE_FRAME_IF_NON_WHITESPACE flag), or
     // going to be reframed anyway.
     return;
   }
@@ -7411,17 +7411,17 @@ nsCSSFrameConstructor::ContentRangeInser
                                             nsILayoutHistoryState* aFrameState,
                                             InsertionKind aInsertionKind)
 {
   MOZ_ASSERT(aInsertionKind == InsertionKind::Sync ||
              !RestyleManager()->IsInStyleRefresh());
 
   AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
 
-  NS_PRECONDITION(aStartChild, "must always pass a child");
+  MOZ_ASSERT(aStartChild, "must always pass a child");
 
 #ifdef DEBUG
   if (gNoisyContentUpdates) {
     printf("nsCSSFrameConstructor::ContentRangeInserted container=%p "
            "start-child=%p end-child=%p lazy=%d\n",
            aStartChild->GetParent(),
            aStartChild,
            aEndChild,
@@ -8206,18 +8206,18 @@ nsCSSFrameConstructor::ContentRemoved(ns
  * document root node or an HTML BODY which is a child of the root node.
  *
  * @param aFrame a frame for a content node about to be removed or a frame that
  *               was just created for a content node that was inserted.
  */
 static void
 InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node)
 {
-  NS_PRECONDITION(presShell->GetRootFrame(), "What happened here?");
-  NS_PRECONDITION(presShell->GetPresContext(), "Say what?");
+  MOZ_ASSERT(presShell->GetRootFrame(), "What happened here?");
+  MOZ_ASSERT(presShell->GetPresContext(), "Say what?");
 
   //  Note that both in ContentRemoved and ContentInserted the content node
   //  will still have the right parent pointer, so looking at that is ok.
 
   nsIContent* parent = node->GetParent();
   if (parent) {
     // Has a parent; might not be what we want
     nsIContent* grandParent = parent->GetParent();
@@ -8851,19 +8851,19 @@ FindPreviousNonWhitespaceSibling(nsIFram
     f = f->GetPrevSibling();
   } while (f && IsWhitespaceFrame(f));
   return f;
 }
 
 bool
 nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "Must have a frame");
-  NS_PRECONDITION(aFrame->GetParent(), "Frame shouldn't be root");
-  NS_PRECONDITION(aFrame == aFrame->FirstContinuation(),
+  MOZ_ASSERT(aFrame, "Must have a frame");
+  MOZ_ASSERT(aFrame->GetParent(), "Frame shouldn't be root");
+  MOZ_ASSERT(aFrame == aFrame->FirstContinuation(),
                   "aFrame not the result of GetPrimaryFrame()?");
 
   if (IsFramePartOfIBSplit(aFrame)) {
     // The removal functions can't handle removal of an {ib} split directly; we
     // need to rebuild the containing block.
 #ifdef DEBUG
     if (gNoisyContentUpdates) {
       printf("nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval: "
@@ -9276,17 +9276,17 @@ nsCSSFrameConstructor::ShouldHaveFirstLe
   return nsLayoutUtils::HasPseudoStyle(aContent, aComputedStyle,
                                        CSSPseudoElementType::firstLetter,
                                        mPresShell->GetPresContext());
 }
 
 bool
 nsCSSFrameConstructor::HasFirstLetterStyle(nsIFrame* aBlockFrame)
 {
-  NS_PRECONDITION(aBlockFrame, "Need a frame");
+  MOZ_ASSERT(aBlockFrame, "Need a frame");
   NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlockFrame),
                "Not a block frame?");
 
   return (aBlockFrame->GetStateBits() & NS_BLOCK_HAS_FIRST_LETTER_STYLE) != 0;
 }
 
 bool
 nsCSSFrameConstructor::ShouldHaveFirstLineStyle(nsIContent* aContent,
@@ -10201,18 +10201,18 @@ nsCSSFrameConstructor::ProcessChildren(n
                                        ComputedStyle*          aComputedStyle,
                                        nsContainerFrame*        aFrame,
                                        const bool               aCanHaveGeneratedContent,
                                        nsFrameItems&            aFrameItems,
                                        const bool               aAllowBlockStyles,
                                        PendingBinding*          aPendingBinding,
                                        nsIFrame*                aPossiblyLeafFrame)
 {
-  NS_PRECONDITION(aFrame, "Must have parent frame here");
-  NS_PRECONDITION(aFrame->GetContentInsertionFrame() == aFrame,
+  MOZ_ASSERT(aFrame, "Must have parent frame here");
+  MOZ_ASSERT(aFrame->GetContentInsertionFrame() == aFrame,
                   "Parent frame in ProcessChildren should be its own "
                   "content insertion frame");
   const uint32_t kMaxDepth = 2 * MAX_REFLOW_DEPTH;
   static_assert(kMaxDepth <= UINT16_MAX, "mCurrentDepth type is too narrow");
   AutoRestore<uint16_t> savedDepth(mCurrentDepth);
   if (mCurrentDepth != UINT16_MAX) {
     ++mCurrentDepth;
   }
@@ -10594,17 +10594,17 @@ FirstLetterCount(const nsTextFragment* a
   }
 
   return count;
 }
 
 static bool
 NeedFirstLetterContinuation(nsIContent* aContent)
 {
-  NS_PRECONDITION(aContent, "null ptr");
+  MOZ_ASSERT(aContent, "null ptr");
 
   bool result = false;
   if (aContent) {
     const nsTextFragment* frag = aContent->GetText();
     if (frag) {
       int32_t flc = FirstLetterCount(frag);
       int32_t tl = frag->GetLength();
       if (flc < tl) {
@@ -10697,17 +10697,17 @@ nsCSSFrameConstructor::CreateFloatingLet
  */
 void
 nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame,
                                          nsContainerFrame* aBlockContinuation,
                                          nsIContent* aTextContent,
                                          nsContainerFrame* aParentFrame,
                                          nsFrameItems& aResult)
 {
-  NS_PRECONDITION(aTextContent->IsText(), "aTextContent isn't text");
+  MOZ_ASSERT(aTextContent->IsText(), "aTextContent isn't text");
   NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlockFrame),
                  "Not a block frame?");
 
   // Get a ComputedStyle for the first-letter-frame.
   //
   // Keep this in sync with nsBlockFrame::UpdatePseudoElementStyles.
   nsIFrame* parentFrame =
     nsFrame::CorrectStyleParentFrame(aParentFrame,
@@ -11422,18 +11422,18 @@ nsCSSFrameConstructor::CreateIBSiblings(
     ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::mozBlockInsideInlineWrapper,
                                        computedStyle);
 
   nsContainerFrame* lastNewInline =
     static_cast<nsContainerFrame*>(aInitialInline->FirstContinuation());
   do {
     // On entry to this loop aChildItems is not empty and the first frame in it
     // is block-level.
-    NS_PRECONDITION(aChildItems.NotEmpty(), "Should have child items");
-    NS_PRECONDITION(!aChildItems.FirstChild()->IsInlineOutside(),
+    MOZ_ASSERT(aChildItems.NotEmpty(), "Should have child items");
+    MOZ_ASSERT(!aChildItems.FirstChild()->IsInlineOutside(),
                     "Must have list starting with block");
 
     // The initial run of blocks belongs to an anonymous block that we create
     // right now. The anonymous block will be the parent of these block
     // children of the inline.
     nsBlockFrame* blockFrame = NS_NewBlockFrame(mPresShell, blockSC);
     InitAndRestoreFrame(aState, content, parentFrame, blockFrame, false);
 
@@ -11542,17 +11542,17 @@ nsCSSFrameConstructor::BuildInlineChildI
 }
 
 // return whether it's ok to append (in the AppendFrames sense) to
 // aParentFrame if our nextSibling is aNextSibling.  aParentFrame must
 // be an ib-split inline.
 static bool
 IsSafeToAppendToIBSplitInline(nsIFrame* aParentFrame, nsIFrame* aNextSibling)
 {
-  NS_PRECONDITION(IsInlineFrame(aParentFrame),
+  MOZ_ASSERT(IsInlineFrame(aParentFrame),
                   "Must have an inline parent here");
   do {
     NS_ASSERTION(IsFramePartOfIBSplit(aParentFrame),
                  "How is this not part of an ib-split?");
     if (aNextSibling || aParentFrame->GetNextContinuation() ||
         GetIBSplitSibling(aParentFrame)) {
       return false;
     }
@@ -12007,34 +12007,34 @@ nsCSSFrameConstructor::GenerateChildFram
 
 //////////////////////////////////////////////////////////
 // nsCSSFrameConstructor::FrameConstructionItem methods //
 //////////////////////////////////////////////////////////
 bool
 nsCSSFrameConstructor::
 FrameConstructionItem::IsWhitespace(nsFrameConstructorState& aState) const
 {
-  NS_PRECONDITION(aState.mCreatingExtraFrames ||
+  MOZ_ASSERT(aState.mCreatingExtraFrames ||
                   !mContent->GetPrimaryFrame(), "How did that happen?");
   if (!mIsText) {
     return false;
   }
   mContent->SetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE |
                      NS_REFRAME_IF_WHITESPACE);
   return mContent->TextIsOnlyWhitespace();
 }
 
 //////////////////////////////////////////////////////////////
 // nsCSSFrameConstructor::FrameConstructionItemList methods //
 //////////////////////////////////////////////////////////////
 void
 nsCSSFrameConstructor::FrameConstructionItemList::
 AdjustCountsForItem(FrameConstructionItem* aItem, int32_t aDelta)
 {
-  NS_PRECONDITION(aDelta == 1 || aDelta == -1, "Unexpected delta");
+  MOZ_ASSERT(aDelta == 1 || aDelta == -1, "Unexpected delta");
   mItemCount += aDelta;
   if (aItem->mIsAllInline) {
     mInlineCount += aDelta;
   }
   if (aItem->mIsBlock) {
     mBlockCount += aDelta;
   }
   if (aItem->mIsLineParticipant) {
@@ -12045,31 +12045,31 @@ AdjustCountsForItem(FrameConstructionIte
 
 ////////////////////////////////////////////////////////////////////////
 // nsCSSFrameConstructor::FrameConstructionItemList::Iterator methods //
 ////////////////////////////////////////////////////////////////////////
 inline bool
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::SkipItemsWantingParentType(ParentType aParentType)
 {
-  NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
+  MOZ_ASSERT(!IsDone(), "Shouldn't be done yet");
   while (item().DesiredParentType() == aParentType) {
     Next();
     if (IsDone()) {
       return true;
     }
   }
   return false;
 }
 
 inline bool
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::SkipItemsNotWantingParentType(ParentType aParentType)
 {
-  NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
+  MOZ_ASSERT(!IsDone(), "Shouldn't be done yet");
   while (item().DesiredParentType() != aParentType) {
     Next();
     if (IsDone()) {
       return true;
     }
   }
   return false;
 }
@@ -12110,95 +12110,95 @@ nsCSSFrameConstructor::FrameConstruction
 }
 
 inline bool
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::SkipItemsThatNeedAnonFlexOrGridItem(
   const nsFrameConstructorState& aState,
   bool aIsLegacyBox)
 {
-  NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
+  MOZ_ASSERT(!IsDone(), "Shouldn't be done yet");
   while (item().NeedsAnonFlexOrGridItem(aState, aIsLegacyBox)) {
     Next();
     if (IsDone()) {
       return true;
     }
   }
   return false;
 }
 
 inline bool
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::SkipItemsThatDontNeedAnonFlexOrGridItem(
   const nsFrameConstructorState& aState,
   bool aIsLegacyBox)
 {
-  NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
+  MOZ_ASSERT(!IsDone(), "Shouldn't be done yet");
   while (!(item().NeedsAnonFlexOrGridItem(aState, aIsLegacyBox))) {
     Next();
     if (IsDone()) {
       return true;
     }
   }
   return false;
 }
 
 inline bool
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::SkipItemsNotWantingRubyParent()
 {
-  NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
+  MOZ_ASSERT(!IsDone(), "Shouldn't be done yet");
   while (!IsRubyParentType(item().DesiredParentType())) {
     Next();
     if (IsDone()) {
       return true;
     }
   }
   return false;
 }
 
 inline bool
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::SkipWhitespace(nsFrameConstructorState& aState)
 {
-  NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
-  NS_PRECONDITION(item().IsWhitespace(aState), "Not pointing to whitespace?");
+  MOZ_ASSERT(!IsDone(), "Shouldn't be done yet");
+  MOZ_ASSERT(item().IsWhitespace(aState), "Not pointing to whitespace?");
   do {
     Next();
     if (IsDone()) {
       return true;
     }
   } while (item().IsWhitespace(aState));
 
   return false;
 }
 
 void
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::AppendItemToList(FrameConstructionItemList& aTargetList)
 {
   NS_ASSERTION(&aTargetList != &mList, "Unexpected call");
-  NS_PRECONDITION(!IsDone(), "should not be done");
+  MOZ_ASSERT(!IsDone(), "should not be done");
 
   FrameConstructionItem* item = mCurrent;
   Next();
   item->remove();
   aTargetList.mItems.insertBack(item);
 
   mList.AdjustCountsForItem(item, -1);
   aTargetList.AdjustCountsForItem(item, 1);
 }
 
 void
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::AppendItemsToList(nsCSSFrameConstructor* aFCtor, const Iterator& aEnd,
                             FrameConstructionItemList& aTargetList)
 {
   NS_ASSERTION(&aTargetList != &mList, "Unexpected call");
-  NS_PRECONDITION(&mList == &aEnd.mList, "End iterator for some other list?");
+  MOZ_ASSERT(&mList == &aEnd.mList, "End iterator for some other list?");
 
   // We can't just move our guts to the other list if it already has
   // some information or if we're not moving our entire list.
   if (!AtStart() || !aEnd.IsDone() || !aTargetList.IsEmpty()) {
     do {
       AppendItemToList(aTargetList);
     } while (*this != aEnd);
     return;
@@ -12237,18 +12237,18 @@ Iterator::InsertItem(FrameConstructionIt
 
   MOZ_ASSERT(aItem->getNext() == mCurrent, "How did that happen?");
 }
 
 void
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::DeleteItemsTo(nsCSSFrameConstructor* aFCtor, const Iterator& aEnd)
 {
-  NS_PRECONDITION(&mList == &aEnd.mList, "End iterator for some other list?");
-  NS_PRECONDITION(*this != aEnd, "Shouldn't be at aEnd yet");
+  MOZ_ASSERT(&mList == &aEnd.mList, "End iterator for some other list?");
+  MOZ_ASSERT(*this != aEnd, "Shouldn't be at aEnd yet");
 
   do {
     NS_ASSERTION(!IsDone(), "Ran off end of list?");
     FrameConstructionItem* item = mCurrent;
     Next();
     item->remove();
     mList.AdjustCountsForItem(item, -1);
     item->Delete(aFCtor);
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -2581,19 +2581,19 @@ nsDocumentViewer::FindContainerView()
 
   NS_ASSERTION(subdocFrame->GetView(), "Subdoc frames must have views");
   return static_cast<nsSubDocumentFrame*>(subdocFrame)->EnsureInnerView();
 }
 
 nsresult
 nsDocumentViewer::CreateDeviceContext(nsView* aContainerView)
 {
-  NS_PRECONDITION(!mPresShell && !mWindow,
+  MOZ_ASSERT(!mPresShell && !mWindow,
                   "This will screw up our existing presentation");
-  NS_PRECONDITION(mDocument, "Gotta have a document here");
+  MOZ_ASSERT(mDocument, "Gotta have a document here");
 
   nsIDocument* doc = mDocument->GetDisplayDocument();
   if (doc) {
     NS_ASSERTION(!aContainerView, "External resource document embedded somewhere?");
     // We want to use our display document's device context if possible
     nsPresContext* ctx = doc->GetPresContext();
     if (ctx) {
       mDeviceContext = ctx->DeviceContext();
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -79,17 +79,17 @@ nsFrameManager::AppendFrames(nsContainer
 }
 
 void
 nsFrameManager::InsertFrames(nsContainerFrame* aParentFrame,
                              ChildListID       aListID,
                              nsIFrame*         aPrevFrame,
                              nsFrameList&      aFrameList)
 {
-  NS_PRECONDITION(!aPrevFrame || (!aPrevFrame->GetNextContinuation()
+  MOZ_ASSERT(!aPrevFrame || (!aPrevFrame->GetNextContinuation()
                   || (((aPrevFrame->GetNextContinuation()->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))
                   && !(aPrevFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))),
                   "aPrevFrame must be the last continuation in its chain!");
 
   if (aParentFrame->IsAbsoluteContainer() &&
       aListID == aParentFrame->GetAbsoluteListID()) {
     aParentFrame->GetAbsoluteContainingBlock()->
       InsertFrames(aParentFrame, aListID, aPrevFrame, aFrameList);
@@ -165,17 +165,17 @@ nsFrameManager::CaptureFrameStateFor(nsI
   // Store the state. aState owns frameState now.
   aState->AddState(stateKey, Move(frameState));
 }
 
 void
 nsFrameManager::CaptureFrameState(nsIFrame* aFrame,
                                   nsILayoutHistoryState* aState)
 {
-  NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in");
+  MOZ_ASSERT(nullptr != aFrame && nullptr != aState, "null parameters passed in");
 
   CaptureFrameStateFor(aFrame, aState);
 
   // Now capture state recursively for the frame hierarchy rooted at aFrame
   nsIFrame::ChildListIterator lists(aFrame);
   for (; !lists.IsDone(); lists.Next()) {
     nsFrameList::Enumerator childFrames(lists.CurrentList());
     for (; !childFrames.AtEnd(); childFrames.Next()) {
@@ -240,17 +240,17 @@ nsFrameManager::RestoreFrameStateFor(nsI
   // If we restore ok, remove the state from the state table
   aState->RemoveState(stateKey);
 }
 
 void
 nsFrameManager::RestoreFrameState(nsIFrame* aFrame,
                                   nsILayoutHistoryState* aState)
 {
-  NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in");
+  MOZ_ASSERT(nullptr != aFrame && nullptr != aState, "null parameters passed in");
 
   RestoreFrameStateFor(aFrame, aState);
 
   // Now restore state recursively for the frame hierarchy rooted at aFrame
   nsIFrame::ChildListIterator lists(aFrame);
   for (; !lists.IsDone(); lists.Next()) {
     nsFrameList::Enumerator childFrames(lists.CurrentList());
     for (; !childFrames.AtEnd(); childFrames.Next()) {
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -39,17 +39,17 @@ public:
 
 protected:
   virtual ~nsLayoutDebugger();
 };
 
 nsresult
 NS_NewLayoutDebugger(nsILayoutDebugger** aResult)
 {
-  NS_PRECONDITION(aResult, "null OUT ptr");
+  MOZ_ASSERT(aResult, "null OUT ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
   nsLayoutDebugger* it = new nsLayoutDebugger();
   return it->QueryInterface(NS_GET_IID(nsILayoutDebugger), (void**)aResult);
 }
 
 nsLayoutDebugger::nsLayoutDebugger()
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1375,17 +1375,17 @@ nsLayoutUtils::RemoveDisplayPort(nsICont
 {
   aContent->DeleteProperty(nsGkAtoms::DisplayPort);
   aContent->DeleteProperty(nsGkAtoms::DisplayPortMargins);
 }
 
 nsContainerFrame*
 nsLayoutUtils::LastContinuationWithChild(nsContainerFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "NULL frame pointer");
+  MOZ_ASSERT(aFrame, "NULL frame pointer");
   nsIFrame* f = aFrame->LastContinuation();
   while (!f->PrincipalChildList().FirstChild() && f->GetPrevContinuation()) {
     f = f->GetPrevContinuation();
   }
   return static_cast<nsContainerFrame*>(f);
 }
 
 //static
@@ -1618,18 +1618,18 @@ nsLayoutUtils::IsProperAncestorFrame(nsI
 // static
 int32_t
 nsLayoutUtils::DoCompareTreePosition(nsIContent* aContent1,
                                      nsIContent* aContent2,
                                      int32_t aIf1Ancestor,
                                      int32_t aIf2Ancestor,
                                      const nsIContent* aCommonAncestor)
 {
-  NS_PRECONDITION(aContent1, "aContent1 must not be null");
-  NS_PRECONDITION(aContent2, "aContent2 must not be null");
+  MOZ_ASSERT(aContent1, "aContent1 must not be null");
+  MOZ_ASSERT(aContent2, "aContent2 must not be null");
 
   AutoTArray<nsINode*, 32> content1Ancestors;
   nsINode* c1;
   for (c1 = aContent1; c1 && c1 != aCommonAncestor; c1 = c1->GetParentNode()) {
     content1Ancestors.AppendElement(c1);
   }
   if (!c1 && aCommonAncestor) {
     // So, it turns out aCommonAncestor was not an ancestor of c1. Oops.
@@ -1723,18 +1723,18 @@ static bool IsFrameAfter(nsIFrame* aFram
 // static
 int32_t
 nsLayoutUtils::DoCompareTreePosition(nsIFrame* aFrame1,
                                      nsIFrame* aFrame2,
                                      int32_t aIf1Ancestor,
                                      int32_t aIf2Ancestor,
                                      nsIFrame* aCommonAncestor)
 {
-  NS_PRECONDITION(aFrame1, "aFrame1 must not be null");
-  NS_PRECONDITION(aFrame2, "aFrame2 must not be null");
+  MOZ_ASSERT(aFrame1, "aFrame1 must not be null");
+  MOZ_ASSERT(aFrame2, "aFrame2 must not be null");
 
   AutoTArray<nsIFrame*,20> frame2Ancestors;
   nsIFrame* nonCommonAncestor =
     FillAncestors(aFrame2, aCommonAncestor, &frame2Ancestors);
 
   return DoCompareTreePosition(aFrame1, aFrame2, frame2Ancestors,
                                aIf1Ancestor, aIf2Ancestor,
                                nonCommonAncestor ? aCommonAncestor : nullptr);
@@ -1744,18 +1744,18 @@ nsLayoutUtils::DoCompareTreePosition(nsI
 int32_t
 nsLayoutUtils::DoCompareTreePosition(nsIFrame* aFrame1,
                                      nsIFrame* aFrame2,
                                      nsTArray<nsIFrame*>& aFrame2Ancestors,
                                      int32_t aIf1Ancestor,
                                      int32_t aIf2Ancestor,
                                      nsIFrame* aCommonAncestor)
 {
-  NS_PRECONDITION(aFrame1, "aFrame1 must not be null");
-  NS_PRECONDITION(aFrame2, "aFrame2 must not be null");
+  MOZ_ASSERT(aFrame1, "aFrame1 must not be null");
+  MOZ_ASSERT(aFrame2, "aFrame2 must not be null");
 
   nsPresContext* presContext = aFrame1->PresContext();
   if (presContext != aFrame2->PresContext()) {
     NS_ERROR("no common ancestor at all, different documents");
     return 0;
   }
 
   AutoTArray<nsIFrame*,20> frame1Ancestors;
@@ -2077,17 +2077,17 @@ nsLayoutUtils::GetScrolledRect(nsIFrame*
 
 //static
 bool
 nsLayoutUtils::HasPseudoStyle(nsIContent* aContent,
                               ComputedStyle* aComputedStyle,
                               CSSPseudoElementType aPseudoElement,
                               nsPresContext* aPresContext)
 {
-  NS_PRECONDITION(aPresContext, "Must have a prescontext");
+  MOZ_ASSERT(aPresContext, "Must have a prescontext");
 
   RefPtr<ComputedStyle> pseudoContext;
   if (aContent) {
     pseudoContext = aPresContext->StyleSet()->
       ProbePseudoElementStyle(aContent->AsElement(), aPseudoElement,
                               aComputedStyle);
   }
   return pseudoContext != nullptr;
@@ -4985,17 +4985,17 @@ GetDefiniteSizeTakenByBoxSizing(StyleBox
 enum eWidthProperty { PROP_WIDTH, PROP_MAX_WIDTH, PROP_MIN_WIDTH };
 static bool
 GetIntrinsicCoord(const nsStyleCoord& aStyle,
                   gfxContext* aRenderingContext,
                   nsIFrame* aFrame,
                   eWidthProperty aProperty,
                   nscoord& aResult)
 {
-  NS_PRECONDITION(aProperty == PROP_WIDTH || aProperty == PROP_MAX_WIDTH ||
+  MOZ_ASSERT(aProperty == PROP_WIDTH || aProperty == PROP_MAX_WIDTH ||
                   aProperty == PROP_MIN_WIDTH, "unexpected property");
   if (aStyle.GetUnit() != eStyleUnit_Enumerated)
     return false;
   int32_t val = aStyle.GetIntValue();
   NS_ASSERTION(val == NS_STYLE_WIDTH_MAX_CONTENT ||
                val == NS_STYLE_WIDTH_MIN_CONTENT ||
                val == NS_STYLE_WIDTH_FIT_CONTENT ||
                val == NS_STYLE_WIDTH_AVAILABLE,
@@ -5207,20 +5207,20 @@ AddStateBitToAncestors(nsIFrame* aFrame,
 nsLayoutUtils::IntrinsicForAxis(PhysicalAxis              aAxis,
                                 gfxContext*               aRenderingContext,
                                 nsIFrame*                 aFrame,
                                 IntrinsicISizeType        aType,
                                 const Maybe<LogicalSize>& aPercentageBasis,
                                 uint32_t                  aFlags,
                                 nscoord                   aMarginBoxMinSizeClamp)
 {
-  NS_PRECONDITION(aFrame, "null frame");
-  NS_PRECONDITION(aFrame->GetParent(),
+  MOZ_ASSERT(aFrame, "null frame");
+  MOZ_ASSERT(aFrame->GetParent(),
                   "IntrinsicForAxis called on frame not in tree");
-  NS_PRECONDITION(aType == MIN_ISIZE || aType == PREF_ISIZE, "bad type");
+  MOZ_ASSERT(aType == MIN_ISIZE || aType == PREF_ISIZE, "bad type");
   MOZ_ASSERT(aFrame->GetParent()->Type() != LayoutFrameType::GridContainer ||
              aPercentageBasis.isSome(),
              "grid layout should always pass a percentage basis");
 
   const bool horizontalAxis = MOZ_LIKELY(aAxis == eAxisHorizontal);
 #ifdef DEBUG_INTRINSIC_WIDTH
   nsFrame::IndentBy(stderr, gNoiseIndent);
   static_cast<nsFrame*>(aFrame)->ListTag(stderr);
@@ -5590,17 +5590,17 @@ nsLayoutUtils::ComputeBSizeDependentValu
 {
   // XXXldb Some callers explicitly check aContainingBlockBSize
   // against NS_AUTOHEIGHT *and* unit against eStyleUnit_Percent or
   // calc()s containing percents before calling this function.
   // However, it would be much more likely to catch problems without
   // the unit conditions.
   // XXXldb Many callers pass a non-'auto' containing block height when
   // according to CSS2.1 they should be passing 'auto'.
-  NS_PRECONDITION(NS_AUTOHEIGHT != aContainingBlockBSize ||
+  MOZ_ASSERT(NS_AUTOHEIGHT != aContainingBlockBSize ||
                   !aCoord.HasPercent(),
                   "unexpected containing block block-size");
 
   if (aCoord.IsCoordPercentCalcUnit()) {
     return aCoord.ComputeCoordPercentCalc(aContainingBlockBSize);
   }
 
   NS_ASSERTION(aCoord.GetUnit() == eStyleUnit_None ||
@@ -6299,17 +6299,17 @@ nsLayoutUtils::GetLastLineBaseline(Writi
     }
   }
   return false;
 }
 
 static nscoord
 CalculateBlockContentBEnd(WritingMode aWM, nsBlockFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "null ptr");
+  MOZ_ASSERT(aFrame, "null ptr");
 
   nscoord contentBEnd = 0;
 
   for (nsBlockFrame::LineIterator line = aFrame->LinesBegin(),
                                   line_end = aFrame->LinesEnd();
        line != line_end; ++line) {
     if (line->IsBlock()) {
       nsIFrame* child = line->mFirstChild;
@@ -6325,17 +6325,17 @@ CalculateBlockContentBEnd(WritingMode aW
     }
   }
   return contentBEnd;
 }
 
 /* static */ nscoord
 nsLayoutUtils::CalculateContentBEnd(WritingMode aWM, nsIFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "null ptr");
+  MOZ_ASSERT(aFrame, "null ptr");
 
   nscoord contentBEnd = aFrame->BSize(aWM);
 
   // We want scrollable overflow rather than visual because this
   // calculation is intended to affect layout.
   LogicalSize overflowSize(aWM, aFrame->GetScrollableOverflowRect().Size());
   if (overflowSize.BSize(aWM) > contentBEnd) {
     nsIFrame::ChildListIDs skip(nsIFrame::kOverflowList |
@@ -7831,17 +7831,17 @@ nsLayoutUtils::AssertTreeOnlyEmptyNextIn
 }
 #endif
 
 static void
 GetFontFacesForFramesInner(nsIFrame* aFrame,
                            nsLayoutUtils::UsedFontFaceTable& aFontFaces,
                            uint32_t aMaxRanges)
 {
-  NS_PRECONDITION(aFrame, "NULL frame pointer");
+  MOZ_ASSERT(aFrame, "NULL frame pointer");
 
   if (aFrame->IsTextFrame()) {
     if (!aFrame->GetPrevContinuation()) {
       nsLayoutUtils::GetFontFacesForText(aFrame, 0, INT32_MAX, true,
                                          aFontFaces, aMaxRanges);
     }
     return;
   }
@@ -7858,17 +7858,17 @@ GetFontFacesForFramesInner(nsIFrame* aFr
   }
 }
 
 /* static */ nsresult
 nsLayoutUtils::GetFontFacesForFrames(nsIFrame* aFrame,
                                      UsedFontFaceTable& aFontFaces,
                                      uint32_t aMaxRanges)
 {
-  NS_PRECONDITION(aFrame, "NULL frame pointer");
+  MOZ_ASSERT(aFrame, "NULL frame pointer");
 
   while (aFrame) {
     GetFontFacesForFramesInner(aFrame, aFontFaces, aMaxRanges);
     aFrame = GetNextContinuationOrIBSplitSibling(aFrame);
   }
 
   return NS_OK;
 }
@@ -7934,17 +7934,17 @@ AddFontsFromTextRun(gfxTextRun* aTextRun
 /* static */ void
 nsLayoutUtils::GetFontFacesForText(nsIFrame* aFrame,
                                    int32_t aStartOffset,
                                    int32_t aEndOffset,
                                    bool aFollowContinuations,
                                    UsedFontFaceTable& aFontFaces,
                                    uint32_t aMaxRanges)
 {
-  NS_PRECONDITION(aFrame, "NULL frame pointer");
+  MOZ_ASSERT(aFrame, "NULL frame pointer");
 
   if (!aFrame->IsTextFrame()) {
     return;
   }
 
   if (!aFrame->StyleVisibility()->IsVisible()) {
     return;
   }
@@ -7986,17 +7986,17 @@ nsLayoutUtils::GetFontFacesForText(nsIFr
 }
 
 /* static */
 size_t
 nsLayoutUtils::SizeOfTextRunsForFrames(nsIFrame* aFrame,
                                        MallocSizeOf aMallocSizeOf,
                                        bool clear)
 {
-  NS_PRECONDITION(aFrame, "NULL frame pointer");
+  MOZ_ASSERT(aFrame, "NULL frame pointer");
 
   size_t total = 0;
 
   if (aFrame->IsTextFrame()) {
     nsTextFrame* textFrame = static_cast<nsTextFrame*>(aFrame);
     for (uint32_t i = 0; i < 2; ++i) {
       gfxTextRun *run = textFrame->GetTextRun(
         (i != 0) ? nsTextFrame::eInflated : nsTextFrame::eNotInflated);
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -352,17 +352,17 @@ nsPresContext::Destroy()
                                   "intl.accept_languages",
                                   this);
 
   mRefreshDriver = nullptr;
 }
 
 nsPresContext::~nsPresContext()
 {
-  NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
+  MOZ_ASSERT(!mShell, "Presshell forgot to clear our mShell pointer");
   DetachShell();
 
   Destroy();
 }
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPresContext)
    NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
@@ -2848,17 +2848,17 @@ nsPresContext::CheckForInterrupt(nsIFram
     mShell->FrameNeedsToContinueReflow(aFrame);
   }
   return mHasPendingInterrupt;
 }
 
 nsIFrame*
 nsPresContext::GetPrimaryFrameFor(nsIContent* aContent)
 {
-  NS_PRECONDITION(aContent, "Don't do that");
+  MOZ_ASSERT(aContent, "Don't do that");
   if (GetPresShell() &&
       GetPresShell()->GetDocument() == aContent->GetComposedDoc()) {
     return aContent->GetPrimaryFrame();
   }
   return nullptr;
 }
 
 size_t
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1506,19 +1506,19 @@ nsRefreshDriver::ArrayFor(FlushType aFlu
 
 /*
  * nsITimerCallback implementation
  */
 
 void
 nsRefreshDriver::DoTick()
 {
-  NS_PRECONDITION(!IsFrozen(), "Why are we notified while frozen?");
-  NS_PRECONDITION(mPresContext, "Why are we notified after disconnection?");
-  NS_PRECONDITION(!nsContentUtils::GetCurrentJSContext(),
+  MOZ_ASSERT(!IsFrozen(), "Why are we notified while frozen?");
+  MOZ_ASSERT(mPresContext, "Why are we notified after disconnection?");
+  MOZ_ASSERT(!nsContentUtils::GetCurrentJSContext(),
                   "Shouldn't have a JSContext on the stack");
 
   if (mTestControllingRefreshes) {
     Tick(mMostRecentRefreshEpochTime, mMostRecentRefresh);
   } else {
     Tick(JS_Now(), TimeStamp::Now());
   }
 }
@@ -1777,17 +1777,17 @@ nsRefreshDriver::CancelIdleRunnable(nsIR
     delete sPendingIdleRunnables;
     sPendingIdleRunnables = nullptr;
   }
 }
 
 void
 nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
 {
-  NS_PRECONDITION(!nsContentUtils::GetCurrentJSContext(),
+  MOZ_ASSERT(!nsContentUtils::GetCurrentJSContext(),
                   "Shouldn't have a JSContext on the stack");
 
   if (nsNPAPIPluginInstance::InPluginCallUnsafeForReentry()) {
     NS_ERROR("Refresh driver should not run during plugin call!");
     // Try to survive this by just ignoring the refresh tick.
     return;
   }
 
--- a/layout/base/nsStyleSheetService.cpp
+++ b/layout/base/nsStyleSheetService.cpp
@@ -241,17 +241,17 @@ nsStyleSheetService::LoadAndRegisterShee
 NS_IMETHODIMP
 nsStyleSheetService::SheetRegistered(nsIURI *sheetURI,
                                      uint32_t aSheetType, bool *_retval)
 {
   NS_ENSURE_ARG(aSheetType == AGENT_SHEET ||
                 aSheetType == USER_SHEET ||
                 aSheetType == AUTHOR_SHEET);
   NS_ENSURE_ARG_POINTER(sheetURI);
-  NS_PRECONDITION(_retval, "Null out param");
+  MOZ_ASSERT(_retval, "Null out param");
 
   // Check to see if we have the sheet.
   *_retval = (FindSheetByURI(aSheetType, sheetURI) >= 0);
 
   return NS_OK;
 }
 
 static nsresult
@@ -275,17 +275,17 @@ GetParsingMode(uint32_t aSheetType, css:
       return NS_ERROR_INVALID_ARG;
   }
 }
 
 NS_IMETHODIMP
 nsStyleSheetService::PreloadSheet(nsIURI* aSheetURI, uint32_t aSheetType,
                                   nsIPreloadedStyleSheet** aSheet)
 {
-  NS_PRECONDITION(aSheet, "Null out param");
+  MOZ_ASSERT(aSheet, "Null out param");
   NS_ENSURE_ARG_POINTER(aSheetURI);
 
   css::SheetParsingMode parsingMode;
   nsresult rv = GetParsingMode(aSheetType, &parsingMode);
   NS_ENSURE_SUCCESS(rv, rv);
 
   RefPtr<PreloadedStyleSheet> sheet;
   rv = PreloadedStyleSheet::Create(aSheetURI, parsingMode,
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -89,17 +89,17 @@ IsTypeInList(const nsACString& aType, co
   }
 
   return false;
 }
 
 nsresult
 NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult)
 {
-  NS_PRECONDITION(aResult, "null OUT ptr");
+  MOZ_ASSERT(aResult, "null OUT ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
   nsContentDLF* it = new nsContentDLF();
   if (!it) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -280,17 +280,17 @@ Initialize()
 }
 
 // Shutdown this module, releasing all of the module resources
 
 // static
 void
 Shutdown()
 {
-  NS_PRECONDITION(gInitialized, "module not initialized");
+  MOZ_ASSERT(gInitialized, "module not initialized");
   if (!gInitialized)
     return;
 
   gInitialized = false;
 
   nsLayoutStatics::Release();
 }
 
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1056,17 +1056,17 @@ nsComboboxControlFrame::HandleRedisplayT
   PresContext()->Document()->
     FlushPendingNotifications(FlushType::ContentAndNotify);
   if (!weakThis.IsAlive())
     return;
 
   // Redirect frame insertions during this method (see GetContentInsertionFrame())
   // so that any reframing that the frame constructor forces upon us is inserted
   // into the correct parent (mDisplayFrame). See bug 282607.
-  NS_PRECONDITION(!mInRedisplayText, "Nested RedisplayText");
+  MOZ_ASSERT(!mInRedisplayText, "Nested RedisplayText");
   mInRedisplayText = true;
   mRedisplayTextEvent.Forget();
 
   ActuallyDisplayText(true);
   // XXXbz This should perhaps be eResize.  Check.
   PresShell()->FrameNeedsReflow(mDisplayFrame,
                                                nsIPresShell::eStyleChange,
                                                NS_FRAME_IS_DIRTY);
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -360,17 +360,17 @@ nsFieldSetFrame::Reflow(nsPresContext*  
                         ReflowOutput&     aDesiredSize,
                         const ReflowInput& aReflowInput,
                         nsReflowStatus&          aStatus)
 {
   MarkInReflow();
   DO_GLOBAL_REFLOW_COUNT("nsFieldSetFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
-  NS_PRECONDITION(aReflowInput.ComputedISize() != NS_INTRINSICSIZE,
+  MOZ_ASSERT(aReflowInput.ComputedISize() != NS_INTRINSICSIZE,
                   "Should have a precomputed inline-size!");
 
   nsOverflowAreas ocBounds;
   nsReflowStatus ocStatus;
   if (GetPrevInFlow()) {
     ReflowOverflowContainerChildren(aPresContext, aReflowInput, ocBounds, 0,
                                     ocStatus);
   }
@@ -701,9 +701,8 @@ nsFieldSetFrame::GetNaturalBaselineBOffs
 
 void
 nsFieldSetFrame::AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult)
 {
   if (nsIFrame* kid = GetInner()) {
     aResult.AppendElement(OwnedAnonBox(kid));
   }
 }
-
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -363,17 +363,17 @@ nsListControlFrame::GetMinISize(gfxConte
 
 void
 nsListControlFrame::Reflow(nsPresContext*           aPresContext,
                            ReflowOutput&     aDesiredSize,
                            const ReflowInput& aReflowInput,
                            nsReflowStatus&          aStatus)
 {
   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
-  NS_PRECONDITION(aReflowInput.ComputedISize() != NS_UNCONSTRAINEDSIZE,
+  MOZ_ASSERT(aReflowInput.ComputedISize() != NS_UNCONSTRAINEDSIZE,
                   "Must have a computed inline size");
 
   SchedulePaint();
 
   mHasPendingInterruptAtStartOfReflow = aPresContext->HasPendingInterrupt();
 
   // If all the content and frames are here
   // then initialize it before reflow
@@ -498,17 +498,17 @@ nsListControlFrame::Reflow(nsPresContext
 }
 
 void
 nsListControlFrame::ReflowAsDropdown(nsPresContext*           aPresContext,
                                      ReflowOutput&     aDesiredSize,
                                      const ReflowInput& aReflowInput,
                                      nsReflowStatus&          aStatus)
 {
-  NS_PRECONDITION(aReflowInput.ComputedBSize() == NS_UNCONSTRAINEDSIZE,
+  MOZ_ASSERT(aReflowInput.ComputedBSize() == NS_UNCONSTRAINEDSIZE,
                   "We should not have a computed block size here!");
 
   mMightNeedSecondPass = NS_SUBTREE_DIRTY(this) ||
     aReflowInput.ShouldReflowAllKids();
 
   WritingMode wm = aReflowInput.GetWritingMode();
 #ifdef DEBUG
   nscoord oldBSizeOfARow = BSizeOfARow();
@@ -1238,17 +1238,17 @@ static int32_t
 DecrementAndClamp(int32_t aSelectionIndex, int32_t aLength)
 {
   return aLength == 0 ? kNothingSelected : std::max(0, aSelectionIndex - 1);
 }
 
 NS_IMETHODIMP
 nsListControlFrame::RemoveOption(int32_t aIndex)
 {
-  NS_PRECONDITION(aIndex >= 0, "negative <option> index");
+  MOZ_ASSERT(aIndex >= 0, "negative <option> index");
 
   // Need to reset if we're a dropdown
   if (IsInDropDownMode()) {
     mNeedToReset = true;
     mPostChildrenLoadedReset = mIsAllContentHere;
   }
 
   if (mStartSelectionIndex != kNothingSelected) {
@@ -1576,17 +1576,17 @@ nsListControlFrame::CalcFallbackRowBSize
     nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation);
   return fontMet->MaxHeight();
 }
 
 nscoord
 nsListControlFrame::CalcIntrinsicBSize(nscoord aBSizeOfARow,
                                        int32_t aNumberOfOptions)
 {
-  NS_PRECONDITION(!IsInDropDownMode(),
+  MOZ_ASSERT(!IsInDropDownMode(),
                   "Shouldn't be in dropdown mode when we call this");
 
   dom::HTMLSelectElement* select =
     dom::HTMLSelectElement::FromNodeOrNull(mContent);
   if (select) {
     mNumDisplayRows = select->Size();
   } else {
     mNumDisplayRows = 1;
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -1254,18 +1254,18 @@ nsTextControlFrame::SetValueChanged(bool
 nsresult
 nsTextControlFrame::UpdateValueDisplay(bool aNotify,
                                        bool aBeforeEditorInit,
                                        const nsAString *aValue)
 {
   if (!IsSingleLineTextControl()) // textareas don't use this
     return NS_OK;
 
-  NS_PRECONDITION(mRootNode, "Must have a div content\n");
-  NS_PRECONDITION(!mEditorHasBeenInitialized,
+  MOZ_ASSERT(mRootNode, "Must have a div content\n");
+  MOZ_ASSERT(!mEditorHasBeenInitialized,
                   "Do not call this after editor has been initialized");
 
   nsIContent* childContent = mRootNode->GetFirstChild();
   Text* textContent;
   if (!childContent) {
     // Set up a textnode with our value
     RefPtr<nsTextNode> textNode =
       new nsTextNode(mContent->NodeInfo()->NodeInfoManager());
--- a/layout/generic/BlockReflowInput.cpp
+++ b/layout/generic/BlockReflowInput.cpp
@@ -562,19 +562,19 @@ BlockReflowInput::RecoverStateFrom(nsLin
 // technically we're supposed let the current line flow around the
 // float as well unless it won't fit next to what we already have.
 // But nobody else implements it that way...
 bool
 BlockReflowInput::AddFloat(nsLineLayout*       aLineLayout,
                              nsIFrame*           aFloat,
                              nscoord             aAvailableISize)
 {
-  NS_PRECONDITION(aLineLayout, "must have line layout");
-  NS_PRECONDITION(mBlock->LinesEnd() != mCurrentLine, "null ptr");
-  NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
+  MOZ_ASSERT(aLineLayout, "must have line layout");
+  MOZ_ASSERT(mBlock->LinesEnd() != mCurrentLine, "null ptr");
+  MOZ_ASSERT(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
                   "aFloat must be an out-of-flow frame");
 
   MOZ_ASSERT(aFloat->GetParent(), "float must have parent");
   MOZ_ASSERT(aFloat->GetParent()->IsFrameOfType(nsIFrame::eBlockFrame),
              "float's parent must be block");
   MOZ_ASSERT(aFloat->GetParent() == mBlock ||
              (aFloat->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT),
              "float should be in this block unless it was marked as "
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -60,17 +60,17 @@ ReflowInput::ReflowInput(nsPresContext* 
                                      const LogicalSize&   aAvailableSpace,
                                      uint32_t             aFlags)
   : SizeComputationInput(aFrame, aRenderingContext)
   , mBlockDelta(0)
   , mOrthogonalLimit(NS_UNCONSTRAINEDSIZE)
   , mContainingBlockSize(mWritingMode)
   , mReflowDepth(0)
 {
-  NS_PRECONDITION(aRenderingContext, "no rendering context");
+  MOZ_ASSERT(aRenderingContext, "no rendering context");
   MOZ_ASSERT(aPresContext, "no pres context");
   MOZ_ASSERT(aFrame, "no frame");
   MOZ_ASSERT(aPresContext == aFrame->PresContext(), "wrong pres context");
   mParentReflowInput = nullptr;
   AvailableISize() = aAvailableSpace.ISize(mWritingMode);
   AvailableBSize() = aAvailableSpace.BSize(mWritingMode);
   mFloatManager = nullptr;
   mLineLayout = nullptr;
@@ -184,17 +184,17 @@ ReflowInput::ReflowInput(
   , mOrthogonalLimit(NS_UNCONSTRAINEDSIZE)
   , mContainingBlockSize(mWritingMode)
   , mFlags(aParentReflowInput.mFlags)
   , mReflowDepth(aParentReflowInput.mReflowDepth + 1)
 {
   MOZ_ASSERT(aPresContext, "no pres context");
   MOZ_ASSERT(aFrame, "no frame");
   MOZ_ASSERT(aPresContext == aFrame->PresContext(), "wrong pres context");
-  NS_PRECONDITION(!mFlags.mSpecialBSizeReflow ||
+  MOZ_ASSERT(!mFlags.mSpecialBSizeReflow ||
                   !NS_SUBTREE_DIRTY(aFrame),
                   "frame should be clean when getting special bsize reflow");
 
   mParentReflowInput = &aParentReflowInput;
 
   AvailableISize() = aAvailableSpace.ISize(mWritingMode);
   AvailableBSize() = aAvailableSpace.BSize(mWritingMode);
 
@@ -303,17 +303,17 @@ ReflowInput::SetComputedWidth(nscoord aC
   //    want to mess with the resize flags, because comparing the frame's rect
   //    to the munged computed width is pointless.
   // 2) nsFrame::BoxReflow creates a reflow state for its parent.  This reflow
   //    state is not used to reflow the parent, but just as a parent for the
   //    frame's own reflow state.  So given a nsBoxFrame inside some non-XUL
   //    (like a text control, for example), we'll end up creating a reflow
   //    state for the parent while the parent is reflowing.
 
-  NS_PRECONDITION(aComputedWidth >= 0, "Invalid computed width");
+  MOZ_ASSERT(aComputedWidth >= 0, "Invalid computed width");
   if (ComputedWidth() != aComputedWidth) {
     ComputedWidth() = aComputedWidth;
     LayoutFrameType frameType = mFrame->Type();
     if (frameType != LayoutFrameType::Viewport || // Or check GetParent()?
         mWritingMode.IsVertical()) {
       InitResizeFlags(mFrame->PresContext(), frameType);
     }
   }
@@ -327,17 +327,17 @@ ReflowInput::SetComputedHeight(nscoord a
   // because:
   //
   //    nsFrame::BoxReflow creates a reflow state for its parent.  This reflow
   //    state is not used to reflow the parent, but just as a parent for the
   //    frame's own reflow state.  So given a nsBoxFrame inside some non-XUL
   //    (like a text control, for example), we'll end up creating a reflow
   //    state for the parent while the parent is reflowing.
 
-  NS_PRECONDITION(aComputedHeight >= 0, "Invalid computed height");
+  MOZ_ASSERT(aComputedHeight >= 0, "Invalid computed height");
   if (ComputedHeight() != aComputedHeight) {
     ComputedHeight() = aComputedHeight;
     LayoutFrameType frameType = mFrame->Type();
     if (frameType != LayoutFrameType::Viewport || !mWritingMode.IsVertical()) {
       InitResizeFlags(mFrame->PresContext(), frameType);
     }
   }
 }
@@ -1587,17 +1587,17 @@ ReflowInput::CalculateHypotheticalPositi
 void
 ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
                                      const ReflowInput* aReflowInput,
                                      const LogicalSize& aCBSize,
                                      LayoutFrameType aFrameType)
 {
   WritingMode wm = GetWritingMode();
   WritingMode cbwm = aReflowInput->GetWritingMode();
-  NS_PRECONDITION(aCBSize.BSize(cbwm) != NS_AUTOHEIGHT,
+  MOZ_ASSERT(aCBSize.BSize(cbwm) != NS_AUTOHEIGHT,
                   "containing block bsize must be constrained");
 
   NS_ASSERTION(aFrameType != LayoutFrameType::Table,
                "InitAbsoluteConstraints should not be called on table frames");
   NS_ASSERTION(mFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
                "Why are we here?");
 
   const auto& styleOffset = mStylePosition->mOffset;
@@ -2789,17 +2789,17 @@ ReflowInput::CalculateBlockSideMargins(L
 // in eCompensateLeading mode. This is necessary because without this
 // compensation, normal line height might looks too tight.
 
 // For risk management, we use preference to control the behavior, and
 // eNoExternalLeading is the old behavior.
 static nscoord
 GetNormalLineHeight(nsFontMetrics* aFontMetrics)
 {
-  NS_PRECONDITION(nullptr != aFontMetrics, "no font metrics");
+  MOZ_ASSERT(nullptr != aFontMetrics, "no font metrics");
 
   nscoord normalLineHeight;
 
   nscoord externalLeading = aFontMetrics->ExternalLeading();
   nscoord internalLeading = aFontMetrics->InternalLeading();
   nscoord emHeight = aFontMetrics->EmHeight();
   switch (GetNormalLineHeightCalcControl()) {
   case eIncludeExternalLeading:
@@ -2874,17 +2874,17 @@ ReflowInput::CalcLineHeight() const
 
 /* static */ nscoord
 ReflowInput::CalcLineHeight(nsIContent* aContent,
                             ComputedStyle* aComputedStyle,
                             nsPresContext* aPresContext,
                             nscoord aBlockBSize,
                             float aFontSizeInflation)
 {
-  NS_PRECONDITION(aComputedStyle, "Must have a ComputedStyle");
+  MOZ_ASSERT(aComputedStyle, "Must have a ComputedStyle");
 
   nscoord lineHeight =
     ComputeLineHeight(aComputedStyle,
                       aPresContext,
                       aBlockBSize,
                       aFontSizeInflation);
 
   NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -69,20 +69,20 @@ GetSelfOrNearestBlock(nsIFrame* aFrame)
 }
 
 // Return true if the frame is an atomic inline-level element.
 // It's not supposed to be called for block frames since we never
 // process block descendants for text-overflow.
 static bool
 IsAtomicElement(nsIFrame* aFrame, LayoutFrameType aFrameType)
 {
-  NS_PRECONDITION(!nsLayoutUtils::GetAsBlock(aFrame) ||
+  MOZ_ASSERT(!nsLayoutUtils::GetAsBlock(aFrame) ||
                   !aFrame->IsBlockOutside(),
                   "unexpected block frame");
-  NS_PRECONDITION(aFrameType != LayoutFrameType::Placeholder,
+  MOZ_ASSERT(aFrameType != LayoutFrameType::Placeholder,
                   "unexpected placeholder frame");
   return !aFrame->IsFrameOfType(nsIFrame::eLineParticipant);
 }
 
 static bool
 IsFullyClipped(nsTextFrame* aFrame, nscoord aLeft, nscoord aRight,
                nscoord* aSnappedLeft, nscoord* aSnappedRight)
 {
@@ -93,17 +93,17 @@ IsFullyClipped(nsTextFrame* aFrame, nsco
   }
   return !aFrame->MeasureCharClippedText(aLeft, aRight,
                                          aSnappedLeft, aSnappedRight);
 }
 
 static bool
 IsInlineAxisOverflowVisible(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(nsLayoutUtils::GetAsBlock(aFrame) != nullptr,
+  MOZ_ASSERT(nsLayoutUtils::GetAsBlock(aFrame) != nullptr,
                   "expected a block frame");
 
   nsIFrame* f = aFrame;
   while (f && f->Style()->IsAnonBox() && !f->IsScrollFrame()) {
     f = f->GetParent();
   }
   if (!f) {
     return true;
--- a/layout/generic/nsAbsoluteContainingBlock.cpp
+++ b/layout/generic/nsAbsoluteContainingBlock.cpp
@@ -44,17 +44,17 @@ using namespace mozilla;
 
 typedef mozilla::CSSAlignUtils::AlignJustifyFlags AlignJustifyFlags;
 
 void
 nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame*       aDelegatingFrame,
                                                ChildListID     aListID,
                                                nsFrameList&    aChildList)
 {
-  NS_PRECONDITION(mChildListID == aListID, "unexpected child list name");
+  MOZ_ASSERT(mChildListID == aListID, "unexpected child list name");
 #ifdef DEBUG
   nsFrame::VerifyDirtyBitSet(aChildList);
 #endif
   mAbsoluteFrames.SetFrames(aChildList);
 }
 
 void
 nsAbsoluteContainingBlock::AppendFrames(nsIFrame*      aDelegatingFrame,
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -2770,17 +2770,17 @@ nsBlockFrame::MarkLineDirtyForInterrupt(
   }
 }
 
 void
 nsBlockFrame::DeleteLine(BlockReflowInput& aState,
                          nsLineList::iterator aLine,
                          nsLineList::iterator aLineEnd)
 {
-  NS_PRECONDITION(0 == aLine->GetChildCount(), "can't delete !empty line");
+  MOZ_ASSERT(0 == aLine->GetChildCount(), "can't delete !empty line");
   if (0 == aLine->GetChildCount()) {
     NS_ASSERTION(aState.mCurrentLine == aLine,
                  "using function more generally than designed, "
                  "but perhaps OK now");
     nsLineBox* line = aLine;
     aLine = mLines.erase(aLine);
     FreeLineBox(line);
     // Mark the previous margin of the next line dirty since we need to
@@ -2933,17 +2933,17 @@ nsBlockFrame::PullFrameFrom(nsLineBox*  
 
   return frame;
 }
 
 void
 nsBlockFrame::SlideLine(BlockReflowInput& aState,
                         nsLineBox* aLine, nscoord aDeltaBCoord)
 {
-  NS_PRECONDITION(aDeltaBCoord != 0, "why slide a line nowhere?");
+  MOZ_ASSERT(aDeltaBCoord != 0, "why slide a line nowhere?");
 
   // Adjust line state
   aLine->SlideBy(aDeltaBCoord, aState.ContainerSize());
 
   // Adjust the frames in the line
   MoveChildFramesOfLine(aLine, aDeltaBCoord);
 }
 
@@ -3185,17 +3185,17 @@ nsBlockFrame::ShouldApplyBStartMargin(Bl
   return false;
 }
 
 void
 nsBlockFrame::ReflowBlockFrame(BlockReflowInput& aState,
                                LineIterator aLine,
                                bool* aKeepReflowGoing)
 {
-  NS_PRECONDITION(*aKeepReflowGoing, "bad caller");
+  MOZ_ASSERT(*aKeepReflowGoing, "bad caller");
 
   nsIFrame* frame = aLine->mFirstChild;
   if (!frame) {
     NS_ASSERTION(false, "program error - unexpected empty line");
     return;
   }
 
   // Prepare the block reflow engine
@@ -5070,17 +5070,17 @@ nsBlockFrame::GetOverflowOutOfFlows() co
   return result;
 }
 
 // This takes ownership of the frames
 void
 nsBlockFrame::SetOverflowOutOfFlows(const nsFrameList& aList,
                                     nsFrameList* aPropValue)
 {
-  NS_PRECONDITION(!!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) ==
+  MOZ_ASSERT(!!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) ==
                   !!aPropValue, "state does not match value");
 
   if (aList.IsEmpty()) {
     if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) {
       return;
     }
     nsFrameList* list = RemovePropTableFrames(OverflowOutOfFlowsProperty());
     NS_ASSERTION(aPropValue == list, "prop value mismatch");
@@ -6170,17 +6170,17 @@ nsBlockFrame::RemoveFrameFromLine(nsIFra
     FreeLineBox(lineBox);
   }
 }
 
 void
 nsBlockFrame::DeleteNextInFlowChild(nsIFrame* aNextInFlow,
                                     bool      aDeletingEmptyFrames)
 {
-  NS_PRECONDITION(aNextInFlow->GetPrevInFlow(), "bad next-in-flow");
+  MOZ_ASSERT(aNextInFlow->GetPrevInFlow(), "bad next-in-flow");
 
   if (aNextInFlow->GetStateBits() &
       (NS_FRAME_OUT_OF_FLOW | NS_FRAME_IS_OVERFLOW_CONTAINER)) {
     nsContainerFrame::DeleteNextInFlowChild(aNextInFlow, aDeletingEmptyFrames);
   }
   else {
 #ifdef DEBUG
     if (aDeletingEmptyFrames) {
@@ -6243,18 +6243,19 @@ nsBlockFrame::AdjustFloatAvailableSpace(
                      availISize, availBSize);
 }
 
 nscoord
 nsBlockFrame::ComputeFloatISize(BlockReflowInput& aState,
                                 const LogicalRect&  aFloatAvailableSpace,
                                 nsIFrame*           aFloat)
 {
-  NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
+  MOZ_ASSERT(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
                   "aFloat must be an out-of-flow frame");
+
   // Reflow the float.
   LogicalRect availSpace = AdjustFloatAvailableSpace(aState,
                                                      aFloatAvailableSpace,
                                                      aFloat);
 
   WritingMode blockWM = aState.mReflowInput.GetWritingMode();
   WritingMode floatWM = aFloat->GetWritingMode();
   ReflowInput
@@ -6268,18 +6269,19 @@ void
 nsBlockFrame::ReflowFloat(BlockReflowInput& aState,
                           const LogicalRect&  aAdjustedAvailableSpace,
                           nsIFrame*           aFloat,
                           LogicalMargin&      aFloatMargin,
                           LogicalMargin&      aFloatOffsets,
                           bool                aFloatPushedDown,
                           nsReflowStatus&     aReflowStatus)
 {
-  NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
+  MOZ_ASSERT(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
                   "aFloat must be an out-of-flow frame");
+
   // Reflow the float.
   aReflowStatus.Reset();
 
   WritingMode wm = aState.mReflowInput.GetWritingMode();
 #ifdef NOISY_FLOAT
   printf("Reflow Float %p in parent %p, availSpace(%d,%d,%d,%d)\n",
          aFloat, this,
          aAdjustedAvailableSpace.IStart(wm), aAdjustedAvailableSpace.BStart(wm),
@@ -6508,17 +6510,18 @@ nsBlockFrame::RecoverFloats(nsFloatManag
 }
 
 void
 nsBlockFrame::RecoverFloatsFor(nsIFrame*       aFrame,
                                nsFloatManager& aFloatManager,
                                WritingMode     aWM,
                                const nsSize&   aContainerSize)
 {
-  NS_PRECONDITION(aFrame, "null frame");
+  MOZ_ASSERT(aFrame, "null frame");
+
   // Only blocks have floats
   nsBlockFrame* block = nsLayoutUtils::GetAsBlock(aFrame);
   // Don't recover any state inside a block that has its own space manager
   // (we don't currently have any blocks like this, though, thanks to our
   // use of extra frames for 'overflow')
   if (block && !nsBlockFrame::BlockNeedsFloatManager(block)) {
     // If the element is relatively positioned, then adjust x and y
     // accordingly so that we consider relatively positioned frames
@@ -7355,17 +7358,17 @@ nsBlockFrame::IsMarginRoot(bool* aBStart
   *aBStartMarginRoot = true;
   *aBEndMarginRoot = true;
 }
 
 /* static */
 bool
 nsBlockFrame::BlockNeedsFloatManager(nsIFrame* aBlock)
 {
-  NS_PRECONDITION(aBlock, "Must have a frame");
+  MOZ_ASSERT(aBlock, "Must have a frame");
   NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlock), "aBlock must be a block");
 
   nsIFrame* parent = aBlock->GetParent();
   return (aBlock->GetStateBits() & NS_BLOCK_FLOAT_MGR) ||
     (parent && !parent->IsFloatContainingBlock());
 }
 
 /* static */
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -1280,17 +1280,17 @@ nsBulletFrame::OnSizeAvailable(imgIReque
 }
 
 void
 nsBulletFrame::GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup)
 {
   if (!aPresContext)
     return;
 
-  NS_PRECONDITION(nullptr != aLoadGroup, "null OUT parameter pointer");
+  MOZ_ASSERT(nullptr != aLoadGroup, "null OUT parameter pointer");
 
   nsIPresShell *shell = aPresContext->GetPresShell();
 
   if (!shell)
     return;
 
   nsIDocument *doc = shell->GetDocument();
   if (!doc)
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -449,20 +449,20 @@ nsContainerFrame::PositionFrameView(nsIF
   vm->MoveViewTo(view, pt.x, pt.y);
 }
 
 nsresult
 nsContainerFrame::ReparentFrameView(nsIFrame* aChildFrame,
                                     nsIFrame* aOldParentFrame,
                                     nsIFrame* aNewParentFrame)
 {
-  NS_PRECONDITION(aChildFrame, "null child frame pointer");
-  NS_PRECONDITION(aOldParentFrame, "null old parent frame pointer");
-  NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
-  NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
+  MOZ_ASSERT(aChildFrame, "null child frame pointer");
+  MOZ_ASSERT(aOldParentFrame, "null old parent frame pointer");
+  MOZ_ASSERT(aNewParentFrame, "null new parent frame pointer");
+  MOZ_ASSERT(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
 
   // See if either the old parent frame or the new parent frame have a view
   while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
     // Walk up both the old parent frame and the new parent frame nodes
     // stopping when we either find a common parent or views for one
     // or both of the frames.
     //
     // This works well in the common case where we push/pull and the old parent
@@ -508,20 +508,20 @@ nsContainerFrame::ReparentFrameView(nsIF
   return NS_OK;
 }
 
 nsresult
 nsContainerFrame::ReparentFrameViewList(const nsFrameList& aChildFrameList,
                                         nsIFrame*          aOldParentFrame,
                                         nsIFrame*          aNewParentFrame)
 {
-  NS_PRECONDITION(aChildFrameList.NotEmpty(), "empty child frame list");
-  NS_PRECONDITION(aOldParentFrame, "null old parent frame pointer");
-  NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
-  NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
+  MOZ_ASSERT(aChildFrameList.NotEmpty(), "empty child frame list");
+  MOZ_ASSERT(aOldParentFrame, "null old parent frame pointer");
+  MOZ_ASSERT(aNewParentFrame, "null new parent frame pointer");
+  MOZ_ASSERT(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
 
   // See if either the old parent frame or the new parent frame have a view
   while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
     // Walk up both the old parent frame and the new parent frame nodes
     // stopping when we either find a common parent or views for one
     // or both of the frames.
     //
     // This works well in the common case where we push/pull and the old parent
@@ -738,17 +738,17 @@ static nscoord GetCoord(const nsStyleCoo
 void
 nsContainerFrame::DoInlineIntrinsicISize(gfxContext *aRenderingContext,
                                          InlineIntrinsicISizeData *aData,
                                          nsLayoutUtils::IntrinsicISizeType aType)
 {
   if (GetPrevInFlow())
     return; // Already added.
 
-  NS_PRECONDITION(aType == nsLayoutUtils::MIN_ISIZE ||
+  MOZ_ASSERT(aType == nsLayoutUtils::MIN_ISIZE ||
                   aType == nsLayoutUtils::PREF_ISIZE, "bad type");
 
   WritingMode wm = GetWritingMode();
   mozilla::Side startSide =
     wm.PhysicalSideForInlineAxis(eLogicalEdgeStart);
   mozilla::Side endSide =
     wm.PhysicalSideForInlineAxis(eLogicalEdgeEnd);
 
@@ -923,17 +923,17 @@ nsContainerFrame::ReflowChild(nsIFrame* 
                               const ReflowInput&       aReflowInput,
                               const WritingMode&       aWM,
                               const LogicalPoint&      aPos,
                               const nsSize&            aContainerSize,
                               uint32_t                 aFlags,
                               nsReflowStatus&          aStatus,
                               nsOverflowContinuationTracker* aTracker)
 {
-  NS_PRECONDITION(aReflowInput.mFrame == aKidFrame, "bad reflow state");
+  MOZ_ASSERT(aReflowInput.mFrame == aKidFrame, "bad reflow state");
   if (aWM.IsVerticalRL() || (!aWM.IsVertical() && !aWM.IsBidiLTR())) {
     NS_ASSERTION(aContainerSize.width != NS_UNCONSTRAINEDSIZE,
                  "ReflowChild with unconstrained container width!");
   }
   MOZ_ASSERT(aDesiredSize.VisualOverflow() == nsRect(0,0,0,0) &&
              aDesiredSize.ScrollableOverflow() == nsRect(0,0,0,0),
              "please reset the overflow areas before calling ReflowChild");
 
@@ -974,17 +974,17 @@ nsContainerFrame::ReflowChild(nsIFrame* 
                               ReflowOutput&     aDesiredSize,
                               const ReflowInput& aReflowInput,
                               nscoord                  aX,
                               nscoord                  aY,
                               uint32_t                 aFlags,
                               nsReflowStatus&          aStatus,
                               nsOverflowContinuationTracker* aTracker)
 {
-  NS_PRECONDITION(aReflowInput.mFrame == aKidFrame, "bad reflow state");
+  MOZ_ASSERT(aReflowInput.mFrame == aKidFrame, "bad reflow state");
 
   // Position the child frame and its view if requested.
   if (NS_FRAME_NO_MOVE_FRAME != (aFlags & NS_FRAME_NO_MOVE_FRAME)) {
     aKidFrame->SetPosition(nsPoint(aX, aY));
   }
 
   if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
     PositionFrameView(aKidFrame);
@@ -1162,17 +1162,17 @@ nsContainerFrame::FinishReflowChild(nsIF
 void
 nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext*           aPresContext,
                                                   const ReflowInput& aReflowInput,
                                                   nsOverflowAreas&         aOverflowRects,
                                                   uint32_t                 aFlags,
                                                   nsReflowStatus&          aStatus,
                                                   ChildFrameMerger         aMergeFunc)
 {
-  NS_PRECONDITION(aPresContext, "null pointer");
+  MOZ_ASSERT(aPresContext, "null pointer");
 
   nsFrameList* overflowContainers = DrainExcessOverflowContainersList(aMergeFunc);
   if (!overflowContainers) {
     return; // nothing to reflow
   }
 
   nsOverflowContinuationTracker tracker(this, false, false);
   bool shouldReflowAllKids = aReflowInput.ShouldReflowAllKids();
@@ -1394,19 +1394,19 @@ nsContainerFrame::StealFramesAfter(nsIFr
 /*
  * Create a next-in-flow for aFrame. Will return the newly created
  * frame <b>if and only if</b> a new frame is created; otherwise
  * nullptr is returned.
  */
 nsIFrame*
 nsContainerFrame::CreateNextInFlow(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(!IsBlockFrame(),
+  MOZ_ASSERT(!IsBlockFrame(),
                   "you should have called nsBlockFrame::CreateContinuationFor instead");
-  NS_PRECONDITION(mFrames.ContainsFrame(aFrame), "expected an in-flow child frame");
+  MOZ_ASSERT(mFrames.ContainsFrame(aFrame), "expected an in-flow child frame");
 
   nsPresContext* pc = PresContext();
   nsIFrame* nextInFlow = aFrame->GetNextInFlow();
   if (nullptr == nextInFlow) {
     // Create a continuation frame for the child frame and insert it
     // into our child list.
     nextInFlow = pc->PresShell()->FrameConstructor()->
       CreateContinuingFrame(pc, aFrame, this);
@@ -1427,17 +1427,17 @@ nsContainerFrame::CreateNextInFlow(nsIFr
  */
 void
 nsContainerFrame::DeleteNextInFlowChild(nsIFrame* aNextInFlow,
                                         bool      aDeletingEmptyFrames)
 {
 #ifdef DEBUG
   nsIFrame* prevInFlow = aNextInFlow->GetPrevInFlow();
 #endif
-  NS_PRECONDITION(prevInFlow, "bad prev-in-flow");
+  MOZ_ASSERT(prevInFlow, "bad prev-in-flow");
 
   // If the next-in-flow has a next-in-flow then delete it, too (and
   // delete it first).
   // Do this in a loop so we don't overflow the stack for frames
   // with very many next-in-flows
   nsIFrame* nextNextInFlow = aNextInFlow->GetNextInFlow();
   if (nextNextInFlow) {
     AutoTArray<nsIFrame*, 8> frames;
@@ -1468,17 +1468,17 @@ nsContainerFrame::DeleteNextInFlowChild(
 }
 
 /**
  * Set the frames on the overflow list
  */
 void
 nsContainerFrame::SetOverflowFrames(const nsFrameList& aOverflowFrames)
 {
-  NS_PRECONDITION(aOverflowFrames.NotEmpty(), "Shouldn't be called");
+  MOZ_ASSERT(aOverflowFrames.NotEmpty(), "Shouldn't be called");
 
   nsPresContext* pc = PresContext();
   nsFrameList* newList = new (pc->PresShell()) nsFrameList(aOverflowFrames);
 
   SetProperty(OverflowProperty(), newList);
 }
 
 nsFrameList*
@@ -1493,46 +1493,46 @@ nsContainerFrame::RemovePropTableFrames(
 {
   return RemoveProperty(aProperty);
 }
 
 void
 nsContainerFrame::SetPropTableFrames(nsFrameList* aFrameList,
                                      FrameListPropertyDescriptor aProperty)
 {
-  NS_PRECONDITION(aProperty && aFrameList, "null ptr");
-  NS_PRECONDITION(
+  MOZ_ASSERT(aProperty && aFrameList, "null ptr");
+  MOZ_ASSERT(
     (aProperty != nsContainerFrame::OverflowContainersProperty() &&
      aProperty != nsContainerFrame::ExcessOverflowContainersProperty()) ||
     IsFrameOfType(nsIFrame::eCanContainOverflowContainers),
     "this type of frame can't have overflow containers");
   MOZ_ASSERT(!GetPropTableFrames(aProperty));
   SetProperty(aProperty, aFrameList);
 }
 
 void
 nsContainerFrame::PushChildrenToOverflow(nsIFrame* aFromChild,
                                          nsIFrame* aPrevSibling)
 {
-  NS_PRECONDITION(aFromChild, "null pointer");
-  NS_PRECONDITION(aPrevSibling, "pushing first child");
-  NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
+  MOZ_ASSERT(aFromChild, "null pointer");
+  MOZ_ASSERT(aPrevSibling, "pushing first child");
+  MOZ_ASSERT(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
 
   // Add the frames to our overflow list (let our next in flow drain
   // our overflow list when it is ready)
   SetOverflowFrames(mFrames.RemoveFramesAfter(aPrevSibling));
 }
 
 void
 nsContainerFrame::PushChildren(nsIFrame* aFromChild,
                                nsIFrame* aPrevSibling)
 {
-  NS_PRECONDITION(aFromChild, "null pointer");
-  NS_PRECONDITION(aPrevSibling, "pushing first child");
-  NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
+  MOZ_ASSERT(aFromChild, "null pointer");
+  MOZ_ASSERT(aPrevSibling, "pushing first child");
+  MOZ_ASSERT(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
 
   // Disconnect aFromChild from its previous sibling
   nsFrameList tail = mFrames.RemoveFramesAfter(aPrevSibling);
 
   nsContainerFrame* nextInFlow =
     static_cast<nsContainerFrame*>(GetNextInFlow());
   if (nextInFlow) {
     // XXX This is not a very good thing to do. If it gets removed
@@ -1868,17 +1868,17 @@ nsContainerFrame::RenumberList()
 #define MAX_DEPTH_FOR_LIST_RENUMBERING 200  // 200 open displayable tags is pretty unrealistic
 
 bool
 nsContainerFrame::RenumberFrameAndDescendants(int32_t* aOrdinal,
                                               int32_t aDepth,
                                               int32_t aIncrement,
                                               bool aForCounting)
 {
-  NS_PRECONDITION(aOrdinal, "null params are immoral!");
+  MOZ_ASSERT(aOrdinal, "null params are immoral!");
 
   // add in a sanity check for absurdly deep frame trees.  See bug 42138
   if (MAX_DEPTH_FOR_LIST_RENUMBERING < aDepth) {
     return false;
   }
   const nsStyleDisplay* display = StyleDisplay();
 
   // drill down through any wrappers to the real frame
@@ -2030,25 +2030,25 @@ nsOverflowContinuationTracker::nsOverflo
                                                              bool              aSkipOverflowContainerChildren)
   : mOverflowContList(nullptr),
     mPrevOverflowCont(nullptr),
     mSentry(nullptr),
     mParent(aFrame),
     mSkipOverflowContainerChildren(aSkipOverflowContainerChildren),
     mWalkOOFFrames(aWalkOOFFrames)
 {
-  NS_PRECONDITION(aFrame, "null frame pointer");
+  MOZ_ASSERT(aFrame, "null frame pointer");
   SetupOverflowContList();
 }
 
 void
 nsOverflowContinuationTracker::SetupOverflowContList()
 {
-  NS_PRECONDITION(mParent, "null frame pointer");
-  NS_PRECONDITION(!mOverflowContList, "already have list");
+  MOZ_ASSERT(mParent, "null frame pointer");
+  MOZ_ASSERT(!mOverflowContList, "already have list");
   nsContainerFrame* nif =
     static_cast<nsContainerFrame*>(mParent->GetNextInFlow());
   if (nif) {
     mOverflowContList = nif->GetPropTableFrames(
       nsContainerFrame::OverflowContainersProperty());
     if (mOverflowContList) {
       mParent = nif;
       SetUpListWalker();
@@ -2096,17 +2096,17 @@ nsOverflowContinuationTracker::SetUpList
  * Helper function to step forward through the overflow continuations list.
  * Sets mSentry and mPrevOverflowCont, skipping over OOF or non-OOF frames
  * as appropriate. May only be called when we have already set up an
  * mOverflowContList; mOverflowContList cannot be null.
  */
 void
 nsOverflowContinuationTracker::StepForward()
 {
-  NS_PRECONDITION(mOverflowContList, "null list");
+  MOZ_ASSERT(mOverflowContList, "null list");
 
   // Step forward
   if (mPrevOverflowCont) {
     mPrevOverflowCont = mPrevOverflowCont->GetNextSibling();
   }
   else {
     mPrevOverflowCont = mOverflowContList->FirstChild();
   }
@@ -2126,21 +2126,21 @@ nsOverflowContinuationTracker::StepForwa
             ? mPrevOverflowCont->GetNextSibling()->GetPrevInFlow()
             : nullptr;
 }
 
 nsresult
 nsOverflowContinuationTracker::Insert(nsIFrame*       aOverflowCont,
                                       nsReflowStatus& aReflowStatus)
 {
-  NS_PRECONDITION(aOverflowCont, "null frame pointer");
-  NS_PRECONDITION(!mSkipOverflowContainerChildren || mWalkOOFFrames ==
+  MOZ_ASSERT(aOverflowCont, "null frame pointer");
+  MOZ_ASSERT(!mSkipOverflowContainerChildren || mWalkOOFFrames ==
                   !!(aOverflowCont->GetStateBits() & NS_FRAME_OUT_OF_FLOW),
                   "shouldn't insert frame that doesn't match walker type");
-  NS_PRECONDITION(aOverflowCont->GetPrevInFlow(),
+  MOZ_ASSERT(aOverflowCont->GetPrevInFlow(),
                   "overflow containers must have a prev-in-flow");
   nsresult rv = NS_OK;
   bool reparented = false;
   nsPresContext* presContext = aOverflowCont->PresContext();
   bool addToList = !mSentry || aOverflowCont != mSentry->GetNextInFlow();
 
   // If we have a list and aOverflowCont is already in it then don't try to
   // add it again.
@@ -2230,18 +2230,18 @@ nsOverflowContinuationTracker::Insert(ns
     }
   }
   return rv;
 }
 
 void
 nsOverflowContinuationTracker::BeginFinish(nsIFrame* aChild)
 {
-  NS_PRECONDITION(aChild, "null ptr");
-  NS_PRECONDITION(aChild->GetNextInFlow(),
+  MOZ_ASSERT(aChild, "null ptr");
+  MOZ_ASSERT(aChild->GetNextInFlow(),
                   "supposed to call Finish *before* deleting next-in-flow!");
   for (nsIFrame* f = aChild; f; f = f->GetNextInFlow()) {
     // We'll update these in EndFinish after the next-in-flows are gone.
     if (f == mPrevOverflowCont) {
       mSentry = nullptr;
       mPrevOverflowCont = nullptr;
       break;
     }
--- a/layout/generic/nsContainerFrame.h
+++ b/layout/generic/nsContainerFrame.h
@@ -861,17 +861,17 @@ public:
    * reflow flag if it encounters an overflow continuation so that our
    * next-in-flow doesn't get prematurely deleted. It MUST be called on
    * each unreflowed child that has an overflow container continuation;
    * it MAY be called on other children, but it isn't necessary (doesn't
    * do anything).
    */
   void Skip(nsIFrame* aChild, nsReflowStatus& aReflowStatus)
   {
-    NS_PRECONDITION(aChild, "null ptr");
+    MOZ_ASSERT(aChild, "null ptr");
     if (aChild == mSentry) {
       StepForward();
       if (aReflowStatus.IsComplete()) {
         aReflowStatus.SetOverflowIncomplete();
       }
     }
   }
 
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -302,17 +302,17 @@ nsFirstLetterFrame::CanContinueTextRun()
 nsresult
 nsFirstLetterFrame::CreateContinuationForFloatingParent(nsPresContext* aPresContext,
                                                         nsIFrame* aChild,
                                                         nsIFrame** aContinuation,
                                                         bool aIsFluid)
 {
   NS_ASSERTION(IsFloating(),
                "can only call this on floating first letter frames");
-  NS_PRECONDITION(aContinuation, "bad args");
+  MOZ_ASSERT(aContinuation, "bad args");
 
   *aContinuation = nullptr;
 
   nsIPresShell* presShell = aPresContext->PresShell();
   nsPlaceholderFrame* placeholderFrame = GetPlaceholderFrame();
   nsContainerFrame* parent = placeholderFrame->GetParent();
 
   nsIFrame* continuation = presShell->FrameConstructor()->
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -382,17 +382,17 @@ nsFloatManager::RemoveTrailingRegions(ns
 #endif
 
   return NS_OK;
 }
 
 void
 nsFloatManager::PushState(SavedState* aState)
 {
-  NS_PRECONDITION(aState, "Need a place to save state");
+  MOZ_ASSERT(aState, "Need a place to save state");
 
   // This is a cheap push implementation, which
   // only saves the (x,y) and last frame in the mFrameInfoMap
   // which is enough info to get us back to where we should be
   // when pop is called.
   //
   // This push/pop mechanism is used to undo any
   // floats that were added during the unconstrained reflow
@@ -413,17 +413,17 @@ nsFloatManager::PushState(SavedState* aS
   aState->mSplitLeftFloatAcrossBreak = mSplitLeftFloatAcrossBreak;
   aState->mSplitRightFloatAcrossBreak = mSplitRightFloatAcrossBreak;
   aState->mFloatInfoCount = mFloats.Length();
 }
 
 void
 nsFloatManager::PopState(SavedState* aState)
 {
-  NS_PRECONDITION(aState, "No state to restore?");
+  MOZ_ASSERT(aState, "No state to restore?");
 
   mLineLeft = aState->mLineLeft;
   mBlockStart = aState->mBlockStart;
   mPushedLeftFloatPastBreak = aState->mPushedLeftFloatPastBreak;
   mPushedRightFloatPastBreak = aState->mPushedRightFloatPastBreak;
   mSplitLeftFloatAcrossBreak = aState->mSplitLeftFloatAcrossBreak;
   mSplitRightFloatAcrossBreak = aState->mSplitRightFloatAcrossBreak;
 
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -599,17 +599,17 @@ IsFontSizeInflationContainer(nsIFrame* a
 }
 
 void
 nsFrame::Init(nsIContent*       aContent,
               nsContainerFrame* aParent,
               nsIFrame*         aPrevInFlow)
 {
   MOZ_ASSERT(nsQueryFrame::FrameIID(mClass) == GetFrameId());
-  NS_PRECONDITION(!mContent, "Double-initing a frame?");
+  MOZ_ASSERT(!mContent, "Double-initing a frame?");
   NS_ASSERTION(IsFrameOfType(eDEBUGAllFrames) &&
                !IsFrameOfType(eDEBUGNoFrames),
                "IsFrameOfType implementation that doesn't call base class");
 
   mContent = aContent;
   mParent = aParent;
 
   if (aPrevInFlow) {
@@ -1869,25 +1869,25 @@ nsIFrame::GetShapeBoxBorderRadii(nscoord
       MOZ_ASSERT_UNREACHABLE("Unexpected box value");
       return false;
   }
 }
 
 ComputedStyle*
 nsFrame::GetAdditionalComputedStyle(int32_t aIndex) const
 {
-  NS_PRECONDITION(aIndex >= 0, "invalid index number");
+  MOZ_ASSERT(aIndex >= 0, "invalid index number");
   return nullptr;
 }
 
 void
 nsFrame::SetAdditionalComputedStyle(int32_t aIndex,
                                    ComputedStyle* aComputedStyle)
 {
-  NS_PRECONDITION(aIndex >= 0, "invalid index number");
+  MOZ_ASSERT(aIndex >= 0, "invalid index number");
 }
 
 nscoord
 nsFrame::GetLogicalBaseline(WritingMode aWritingMode) const
 {
   NS_ASSERTION(!NS_SUBTREE_DIRTY(this),
                "frame must not be dirty");
   // Baseline for inverted line content is the top (block-start) margin edge,
@@ -6401,22 +6401,22 @@ nsFrame::ShrinkWidthToFit(gfxContext*   
 nscoord
 nsIFrame::ComputeISizeValue(gfxContext*         aRenderingContext,
                             nscoord             aContainingBlockISize,
                             nscoord             aContentEdgeToBoxSizing,
                             nscoord             aBoxSizingToMarginEdge,
                             const nsStyleCoord& aCoord,
                             ComputeSizeFlags    aFlags)
 {
-  NS_PRECONDITION(aRenderingContext, "non-null rendering context expected");
+  MOZ_ASSERT(aRenderingContext, "non-null rendering context expected");
   LAYOUT_WARN_IF_FALSE(aContainingBlockISize != NS_UNCONSTRAINEDSIZE,
                        "have unconstrained inline-size; this should only result from "
                        "very large sizes, not attempts at intrinsic inline-size "
                        "calculation");
-  NS_PRECONDITION(aContainingBlockISize >= 0,
+  MOZ_ASSERT(aContainingBlockISize >= 0,
                   "inline-size less than zero");
 
   nscoord result;
   if (aCoord.IsCoordPercentCalcUnit()) {
     result = aCoord.ComputeCoordPercentCalc(aContainingBlockISize);
     // The result of a calc() expression might be less than 0; we
     // should clamp at runtime (below).  (Percentages and coords that
     // are less than 0 have already been dropped by the parser.)
@@ -6712,17 +6712,17 @@ nsIFrame* nsIFrame::GetAncestorWithView(
     }
   }
   return nullptr;
 }
 
 template<nsPoint (nsIFrame::* PositionGetter)() const>
 static nsPoint OffsetCalculator(const nsIFrame* aThis, const nsIFrame* aOther)
 {
-  NS_PRECONDITION(aOther,
+  MOZ_ASSERT(aOther,
                   "Must have frame for destination coordinate system!");
 
   NS_ASSERTION(aThis->PresContext() == aOther->PresContext(),
                "GetOffsetTo called on frames in different documents");
 
   nsPoint offset(0, 0);
   const nsIFrame* f;
   for (f = aThis; f != aOther && f; f = f->GetParent()) {
@@ -6757,17 +6757,17 @@ nsIFrame::GetOffsetToIgnoringScrolling(c
 nsPoint nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther) const
 {
   return GetOffsetToCrossDoc(aOther, PresContext()->AppUnitsPerDevPixel());
 }
 
 nsPoint
 nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther, const int32_t aAPD) const
 {
-  NS_PRECONDITION(aOther,
+  MOZ_ASSERT(aOther,
                   "Must have frame for destination coordinate system!");
   NS_ASSERTION(PresContext()->GetRootPresContext() ==
                  aOther->PresContext()->GetRootPresContext(),
                "trying to get the offset between frames in different document "
                "hierarchies?");
   if (PresContext()->GetRootPresContext() !=
         aOther->PresContext()->GetRootPresContext()) {
     // crash right away, we are almost certainly going to crash anyway.
@@ -6851,17 +6851,17 @@ nsRect nsIFrame::GetScreenRectInAppUnits
   return nsRect(rootScreenPos + GetOffsetTo(rootFrame), GetSize());
 }
 
 // Returns the offset from this frame to the closest geometric parent that
 // has a view. Also returns the containing view or null in case of error
 void
 nsIFrame::GetOffsetFromView(nsPoint& aOffset, nsView** aView) const
 {
-  NS_PRECONDITION(nullptr != aView, "null OUT parameter pointer");
+  MOZ_ASSERT(nullptr != aView, "null OUT parameter pointer");
   nsIFrame* frame = const_cast<nsIFrame*>(this);
 
   *aView = nullptr;
   aOffset.MoveTo(0, 0);
   do {
     aOffset += frame->GetPosition();
     frame = frame->GetParent();
   } while (frame && !frame->HasView());
@@ -6888,17 +6888,17 @@ nsIFrame::GetNearestWidget(nsPoint& aOff
   return widget;
 }
 
 Matrix4x4Flagged
 nsIFrame::GetTransformMatrix(const nsIFrame* aStopAtAncestor,
                              nsIFrame** aOutAncestor,
                              uint32_t aFlags)
 {
-  NS_PRECONDITION(aOutAncestor, "Need a place to put the ancestor!");
+  MOZ_ASSERT(aOutAncestor, "Need a place to put the ancestor!");
 
   /* If we're transformed, we want to hand back the combination
    * transform/translate matrix that will apply our current transform, then
    * shift us to our parent.
    */
   if (IsTransformed()) {
     /* Compute the delta to the parent, which we need because we are converting
      * coordinates to our parent.
@@ -7967,17 +7967,17 @@ nsIFrame::IsVisibleInSelection(nsISelect
 nsFrame::IsEmpty()
 {
   return false;
 }
 
 bool
 nsIFrame::CachedIsEmpty()
 {
-  NS_PRECONDITION(!(GetStateBits() & NS_FRAME_IS_DIRTY),
+  MOZ_ASSERT(!(GetStateBits() & NS_FRAME_IS_DIRTY),
                   "Must only be called on reflowed lines");
   return IsEmpty();
 }
 
 /* virtual */ bool
 nsFrame::IsSelfEmpty()
 {
   return false;
@@ -8031,17 +8031,17 @@ nsIFrame::IsFrameSelected() const
                "use the public IsSelected() instead");
   return nsRange::IsNodeSelected(GetContent(), 0,
                                  GetContent()->GetChildCount());
 }
 
 nsresult
 nsFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint)
 {
-  NS_PRECONDITION(outPoint != nullptr, "Null parameter");
+  MOZ_ASSERT(outPoint != nullptr, "Null parameter");
   nsRect contentRect = GetContentRectRelativeToSelf();
   nsPoint pt = contentRect.TopLeft();
   if (mContent)
   {
     nsIContent* newContent = mContent->GetParent();
     if (newContent){
       int32_t newOffset = newContent->ComputeIndexOf(mContent);
 
@@ -8071,17 +8071,17 @@ nsFrame::GetCharacterRectsInRange(int32_
 {
   /* no text */
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 nsFrame::GetChildFrameContainingOffset(int32_t inContentOffset, bool inHint, int32_t* outFrameContentOffset, nsIFrame **outChildFrame)
 {
-  NS_PRECONDITION(outChildFrame && outFrameContentOffset, "Null parameter");
+  MOZ_ASSERT(outChildFrame && outFrameContentOffset, "Null parameter");
   *outFrameContentOffset = (int32_t)inHint;
   //the best frame to reflect any given offset would be a visible frame if possible
   //i.e. we are looking for a valid frame to place the blinking caret
   nsRect rect = GetRect();
   if (!rect.width || !rect.height)
   {
     //if we have a 0 width or height then lets look for another frame that possibly has
     //the same content.  If we have no frames in flow then just let us return 'this' frame
@@ -9765,17 +9765,17 @@ nsFrame::ShouldAvoidBreakInside(const Re
  * returns the block's preceding inline.  This is needed because the
  * split inline's style is the parent of the anonymous block's style.
  *
  * If aFrame is not an anonymous block, null is returned.
  */
 static nsIFrame*
 GetIBSplitSiblingForAnonymousBlock(const nsIFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "Must have a non-null frame!");
+  MOZ_ASSERT(aFrame, "Must have a non-null frame!");
   NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT,
                "GetIBSplitSibling should only be called on ib-split frames");
 
   nsAtom* type = aFrame->Style()->GetPseudo();
   if (type != nsCSSAnonBoxes::mozBlockInsideInlineWrapper) {
     // it's not an anonymous block
     return nullptr;
   }
@@ -9859,17 +9859,17 @@ GetCorrectedParent(const nsIFrame* aFram
   return nsFrame::CorrectStyleParentFrame(parent, pseudo);
 }
 
 /* static */
 nsIFrame*
 nsFrame::CorrectStyleParentFrame(nsIFrame* aProspectiveParent,
                                  nsAtom* aChildPseudo)
 {
-  NS_PRECONDITION(aProspectiveParent, "Must have a prospective parent");
+  MOZ_ASSERT(aProspectiveParent, "Must have a prospective parent");
 
   if (aChildPseudo) {
     // Non-inheriting anon boxes have no style parent frame at all.
     if (nsCSSAnonBoxes::IsNonInheritingAnonBox(aChildPseudo)) {
       return nullptr;
     }
 
     // Other anon boxes are parented to their actual parent already, except
@@ -12556,18 +12556,18 @@ void DR_cookie::Change() const
 /* static */ void*
 ReflowInput::DisplayInitConstraintsEnter(nsIFrame* aFrame,
                                                ReflowInput* aState,
                                                nscoord aContainingBlockWidth,
                                                nscoord aContainingBlockHeight,
                                                const nsMargin* aBorder,
                                                const nsMargin* aPadding)
 {
-  NS_PRECONDITION(aFrame, "non-null frame required");
-  NS_PRECONDITION(aState, "non-null state required");
+  MOZ_ASSERT(aFrame, "non-null frame required");
+  MOZ_ASSERT(aState, "non-null state required");
 
   if (!DR_state->mInited) DR_state->Init();
   if (!DR_state->mActive) return nullptr;
 
   DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, aState);
   if (treeNode && treeNode->mDisplay) {
     DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
 
@@ -12592,18 +12592,18 @@ ReflowInput::DisplayInitConstraintsEnter
   return treeNode;
 }
 
 /* static */ void
 ReflowInput::DisplayInitConstraintsExit(nsIFrame* aFrame,
                                               ReflowInput* aState,
                                               void* aValue)
 {
-  NS_PRECONDITION(aFrame, "non-null frame required");
-  NS_PRECONDITION(aState, "non-null state required");
+  MOZ_ASSERT(aFrame, "non-null frame required");
+  MOZ_ASSERT(aState, "non-null state required");
 
   if (!DR_state->mActive) return;
   if (!aValue) return;
 
   DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aValue;
   if (treeNode->mDisplay) {
     DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
     char cmiw[16], cw[16], cmxw[16], cmih[16], ch[16], cmxh[16];
@@ -12625,18 +12625,18 @@ ReflowInput::DisplayInitConstraintsExit(
 /* static */ void*
 SizeComputationInput::DisplayInitOffsetsEnter(nsIFrame* aFrame,
                                           SizeComputationInput* aState,
                                           nscoord aPercentBasis,
                                           WritingMode aCBWritingMode,
                                           const nsMargin* aBorder,
                                           const nsMargin* aPadding)
 {
-  NS_PRECONDITION(aFrame, "non-null frame required");
-  NS_PRECONDITION(aState, "non-null state required");
+  MOZ_ASSERT(aFrame, "non-null frame required");
+  MOZ_ASSERT(aState, "non-null state required");
 
   if (!DR_state->mInited) DR_state->Init();
   if (!DR_state->mActive) return nullptr;
 
   // aState is not necessarily a ReflowInput
   DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, nullptr);
   if (treeNode && treeNode->mDisplay) {
     DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
@@ -12652,18 +12652,18 @@ SizeComputationInput::DisplayInitOffsets
   return treeNode;
 }
 
 /* static */ void
 SizeComputationInput::DisplayInitOffsetsExit(nsIFrame* aFrame,
                                          SizeComputationInput* aState,
                                          void* aValue)
 {
-  NS_PRECONDITION(aFrame, "non-null frame required");
-  NS_PRECONDITION(aState, "non-null state required");
+  MOZ_ASSERT(aFrame, "non-null frame required");
+  MOZ_ASSERT(aState, "non-null state required");
 
   if (!DR_state->mActive) return;
   if (!aValue) return;
 
   DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aValue;
   if (treeNode->mDisplay) {
     DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
     printf("InitOffsets=");
@@ -12674,33 +12674,33 @@ SizeComputationInput::DisplayInitOffsets
   }
   DR_state->DeleteTreeNode(*treeNode);
 }
 
 /* static */ void*
 ReflowInput::DisplayInitFrameTypeEnter(nsIFrame* aFrame,
                                              ReflowInput* aState)
 {
-  NS_PRECONDITION(aFrame, "non-null frame required");
-  NS_PRECONDITION(aState, "non-null state required");
+  MOZ_ASSERT(aFrame, "non-null frame required");
+  MOZ_ASSERT(aState, "non-null state required");
 
   if (!DR_state->mInited) DR_state->Init();
   if (!DR_state->mActive) return nullptr;
 
   // we don't print anything here
   return DR_state->CreateTreeNode(aFrame, aState);
 }
 
 /* static */ void
 ReflowInput::DisplayInitFrameTypeExit(nsIFrame* aFrame,
                                             ReflowInput* aState,
                                             void* aValue)
 {
-  NS_PRECONDITION(aFrame, "non-null frame required");
-  NS_PRECONDITION(aState, "non-null state required");
+  MOZ_ASSERT(aFrame, "non-null frame required");
+  MOZ_ASSERT(aState, "non-null state required");
 
   if (!DR_state->mActive) return;
   if (!aValue) return;
 
   DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aValue;
   if (treeNode->mDisplay) {
     DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
     printf("InitFrameType");
--- a/layout/generic/nsFrameList.cpp
+++ b/layout/generic/nsFrameList.cpp
@@ -29,17 +29,17 @@ void*
 nsFrameList::operator new(size_t sz, nsIPresShell* aPresShell)
 {
   return aPresShell->AllocateByObjectID(eArenaObjectID_nsFrameList, sz);
 }
 
 void
 nsFrameList::Delete(nsIPresShell* aPresShell)
 {
-  NS_PRECONDITION(this != &EmptyList(), "Shouldn't Delete() this list");
+  MOZ_ASSERT(this != &EmptyList(), "Shouldn't Delete() this list");
   NS_ASSERTION(IsEmpty(), "Shouldn't Delete() a non-empty list");
 
   aPresShell->FreeByObjectID(eArenaObjectID_nsFrameList, this);
 }
 
 void
 nsFrameList::DestroyFrames()
 {
@@ -48,40 +48,40 @@ nsFrameList::DestroyFrames()
   }
   mLastChild = nullptr;
 }
 
 void
 nsFrameList::DestroyFramesFrom(nsIFrame* aDestructRoot,
                                layout::PostFrameDestroyData& aPostDestroyData)
 {
-  NS_PRECONDITION(aDestructRoot, "Missing destruct root");
+  MOZ_ASSERT(aDestructRoot, "Missing destruct root");
 
   while (nsIFrame* frame = RemoveFirstChild()) {
     frame->DestroyFrom(aDestructRoot, aPostDestroyData);
   }
   mLastChild = nullptr;
 }
 
 void
 nsFrameList::SetFrames(nsIFrame* aFrameList)
 {
-  NS_PRECONDITION(!mFirstChild, "Losing frames");
+  MOZ_ASSERT(!mFirstChild, "Losing frames");
 
   mFirstChild = aFrameList;
   mLastChild = nsLayoutUtils::GetLastSibling(mFirstChild);
 }
 
 void
 nsFrameList::RemoveFrame(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "null ptr");
+  MOZ_ASSERT(aFrame, "null ptr");
 #ifdef DEBUG_FRAME_LIST
   // ContainsFrame is O(N)
-  NS_PRECONDITION(ContainsFrame(aFrame), "wrong list");
+  MOZ_ASSERT(ContainsFrame(aFrame), "wrong list");
 #endif
 
   nsIFrame* nextFrame = aFrame->GetNextSibling();
   if (aFrame == mFirstChild) {
     mFirstChild = nextFrame;
     aFrame->SetNextSibling(nullptr);
     if (!nextFrame) {
       mLastChild = nullptr;
@@ -103,19 +103,19 @@ nsFrameList
 nsFrameList::RemoveFramesAfter(nsIFrame* aAfterFrame)
 {
   if (!aAfterFrame) {
     nsFrameList result;
     result.InsertFrames(nullptr, nullptr, *this);
     return result;
   }
 
-  NS_PRECONDITION(NotEmpty(), "illegal operation on empty list");
+  MOZ_ASSERT(NotEmpty(), "illegal operation on empty list");
 #ifdef DEBUG_FRAME_LIST
-  NS_PRECONDITION(ContainsFrame(aAfterFrame), "wrong list");
+  MOZ_ASSERT(ContainsFrame(aAfterFrame), "wrong list");
 #endif
 
   nsIFrame* tail = aAfterFrame->GetNextSibling();
   // if (!tail) return EmptyList();  -- worth optimizing this case?
   nsIFrame* oldLastChild = mLastChild;
   mLastChild = aAfterFrame;
   aAfterFrame->SetNextSibling(nullptr);
   return nsFrameList(tail, tail ? oldLastChild : nullptr);
@@ -130,26 +130,26 @@ nsFrameList::RemoveFirstChild()
     return firstChild;
   }
   return nullptr;
 }
 
 void
 nsFrameList::DestroyFrame(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "null ptr");
+  MOZ_ASSERT(aFrame, "null ptr");
   RemoveFrame(aFrame);
   aFrame->Destroy();
 }
 
 nsFrameList::Slice
 nsFrameList::InsertFrames(nsContainerFrame* aParent, nsIFrame* aPrevSibling,
                           nsFrameList& aFrameList)
 {
-  NS_PRECONDITION(aFrameList.NotEmpty(), "Unexpected empty list");
+  MOZ_ASSERT(aFrameList.NotEmpty(), "Unexpected empty list");
 
   if (aParent) {
     aFrameList.ApplySetParent(aParent);
   }
 
   NS_ASSERTION(IsEmpty() ||
                FirstChild()->GetParent() == aFrameList.FirstChild()->GetParent(),
                "frame to add has different parent");
@@ -183,28 +183,28 @@ nsFrameList::InsertFrames(nsContainerFra
 
   aFrameList.Clear();
   return Slice(*this, firstNewFrame, nextSibling);
 }
 
 nsFrameList
 nsFrameList::ExtractHead(FrameLinkEnumerator& aLink)
 {
-  NS_PRECONDITION(&aLink.List() == this, "Unexpected list");
-  NS_PRECONDITION(!aLink.PrevFrame() ||
+  MOZ_ASSERT(&aLink.List() == this, "Unexpected list");
+  MOZ_ASSERT(!aLink.PrevFrame() ||
                   aLink.PrevFrame()->GetNextSibling() ==
                     aLink.NextFrame(),
                   "Unexpected PrevFrame()");
-  NS_PRECONDITION(aLink.PrevFrame() ||
+  MOZ_ASSERT(aLink.PrevFrame() ||
                   aLink.NextFrame() == FirstChild(),
                   "Unexpected NextFrame()");
-  NS_PRECONDITION(!aLink.PrevFrame() ||
+  MOZ_ASSERT(!aLink.PrevFrame() ||
                   aLink.NextFrame() != FirstChild(),
                   "Unexpected NextFrame()");
-  NS_PRECONDITION(aLink.mEnd == nullptr,
+  MOZ_ASSERT(aLink.mEnd == nullptr,
                   "Unexpected mEnd for frame link enumerator");
 
   nsIFrame* prev = aLink.PrevFrame();
   nsIFrame* newFirstFrame = nullptr;
   if (prev) {
     // Truncate the list after |prev| and hand the first part to our new list.
     prev->SetNextSibling(nullptr);
     newFirstFrame = mFirstChild;
@@ -219,28 +219,28 @@ nsFrameList::ExtractHead(FrameLinkEnumer
   // else aLink is pointing to before our first frame.  Nothing to do.
 
   return nsFrameList(newFirstFrame, prev);
 }
 
 nsFrameList
 nsFrameList::ExtractTail(FrameLinkEnumerator& aLink)
 {
-  NS_PRECONDITION(&aLink.List() == this, "Unexpected list");
-  NS_PRECONDITION(!aLink.PrevFrame() ||
+  MOZ_ASSERT(&aLink.List() == this, "Unexpected list");
+  MOZ_ASSERT(!aLink.PrevFrame() ||
                   aLink.PrevFrame()->GetNextSibling() ==
                     aLink.NextFrame(),
                   "Unexpected PrevFrame()");
-  NS_PRECONDITION(aLink.PrevFrame() ||
+  MOZ_ASSERT(aLink.PrevFrame() ||
                   aLink.NextFrame() == FirstChild(),
                   "Unexpected NextFrame()");
-  NS_PRECONDITION(!aLink.PrevFrame() ||
+  MOZ_ASSERT(!aLink.PrevFrame() ||
                   aLink.NextFrame() != FirstChild(),
                   "Unexpected NextFrame()");
-  NS_PRECONDITION(aLink.mEnd == nullptr,
+  MOZ_ASSERT(aLink.mEnd == nullptr,
                   "Unexpected mEnd for frame link enumerator");
 
   nsIFrame* prev = aLink.PrevFrame();
   nsIFrame* newFirstFrame;
   nsIFrame* newLastFrame;
   if (prev) {
     // Truncate the list after |prev| and hand the second part to our new list
     prev->SetNextSibling(nullptr);
@@ -260,17 +260,17 @@ nsFrameList::ExtractTail(FrameLinkEnumer
   MOZ_ASSERT(aLink.AtEnd(), "What's going on here?");
 
   return nsFrameList(newFirstFrame, newLastFrame);
 }
 
 nsIFrame*
 nsFrameList::FrameAt(int32_t aIndex) const
 {
-  NS_PRECONDITION(aIndex >= 0, "invalid arg");
+  MOZ_ASSERT(aIndex >= 0, "invalid arg");
   if (aIndex < 0) return nullptr;
   nsIFrame* frame = mFirstChild;
   while ((aIndex-- > 0) && frame) {
     frame = frame->GetNextSibling();
   }
   return frame;
 }
 
@@ -284,17 +284,17 @@ nsFrameList::IndexOf(nsIFrame* aFrame) c
     ++count;
   }
   return -1;
 }
 
 bool
 nsFrameList::ContainsFrame(const nsIFrame* aFrame) const
 {
-  NS_PRECONDITION(aFrame, "null ptr");
+  MOZ_ASSERT(aFrame, "null ptr");
 
   nsIFrame* frame = mFirstChild;
   while (frame) {
     if (frame == aFrame) {
       return true;
     }
     frame = frame->GetNextSibling();
   }
--- a/layout/generic/nsFrameList.h
+++ b/layout/generic/nsFrameList.h
@@ -116,17 +116,17 @@ public:
   void DestroyFramesFrom(nsIFrame* aDestructRoot,
                          mozilla::layout::PostFrameDestroyData& aPostDestroyData);
 
   void Clear() { mFirstChild = mLastChild = nullptr; }
 
   void SetFrames(nsIFrame* aFrameList);
 
   void SetFrames(nsFrameList& aFrameList) {
-    NS_PRECONDITION(!mFirstChild, "Losing frames");
+    MOZ_ASSERT(!mFirstChild, "Losing frames");
 
     mFirstChild = aFrameList.FirstChild();
     mLastChild = aFrameList.LastChild();
     aFrameList.Clear();
   }
 
   class Slice;
 
@@ -389,17 +389,17 @@ public:
        the implementation in nsIFrame.h */
     inline void Next();
 
     /**
      * Get the current frame we're pointing to.  Do not call this on an
      * iterator that is at end!
      */
     nsIFrame* get() const {
-      NS_PRECONDITION(!AtEnd(), "Enumerator is at end");
+      MOZ_ASSERT(!AtEnd(), "Enumerator is at end");
       return mFrame;
     }
 
     /**
      * Get an enumerator that is just like this one, but not limited in terms of
      * the part of the list it will traverse.
      */
     Enumerator GetUnlimitedEnumerator() const {
@@ -453,17 +453,17 @@ public:
     {}
 
     /* This constructor needs to know about nsIFrame, and nsIFrame will need to
        know about nsFrameList methods, so in order to inline this put
        the implementation in nsIFrame.h */
     inline FrameLinkEnumerator(const nsFrameList& aList, nsIFrame* aPrevFrame);
 
     void operator=(const FrameLinkEnumerator& aOther) {
-      NS_PRECONDITION(&List() == &aOther.List(), "Different lists?");
+      MOZ_ASSERT(&List() == &aOther.List(), "Different lists?");
       mFrame = aOther.mFrame;
       mPrev = aOther.mPrev;
     }
 
     inline void Next();
 
     bool AtEnd() const { return Enumerator::AtEnd(); }
 
--- a/layout/generic/nsFrameSelection.cpp
+++ b/layout/generic/nsFrameSelection.cpp
@@ -2055,18 +2055,18 @@ nsFrameSelection::ClearNormalSelection()
 
 static nsIContent*
 GetFirstSelectedContent(nsRange* aRange)
 {
   if (!aRange) {
     return nullptr;
   }
 
-  NS_PRECONDITION(aRange->GetStartContainer(), "Must have start parent!");
-  NS_PRECONDITION(aRange->GetStartContainer()->IsElement(),
+  MOZ_ASSERT(aRange->GetStartContainer(), "Must have start parent!");
+  MOZ_ASSERT(aRange->GetStartContainer()->IsElement(),
                   "Unexpected parent");
 
   return aRange->GetChildAtStartOffset();
 }
 
 // Table selection support.
 // TODO: Separate table methods into a separate nsITableSelection interface
 nsresult
@@ -2447,17 +2447,17 @@ nsFrameSelection::UnselectCells(nsIConte
   int32_t minRowIndex = std::min(aStartRowIndex, aEndRowIndex);
   int32_t maxRowIndex = std::max(aStartRowIndex, aEndRowIndex);
   int32_t minColIndex = std::min(aStartColumnIndex, aEndColumnIndex);
   int32_t maxColIndex = std::max(aStartColumnIndex, aEndColumnIndex);
 
   // Strong reference because we sometimes remove the range
   RefPtr<nsRange> range = GetFirstCellRange();
   nsIContent* cellNode = GetFirstSelectedContent(range);
-  NS_PRECONDITION(!range || cellNode, "Must have cellNode if had a range");
+  MOZ_ASSERT(!range || cellNode, "Must have cellNode if had a range");
 
   int32_t curRowIndex, curColIndex;
   while (cellNode)
   {
     nsresult result = GetCellIndexes(cellNode, curRowIndex, curColIndex);
     if (NS_FAILED(result))
       return result;
 
@@ -2497,17 +2497,17 @@ nsFrameSelection::UnselectCells(nsIConte
           // Since we've removed the range, decrement pointer to next range
           mSelectedCellIndex--;
         }
       }
     }
 
     range = GetNextCellRange();
     cellNode = GetFirstSelectedContent(range);
-    NS_PRECONDITION(!range || cellNode, "Must have cellNode if had a range");
+    MOZ_ASSERT(!range || cellNode, "Must have cellNode if had a range");
   }
 
   return NS_OK;
 }
 
 nsresult
 nsFrameSelection::AddCellsToSelection(nsIContent *aTableContent,
                                       int32_t aStartRowIndex,
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -5803,17 +5803,17 @@ ScrollFrameHelper::LayoutScrollbars(nsBo
   double res = 1.0;
   if (overlayScrollBarsWithZoom) {
     scrollPortClampingSize = presShell->GetScrollPositionClampingScrollPortSize();
     res = presShell->GetCumulativeResolution();
   }
 
   // place the scrollcorner
   if (mScrollCornerBox || mResizerBox) {
-    NS_PRECONDITION(!mScrollCornerBox || mScrollCornerBox->IsXULBoxFrame(), "Must be a box frame!");
+    MOZ_ASSERT(!mScrollCornerBox || mScrollCornerBox->IsXULBoxFrame(), "Must be a box frame!");
 
     nsRect r(0, 0, 0, 0);
     if (aContentArea.x != mScrollPort.x || scrollbarOnLeft) {
       // scrollbar (if any) on left
       r.x = aContentArea.x;
       r.width = mScrollPort.x - aContentArea.x;
       NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
     } else {
@@ -5859,34 +5859,34 @@ ScrollFrameHelper::LayoutScrollbars(nsBo
       // otherwise lay out the resizer with an empty rectangle
       nsBoxFrame::LayoutChildAt(aState, mResizerBox, nsRect());
     }
   }
 
   nsPresContext* presContext = mScrolledFrame->PresContext();
   nsRect vRect;
   if (mVScrollbarBox) {
-    NS_PRECONDITION(mVScrollbarBox->IsXULBoxFrame(), "Must be a box frame!");
+    MOZ_ASSERT(mVScrollbarBox->IsXULBoxFrame(), "Must be a box frame!");
     vRect = mScrollPort;
     if (overlayScrollBarsWithZoom) {
       vRect.height = NSToCoordRound(res * scrollPortClampingSize.height);
     }
     vRect.width = aContentArea.width - mScrollPort.width;
     vRect.x = scrollbarOnLeft ? aContentArea.x : mScrollPort.x + NSToCoordRound(res * scrollPortClampingSize.width);
     if (mHasVerticalScrollbar) {
       nsMargin margin;
       mVScrollbarBox->GetXULMargin(margin);
       vRect.Deflate(margin);
     }
     AdjustScrollbarRectForResizer(mOuter, presContext, vRect, hasResizer, true);
   }
 
   nsRect hRect;
   if (mHScrollbarBox) {
-    NS_PRECONDITION(mHScrollbarBox->IsXULBoxFrame(), "Must be a box frame!");
+    MOZ_ASSERT(mHScrollbarBox->IsXULBoxFrame(), "Must be a box frame!");
     hRect = mScrollPort;
     if (overlayScrollBarsWithZoom) {
       hRect.width = NSToCoordRound(res * scrollPortClampingSize.width);
     }
     hRect.height = aContentArea.height - mScrollPort.height;
     hRect.y = mScrollPort.y + NSToCoordRound(res * scrollPortClampingSize.height);
     if (mHasHorizontalScrollbar) {
       nsMargin margin;
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -341,17 +341,17 @@ nsHTMLCanvasFrame::Reflow(nsPresContext*
   MarkInReflow();
   DO_GLOBAL_REFLOW_COUNT("nsHTMLCanvasFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowInput, aMetrics, aStatus);
   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
                   ("enter nsHTMLCanvasFrame::Reflow: availSize=%d,%d",
                   aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
 
-  NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
+  MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
 
   WritingMode wm = aReflowInput.GetWritingMode();
   LogicalSize finalSize(wm,
                         aReflowInput.ComputedISize(),
                         aReflowInput.ComputedBSize());
 
   // stash this away so we can compute our inner area later
   mBorderPadding   = aReflowInput.ComputedLogicalBorderPadding();
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -4813,17 +4813,17 @@ nsFrameList::Iterator::operator--()
 
 // Helper-functions for nsIFrame::SortFrameList()
 // ---------------------------------------------------
 
 template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
 /* static */ nsIFrame*
 nsIFrame::SortedMerge(nsIFrame *aLeft, nsIFrame *aRight)
 {
-  NS_PRECONDITION(aLeft && aRight, "SortedMerge must have non-empty lists");
+  MOZ_ASSERT(aLeft && aRight, "SortedMerge must have non-empty lists");
 
   nsIFrame *result;
   // Unroll first iteration to avoid null-check 'result' inside the loop.
   if (IsLessThanOrEqual(aLeft, aRight)) {
     result = aLeft;
     aLeft = aLeft->GetNextSibling();
     if (!aLeft) {
       result->SetNextSibling(aRight);
@@ -4861,17 +4861,17 @@ nsIFrame::SortedMerge(nsIFrame *aLeft, n
     }
   }
 }
 
 template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
 /* static */ nsIFrame*
 nsIFrame::MergeSort(nsIFrame *aSource)
 {
-  NS_PRECONDITION(aSource, "MergeSort null arg");
+  MOZ_ASSERT(aSource, "MergeSort null arg");
 
   nsIFrame *sorted[32] = { nullptr };
   nsIFrame **fill = &sorted[0];
   nsIFrame **left;
   nsIFrame *rest = aSource;
 
   do {
     nsIFrame *current = rest;
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -292,17 +292,17 @@ nsImageFrame::Init(nsIContent*       aCo
 
     currentRequest->BoostPriority(categoryToBoostPriority);
   }
 }
 
 bool
 nsImageFrame::UpdateIntrinsicSize(imgIContainer* aImage)
 {
-  NS_PRECONDITION(aImage, "null image");
+  MOZ_ASSERT(aImage, "null image");
   if (!aImage)
     return false;
 
   IntrinsicSize oldIntrinsicSize = mIntrinsicSize;
   mIntrinsicSize = IntrinsicSize();
 
   // Set intrinsic size to match aImage's reported intrinsic width & height.
   nsSize intrinsicSize;
@@ -322,17 +322,17 @@ nsImageFrame::UpdateIntrinsicSize(imgICo
   }
 
   return mIntrinsicSize != oldIntrinsicSize;
 }
 
 bool
 nsImageFrame::UpdateIntrinsicRatio(imgIContainer* aImage)
 {
-  NS_PRECONDITION(aImage, "null image");
+  MOZ_ASSERT(aImage, "null image");
 
   if (!aImage)
     return false;
 
   nsSize oldIntrinsicRatio = mIntrinsicRatio;
 
   // Set intrinsic ratio to match aImage's reported intrinsic ratio.
   if (NS_FAILED(aImage->GetIntrinsicRatio(&mIntrinsicRatio)))
@@ -981,17 +981,17 @@ nsImageFrame::Reflow(nsPresContext*     
   MarkInReflow();
   DO_GLOBAL_REFLOW_COUNT("nsImageFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowInput, aMetrics, aStatus);
   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
                   ("enter nsImageFrame::Reflow: availSize=%d,%d",
                   aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
 
-  NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
+  MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
 
   // see if we have a frozen size (i.e. a fixed width and height)
   if (HaveFixedSize(aReflowInput)) {
     AddStateBits(IMAGE_SIZECONSTRAINED);
   } else {
     RemoveStateBits(IMAGE_SIZECONSTRAINED);
   }
 
@@ -2223,17 +2223,17 @@ nsImageFrame::GetIntrinsicImageSize(nsSi
 }
 
 nsresult
 nsImageFrame::LoadIcon(const nsAString& aSpec,
                        nsPresContext *aPresContext,
                        imgRequestProxy** aRequest)
 {
   nsresult rv = NS_OK;
-  NS_PRECONDITION(!aSpec.IsEmpty(), "What happened??");
+  MOZ_ASSERT(!aSpec.IsEmpty(), "What happened??");
 
   if (!sIOService) {
     rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCOMPtr<nsIURI> realURI;
   SpecToURI(aSpec, sIOService, getter_AddRefs(realURI));
@@ -2294,17 +2294,17 @@ nsImageFrame::SpecToURI(const nsAString&
 }
 
 void
 nsImageFrame::GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup)
 {
   if (!aPresContext)
     return;
 
-  NS_PRECONDITION(nullptr != aLoadGroup, "null OUT parameter pointer");
+  MOZ_ASSERT(nullptr != aLoadGroup, "null OUT parameter pointer");
 
   nsIPresShell *shell = aPresContext->GetPresShell();
 
   if (!shell)
     return;
 
   nsIDocument *doc = shell->GetDocument();
   if (!doc)
--- a/layout/generic/nsLineBox.cpp
+++ b/layout/generic/nsLineBox.cpp
@@ -409,17 +409,17 @@ nsLineBox::DeleteLineList(nsPresContext*
 
 bool
 nsLineBox::RFindLineContaining(nsIFrame* aFrame,
                                const nsLineList::iterator& aBegin,
                                nsLineList::iterator& aEnd,
                                nsIFrame* aLastFrameBeforeEnd,
                                int32_t* aFrameIndexInLine)
 {
-  NS_PRECONDITION(aFrame, "null ptr");
+  MOZ_ASSERT(aFrame, "null ptr");
 
   nsIFrame* curFrame = aLastFrameBeforeEnd;
   while (aBegin != aEnd) {
     --aEnd;
     NS_ASSERTION(aEnd->LastChild() == curFrame, "Unexpected curFrame");
     if (MOZ_UNLIKELY(aEnd->mFlags.mHasHashedFrames) &&
         !aEnd->Contains(aFrame)) {
       if (aEnd->mFirstChild) {
@@ -688,17 +688,17 @@ nsLineIterator::GetLine(int32_t aLineNum
   aLineBounds = line->GetPhysicalBounds();
 
   return NS_OK;
 }
 
 int32_t
 nsLineIterator::FindLineContaining(nsIFrame* aFrame, int32_t aStartLine)
 {
-  NS_PRECONDITION(aStartLine <= mNumLines, "Bogus line numbers");
+  MOZ_ASSERT(aStartLine <= mNumLines, "Bogus line numbers");
   int32_t lineNumber = aStartLine;
   while (lineNumber != mNumLines) {
     nsLineBox* line = mLines[lineNumber];
     if (line->Contains(aFrame)) {
       return lineNumber;
     }
     ++lineNumber;
   }
@@ -734,18 +734,19 @@ nsLineIterator::CheckLineOrder(int32_t  
 
 NS_IMETHODIMP
 nsLineIterator::FindFrameAt(int32_t aLineNumber,
                             nsPoint aPos,
                             nsIFrame** aFrameFound,
                             bool* aPosIsBeforeFirstFrame,
                             bool* aPosIsAfterLastFrame)
 {
-  NS_PRECONDITION(aFrameFound && aPosIsBeforeFirstFrame && aPosIsAfterLastFrame,
+  MOZ_ASSERT(aFrameFound && aPosIsBeforeFirstFrame && aPosIsAfterLastFrame,
                   "null OUT ptr");
+
   if (!aFrameFound || !aPosIsBeforeFirstFrame || !aPosIsAfterLastFrame) {
     return NS_ERROR_NULL_POINTER;
   }
   if ((aLineNumber < 0) || (aLineNumber >= mNumLines)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsLineBox* line = mLines[aLineNumber];
@@ -867,17 +868,17 @@ nsFloatCacheList::Tail() const
     fc = fc->mNext;
   }
   return fc;
 }
 
 void
 nsFloatCacheList::Append(nsFloatCacheFreeList& aList)
 {
-  NS_PRECONDITION(aList.NotEmpty(), "Appending empty list will fail");
+  MOZ_ASSERT(aList.NotEmpty(), "Appending empty list will fail");
 
   nsFloatCache* tail = Tail();
   if (tail) {
     NS_ASSERTION(!tail->mNext, "Bogus!");
     tail->mNext = aList.mHead;
   }
   else {
     NS_ASSERTION(!mHead, "Bogus!");
@@ -933,17 +934,17 @@ nsFloatCacheFreeList::~nsFloatCacheFreeL
 {
   MOZ_COUNT_DTOR(nsFloatCacheFreeList);
 }
 #endif
 
 void
 nsFloatCacheFreeList::Append(nsFloatCacheList& aList)
 {
-  NS_PRECONDITION(aList.NotEmpty(), "Appending empty list will fail");
+  MOZ_ASSERT(aList.NotEmpty(), "Appending empty list will fail");
 
   if (mTail) {
     NS_ASSERTION(!mTail->mNext, "Bogus");
     mTail->mNext = aList.mHead;
   }
   else {
     NS_ASSERTION(!mHead, "Bogus");
     mHead = aList.mHead;
@@ -966,18 +967,19 @@ nsFloatCacheFreeList::DeleteAll()
 {
   nsFloatCacheList::DeleteAll();
   mTail = nullptr;
 }
 
 nsFloatCache*
 nsFloatCacheFreeList::Alloc(nsIFrame* aFloat)
 {
-  NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
+  MOZ_ASSERT(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
                   "This is a float cache, why isn't the frame out-of-flow?");
+
   nsFloatCache* fc = mHead;
   if (mHead) {
     if (mHead == mTail) {
       mHead = mTail = nullptr;
     }
     else {
       mHead = fc->mNext;
     }
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -455,17 +455,17 @@ nsLineLayout::EndSpan(nsIFrame* aFrame)
   mCurrentSpan->mReflowInput = nullptr;  // no longer valid so null it out!
   mCurrentSpan = mCurrentSpan->mParent;
   return iSizeResult;
 }
 
 void
 nsLineLayout::AttachFrameToBaseLineLayout(PerFrameData* aFrame)
 {
-  NS_PRECONDITION(mBaseLineLayout,
+  MOZ_ASSERT(mBaseLineLayout,
                   "This method must not be called in a base line layout.");
 
   PerFrameData* baseFrame = mBaseLineLayout->LastFrame();
   MOZ_ASSERT(aFrame && baseFrame);
   MOZ_ASSERT(!aFrame->mIsLinkedToBase,
              "The frame must not have been linked with the base");
 #ifdef DEBUG
   LayoutFrameType baseType = baseFrame->mFrame->Type();
@@ -1254,17 +1254,17 @@ bool
 nsLineLayout::CanPlaceFrame(PerFrameData* pfd,
                             bool aNotSafeToBreak,
                             bool aFrameCanContinueTextRun,
                             bool aCanRollBackBeforeFrame,
                             ReflowOutput& aMetrics,
                             nsReflowStatus& aStatus,
                             bool* aOptionalBreakAfterFits)
 {
-  NS_PRECONDITION(pfd && pfd->mFrame, "bad args, null pointers for frame data");
+  MOZ_ASSERT(pfd && pfd->mFrame, "bad args, null pointers for frame data");
 
   *aOptionalBreakAfterFits = true;
 
   WritingMode lineWM = mRootSpan->mWritingMode;
   /*
    * We want to only apply the end margin if we're the last continuation and
    * either not in an {ib} split or the last inline in it.  In all other
    * cases we want to zero it out.  That means zeroing it out if any of these
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -678,17 +678,17 @@ nsPageFrame::AppendDirectlyOwnedAnonBoxe
              mFrames.FirstChild()->IsPageContentFrame(),
              "pageFrame must have a pageContentFrame child");
   aResult.AppendElement(mFrames.FirstChild());
 }
 
 nsIFrame*
 NS_NewPageBreakFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle)
 {
-  NS_PRECONDITION(aPresShell, "null PresShell");
+  MOZ_ASSERT(aPresShell, "null PresShell");
   //check that we are only creating page break frames when printing
   NS_ASSERTION(aPresShell->GetPresContext()->IsPaginated(), "created a page break frame while not printing");
 
   return new (aPresShell) nsPageBreakFrame(aStyle);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsPageBreakFrame)
 
--- a/layout/generic/nsPlaceholderFrame.cpp
+++ b/layout/generic/nsPlaceholderFrame.cpp
@@ -210,17 +210,17 @@ nsPlaceholderFrame::CanContinueTextRun()
   // first-letter frames can continue text runs, and placeholders for floated
   // first-letter frames can too
   return mOutOfFlowFrame->CanContinueTextRun();
 }
 
 ComputedStyle*
 nsPlaceholderFrame::GetParentComputedStyleForOutOfFlow(nsIFrame** aProviderFrame) const
 {
-  NS_PRECONDITION(GetParent(), "How can we not have a parent here?");
+  MOZ_ASSERT(GetParent(), "How can we not have a parent here?");
 
   Element* parentElement =
     mContent ? mContent->GetFlattenedTreeParentElement() : nullptr;
   if (parentElement && Servo_Element_IsDisplayContents(parentElement)) {
     RefPtr<ComputedStyle> style =
       PresShell()->StyleSet()->ResolveServoStyle(parentElement);
     *aProviderFrame = nullptr;
     // See the comment in GetParentComputedStyle to see why returning this as a
--- a/layout/generic/nsPlaceholderFrame.h
+++ b/layout/generic/nsPlaceholderFrame.h
@@ -160,28 +160,28 @@ public:
       RenumberFrameAndDescendants(aOrdinal, aDepth, aIncrement, aForCounting);
   }
 
   /**
    * @return the out-of-flow for aFrame if aFrame is a placeholder; otherwise
    * aFrame
    */
   static nsIFrame* GetRealFrameFor(nsIFrame* aFrame) {
-    NS_PRECONDITION(aFrame, "Must have a frame to work with");
+    MOZ_ASSERT(aFrame, "Must have a frame to work with");
     if (aFrame->IsPlaceholderFrame()) {
       return GetRealFrameForPlaceholder(aFrame);
     }
     return aFrame;
   }
 
   /**
    * @return the out-of-flow for aFrame, which is known to be a placeholder
    */
   static nsIFrame* GetRealFrameForPlaceholder(nsIFrame* aFrame) {
-    NS_PRECONDITION(aFrame->IsPlaceholderFrame(),
+    MOZ_ASSERT(aFrame->IsPlaceholderFrame(),
                     "Must have placeholder frame as input");
     nsIFrame* outOfFlow =
       static_cast<nsPlaceholderFrame*>(aFrame)->GetOutOfFlowFrame();
     NS_ASSERTION(outOfFlow, "Null out-of-flow for placeholder?");
     return outOfFlow;
   }
 
 protected:
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -1757,17 +1757,17 @@ nsPluginFrame::GetNextObjectFrame(nsPres
   }
 
   return nullptr;
 }
 
 /*static*/ void
 nsPluginFrame::BeginSwapDocShells(nsISupports* aSupports, void*)
 {
-  NS_PRECONDITION(aSupports, "");
+  MOZ_ASSERT(aSupports, "null parameter");
   nsCOMPtr<nsIContent> content(do_QueryInterface(aSupports));
   if (!content) {
     return;
   }
 
   // This function is called from a document content enumerator so we need
   // to filter out the nsPluginFrames and ignore the rest.
   nsIObjectFrame* obj = do_QueryFrame(content->GetPrimaryFrame());
@@ -1778,17 +1778,17 @@ nsPluginFrame::BeginSwapDocShells(nsISup
   NS_ASSERTION(!objectFrame->mWidget || objectFrame->mWidget->GetParent(),
                "Plugin windows must not be toplevel");
   objectFrame->UnregisterPluginForGeometryUpdates();
 }
 
 /*static*/ void
 nsPluginFrame::EndSwapDocShells(nsISupports* aSupports, void*)
 {
-  NS_PRECONDITION(aSupports, "");
+  MOZ_ASSERT(aSupports, "null parameter");
   nsCOMPtr<nsIContent> content(do_QueryInterface(aSupports));
   if (!content) {
     return;
   }
 
   // This function is called from a document content enumerator so we need
   // to filter out the nsPluginFrames and ignore the rest.
   nsIObjectFrame* obj = do_QueryFrame(content->GetPrimaryFrame());
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -142,17 +142,17 @@ nsSimplePageSequenceFrame::ComputeCenter
  */
 void
 nsSimplePageSequenceFrame::Reflow(nsPresContext*     aPresContext,
                                   ReflowOutput&      aDesiredSize,
                                   const ReflowInput& aReflowInput,
                                   nsReflowStatus&    aStatus)
 {
   MarkInReflow();
-  NS_PRECONDITION(aPresContext->IsRootPaginatedDocument(),
+  MOZ_ASSERT(aPresContext->IsRootPaginatedDocument(),
                   "A Page Sequence is only for real pages");
   DO_GLOBAL_REFLOW_COUNT("nsSimplePageSequenceFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
   NS_FRAME_TRACE_REFLOW_IN("nsSimplePageSequenceFrame::Reflow");
 
   // Don't do incremental reflow until we've taught tables how to do
   // it right in paginated mode.
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -47,17 +47,17 @@
 using namespace mozilla;
 using mozilla::layout::RenderFrameParent;
 
 static bool sShowPreviousPage = true;
 
 static nsIDocument*
 GetDocumentFromView(nsView* aView)
 {
-  NS_PRECONDITION(aView, "");
+  MOZ_ASSERT(aView, "null view");
 
   nsViewManager* vm = aView->GetViewManager();
   nsIPresShell* ps =  vm ? vm->GetPresShell() : nullptr;
   return ps ? ps->GetDocument() : nullptr;
 }
 
 nsSubDocumentFrame::nsSubDocumentFrame(ComputedStyle* aStyle)
   : nsAtomicContainerFrame(aStyle, kClassID)
@@ -1082,17 +1082,17 @@ DestroyDisplayItemDataForFrames(nsIFrame
       DestroyDisplayItemDataForFrames(childFrames.get());
     }
   }
 }
 
 static bool
 BeginSwapDocShellsForDocument(nsIDocument* aDocument, void*)
 {
-  NS_PRECONDITION(aDocument, "");
+  MOZ_ASSERT(aDocument, "null document");
 
   nsIPresShell* shell = aDocument->GetShell();
   if (shell) {
     // Disable painting while the views are detached, see bug 946929.
     shell->SetNeverPainting(true);
 
     nsIFrame* rootFrame = shell->GetRootFrame();
     if (rootFrame) {
@@ -1122,18 +1122,18 @@ BeginSwapDocShellsForViews(nsView* aSibl
     aSibling = next;
   }
   return removedViews;
 }
 
 static void
 InsertViewsInReverseOrder(nsView* aSibling, nsView* aParent)
 {
-  NS_PRECONDITION(aParent, "");
-  NS_PRECONDITION(!aParent->GetFirstChild(), "inserting into non-empty list");
+  MOZ_ASSERT(aParent, "null view");
+  MOZ_ASSERT(!aParent->GetFirstChild(), "inserting into non-empty list");
 
   nsViewManager* vm = aParent->GetViewManager();
   while (aSibling) {
     nsView* next = aSibling->GetNextSibling();
     aSibling->SetNextSibling(nullptr);
     // true means 'after' in document order which is 'before' in view order,
     // so this call prepends the child, thus reversing the siblings as we go.
     vm->InsertChild(aParent, aSibling, nullptr, true);
@@ -1165,17 +1165,17 @@ nsSubDocumentFrame::BeginSwapDocShells(n
   }
   mFrameLoader.swap(other->mFrameLoader);
   return NS_OK;
 }
 
 static bool
 EndSwapDocShellsForDocument(nsIDocument* aDocument, void*)
 {
-  NS_PRECONDITION(aDocument, "");
+  MOZ_ASSERT(aDocument, "null document");
 
   // Our docshell and view trees have been updated for the new hierarchy.
   // Now also update all nsDeviceContext::mWidget to that of the
   // container view in the new hierarchy.
   nsCOMPtr<nsIDocShell> ds = aDocument->GetDocShell();
   if (ds) {
     nsCOMPtr<nsIContentViewer> cv;
     ds->GetContentViewer(getter_AddRefs(cv));
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -576,18 +576,18 @@ GetFrameForSimpleFlow(const gfxTextRun* 
  * Return true if |aStartContinuation| is non-null and was found
  * in the next-continuation chain of |aFrame|.
  */
 static bool
 ClearAllTextRunReferences(nsTextFrame* aFrame, gfxTextRun* aTextRun,
                           nsTextFrame* aStartContinuation,
                           nsFrameState aWhichTextRunState)
 {
-  NS_PRECONDITION(aFrame, "");
-  NS_PRECONDITION(!aStartContinuation ||
+  MOZ_ASSERT(aFrame, "null frame");
+  MOZ_ASSERT(!aStartContinuation ||
                   (!aStartContinuation->GetTextRun(nsTextFrame::eInflated) ||
                    aStartContinuation->GetTextRun(nsTextFrame::eInflated) == aTextRun) ||
                   (!aStartContinuation->GetTextRun(nsTextFrame::eNotInflated) ||
                    aStartContinuation->GetTextRun(nsTextFrame::eNotInflated) == aTextRun),
                   "wrong aStartContinuation for this text run");
 
   if (!aStartContinuation || aStartContinuation == aFrame) {
     aFrame->RemoveStateBits(aWhichTextRunState);
@@ -3282,17 +3282,17 @@ static void FindClusterStart(const gfxTe
  * If aAllowSplitLigature is false, we also check for a ligature-group
  * start.
  */
 static void FindClusterEnd(const gfxTextRun* aTextRun,
                            int32_t aOriginalEnd,
                            gfxSkipCharsIterator* aPos,
                            bool aAllowSplitLigature = true)
 {
-  NS_PRECONDITION(aPos->GetOriginalOffset() < aOriginalEnd,
+  MOZ_ASSERT(aPos->GetOriginalOffset() < aOriginalEnd,
                   "character outside string");
   aPos->AdvanceOriginal(1);
   while (aPos->GetOriginalOffset() < aOriginalEnd) {
     if (aPos->IsOriginalCharSkipped() ||
         (aTextRun->IsClusterStart(aPos->GetSkippedOffset()) &&
          (aAllowSplitLigature ||
           aTextRun->IsLigatureGroupStart(aPos->GetSkippedOffset())))) {
       break;
@@ -3423,17 +3423,17 @@ ComputeTabWidthAppUnits(const nsIFrame* 
              aTextRun->GetAppUnitsPerDevUnit());
   return spaces * spaceWidthAppUnits;
 }
 
 void
 PropertyProvider::GetSpacingInternal(Range aRange, Spacing* aSpacing,
                                      bool aIgnoreTabs) const
 {
-  NS_PRECONDITION(IsInBounds(mStart, mLength, aRange), "Range out of bounds");
+  MOZ_ASSERT(IsInBounds(mStart, mLength, aRange), "Range out of bounds");
 
   uint32_t index;
   for (index = 0; index < aRange.Length(); ++index) {
     aSpacing[index].mBefore = 0.0;
     aSpacing[index].mAfter = 0.0;
   }
 
   if (mFrame->Style()->IsTextCombined()) {
@@ -3613,18 +3613,18 @@ IS_HYPHEN(char16_t u)
           u == 0x2010 || // HYPHEN
           u == 0x2012 || // FIGURE DASH
           u == 0x2013);  // EN DASH
 }
 
 void
 PropertyProvider::GetHyphenationBreaks(Range aRange, HyphenType* aBreakBefore) const
 {
-  NS_PRECONDITION(IsInBounds(mStart, mLength, aRange), "Range out of bounds");
-  NS_PRECONDITION(mLength != INT32_MAX, "Can't call this with undefined length");
+  MOZ_ASSERT(IsInBounds(mStart, mLength, aRange), "Range out of bounds");
+  MOZ_ASSERT(mLength != INT32_MAX, "Can't call this with undefined length");
 
   if (!mTextStyle->WhiteSpaceCanWrap(mFrame) ||
       mTextStyle->mHyphens == StyleHyphens::None)
   {
     memset(aBreakBefore, static_cast<uint8_t>(HyphenType::None),
            aRange.Length() * sizeof(HyphenType));
     return;
   }
@@ -3701,17 +3701,17 @@ PropertyProvider::InitializeForMeasure()
   mLength = trimmed.mLength;
   SetupJustificationSpacing(false);
 }
 
 
 void
 PropertyProvider::SetupJustificationSpacing(bool aPostReflow)
 {
-  NS_PRECONDITION(mLength != INT32_MAX, "Can't call this with undefined length");
+  MOZ_ASSERT(mLength != INT32_MAX, "Can't call this with undefined length");
 
   if (!(mFrame->GetStateBits() & TEXT_JUSTIFICATION_ENABLED)) {
     return;
   }
 
   gfxSkipCharsIterator start(mStart), end(mStart);
   // We can't just use our mLength here; when InitializeForDisplay is
   // called with false for aTrimAfter, we still shouldn't be assigning
@@ -4334,17 +4334,17 @@ nsTextFrame::AccessibleType()
 
 //-----------------------------------------------------------------------------
 void
 nsTextFrame::Init(nsIContent*       aContent,
                   nsContainerFrame* aParent,
                   nsIFrame*         aPrevInFlow)
 {
   NS_ASSERTION(!aPrevInFlow, "Can't be a continuation!");
-  NS_PRECONDITION(aContent->IsText(), "Bogus content!");
+  MOZ_ASSERT(aContent->IsText(), "Bogus content!");
 
   // Remove any NewlineOffsetProperty or InFlowContentLengthProperty since they
   // might be invalid if the content was modified while there was no frame
   if (aContent->HasFlag(NS_HAS_NEWLINE_PROPERTY)) {
     aContent->DeleteProperty(nsGkAtoms::newline);
     aContent->UnsetFlags(NS_HAS_NEWLINE_PROPERTY);
   }
   if (aContent->HasFlag(NS_HAS_FLOWLENGTH_PROPERTY)) {
@@ -6684,24 +6684,24 @@ nsTextFrame::DrawEmphasisMarks(gfxContex
     info->textRun->Draw(Range(info->textRun.get()), pt,
                         params);
   }
 }
 
 nscolor
 nsTextFrame::GetCaretColorAt(int32_t aOffset)
 {
-  NS_PRECONDITION(aOffset >= 0, "aOffset must be positive");
+  MOZ_ASSERT(aOffset >= 0, "aOffset must be positive");
 
   nscolor result = nsFrame::GetCaretColorAt(aOffset);
   gfxSkipCharsIterator iter = EnsureTextRun(nsTextFrame::eInflated);
   PropertyProvider provider(this, iter, nsTextFrame::eInflated);
   int32_t contentOffset = provider.GetStart().GetOriginalOffset();
   int32_t contentLength = provider.GetOriginalLength();
-  NS_PRECONDITION(aOffset >= contentOffset &&
+  MOZ_ASSERT(aOffset >= contentOffset &&
                   aOffset <= contentOffset + contentLength,
                   "aOffset must be in the frame's range");
   int32_t offsetInFrame = aOffset - contentOffset;
   if (offsetInFrame < 0 || offsetInFrame >= contentLength) {
     return result;
   }
 
   bool isSolidTextColor = true;
@@ -8965,17 +8965,17 @@ HasSoftHyphenBefore(const nsTextFragment
 
 /**
  * Removes all frames from aFrame up to (but not including) aFirstToNotRemove,
  * because their text has all been taken and reflowed by earlier frames.
  */
 static void
 RemoveEmptyInFlows(nsTextFrame* aFrame, nsTextFrame* aFirstToNotRemove)
 {
-  NS_PRECONDITION(aFrame != aFirstToNotRemove, "This will go very badly");
+  MOZ_ASSERT(aFrame != aFirstToNotRemove, "This will go very badly");
   // We have to be careful here, because some RemoveFrame implementations
   // remove and destroy not only the passed-in frame but also all its following
   // in-flows (and sometimes all its following continuations in general).  So
   // we remove |f| and everything up to but not including firstToNotRemove from
   // the flow first, to make sure that only the things we want destroyed are
   // destroyed.
 
   // This sadly duplicates some of the logic from
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -285,17 +285,17 @@ nsVideoFrame::Reflow(nsPresContext* aPre
   DO_GLOBAL_REFLOW_COUNT("nsVideoFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowInput, aMetrics, aStatus);
   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
                  ("enter nsVideoFrame::Reflow: availSize=%d,%d",
                   aReflowInput.AvailableWidth(),
                   aReflowInput.AvailableHeight()));
 
-  NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
+  MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
 
   const WritingMode myWM = aReflowInput.GetWritingMode();
   nscoord contentBoxBSize = aReflowInput.ComputedBSize();
   const nscoord borderBoxISize = aReflowInput.ComputedISize() +
     aReflowInput.ComputedLogicalBorderPadding().IStartEnd(myWM);
   const bool isBSizeShrinkWrapping = (contentBoxBSize == NS_INTRINSICSIZE);
 
   nscoord borderBoxBSize;
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -137,17 +137,17 @@ nsMathMLContainerFrame::SaveReflowAndBou
 
 // helper method to facilitate getting the reflow and bounding metrics
 /* static */ void
 nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor(nsIFrame*            aFrame,
                                                        ReflowOutput& aReflowOutput,
                                                        nsBoundingMetrics&   aBoundingMetrics,
                                                        eMathMLFrameType*    aMathMLFrameType)
 {
-  NS_PRECONDITION(aFrame, "null arg");
+  MOZ_ASSERT(aFrame, "null arg");
 
   ReflowOutput* reflowOutput =
     aFrame->GetProperty(HTMLReflowOutputProperty());
 
   // IMPORTANT: This function is only meant to be called in Place() methods
   // where it is assumed that SaveReflowAndBoundingMetricsFor has recorded the
   // information.
   NS_ASSERTION(reflowOutput, "Didn't SaveReflowAndBoundingMetricsFor frame!");
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -252,17 +252,17 @@ protected:
   nscoord        mUnbrokenMeasure;
   nscoord        mLineContinuationPoint;
   PhysicalInlineStartBorderData mPIStartBorderData;
   bool           mBidiEnabled;
   bool           mVertical;
 
   void SetFrame(nsIFrame* aFrame)
   {
-    NS_PRECONDITION(aFrame, "Need a frame");
+    MOZ_ASSERT(aFrame, "Need a frame");
     NS_ASSERTION(gFrameTreeLockCount > 0,
                  "Can't call this when frame tree is not locked");
 
     if (aFrame == mFrame) {
       return;
     }
 
     nsIFrame *prevContinuation = GetPrevContinuation(aFrame);
@@ -2018,17 +2018,17 @@ nsCSSRendering::PaintBGParams::ForSingle
 }
 
 ImgDrawResult
 nsCSSRendering::PaintStyleImageLayer(const PaintBGParams& aParams,
                                      gfxContext& aRenderingCtx)
 {
   AUTO_PROFILER_LABEL("nsCSSRendering::PaintStyleImageLayer", GRAPHICS);
 
-  NS_PRECONDITION(aParams.frame,
+  MOZ_ASSERT(aParams.frame,
                   "Frame is expected to be provided to PaintStyleImageLayer");
 
   ComputedStyle *sc;
   if (!FindBackground(aParams.frame, &sc)) {
     // We don't want to bail out if moz-appearance is set on a root
     // node. If it has a parent content node, bail because it's not
     // a root, otherwise keep going in order to let the theme stuff
     // draw the background. The canvas really should be drawing the
@@ -2111,17 +2111,17 @@ nsCSSRendering::CanBuildWebRenderDisplay
 ImgDrawResult
 nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams,
                                                              mozilla::wr::DisplayListBuilder& aBuilder,
                                                              mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                              const mozilla::layers::StackingContextHelper& aSc,
                                                              mozilla::layers::WebRenderLayerManager* aManager,
                                                              nsDisplayItem* aItem)
 {
-  NS_PRECONDITION(aParams.frame,
+  MOZ_ASSERT(aParams.frame,
                   "Frame is expected to be provided to BuildWebRenderDisplayItemsForStyleImageLayer");
 
   ComputedStyle *sc;
   if (!FindBackground(aParams.frame, &sc)) {
     // We don't want to bail out if moz-appearance is set on a root
     // node. If it has a parent content node, bail because it's not
     // a root, otherwise keep going in order to let the theme stuff
     // draw the background. The canvas really should be drawing the
@@ -2616,17 +2616,17 @@ DetermineCompositionOp(const nsCSSRender
 }
 
 ImgDrawResult
 nsCSSRendering::PaintStyleImageLayerWithSC(const PaintBGParams& aParams,
                                            gfxContext& aRenderingCtx,
                                            ComputedStyle *aBackgroundSC,
                                            const nsStyleBorder& aBorder)
 {
-  NS_PRECONDITION(aParams.frame,
+  MOZ_ASSERT(aParams.frame,
                   "Frame is expected to be provided to PaintStyleImageLayerWithSC");
 
   // If we're drawing all layers, aCompositonOp is ignored, so make sure that
   // it was left at its default value.
   MOZ_ASSERT(aParams.layer != -1 ||
              aParams.compositionOp == CompositionOp::OP_OVER);
 
   // Check to see if we have an appearance defined.  If so, we let the theme
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7986,18 +7986,18 @@ nsDisplayTransform::nsDisplayTransform(n
  * to get from (0, 0) of the frame to the transform origin.  This function is
  * called off the main thread.
  */
 /* static */ Point3D
 nsDisplayTransform::GetDeltaToTransformOrigin(const nsIFrame* aFrame,
                                               float aAppUnitsPerPixel,
                                               const nsRect* aBoundsOverride)
 {
-  NS_PRECONDITION(aFrame, "Can't get delta for a null frame!");
-  NS_PRECONDITION(aFrame->IsTransformed() ||
+  MOZ_ASSERT(aFrame, "Can't get delta for a null frame!");
+  MOZ_ASSERT(aFrame->IsTransformed() ||
                   aFrame->BackfaceIsHidden() ||
                   aFrame->Combines3DTransformWithAncestors(),
                   "Shouldn't get a delta for an untransformed frame!");
 
   if (!aFrame->IsTransformed()) {
     return Point3D();
   }
 
@@ -8061,22 +8061,22 @@ nsDisplayTransform::GetDeltaToTransformO
                                          aAppUnitsPerPixel));
 }
 
 /* static */ bool
 nsDisplayTransform::ComputePerspectiveMatrix(const nsIFrame* aFrame,
                                              float aAppUnitsPerPixel,
                                              Matrix4x4& aOutMatrix)
 {
-  NS_PRECONDITION(aFrame, "Can't get delta for a null frame!");
-  NS_PRECONDITION(aFrame->IsTransformed() ||
+  MOZ_ASSERT(aFrame, "Can't get delta for a null frame!");
+  MOZ_ASSERT(aFrame->IsTransformed() ||
                   aFrame->BackfaceIsHidden() ||
                   aFrame->Combines3DTransformWithAncestors(),
                   "Shouldn't get a delta for an untransformed frame!");
-  NS_PRECONDITION(aOutMatrix.IsIdentity(), "Must have a blank output matrix");
+  MOZ_ASSERT(aOutMatrix.IsIdentity(), "Must have a blank output matrix");
 
   if (!aFrame->IsTransformed()) {
     return false;
   }
 
   /* Find our containing block, which is the element that provides the
    * value for perspective we need to use
    */
@@ -8997,33 +8997,33 @@ nsDisplayTransform::IsUniform(nsDisplayL
  *        specified bounds.
  * @return The smallest rectangle containing the image of the transformed
  *         rectangle.
  */
 nsRect nsDisplayTransform::TransformRect(const nsRect &aUntransformedBounds,
                                          const nsIFrame* aFrame,
                                          const nsRect* aBoundsOverride)
 {
-  NS_PRECONDITION(aFrame, "Can't take the transform based on a null frame!");
+  MOZ_ASSERT(aFrame, "Can't take the transform based on a null frame!");
 
   float factor = aFrame->PresContext()->AppUnitsPerDevPixel();
 
   uint32_t flags = INCLUDE_PERSPECTIVE|OFFSET_BY_ORIGIN|INCLUDE_PRESERVE3D_ANCESTORS;
   return nsLayoutUtils::MatrixTransformRect
     (aUntransformedBounds,
      GetResultingTransformMatrix(aFrame, nsPoint(0, 0), factor, flags, aBoundsOverride),
      factor);
 }
 
 bool nsDisplayTransform::UntransformRect(const nsRect &aTransformedBounds,
                                          const nsRect &aChildBounds,
                                          const nsIFrame* aFrame,
                                          nsRect *aOutRect)
 {
-  NS_PRECONDITION(aFrame, "Can't take the transform based on a null frame!");
+  MOZ_ASSERT(aFrame, "Can't take the transform based on a null frame!");
 
   float factor = aFrame->PresContext()->AppUnitsPerDevPixel();
 
   uint32_t flags = INCLUDE_PERSPECTIVE|OFFSET_BY_ORIGIN|INCLUDE_PRESERVE3D_ANCESTORS;
 
   Matrix4x4 transform = GetResultingTransformMatrix(aFrame, nsPoint(0, 0), factor, flags);
   if (transform.IsSingular()) {
     return false;
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -383,17 +383,17 @@ SetPrintAsIs(nsPrintObject* aPO, bool aA
  * This method recursvely "walks" the content for a document finding
  * all the Frames and IFrames, then sets the "mFrameType" data member
  * which tells us what type of PO we have
  */
 static void
 MapContentForPO(const UniquePtr<nsPrintObject>& aPO,
                 nsIContent* aContent)
 {
-  NS_PRECONDITION(aPO && aContent, "Null argument");
+  MOZ_ASSERT(aPO && aContent, "Null argument");
 
   nsIDocument* doc = aContent->GetComposedDoc();
 
   NS_ASSERTION(doc, "Content without a document from a document tree?");
 
   nsIDocument* subDoc = doc->GetSubDocumentFor(aContent);
 
   if (subDoc) {
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -171,17 +171,17 @@ SheetLoadData::SheetLoadData(Loader* aLo
   , mBlockResourceTiming(false)
   , mLoadFailed(false)
   , mOwningElement(aOwningElement)
   , mObserver(aObserver)
   , mLoaderPrincipal(aLoaderPrincipal)
   , mRequestingNode(aRequestingNode)
   , mPreloadEncoding(nullptr)
 {
-  NS_PRECONDITION(mLoader, "Must have a loader!");
+  MOZ_ASSERT(mLoader, "Must have a loader!");
 }
 
 SheetLoadData::SheetLoadData(Loader* aLoader,
                              nsIURI* aURI,
                              StyleSheet* aSheet,
                              SheetLoadData* aParentData,
                              nsICSSLoaderObserver* aObserver,
                              nsIPrincipal* aLoaderPrincipal,
@@ -208,17 +208,17 @@ SheetLoadData::SheetLoadData(Loader* aLo
   , mBlockResourceTiming(false)
   , mLoadFailed(false)
   , mOwningElement(nullptr)
   , mObserver(aObserver)
   , mLoaderPrincipal(aLoaderPrincipal)
   , mRequestingNode(aRequestingNode)
   , mPreloadEncoding(nullptr)
 {
-  NS_PRECONDITION(mLoader, "Must have a loader!");
+  MOZ_ASSERT(mLoader, "Must have a loader!");
   if (mParentData) {
     mSyncLoad = mParentData->mSyncLoad;
     mIsNonDocumentSheet = mParentData->mIsNonDocumentSheet;
     mUseSystemPrincipal = mParentData->mUseSystemPrincipal;
     ++(mParentData->mPendingChildren);
   }
 
   MOZ_ASSERT(!mUseSystemPrincipal || mSyncLoad,
@@ -255,17 +255,17 @@ SheetLoadData::SheetLoadData(Loader* aLo
   , mBlockResourceTiming(false)
   , mLoadFailed(false)
   , mOwningElement(nullptr)
   , mObserver(aObserver)
   , mLoaderPrincipal(aLoaderPrincipal)
   , mRequestingNode(aRequestingNode)
   , mPreloadEncoding(aPreloadEncoding)
 {
-  NS_PRECONDITION(mLoader, "Must have a loader!");
+  MOZ_ASSERT(mLoader, "Must have a loader!");
   MOZ_ASSERT(!mUseSystemPrincipal || mSyncLoad,
              "Shouldn't use system principal for async loads");
 }
 
 SheetLoadData::~SheetLoadData()
 {
   NS_CSS_NS_RELEASE_LIST_MEMBER(SheetLoadData, this, mNext);
 }
@@ -944,17 +944,17 @@ Loader::CreateSheet(nsIURI* aURI,
                     bool aSyncLoad,
                     bool aHasAlternateRel,
                     const nsAString& aTitle,
                     StyleSheetState& aSheetState,
                     IsAlternate* aIsAlternate,
                     RefPtr<StyleSheet>* aSheet)
 {
   LOG(("css::Loader::CreateSheet"));
-  NS_PRECONDITION(aSheet, "Null out param!");
+  MOZ_ASSERT(aSheet, "Null out param!");
 
   if (!mSheets) {
     mSheets = new Sheets();
   }
 
   *aSheet = nullptr;
   aSheetState = eSheetStateUnknown;
 
@@ -1148,17 +1148,17 @@ MediaListMatches(const MediaList* aMedia
  */
 Loader::MediaMatched
 Loader::PrepareSheet(StyleSheet* aSheet,
                      const nsAString& aTitle,
                      const nsAString& aMediaString,
                      MediaList* aMediaList,
                      IsAlternate aIsAlternate)
 {
-  NS_PRECONDITION(aSheet, "Must have a sheet!");
+  MOZ_ASSERT(aSheet, "Must have a sheet!");
 
   RefPtr<MediaList> mediaList(aMediaList);
 
   if (!aMediaString.IsEmpty()) {
     NS_ASSERTION(!aMediaList,
                  "must not provide both aMediaString and aMediaList");
     mediaList = MediaList::Create(aMediaString);
   }
@@ -1184,18 +1184,18 @@ Loader::PrepareSheet(StyleSheet* aSheet,
  *    as determined by CompareDocumentPosition.
  */
 nsresult
 Loader::InsertSheetInDoc(StyleSheet* aSheet,
                          nsIContent* aLinkingContent,
                          nsIDocument* aDocument)
 {
   LOG(("css::Loader::InsertSheetInDoc"));
-  NS_PRECONDITION(aSheet, "Nothing to insert");
-  NS_PRECONDITION(aDocument, "Must have a document to insert into");
+  MOZ_ASSERT(aSheet, "Nothing to insert");
+  MOZ_ASSERT(aDocument, "Must have a document to insert into");
 
   // XXX Need to cancel pending sheet loads for this element, if any
 
   int32_t sheetCount = aDocument->SheetCount();
 
   /*
    * Start the walk at the _end_ of the list, since in the typical
    * case we'll just want to append anyway.  We want to break out of
@@ -1288,21 +1288,21 @@ Loader::InsertChildSheet(StyleSheet* aSh
  * a new load is kicked off asynchronously.
  */
 nsresult
 Loader::LoadSheet(SheetLoadData* aLoadData,
                   StyleSheetState aSheetState,
                   bool aIsPreload)
 {
   LOG(("css::Loader::LoadSheet"));
-  NS_PRECONDITION(aLoadData, "Need a load data");
-  NS_PRECONDITION(aLoadData->mURI, "Need a URI to load");
-  NS_PRECONDITION(aLoadData->mSheet, "Need a sheet to load into");
-  NS_PRECONDITION(aSheetState != eSheetComplete, "Why bother?");
-  NS_PRECONDITION(!aLoadData->mUseSystemPrincipal || aLoadData->mSyncLoad,
+  MOZ_ASSERT(aLoadData, "Need a load data");
+  MOZ_ASSERT(aLoadData->mURI, "Need a URI to load");
+  MOZ_ASSERT(aLoadData->mSheet, "Need a sheet to load into");
+  MOZ_ASSERT(aSheetState != eSheetComplete, "Why bother?");
+  MOZ_ASSERT(!aLoadData->mUseSystemPrincipal || aLoadData->mSyncLoad,
                   "Shouldn't use system principal for async loads");
   NS_ASSERTION(mSheets, "mLoadingDatas should be initialized by now.");
 
   LOG_URI("  Load from: '%s'", aLoadData->mURI);
 
   nsresult rv = NS_OK;
 
   if (!mDocument && !aLoadData->mIsNonDocumentSheet) {
@@ -1761,18 +1761,18 @@ Loader::SheetComplete(SheetLoadData* aLo
     StartDeferredLoads();
   }
 }
 
 void
 Loader::DoSheetComplete(SheetLoadData* aLoadData, LoadDataArray& aDatasToNotify)
 {
   LOG(("css::Loader::DoSheetComplete"));
-  NS_PRECONDITION(aLoadData, "Must have a load data!");
-  NS_PRECONDITION(aLoadData->mSheet, "Must have a sheet");
+  MOZ_ASSERT(aLoadData, "Must have a load data!");
+  MOZ_ASSERT(aLoadData->mSheet, "Must have a sheet");
   NS_ASSERTION(mSheets, "mLoadingDatas should be initialized by now.");
 
   // Twiddle the hashtables
   if (aLoadData->mURI) {
     LOG_URI("  Finished loading: '%s'", aLoadData->mURI);
     // Remove the data from the list of loading datas
     if (aLoadData->mIsLoading) {
       URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
@@ -1995,17 +1995,17 @@ Loader::LoadStyleLink(nsIContent* aEleme
                       const nsAString& aTitle,
                       const nsAString& aMedia,
                       bool aHasAlternateRel,
                       CORSMode aCORSMode,
                       ReferrerPolicy aReferrerPolicy,
                       const nsAString& aIntegrity,
                       nsICSSLoaderObserver* aObserver)
 {
-  NS_PRECONDITION(aURL, "Must have URL to load");
+  MOZ_ASSERT(aURL, "Must have URL to load");
   LOG(("css::Loader::LoadStyleLink"));
   LOG_URI("  Link uri: '%s'", aURL);
   LOG(("  Link title: '%s'", NS_ConvertUTF16toUTF8(aTitle).get()));
   LOG(("  Link media: '%s'", NS_ConvertUTF16toUTF8(aMedia).get()));
   LOG(("  Link alternate rel: %d", aHasAlternateRel));
 
   if (!mEnabled) {
     LOG_WARN(("  Not enabled"));
@@ -2159,18 +2159,18 @@ HaveAncestorDataWithURI(SheetLoadData *a
 nsresult
 Loader::LoadChildSheet(StyleSheet* aParentSheet,
                        SheetLoadData* aParentData,
                        nsIURI* aURL,
                        dom::MediaList* aMedia,
                        LoaderReusableStyleSheets* aReusableSheets)
 {
   LOG(("css::Loader::LoadChildSheet"));
-  NS_PRECONDITION(aURL, "Must have a URI to load");
-  NS_PRECONDITION(aParentSheet, "Must have a parent sheet");
+  MOZ_ASSERT(aURL, "Must have a URI to load");
+  MOZ_ASSERT(aParentSheet, "Must have a parent sheet");
 
   if (!mEnabled) {
     LOG_WARN(("  Not enabled"));
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   LOG_URI("  Child uri: '%s'", aURL);
 
@@ -2313,17 +2313,17 @@ Loader::LoadSheet(nsIURI* aURL,
 
 nsresult
 Loader::LoadSheet(nsIURI* aURL,
                   nsIPrincipal* aOriginPrincipal,
                   nsICSSLoaderObserver* aObserver,
                   RefPtr<StyleSheet>* aSheet)
 {
   LOG(("css::Loader::LoadSheet(aURL, aObserver, aSheet) api call"));
-  NS_PRECONDITION(aSheet, "aSheet is null");
+  MOZ_ASSERT(aSheet, "aSheet is null");
   return InternalLoadNonDocumentSheet(aURL,
                                       false,
                                       eAuthorSheetFeatures,
                                       false,
                                       aOriginPrincipal,
                                       nullptr,
                                       aSheet,
                                       aObserver);
@@ -2361,19 +2361,19 @@ Loader::InternalLoadNonDocumentSheet(nsI
                                      nsIPrincipal* aOriginPrincipal,
                                      const Encoding* aPreloadEncoding,
                                      RefPtr<StyleSheet>* aSheet,
                                      nsICSSLoaderObserver* aObserver,
                                      CORSMode aCORSMode,
                                      ReferrerPolicy aReferrerPolicy,
                                      const nsAString& aIntegrity)
 {
-  NS_PRECONDITION(aURL, "Must have a URI to load");
-  NS_PRECONDITION(aSheet || aObserver, "Sheet and observer can't both be null");
-  NS_PRECONDITION(!aUseSystemPrincipal || !aObserver,
+  MOZ_ASSERT(aURL, "Must have a URI to load");
+  MOZ_ASSERT(aSheet || aObserver, "Sheet and observer can't both be null");
+  MOZ_ASSERT(!aUseSystemPrincipal || !aObserver,
                   "Shouldn't load system-principal sheets async");
 
   LOG_URI("  Non-document sheet uri: '%s'", aURL);
 
   if (aSheet) {
     *aSheet = nullptr;
   }
 
@@ -2446,18 +2446,18 @@ nsresult
 Loader::PostLoadEvent(nsIURI* aURI,
                       StyleSheet* aSheet,
                       nsICSSLoaderObserver* aObserver,
                       IsAlternate aWasAlternate,
                       MediaMatched aMediaMatched,
                       nsIStyleSheetLinkingElement* aElement)
 {
   LOG(("css::Loader::PostLoadEvent"));
-  NS_PRECONDITION(aSheet, "Must have sheet");
-  NS_PRECONDITION(aObserver || !mObservers.IsEmpty() || aElement,
+  MOZ_ASSERT(aSheet, "Must have sheet");
+  MOZ_ASSERT(aObserver || !mObservers.IsEmpty() || aElement,
                   "Must have observer or element");
 
   RefPtr<SheetLoadData> evt =
     new SheetLoadData(this, EmptyString(), // title doesn't matter here
                       aURI,
                       aSheet,
                       aElement,
                       aWasAlternate == IsAlternate::Yes,
@@ -2591,34 +2591,34 @@ Loader::HasPendingLoads()
     (mSheets && mSheets->mPendingDatas.Count() != 0) ||
     mPostedEvents.Length() != 0 ||
     mDatasToNotifyOn != 0;
 }
 
 nsresult
 Loader::AddObserver(nsICSSLoaderObserver* aObserver)
 {
-  NS_PRECONDITION(aObserver, "Must have observer");
+  MOZ_ASSERT(aObserver, "Must have observer");
   if (mObservers.AppendElementUnlessExists(aObserver)) {
     return NS_OK;
   }
 
   return NS_ERROR_OUT_OF_MEMORY;
 }
 
 void
 Loader::RemoveObserver(nsICSSLoaderObserver* aObserver)
 {
   mObservers.RemoveElement(aObserver);
 }
 
 void
 Loader::StartDeferredLoads()
 {
-  NS_PRECONDITION(mSheets, "Don't call me!");
+  MOZ_ASSERT(mSheets, "Don't call me!");
   LoadDataArray arr(mSheets->mPendingDatas.Count());
   for (auto iter = mSheets->mPendingDatas.Iter(); !iter.Done(); iter.Next()) {
     arr.AppendElement(iter.Data());
     iter.Remove();
   }
 
   mDatasToNotifyOn += arr.Length();
   for (uint32_t i = 0; i < arr.Length(); ++i) {
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -1608,27 +1608,27 @@ nsComputedDOMStyle::DoGetTranslate()
 
       // Even though the spec doesn't say to resolve percentage values, Blink
       // and Edge do and so until that is clarified we do as well:
       //
       // https://github.com/w3c/csswg-drafts/issues/2124
       switch (nsStyleTransformMatrix::TransformFunctionOf(aData)) {
         /* translate : <length-percentage> */
         case eCSSKeyword_translatex: {
-          NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
           float tx = ProcessTranslatePart(aData->Item(1),
                                           &refBox,
                                           &TransformReferenceBox::Width);
           aResult.AppendFloat(tx);
           aResult.AppendLiteral("px");
           break;
         }
         /* translate : <length-percentage> <length-percentage> */
         case eCSSKeyword_translate: {
-          NS_PRECONDITION(aData->Count() == 3, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 3, "Invalid array!");
           float tx = ProcessTranslatePart(aData->Item(1),
                                           &refBox,
                                           &TransformReferenceBox::Width);
           aResult.AppendFloat(tx);
           aResult.AppendLiteral("px");
 
           float ty = ProcessTranslatePart(aData->Item(2),
                                           &refBox,
@@ -1637,17 +1637,17 @@ nsComputedDOMStyle::DoGetTranslate()
             aResult.AppendLiteral(" ");
             aResult.AppendFloat(ty);
             aResult.AppendLiteral("px");
           }
           break;
         }
         /* translate : <length-percentage> <length-percentage> <length>*/
         case eCSSKeyword_translate3d: {
-          NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 4, "Invalid array!");
           float tx = ProcessTranslatePart(aData->Item(1),
                                           &refBox,
                                           &TransformReferenceBox::Width);
           aResult.AppendFloat(tx);
           aResult.AppendLiteral("px");
 
           float ty = ProcessTranslatePart(aData->Item(2),
                                           &refBox,
@@ -1678,34 +1678,34 @@ nsComputedDOMStyle::DoGetTranslate()
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetScale()
 {
   return ReadIndividualTransformValue(StyleDisplay()->mSpecifiedScale,
     [](const nsCSSValue::Array* aData, nsString& aResult) {
       switch (nsStyleTransformMatrix::TransformFunctionOf(aData)) {
         /* scale : <number> */
         case eCSSKeyword_scalex:
-          NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
           aResult.AppendFloat(aData->Item(1).GetFloatValue());
           break;
         /* scale : <number> <number>*/
         case eCSSKeyword_scale: {
-          NS_PRECONDITION(aData->Count() == 3, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 3, "Invalid array!");
           aResult.AppendFloat(aData->Item(1).GetFloatValue());
 
           float sy = aData->Item(2).GetFloatValue();
           if (sy != 1.) {
             aResult.AppendLiteral(" ");
             aResult.AppendFloat(sy);
           }
           break;
         }
         /* scale : <number> <number> <number> */
         case eCSSKeyword_scale3d: {
-          NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 4, "Invalid array!");
           aResult.AppendFloat(aData->Item(1).GetFloatValue());
 
           float sy = aData->Item(2).GetFloatValue();
           float sz = aData->Item(3).GetFloatValue();
 
           if (sy != 1. || sz != 1.) {
             aResult.AppendLiteral(" ");
             aResult.AppendFloat(sy);
@@ -1726,25 +1726,25 @@ already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetRotate()
 {
   return ReadIndividualTransformValue(StyleDisplay()->mSpecifiedRotate,
     [](const nsCSSValue::Array* aData, nsString& aResult) {
 
       switch (nsStyleTransformMatrix::TransformFunctionOf(aData)) {
         /* rotate : <angle> */
         case eCSSKeyword_rotate: {
-          NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
           float theta = aData->Item(1).GetAngleValueInDegrees();
           aResult.AppendFloat(theta);
           aResult.AppendLiteral("deg");
           break;
         }
         /* rotate : <number> <number> <number> <angle> */
         case eCSSKeyword_rotate3d: {
-          NS_PRECONDITION(aData->Count() == 5, "Invalid array!");
+          MOZ_ASSERT(aData->Count() == 5, "Invalid array!");
           float rx = aData->Item(1).GetFloatValue();
           float ry = aData->Item(2).GetFloatValue();
           float rz = aData->Item(3).GetFloatValue();
           if (rx != 0. || ry != 0. || rz != 1.) {
             aResult.AppendFloat(rx);
             aResult.AppendLiteral(" ");
             aResult.AppendFloat(ry);
             aResult.AppendLiteral(" ");
@@ -5774,17 +5774,17 @@ void
 nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue* aValue,
                                     const nsStyleCoord& aCoord,
                                     bool aClampNegativeCalc,
                                     PercentageBaseGetter aPercentageBaseGetter,
                                     const KTableEntry aTable[],
                                     nscoord aMinAppUnits,
                                     nscoord aMaxAppUnits)
 {
-  NS_PRECONDITION(aValue, "Must have a value to work with");
+  MOZ_ASSERT(aValue, "Must have a value to work with");
 
   switch (aCoord.GetUnit()) {
     case eStyleUnit_Normal:
       aValue->SetIdent(eCSSKeyword_normal);
       break;
 
     case eStyleUnit_Auto:
       aValue->SetIdent(eCSSKeyword_auto);
@@ -5885,17 +5885,17 @@ nsComputedDOMStyle::SetValueToCoord(nsRO
 }
 
 nscoord
 nsComputedDOMStyle::StyleCoordToNSCoord(const nsStyleCoord& aCoord,
                                         PercentageBaseGetter aPercentageBaseGetter,
                                         nscoord aDefaultValue,
                                         bool aClampNegativeCalc)
 {
-  NS_PRECONDITION(aPercentageBaseGetter, "Must have a percentage base getter");
+  MOZ_ASSERT(aPercentageBaseGetter, "Must have a percentage base getter");
   if (aCoord.GetUnit() == eStyleUnit_Coord) {
     return aCoord.GetCoordValue();
   }
   if (aCoord.GetUnit() == eStyleUnit_Percent || aCoord.IsCalcUnit()) {
     nscoord percentageBase;
     if ((this->*aPercentageBaseGetter)(percentageBase)) {
       nscoord result = aCoord.ComputeCoordPercentCalc(percentageBase);
       if (aClampNegativeCalc && result < 0) {
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -33,17 +33,17 @@ nsDOMCSSDeclaration::WrapObject(JSContex
 
 NS_IMPL_QUERY_INTERFACE(nsDOMCSSDeclaration,
                         nsICSSDeclaration)
 
 nsresult
 nsDOMCSSDeclaration::GetPropertyValue(const nsCSSPropertyID aPropID,
                                       nsAString& aValue)
 {
-  NS_PRECONDITION(aPropID != eCSSProperty_UNKNOWN,
+  MOZ_ASSERT(aPropID != eCSSProperty_UNKNOWN,
                   "Should never pass eCSSProperty_UNKNOWN around");
 
   aValue.Truncate();
   if (DeclarationBlock* decl = GetCSSDeclaration(eOperation_Read)) {
     decl->GetPropertyValueByID(aPropID, aValue);
   }
   return NS_OK;
 }
--- a/layout/style/nsROCSSPrimitiveValue.cpp
+++ b/layout/style/nsROCSSPrimitiveValue.cpp
@@ -527,17 +527,17 @@ void
 nsROCSSPrimitiveValue::SetAppUnits(float aValue)
 {
   SetAppUnits(NSToCoordRound(aValue));
 }
 
 void
 nsROCSSPrimitiveValue::SetIdent(nsCSSKeyword aKeyword)
 {
-  NS_PRECONDITION(aKeyword != eCSSKeyword_UNKNOWN &&
+  MOZ_ASSERT(aKeyword != eCSSKeyword_UNKNOWN &&
                   0 <= aKeyword && aKeyword < eCSSKeyword_COUNT,
                   "bad keyword");
   Reset();
   mValue.mKeyword = aKeyword;
   mType = CSSPrimitiveValueBinding::CSS_IDENT;
 }
 
 // FIXME: CSS_STRING should imply a string with "" and a need for escaping.
@@ -575,32 +575,34 @@ nsROCSSPrimitiveValue::SetURI(nsIURI *aU
   mValue.mURI = aURI;
   NS_IF_ADDREF(mValue.mURI);
   mType = CSSPrimitiveValueBinding::CSS_URI;
 }
 
 void
 nsROCSSPrimitiveValue::SetColor(nsDOMCSSRGBColor* aColor)
 {
-  NS_PRECONDITION(aColor, "Null RGBColor being set!");
+  MOZ_ASSERT(aColor, "Null RGBColor being set!");
+
   Reset();
   mValue.mColor = aColor;
   if (mValue.mColor) {
     NS_ADDREF(mValue.mColor);
     mType = CSSPrimitiveValueBinding::CSS_RGBCOLOR;
   }
   else {
     mType = CSSPrimitiveValueBinding::CSS_UNKNOWN;
   }
 }
 
 void
 nsROCSSPrimitiveValue::SetRect(nsDOMCSSRect* aRect)
 {
-  NS_PRECONDITION(aRect, "Null rect being set!");
+  MOZ_ASSERT(aRect, "Null rect being set!");
+
   Reset();
   mValue.mRect = aRect;
   if (mValue.mRect) {
     NS_ADDREF(mValue.mRect);
     mType = CSSPrimitiveValueBinding::CSS_RECT;
   }
   else {
     mType = CSSPrimitiveValueBinding::CSS_UNKNOWN;
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3169,17 +3169,17 @@ nsStyleImageLayers::Layer::operator==(co
 
 template <class ComputedValueItem>
 static void
 FillImageLayerList(
     nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
     ComputedValueItem nsStyleImageLayers::Layer::* aResultLocation,
     uint32_t aItemCount, uint32_t aFillCount)
 {
-  NS_PRECONDITION(aFillCount <= aLayers.Length(), "unexpected array length");
+  MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
   for (uint32_t sourceLayer = 0, destLayer = aItemCount;
        destLayer < aFillCount;
        ++sourceLayer, ++destLayer) {
     aLayers[destLayer].*aResultLocation =
       aLayers[sourceLayer].*aResultLocation;
   }
 }
 
@@ -3187,17 +3187,17 @@ FillImageLayerList(
 // layer.mPosition.*aResultLocation instead of layer.*aResultLocation.
 static void
 FillImageLayerPositionCoordList(
     nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
     Position::Coord
         Position::* aResultLocation,
     uint32_t aItemCount, uint32_t aFillCount)
 {
-  NS_PRECONDITION(aFillCount <= aLayers.Length(), "unexpected array length");
+  MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
   for (uint32_t sourceLayer = 0, destLayer = aItemCount;
        destLayer < aFillCount;
        ++sourceLayer, ++destLayer) {
     aLayers[destLayer].mPosition.*aResultLocation =
       aLayers[sourceLayer].mPosition.*aResultLocation;
   }
 }
 
--- a/layout/style/nsStyleTransformMatrix.cpp
+++ b/layout/style/nsStyleTransformMatrix.cpp
@@ -191,17 +191,17 @@ ProcessTranslatePart(const nsCSSValue& a
  */
 
 /* Helper function to process a matrix entry. */
 static void
 ProcessMatrix(Matrix4x4& aMatrix,
               const nsCSSValue::Array* aData,
               TransformReferenceBox& aRefBox)
 {
-  NS_PRECONDITION(aData->Count() == 7, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 7, "Invalid array!");
 
   gfxMatrix result;
 
   /* Take the first four elements out of the array as floats and store
    * them.
    */
   result._11 = aData->Item(1).GetFloatValue();
   result._12 = aData->Item(2).GetFloatValue();
@@ -219,17 +219,17 @@ ProcessMatrix(Matrix4x4& aMatrix,
   aMatrix = result * aMatrix;
 }
 
 static void
 ProcessMatrix3D(Matrix4x4& aMatrix,
                 const nsCSSValue::Array* aData,
                 TransformReferenceBox& aRefBox)
 {
-  NS_PRECONDITION(aData->Count() == 17, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 17, "Invalid array!");
 
   Matrix4x4 temp;
 
   temp._11 = aData->Item(1).GetFloatValue();
   temp._12 = aData->Item(2).GetFloatValue();
   temp._13 = aData->Item(3).GetFloatValue();
   temp._14 = aData->Item(4).GetFloatValue();
   temp._21 = aData->Item(5).GetFloatValue();
@@ -478,17 +478,17 @@ OperateTransformMatrixByServo(const Matr
 
 template <typename Operator>
 static void
 ProcessMatrixOperator(Matrix4x4& aMatrix,
                       const nsCSSValue::Array* aData,
                       TransformReferenceBox& aRefBox,
                       bool* aContains3dTransform)
 {
-  NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 4, "Invalid array!");
 
   auto readTransform = [&](const nsCSSValue& aValue) -> Matrix4x4 {
     const nsCSSValueList* list = nullptr;
     switch (aValue.GetUnit()) {
       case eCSSUnit_List:
         // For Gecko style backend.
         list = aValue.GetListValue();
         break;
@@ -557,58 +557,58 @@ ProcessAccumulateMatrix(Matrix4x4& aMatr
 }
 
 /* Helper function to process a translatex function. */
 static void
 ProcessTranslateX(Matrix4x4& aMatrix,
                   const nsCSSValue::Array* aData,
                   TransformReferenceBox& aRefBox)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
 
   Point3D temp;
 
   temp.x = ProcessTranslatePart(aData->Item(1),
                                 &aRefBox, &TransformReferenceBox::Width);
   aMatrix.PreTranslate(temp);
 }
 
 /* Helper function to process a translatey function. */
 static void
 ProcessTranslateY(Matrix4x4& aMatrix,
                   const nsCSSValue::Array* aData,
                   TransformReferenceBox& aRefBox)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
 
   Point3D temp;
 
   temp.y = ProcessTranslatePart(aData->Item(1),
                                 &aRefBox, &TransformReferenceBox::Height);
   aMatrix.PreTranslate(temp);
 }
 
 static void
 ProcessTranslateZ(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
 
   Point3D temp;
 
   temp.z = ProcessTranslatePart(aData->Item(1), nullptr);
   aMatrix.PreTranslate(temp);
 }
 
 /* Helper function to process a translate function. */
 static void
 ProcessTranslate(Matrix4x4& aMatrix,
                  const nsCSSValue::Array* aData,
                  TransformReferenceBox& aRefBox)
 {
-  NS_PRECONDITION(aData->Count() == 2 || aData->Count() == 3, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2 || aData->Count() == 3, "Invalid array!");
 
   Point3D temp;
 
   temp.x = ProcessTranslatePart(aData->Item(1),
                                 &aRefBox, &TransformReferenceBox::Width);
 
   /* If we read in a Y component, set it appropriately */
   if (aData->Count() == 3) {
@@ -618,17 +618,17 @@ ProcessTranslate(Matrix4x4& aMatrix,
   aMatrix.PreTranslate(temp);
 }
 
 static void
 ProcessTranslate3D(Matrix4x4& aMatrix,
                    const nsCSSValue::Array* aData,
                    TransformReferenceBox& aRefBox)
 {
-  NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 4, "Invalid array!");
 
   Point3D temp;
 
   temp.x = ProcessTranslatePart(aData->Item(1),
                                 &aRefBox, &TransformReferenceBox::Width);
 
   temp.y = ProcessTranslatePart(aData->Item(2),
                                 &aRefBox, &TransformReferenceBox::Height);
@@ -648,50 +648,50 @@ ProcessScaleHelper(Matrix4x4& aMatrix,
 {
   aMatrix.PreScale(aXScale, aYScale, aZScale);
 }
 
 /* Process a scalex function. */
 static void
 ProcessScaleX(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Bad array!");
+  MOZ_ASSERT(aData->Count() == 2, "Bad array!");
   ProcessScaleHelper(aMatrix, aData->Item(1).GetFloatValue(), 1.0f, 1.0f);
 }
 
 /* Process a scaley function. */
 static void
 ProcessScaleY(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Bad array!");
+  MOZ_ASSERT(aData->Count() == 2, "Bad array!");
   ProcessScaleHelper(aMatrix, 1.0f, aData->Item(1).GetFloatValue(), 1.0f);
 }
 
 static void
 ProcessScaleZ(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Bad array!");
+  MOZ_ASSERT(aData->Count() == 2, "Bad array!");
   ProcessScaleHelper(aMatrix, 1.0f, 1.0f, aData->Item(1).GetFloatValue());
 }
 
 static void
 ProcessScale3D(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 4, "Bad array!");
+  MOZ_ASSERT(aData->Count() == 4, "Bad array!");
   ProcessScaleHelper(aMatrix,
                      aData->Item(1).GetFloatValue(),
                      aData->Item(2).GetFloatValue(),
                      aData->Item(3).GetFloatValue());
 }
 
 /* Process a scale function. */
 static void
 ProcessScale(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2 || aData->Count() == 3, "Bad array!");
+  MOZ_ASSERT(aData->Count() == 2 || aData->Count() == 3, "Bad array!");
   /* We either have one element or two.  If we have one, it's for both X and Y.
    * Otherwise it's one for each.
    */
   const nsCSSValue& scaleX = aData->Item(1);
   const nsCSSValue& scaleY = (aData->Count() == 2 ? scaleX :
                               aData->Item(2));
 
   ProcessScaleHelper(aMatrix,
@@ -737,57 +737,57 @@ ProcessSkew(Matrix4x4& aMatrix, const ns
 
   ProcessSkewHelper(aMatrix, xSkew, ySkew);
 }
 
 /* Function that converts a rotate transform into a matrix. */
 static void
 ProcessRotateZ(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
   double theta = aData->Item(1).GetAngleValueInRadians();
   aMatrix.RotateZ(theta);
 }
 
 static void
 ProcessRotateX(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
   double theta = aData->Item(1).GetAngleValueInRadians();
   aMatrix.RotateX(theta);
 }
 
 static void
 ProcessRotateY(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
   double theta = aData->Item(1).GetAngleValueInRadians();
   aMatrix.RotateY(theta);
 }
 
 static void
 ProcessRotate3D(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 5, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 5, "Invalid array!");
 
   double theta = aData->Item(4).GetAngleValueInRadians();
   float x = aData->Item(1).GetFloatValue();
   float y = aData->Item(2).GetFloatValue();
   float z = aData->Item(3).GetFloatValue();
 
   Matrix4x4 temp;
   temp.SetRotateAxisAngle(x, y, z, theta);
 
   aMatrix = temp * aMatrix;
 }
 
 static void
 ProcessPerspective(Matrix4x4& aMatrix, const nsCSSValue::Array* aData)
 {
-  NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
+  MOZ_ASSERT(aData->Count() == 2, "Invalid array!");
 
   float depth = ProcessTranslatePart(aData->Item(1), nullptr);
   ApplyPerspectiveToMatrix(aMatrix, depth);
 }
 
 
 /**
  * SetToTransformFunction is essentially a giant switch statement that fans
@@ -795,17 +795,17 @@ ProcessPerspective(Matrix4x4& aMatrix, c
  */
 static void
 MatrixForTransformFunction(Matrix4x4& aMatrix,
                            const nsCSSValue::Array * aData,
                            TransformReferenceBox& aRefBox,
                            bool* aContains3dTransform)
 {
   MOZ_ASSERT(aContains3dTransform);
-  NS_PRECONDITION(aData, "Why did you want to get data from a null array?");
+  MOZ_ASSERT(aData, "Why did you want to get data from a null array?");
 
   /* Get the keyword for the transform. */
   switch (TransformFunctionOf(aData)) {
   case eCSSKeyword_translatex:
     ProcessTranslateX(aMatrix, aData, aRefBox);
     break;
   case eCSSKeyword_translatey:
     ProcessTranslateY(aMatrix, aData, aRefBox);
--- a/layout/style/nsStyleUtil.cpp
+++ b/layout/style/nsStyleUtil.cpp
@@ -84,18 +84,19 @@ nsStyleUtil::ValueIncludes(const nsAStri
   }
   return false;
 }
 
 void nsStyleUtil::AppendEscapedCSSString(const nsAString& aString,
                                          nsAString& aReturn,
                                          char16_t quoteChar)
 {
-  NS_PRECONDITION(quoteChar == '\'' || quoteChar == '"',
+  MOZ_ASSERT(quoteChar == '\'' || quoteChar == '"',
                   "CSS strings must be quoted with ' or \"");
+
   aReturn.Append(quoteChar);
 
   const char16_t* in = aString.BeginReading();
   const char16_t* const end = aString.EndReading();
   for (; in != end; in++) {
     if (*in < 0x20 || *in == 0x7F) {
       // Escape U+0000 through U+001F and U+007F numerically.
       aReturn.AppendPrintf("\\%x ", *in);
@@ -394,17 +395,17 @@ nsStyleUtil::AppendFontFeatureSettings(c
 {
   nsCSSUnit unit = aSrc.GetUnit();
 
   if (unit == eCSSUnit_Normal) {
     aResult.AppendLiteral("normal");
     return;
   }
 
-  NS_PRECONDITION(unit == eCSSUnit_PairList || unit == eCSSUnit_PairListDep,
+  MOZ_ASSERT(unit == eCSSUnit_PairList || unit == eCSSUnit_PairListDep,
                   "improper value unit for font-feature-settings:");
 
   nsTArray<gfxFontFeature> featureSettings;
   nsLayoutUtils::ComputeFontFeatures(aSrc.GetPairListValue(), featureSettings);
   AppendFontFeatureSettings(featureSettings, aResult);
 }
 
 /* static */ void
@@ -433,17 +434,17 @@ nsStyleUtil::AppendFontVariationSettings
 {
   nsCSSUnit unit = aSrc.GetUnit();
 
   if (unit == eCSSUnit_Normal) {
     aResult.AppendLiteral("normal");
     return;
   }
 
-  NS_PRECONDITION(unit == eCSSUnit_PairList || unit == eCSSUnit_PairListDep,
+  MOZ_ASSERT(unit == eCSSUnit_PairList || unit == eCSSUnit_PairListDep,
                   "improper value unit for font-variation-settings:");
 
   nsTArray<gfxFontVariation> variationSettings;
   nsLayoutUtils::ComputeFontVariations(aSrc.GetPairListValue(),
                                        variationSettings);
   AppendFontVariationSettings(variationSettings, aResult);
 }
 
@@ -566,17 +567,17 @@ AppendSerializedUnicodePoint(uint32_t aC
 
 // A unicode-range: descriptor is represented as an array of integers,
 // to be interpreted as a sequence of pairs: min max min max ...
 // It is in source order.  (Possibly it should be sorted and overlaps
 // consolidated, but right now we don't do that.)
 /* static */ void
 nsStyleUtil::AppendUnicodeRange(const nsCSSValue& aValue, nsAString& aResult)
 {
-  NS_PRECONDITION(aValue.GetUnit() == eCSSUnit_Null ||
+  MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Null ||
                   aValue.GetUnit() == eCSSUnit_Array,
                   "improper value unit for unicode-range:");
   aResult.Truncate();
   if (aValue.GetUnit() != eCSSUnit_Array)
     return;
 
   nsCSSValue::Array const & sources = *aValue.GetArrayValue();
   nsAutoCString buf;
@@ -607,17 +608,17 @@ nsStyleUtil::AppendSerializedFontSrc(con
                                      nsAString& aResult)
 {
   // A src: descriptor is represented as an array value; each entry in
   // the array can be eCSSUnit_URL, eCSSUnit_Local_Font, or
   // eCSSUnit_Font_Format.  Blocks of eCSSUnit_Font_Format may appear
   // only after one of the first two.  (css3-fonts only contemplates
   // annotating URLs with formats, but we handle the general case.)
 
-  NS_PRECONDITION(aValue.GetUnit() == eCSSUnit_Array,
+  MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Array,
                   "improper value unit for src:");
 
   const nsCSSValue::Array& sources = *aValue.GetArrayValue();
   size_t i = 0;
 
   while (i < sources.Count()) {
     nsAutoString formats;
 
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -414,17 +414,17 @@ TruncateTo(nsTArray<T>& aArrayToTruncate
  * We check whether the kid has been reflowed and not the frame itself
  * since we sometimes need to call this function during reflow, after the
  * kid has been reflowed but before we have cleared the dirty bits on the
  * frame itself.
  */
 static SVGTextFrame*
 FrameIfAnonymousChildReflowed(SVGTextFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "aFrame must not be null");
+  MOZ_ASSERT(aFrame, "aFrame must not be null");
   nsIFrame* kid = aFrame->PrincipalChildList().FirstChild();
   if (NS_SUBTREE_DIRTY(kid)) {
     MOZ_ASSERT(false, "should have already reflowed the anonymous block child");
     return nullptr;
   }
   return aFrame;
 }
 
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -369,17 +369,17 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext
   MarkInReflow();
   DO_GLOBAL_REFLOW_COUNT("nsSVGOuterSVGFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
   MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
                   ("enter nsSVGOuterSVGFrame::Reflow: availSize=%d,%d",
                   aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
 
-  NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
+  MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
 
   aDesiredSize.Width()  = aReflowInput.ComputedWidth() +
                           aReflowInput.ComputedPhysicalBorderPadding().LeftRight();
   aDesiredSize.Height() = aReflowInput.ComputedHeight() +
                           aReflowInput.ComputedPhysicalBorderPadding().TopBottom();
 
   NS_ASSERTION(!GetPrevInFlow(), "SVG can't currently be broken across pages.");
 
--- a/layout/tables/nsCellMap.cpp
+++ b/layout/tables/nsCellMap.cpp
@@ -217,17 +217,17 @@ FindMapFor(const nsTableRowGroupFrame* a
 
   return nullptr;
 }
 
 nsCellMap*
 nsTableCellMap::GetMapFor(const nsTableRowGroupFrame* aRowGroup,
                           nsCellMap* aStartHint) const
 {
-  NS_PRECONDITION(aRowGroup, "Must have a rowgroup");
+  MOZ_ASSERT(aRowGroup, "Must have a rowgroup");
   NS_ASSERTION(!aRowGroup->GetPrevInFlow(), "GetMapFor called with continuation");
   if (aStartHint) {
     nsCellMap* map = FindMapFor(aRowGroup, aStartHint, nullptr);
     if (map) {
       return map;
     }
   }
 
@@ -664,17 +664,17 @@ nsTableCellMap::RebuildConsideringCells(
 
 void
 nsTableCellMap::RebuildConsideringRows(nsCellMap*                  aCellMap,
                                        int32_t                     aStartRowIndex,
                                        nsTArray<nsTableRowFrame*>* aRowsToInsert,
                                        int32_t                     aNumRowsToRemove,
                                        TableArea&                  aDamageArea)
 {
-  NS_PRECONDITION(!aRowsToInsert || aNumRowsToRemove == 0,
+  MOZ_ASSERT(!aRowsToInsert || aNumRowsToRemove == 0,
                   "Can't handle both removing and inserting rows at once");
 
   int32_t numOrigCols = GetColCount();
   ClearCols();
   nsCellMap* cellMap = mFirstMap;
   int32_t rowCount = 0;
   while (cellMap) {
     if (cellMap == aCellMap) {
@@ -2638,18 +2638,18 @@ nsCellMapColumnIterator::AdvanceRowGroup
 
   // Set mCurMapRow to 0, since cells can't span across table row groups.
   mCurMapRow = 0;
 }
 
 void
 nsCellMapColumnIterator::IncrementRow(int32_t aIncrement)
 {
-  NS_PRECONDITION(aIncrement >= 0, "Bogus increment");
-  NS_PRECONDITION(mCurMap, "Bogus mOrigCells?");
+  MOZ_ASSERT(aIncrement >= 0, "Bogus increment");
+  MOZ_ASSERT(mCurMap, "Bogus mOrigCells?");
   if (aIncrement == 0) {
     AdvanceRowGroup();
   }
   else {
     mCurMapRow += aIncrement;
     if (mCurMapRow >= mCurMapRelevantRowCount) {
       AdvanceRowGroup();
     }
--- a/layout/tables/nsCellMap.h
+++ b/layout/tables/nsCellMap.h
@@ -557,18 +557,18 @@ protected:
  */
 class nsCellMapColumnIterator
 {
 public:
   nsCellMapColumnIterator(const nsTableCellMap* aMap, int32_t aCol) :
     mMap(aMap), mCurMap(aMap->mFirstMap), mCurMapStart(0),
     mCurMapRow(0), mCol(aCol), mFoundCells(0)
   {
-    NS_PRECONDITION(aMap, "Must have map");
-    NS_PRECONDITION(mCol < aMap->GetColCount(), "Invalid column");
+    MOZ_ASSERT(aMap, "Must have map");
+    MOZ_ASSERT(mCol < aMap->GetColCount(), "Invalid column");
     mOrigCells = aMap->GetNumCellsOriginatingInCol(mCol);
     if (mCurMap) {
       mCurMapContentRowCount = mCurMap->GetRowCount();
       uint32_t rowArrayLength = mCurMap->mRows.Length();
       mCurMapRelevantRowCount = std::min(mCurMapContentRowCount, rowArrayLength);
       if (mCurMapRelevantRowCount == 0 && mOrigCells > 0) {
         // This row group is useless; advance!
         AdvanceRowGroup();
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -128,17 +128,17 @@ struct BCPropertyData
 };
 
 ComputedStyle*
 nsTableFrame::GetParentComputedStyle(nsIFrame** aProviderFrame) const
 {
   // Since our parent, the table wrapper frame, returned this frame, we
   // must return whatever our parent would normally have returned.
 
-  NS_PRECONDITION(GetParent(), "table constructed without table wrapper");
+  MOZ_ASSERT(GetParent(), "table constructed without table wrapper");
   if (!mContent->GetParent() && !Style()->GetPseudo()) {
     // We're the root.  We have no ComputedStyle parent.
     *aProviderFrame = nullptr;
     return nullptr;
   }
 
   return GetParent()->DoGetParentComputedStyle(aProviderFrame);
 }
@@ -151,19 +151,19 @@ nsTableFrame::nsTableFrame(ComputedStyle
   memset(&mBits, 0, sizeof(mBits));
 }
 
 void
 nsTableFrame::Init(nsIContent*       aContent,
                    nsContainerFrame* aParent,
                    nsIFrame*         aPrevInFlow)
 {
-  NS_PRECONDITION(!mCellMap, "Init called twice");
-  NS_PRECONDITION(!mTableLayoutStrategy, "Init called twice");
-  NS_PRECONDITION(!aPrevInFlow || aPrevInFlow->IsTableFrame(),
+  MOZ_ASSERT(!mCellMap, "Init called twice");
+  MOZ_ASSERT(!mTableLayoutStrategy, "Init called twice");
+  MOZ_ASSERT(!aPrevInFlow || aPrevInFlow->IsTableFrame(),
                   "prev-in-flow must be of same type");
 
   // Let the base class do its processing
   nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
 
   // see if border collapse is on, if so set it
   const nsStyleTableBorder* tableStyle = StyleTableBorder();
   bool borderCollapse = (NS_STYLE_BORDER_COLLAPSE == tableStyle->mBorderCollapse);
@@ -429,17 +429,17 @@ nsTableFrame::GetColFrame(int32_t aColIn
   }
 }
 
 int32_t
 nsTableFrame::GetEffectiveRowSpan(int32_t                 aRowIndex,
                                   const nsTableCellFrame& aCell) const
 {
   nsTableCellMap* cellMap = GetCellMap();
-  NS_PRECONDITION (nullptr != cellMap, "bad call, cellMap not yet allocated.");
+  MOZ_ASSERT(nullptr != cellMap, "bad call, cellMap not yet allocated.");
 
   return cellMap->GetEffectiveRowSpan(aRowIndex, aCell.ColIndex());
 }
 
 int32_t
 nsTableFrame::GetEffectiveRowSpan(const nsTableCellFrame& aCell,
                                   nsCellMap*              aCellMap)
 {
@@ -712,18 +712,18 @@ nsTableFrame::AppendAnonymousColFrames(i
 // XXX this needs to be moved to nsCSSFrameConstructor
 // Right now it only creates the col frames at the end
 void
 nsTableFrame::AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
                                        int32_t               aNumColsToAdd,
                                        nsTableColType        aColType,
                                        bool                  aAddToTable)
 {
-  NS_PRECONDITION(aColGroupFrame, "null frame");
-  NS_PRECONDITION(aColType != eColAnonymousCol, "Shouldn't happen");
+  MOZ_ASSERT(aColGroupFrame, "null frame");
+  MOZ_ASSERT(aColType != eColAnonymousCol, "Shouldn't happen");
   MOZ_ASSERT(aNumColsToAdd > 0, "We should be adding _something_.");
 
   nsIPresShell *shell = PresShell();
 
   // Get the last col frame
   nsFrameList newColFrames;
 
   int32_t startIndex = mColFrames.Length();
@@ -780,18 +780,19 @@ nsTableFrame::MatchCellMapToColCache(nsT
       aCellMap->AddColsAtEnd(numColsNotRemoved);
     }
   }
 }
 
 void
 nsTableFrame::DidResizeColumns()
 {
-  NS_PRECONDITION(!GetPrevInFlow(),
+  MOZ_ASSERT(!GetPrevInFlow(),
                   "should only be called on first-in-flow");
+
   if (mBits.mResizedColumns)
     return; // already marked
 
   for (nsTableFrame *f = this; f;
        f = static_cast<nsTableFrame*>(f->GetNextInFlow()))
     f->mBits.mResizedColumns = true;
 }
 
@@ -1089,17 +1090,17 @@ nsTableFrame::RemoveRows(nsTableRowFrame
 #endif
 }
 
 // collect the rows ancestors of aFrame
 int32_t
 nsTableFrame::CollectRows(nsIFrame*                   aFrame,
                           nsTArray<nsTableRowFrame*>& aCollection)
 {
-  NS_PRECONDITION(aFrame, "null frame");
+  MOZ_ASSERT(aFrame, "null frame");
   int32_t numRows = 0;
   for (nsIFrame* childFrame : aFrame->PrincipalChildList()) {
     aCollection.AppendElement(static_cast<nsTableRowFrame*>(childFrame));
     numRows++;
   }
   return numRows;
 }
 
@@ -2365,17 +2366,17 @@ nsTableFrame::GetFirstBodyRowGroupFrame(
 }
 
 // Table specific version that takes into account repeated header and footer
 // frames when continuing table frames
 void
 nsTableFrame::PushChildren(const RowGroupArray& aRowGroups,
                            int32_t aPushFrom)
 {
-  NS_PRECONDITION(aPushFrom > 0, "pushing first child");
+  MOZ_ASSERT(aPushFrom > 0, "pushing first child");
 
   // extract the frames from the array into a sibling list
   nsFrameList frames;
   uint32_t childX;
   for (childX = aPushFrom; childX < aRowGroups.Length(); ++childX) {
     nsTableRowGroupFrame* rgFrame = aRowGroups[childX];
     if (!rgFrame->IsRepeatable()) {
       mFrames.RemoveFrame(rgFrame);
@@ -5022,18 +5023,19 @@ static uint8_t styleToPriority[13] = { 0
 static void
 GetColorAndStyle(const nsIFrame* aFrame,
                  WritingMode aTableWM,
                  LogicalSide aSide,
                  uint8_t* aStyle,
                  nscolor* aColor,
                  BCPixelSize* aWidth = nullptr)
 {
-  NS_PRECONDITION(aFrame, "null frame");
-  NS_PRECONDITION(aStyle && aColor, "null argument");
+  MOZ_ASSERT(aFrame, "null frame");
+  MOZ_ASSERT(aStyle && aColor, "null argument");
+
   // initialize out arg
   *aColor = 0;
   if (aWidth) {
     *aWidth = 0;
   }
 
   const nsStyleBorder* styleData = aFrame->StyleBorder();
   mozilla::Side physicalSide = aTableWM.PhysicalSide(aSide);
@@ -8086,29 +8088,29 @@ nsTableFrame::CreateWebRenderCommandsFor
   }
 }
 
 bool
 nsTableFrame::RowHasSpanningCells(int32_t aRowIndex, int32_t aNumEffCols)
 {
   bool result = false;
   nsTableCellMap* cellMap = GetCellMap();
-  NS_PRECONDITION (cellMap, "bad call, cellMap not yet allocated.");
+  MOZ_ASSERT (cellMap, "bad call, cellMap not yet allocated.");
   if (cellMap) {
     result = cellMap->RowHasSpanningCells(aRowIndex, aNumEffCols);
   }
   return result;
 }
 
 bool
 nsTableFrame::RowIsSpannedInto(int32_t aRowIndex, int32_t aNumEffCols)
 {
   bool result = false;
   nsTableCellMap* cellMap = GetCellMap();
-  NS_PRECONDITION (cellMap, "bad call, cellMap not yet allocated.");
+  MOZ_ASSERT (cellMap, "bad call, cellMap not yet allocated.");
   if (cellMap) {
     result = cellMap->RowIsSpannedInto(aRowIndex, aNumEffCols);
   }
   return result;
 }
 
 /* static */
 void
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -1061,17 +1061,17 @@ nsTableRowGroupFrame::SplitSpanningCells
 void
 nsTableRowGroupFrame::UndoContinuedRow(nsPresContext*   aPresContext,
                                        nsTableRowFrame* aRow)
 {
   if (!aRow) return; // allow null aRow to avoid callers doing null checks
 
   // rowBefore was the prev-sibling of aRow's next-sibling before aRow was created
   nsTableRowFrame* rowBefore = (nsTableRowFrame*)aRow->GetPrevInFlow();
-  NS_PRECONDITION(mFrames.ContainsFrame(rowBefore),
+  MOZ_ASSERT(mFrames.ContainsFrame(rowBefore),
                   "rowBefore not in our frame list?");
 
   AutoFrameListPtr overflows(aPresContext, StealOverflowFrames());
   if (!rowBefore || !overflows || overflows->IsEmpty() ||
       overflows->FirstChild() != aRow) {
     NS_ERROR("invalid continued row");
     return;
   }
@@ -1100,17 +1100,17 @@ GetRowBefore(nsTableRowFrame& aStartRow,
 nsresult
 nsTableRowGroupFrame::SplitRowGroup(nsPresContext*           aPresContext,
                                     ReflowOutput&     aDesiredSize,
                                     const ReflowInput& aReflowInput,
                                     nsTableFrame*            aTableFrame,
                                     nsReflowStatus&          aStatus,
                                     bool                     aRowForcedPageBreak)
 {
-  NS_PRECONDITION(aPresContext->IsPaginated(), "SplitRowGroup currently supports only paged media");
+  MOZ_ASSERT(aPresContext->IsPaginated(), "SplitRowGroup currently supports only paged media");
 
   nsTableRowFrame* prevRowFrame = nullptr;
   aDesiredSize.Height() = 0;
 
   nscoord availWidth  = aReflowInput.AvailableWidth();
   nscoord availHeight = aReflowInput.AvailableHeight();
 
   const bool borderCollapse = aTableFrame->IsBorderCollapse();
--- a/layout/tables/nsTableWrapperFrame.cpp
+++ b/layout/tables/nsTableWrapperFrame.cpp
@@ -145,17 +145,17 @@ nsTableWrapperFrame::InsertFrames(ChildL
 }
 
 void
 nsTableWrapperFrame::RemoveFrame(ChildListID  aListID,
                                  nsIFrame*    aOldFrame)
 {
   // We only have two child frames: the inner table and one caption frame.
   // The inner frame can't be removed so this should be the caption
-  NS_PRECONDITION(kCaptionList == aListID, "can't remove inner frame");
+  MOZ_ASSERT(kCaptionList == aListID, "can't remove inner frame");
 
   if (HasSideCaption()) {
     // The old caption isize had an effect on the inner table isize, so
     // we're going to need to reflow it. Mark it dirty
     InnerTableFrame()->AddStateBits(NS_FRAME_IS_DIRTY);
   }
 
   // Remove the frame and destroy it
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -924,17 +924,18 @@ nsBoxFrame::MarkIntrinsicISizesDirty()
   // Don't call base class method, since everything it does is within an
   // IsXULBoxWrapped check.
 }
 
 void
 nsBoxFrame::RemoveFrame(ChildListID     aListID,
                         nsIFrame*       aOldFrame)
 {
-  NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
+  MOZ_ASSERT(aListID == kPrincipalList, "We don't support out-of-flow kids");
+
   nsPresContext* presContext = PresContext();
   nsBoxLayoutState state(presContext);
 
   // remove the child frame
   mFrames.RemoveFrame(aOldFrame);
 
   // notify the layout manager
   if (mLayoutManager)
@@ -952,17 +953,18 @@ void
 nsBoxFrame::InsertFrames(ChildListID     aListID,
                          nsIFrame*       aPrevFrame,
                          nsFrameList&    aFrameList)
 {
    NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
                 "inserting after sibling frame with different parent");
    NS_ASSERTION(!aPrevFrame || mFrames.ContainsFrame(aPrevFrame),
                 "inserting after sibling frame not in our child list");
-   NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
+   MOZ_ASSERT(aListID == kPrincipalList, "We don't support out-of-flow kids");
+
    nsBoxLayoutState state(PresContext());
 
    // insert the child frames
    const nsFrameList::Slice& newFrames =
      mFrames.InsertFrames(this, aPrevFrame, aFrameList);
 
    // notify the layout manager
    if (mLayoutManager)
@@ -978,17 +980,18 @@ nsBoxFrame::InsertFrames(ChildListID    
                                  NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
 
 void
 nsBoxFrame::AppendFrames(ChildListID     aListID,
                          nsFrameList&    aFrameList)
 {
-   NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
+   MOZ_ASSERT(aListID == kPrincipalList, "We don't support out-of-flow kids");
+
    nsBoxLayoutState state(PresContext());
 
    // append the new frames
    const nsFrameList::Slice& newFrames = mFrames.AppendFrames(this, aFrameList);
 
    // notify the layout manager
    if (mLayoutManager)
      mLayoutManager->ChildrenAppended(this, state, newFrames);
--- a/layout/xul/nsListBoxBodyFrame.cpp
+++ b/layout/xul/nsListBoxBodyFrame.cpp
@@ -1395,17 +1395,17 @@ nsListBoxBodyFrame::OnContentRemoved(nsP
         GetListItemNextSibling(aOldNextSibling,
                                getter_AddRefs(nextSiblingContent),
                                siblingIndex);
       }
 
       // if the row being removed is off-screen and above the top frame, we need to
       // adjust our top index and tell the scrollbar to shift up one row.
       if (siblingIndex >= 0 && siblingIndex-1 < mCurrentIndex) {
-        NS_PRECONDITION(mCurrentIndex > 0, "mCurrentIndex > 0");
+        MOZ_ASSERT(mCurrentIndex > 0, "mCurrentIndex > 0");
         --mCurrentIndex;
         mYPosition = mCurrentIndex*mRowHeight;
         AutoWeakFrame weakChildFrame(aChildFrame);
         VerticalScroll(mYPosition);
         if (!weakChildFrame.IsAlive()) {
           return;
         }
       }
--- a/layout/xul/nsPopupSetFrame.cpp
+++ b/layout/xul/nsPopupSetFrame.cpp
@@ -129,17 +129,17 @@ nsPopupSetFrame::DoXULLayout(nsBoxLayout
   }
 
   return rv;
 }
 
 void
 nsPopupSetFrame::RemovePopupFrame(nsIFrame* aPopup)
 {
-  NS_PRECONDITION((aPopup->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
+  MOZ_ASSERT((aPopup->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
                   aPopup->IsMenuPopupFrame(),
                   "removing wrong type of frame in popupset's ::popupList");
 
   mPopupList.DestroyFrame(aPopup);
 }
 
 void
 nsPopupSetFrame::AddPopupFrameList(nsFrameList& aPopupFrameList)
--- a/layout/xul/nsRepeatService.cpp
+++ b/layout/xul/nsRepeatService.cpp
@@ -45,17 +45,17 @@ nsRepeatService::Shutdown()
   gRepeatService = nullptr;
 }
 
 void
 nsRepeatService::Start(Callback aCallback, void* aCallbackData,
                        nsIDocument* aDocument, const nsACString& aCallbackName,
                        uint32_t aInitialDelay)
 {
-  NS_PRECONDITION(aCallback != nullptr, "null ptr");
+  MOZ_ASSERT(aCallback != nullptr, "null ptr");
 
   mCallback = aCallback;
   mCallbackData = aCallbackData;
   mCallbackName = aCallbackName;
 
   mRepeatTimer = NS_NewTimer(
     aDocument->EventTargetFor(TaskCategory::Other));
 
--- a/layout/xul/nsSprocketLayout.cpp
+++ b/layout/xul/nsSprocketLayout.cpp
@@ -907,17 +907,17 @@ nsSprocketLayout::AlignChildren(nsIFrame
                                 nsBoxLayoutState& aState)
 {
   nsFrameState frameState = nsFrameState(0);
   GetFrameState(aBox, frameState);
   bool isHorizontal = (frameState & NS_STATE_IS_HORIZONTAL) != 0;
   nsRect clientRect;
   aBox->GetXULClientRect(clientRect);
 
-  NS_PRECONDITION(!(frameState & NS_STATE_AUTO_STRETCH),
+  MOZ_ASSERT(!(frameState & NS_STATE_AUTO_STRETCH),
                   "Only AlignChildren() with non-stretch alignment");
 
   // These are only calculated if needed
   nsIFrame::Halignment halign;
   nsIFrame::Valignment valign;
   nscoord maxAscent = 0;
   bool isLTR;
 
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -1314,17 +1314,17 @@ nsTreeBodyFrame::CheckTextForBidi(nsAuto
 
 void
 nsTreeBodyFrame::AdjustForCellText(nsAutoString& aText,
                                    int32_t aRowIndex,  nsTreeColumn* aColumn,
                                    gfxContext& aRenderingContext,
                                    nsFontMetrics& aFontMetrics,
                                    nsRect& aTextRect)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
 
   nscoord maxWidth = aTextRect.width;
   bool widthIsGreater = nsLayoutUtils::StringWidthIsGreaterThan(aText,
                                                                 aFontMetrics,
                                                                 drawTarget,
                                                                 maxWidth);
@@ -1486,17 +1486,17 @@ nsTreeBodyFrame::AdjustForCellText(nsAut
   aTextRect.width = width;
 }
 
 nsICSSAnonBoxPseudo*
 nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
                                      int32_t aRowIndex,
                                      nsTreeColumn* aColumn)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   // Obtain the properties for our cell.
   PrefillPropertyArray(aRowIndex, aColumn);
   nsAutoString properties;
   mView->GetCellProperties(aRowIndex, aColumn, properties);
   nsTreeUtils::TokenizeProperties(properties, mScratchArray);
 
   // Resolve style for the cell.
@@ -1677,18 +1677,18 @@ nsTreeBodyFrame::GetCellAt(nscoord aX, n
   }
 }
 
 nsresult
 nsTreeBodyFrame::GetCellWidth(int32_t aRow, nsTreeColumn* aCol,
                               gfxContext* aRenderingContext,
                               nscoord& aDesiredSize, nscoord& aCurrentSize)
 {
-  NS_PRECONDITION(aCol, "aCol must not be null");
-  NS_PRECONDITION(aRenderingContext, "aRenderingContext must not be null");
+  MOZ_ASSERT(aCol, "aCol must not be null");
+  MOZ_ASSERT(aRenderingContext, "aRenderingContext must not be null");
 
   // The rect for the current cell.
   nscoord colWidth;
   nsresult rv = aCol->GetWidthInTwips(this, &colWidth);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsRect cellRect(0, 0, colWidth, mRowHeight);
 
@@ -1920,17 +1920,17 @@ nsTreeBodyFrame::EndUpdateBatch()
   }
 
   return NS_OK;
 }
 
 void
 nsTreeBodyFrame::PrefillPropertyArray(int32_t aRowIndex, nsTreeColumn* aCol)
 {
-  NS_PRECONDITION(!aCol || aCol->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(!aCol || aCol->GetFrame(), "invalid column passed");
   mScratchArray.Clear();
 
   // focus
   if (mFocused)
     mScratchArray.AppendElement(nsGkAtoms::focus);
 
   // sort
   bool sorted = false;
@@ -2979,17 +2979,17 @@ nsTreeBodyFrame::PaintTreeBody(gfxContex
 
 ImgDrawResult
 nsTreeBodyFrame::PaintColumn(nsTreeColumn*        aColumn,
                              const nsRect&        aColumnRect,
                              nsPresContext*      aPresContext,
                              gfxContext&          aRenderingContext,
                              const nsRect&        aDirtyRect)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   // Now obtain the properties for our cell.
   PrefillPropertyArray(-1, aColumn);
   nsAutoString properties;
   mView->GetColumnProperties(aColumn, properties);
   nsTreeUtils::TokenizeProperties(properties, mScratchArray);
 
   // Resolve style for the column.  It contains all the info we need to lay ourselves
@@ -3230,17 +3230,17 @@ nsTreeBodyFrame::PaintCell(int32_t      
                            const nsRect&         aCellRect,
                            nsPresContext*        aPresContext,
                            gfxContext&           aRenderingContext,
                            const nsRect&         aDirtyRect,
                            nscoord&              aCurrX,
                            nsPoint               aPt,
                            nsDisplayListBuilder* aBuilder)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   // Now obtain the properties for our cell.
   // XXX Automatically fill in the following props: open, closed, container, leaf, selected, focused, and the col ID.
   PrefillPropertyArray(aRowIndex, aColumn);
   nsAutoString properties;
   mView->GetCellProperties(aRowIndex, aColumn, properties);
   nsTreeUtils::TokenizeProperties(properties, mScratchArray);
 
@@ -3417,17 +3417,17 @@ nsTreeBodyFrame::PaintTwisty(int32_t    
                              nsTreeColumn*        aColumn,
                              const nsRect&        aTwistyRect,
                              nsPresContext*      aPresContext,
                              gfxContext&          aRenderingContext,
                              const nsRect&        aDirtyRect,
                              nscoord&             aRemainingWidth,
                              nscoord&             aCurrX)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   bool isRTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
   nscoord rightEdge = aCurrX + aRemainingWidth;
   // Paint the twisty, but only if we are a non-empty container.
   bool shouldPaint = false;
   bool isContainer = false;
   mView->IsContainer(aRowIndex, &isContainer);
   if (isContainer) {
@@ -3524,17 +3524,17 @@ nsTreeBodyFrame::PaintImage(int32_t     
                             const nsRect&         aImageRect,
                             nsPresContext*        aPresContext,
                             gfxContext&           aRenderingContext,
                             const nsRect&         aDirtyRect,
                             nscoord&              aRemainingWidth,
                             nscoord&              aCurrX,
                             nsDisplayListBuilder* aBuilder)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   bool isRTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
   nscoord rightEdge = aCurrX + aRemainingWidth;
   // Resolve style for the image.
   ComputedStyle* imageContext = GetPseudoComputedStyle(nsCSSAnonBoxes::mozTreeImage);
 
   // Obtain opacity value for the image.
   float opacity = imageContext->StyleEffects()->mOpacity;
@@ -3699,17 +3699,17 @@ ImgDrawResult
 nsTreeBodyFrame::PaintText(int32_t              aRowIndex,
                            nsTreeColumn*        aColumn,
                            const nsRect&        aTextRect,
                            nsPresContext*      aPresContext,
                            gfxContext&          aRenderingContext,
                            const nsRect&        aDirtyRect,
                            nscoord&             aCurrX)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   bool isRTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
 
   // Now obtain the text for our cell.
   nsAutoString text;
   mView->GetCellText(aRowIndex, aColumn, text);
 
   if (aColumn->Type() == nsITreeColumn::TYPE_PASSWORD) {
@@ -3830,17 +3830,17 @@ nsTreeBodyFrame::PaintText(int32_t      
 ImgDrawResult
 nsTreeBodyFrame::PaintCheckbox(int32_t              aRowIndex,
                                nsTreeColumn*        aColumn,
                                const nsRect&        aCheckboxRect,
                                nsPresContext*      aPresContext,
                                gfxContext&          aRenderingContext,
                                const nsRect&        aDirtyRect)
 {
-  NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
+  MOZ_ASSERT(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   // Resolve style for the checkbox.
   ComputedStyle* checkboxContext = GetPseudoComputedStyle(nsCSSAnonBoxes::mozTreeCheckbox);
 
   nscoord rightEdge = aCheckboxRect.XMost();
 
   // Obtain the margins for the checkbox and then deflate our rect by that
   // amount.  The checkbox is assumed to be contained within the deflated rect.
--- a/modules/libjar/nsJAR.cpp
+++ b/modules/libjar/nsJAR.cpp
@@ -44,17 +44,17 @@ NS_IMPL_QUERY_INTERFACE(nsJAR, nsIZipRea
 NS_IMPL_ADDREF(nsJAR)
 
 // Custom Release method works with nsZipReaderCache...
 // Release might be called from multi-thread, we have to
 // take this function carefully to avoid delete-after-use.
 MozExternalRefCountType nsJAR::Release(void)
 {
   nsrefcnt count;
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
 
   RefPtr<nsZipReaderCache> cache;
   if (mRefCnt == 2) { // don't use a lock too frequently
     // Use a mutex here to guarantee mCache is not racing and the target instance
     // is still valid to increase ref-count.
     MutexAutoLock lock(mLock);
     cache = mCache;
     mCache = nullptr;
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -800,17 +800,17 @@ nsJARChannel::SetNotificationCallbacks(n
 {
     mCallbacks = aCallbacks;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsJARChannel::GetSecurityInfo(nsISupports **aSecurityInfo)
 {
-    NS_PRECONDITION(aSecurityInfo, "Null out param");
+    MOZ_ASSERT(aSecurityInfo, "Null out param");
     NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsJARChannel::GetContentType(nsACString &result)
 {
     // If the Jar file has not been open yet,
--- a/netwerk/base/nsBaseChannel.h
+++ b/netwerk/base/nsBaseChannel.h
@@ -264,17 +264,17 @@ private:
   class RedirectRunnable : public mozilla::Runnable
   {
   public:
     RedirectRunnable(nsBaseChannel* chan, nsIChannel* newChannel)
       : mozilla::Runnable("nsBaseChannel::RedirectRunnable")
       , mChannel(chan)
       , mNewChannel(newChannel)
     {
-      NS_PRECONDITION(newChannel, "Must have channel to redirect to");
+      MOZ_ASSERT(newChannel, "Must have channel to redirect to");
     }
 
     NS_IMETHOD Run() override
     {
       mChannel->HandleAsyncRedirect(mNewChannel);
       return NS_OK;
     }
 
--- a/netwerk/base/nsDirectoryIndexStream.cpp
+++ b/netwerk/base/nsDirectoryIndexStream.cpp
@@ -79,17 +79,17 @@ static int compare(nsIFile* aElement1, n
 
 nsresult
 nsDirectoryIndexStream::Init(nsIFile* aDir)
 {
     nsresult rv;
     bool isDir;
     rv = aDir->IsDirectory(&isDir);
     if (NS_FAILED(rv)) return rv;
-    NS_PRECONDITION(isDir, "not a directory");
+    MOZ_ASSERT(isDir, "not a directory");
     if (!isDir)
         return NS_ERROR_ILLEGAL_VALUE;
 
     if (MOZ_LOG_TEST(gLog, LogLevel::Debug)) {
         MOZ_LOG(gLog, LogLevel::Debug,
                ("nsDirectoryIndexStream[%p]: initialized on %s",
                 this, aDir->HumanReadablePath().get()));
     }
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -2307,18 +2307,18 @@ NS_NewNotificationCallbacksAggregation(n
                                        nsIInterfaceRequestor **result)
 {
     return NS_NewNotificationCallbacksAggregation(callbacks, loadGroup, nullptr, result);
 }
 
 nsresult
 NS_DoImplGetInnermostURI(nsINestedURI *nestedURI, nsIURI **result)
 {
-    NS_PRECONDITION(nestedURI, "Must have a nested URI!");
-    NS_PRECONDITION(!*result, "Must have null *result");
+    MOZ_ASSERT(nestedURI, "Must have a nested URI!");
+    MOZ_ASSERT(!*result, "Must have null *result");
 
     nsCOMPtr<nsIURI> inner;
     nsresult rv = nestedURI->GetInnerURI(getter_AddRefs(inner));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // We may need to loop here until we reach the innermost
     // URI.
     nsCOMPtr<nsINestedURI> nestedInner(do_QueryInterface(inner));
@@ -2341,17 +2341,17 @@ NS_ImplGetInnermostURI(nsINestedURI *nes
     *result = nullptr;
 
     return NS_DoImplGetInnermostURI(nestedURI, result);
 }
 
 nsresult
 NS_EnsureSafeToReturn(nsIURI *uri, nsIURI **result)
 {
-    NS_PRECONDITION(uri, "Must have a URI");
+    MOZ_ASSERT(uri, "Must have a URI");
 
     // Assume mutable until told otherwise
     bool isMutable = true;
     nsCOMPtr<nsIMutable> mutableObj(do_QueryInterface(uri));
     if (mutableObj) {
         nsresult rv = mutableObj->GetMutable(&isMutable);
         isMutable = NS_FAILED(rv) || isMutable;
     }
@@ -2401,17 +2401,17 @@ NS_TryToMakeImmutable(nsIURI *uri,
     }
 
     return result.forget();
 }
 
 already_AddRefed<nsIURI>
 NS_GetInnermostURI(nsIURI *aURI)
 {
-    NS_PRECONDITION(aURI, "Must have URI");
+    MOZ_ASSERT(aURI, "Must have URI");
 
     nsCOMPtr<nsIURI> uri = aURI;
 
     nsCOMPtr<nsINestedURI> nestedURI(do_QueryInterface(uri));
     if (!nestedURI) {
         return uri.forget();
     }
 
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -600,17 +600,17 @@ NS_LoadPersistentPropertiesFromURISpec(n
  * Note: templatized only because nsIWebSocketChannel is currently not an
  * nsIChannel.
  */
 template <class T> inline void
 NS_QueryNotificationCallbacks(T            *channel,
                               const nsIID  &iid,
                               void        **result)
 {
-    NS_PRECONDITION(channel, "null channel");
+    MOZ_ASSERT(channel, "null channel");
     *result = nullptr;
 
     nsCOMPtr<nsIInterfaceRequestor> cbs;
     mozilla::Unused << channel->GetNotificationCallbacks(getter_AddRefs(cbs));
     if (cbs)
         cbs->GetInterface(iid, result);
     if (!*result) {
         // try load group's notification callbacks...
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -2127,18 +2127,18 @@ nsProtocolProxyService::LoadHostFilters(
 loser:
         delete hinfo;
     }
 }
 
 nsresult
 nsProtocolProxyService::GetProtocolInfo(nsIURI *uri, nsProtocolInfo *info)
 {
-    NS_PRECONDITION(uri, "URI is null");
-    NS_PRECONDITION(info, "info is null");
+    MOZ_ASSERT(uri, "URI is null");
+    MOZ_ASSERT(info, "info is null");
 
     nsresult rv;
 
     rv = uri->GetScheme(info->scheme);
     if (NS_FAILED(rv))
         return rv;
 
     nsCOMPtr<nsIIOService> ios = do_GetIOService(&rv);
--- a/netwerk/base/nsRequestObserverProxy.cpp
+++ b/netwerk/base/nsRequestObserverProxy.cpp
@@ -23,33 +23,33 @@ static LazyLogModule gRequestObserverPro
 //-----------------------------------------------------------------------------
 // nsARequestObserverEvent internal class...
 //-----------------------------------------------------------------------------
 
 nsARequestObserverEvent::nsARequestObserverEvent(nsIRequest* request)
   : Runnable("net::nsARequestObserverEvent")
   , mRequest(request)
 {
-    NS_PRECONDITION(mRequest, "null pointer");
+    MOZ_ASSERT(mRequest, "null pointer");
 }
 
 //-----------------------------------------------------------------------------
 // nsOnStartRequestEvent internal class...
 //-----------------------------------------------------------------------------
 
 class nsOnStartRequestEvent : public nsARequestObserverEvent
 {
     RefPtr<nsRequestObserverProxy> mProxy;
 public:
     nsOnStartRequestEvent(nsRequestObserverProxy *proxy,
                           nsIRequest *request)
         : nsARequestObserverEvent(request)
         , mProxy(proxy)
     {
-        NS_PRECONDITION(mProxy, "null pointer");
+        MOZ_ASSERT(mProxy, "null pointer");
     }
 
     virtual ~nsOnStartRequestEvent() = default;
 
     NS_IMETHOD Run() override
     {
         LOG(("nsOnStartRequestEvent::HandleEvent [req=%p]\n", mRequest.get()));
 
@@ -79,17 +79,17 @@ class nsOnStopRequestEvent : public nsAR
 {
     RefPtr<nsRequestObserverProxy> mProxy;
 public:
     nsOnStopRequestEvent(nsRequestObserverProxy *proxy,
                          nsIRequest *request)
         : nsARequestObserverEvent(request)
         , mProxy(proxy)
     {
-        NS_PRECONDITION(mProxy, "null pointer");
+        MOZ_ASSERT(mProxy, "null pointer");
     }
 
     virtual ~nsOnStopRequestEvent() = default;
 
     NS_IMETHOD Run() override
     {
         LOG(("nsOnStopRequestEvent::HandleEvent [req=%p]\n", mRequest.get()));
 
--- a/netwerk/base/nsSimpleStreamListener.cpp
+++ b/netwerk/base/nsSimpleStreamListener.cpp
@@ -66,17 +66,17 @@ nsSimpleStreamListener::OnDataAvailable(
 //----------------------------------------------------------------------------
 // nsISimpleStreamListener implementation...
 //----------------------------------------------------------------------------
 //
 NS_IMETHODIMP
 nsSimpleStreamListener::Init(nsIOutputStream *aSink,
                              nsIRequestObserver *aObserver)
 {
-    NS_PRECONDITION(aSink, "null output stream");
+    MOZ_ASSERT(aSink, "null output stream");
 
     mSink = aSink;
     mObserver = aObserver;
 
     return NS_OK;
 }
 
 } // namespace net
--- a/netwerk/base/nsSimpleURI.cpp
+++ b/netwerk/base/nsSimpleURI.cpp
@@ -572,17 +572,17 @@ nsSimpleURI::EqualsExceptRef(nsIURI* oth
 }
 
 /* virtual */ nsresult
 nsSimpleURI::EqualsInternal(nsIURI* other,
                             nsSimpleURI::RefHandlingEnum refHandlingMode,
                             bool* result)
 {
     NS_ENSURE_ARG_POINTER(other);
-    NS_PRECONDITION(result, "null pointer");
+    MOZ_ASSERT(result, "null pointer");
 
     RefPtr<nsSimpleURI> otherUri;
     nsresult rv = other->QueryInterface(kThisSimpleURIImplementationCID,
                                         getter_AddRefs(otherUri));
     if (NS_FAILED(rv)) {
         *result = false;
         return NS_OK;
     }
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -2199,17 +2199,17 @@ nsStandardURL::EqualsExceptRef(nsIURI *u
 }
 
 nsresult
 nsStandardURL::EqualsInternal(nsIURI *unknownOther,
                               nsStandardURL::RefHandlingEnum refHandlingMode,
                               bool *result)
 {
     NS_ENSURE_ARG_POINTER(unknownOther);
-    NS_PRECONDITION(result, "null pointer");
+    MOZ_ASSERT(result, "null pointer");
 
     RefPtr<nsStandardURL> other;
     nsresult rv = unknownOther->QueryInterface(kThisImplCID,
                                                getter_AddRefs(other));
     if (NS_FAILED(rv)) {
         *result = false;
         return NS_OK;
     }
@@ -2287,17 +2287,17 @@ nsStandardURL::EqualsInternal(nsIURI *un
     *result = false;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsStandardURL::SchemeIs(const char *scheme, bool *result)
 {
-    NS_PRECONDITION(result, "null pointer");
+    MOZ_ASSERT(result, "null pointer");
 
     *result = SegmentIs(mScheme, scheme);
     return NS_OK;
 }
 
 /* virtual */ nsStandardURL*
 nsStandardURL::StartClone()
 {
@@ -3142,17 +3142,17 @@ nsStandardURL::SetFileExtensionInternal(
 
 //----------------------------------------------------------------------------
 // nsStandardURL::nsIFileURL
 //----------------------------------------------------------------------------
 
 nsresult
 nsStandardURL::EnsureFile()
 {
-    NS_PRECONDITION(mSupportsFileURL,
+    MOZ_ASSERT(mSupportsFileURL,
                     "EnsureFile() called on a URL that doesn't support files!");
     if (mFile) {
         // Nothing to do
         return NS_OK;
     }
 
     // Parse the spec if we don't have a cached result
     if (mSpec.IsEmpty()) {
@@ -3166,17 +3166,17 @@ nsStandardURL::EnsureFile()
     }
 
     return net_GetFileFromURLSpec(mSpec, getter_AddRefs(mFile));
 }
 
 NS_IMETHODIMP
 nsStandardURL::GetFile(nsIFile **result)
 {
-    NS_PRECONDITION(mSupportsFileURL,
+    MOZ_ASSERT(mSupportsFileURL,
                     "GetFile() called on a URL that doesn't support files!");
     nsresult rv = EnsureFile();
     if (NS_FAILED(rv))
         return rv;
 
     if (LOG_ENABLED()) {
         LOG(("nsStandardURL::GetFile [this=%p spec=%s resulting_path=%s]\n",
             this, mSpec.get(), mFile->HumanReadablePath().get()));
@@ -3336,17 +3336,17 @@ nsStandardURL::Read(nsIObjectInputStream
 {
     NS_NOTREACHED("Use nsIURIMutator.read() instead");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 nsresult
 nsStandardURL::ReadPrivate(nsIObjectInputStream *stream)
 {
-    NS_PRECONDITION(mDisplayHost.IsEmpty(), "Shouldn't have cached unicode host");
+    MOZ_ASSERT(mDisplayHost.IsEmpty(), "Shouldn't have cached unicode host");
 
     nsresult rv;
 
     uint32_t urlType;
     rv = stream->Read32(&urlType);
     if (NS_FAILED(rv)) return rv;
     mURLType = urlType;
     switch (mURLType) {
@@ -3591,18 +3591,18 @@ nsStandardURL::Serialize(URIParams& aPar
     // mDisplayHost is just a cache that can be recovered as needed.
 
     aParams = params;
 }
 
 bool
 nsStandardURL::Deserialize(const URIParams& aParams)
 {
-    NS_PRECONDITION(mDisplayHost.IsEmpty(), "Shouldn't have cached unicode host");
-    NS_PRECONDITION(!mFile, "Shouldn't have cached file");
+    MOZ_ASSERT(mDisplayHost.IsEmpty(), "Shouldn't have cached unicode host");
+    MOZ_ASSERT(!mFile, "Shouldn't have cached file");
 
     if (aParams.type() != URIParams::TStandardURLParams) {
         NS_ERROR("Received unknown parameters from the other process!");
         return false;
     }
 
     const StandardURLParams& params = aParams.get_StandardURLParams();
 
--- a/netwerk/base/nsURLParsers.cpp
+++ b/netwerk/base/nsURLParsers.cpp
@@ -363,17 +363,17 @@ nsNoAuthURLParser::ParseAuthority(const 
     return NS_ERROR_UNEXPECTED;
 }
 
 void
 nsNoAuthURLParser::ParseAfterScheme(const char *spec, int32_t specLen,
                                     uint32_t *authPos, int32_t *authLen,
                                     uint32_t *pathPos, int32_t *pathLen)
 {
-    NS_PRECONDITION(specLen >= 0, "unexpected");
+    MOZ_ASSERT(specLen >= 0, "unexpected");
 
     // everything is the path
     uint32_t pos = 0;
     switch (CountConsecutiveSlashes(spec, specLen)) {
     case 0:
     case 1:
         break;
     case 2:
@@ -626,17 +626,17 @@ nsAuthURLParser::ParseServerInfo(const c
     return NS_OK;
 }
 
 void
 nsAuthURLParser::ParseAfterScheme(const char *spec, int32_t specLen,
                                   uint32_t *authPos, int32_t *authLen,
                                   uint32_t *pathPos, int32_t *pathLen)
 {
-    NS_PRECONDITION(specLen >= 0, "unexpected");
+    MOZ_ASSERT(specLen >= 0, "unexpected");
 
     uint32_t nslash = CountConsecutiveSlashes(spec, specLen);
 
     // search for the end of the authority section
     const char *end = spec + specLen;
     const char *p;
     for (p = spec + nslash; p < end; ++p) {
         if (*p == '/' || *p == '?' || *p == '#')
@@ -658,17 +658,17 @@ nsAuthURLParser::ParseAfterScheme(const 
 // nsStdURLParser implementation
 //----------------------------------------------------------------------------
 
 void
 nsStdURLParser::ParseAfterScheme(const char *spec, int32_t specLen,
                                  uint32_t *authPos, int32_t *authLen,
                                  uint32_t *pathPos, int32_t *pathLen)
 {
-    NS_PRECONDITION(specLen >= 0, "unexpected");
+    MOZ_ASSERT(specLen >= 0, "unexpected");
 
     uint32_t nslash = CountConsecutiveSlashes(spec, specLen);
 
     // search for the end of the authority section
     const char *end = spec + specLen;
     const char *p;
     for (p = spec + nslash; p < end; ++p) {
         if (strchr("/?#;", *p))
--- a/netwerk/cache/nsCacheEntryDescriptor.cpp
+++ b/netwerk/cache/nsCacheEntryDescriptor.cpp
@@ -664,17 +664,17 @@ nsCacheEntryDescriptor::nsInputStreamWra
         mozilla::MutexAutoLock lock(mLock);
         desc = mDescriptor;
     }
 
     if (desc)
         nsCacheService::Lock(LOCK_TELEM(NSINPUTSTREAMWRAPPER_RELEASE));
 
     nsrefcnt count;
-    NS_PRECONDITION(0 != mRefCnt, "dup release");
+    MOZ_ASSERT(0 != mRefCnt, "dup release");
     count = --mRefCnt;
     NS_LOG_RELEASE(this, count, "nsCacheEntryDescriptor::nsInputStreamWrapper");
 
     if (0 == count) {
         // don't use desc here since mDescriptor might be already nulled out
         if (mDescriptor) {
             NS_ASSERTION(mDescriptor->mInputWrappers.Contains(this),
                          "Wrapper not found in array!");
@@ -857,17 +857,17 @@ nsCacheEntryDescriptor::nsDecompressInpu
         desc = mDescriptor;
     }
 
     if (desc)
         nsCacheService::Lock(LOCK_TELEM(
                              NSDECOMPRESSINPUTSTREAMWRAPPER_RELEASE));
 
     nsrefcnt count;
-    NS_PRECONDITION(0 != mRefCnt, "dup release");
+    MOZ_ASSERT(0 != mRefCnt, "dup release");
     count = --mRefCnt;
     NS_LOG_RELEASE(this, count,
                    "nsCacheEntryDescriptor::nsDecompressInputStreamWrapper");
 
     if (0 == count) {
         // don't use desc here since mDescriptor might be already nulled out
         if (mDescriptor) {
             NS_ASSERTION(mDescriptor->mInputWrappers.Contains(this),
@@ -1046,17 +1046,17 @@ nsCacheEntryDescriptor::nsOutputStreamWr
         mozilla::MutexAutoLock lock(mLock);
         desc = mDescriptor;
     }
 
     if (desc)
         nsCacheService::Lock(LOCK_TELEM(NSOUTPUTSTREAMWRAPPER_RELEASE));
 
     nsrefcnt count;
-    NS_PRECONDITION(0 != mRefCnt, "dup release");
+    MOZ_ASSERT(0 != mRefCnt, "dup release");
     count = --mRefCnt;
     NS_LOG_RELEASE(this, count,
                    "nsCacheEntryDescriptor::nsOutputStreamWrapper");
 
     if (0 == count) {
         // don't use desc here since mDescriptor might be already nulled out
         if (mDescriptor)
             mDescriptor->mOutputWrapper = nullptr;
@@ -1276,17 +1276,17 @@ nsCacheEntryDescriptor::nsCompressOutput
         mozilla::MutexAutoLock lock(mLock);
         desc = mDescriptor;
     }
 
     if (desc)
         nsCacheService::Lock(LOCK_TELEM(NSCOMPRESSOUTPUTSTREAMWRAPPER_RELEASE));
 
     nsrefcnt count;
-    NS_PRECONDITION(0 != mRefCnt, "dup release");
+    MOZ_ASSERT(0 != mRefCnt, "dup release");
     count = --mRefCnt;
     NS_LOG_RELEASE(this, count,
                    "nsCacheEntryDescriptor::nsCompressOutputStreamWrapper");
 
     if (0 == count) {
         // don't use desc here since mDescriptor might be already nulled out
         if (mDescriptor)
             mDescriptor->mOutputWrapper = nullptr;
--- a/netwerk/cache2/CacheFileChunk.cpp
+++ b/netwerk/cache2/CacheFileChunk.cpp
@@ -295,17 +295,17 @@ NS_IMETHODIMP_(MozExternalRefCountType)
 CacheFileChunk::Release()
 {
   nsrefcnt count = mRefCnt - 1;
   if (DispatchRelease()) {
     // Redispatched to the main thread.
     return count;
   }
 
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "CacheFileChunk");
 
   if (0 == count) {
     mRefCnt = 1;
     delete (this);
     return 0;
   }
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -88,17 +88,17 @@ CacheFileHandle::Release()
   if (DispatchRelease()) {
     // Redispatched to the IO thread.
     return count;
   }
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
   LOG(("CacheFileHandle::Release() [this=%p, refcnt=%" PRIuPTR "]", this, mRefCnt.get()));
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "CacheFileHandle");
 
   if (0 == count) {
     mRefCnt = 1;
     delete (this);
     return 0;
   }
--- a/netwerk/cache2/CacheFileInputStream.cpp
+++ b/netwerk/cache2/CacheFileInputStream.cpp
@@ -12,17 +12,17 @@
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ADDREF(CacheFileInputStream)
 NS_IMETHODIMP_(MozExternalRefCountType)
 CacheFileInputStream::Release()
 {
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   nsrefcnt count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "CacheFileInputStream");
 
   if (0 == count) {
     mRefCnt = 1;
     delete (this);
     return 0;
   }
--- a/netwerk/cache2/CacheFileOutputStream.cpp
+++ b/netwerk/cache2/CacheFileOutputStream.cpp
@@ -14,17 +14,17 @@
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ADDREF(CacheFileOutputStream)
 NS_IMETHODIMP_(MozExternalRefCountType)
 CacheFileOutputStream::Release()
 {
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   nsrefcnt count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "CacheFileOutputStream");
 
   if (0 == count) {
     mRefCnt = 1;
     {
       CacheFileAutoLock lock(mFile);
       mFile->RemoveOutput(this, mStatus);
--- a/netwerk/protocol/about/nsAboutProtocolUtils.h
+++ b/netwerk/protocol/about/nsAboutProtocolUtils.h
@@ -35,17 +35,17 @@ NS_GetAboutModuleName(nsIURI *aAboutURI,
     // convert to lowercase, as all about: modules are lowercase
     ToLowerCase(aModule);
     return NS_OK;
 }
 
 inline nsresult
 NS_GetAboutModule(nsIURI *aAboutURI, nsIAboutModule** aModule)
 {
-  NS_PRECONDITION(aAboutURI, "Must have URI");
+  MOZ_ASSERT(aAboutURI, "Must have URI");
 
   nsAutoCString contractID;
   nsresult rv = NS_GetAboutModuleName(aAboutURI, contractID);
   if (NS_FAILED(rv)) return rv;
 
   // look up a handler to deal with "what"
   contractID.InsertLiteral(NS_ABOUT_MODULE_CONTRACTID_PREFIX, 0);
 
--- a/netwerk/protocol/http/AltDataOutputStreamChild.cpp
+++ b/netwerk/protocol/http/AltDataOutputStreamChild.cpp
@@ -4,17 +4,17 @@
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ADDREF(AltDataOutputStreamChild)
 
 NS_IMETHODIMP_(MozExternalRefCountType) AltDataOutputStreamChild::Release()
 {
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
   --mRefCnt;
   NS_LOG_RELEASE(this, mRefCnt, "AltDataOutputStreamChild");
 
   if (mRefCnt == 1 && mIPCOpen) {
     // The only reference left is the IPDL one. After the parent replies back
     // with a DeleteSelf message, the child will call Send__delete__(this),
     // decrementing the ref count and triggering the destructor.
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -321,17 +321,17 @@ HttpBaseChannel::Init(nsIURI *aURI,
                       uint32_t aCaps,
                       nsProxyInfo *aProxyInfo,
                       uint32_t aProxyResolveFlags,
                       nsIURI *aProxyURI,
                       uint64_t aChannelId)
 {
   LOG(("HttpBaseChannel::Init [this=%p]\n", this));
 
-  NS_PRECONDITION(aURI, "null uri");
+  MOZ_ASSERT(aURI, "null uri");
 
   mURI = aURI;
   mOriginalURI = aURI;
   mDocumentURI = nullptr;
   mCaps = aCaps;
   mProxyResolveFlags = aProxyResolveFlags;
   mProxyURI = aProxyURI;
   mChannelId = aChannelId;
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -779,17 +779,17 @@ MOZ_MUST_USE nsresult HttpAsyncAborter<T
   return AsyncCall(&T::HandleAsyncAbort);
 }
 
 // Each subclass needs to define its own version of this (which just calls this
 // base version), else we wind up casting base/derived member function ptrs
 template <class T>
 inline void HttpAsyncAborter<T>::HandleAsyncAbort()
 {
-  NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+  MOZ_ASSERT(!mCallOnResume, "How did that happen?");
 
   if (mThis->mSuspendCount) {
     MOZ_LOG(gHttpLog, LogLevel::Debug,
            ("Waiting until resume to do async notification [this=%p]\n", mThis));
     mCallOnResume = &T::HandleAsyncAbort;
     return;
   }
 
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -531,17 +531,17 @@ nsHttpChannel::OnBeforeConnect()
     }
 
     return Connect();
 }
 
 void
 nsHttpChannel::OnBeforeConnectContinue()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
     nsresult rv;
 
     if (mSuspendCount) {
         LOG(("Waiting until resume OnBeforeConnect [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::OnBeforeConnectContinue;
         return;
     }
 
@@ -844,17 +844,17 @@ nsHttpChannel::ReleaseListeners()
     HttpBaseChannel::ReleaseListeners();
     mChannelClassifier = nullptr;
     mWarningReporter = nullptr;
 }
 
 void
 nsHttpChannel::HandleAsyncRedirect()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
 
     if (mSuspendCount) {
         LOG(("Waiting until resume to do async redirect [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::HandleAsyncRedirect;
         return;
     }
 
     nsresult rv = NS_OK;
@@ -918,17 +918,17 @@ nsHttpChannel::ContinueHandleAsyncRedire
         mLoadGroup->RemoveRequest(this, nullptr, mStatus);
 
     return NS_OK;
 }
 
 void
 nsHttpChannel::HandleAsyncNotModified()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
 
     if (mSuspendCount) {
         LOG(("Waiting until resume to do async not-modified [this=%p]\n",
              this));
         mCallOnResume = &nsHttpChannel::HandleAsyncNotModified;
         return;
     }
 
@@ -942,17 +942,17 @@ nsHttpChannel::HandleAsyncNotModified()
 
     if (mLoadGroup)
         mLoadGroup->RemoveRequest(this, nullptr, mStatus);
 }
 
 void
 nsHttpChannel::HandleAsyncFallback()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
 
     if (mSuspendCount) {
         LOG(("Waiting until resume to do async fallback [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::HandleAsyncFallback;
         return;
     }
 
     nsresult rv = NS_OK;
@@ -2283,17 +2283,17 @@ nsHttpChannel::AsyncContinueProcessRespo
         // ourselves.
         Unused << Cancel(rv);
     }
 }
 
 nsresult
 nsHttpChannel::ContinueProcessResponse1()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
     nsresult rv;
 
     if (mSuspendCount) {
         LOG(("Waiting until resume to finish processing response [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::AsyncContinueProcessResponse;
         return NS_OK;
     }
 
@@ -2792,17 +2792,17 @@ nsHttpChannel::ProxyFailover()
     // XXXbz so where does this codepath remove us from the loadgroup,
     // exactly?
     return AsyncDoReplaceWithProxy(pi);
 }
 
 void
 nsHttpChannel::HandleAsyncRedirectChannelToHttps()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
 
     if (mSuspendCount) {
         LOG(("Waiting until resume to do async redirect to https [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::HandleAsyncRedirectChannelToHttps;
         return;
     }
 
     nsresult rv = StartRedirectChannelToHttps();
@@ -2827,18 +2827,18 @@ nsHttpChannel::StartRedirectChannelToHtt
     return StartRedirectChannelToURI(upgradedURI,
                                      nsIChannelEventSink::REDIRECT_PERMANENT |
                                      nsIChannelEventSink::REDIRECT_STS_UPGRADE);
 }
 
 void
 nsHttpChannel::HandleAsyncAPIRedirect()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
-    NS_PRECONDITION(mAPIRedirectToURI, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(mAPIRedirectToURI, "How did that happen?");
 
     if (mSuspendCount) {
         LOG(("Waiting until resume to do async API redirect [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::HandleAsyncAPIRedirect;
         return;
     }
 
     nsresult rv = StartRedirectChannelToURI(mAPIRedirectToURI,
@@ -3003,17 +3003,17 @@ nsHttpChannel::AsyncDoReplaceWithProxy(n
 nsresult
 nsHttpChannel::ContinueDoReplaceWithProxy(nsresult rv)
 {
     AutoRedirectVetoNotifier notifier(this);
 
     if (NS_FAILED(rv))
         return rv;
 
-    NS_PRECONDITION(mRedirectChannel, "No redirect channel?");
+    MOZ_ASSERT(mRedirectChannel, "No redirect channel?");
 
     // Make sure to do this after we received redirect veto answer,
     // i.e. after all sinks had been notified
     mRedirectChannel->SetOriginalURI(mOriginalURI);
 
     // open new channel
     if (mLoadInfo && mLoadInfo->GetEnforceSecurity()) {
         MOZ_ASSERT(!mListenerContext, "mListenerContext should be null!");
@@ -3600,17 +3600,17 @@ nsHttpChannel::ProcessFallback(bool *wai
 nsresult
 nsHttpChannel::ContinueProcessFallback(nsresult rv)
 {
     AutoRedirectVetoNotifier notifier(this);
 
     if (NS_FAILED(rv))
         return rv;
 
-    NS_PRECONDITION(mRedirectChannel, "No redirect channel?");
+    MOZ_ASSERT(mRedirectChannel, "No redirect channel?");
 
     // Make sure to do this after we received redirect veto answer,
     // i.e. after all sinks had been notified
     mRedirectChannel->SetOriginalURI(mOriginalURI);
 
     if (mLoadInfo && mLoadInfo->GetEnforceSecurity()) {
         MOZ_ASSERT(!mListenerContext, "mListenerContext should be null!");
         rv = mRedirectChannel->AsyncOpen2(mListener);
@@ -3655,17 +3655,17 @@ nsHttpChannel::OpenCacheEntry(bool isHtt
     mConcurrentCacheAccess = 0;
 
     mLoadedFromApplicationCache = false;
     mHasQueryString = HasQueryString(mRequestHead.ParsedMethod(), mURI);
 
     LOG(("nsHttpChannel::OpenCacheEntry [this=%p]", this));
 
     // make sure we're not abusing this function
-    NS_PRECONDITION(!mCacheEntry, "cache entry already open");
+    MOZ_ASSERT(!mCacheEntry, "cache entry already open");
 
     if (mRequestHead.IsPost()) {
         // If the post id is already set then this is an attempt to replay
         // a post transaction via the cache.  Otherwise, we need a unique
         // post id for this transaction.
         if (mPostID == 0)
             mPostID = gHttpHandler->GenerateUniqueID();
     }
@@ -3859,17 +3859,17 @@ nsHttpChannel::OpenCacheEntryInternal(bo
 
 bypassCacheEntryOpen:
     if (!mApplicationCacheForWrite || !allowApplicationCache)
         return NS_OK;
 
     // If there is an app cache to write to, open the entry right now in parallel.
 
     // make sure we're not abusing this function
-    NS_PRECONDITION(!mOfflineCacheEntry, "cache entry already open");
+    MOZ_ASSERT(!mOfflineCacheEntry, "cache entry already open");
 
     if (offline) {
         // only put things in the offline cache while online
         return NS_OK;
     }
 
     if (mLoadFlags & INHIBIT_CACHING) {
         // respect demand not to cache
@@ -5688,17 +5688,17 @@ nsHttpChannel::ContinueProcessRedirectio
 {
     AutoRedirectVetoNotifier notifier(this);
 
     LOG(("nsHttpChannel::ContinueProcessRedirection [rv=%" PRIx32 ",this=%p]\n",
          static_cast<uint32_t>(rv), this));
     if (NS_FAILED(rv))
         return rv;
 
-    NS_PRECONDITION(mRedirectChannel, "No redirect channel?");
+    MOZ_ASSERT(mRedirectChannel, "No redirect channel?");
 
     // Make sure to do this after we received redirect veto answer,
     // i.e. after all sinks had been notified
     mRedirectChannel->SetOriginalURI(mOriginalURI);
 
     // XXX we used to talk directly with the script security manager, but that
     // should really be handled by the event sink implementation.
 
@@ -6288,17 +6288,17 @@ nsHttpChannel::BeginConnect()
     }
 
     return BeginConnectContinue();
 }
 
 void
 nsHttpChannel::HandleBeginConnectContinue()
 {
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
     nsresult rv;
 
     if (mSuspendCount) {
         LOG(("Waiting until resume BeginConnect [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::HandleBeginConnectContinue;
         return;
     }
 
@@ -6563,17 +6563,17 @@ nsHttpChannel::SetPriority(int32_t value
 
     return NS_OK;
 }
 
 nsresult
 nsHttpChannel::ContinueBeginConnectWithResult()
 {
     LOG(("nsHttpChannel::ContinueBeginConnectWithResult [this=%p]", this));
-    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
+    MOZ_ASSERT(!mCallOnResume, "How did that happen?");
 
     nsresult rv;
 
     if (mSuspendCount) {
         LOG(("Waiting until resume to do async connect [this=%p]\n", this));
         mCallOnResume = &nsHttpChannel::ContinueBeginConnect;
         rv = NS_OK;
     } else if (mCanceled) {
--- a/netwerk/protocol/http/nsHttpChunkedDecoder.cpp
+++ b/netwerk/protocol/http/nsHttpChunkedDecoder.cpp
@@ -86,18 +86,18 @@ nsHttpChunkedDecoder::HandleChunkedConte
 // nsHttpChunkedDecoder <private>
 //-----------------------------------------------------------------------------
 
 nsresult
 nsHttpChunkedDecoder::ParseChunkRemaining(char *buf,
                                           uint32_t count,
                                           uint32_t *bytesConsumed)
 {
-    NS_PRECONDITION(mChunkRemaining == 0, "chunk remaining should be zero");
-    NS_PRECONDITION(count, "unexpected");
+    MOZ_ASSERT(mChunkRemaining == 0, "chunk remaining should be zero");
+    MOZ_ASSERT(count, "unexpected");
 
     *bytesConsumed = 0;
 
     char *p = static_cast<char *>(memchr(buf, '\n', count));
     if (p) {
         *p = 0;
         count = p - buf; // new length
         *bytesConsumed = count + 1; // length + newline
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -1400,17 +1400,17 @@ nsHttpTransaction::ParseLine(nsACString 
         rv = mResponseHead->ParseHeaderLine(line);
     }
     return rv;
 }
 
 nsresult
 nsHttpTransaction::ParseLineSegment(char *segment, uint32_t len)
 {
-    NS_PRECONDITION(!mHaveAllHeaders, "already have all headers");
+    MOZ_ASSERT(!mHaveAllHeaders, "already have all headers");
 
     if (!mLineBuf.IsEmpty() && mLineBuf.Last() == '\n') {
         // trim off the new line char, and if this segment is
         // not a continuation of the previous or if we haven't
         // parsed the status line yet, then parse the contents
         // of mLineBuf.
         mLineBuf.Truncate(mLineBuf.Length() - 1);
         if (!mHaveStatusLine || (*segment != ' ' && *segment != '\t')) {
@@ -1451,17 +1451,17 @@ nsHttpTransaction::ParseHead(char *buf,
     nsresult rv;
     uint32_t len;
     char *eol;
 
     LOG(("nsHttpTransaction::ParseHead [count=%u]\n", count));
 
     *countRead = 0;
 
-    NS_PRECONDITION(!mHaveAllHeaders, "oops");
+    MOZ_ASSERT(!mHaveAllHeaders, "oops");
 
     // allocate the response head object if necessary
     if (!mResponseHead) {
         mResponseHead = new nsHttpResponseHead();
         if (!mResponseHead)
             return NS_ERROR_OUT_OF_MEMORY;
 
         // report that we have a least some of the response
@@ -2270,17 +2270,17 @@ nsHttpTransaction::CancelPacing(nsresult
 //-----------------------------------------------------------------------------
 
 NS_IMPL_ADDREF(nsHttpTransaction)
 
 NS_IMETHODIMP_(MozExternalRefCountType)
 nsHttpTransaction::Release()
 {
     nsrefcnt count;
-    NS_PRECONDITION(0 != mRefCnt, "dup release");
+    MOZ_ASSERT(0 != mRefCnt, "dup release");
     count = --mRefCnt;
     NS_LOG_RELEASE(this, count, "nsHttpTransaction");
     if (0 == count) {
         mRefCnt = 1; /* stablize */
         // it is essential that the transaction be destroyed on the consumer
         // thread (we could be holding the last reference to our consumer).
         DeleteSelfOnConsumerThread();
         return 0;
--- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp
@@ -22,17 +22,17 @@ using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ADDREF(WebSocketChannelChild)
 
 NS_IMETHODIMP_(MozExternalRefCountType) WebSocketChannelChild::Release()
 {
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   --mRefCnt;
   NS_LOG_RELEASE(this, mRefCnt, "WebSocketChannelChild");
 
   if (mRefCnt == 1) {
     MaybeReleaseIPCObject();
     return mRefCnt;
   }
 
--- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
@@ -655,17 +655,17 @@ WyciwygChannelChild::AsyncOpen(nsIStream
               nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal())),
              "security flags in loadInfo but asyncOpen2() not called");
 
   LOG(("WyciwygChannelChild::AsyncOpen [this=%p]\n", this));
 
   // The only places creating wyciwyg: channels should be
   // HTMLDocument::OpenCommon and session history.  Both should be setting an
   // owner or loadinfo.
-  NS_PRECONDITION(mOwner || mLoadInfo, "Must have a principal");
+  MOZ_ASSERT(mOwner || mLoadInfo, "Must have a principal");
   NS_ENSURE_STATE(mOwner || mLoadInfo);
 
   NS_ENSURE_ARG_POINTER(aListener);
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
 
   mListener = aListener;
   mListenerContext = aContext;
   mIsPending = true;
--- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
@@ -780,17 +780,17 @@ nsWyciwygChannel::ReadFromCache()
   // Pump the cache data downstream
   return mPump->AsyncRead(this, nullptr);
 }
 
 void
 nsWyciwygChannel::WriteCharsetAndSourceToCache(int32_t aSource,
                                                const nsCString& aCharset)
 {
-  NS_PRECONDITION(mCacheEntry, "Better have cache entry!");
+  MOZ_ASSERT(mCacheEntry, "Better have cache entry!");
 
   mCacheEntry->SetMetaDataElement("charset", aCharset.get());
 
   nsAutoCString source;
   source.AppendInt(aSource);
   mCacheEntry->SetMetaDataElement("charset-source", source.get());
 }
 
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -670,17 +670,17 @@ DataChannelConnection::SetEvenOdd()
   mAllocateEven = (dtls->role() == TransportLayerDtls::CLIENT);
 }
 
 bool
 DataChannelConnection::ConnectViaTransportFlow(TransportFlow *aFlow, uint16_t localport, uint16_t remoteport)
 {
   LOG(("Connect DTLS local %u, remote %u", localport, remoteport));
 
-  NS_PRECONDITION(mMasterSocket, "SCTP wasn't initialized before ConnectViaTransportFlow!");
+  MOZ_ASSERT(mMasterSocket, "SCTP wasn't initialized before ConnectViaTransportFlow!");
   if (NS_WARN_IF(!aFlow)) {
     return false;
   }
 
   mTransportFlow = aFlow;
   mLocalPort = localport;
   mRemotePort = remoteport;
   mState = CONNECTING;
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -1396,17 +1396,17 @@ mozTXTToHTMLConv::ScanHTML(const char16_
   ScanHTML(inString, whattodo, outString);
   *_retval = ToNewUnicode(outString);
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 nsresult
 MOZ_NewTXTToHTMLConv(mozTXTToHTMLConv** aConv)
 {
-    NS_PRECONDITION(aConv != nullptr, "null ptr");
+    MOZ_ASSERT(aConv != nullptr, "null ptr");
     if (!aConv)
       return NS_ERROR_NULL_POINTER;
 
     *aConv = new mozTXTToHTMLConv();
     if (!*aConv)
       return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(*aConv);
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -329,17 +329,17 @@ nsFTPDirListingConv::DigestBufferLines(c
     } // end while(eol)
 
     return line;
 }
 
 nsresult
 NS_NewFTPDirListingConv(nsFTPDirListingConv** aFTPDirListingConv)
 {
-    NS_PRECONDITION(aFTPDirListingConv != nullptr, "null ptr");
+    MOZ_ASSERT(aFTPDirListingConv != nullptr, "null ptr");
     if (! aFTPDirListingConv)
         return NS_ERROR_NULL_POINTER;
 
     *aFTPDirListingConv = new nsFTPDirListingConv();
     if (! *aFTPDirListingConv)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(*aFTPDirListingConv);
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -689,17 +689,17 @@ nsHTTPCompressConv::CheckListenerChain()
 }
 
 } // namespace net
 } // namespace mozilla
 
 nsresult
 NS_NewHTTPCompressConv(mozilla::net::nsHTTPCompressConv **aHTTPCompressConv)
 {
-  NS_PRECONDITION(aHTTPCompressConv != nullptr, "null ptr");
+  MOZ_ASSERT(aHTTPCompressConv != nullptr, "null ptr");
   if (!aHTTPCompressConv) {
     return NS_ERROR_NULL_POINTER;
   }
 
   RefPtr<mozilla::net::nsHTTPCompressConv> outVal =
     new mozilla::net::nsHTTPCompressConv();
   if (!outVal) {
     return NS_ERROR_OUT_OF_MEMORY;
--- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp
+++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp
@@ -1089,17 +1089,17 @@ nsMultiMixedConv::ProcessHeader()
     }
 
     return NS_OK;
 }
 
 nsresult
 NS_NewMultiMixedConv(nsMultiMixedConv** aMultiMixedConv)
 {
-    NS_PRECONDITION(aMultiMixedConv != nullptr, "null ptr");
+    MOZ_ASSERT(aMultiMixedConv != nullptr, "null ptr");
     if (! aMultiMixedConv)
         return NS_ERROR_NULL_POINTER;
 
     *aMultiMixedConv = new nsMultiMixedConv();
 
     NS_ADDREF(*aMultiMixedConv);
     return NS_OK;
 }
--- a/netwerk/streamconv/nsStreamConverterService.cpp
+++ b/netwerk/streamconv/nsStreamConverterService.cpp
@@ -523,16 +523,16 @@ nsStreamConverterService::AsyncConvertDa
 
     return rv;
 
 }
 
 nsresult
 NS_NewStreamConv(nsStreamConverterService** aStreamConv)
 {
-    NS_PRECONDITION(aStreamConv != nullptr, "null ptr");
+    MOZ_ASSERT(aStreamConv != nullptr, "null ptr");
     if (!aStreamConv) return NS_ERROR_NULL_POINTER;
 
     *aStreamConv = new nsStreamConverterService();
     NS_ADDREF(*aStreamConv);
 
     return NS_OK;
 }
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -483,25 +483,25 @@ nsHtml5Highlighter::End()
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(eTreeOpStreamEnded);
   FlushOps();
 }
 
 void
 nsHtml5Highlighter::SetBuffer(nsHtml5UTF16Buffer* aBuffer)
 {
-  NS_PRECONDITION(!mBuffer, "Old buffer still here!");
+  MOZ_ASSERT(!mBuffer, "Old buffer still here!");
   mBuffer = aBuffer;
   mCStart = aBuffer->getStart();
 }
 
 void
 nsHtml5Highlighter::DropBuffer(int32_t aPos)
 {
-  NS_PRECONDITION(mBuffer, "No buffer to drop!");
+  MOZ_ASSERT(mBuffer, "No buffer to drop!");
   mPos = aPos;
   FlushChars();
   mBuffer = nullptr;
 }
 
 void
 nsHtml5Highlighter::StartSpan()
 {
@@ -523,27 +523,27 @@ nsHtml5Highlighter::EndSpanOrA()
   FlushChars();
   Pop();
   --mInlinesOpen;
 }
 
 void
 nsHtml5Highlighter::StartCharacters()
 {
-  NS_PRECONDITION(!mInCharacters, "Already in characters!");
+  MOZ_ASSERT(!mInCharacters, "Already in characters!");
   FlushChars();
   Push(nsGkAtoms::span, nullptr, NS_NewHTMLSpanElement);
   mCurrentRun = CurrentNode();
   mInCharacters = true;
 }
 
 void
 nsHtml5Highlighter::EndCharactersAndStartMarkupRun()
 {
-  NS_PRECONDITION(mInCharacters, "Not in characters!");
+  MOZ_ASSERT(mInCharacters, "Not in characters!");
   FlushChars();
   Pop();
   mInCharacters = false;
   // Now start markup run
   StartSpan();
   mCurrentRun = CurrentNode();
 }
 
@@ -670,64 +670,64 @@ nsHtml5Highlighter::AllocateContentHandl
 
 nsIContent**
 nsHtml5Highlighter::CreateElement(
   nsAtom* aName,
   nsHtml5HtmlAttributes* aAttributes,
   nsIContent** aIntendedParent,
   mozilla::dom::HTMLContentCreatorFunction aCreator)
 {
-  NS_PRECONDITION(aName, "Got null name.");
+  MOZ_ASSERT(aName, "Got null name.");
   nsHtml5ContentCreatorFunction creator;
   creator.html = aCreator;
   nsIContent** content = AllocateContentHandle();
   mOpQueue.AppendElement()->Init(kNameSpaceID_XHTML,
                                  aName,
                                  aAttributes,
                                  content,
                                  aIntendedParent,
                                  true,
                                  creator);
   return content;
 }
 
 nsIContent**
 nsHtml5Highlighter::CurrentNode()
 {
-  NS_PRECONDITION(mStack.Length() >= 1, "Must have something on stack.");
+  MOZ_ASSERT(mStack.Length() >= 1, "Must have something on stack.");
   return mStack[mStack.Length() - 1];
 }
 
 void
 nsHtml5Highlighter::Push(nsAtom* aName,
                          nsHtml5HtmlAttributes* aAttributes,
                          mozilla::dom::HTMLContentCreatorFunction aCreator)
 {
-  NS_PRECONDITION(mStack.Length() >= 1, "Pushing without root.");
+  MOZ_ASSERT(mStack.Length() >= 1, "Pushing without root.");
   nsIContent** elt = CreateElement(aName,
                                    aAttributes,
                                    CurrentNode(),
                                    aCreator); // Don't inline below!
   mOpQueue.AppendElement()->Init(eTreeOpAppend, elt, CurrentNode());
   mStack.AppendElement(elt);
 }
 
 void
 nsHtml5Highlighter::Pop()
 {
-  NS_PRECONDITION(mStack.Length() >= 2, "Popping when stack too short.");
+  MOZ_ASSERT(mStack.Length() >= 2, "Popping when stack too short.");
   mStack.RemoveLastElement();
 }
 
 void
 nsHtml5Highlighter::AppendCharacters(const char16_t* aBuffer,
                                      int32_t aStart,
                                      int32_t aLength)
 {
-  NS_PRECONDITION(aBuffer, "Null buffer");
+  MOZ_ASSERT(aBuffer, "Null buffer");
 
   char16_t* bufferCopy = new char16_t[aLength];
   memcpy(bufferCopy, aBuffer + aStart, aLength * sizeof(char16_t));
 
   mOpQueue.AppendElement()->Init(
     eTreeOpAppendText, bufferCopy, aLength, CurrentNode());
 }
 
@@ -769,51 +769,51 @@ nsHtml5Highlighter::AddErrorToCurrentNod
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(CurrentNode(), aMsgId);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId)
 {
-  NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
+  MOZ_ASSERT(mCurrentRun, "Adding error to run without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mCurrentRun, aMsgId);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId, nsAtom* aName)
 {
-  NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
+  MOZ_ASSERT(mCurrentRun, "Adding error to run without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mCurrentRun, aMsgId, aName);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
                                          nsAtom* aName,
                                          nsAtom* aOther)
 {
-  NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
+  MOZ_ASSERT(mCurrentRun, "Adding error to run without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mCurrentRun, aMsgId, aName, aOther);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentAmpersand(const char* aMsgId)
 {
-  NS_PRECONDITION(mAmpersand, "Adding error to ampersand without one!");
+  MOZ_ASSERT(mAmpersand, "Adding error to ampersand without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mAmpersand, aMsgId);
 }
 
 void
 nsHtml5Highlighter::AddErrorToCurrentSlash(const char* aMsgId)
 {
-  NS_PRECONDITION(mSlash, "Adding error to slash without one!");
+  MOZ_ASSERT(mSlash, "Adding error to slash without one!");
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(mSlash, aMsgId);
 }
--- a/parser/html/nsHtml5OwningUTF16Buffer.cpp
+++ b/parser/html/nsHtml5OwningUTF16Buffer.cpp
@@ -73,26 +73,26 @@ nsHtml5OwningUTF16Buffer::AdvanceEnd(int
 }
 
 // Not using macros for AddRef and Release in order to be able to refcount on
 // and create on different threads.
 
 nsrefcnt
 nsHtml5OwningUTF16Buffer::AddRef()
 {
-  NS_PRECONDITION(int32_t(mRefCnt) >= 0, "Illegal refcount.");
+  MOZ_ASSERT(int32_t(mRefCnt) >= 0, "Illegal refcount.");
   ++mRefCnt;
   NS_LOG_ADDREF(this, mRefCnt, "nsHtml5OwningUTF16Buffer", sizeof(*this));
   return mRefCnt;
 }
 
 nsrefcnt
 nsHtml5OwningUTF16Buffer::Release()
 {
-  NS_PRECONDITION(0 != mRefCnt, "Release without AddRef.");
+  MOZ_ASSERT(0 != mRefCnt, "Release without AddRef.");
   --mRefCnt;
   NS_LOG_RELEASE(this, mRefCnt, "nsHtml5OwningUTF16Buffer");
   if (mRefCnt == 0) {
     mRefCnt = 1; /* stabilize */
     delete this;
     return 0;
   }
   return mRefCnt;
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -97,18 +97,18 @@ nsHtml5Parser::SetCommand(eParserCommand
   NS_ASSERTION(aParserCommand == eViewNormal,
                "Parser command was not eViewNormal.");
 }
 
 void
 nsHtml5Parser::SetDocumentCharset(NotNull<const Encoding*> aEncoding,
                                   int32_t aCharsetSource)
 {
-  NS_PRECONDITION(!mExecutor->HasStarted(), "Document charset set too late.");
-  NS_PRECONDITION(GetStreamParser(),
+  MOZ_ASSERT(!mExecutor->HasStarted(), "Document charset set too late.");
+  MOZ_ASSERT(GetStreamParser(),
                   "Setting charset on a script-only parser.");
   GetStreamParser()->SetDocumentCharset(aEncoding, aCharsetSource);
   mExecutor->SetDocumentCharsetAndSource(aEncoding, aCharsetSource);
 }
 
 NS_IMETHODIMP
 nsHtml5Parser::GetChannel(nsIChannel** aChannel)
 {
@@ -182,19 +182,19 @@ nsHtml5Parser::Parse(nsIURI* aURL,
                      nsIRequestObserver* aObserver,
                      void* aKey,      // legacy; ignored
                      nsDTDMode aMode) // legacy; ignored
 {
   /*
    * Do NOT cause WillBuildModel to be called synchronously from here!
    * The document won't be ready for it until OnStartRequest!
    */
-  NS_PRECONDITION(!mExecutor->HasStarted(),
+  MOZ_ASSERT(!mExecutor->HasStarted(),
                   "Tried to start parse without initializing the parser.");
-  NS_PRECONDITION(GetStreamParser(),
+  MOZ_ASSERT(GetStreamParser(),
                   "Can't call this Parse() variant on script-created parser");
   GetStreamParser()->SetObserver(aObserver);
   GetStreamParser()->SetViewSourceTitle(aURL); // In case we're viewing source
   mExecutor->SetStreamParser(GetStreamParser());
   mExecutor->SetParser(this);
   return NS_OK;
 }
 
@@ -578,17 +578,17 @@ void
 nsHtml5Parser::PopDefinedInsertionPoint()
 {
   --mInsertionPointPushLevel;
 }
 
 void
 nsHtml5Parser::MarkAsNotScriptCreated(const char* aCommand)
 {
-  NS_PRECONDITION(!mStreamListener, "Must not call this twice.");
+  MOZ_ASSERT(!mStreamListener, "Must not call this twice.");
   eParserMode mode = NORMAL;
   if (!nsCRT::strcmp(aCommand, "view-source")) {
     mode = VIEW_SOURCE_HTML;
   } else if (!nsCRT::strcmp(aCommand, "view-source-xml")) {
     mode = VIEW_SOURCE_XML;
   } else if (!nsCRT::strcmp(aCommand, "view-source-plain")) {
     mode = VIEW_SOURCE_PLAIN;
   } else if (!nsCRT::strcmp(aCommand, "plain-text")) {
@@ -755,13 +755,13 @@ nsHtml5Parser::InitializeDocWriteParserS
   mTreeBuilder->loadState(aState, &mAtomTable);
   mLastWasCR = false;
   mReturnToStreamParserPermitted = true;
 }
 
 void
 nsHtml5Parser::ContinueAfterFailedCharsetSwitch()
 {
-  NS_PRECONDITION(
+  MOZ_ASSERT(
     GetStreamParser(),
     "Tried to continue after failed charset switch without a stream parser");
   GetStreamParser()->ContinueAfterFailedCharsetSwitch();
 }
--- a/parser/html/nsHtml5Portability.cpp
+++ b/parser/html/nsHtml5Portability.cpp
@@ -84,18 +84,18 @@ nsHtml5Portability::newCharArrayFromStri
   jArray<char16_t, int32_t> arr = jArray<char16_t, int32_t>::newJArray(len);
   string.CopyToBuffer(arr);
   return arr;
 }
 
 nsAtom*
 nsHtml5Portability::newLocalFromLocal(nsAtom* local, nsHtml5AtomTable* interner)
 {
-  NS_PRECONDITION(local, "Atom was null.");
-  NS_PRECONDITION(interner, "Atom table was null");
+  MOZ_ASSERT(local, "Atom was null.");
+  MOZ_ASSERT(interner, "Atom table was null");
   if (!local->IsStatic()) {
     nsAutoString str;
     local->ToString(str);
     local = interner->GetAtom(str);
   }
   return local;
 }
 
--- a/parser/html/nsHtml5SpeculativeLoad.h
+++ b/parser/html/nsHtml5SpeculativeLoad.h
@@ -42,53 +42,53 @@ class nsHtml5SpeculativeLoad
   using NotNull = mozilla::NotNull<T>;
 
 public:
   nsHtml5SpeculativeLoad();
   ~nsHtml5SpeculativeLoad();
 
   inline void InitBase(nsHtml5String aUrl)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadBase;
     aUrl.ToString(mUrlOrSizes);
   }
 
   inline void InitMetaCSP(nsHtml5String aCSP)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadCSP;
     nsString csp; // Not Auto, because using it to hold nsStringBuffer*
     aCSP.ToString(csp);
     mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Assign(
       nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(csp));
   }
 
   inline void InitMetaReferrerPolicy(nsHtml5String aReferrerPolicy)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadMetaReferrer;
     nsString
       referrerPolicy; // Not Auto, because using it to hold nsStringBuffer*
     aReferrerPolicy.ToString(referrerPolicy);
     mReferrerPolicyOrIntegrity.Assign(
       nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(
         referrerPolicy));
   }
 
   inline void InitImage(nsHtml5String aUrl,
                         nsHtml5String aCrossOrigin,
                         nsHtml5String aReferrerPolicy,
                         nsHtml5String aSrcset,
                         nsHtml5String aSizes)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadImage;
     aUrl.ToString(mUrlOrSizes);
     aCrossOrigin.ToString(mCrossOriginOrMedia);
     nsString
       referrerPolicy; // Not Auto, because using it to hold nsStringBuffer*
     aReferrerPolicy.ToString(referrerPolicy);
     mReferrerPolicyOrIntegrity.Assign(
@@ -103,34 +103,34 @@ public:
   // where we use the first valid source, which may be the img. Because we
   // can't determine validity at this point without parsing CSS and getting
   // main thread state, we push preload operations for picture pushed and
   // popped, so that the target of the preload ops can determine what picture
   // and nesting level each source/img from the main preloading code exists
   // at.
   inline void InitOpenPicture()
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadOpenPicture;
   }
 
   inline void InitEndPicture()
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadEndPicture;
   }
 
   inline void InitPictureSource(nsHtml5String aSrcset,
                                 nsHtml5String aSizes,
                                 nsHtml5String aType,
                                 nsHtml5String aMedia)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadPictureSource;
     aSrcset.ToString(mCharsetOrSrcset);
     aSizes.ToString(mUrlOrSizes);
     aType.ToString(
       mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
     aMedia.ToString(mCrossOriginOrMedia);
   }
@@ -140,17 +140,17 @@ public:
                          nsHtml5String aType,
                          nsHtml5String aCrossOrigin,
                          nsHtml5String aIntegrity,
                          bool aParserInHead,
                          bool aAsync,
                          bool aDefer,
                          bool aNoModule)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     if (aNoModule) {
       mOpCode = aParserInHead ? eSpeculativeLoadNoModuleScriptFromHead
                               : eSpeculativeLoadNoModuleScript;
     } else {
       mOpCode =
         aParserInHead ? eSpeculativeLoadScriptFromHead : eSpeculativeLoadScript;
     }
@@ -165,17 +165,17 @@ public:
   }
 
   inline void InitStyle(nsHtml5String aUrl,
                         nsHtml5String aCharset,
                         nsHtml5String aCrossOrigin,
                         nsHtml5String aReferrerPolicy,
                         nsHtml5String aIntegrity)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadStyle;
     aUrl.ToString(mUrlOrSizes);
     aCharset.ToString(mCharsetOrSrcset);
     aCrossOrigin.ToString(mCrossOriginOrMedia);
     aReferrerPolicy.ToString(mReferrerPolicyOrIntegrity);
     aIntegrity.ToString(
       mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
@@ -189,17 +189,17 @@ public:
    * thread-discovered manifest gets loaded via the speculative load queue
    * as opposed to tree operation queue is that the manifest must get
    * processed before any actual speculative loads such as scripts. Thus,
    * manifests seen by the parser thread have to maintain the queue order
    * relative to true speculative loads. See bug 541079.
    */
   inline void InitManifest(nsHtml5String aUrl)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadManifest;
     aUrl.ToString(mUrlOrSizes);
   }
 
   /**
    * "Speculative" charset setting isn't truly speculative. If the charset
    * is set via this operation, we are committed to it unless chardet or
@@ -208,43 +208,43 @@ public:
    * queue as opposed to tree operation queue is that the charset change
    * must get processed before any actual speculative loads such as style
    * sheets. Thus, encoding decisions by the parser thread have to maintain
    * the queue order relative to true speculative loads. See bug 675499.
    */
   inline void InitSetDocumentCharset(NotNull<const Encoding*> aEncoding,
                                      int32_t aCharsetSource)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadSetDocumentCharset;
     mCharsetOrSrcset.~nsString();
     mEncoding = aEncoding;
     mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Assign(
       (char16_t)aCharsetSource);
   }
 
   /**
    * Speculative document mode setting isn't really speculative. Once it
    * happens, we are committed to it. However, this information needs to
    * travel in the speculation queue in order to have this information
    * available before parsing the speculatively loaded style sheets.
    */
   inline void InitSetDocumentMode(nsHtml5DocumentMode aMode)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadSetDocumentMode;
     mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Assign(
       (char16_t)aMode);
   }
 
   inline void InitPreconnect(nsHtml5String aUrl, nsHtml5String aCrossOrigin)
   {
-    NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+    MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
                     "Trying to reinitialize a speculative load!");
     mOpCode = eSpeculativeLoadPreconnect;
     aUrl.ToString(mUrlOrSizes);
     aCrossOrigin.ToString(mCrossOriginOrMedia);
   }
 
   void Perform(nsHtml5TreeOpExecutor* aExecutor);
 
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -881,17 +881,17 @@ public:
   nsCOMPtr<nsIDocShell> mDocShell;
 };
 
 nsresult
 nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
 {
   MOZ_RELEASE_ASSERT(STREAM_NOT_STARTED == mStreamState,
                      "Got OnStartRequest when the stream had already started.");
-  NS_PRECONDITION(
+  MOZ_ASSERT(
     !mExecutor->HasStarted(),
     "Got OnStartRequest at the wrong stage in the executor life cycle.");
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   if (mObserver) {
     mObserver->OnStartRequest(aRequest, aContext);
   }
   mRequest = aRequest;
 
--- a/parser/html/nsHtml5StreamParser.h
+++ b/parser/html/nsHtml5StreamParser.h
@@ -161,17 +161,17 @@ public:
    *  about what charset to load
    *
    *  @param   aEncoding the charset of a document
    *  @param   aCharsetSource the source of the charset
    */
   inline void SetDocumentCharset(NotNull<const Encoding*> aEncoding,
                                  int32_t aSource)
   {
-    NS_PRECONDITION(mStreamState == STREAM_NOT_STARTED,
+    MOZ_ASSERT(mStreamState == STREAM_NOT_STARTED,
                     "SetDocumentCharset called too late.");
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     mEncoding = aEncoding;
     mCharsetSource = aSource;
   }
 
   inline void SetObserver(nsIRequestObserver* aObserver)
   {
--- a/parser/html/nsHtml5StreamParserPtr.h
+++ b/parser/html/nsHtml5StreamParserPtr.h
@@ -146,17 +146,17 @@ public:
      substitutable for a raw pointer. Prefer the implicit use of this operator
      to calling |get()|, except where necessary to resolve ambiguity.
           */
   {
     return get();
   }
   nsHtml5StreamParser* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
   {
-    NS_PRECONDITION(
+    MOZ_ASSERT(
       mRawPtr != 0,
       "You can't dereference a NULL nsHtml5StreamParserPtr with operator->().");
     return get();
   }
   nsHtml5StreamParserPtr* get_address()
   // This is not intended to be used by clients.  See |address_of|
   // below.
   {
@@ -167,17 +167,17 @@ public:
   // below.
   {
     return this;
   }
 
 public:
   nsHtml5StreamParser& operator*() const
   {
-    NS_PRECONDITION(
+    MOZ_ASSERT(
       mRawPtr != 0,
       "You can't dereference a NULL nsHtml5StreamParserPtr with operator*().");
     return *get();
   }
   nsHtml5StreamParser** StartAssignment()
   {
 #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT
     return reinterpret_cast<nsHtml5StreamParser**>(begin_assignment());
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -71,19 +71,19 @@ nsHtml5TreeBuilder::~nsHtml5TreeBuilder(
 
 nsIContentHandle*
 nsHtml5TreeBuilder::createElement(int32_t aNamespace,
                                   nsAtom* aName,
                                   nsHtml5HtmlAttributes* aAttributes,
                                   nsIContentHandle* aIntendedParent,
                                   nsHtml5ContentCreatorFunction aCreator)
 {
-  NS_PRECONDITION(aAttributes, "Got null attributes.");
-  NS_PRECONDITION(aName, "Got null name.");
-  NS_PRECONDITION(aNamespace == kNameSpaceID_XHTML ||
+  MOZ_ASSERT(aAttributes, "Got null attributes.");
+  MOZ_ASSERT(aName, "Got null name.");
+  MOZ_ASSERT(aNamespace == kNameSpaceID_XHTML ||
                     aNamespace == kNameSpaceID_SVG ||
                     aNamespace == kNameSpaceID_MathML,
                   "Bogus namespace.");
 
   if (mBuilder) {
     RefPtr<nsAtom> name = nsHtml5TreeOperation::Reget(aName);
 
     nsIContent* intendedParent =
@@ -480,18 +480,18 @@ nsHtml5TreeBuilder::createAndInsertFoste
   int32_t aNamespace,
   nsAtom* aName,
   nsHtml5HtmlAttributes* aAttributes,
   nsIContentHandle* aFormElement,
   nsIContentHandle* aTable,
   nsIContentHandle* aStackParent,
   nsHtml5ContentCreatorFunction aCreator)
 {
-  NS_PRECONDITION(aTable, "Null table");
-  NS_PRECONDITION(aStackParent, "Null stack parent");
+  MOZ_ASSERT(aTable, "Null table");
+  MOZ_ASSERT(aStackParent, "Null stack parent");
 
   if (mBuilder) {
     // Get the foster parent to use as the intended parent when creating
     // the child element.
     nsIContent* fosterParent = nsHtml5TreeOperation::GetFosterParent(
       static_cast<nsIContent*>(aTable), static_cast<nsIContent*>(aStackParent));
 
     nsIContentHandle* child = createElement(
@@ -518,17 +518,17 @@ nsHtml5TreeBuilder::createAndInsertFoste
   insertFosterParentedChild(child, aTable, aStackParent);
 
   return child;
 }
 
 void
 nsHtml5TreeBuilder::detachFromParent(nsIContentHandle* aElement)
 {
-  NS_PRECONDITION(aElement, "Null element");
+  MOZ_ASSERT(aElement, "Null element");
 
   if (mBuilder) {
     nsHtml5TreeOperation::Detach(static_cast<nsIContent*>(aElement), mBuilder);
     return;
   }
 
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(mozilla::fallible);
   if (MOZ_UNLIKELY(!treeOp)) {
@@ -537,18 +537,18 @@ nsHtml5TreeBuilder::detachFromParent(nsI
   }
   treeOp->Init(eTreeOpDetach, aElement);
 }
 
 void
 nsHtml5TreeBuilder::appendElement(nsIContentHandle* aChild,
                                   nsIContentHandle* aParent)
 {
-  NS_PRECONDITION(aChild, "Null child");
-  NS_PRECONDITION(aParent, "Null parent");
+  MOZ_ASSERT(aChild, "Null child");
+  MOZ_ASSERT(aParent, "Null parent");
   if (deepTreeSurrogateParent) {
     return;
   }
 
   if (mBuilder) {
     nsresult rv =
       nsHtml5TreeOperation::Append(static_cast<nsIContent*>(aChild),
                                    static_cast<nsIContent*>(aParent),
@@ -566,18 +566,18 @@ nsHtml5TreeBuilder::appendElement(nsICon
   }
   treeOp->Init(eTreeOpAppend, aChild, aParent);
 }
 
 void
 nsHtml5TreeBuilder::appendChildrenToNewParent(nsIContentHandle* aOldParent,
                                               nsIContentHandle* aNewParent)
 {
-  NS_PRECONDITION(aOldParent, "Null old parent");
-  NS_PRECONDITION(aNewParent, "Null new parent");
+  MOZ_ASSERT(aOldParent, "Null old parent");
+  MOZ_ASSERT(aNewParent, "Null new parent");
 
   if (mBuilder) {
     nsresult rv = nsHtml5TreeOperation::AppendChildrenToNewParent(
       static_cast<nsIContent*>(aOldParent),
       static_cast<nsIContent*>(aNewParent),
       mBuilder);
     if (NS_FAILED(rv)) {
       MarkAsBrokenAndRequestSuspensionWithBuilder(rv);
@@ -596,19 +596,19 @@ nsHtml5TreeBuilder::appendChildrenToNewP
 void
 nsHtml5TreeBuilder::insertFosterParentedCharacters(
   char16_t* aBuffer,
   int32_t aStart,
   int32_t aLength,
   nsIContentHandle* aTable,
   nsIContentHandle* aStackParent)
 {
-  NS_PRECONDITION(aBuffer, "Null buffer");
-  NS_PRECONDITION(aTable, "Null table");
-  NS_PRECONDITION(aStackParent, "Null stack parent");
+  MOZ_ASSERT(aBuffer, "Null buffer");
+  MOZ_ASSERT(aTable, "Null table");
+  MOZ_ASSERT(aStackParent, "Null stack parent");
   MOZ_ASSERT(!aStart, "aStart must always be zero.");
 
   if (mBuilder) {
     nsresult rv = nsHtml5TreeOperation::FosterParentText(
       static_cast<nsIContent*>(aStackParent),
       aBuffer, // XXX aStart always ignored???
       aLength,
       static_cast<nsIContent*>(aTable),
@@ -642,19 +642,19 @@ nsHtml5TreeBuilder::insertFosterParented
                aTable);
 }
 
 void
 nsHtml5TreeBuilder::insertFosterParentedChild(nsIContentHandle* aChild,
                                               nsIContentHandle* aTable,
                                               nsIContentHandle* aStackParent)
 {
-  NS_PRECONDITION(aChild, "Null child");
-  NS_PRECONDITION(aTable, "Null table");
-  NS_PRECONDITION(aStackParent, "Null stack parent");
+  MOZ_ASSERT(aChild, "Null child");
+  MOZ_ASSERT(aTable, "Null table");
+  MOZ_ASSERT(aStackParent, "Null stack parent");
 
   if (mBuilder) {
     nsresult rv =
       nsHtml5TreeOperation::FosterParent(static_cast<nsIContent*>(aChild),
                                          static_cast<nsIContent*>(aStackParent),
                                          static_cast<nsIContent*>(aTable),
                                          mBuilder);
     if (NS_FAILED(rv)) {
@@ -672,18 +672,18 @@ nsHtml5TreeBuilder::insertFosterParented
 }
 
 void
 nsHtml5TreeBuilder::appendCharacters(nsIContentHandle* aParent,
                                      char16_t* aBuffer,
                                      int32_t aStart,
                                      int32_t aLength)
 {
-  NS_PRECONDITION(aBuffer, "Null buffer");
-  NS_PRECONDITION(aParent, "Null parent");
+  MOZ_ASSERT(aBuffer, "Null buffer");
+  MOZ_ASSERT(aParent, "Null parent");
   MOZ_ASSERT(!aStart, "aStart must always be zero.");
 
   if (mBuilder) {
     nsresult rv = nsHtml5TreeOperation::AppendText(
       aBuffer, // XXX aStart always ignored???
       aLength,
       static_cast<nsIContent*>(deepTreeSurrogateParent ? deepTreeSurrogateParent
                                                        : aParent),
@@ -717,18 +717,18 @@ nsHtml5TreeBuilder::appendCharacters(nsI
 }
 
 void
 nsHtml5TreeBuilder::appendComment(nsIContentHandle* aParent,
                                   char16_t* aBuffer,
                                   int32_t aStart,
                                   int32_t aLength)
 {
-  NS_PRECONDITION(aBuffer, "Null buffer");
-  NS_PRECONDITION(aParent, "Null parent");
+  MOZ_ASSERT(aBuffer, "Null buffer");
+  MOZ_ASSERT(aParent, "Null parent");
   MOZ_ASSERT(!aStart, "aStart must always be zero.");
 
   if (deepTreeSurrogateParent) {
     return;
   }
 
   if (mBuilder) {
     nsresult rv = nsHtml5TreeOperation::AppendComment(
@@ -761,17 +761,17 @@ nsHtml5TreeBuilder::appendComment(nsICon
   treeOp->Init(eTreeOpAppendComment, bufferCopy.release(), aLength, aParent);
 }
 
 void
 nsHtml5TreeBuilder::appendCommentToDocument(char16_t* aBuffer,
                                             int32_t aStart,
                                             int32_t aLength)
 {
-  NS_PRECONDITION(aBuffer, "Null buffer");
+  MOZ_ASSERT(aBuffer, "Null buffer");
   MOZ_ASSERT(!aStart, "aStart must always be zero.");
 
   if (mBuilder) {
     nsresult rv = nsHtml5TreeOperation::AppendCommentToDocument(
       aBuffer, // XXX aStart always ignored???
       aLength,
       mBuilder);
     if (NS_FAILED(rv)) {
@@ -798,18 +798,18 @@ nsHtml5TreeBuilder::appendCommentToDocum
   }
   treeOp->Init(eTreeOpAppendCommentToDocument, bufferCopy.release(), aLength);
 }
 
 void
 nsHtml5TreeBuilder::addAttributesToElement(nsIContentHandle* aElement,
                                            nsHtml5HtmlAttributes* aAttributes)
 {
-  NS_PRECONDITION(aElement, "Null element");
-  NS_PRECONDITION(aAttributes, "Null attributes");
+  MOZ_ASSERT(aElement, "Null element");
+  MOZ_ASSERT(aAttributes, "Null attributes");
 
   if (aAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
     return;
   }
 
   if (mBuilder) {
     MOZ_ASSERT(
       aAttributes == tokenizer->GetAttributes(),
@@ -828,17 +828,17 @@ nsHtml5TreeBuilder::addAttributesToEleme
     return;
   }
   treeOp->Init(aElement, aAttributes);
 }
 
 void
 nsHtml5TreeBuilder::markMalformedIfScript(nsIContentHandle* aElement)
 {
-  NS_PRECONDITION(aElement, "Null element");
+  MOZ_ASSERT(aElement, "Null element");
 
   if (mBuilder) {
     nsHtml5TreeOperation::MarkMalformedIfScript(
       static_cast<nsIContent*>(aElement));
     return;
   }
 
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(mozilla::fallible);
@@ -868,17 +868,17 @@ nsHtml5TreeBuilder::end()
 #endif
 }
 
 void
 nsHtml5TreeBuilder::appendDoctypeToDocument(nsAtom* aName,
                                             nsHtml5String aPublicId,
                                             nsHtml5String aSystemId)
 {
-  NS_PRECONDITION(aName, "Null name");
+  MOZ_ASSERT(aName, "Null name");
   nsString publicId; // Not Auto, because using it to hold nsStringBuffer*
   nsString systemId; // Not Auto, because using it to hold nsStringBuffer*
   aPublicId.ToString(publicId);
   aSystemId.ToString(systemId);
   if (mBuilder) {
     RefPtr<nsAtom> name = nsHtml5TreeOperation::Reget(aName);
     nsresult rv = nsHtml5TreeOperation::AppendDoctypeToDocument(
       name, publicId, systemId, mBuilder);
@@ -1322,18 +1322,18 @@ nsHtml5TreeBuilder::TryToEnableEncodingM
 void
 nsHtml5TreeBuilder::AddSnapshotToScript(nsAHtml5TreeBuilderState* aSnapshot,
                                         int32_t aLine)
 {
   if (MOZ_UNLIKELY(mBuilder)) {
     MOZ_ASSERT_UNREACHABLE("Must never use snapshots with builder.");
     return;
   }
-  NS_PRECONDITION(HasScript(), "No script to add a snapshot to!");
-  NS_PRECONDITION(aSnapshot, "Got null snapshot.");
+  MOZ_ASSERT(HasScript(), "No script to add a snapshot to!");
+  MOZ_ASSERT(aSnapshot, "Got null snapshot.");
   mOpQueue.ElementAt(mOpQueue.Length() - 1).SetSnapshot(aSnapshot, aLine);
 }
 
 void
 nsHtml5TreeBuilder::DropHandles()
 {
   MOZ_ASSERT(!mBuilder, "Must not drop handles with builder.");
   mOldHandles.Clear();
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -751,17 +751,17 @@ nsHtml5TreeOpExecutor::RunScript(nsICont
     // necessary for the parse to continue after complex situations.
     nsHtml5TreeOpExecutor::ContinueInterruptedParsingAsync();
   }
 }
 
 void
 nsHtml5TreeOpExecutor::Start()
 {
-  NS_PRECONDITION(!mStarted, "Tried to start when already started.");
+  MOZ_ASSERT(!mStarted, "Tried to start when already started.");
   mStarted = true;
 }
 
 void
 nsHtml5TreeOpExecutor::NeedsCharsetSwitchTo(NotNull<const Encoding*> aEncoding,
                                             int32_t aSource,
                                             uint32_t aLineNumber)
 {
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -52,18 +52,18 @@ static NS_DEFINE_CID(kFormProcessorCID, 
  * Helper class that opens a notification batch if the current doc
  * is different from the executor doc.
  */
 class MOZ_STACK_CLASS nsHtml5OtherDocUpdate
 {
 public:
   nsHtml5OtherDocUpdate(nsIDocument* aCurrentDoc, nsIDocument* aExecutorDoc)
   {
-    NS_PRECONDITION(aCurrentDoc, "Node has no doc?");
-    NS_PRECONDITION(aExecutorDoc, "Executor has no doc?");
+    MOZ_ASSERT(aCurrentDoc, "Node has no doc?");
+    MOZ_ASSERT(aExecutorDoc, "Executor has no doc?");
     if (MOZ_LIKELY(aCurrentDoc == aExecutorDoc)) {
       mDocument = nullptr;
     } else {
       mDocument = aCurrentDoc;
       aCurrentDoc->BeginUpdate(UPDATE_CONTENT_MODEL);
     }
   }
 
@@ -122,17 +122,17 @@ nsHtml5TreeOperation::~nsHtml5TreeOperat
 }
 
 nsresult
 nsHtml5TreeOperation::AppendTextToTextNode(const char16_t* aBuffer,
                                            uint32_t aLength,
                                            dom::Text* aTextNode,
                                            nsHtml5DocumentBuilder* aBuilder)
 {
-  NS_PRECONDITION(aTextNode, "Got null text node.");
+  MOZ_ASSERT(aTextNode, "Got null text node.");
   MOZ_ASSERT(aBuilder);
   MOZ_ASSERT(aBuilder->IsInDocUpdate());
   uint32_t oldLength = aTextNode->TextLength();
   CharacterDataChangeInfo info = { true, oldLength, oldLength, aLength };
   nsNodeUtils::CharacterDataWillChange(aTextNode, info);
 
   nsresult rv = aTextNode->AppendText(aBuffer, aLength, false);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/parser/html/nsHtml5TreeOperation.h
+++ b/parser/html/nsHtml5TreeOperation.h
@@ -226,48 +226,48 @@ public:
   static void MarkMalformedIfScript(nsIContent* aNode);
 
   nsHtml5TreeOperation();
 
   ~nsHtml5TreeOperation();
 
   inline void Init(eHtml5TreeOperation aOpCode)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
     mOpCode = aOpCode;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode, nsIContentHandle* aNode)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aNode, "Initialized tree op with null node.");
+    MOZ_ASSERT(aNode, "Initialized tree op with null node.");
     mOpCode = aOpCode;
     mOne.node = static_cast<nsIContent**>(aNode);
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    nsIContentHandle* aNode,
                    nsIContentHandle* aParent)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aNode, "Initialized tree op with null node.");
-    NS_PRECONDITION(aParent, "Initialized tree op with null parent.");
+    MOZ_ASSERT(aNode, "Initialized tree op with null node.");
+    MOZ_ASSERT(aParent, "Initialized tree op with null parent.");
     mOpCode = aOpCode;
     mOne.node = static_cast<nsIContent**>(aNode);
     mTwo.node = static_cast<nsIContent**>(aParent);
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    const nsACString& aString,
                    int32_t aInt32)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
 
     int32_t len = aString.Length();
     char* str = new char[len + 1];
     const char* start = aString.BeginReading();
     for (int32_t i = 0; i < len; ++i) {
       str[i] = start[i];
     }
@@ -286,17 +286,17 @@ public:
     Init(aOpCode, aString, aInt32);
     mTwo.integer = aLineNumber;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    NotNull<const Encoding*> aEncoding,
                    int32_t aInt32)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
 
     mOpCode = aOpCode;
     mOne.encoding = aEncoding;
     mFour.integer = aInt32;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
@@ -308,57 +308,58 @@ public:
     mTwo.integer = aLineNumber;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    nsIContentHandle* aNode,
                    nsIContentHandle* aParent,
                    nsIContentHandle* aTable)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aNode, "Initialized tree op with null node.");
-    NS_PRECONDITION(aParent, "Initialized tree op with null parent.");
-    NS_PRECONDITION(aTable, "Initialized tree op with null table.");
+    MOZ_ASSERT(aNode, "Initialized tree op with null node.");
+    MOZ_ASSERT(aParent, "Initialized tree op with null parent.");
+    MOZ_ASSERT(aTable, "Initialized tree op with null table.");
     mOpCode = aOpCode;
     mOne.node = static_cast<nsIContent**>(aNode);
     mTwo.node = static_cast<nsIContent**>(aParent);
     mThree.node = static_cast<nsIContent**>(aTable);
   }
 
   inline void Init(nsHtml5DocumentMode aMode)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
     mOpCode = eTreeOpDocumentMode;
     mOne.mode = aMode;
   }
 
   inline void InitScript(nsIContentHandle* aNode)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aNode, "Initialized tree op with null node.");
+    MOZ_ASSERT(aNode, "Initialized tree op with null node.");
     mOpCode = eTreeOpRunScript;
     mOne.node = static_cast<nsIContent**>(aNode);
     mTwo.state = nullptr;
   }
 
   inline void Init(int32_t aNamespace,
                    nsAtom* aName,
                    nsHtml5HtmlAttributes* aAttributes,
                    nsIContentHandle* aTarget,
                    nsIContentHandle* aIntendedParent,
                    bool aFromNetwork,
                    nsHtml5ContentCreatorFunction aCreator)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aName, "Initialized tree op with null name.");
-    NS_PRECONDITION(aTarget, "Initialized tree op with null target node.");
+    MOZ_ASSERT(aName, "Initialized tree op with null name.");
+    MOZ_ASSERT(aTarget, "Initialized tree op with null target node.");
+
     if (aNamespace == kNameSpaceID_XHTML) {
       mOpCode = aFromNetwork ? eTreeOpCreateHTMLElementNetwork
                              : eTreeOpCreateHTMLElementNotNetwork;
       mFour.htmlCreator = aCreator.html;
     } else if (aNamespace == kNameSpaceID_SVG) {
       mOpCode = aFromNetwork ? eTreeOpCreateSVGElementNetwork
                              : eTreeOpCreateSVGElementNotNetwork;
       mFour.svgCreator = aCreator.svg;
@@ -377,80 +378,80 @@ public:
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    char16_t* aBuffer,
                    int32_t aLength,
                    nsIContentHandle* aStackParent,
                    nsIContentHandle* aTable)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
+    MOZ_ASSERT(aBuffer, "Initialized tree op with null buffer.");
     mOpCode = aOpCode;
     mOne.node = static_cast<nsIContent**>(aStackParent);
     mTwo.unicharPtr = aBuffer;
     mThree.node = static_cast<nsIContent**>(aTable);
     mFour.integer = aLength;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    char16_t* aBuffer,
                    int32_t aLength,
                    nsIContentHandle* aParent)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
+    MOZ_ASSERT(aBuffer, "Initialized tree op with null buffer.");
     mOpCode = aOpCode;
     mOne.node = static_cast<nsIContent**>(aParent);
     mTwo.unicharPtr = aBuffer;
     mFour.integer = aLength;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    char16_t* aBuffer,
                    int32_t aLength)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
+    MOZ_ASSERT(aBuffer, "Initialized tree op with null buffer.");
     mOpCode = aOpCode;
     mTwo.unicharPtr = aBuffer;
     mFour.integer = aLength;
   }
 
   inline void Init(nsIContentHandle* aElement,
                    nsHtml5HtmlAttributes* aAttributes)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aElement, "Initialized tree op with null element.");
+    MOZ_ASSERT(aElement, "Initialized tree op with null element.");
     mOpCode = eTreeOpAddAttributes;
     mOne.node = static_cast<nsIContent**>(aElement);
     mTwo.attributes = aAttributes;
   }
 
   inline void Init(nsAtom* aName,
                    const nsAString& aPublicId,
                    const nsAString& aSystemId)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
     mOpCode = eTreeOpAppendDoctypeToDocument;
     mOne.atom = aName;
     mTwo.stringPair = new nsHtml5TreeOperationStringPair(aPublicId, aSystemId);
   }
 
   inline void Init(nsIContentHandle* aElement,
                    const char* aMsgId,
                    nsAtom* aAtom,
                    nsAtom* aOtherAtom)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
     mOpCode = eTreeOpAddError;
     mOne.node = static_cast<nsIContent**>(aElement);
     mTwo.charPtr = (char*)aMsgId;
     mThree.atom = aAtom;
     mFour.atom = aOtherAtom;
   }
 
@@ -463,90 +464,90 @@ public:
 
   inline void Init(nsIContentHandle* aElement, const char* aMsgId)
   {
     Init(aElement, aMsgId, nullptr, nullptr);
   }
 
   inline void Init(const char* aMsgId, bool aError, int32_t aLineNumber)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
     mOpCode = eTreeOpMaybeComplainAboutCharset;
     mOne.charPtr = const_cast<char*>(aMsgId);
     mTwo.integer = aError;
     mThree.integer = aLineNumber;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode, const nsAString& aString)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
 
     char16_t* str = ToNewUnicode(aString);
     mOpCode = aOpCode;
     mOne.unicharPtr = str;
   }
 
   inline void Init(eHtml5TreeOperation aOpCode,
                    nsIContentHandle* aNode,
                    int32_t aInt)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aNode, "Initialized tree op with null node.");
+    MOZ_ASSERT(aNode, "Initialized tree op with null node.");
     mOpCode = aOpCode;
     mOne.node = static_cast<nsIContent**>(aNode);
     mFour.integer = aInt;
   }
 
   inline void Init(nsresult aRv)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(NS_FAILED(aRv), "Initialized tree op with non-failure.");
+    MOZ_ASSERT(NS_FAILED(aRv), "Initialized tree op with non-failure.");
     mOpCode = eTreeOpMarkAsBroken;
     mOne.result = aRv;
   }
 
   inline void InitAddClass(nsIContentHandle* aNode, const char16_t* aClass)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aNode, "Initialized tree op with null node.");
-    NS_PRECONDITION(aClass, "Initialized tree op with null string.");
+    MOZ_ASSERT(aNode, "Initialized tree op with null node.");
+    MOZ_ASSERT(aClass, "Initialized tree op with null string.");
     // aClass must be a literal string that does not need freeing
     mOpCode = eTreeOpAddClass;
     mOne.node = static_cast<nsIContent**>(aNode);
     mTwo.unicharPtr = (char16_t*)aClass;
   }
 
   inline void InitAddLineNumberId(nsIContentHandle* aNode,
                                   const int32_t aLineNumber)
   {
-    NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
+    MOZ_ASSERT(mOpCode == eTreeOpUninitialized,
                     "Op code must be uninitialized when initializing.");
-    NS_PRECONDITION(aNode, "Initialized tree op with null node.");
-    NS_PRECONDITION(aLineNumber > 0, "Initialized tree op with line number.");
+    MOZ_ASSERT(aNode, "Initialized tree op with null node.");
+    MOZ_ASSERT(aLineNumber > 0, "Initialized tree op with line number.");
     // aClass must be a literal string that does not need freeing
     mOpCode = eTreeOpAddLineNumberId;
     mOne.node = static_cast<nsIContent**>(aNode);
     mFour.integer = aLineNumber;
   }
 
   inline bool IsRunScript() { return mOpCode == eTreeOpRunScript; }
 
   inline bool IsMarkAsBroken() { return mOpCode == eTreeOpMarkAsBroken; }
 
   inline void SetSnapshot(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine)
   {
     NS_ASSERTION(
       IsRunScript(),
       "Setting a snapshot for a tree operation other than eTreeOpRunScript!");
-    NS_PRECONDITION(aSnapshot, "Initialized tree op with null snapshot.");
+    MOZ_ASSERT(aSnapshot, "Initialized tree op with null snapshot.");
     mTwo.state = aSnapshot;
     mFour.integer = aLine;
   }
 
   nsresult Perform(nsHtml5TreeOpExecutor* aBuilder,
                    nsIContent** aScriptElement,
                    bool* aInterrupted,
                    bool* aStreamEnded);
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -864,19 +864,19 @@ void
 nsExpatDriver::ParseBuffer(const char16_t *aBuffer,
                            uint32_t aLength,
                            bool aIsFinal,
                            uint32_t *aConsumed)
 {
   NS_ASSERTION((aBuffer && aLength != 0) || (!aBuffer && aLength == 0), "?");
   NS_ASSERTION(mInternalState != NS_OK || aIsFinal || aBuffer,
                "Useless call, we won't call Expat");
-  NS_PRECONDITION(!BlockedOrInterrupted() || !aBuffer,
+  MOZ_ASSERT(!BlockedOrInterrupted() || !aBuffer,
                   "Non-null buffer when resuming");
-  NS_PRECONDITION(XML_GetCurrentByteIndex(mExpatParser) % sizeof(char16_t) == 0,
+  MOZ_ASSERT(XML_GetCurrentByteIndex(mExpatParser) % sizeof(char16_t) == 0,
                   "Consumed part of a char16_t?");
 
   if (mExpatParser && (mInternalState == NS_OK || BlockedOrInterrupted())) {
     int32_t parserBytesBefore = XML_GetCurrentByteIndex(mExpatParser);
     NS_ASSERTION(parserBytesBefore >= 0, "Unexpected value");
 
     XML_Status status;
     if (BlockedOrInterrupted()) {
--- a/parser/htmlparser/nsParser.cpp
+++ b/parser/htmlparser/nsParser.cpp
@@ -308,17 +308,17 @@ nsParser::SetSinkCharset(NotNull<const E
  *  This method gets called in order to set the content
  *  sink for this parser to dump nodes to.
  *
  *  @param   nsIContentSink interface for node receiver
  */
 NS_IMETHODIMP_(void)
 nsParser::SetContentSink(nsIContentSink* aSink)
 {
-  NS_PRECONDITION(aSink, "sink cannot be null!");
+  MOZ_ASSERT(aSink, "sink cannot be null!");
   mSink = aSink;
 
   if (mSink) {
     mSink->SetParser(this);
     nsCOMPtr<nsIHTMLContentSink> htmlSink = do_QueryInterface(mSink);
     if (htmlSink) {
       mIsAboutBlank = true;
     }
@@ -758,17 +758,17 @@ nsParser::IsScriptCreated()
  */
 NS_IMETHODIMP
 nsParser::Parse(nsIURI* aURL,
                 nsIRequestObserver* aListener,
                 void* aKey,
                 nsDTDMode aMode)
 {
 
-  NS_PRECONDITION(aURL, "Error: Null URL given");
+  MOZ_ASSERT(aURL, "Error: Null URL given");
 
   nsresult result = NS_ERROR_HTMLPARSER_BADURL;
   mObserver = aListener;
 
   if (aURL) {
     nsAutoCString spec;
     nsresult rv = aURL->GetSpec(spec);
     if (rv != NS_OK) {
@@ -1162,19 +1162,20 @@ nsParser::BuildModel()
 
 /*******************************************************************
   These methods are used to talk to the netlib system...
  *******************************************************************/
 
 nsresult
 nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext)
 {
-  NS_PRECONDITION(eNone == mParserContext->mStreamListenerState,
+  MOZ_ASSERT(eNone == mParserContext->mStreamListenerState,
                   "Parser's nsIStreamListener API was not setup "
                   "correctly in constructor.");
+
   if (mObserver) {
     mObserver->OnStartRequest(request, aContext);
   }
   mParserContext->mStreamListenerState = eOnStart;
   mParserContext->mAutoDetectStatus = eUnknownDetect;
   mParserContext->mRequest = request;
 
   NS_ASSERTION(!mParserContext->mPrevContext,
@@ -1373,20 +1374,20 @@ ParserWriteFunc(nsIInputStream* in,
   return result;
 }
 
 nsresult
 nsParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
                           nsIInputStream *pIStream, uint64_t sourceOffset,
                           uint32_t aLength)
 {
-  NS_PRECONDITION((eOnStart == mParserContext->mStreamListenerState ||
+  MOZ_ASSERT((eOnStart == mParserContext->mStreamListenerState ||
                    eOnDataAvail == mParserContext->mStreamListenerState),
             "Error: OnStartRequest() must be called before OnDataAvailable()");
-  NS_PRECONDITION(NS_InputStreamIsBuffered(pIStream),
+  MOZ_ASSERT(NS_InputStreamIsBuffered(pIStream),
                   "Must have a buffered input stream");
 
   nsresult rv = NS_OK;
 
   if (mIsAboutBlank) {
     MOZ_ASSERT(false, "Must not get OnDataAvailable for about:blank");
     // ... but if an extension tries to feed us data for about:blank in a
     // release build, silently ignore the data.
--- a/parser/xml/nsSAXXMLReader.cpp
+++ b/parser/xml/nsSAXXMLReader.cpp
@@ -177,17 +177,17 @@ nsSAXXMLReader::HandleXMLDeclaration(con
 }
 
 NS_IMETHODIMP
 nsSAXXMLReader::ReportError(const char16_t* aErrorText,
                             const char16_t* aSourceText,
                             nsIScriptError *aError,
                             bool *_retval)
 {
-  NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
+  MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!");
   // Normally, the expat driver should report the error.
   *_retval = true;
 
   if (mErrorHandler) {
     nsresult rv = mErrorHandler->FatalError(nsDependentString(aErrorText));
     if (NS_SUCCEEDED(rv)) {
       // The error handler has handled the script error.  Don't log to console.
       *_retval = false;
--- a/rdf/base/nsCompositeDataSource.cpp
+++ b/rdf/base/nsCompositeDataSource.cpp
@@ -157,17 +157,17 @@ CompositeEnumeratorImpl::~CompositeEnume
 
 NS_IMPL_ADDREF(CompositeEnumeratorImpl)
 NS_IMPL_RELEASE(CompositeEnumeratorImpl)
 NS_IMPL_QUERY_INTERFACE(CompositeEnumeratorImpl, nsISimpleEnumerator)
 
 NS_IMETHODIMP
 CompositeEnumeratorImpl::HasMoreElements(bool* aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     // If we've already queued up a next target, then yep, there are
     // more elements.
     if (mResult) {
@@ -568,25 +568,25 @@ CompositeDataSourceImpl::GetSource(nsIRD
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::GetSources(nsIRDFResource* aProperty,
                                     nsIRDFNode* aTarget,
                                     bool aTruthValue,
                                     nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     if (! mAllowNegativeAssertions && ! aTruthValue)
         return(NS_RDF_NO_VALUE);
 
     *aResult = new CompositeAssertionEnumeratorImpl(this, nullptr, aProperty,
                                                     aTarget, aTruthValue,
@@ -601,25 +601,25 @@ CompositeDataSourceImpl::GetSources(nsIR
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::GetTarget(nsIRDFResource* aSource,
                                    nsIRDFResource* aProperty,
                                    bool aTruthValue,
                                    nsIRDFNode** aResult)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     if (! mAllowNegativeAssertions && ! aTruthValue)
         return(NS_RDF_NO_VALUE);
 
     int32_t count = mDataSources.Count();
     for (int32_t i = 0; i < count; ++i) {
@@ -673,25 +673,25 @@ CompositeDataSourceImpl::HasAssertionN(i
 
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::GetTargets(nsIRDFResource* aSource,
                                     nsIRDFResource* aProperty,
                                     bool aTruthValue,
                                     nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     if (! mAllowNegativeAssertions && ! aTruthValue)
         return(NS_RDF_NO_VALUE);
 
     *aResult =
         new CompositeAssertionEnumeratorImpl(this,
@@ -708,25 +708,25 @@ CompositeDataSourceImpl::GetTargets(nsIR
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::Assert(nsIRDFResource* aSource,
                                 nsIRDFResource* aProperty,
                                 nsIRDFNode* aTarget,
                                 bool aTruthValue)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     if (! mAllowNegativeAssertions && ! aTruthValue)
         return(NS_RDF_ASSERTION_REJECTED);
 
     nsresult rv;
 
@@ -748,25 +748,25 @@ CompositeDataSourceImpl::Assert(nsIRDFRe
     return NS_RDF_ASSERTION_REJECTED;
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::Unassert(nsIRDFResource* aSource,
                                   nsIRDFResource* aProperty,
                                   nsIRDFNode* aTarget)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     // Iterate through each of the datasources, starting with "the
     // most local" and moving to "the most remote". If _any_ of the
     // datasources have the assertion, attempt to unassert it.
@@ -814,29 +814,29 @@ CompositeDataSourceImpl::Unassert(nsIRDF
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::Change(nsIRDFResource* aSource,
                                 nsIRDFResource* aProperty,
                                 nsIRDFNode* aOldTarget,
                                 nsIRDFNode* aNewTarget)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aOldTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aOldTarget != nullptr, "null ptr");
     if (! aOldTarget)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aNewTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aNewTarget != nullptr, "null ptr");
     if (! aNewTarget)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     // XXX So we're assuming that a datasource _must_ accept the
     // atomic change; i.e., we can't split it up across two
     // datasources. That sucks.
@@ -858,29 +858,29 @@ CompositeDataSourceImpl::Change(nsIRDFRe
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::Move(nsIRDFResource* aOldSource,
                               nsIRDFResource* aNewSource,
                               nsIRDFResource* aProperty,
                               nsIRDFNode* aTarget)
 {
-    NS_PRECONDITION(aOldSource != nullptr, "null ptr");
+    MOZ_ASSERT(aOldSource != nullptr, "null ptr");
     if (! aOldSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aNewSource != nullptr, "null ptr");
+    MOZ_ASSERT(aNewSource != nullptr, "null ptr");
     if (! aNewSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     // XXX So we're assuming that a datasource _must_ accept the
     // atomic move; i.e., we can't split it up across two
     // datasources. That sucks.
@@ -904,25 +904,25 @@ CompositeDataSourceImpl::Move(nsIRDFReso
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::HasAssertion(nsIRDFResource* aSource,
                                       nsIRDFResource* aProperty,
                                       nsIRDFNode* aTarget,
                                       bool aTruthValue,
                                       bool* aResult)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     if (! mAllowNegativeAssertions && ! aTruthValue)
     {
         *aResult = false;
         return(NS_OK);
     }
@@ -957,30 +957,30 @@ CompositeDataSourceImpl::HasAssertion(ns
     // If we get here, nobody had the assertion at all
     *aResult = false;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::AddObserver(nsIRDFObserver* aObserver)
 {
-    NS_PRECONDITION(aObserver != nullptr, "null ptr");
+    MOZ_ASSERT(aObserver != nullptr, "null ptr");
     if (! aObserver)
         return NS_ERROR_NULL_POINTER;
 
     // XXX ensure uniqueness?
     mObservers.AppendObject(aObserver);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::RemoveObserver(nsIRDFObserver* aObserver)
 {
-    NS_PRECONDITION(aObserver != nullptr, "null ptr");
+    MOZ_ASSERT(aObserver != nullptr, "null ptr");
     if (! aObserver)
         return NS_ERROR_NULL_POINTER;
 
     mObservers.RemoveObject(aObserver);
 
     return NS_OK;
 }
 
@@ -1012,21 +1012,21 @@ CompositeDataSourceImpl::HasArcOut(nsIRD
             return NS_OK;
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::ArcLabelsIn(nsIRDFNode* aTarget, nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     nsISimpleEnumerator* result =
         new CompositeArcsInOutEnumeratorImpl(this, aTarget,
                                              CompositeArcsInOutEnumeratorImpl::eArcsIn,
                                              mAllowNegativeAssertions,
                                              mCoalesceDuplicateArcs);
@@ -1038,21 +1038,21 @@ CompositeDataSourceImpl::ArcLabelsIn(nsI
     *aResult = result;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 CompositeDataSourceImpl::ArcLabelsOut(nsIRDFResource* aSource,
                                       nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     nsISimpleEnumerator* result =
         new CompositeArcsInOutEnumeratorImpl(this, aSource,
                                              CompositeArcsInOutEnumeratorImpl::eArcsOut,
                                              mAllowNegativeAssertions,
                                              mCoalesceDuplicateArcs);
--- a/rdf/base/nsContainerEnumerator.cpp
+++ b/rdf/base/nsContainerEnumerator.cpp
@@ -108,17 +108,17 @@ ContainerEnumeratorImpl::~ContainerEnume
 }
 
 NS_IMPL_ISUPPORTS(ContainerEnumeratorImpl, nsISimpleEnumerator)
 
 
 NS_IMETHODIMP
 ContainerEnumeratorImpl::HasMoreElements(bool* aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     // If we've already queued up a next value, then we know there are more elements.
     if (mResult) {
         *aResult = true;
@@ -230,25 +230,25 @@ ContainerEnumeratorImpl::GetNext(nsISupp
 
 ////////////////////////////////////////////////////////////////////////
 
 nsresult
 NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource,
                           nsIRDFResource* aContainer,
                           nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aContainer != nullptr, "null ptr");
+    MOZ_ASSERT(aContainer != nullptr, "null ptr");
     if (! aContainer)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     ContainerEnumeratorImpl* result = new ContainerEnumeratorImpl(aDataSource, aContainer);
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(result);
--- a/rdf/base/nsDefaultResourceFactory.cpp
+++ b/rdf/base/nsDefaultResourceFactory.cpp
@@ -11,17 +11,17 @@
 
  */
 
 #include "nsRDFResource.h"
 
 nsresult
 NS_NewDefaultResource(nsIRDFResource** aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     nsRDFResource* resource = new nsRDFResource();
     if (! resource)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(resource);
--- a/rdf/base/nsInMemoryDataSource.cpp
+++ b/rdf/base/nsInMemoryDataSource.cpp
@@ -593,17 +593,17 @@ InMemoryArcsEnumeratorImpl::~InMemoryArc
 
 NS_IMPL_ADDREF(InMemoryArcsEnumeratorImpl)
 NS_IMPL_RELEASE(InMemoryArcsEnumeratorImpl)
 NS_IMPL_QUERY_INTERFACE(InMemoryArcsEnumeratorImpl, nsISimpleEnumerator)
 
 NS_IMETHODIMP
 InMemoryArcsEnumeratorImpl::HasMoreElements(bool* aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     if (mCurrent) {
         *aResult = true;
         return NS_OK;
     }
 
@@ -686,17 +686,17 @@ InMemoryArcsEnumeratorImpl::GetNext(nsIS
 
 
 ////////////////////////////////////////////////////////////////////////
 // InMemoryDataSource
 
 nsresult
 NS_NewRDFInMemoryDataSource(nsISupports* aOuter, const nsIID& aIID, void** aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
     *aResult = nullptr;
 
     if (aOuter && !aIID.Equals(NS_GET_IID(nsISupports))) {
         NS_ERROR("aggregation requires nsISupports");
         return NS_ERROR_ILLEGAL_VALUE;
     }
@@ -833,25 +833,25 @@ InMemoryDataSource::GetURI(nsACString& a
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::GetSource(nsIRDFResource* property,
                               nsIRDFNode* target,
                               bool tv,
                               nsIRDFResource** source)
 {
-    NS_PRECONDITION(source != nullptr, "null ptr");
+    MOZ_ASSERT(source != nullptr, "null ptr");
     if (! source)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(property != nullptr, "null ptr");
+    MOZ_ASSERT(property != nullptr, "null ptr");
     if (! property)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(target != nullptr, "null ptr");
+    MOZ_ASSERT(target != nullptr, "null ptr");
     if (! target)
         return NS_ERROR_NULL_POINTER;
 
     for (Assertion* as = GetReverseArcs(target); as; as = as->u.as.mInvNext) {
         if ((property == as->u.as.mProperty) && (tv == as->u.as.mTruthValue)) {
             *source = as->mSource;
             NS_ADDREF(*source);
             return NS_OK;
@@ -862,25 +862,25 @@ InMemoryDataSource::GetSource(nsIRDFReso
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::GetTarget(nsIRDFResource* source,
                               nsIRDFResource* property,
                               bool tv,
                               nsIRDFNode** target)
 {
-    NS_PRECONDITION(source != nullptr, "null ptr");
+    MOZ_ASSERT(source != nullptr, "null ptr");
     if (! source)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(property != nullptr, "null ptr");
+    MOZ_ASSERT(property != nullptr, "null ptr");
     if (! property)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(target != nullptr, "null ptr");
+    MOZ_ASSERT(target != nullptr, "null ptr");
     if (! target)
         return NS_ERROR_NULL_POINTER;
 
     Assertion *as = GetForwardArcs(source);
     if (as && as->mHashEntry) {
         PLDHashEntryHdr* hdr = as->u.hash.mPropertyHash->Search(property);
         Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         while (val) {
@@ -958,25 +958,25 @@ InMemoryDataSource::HasAssertion(nsIRDFR
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::GetSources(nsIRDFResource* aProperty,
                                nsIRDFNode* aTarget,
                                bool aTruthValue,
                                nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     InMemoryAssertionEnumeratorImpl* result =
         new InMemoryAssertionEnumeratorImpl(this, nullptr, aProperty,
                                             aTarget, aTruthValue);
 
     if (! result)
@@ -989,25 +989,25 @@ InMemoryDataSource::GetSources(nsIRDFRes
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::GetTargets(nsIRDFResource* aSource,
                                nsIRDFResource* aProperty,
                                bool aTruthValue,
                                nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     InMemoryAssertionEnumeratorImpl* result =
         new InMemoryAssertionEnumeratorImpl(this, aSource, aProperty,
                                             nullptr, aTruthValue);
 
     if (! result)
@@ -1113,25 +1113,25 @@ InMemoryDataSource::LockedAssert(nsIRDFR
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::Assert(nsIRDFResource* aSource,
                            nsIRDFResource* aProperty,
                            nsIRDFNode* aTarget,
                            bool aTruthValue)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     if (mReadCount) {
         NS_WARNING("Writing to InMemoryDataSource during read\n");
         return NS_RDF_ASSERTION_REJECTED;
     }
 
@@ -1268,25 +1268,25 @@ InMemoryDataSource::LockedUnassert(nsIRD
     return NS_OK;
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::Unassert(nsIRDFResource* aSource,
                              nsIRDFResource* aProperty,
                              nsIRDFNode* aTarget)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     if (mReadCount) {
         NS_WARNING("Writing to InMemoryDataSource during read\n");
         return NS_RDF_ASSERTION_REJECTED;
     }
 
@@ -1313,29 +1313,29 @@ InMemoryDataSource::Unassert(nsIRDFResou
 
 
 NS_IMETHODIMP
 InMemoryDataSource::Change(nsIRDFResource* aSource,
                            nsIRDFResource* aProperty,
                            nsIRDFNode* aOldTarget,
                            nsIRDFNode* aNewTarget)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aOldTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aOldTarget != nullptr, "null ptr");
     if (! aOldTarget)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aNewTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aNewTarget != nullptr, "null ptr");
     if (! aNewTarget)
         return NS_ERROR_NULL_POINTER;
 
     if (mReadCount) {
         NS_WARNING("Writing to InMemoryDataSource during read\n");
         return NS_RDF_ASSERTION_REJECTED;
     }
 
@@ -1368,29 +1368,29 @@ InMemoryDataSource::Change(nsIRDFResourc
 
 
 NS_IMETHODIMP
 InMemoryDataSource::Move(nsIRDFResource* aOldSource,
                          nsIRDFResource* aNewSource,
                          nsIRDFResource* aProperty,
                          nsIRDFNode* aTarget)
 {
-    NS_PRECONDITION(aOldSource != nullptr, "null ptr");
+    MOZ_ASSERT(aOldSource != nullptr, "null ptr");
     if (! aOldSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aNewSource != nullptr, "null ptr");
+    MOZ_ASSERT(aNewSource != nullptr, "null ptr");
     if (! aNewSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     if (mReadCount) {
         NS_WARNING("Writing to InMemoryDataSource during read\n");
         return NS_RDF_ASSERTION_REJECTED;
     }
 
@@ -1420,30 +1420,30 @@ InMemoryDataSource::Move(nsIRDFResource*
 
     return NS_RDF_ASSERTION_ACCEPTED;
 }
 
 
 NS_IMETHODIMP
 InMemoryDataSource::AddObserver(nsIRDFObserver* aObserver)
 {
-    NS_PRECONDITION(aObserver != nullptr, "null ptr");
+    MOZ_ASSERT(aObserver != nullptr, "null ptr");
     if (! aObserver)
         return NS_ERROR_NULL_POINTER;
 
     mObservers.AppendObject(aObserver);
     mNumObservers = mObservers.Count();
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::RemoveObserver(nsIRDFObserver* aObserver)
 {
-    NS_PRECONDITION(aObserver != nullptr, "null ptr");
+    MOZ_ASSERT(aObserver != nullptr, "null ptr");
     if (! aObserver)
         return NS_ERROR_NULL_POINTER;
 
     mObservers.RemoveObject(aObserver);
     // note: use Count() instead of just decrementing
     // in case aObserver wasn't in list, for example
     mNumObservers = mObservers.Count();
 
@@ -1489,17 +1489,17 @@ InMemoryDataSource::HasArcOut(nsIRDFReso
     }
     *result = false;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::ArcLabelsIn(nsIRDFNode* aTarget, nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     InMemoryArcsEnumeratorImpl* result =
         new InMemoryArcsEnumeratorImpl(this, nullptr, aTarget);
 
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -1508,17 +1508,17 @@ InMemoryDataSource::ArcLabelsIn(nsIRDFNo
     *aResult = result;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::ArcLabelsOut(nsIRDFResource* aSource, nsISimpleEnumerator** aResult)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
     InMemoryArcsEnumeratorImpl* result =
         new InMemoryArcsEnumeratorImpl(this, aSource, nullptr);
 
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -1663,25 +1663,25 @@ InMemoryDataSource::SetPropagateChanges(
 
 NS_IMETHODIMP
 InMemoryDataSource::Mark(nsIRDFResource* aSource,
                          nsIRDFResource* aProperty,
                          nsIRDFNode* aTarget,
                          bool aTruthValue,
                          bool* aDidMark)
 {
-    NS_PRECONDITION(aSource != nullptr, "null ptr");
+    MOZ_ASSERT(aSource != nullptr, "null ptr");
     if (! aSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aTarget != nullptr, "null ptr");
+    MOZ_ASSERT(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     Assertion *as = GetForwardArcs(aSource);
     if (as && as->mHashEntry) {
         PLDHashEntryHdr* hdr = as->u.hash.mPropertyHash->Search(aProperty);
         Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         while (val) {
--- a/rdf/base/nsRDFContainer.cpp
+++ b/rdf/base/nsRDFContainer.cpp
@@ -110,21 +110,21 @@ RDFContainerImpl::GetResource(nsIRDFReso
     NS_IF_ADDREF(*_retval);
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFContainerImpl::Init(nsIRDFDataSource *aDataSource, nsIRDFResource *aContainer)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aContainer != nullptr, "null ptr");
+    MOZ_ASSERT(aContainer != nullptr, "null ptr");
     if (! aContainer)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
     bool isContainer;
     rv = gRDFContainerUtils->IsContainer(aDataSource, aContainer, &isContainer);
     if (NS_FAILED(rv)) return rv;
 
@@ -200,17 +200,17 @@ RDFContainerImpl::GetElements(nsISimpleE
 
 
 NS_IMETHODIMP
 RDFContainerImpl::AppendElement(nsIRDFNode *aElement)
 {
     if (!mDataSource || !mContainer)
         return NS_ERROR_NOT_INITIALIZED;
 
-    NS_PRECONDITION(aElement != nullptr, "null ptr");
+    MOZ_ASSERT(aElement != nullptr, "null ptr");
     if (! aElement)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     nsCOMPtr<nsIRDFResource> nextVal;
     rv = GetNextValue(getter_AddRefs(nextVal));
     if (NS_FAILED(rv)) return rv;
@@ -223,17 +223,17 @@ RDFContainerImpl::AppendElement(nsIRDFNo
 
 
 NS_IMETHODIMP
 RDFContainerImpl::RemoveElement(nsIRDFNode *aElement, bool aRenumber)
 {
     if (!mDataSource || !mContainer)
         return NS_ERROR_NOT_INITIALIZED;
 
-    NS_PRECONDITION(aElement != nullptr, "null ptr");
+    MOZ_ASSERT(aElement != nullptr, "null ptr");
     if (! aElement)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     int32_t idx;
     rv = IndexOf(aElement, &idx);
     if (NS_FAILED(rv)) return rv;
@@ -263,21 +263,21 @@ RDFContainerImpl::RemoveElement(nsIRDFNo
 
 
 NS_IMETHODIMP
 RDFContainerImpl::InsertElementAt(nsIRDFNode *aElement, int32_t aIndex, bool aRenumber)
 {
     if (!mDataSource || !mContainer)
         return NS_ERROR_NOT_INITIALIZED;
 
-    NS_PRECONDITION(aElement != nullptr, "null ptr");
+    MOZ_ASSERT(aElement != nullptr, "null ptr");
     if (! aElement)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aIndex >= 1, "illegal value");
+    MOZ_ASSERT(aIndex >= 1, "illegal value");
     if (aIndex < 1)
         return NS_ERROR_ILLEGAL_VALUE;
 
     nsresult rv;
 
     int32_t count;
     rv = GetCount(&count);
     if (NS_FAILED(rv)) return rv;
--- a/rdf/base/nsRDFContainerUtils.cpp
+++ b/rdf/base/nsRDFContainerUtils.cpp
@@ -71,17 +71,17 @@ const char      RDFContainerUtilsImpl::k
 NS_IMPL_ISUPPORTS(RDFContainerUtilsImpl, nsIRDFContainerUtils)
 
 ////////////////////////////////////////////////////////////////////////
 // nsIRDFContainerUtils interface
 
 NS_IMETHODIMP
 RDFContainerUtilsImpl::IsOrdinalProperty(nsIRDFResource *aProperty, bool *_retval)
 {
-    NS_PRECONDITION(aProperty != nullptr, "null ptr");
+    MOZ_ASSERT(aProperty != nullptr, "null ptr");
     if (! aProperty)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     const char	*propertyStr;
     rv = aProperty->GetValueConst( &propertyStr );
     if (NS_FAILED(rv)) return rv;
@@ -111,17 +111,17 @@ RDFContainerUtilsImpl::IsOrdinalProperty
     *_retval = true;
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFContainerUtilsImpl::IndexToOrdinalResource(int32_t aIndex, nsIRDFResource **aOrdinal)
 {
-    NS_PRECONDITION(aIndex > 0, "illegal value");
+    MOZ_ASSERT(aIndex > 0, "illegal value");
     if (aIndex <= 0)
         return NS_ERROR_ILLEGAL_VALUE;
 
     nsAutoCString uri(kRDFNameSpaceURI);
     uri.Append('_');
     uri.AppendInt(aIndex);
 
     nsresult rv = gRDFService->GetResource(uri, aOrdinal);
@@ -130,17 +130,17 @@ RDFContainerUtilsImpl::IndexToOrdinalRes
 
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFContainerUtilsImpl::OrdinalResourceToIndex(nsIRDFResource *aOrdinal, int32_t *aIndex)
 {
-    NS_PRECONDITION(aOrdinal != nullptr, "null ptr");
+    MOZ_ASSERT(aOrdinal != nullptr, "null ptr");
     if (! aOrdinal)
         return NS_ERROR_NULL_POINTER;
 
     const char	*ordinalStr;
     if (NS_FAILED(aOrdinal->GetValueConst( &ordinalStr )))
         return NS_ERROR_FAILURE;
 
     const char* s = ordinalStr;
@@ -172,25 +172,25 @@ RDFContainerUtilsImpl::OrdinalResourceTo
 
     *aIndex = idx;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFContainerUtilsImpl::IsContainer(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(_retval != nullptr, "null ptr");
+    MOZ_ASSERT(_retval != nullptr, "null ptr");
     if (! _retval)
         return NS_ERROR_NULL_POINTER;
 
     if (IsA(aDataSource, aResource, kRDF_Seq) ||
         IsA(aDataSource, aResource, kRDF_Bag) ||
         IsA(aDataSource, aResource, kRDF_Alt)) {
         *_retval = true;
     }
@@ -229,65 +229,65 @@ RDFContainerUtilsImpl::IsEmpty(nsIRDFDat
 
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFContainerUtilsImpl::IsBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(_retval != nullptr, "null ptr");
+    MOZ_ASSERT(_retval != nullptr, "null ptr");
     if (! _retval)
         return NS_ERROR_NULL_POINTER;
 
     *_retval = IsA(aDataSource, aResource, kRDF_Bag);
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFContainerUtilsImpl::IsSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(_retval != nullptr, "null ptr");
+    MOZ_ASSERT(_retval != nullptr, "null ptr");
     if (! _retval)
         return NS_ERROR_NULL_POINTER;
 
     *_retval = IsA(aDataSource, aResource, kRDF_Seq);
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFContainerUtilsImpl::IsAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(_retval != nullptr, "null ptr");
+    MOZ_ASSERT(_retval != nullptr, "null ptr");
     if (! _retval)
         return NS_ERROR_NULL_POINTER;
 
     *_retval = IsA(aDataSource, aResource, kRDF_Alt);
     return NS_OK;
 }
 
 
@@ -360,17 +360,17 @@ RDFContainerUtilsImpl::~RDFContainerUtil
     }
 }
 
 
 
 nsresult
 NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     RDFContainerUtilsImpl* result =
         new RDFContainerUtilsImpl();
 
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -379,23 +379,23 @@ NS_NewRDFContainerUtils(nsIRDFContainerU
     *aResult = result;
     return NS_OK;
 }
 
 
 nsresult
 RDFContainerUtilsImpl::MakeContainer(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType, nsIRDFContainer** aResult)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)	return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)	return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aType != nullptr, "null ptr");
+    MOZ_ASSERT(aType != nullptr, "null ptr");
     if (! aType)	return NS_ERROR_NULL_POINTER;
 
     if (aResult)	*aResult = nullptr;
 
     nsresult rv;
 
     // Check to see if somebody has already turned it into a container; if so
     // don't try to do it again.
--- a/rdf/base/nsRDFContentSink.cpp
+++ b/rdf/base/nsRDFContentSink.cpp
@@ -320,17 +320,17 @@ RDFContentSinkImpl::~RDFContentSinkImpl(
 // nsISupports interface
 
 NS_IMPL_ADDREF(RDFContentSinkImpl)
 NS_IMPL_RELEASE(RDFContentSinkImpl)
 
 NS_IMETHODIMP
 RDFContentSinkImpl::QueryInterface(REFNSIID iid, void** result)
 {
-    NS_PRECONDITION(result, "null ptr");
+    MOZ_ASSERT(result, "null ptr");
     if (! result)
         return NS_ERROR_NULL_POINTER;
 
     NS_DEFINE_IID(kIContentSinkIID,    NS_ICONTENT_SINK_IID);
     NS_DEFINE_IID(kIExpatSinkIID,      NS_IEXPATSINK_IID);
     NS_DEFINE_IID(kISupportsIID,       NS_ISUPPORTS_IID);
     NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID);
     NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
@@ -491,17 +491,17 @@ RDFContentSinkImpl::HandleXMLDeclaration
 }
 
 NS_IMETHODIMP
 RDFContentSinkImpl::ReportError(const char16_t* aErrorText,
                                 const char16_t* aSourceText,
                                 nsIScriptError *aError,
                                 bool *_retval)
 {
-  NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
+  MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!");
 
   // The expat driver should report the error.
   *_retval = true;
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////
 // nsIContentSink interface
@@ -564,29 +564,29 @@ RDFContentSinkImpl::SetParser(nsParserBa
 }
 
 ////////////////////////////////////////////////////////////////////////
 // nsIRDFContentSink interface
 
 NS_IMETHODIMP
 RDFContentSinkImpl::Init(nsIURI* aURL)
 {
-    NS_PRECONDITION(aURL != nullptr, "null ptr");
+    MOZ_ASSERT(aURL != nullptr, "null ptr");
     if (! aURL)
         return NS_ERROR_NULL_POINTER;
 
     mDocumentURL = aURL;
     mState = eRDFContentSinkState_InProlog;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFContentSinkImpl::SetDataSource(nsIRDFDataSource* aDataSource)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "SetDataSource null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "SetDataSource null ptr");
     mDataSource = aDataSource;
     NS_ASSERTION(mDataSource != nullptr,"Couldn't QI RDF DataSource");
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFContentSinkImpl::GetDataSource(nsIRDFDataSource*& aDataSource)
@@ -1425,17 +1425,17 @@ RDFContentSinkImpl::PopContext(nsIRDFRes
 }
 
 
 ////////////////////////////////////////////////////////////////////////
 
 nsresult
 NS_NewRDFContentSink(nsIRDFContentSink** aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     RDFContentSinkImpl* sink = new RDFContentSinkImpl();
     if (! sink)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(sink);
--- a/rdf/base/nsRDFResource.cpp
+++ b/rdf/base/nsRDFResource.cpp
@@ -45,17 +45,17 @@ nsRDFResource::~nsRDFResource(void)
 NS_IMPL_ISUPPORTS(nsRDFResource, nsIRDFResource, nsIRDFNode)
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIRDFNode methods:
 
 NS_IMETHODIMP
 nsRDFResource::EqualsNode(nsIRDFNode* aNode, bool* aResult)
 {
-    NS_PRECONDITION(aNode != nullptr, "null ptr");
+    MOZ_ASSERT(aNode != nullptr, "null ptr");
     if (! aNode)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
     nsIRDFResource* resource;
     rv = aNode->QueryInterface(NS_GET_IID(nsIRDFResource), (void**)&resource);
     if (NS_SUCCEEDED(rv)) {
         *aResult = (static_cast<nsIRDFResource*>(this) == resource);
@@ -71,17 +71,17 @@ nsRDFResource::EqualsNode(nsIRDFNode* aN
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIRDFResource methods:
 
 NS_IMETHODIMP
 nsRDFResource::Init(const char* aURI)
 {
-    NS_PRECONDITION(aURI != nullptr, "null ptr");
+    MOZ_ASSERT(aURI != nullptr, "null ptr");
     if (! aURI)
         return NS_ERROR_NULL_POINTER;
 
     mURI = aURI;
 
     if (gRDFServiceRefCnt++ == 0) {
         nsresult rv = CallGetService(kRDFServiceCID, &gRDFService);
         if (NS_FAILED(rv)) return rv;
@@ -116,30 +116,30 @@ nsRDFResource::GetValueConst(const char*
 {
     *aURI = mURI.get();
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsRDFResource::EqualsString(const char* aURI, bool* aResult)
 {
-    NS_PRECONDITION(aURI != nullptr, "null ptr");
+    MOZ_ASSERT(aURI != nullptr, "null ptr");
     if (! aURI)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aResult, "null ptr");
+    MOZ_ASSERT(aResult, "null ptr");
 
     *aResult = mURI.Equals(aURI);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsRDFResource::GetDelegate(const char* aKey, REFNSIID aIID, void** aResult)
 {
-    NS_PRECONDITION(aKey != nullptr, "null ptr");
+    MOZ_ASSERT(aKey != nullptr, "null ptr");
     if (! aKey)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
     *aResult = nullptr;
 
     DelegateEntry* entry = mDelegates;
     while (entry) {
@@ -188,17 +188,17 @@ nsRDFResource::GetDelegate(const char* a
     mDelegates = entry;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsRDFResource::ReleaseDelegate(const char* aKey)
 {
-    NS_PRECONDITION(aKey != nullptr, "null ptr");
+    MOZ_ASSERT(aKey != nullptr, "null ptr");
     if (! aKey)
         return NS_ERROR_NULL_POINTER;
 
     DelegateEntry* entry = mDelegates;
     DelegateEntry** link = &mDelegates;
 
     while (entry) {
         if (entry->mKey.Equals(aKey)) {
--- a/rdf/base/nsRDFService.cpp
+++ b/rdf/base/nsRDFService.cpp
@@ -799,18 +799,18 @@ IsLegalSchemeCharacter(const char aChar)
     return bool((mask & bit) != 0);
 }
 
 
 NS_IMETHODIMP
 RDFServiceImpl::GetResource(const nsACString& aURI, nsIRDFResource** aResource)
 {
     // Sanity checks
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
-    NS_PRECONDITION(!aURI.IsEmpty(), "URI is empty");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(!aURI.IsEmpty(), "URI is empty");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
     if (aURI.IsEmpty())
         return NS_ERROR_INVALID_ARG;
 
     const nsCString& flatURI = PromiseFlatCString(aURI);
     MOZ_LOG(gLog, LogLevel::Debug, ("rdfserv get-resource %s", flatURI.get()));
 
@@ -970,21 +970,21 @@ static int32_t kShift = 6;
 
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFServiceImpl::GetLiteral(const char16_t* aValue, nsIRDFLiteral** aLiteral)
 {
-    NS_PRECONDITION(aValue != nullptr, "null ptr");
+    MOZ_ASSERT(aValue != nullptr, "null ptr");
     if (! aValue)
         return NS_ERROR_NULL_POINTER;
 
-    NS_PRECONDITION(aLiteral != nullptr, "null ptr");
+    MOZ_ASSERT(aLiteral != nullptr, "null ptr");
     if (! aLiteral)
         return NS_ERROR_NULL_POINTER;
 
     // See if we have one already cached
     PLDHashEntryHdr *hdr = mLiterals.Search(aValue);
     if (hdr) {
         LiteralHashEntry *entry = static_cast<LiteralHashEntry *>(hdr);
         NS_ADDREF(*aLiteral = entry->mLiteral);
@@ -1052,17 +1052,17 @@ RDFServiceImpl::GetBlobLiteral(const uin
 
     NS_ADDREF(*aResult = result);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::IsAnonymousResource(nsIRDFResource* aResource, bool* _result)
 {
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     const char* uri;
     rv = aResource->GetValueConst(&uri);
     if (NS_FAILED(rv)) return rv;
@@ -1080,17 +1080,17 @@ RDFServiceImpl::IsAnonymousResource(nsIR
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::RegisterResource(nsIRDFResource* aResource, bool aReplace)
 {
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     const char* uri;
     rv = aResource->GetValueConst(&uri);
     NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get URI from resource");
@@ -1135,17 +1135,17 @@ RDFServiceImpl::RegisterResource(nsIRDFR
     entry->mKey = uri;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::UnregisterResource(nsIRDFResource* aResource)
 {
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
+    MOZ_ASSERT(aResource != nullptr, "null ptr");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     const char* uri;
     rv = aResource->GetValueConst(&uri);
     if (NS_FAILED(rv)) return rv;
@@ -1165,17 +1165,17 @@ RDFServiceImpl::UnregisterResource(nsIRD
 
     mResources.Remove(uri);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource, bool aReplace)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     nsAutoCString uri;
     rv = aDataSource->GetURI(uri);
     if (NS_FAILED(rv)) return rv;
@@ -1214,17 +1214,17 @@ RDFServiceImpl::RegisterDataSource(nsIRD
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::UnregisterDataSource(nsIRDFDataSource* aDataSource)
 {
-    NS_PRECONDITION(aDataSource != nullptr, "null ptr");
+    MOZ_ASSERT(aDataSource != nullptr, "null ptr");
     if (! aDataSource)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     nsAutoCString uri;
     rv = aDataSource->GetURI(uri);
     if (NS_FAILED(rv)) return rv;
@@ -1268,17 +1268,17 @@ RDFServiceImpl::GetDataSourceBlocking(co
 {
     // Use GetDataSource and ask for a blocking Refresh.
     return GetDataSource( aURI, true, aDataSource );
 }
 
 nsresult
 RDFServiceImpl::GetDataSource(const char* aURI, bool aBlock, nsIRDFDataSource** aDataSource)
 {
-    NS_PRECONDITION(aURI != nullptr, "null ptr");
+    MOZ_ASSERT(aURI != nullptr, "null ptr");
     if (! aURI)
         return NS_ERROR_NULL_POINTER;
 
     nsresult rv;
 
     // Attempt to canonify the URI before we look for it in the
     // cache. We won't bother doing this on `rdf:' URIs to avoid
     // useless (and expensive) protocol handler lookups.
--- a/rdf/base/nsRDFXMLDataSource.cpp
+++ b/rdf/base/nsRDFXMLDataSource.cpp
@@ -363,17 +363,17 @@ static const char kFileURIPrefix[] = "fi
 static const char kResourceURIPrefix[] = "resource:";
 
 
 //----------------------------------------------------------------------
 
 nsresult
 NS_NewRDFXMLDataSource(nsIRDFDataSource** aResult)
 {
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     RDFXMLDataSourceImpl* datasource = new RDFXMLDataSourceImpl();
     if (! datasource)
         return NS_ERROR_OUT_OF_MEMORY;
 
     nsresult rv;
@@ -567,17 +567,17 @@ RDFXMLDataSourceImpl::GetLoaded(bool* _r
 {
     *_result = (mLoadState == eLoadState_Loaded);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFXMLDataSourceImpl::Init(const char* uri)
 {
-    NS_PRECONDITION(mInner != nullptr, "not initialized");
+    MOZ_ASSERT(mInner != nullptr, "not initialized");
     if (! mInner)
         return NS_ERROR_OUT_OF_MEMORY;
 
     nsresult rv;
 
     rv = NS_NewURI(getter_AddRefs(mURL), nsDependentCString(uri));
     if (NS_FAILED(rv)) return rv;
 
@@ -780,17 +780,17 @@ RDFXMLDataSourceImpl::rdfXMLFlush(nsIURI
 
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 RDFXMLDataSourceImpl::FlushTo(const char *aURI)
 {
-    NS_PRECONDITION(aURI != nullptr, "not initialized");
+    MOZ_ASSERT(aURI != nullptr, "not initialized");
     if (!aURI)
         return NS_ERROR_NULL_POINTER;
 
     // XXX this is a hack: any "file:" URI is considered writable. All
     // others are considered read-only.
     if ((PL_strncmp(aURI, kFileURIPrefix, sizeof(kFileURIPrefix) - 1) != 0) &&
         (PL_strncmp(aURI, kResourceURIPrefix, sizeof(kResourceURIPrefix) - 1) != 0))
     {
@@ -858,17 +858,17 @@ RDFXMLDataSourceImpl::SetReadOnly(bool a
 // This code is copied from nsSameOriginChecker::OnChannelRedirect. See
 // bug 475940 on providing this code in a shared location.
 NS_IMETHODIMP
 RDFXMLDataSourceImpl::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
                                              nsIChannel *aNewChannel,
                                              uint32_t aFlags,
                                              nsIAsyncVerifyRedirectCallback *cb)
 {
-    NS_PRECONDITION(aNewChannel, "Redirecting to null channel?");
+    MOZ_ASSERT(aNewChannel, "Redirecting to null channel?");
 
     nsresult rv;
     nsCOMPtr<nsIScriptSecurityManager> secMan =
         do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIPrincipal> oldPrincipal;
     secMan->GetChannelResultPrincipal(aOldChannel, getter_AddRefs(oldPrincipal));
--- a/rdf/datasource/nsLocalStore.cpp
+++ b/rdf/datasource/nsLocalStore.cpp
@@ -204,21 +204,21 @@ LocalStoreImpl::~LocalStoreImpl(void)
     if (mRDFService)
         mRDFService->UnregisterDataSource(this);
 }
 
 
 nsresult
 NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult)
 {
-    NS_PRECONDITION(aOuter == nullptr, "no aggregation");
+    MOZ_ASSERT(aOuter == nullptr, "no aggregation");
     if (aOuter)
         return NS_ERROR_NO_AGGREGATION;
 
-    NS_PRECONDITION(aResult != nullptr, "null ptr");
+    MOZ_ASSERT(aResult != nullptr, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     LocalStoreImpl* impl = new LocalStoreImpl();
     if (! impl)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(impl);
--- a/storage/StorageBaseStatementInternal.cpp
+++ b/storage/StorageBaseStatementInternal.cpp
@@ -83,17 +83,17 @@ public:
    *        should be forgotten.
    */
   LastDitchSqliteStatementFinalizer(RefPtr<Connection>& aConnection,
                                     sqlite3_stmt* aStatement)
     : Runnable("storage::LastDitchSqliteStatementFinalizer")
     , mConnection(aConnection)
     , mAsyncStatement(aStatement)
   {
-    NS_PRECONDITION(aConnection, "You must provide a Connection");
+    MOZ_ASSERT(aConnection, "You must provide a Connection");
   }
 
   NS_IMETHOD Run() override
   {
     (void)::sqlite3_finalize(mAsyncStatement);
     mAsyncStatement = nullptr;
 
     nsCOMPtr<nsIThread> target(mConnection->threadOpenedOn);
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -565,17 +565,17 @@ NS_INTERFACE_MAP_BEGIN(Connection)
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(mozIStorageConnection, !mAsyncOnly)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozIStorageConnection)
 NS_INTERFACE_MAP_END
 
 // This is identical to what NS_IMPL_RELEASE provides, but with the
 // extra |1 == count| case.
 NS_IMETHODIMP_(MozExternalRefCountType) Connection::Release(void)
 {
-  NS_PRECONDITION(0 != mRefCnt, "dup release");
+  MOZ_ASSERT(0 != mRefCnt, "dup release");
   nsrefcnt count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "Connection");
   if (1 == count) {
     // If the refcount went to 1, the single reference must be from
     // gService->mConnections (in class |Service|).  And the code calling
     // Release is either:
     // - The "user" code that had created the connection, releasing on any
     //   thread.
--- a/storage/mozStorageStatementData.h
+++ b/storage/mozStorageStatementData.h
@@ -29,24 +29,24 @@ class StatementData
 public:
   StatementData(sqlite3_stmt *aStatement,
                 already_AddRefed<BindingParamsArray> aParamsArray,
                 StorageBaseStatementInternal *aStatementOwner)
   : mStatement(aStatement)
   , mParamsArray(aParamsArray)
   , mStatementOwner(aStatementOwner)
   {
-    NS_PRECONDITION(mStatementOwner, "Must have a statement owner!");
+    MOZ_ASSERT(mStatementOwner, "Must have a statement owner!");
   }
   StatementData(const StatementData &aSource)
   : mStatement(aSource.mStatement)
   , mParamsArray(aSource.mParamsArray)
   , mStatementOwner(aSource.mStatementOwner)
   {
-    NS_PRECONDITION(mStatementOwner, "Must have a statement owner!");
+    MOZ_ASSERT(mStatementOwner, "Must have a statement owner!");
   }
   StatementData()
   : mStatement(nullptr)
   {
   }
   ~StatementData()
   {
     // We need to ensure that mParamsArray is released on the main thread,
@@ -73,17 +73,17 @@ public:
   operator BindingParamsArray *() const { return mParamsArray; }
 
   /**
    * NULLs out our sqlite3_stmt (it is held by the owner) after reseting it and
    * clear all bindings to it.  This is expected to occur on the async thread.
    */
   inline void reset()
   {
-    NS_PRECONDITION(mStatementOwner, "Must have a statement owner!");
+    MOZ_ASSERT(mStatementOwner, "Must have a statement owner!");
     // In the AsyncStatement case we may never have populated mStatement if the
     // AsyncExecuteStatements got canceled or a failure occurred in constructing
     // the statement.
     if (mStatement) {
       (void)::sqlite3_reset(mStatement);
       (void)::sqlite3_clear_bindings(mStatement);
       mStatement = nullptr;
     }
--- a/toolkit/components/browser/nsWebBrowserContentPolicy.cpp
+++ b/toolkit/components/browser/nsWebBrowserContentPolicy.cpp
@@ -21,17 +21,17 @@ nsWebBrowserContentPolicy::~nsWebBrowser
 NS_IMPL_ISUPPORTS(nsWebBrowserContentPolicy, nsIContentPolicy)
 
 NS_IMETHODIMP
 nsWebBrowserContentPolicy::ShouldLoad(nsIURI* aContentLocation,
                                       nsILoadInfo* aLoadInfo,
                                       const nsACString& aMimeGuess,
                                       int16_t* aShouldLoad)
 {
-  NS_PRECONDITION(aShouldLoad, "Null out param");
+  MOZ_ASSERT(aShouldLoad, "Null out param");
 
   uint32_t aContentType = aLoadInfo->GetExternalContentPolicyType();
   nsCOMPtr<nsISupports> aRequestingContext = aLoadInfo->GetLoadingContext();
 
   MOZ_ASSERT(aContentType == nsContentUtils::InternalContentPolicyTypeToExternal(aContentType),
              "We should only see external content policy types here.");
 
   *aShouldLoad = nsIContentPolicy::ACCEPT;
@@ -73,17 +73,17 @@ nsWebBrowserContentPolicy::ShouldLoad(ns
 }
 
 NS_IMETHODIMP
 nsWebBrowserContentPolicy::ShouldProcess(nsIURI* aContentLocation,
                                          nsILoadInfo* aLoadInfo,
                                          const nsACString& aMimeGuess,
                                          int16_t* aShouldProcess)
 {
-  NS_PRECONDITION(aShouldProcess, "Null out param");
+  MOZ_ASSERT(aShouldProcess, "Null out param");
 
   uint32_t aContentType = aLoadInfo->GetExternalContentPolicyType();
   nsCOMPtr<nsISupports> aRequestingContext = aLoadInfo->GetLoadingContext();
 
   MOZ_ASSERT(aContentType == nsContentUtils::InternalContentPolicyTypeToExternal(aContentType),
              "We should only see external content policy types here.");
 
   *aShouldProcess = nsIContentPolicy::ACCEPT;
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -589,17 +589,17 @@ class VisitedQuery final : public AsyncS
                            public mozIStorageCompletionCallback
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   static nsresult Start(nsIURI* aURI,
                         mozIVisitedStatusCallback* aCallback=nullptr)
   {
-    NS_PRECONDITION(aURI, "Null URI");
+    MOZ_ASSERT(aURI, "Null URI");
 
     // If we are a content process, always remote the request to the
     // parent process.
     if (XRE_IsContentProcess()) {
       URIParams uri;
       SerializeURI(aURI, uri);
 
       mozilla::dom::ContentChild* cpc =
@@ -2873,17 +2873,17 @@ History::VisitURI(nsIURI* aURI,
 
 NS_IMETHODIMP
 History::RegisterVisitedCallback(nsIURI* aURI,
                                  Link* aLink)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ASSERTION(aURI, "Must pass a non-null URI!");
   if (XRE_IsContentProcess()) {
-    NS_PRECONDITION(aLink, "Must pass a non-null Link!");
+    MOZ_ASSERT(aLink, "Must pass a non-null Link!");
   }
 
   // Obtain our array of observers for this URI.
 #ifdef DEBUG
   bool keyAlreadyExists = !!mObservers.GetEntry(aURI);
 #endif
   KeyClass* key = mObservers.PutEntry(aURI);
   NS_ENSURE_TRUE(key, NS_ERROR_OUT_OF_MEMORY);
--- a/toolkit/components/places/PlaceInfo.cpp
+++ b/toolkit/components/places/PlaceInfo.cpp
@@ -23,34 +23,34 @@ PlaceInfo::PlaceInfo(int64_t aId,
                      int64_t aFrecency)
 : mId(aId)
 , mGUID(aGUID)
 , mURI(aURI)
 , mTitle(aTitle)
 , mFrecency(aFrecency)
 , mVisitsAvailable(false)
 {
-  NS_PRECONDITION(mURI, "Must provide a non-null uri!");
+  MOZ_ASSERT(mURI, "Must provide a non-null uri!");
 }
 
 PlaceInfo::PlaceInfo(int64_t aId,
                      const nsCString& aGUID,
                      already_AddRefed<nsIURI> aURI,
                      const nsString& aTitle,
                      int64_t aFrecency,
                      const VisitsArray& aVisits)
 : mId(aId)
 , mGUID(aGUID)
 , mURI(aURI)
 , mTitle(aTitle)
 , mFrecency(aFrecency)
 , mVisits(aVisits)
 , mVisitsAvailable(true)
 {
-  NS_PRECONDITION(mURI, "Must provide a non-null uri!");
+  MOZ_ASSERT(mURI, "Must provide a non-null uri!");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// mozIPlaceInfo
 
 NS_IMETHODIMP
 PlaceInfo::GetPlaceId(int64_t* _placeId)
 {
--- a/toolkit/components/places/SQLFunctions.cpp
+++ b/toolkit/components/places/SQLFunctions.cpp
@@ -180,17 +180,17 @@ namespace {
   static
   bool
   findInString(const nsDependentCSubstring &aToken,
                const nsACString &aSourceString,
                FindInStringBehavior aBehavior)
   {
     // GetLowerUTF8Codepoint assumes that there's at least one byte in
     // the string, so don't pass an empty token here.
-    NS_PRECONDITION(!aToken.IsEmpty(), "Don't search for an empty token!");
+    MOZ_ASSERT(!aToken.IsEmpty(), "Don't search for an empty token!");
 
     // We cannot match anything if there is nothing to search.
     if (aSourceString.IsEmpty()) {
       return false;
     }
 
     const_char_iterator tokenStart(aToken.BeginReading()),
                         tokenEnd(aToken.EndReading()),
@@ -350,17 +350,17 @@ namespace places {
     return findInString(aToken, aSourceString, eFindOnBoundary);
   }
 
   /* static */
   bool
   MatchAutoCompleteFunction::findBeginning(const nsDependentCSubstring &aToken,
                                            const nsACString &aSourceString)
   {
-    NS_PRECONDITION(!aToken.IsEmpty(), "Don't search for an empty token!");
+    MOZ_ASSERT(!aToken.IsEmpty(), "Don't search for an empty token!");
 
     // We can't use StringBeginsWith here, unfortunately.  Although it will
     // happily take a case-insensitive UTF8 comparator, it eventually calls
     // nsACString::Equals, which checks that the two strings contain the same
     // number of bytes before calling the comparator.  Two characters may be
     // case-insensitively equal while taking up different numbers of bytes, so
     // this is not what we want.
 
@@ -389,17 +389,17 @@ namespace places {
   }
 
   /* static */
   bool
   MatchAutoCompleteFunction::findBeginningCaseSensitive(
     const nsDependentCSubstring &aToken,
     const nsACString &aSourceString)
   {
-    NS_PRECONDITION(!aToken.IsEmpty(), "Don't search for an empty token!");
+    MOZ_ASSERT(!aToken.IsEmpty(), "Don't search for an empty token!");
 
     return StringBeginsWith(aSourceString, aToken);
   }
 
   /* static */
   MatchAutoCompleteFunction::searchFunctionPtr
   MatchAutoCompleteFunction::getSearchFunction(int32_t aBehavior)
   {
--- a/toolkit/components/places/nsNavHistoryResult.cpp
+++ b/toolkit/components/places/nsNavHistoryResult.cpp
@@ -2793,17 +2793,17 @@ nsNavHistoryQueryResultNode::OnPageChang
 
 NS_IMETHODIMP
 nsNavHistoryQueryResultNode::OnDeleteVisits(nsIURI* aURI,
                                             PRTime aVisitTime,
                                             const nsACString& aGUID,
                                             uint16_t aReason,
                                             uint32_t aTransitionType)
 {
-  NS_PRECONDITION(mOptions->QueryType() == nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY,
+  MOZ_ASSERT(mOptions->QueryType() == nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY,
                   "Bookmarks queries should not get a OnDeleteVisits notification");
   if (aVisitTime == 0) {
     // All visits for this uri have been removed, but the uri won't be removed
     // from the databse, most likely because it's a bookmark.  For a history
     // query this is equivalent to a onDeleteURI notification.
     nsresult rv = OnDeleteURI(aURI, aGUID, aReason);
     NS_ENSURE_SUCCESS(rv, rv);
   }
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -381,17 +381,17 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStop
   //
   return NS_OK;
 }
 
 nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * aCtxt)
 {
   LOG(("[0x%p] nsDocumentOpenInfo::DispatchContent for type '%s'", this, mContentType.get()));
 
-  NS_PRECONDITION(!m_targetStreamListener,
+  MOZ_ASSERT(!m_targetStreamListener,
                   "Why do we already have a target stream listener?");
   
   nsresult rv;
   nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
   if (!aChannel) {
     LOG_ERROR(("  Request is not a channel.  Bailing."));
     return NS_ERROR_FAILURE;
   }
@@ -644,17 +644,17 @@ nsDocumentOpenInfo::ConvertData(nsIReque
        PromiseFlatCString(aOutContentType).get()));
 
   if (mDataConversionDepthLimit == 0) {
     LOG(("[0x%p] nsDocumentOpenInfo::ConvertData - reached the recursion limit!", this));
     // This will fall back to external helper app handling.
     return NS_ERROR_ABORT;
   }
 
-  NS_PRECONDITION(aSrcContentType != aOutContentType,
+  MOZ_ASSERT(aSrcContentType != aOutContentType,
                   "ConvertData called when the two types are the same!");
   nsresult rv = NS_OK;
 
   nsCOMPtr<nsIStreamConverterService> StreamConvService = 
     do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
   if (NS_FAILED(rv)) return rv;
 
   LOG(("  Got converter service"));
@@ -701,18 +701,18 @@ nsDocumentOpenInfo::ConvertData(nsIReque
 
 bool
 nsDocumentOpenInfo::TryContentListener(nsIURIContentListener* aListener,
                                        nsIChannel* aChannel)
 {
   LOG(("[0x%p] nsDocumentOpenInfo::TryContentListener; mFlags = 0x%x",
        this, mFlags));
 
-  NS_PRECONDITION(aListener, "Must have a non-null listener");
-  NS_PRECONDITION(aChannel, "Must have a channel");
+  MOZ_ASSERT(aListener, "Must have a non-null listener");
+  MOZ_ASSERT(aChannel, "Must have a channel");
   
   bool listenerWantsContent = false;
   nsCString typeToUse;
   
   if (mFlags & nsIURILoader::IS_CONTENT_PREFERRED) {
     aListener->IsPreferred(mContentType.get(),
                            getter_Copies(typeToUse),
                            &listenerWantsContent);
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1554,17 +1554,17 @@ nsExternalAppHandler::MaybeApplyDecoding
     }
   }
 
   encChannel->SetApplyConversion( applyConversion );
 }
 
 NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISupports * aCtxt)
 {
-  NS_PRECONDITION(request, "OnStartRequest without request?");
+  MOZ_ASSERT(request, "OnStartRequest without request?");
 
   // Set mTimeDownloadStarted here as the download has already started and
   // we want to record the start time before showing the filepicker.
   mTimeDownloadStarted = PR_Now();
 
   mRequest = request;
 
   nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
@@ -2307,17 +2307,17 @@ NS_IMETHODIMP nsExternalAppHandler::Save
 
   return NS_OK;
 }
 nsresult nsExternalAppHandler::ContinueSave(nsIFile * aNewFileLocation)
 {
   if (mCanceled)
     return NS_OK;
 
-  NS_PRECONDITION(aNewFileLocation, "Must be called with a non-null file");
+  MOZ_ASSERT(aNewFileLocation, "Must be called with a non-null file");
 
   nsresult rv = NS_OK;
   nsCOMPtr<nsIFile> fileToUse = do_QueryInterface(aNewFileLocation);
   mFinalFileDestination = do_QueryInterface(fileToUse);
 
   // Move what we have in the final directory, but append .part
   // to it, to indicate that it's unfinished.  Do not call SetTarget on the
   // saver if we are done (Finish has been called) but OnSaverComplete has not
@@ -2533,18 +2533,17 @@ nsExternalAppHandler::GetName(nsACString
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // The following section contains our nsIMIMEService implementation and related methods.
 //
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 // nsIMIMEService methods
 NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(const nsACString& aMIMEType, const nsACString& aFileExt, nsIMIMEInfo **_retval) 
 {
-  NS_PRECONDITION(!aMIMEType.IsEmpty() ||
-                  !aFileExt.IsEmpty(), 
+  MOZ_ASSERT(!aMIMEType.IsEmpty() || !aFileExt.IsEmpty(),
                   "Give me something to work with");
   LOG(("Getting mimeinfo from type '%s' ext '%s'\n",
         PromiseFlatCString(aMIMEType).get(), PromiseFlatCString(aFileExt).get()));
 
   *_retval = nullptr;
 
   // OK... we need a type. Get one.
   nsAutoCString typeToUse(aMIMEType);
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
@@ -162,17 +162,17 @@ ParseMIMEType(const nsAString::const_ite
 // static
 nsresult
 nsOSHelperAppService::GetFileLocation(const char* aPrefName,
                                       const char* aEnvVarName,
                                       nsAString& aFileLocation) {
   LOG(("-- GetFileLocation.  Pref: '%s'  EnvVar: '%s'\n",
        aPrefName,
        aEnvVarName));
-  NS_PRECONDITION(aPrefName, "Null pref name passed; don't do that!");
+  MOZ_ASSERT(aPrefName, "Null pref name passed; don't do that!");
 
   aFileLocation.Truncate();
   /* The lookup order is:
      1) user pref
      2) env var
      3) pref
   */
   NS_ENSURE_TRUE(Preferences::GetRootBranch(), NS_ERROR_FAILURE);
--- a/view/nsView.cpp
+++ b/view/nsView.cpp
@@ -167,17 +167,17 @@ void nsView::DestroyWidget()
     }
 
     mWindow = nullptr;
   }
 }
 
 nsView* nsView::GetViewFor(nsIWidget* aWidget)
 {
-  NS_PRECONDITION(nullptr != aWidget, "null widget ptr");
+  MOZ_ASSERT(nullptr != aWidget, "null widget ptr");
 
   nsIWidgetListener* listener = aWidget->GetWidgetListener();
   if (listener) {
     nsView* view = listener->GetView();
     if (view)
       return view;
   }
 
@@ -307,17 +307,17 @@ LayoutDeviceIntRect nsView::CalcWidgetBo
 void nsView::DoResetWidgetBounds(bool aMoveOnly,
                                  bool aInvalidateChangedSize) {
   // The geometry of a root view's widget is controlled externally,
   // NOT by sizing or positioning the view
   if (mViewManager->GetRootView() == this) {
     return;
   }
 
-  NS_PRECONDITION(mWindow, "Why was this called??");
+  MOZ_ASSERT(mWindow, "Why was this called??");
 
   // Hold this ref to make sure it stays alive.
   nsCOMPtr<nsIWidget> widget = mWindow;
 
   // Stash a copy of these and use them so we can handle this being deleted (say
   // from sync painting/flushing from Show/Move/Resize on the widget).
   LayoutDeviceIntRect newBounds;
   RefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
@@ -447,17 +447,17 @@ void nsView::InvalidateHierarchy()
     mViewManager->InvalidateHierarchy();
 
   for (nsView *child = mFirstChild; child; child = child->GetNextSibling())
     child->InvalidateHierarchy();
 }
 
 void nsView::InsertChild(nsView *aChild, nsView *aSibling)
 {
-  NS_PRECONDITION(nullptr != aChild, "null ptr");
+  MOZ_ASSERT(nullptr != aChild, "null ptr");
 
   if (nullptr != aChild)
   {
     if (nullptr != aSibling)
     {
 #ifdef DEBUG
       NS_ASSERTION(aSibling->GetParent() == this, "tried to insert view with invalid sibling");
 #endif
@@ -480,17 +480,17 @@ void nsView::InsertChild(nsView *aChild,
     {
       aChild->InvalidateHierarchy();
     }
   }
 }
 
 void nsView::RemoveChild(nsView *child)
 {
-  NS_PRECONDITION(nullptr != child, "null ptr");
+  MOZ_ASSERT(nullptr != child, "null ptr");
 
   if (nullptr != child)
   {
     nsView* prevKid = nullptr;
     nsView* kid = mFirstChild;
     DebugOnly<bool> found = false;
     while (nullptr != kid) {
       if (kid == child) {
@@ -693,17 +693,18 @@ nsView::SetNeedsWindowPropertiesSync()
     mViewManager->PostPendingUpdate();
   }
 }
 
 
 // Attach to a top level widget and start receiving mirrored events.
 nsresult nsView::AttachToTopLevelWidget(nsIWidget* aWidget)
 {
-  NS_PRECONDITION(nullptr != aWidget, "null widget ptr");
+  MOZ_ASSERT(nullptr != aWidget, "null widget ptr");
+
   /// XXXjimm This is a temporary workaround to an issue w/document
   // viewer (bug 513162).
   nsIWidgetListener* listener = aWidget->GetAttachedWidgetListener();
   if (listener) {
     nsView *oldView = listener->GetView();
     if (oldView) {
       oldView->DetachFromTopLevelWidget();
     }
@@ -726,18 +727,18 @@ nsresult nsView::AttachToTopLevelWidget(
   CalcWidgetBounds(mWindow->WindowType());
 
   return NS_OK;
 }
 
 // Detach this view from an attached widget.
 nsresult nsView::DetachFromTopLevelWidget()
 {
-  NS_PRECONDITION(mWidgetIsTopLevel, "Not attached currently!");
-  NS_PRECONDITION(mWindow, "null mWindow for DetachFromTopLevelWidget!");
+  MOZ_ASSERT(mWidgetIsTopLevel, "Not attached currently!");
+  MOZ_ASSERT(mWindow, "null mWindow for DetachFromTopLevelWidget!");
 
   mWindow->SetAttachedWidgetListener(nullptr);
   nsIWidgetListener* listener = mWindow->GetPreviouslyAttachedWidgetListener();
 
   if (listener && listener->GetView()) {
     // Ensure the listener doesn't think it's being used anymore
     listener->GetView()->SetPreviousWidget(nullptr);
   }
@@ -1118,17 +1119,17 @@ nsView::RequestRepaint()
     presShell->ScheduleViewManagerFlush();
   }
 }
 
 nsEventStatus
 nsView::HandleEvent(WidgetGUIEvent* aEvent,
                     bool aUseAttachedEvents)
 {
-  NS_PRECONDITION(nullptr != aEvent->mWidget, "null widget ptr");
+  MOZ_ASSERT(nullptr != aEvent->mWidget, "null widget ptr");
 
   nsEventStatus result = nsEventStatus_eIgnore;
   nsView* view;
   if (aUseAttachedEvents) {
     nsIWidgetListener* listener = aEvent->mWidget->GetAttachedWidgetListener();
     view = listener ? listener->GetView() : nullptr;
   }
   else {
--- a/view/nsViewManager.cpp
+++ b/view/nsViewManager.cpp
@@ -103,17 +103,17 @@ nsViewManager::~nsViewManager()
   MOZ_RELEASE_ASSERT(!mPresShell, "Releasing nsViewManager without having called Destroy on the PresShell!");
 }
 
 // We don't hold a reference to the presentation context because it
 // holds a reference to us.
 nsresult
 nsViewManager::Init(nsDeviceContext* aContext)
 {
-  NS_PRECONDITION(nullptr != aContext, "null ptr");
+  MOZ_ASSERT(nullptr != aContext, "null ptr");
 
   if (nullptr == aContext) {
     return NS_ERROR_NULL_POINTER;
   }
   if (nullptr != mContext) {
     return NS_ERROR_ALREADY_INITIALIZED;
   }
   mContext = aContext;
@@ -132,17 +132,17 @@ nsViewManager::CreateView(const nsRect& 
   nsRect dim(0, 0, aBounds.Width(), aBounds.Height());
   v->SetDimensions(dim, false);
   return v;
 }
 
 void
 nsViewManager::SetRootView(nsView *aView)
 {
-  NS_PRECONDITION(!aView || aView->GetViewManager() == this,
+  MOZ_ASSERT(!aView || aView->GetViewManager() == this,
                   "Unexpected viewmanager on root view");
 
   // Do NOT destroy the current root view. It's the caller's responsibility
   // to destroy it
   mRootView = aView;
 
   if (mRootView) {
     nsView* parent = mRootView->GetParent();
@@ -643,17 +643,17 @@ nsViewManager::InvalidateView(nsView *aV
 
   InvalidateViewNoSuppression(aView, aRect);
 }
 
 void
 nsViewManager::InvalidateViewNoSuppression(nsView *aView,
                                            const nsRect &aRect)
 {
-  NS_PRECONDITION(nullptr != aView, "null view");
+  MOZ_ASSERT(nullptr != aView, "null view");
 
   NS_ASSERTION(aView->GetViewManager() == this,
                "InvalidateViewNoSuppression called on view we don't own");
 
   nsRect damagedRect(aRect);
   if (damagedRect.IsEmpty()) {
     return;
   }
@@ -816,17 +816,17 @@ nsViewManager::DispatchEvent(WidgetGUIEv
 
   *aStatus = nsEventStatus_eIgnore;
 }
 
 // Recursively reparent widgets if necessary
 
 void nsViewManager::ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget)
 {
-  NS_PRECONDITION(aNewWidget, "");
+  MOZ_ASSERT(aNewWidget, "null widget");
 
   if (aView->HasWidget()) {
     // Check to see if the parent widget is the
     // same as the new parent. If not then reparent
     // the widget, otherwise there is nothing more
     // to do for the view and its descendants
     nsIWidget* widget = aView->GetWidget();
     nsIWidget* parentWidget = widget->GetParent();
@@ -849,18 +849,18 @@ void nsViewManager::ReparentChildWidgets
     ReparentChildWidgets(kid, aNewWidget);
   }
 }
 
 // Reparent a view and its descendant views widgets if necessary
 
 void nsViewManager::ReparentWidgets(nsView* aView, nsView *aParent)
 {
-  NS_PRECONDITION(aParent, "Must have a parent");
-  NS_PRECONDITION(aView, "Must have a view");
+  MOZ_ASSERT(aParent, "Must have a parent");
+  MOZ_ASSERT(aView, "Must have a view");
 
   // Quickly determine whether the view has pre-existing children or a
   // widget. In most cases the view will not have any pre-existing
   // children when this is called.  Only in the case
   // where a view has been reparented by removing it from
   // a reinserting it into a new location in the view hierarchy do we
   // have to consider reparenting the existing widgets for the view and
   // it's descendants.
@@ -873,18 +873,18 @@ void nsViewManager::ReparentWidgets(nsVi
     NS_WARNING("Can not find a widget for the parent view");
   }
 }
 
 void
 nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling,
                            bool aAfter)
 {
-  NS_PRECONDITION(nullptr != aParent, "null ptr");
-  NS_PRECONDITION(nullptr != aChild, "null ptr");
+  MOZ_ASSERT(nullptr != aParent, "null ptr");
+  MOZ_ASSERT(nullptr != aChild, "null ptr");
   NS_ASSERTION(aSibling == nullptr || aSibling->GetParent() == aParent,
                "tried to insert view with invalid sibling");
   NS_ASSERTION(!IsViewInserted(aChild), "tried to insert an already-inserted view");
 
   if ((nullptr != aParent) && (nullptr != aChild))
     {
       // if aAfter is set, we will insert the child after 'prev' (i.e. after 'kid' in document
       // order, otherwise after 'kid' (i.e. before 'kid' in document order).
@@ -1116,17 +1116,17 @@ nsViewManager::UpdateWidgetGeometry()
     RefPtr<nsViewManager> strongThis(this);
     ProcessPendingUpdatesForView(mRootView, false);
   }
 }
 
 void
 nsViewManager::CallWillPaintOnObservers()
 {
-  NS_PRECONDITION(IsRootVM(), "Must be root VM for this to be called!");
+  MOZ_ASSERT(IsRootVM(), "Must be root VM for this to be called!");
 
   if (NS_WARN_IF(!gViewManagers)) {
     return;
   }
 
   uint32_t index;
   for (index = 0; index < gViewManagers->Length(); index++) {
     nsViewManager* vm = gViewManagers->ElementAt(index);
@@ -1161,9 +1161,8 @@ nsViewManager::InvalidateHierarchy()
       NS_ADDREF(mRootViewManager);
       NS_ASSERTION(mRootViewManager != this,
                    "Root view had a parent, but it has the same view manager");
     } else {
       mRootViewManager = this;
     }
   }
 }
-
--- a/widget/cocoa/TextInputHandler.h
+++ b/widget/cocoa/TextInputHandler.h
@@ -603,17 +603,17 @@ protected:
 
     ~KeyEventState()
     {
       Clear();
     }
 
     void Set(NSEvent* aNativeKeyEvent, uint32_t aUniqueId = 0)
     {
-      NS_PRECONDITION(aNativeKeyEvent, "aNativeKeyEvent must not be NULL");
+      MOZ_ASSERT(aNativeKeyEvent, "aNativeKeyEvent must not be NULL");
       Clear();
       mKeyEvent = [aNativeKeyEvent retain];
       mUniqueId = aUniqueId;
     }
 
     void Clear()
     {
       if (mKeyEvent) {
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -791,17 +791,17 @@ nsChildView::SetParent(nsIWidget* aNewPa
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 void
 nsChildView::ReparentNativeWidget(nsIWidget* aNewParent)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
-  NS_PRECONDITION(aNewParent, "");
+  MOZ_ASSERT(aNewParent, "null widget");
 
   if (mOnDestroyCalled)
     return;
 
   NSView<mozView>* newParentView =
    (NSView<mozView>*)aNewParent->GetNativeData(NS_NATIVE_WIDGET);
   NS_ENSURE_TRUE_VOID(newParentView);
 
--- a/widget/cocoa/nsMenuUtilsX.mm
+++ b/widget/cocoa/nsMenuUtilsX.mm
@@ -19,17 +19,17 @@
 #include "nsPIDOMWindow.h"
 #include "nsQueryObject.h"
 #include "mozilla/dom/XULCommandEvent.h"
 
 using namespace mozilla;
 
 void nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent)
 {
-  NS_PRECONDITION(aTargetContent, "null ptr");
+  MOZ_ASSERT(aTargetContent, "null ptr");
 
   nsIDocument* doc = aTargetContent->OwnerDoc();
   if (doc) {
     RefPtr<dom::XULCommandEvent> event =
       new dom::XULCommandEvent(doc, doc->GetPresContext(), nullptr);
 
     IgnoredErrorResult rv;
     event->InitCommandEvent(NS_LITERAL_STRING("command"),
--- a/widget/cocoa/nsPrintDialogX.mm
+++ b/widget/cocoa/nsPrintDialogX.mm
@@ -42,17 +42,17 @@ nsPrintDialogServiceX::Init()
 }
 
 NS_IMETHODIMP
 nsPrintDialogServiceX::Show(nsPIDOMWindowOuter *aParent, nsIPrintSettings *aSettings,
                             nsIWebBrowserPrint *aWebBrowserPrint)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  NS_PRECONDITION(aSettings, "aSettings must not be null");
+  MOZ_ASSERT(aSettings, "aSettings must not be null");
 
   RefPtr<nsPrintSettingsX> settingsX(do_QueryObject(aSettings));
   if (!settingsX)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIPrintSettingsService> printSettingsSvc
     = do_GetService("@mozilla.org/gfx/printsettings-service;1");
 
@@ -192,18 +192,18 @@ nsPrintDialogServiceX::Show(nsPIDOMWindo
 }
 
 NS_IMETHODIMP
 nsPrintDialogServiceX::ShowPageSetup(nsPIDOMWindowOuter *aParent,
                                      nsIPrintSettings *aNSSettings)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  NS_PRECONDITION(aParent, "aParent must not be null");
-  NS_PRECONDITION(aNSSettings, "aSettings must not be null");
+  MOZ_ASSERT(aParent, "aParent must not be null");
+  MOZ_ASSERT(aNSSettings, "aSettings must not be null");
   NS_ENSURE_TRUE(aNSSettings, NS_ERROR_FAILURE);
 
   RefPtr<nsPrintSettingsX> settingsX(do_QueryObject(aNSSettings));
   if (!settingsX)
     return NS_ERROR_FAILURE;
 
   NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();
   NSPageLayout *pageLayout = [NSPageLayout pageLayout];
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -313,17 +313,17 @@ IsFcitxInSyncMode()
     return GetFcitxBoolEnv("IBUS_ENABLE_SYNC_MODE") ||
            GetFcitxBoolEnv("FCITX_ENABLE_SYNC_MODE");
 }
 
 void
 IMContextWrapper::Init()
 {
     MozContainer* container = mOwnerWindow->GetMozContainer();
-    NS_PRECONDITION(container, "container is null");
+    MOZ_ASSERT(container, "container is null");
     GdkWindow* gdkWindow = gtk_widget_get_window(GTK_WIDGET(container));
 
     // NOTE: gtk_im_*_new() abort (kill) the whole process when it fails.
     //       So, we don't need to check the result.
 
     // Normal context.
     mContext = gtk_im_multicontext_new();
     gtk_im_context_set_client_window(mContext, gdkWindow);
@@ -537,17 +537,17 @@ IMContextWrapper::GetIMENotificationRequ
 void
 IMContextWrapper::OnDestroyWindow(nsWindow* aWindow)
 {
     MOZ_LOG(gGtkIMLog, LogLevel::Info,
         ("0x%p OnDestroyWindow(aWindow=0x%p), mLastFocusedWindow=0x%p, "
          "mOwnerWindow=0x%p, mLastFocusedModule=0x%p",
          this, aWindow, mLastFocusedWindow, mOwnerWindow, sLastFocusedContext));
 
-    NS_PRECONDITION(aWindow, "aWindow must not be null");
+    MOZ_ASSERT(aWindow, "aWindow must not be null");
 
     if (mLastFocusedWindow == aWindow) {
         EndIMEComposition(aWindow);
         if (mIsIMFocused) {
             Blur();
         }
         mLastFocusedWindow = nullptr;
     }
@@ -673,17 +673,17 @@ IMContextWrapper::OnBlurWindow(nsWindow*
     Blur();
 }
 
 bool
 IMContextWrapper::OnKeyEvent(nsWindow* aCaller,
                              GdkEventKey* aEvent,
                              bool aKeyboardEventWasDispatched /* = false */)
 {
-    NS_PRECONDITION(aEvent, "aEvent must be non-null");
+    MOZ_ASSERT(aEvent, "aEvent must be non-null");
 
     if (!mInputContext.mIMEState.MaybeEditable() ||
         MOZ_UNLIKELY(IsDestroyed())) {
         return false;
     }
 
     MOZ_LOG(gGtkIMLog, LogLevel::Info,
         ("0x%p OnKeyEvent(aCaller=0x%p, "
--- a/widget/gtk/nsPrintDialogGTK.cpp
+++ b/widget/gtk/nsPrintDialogGTK.cpp
@@ -395,17 +395,17 @@ nsPrintDialogWidgetGTK::ExportHeaderFoot
 
   header_footer_str = OptionWidgetToString(footer_dropdown[2]);
   aNS->SetFooterStrRight(NS_ConvertUTF8toUTF16(header_footer_str));
 }
 
 nsresult
 nsPrintDialogWidgetGTK::ImportSettings(nsIPrintSettings *aNSSettings)
 {
-  NS_PRECONDITION(aNSSettings, "aSettings must not be null");
+  MOZ_ASSERT(aNSSettings, "aSettings must not be null");
   NS_ENSURE_TRUE(aNSSettings, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsPrintSettingsGTK> aNSSettingsGTK(do_QueryInterface(aNSSettings));
   if (!aNSSettingsGTK)
     return NS_ERROR_FAILURE;
 
   GtkPrintSettings* settings = aNSSettingsGTK->GetGtkPrintSettings();
   GtkPageSetup* setup = aNSSettingsGTK->GetGtkPageSetup();
@@ -424,17 +424,17 @@ nsPrintDialogWidgetGTK::ImportSettings(n
   gtk_print_unix_dialog_set_page_setup(GTK_PRINT_UNIX_DIALOG(dialog), setup);
 
   return NS_OK;
 }
 
 nsresult
 nsPrintDialogWidgetGTK::ExportSettings(nsIPrintSettings *aNSSettings)
 {
-  NS_PRECONDITION(aNSSettings, "aSettings must not be null");
+  MOZ_ASSERT(aNSSettings, "aSettings must not be null");
   NS_ENSURE_TRUE(aNSSettings, NS_ERROR_FAILURE);
 
   GtkPrintSettings* settings = gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG(dialog));
   GtkPageSetup* setup = gtk_print_unix_dialog_get_page_setup(GTK_PRINT_UNIX_DIALOG(dialog));
   GtkPrinter* printer = gtk_print_unix_dialog_get_selected_printer(GTK_PRINT_UNIX_DIALOG(dialog));
   if (settings && setup && printer) {
     ExportFramePrinting(aNSSettings, settings);
     ExportHeaderFooter(aNSSettings);
@@ -673,18 +673,18 @@ nsFlatpakPrintPortal::nsFlatpakPrintPort
  * FinishPrintDialog.
  *
  * @param aWindow toplevel application window which is used as parent of print
  *                dialog
  */
 nsresult
 nsFlatpakPrintPortal::PreparePrintRequest(GtkWindow* aWindow)
 {
-  NS_PRECONDITION(aWindow, "aWindow must not be null");
-  NS_PRECONDITION(mPrintAndPageSettings, "mPrintAndPageSettings must not be null");
+  MOZ_ASSERT(aWindow, "aWindow must not be null");
+  MOZ_ASSERT(mPrintAndPageSettings, "mPrintAndPageSettings must not be null");
 
   GError* error = nullptr;
   mProxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
       G_DBUS_PROXY_FLAGS_NONE,
       nullptr,
       "org.freedesktop.portal.Desktop",
       "/org/freedesktop/portal/desktop",
       "org.freedesktop.portal.Print",
@@ -982,18 +982,18 @@ nsFlatpakPrintPortal::~nsFlatpakPrintPor
     g_main_loop_quit(mLoop);
 }
 
 NS_IMETHODIMP
 nsPrintDialogServiceGTK::Show(nsPIDOMWindowOuter *aParent,
                               nsIPrintSettings *aSettings,
                               nsIWebBrowserPrint *aWebBrowserPrint)
 {
-  NS_PRECONDITION(aParent, "aParent must not be null");
-  NS_PRECONDITION(aSettings, "aSettings must not be null");
+  MOZ_ASSERT(aParent, "aParent must not be null");
+  MOZ_ASSERT(aSettings, "aSettings must not be null");
 
   // Check for the flatpak portal first
   nsCOMPtr<nsIGIOService> giovfs =
     do_GetService(NS_GIOSERVICE_CONTRACTID);
   bool shouldUsePortal;
   giovfs->ShouldUseFlatpakPortal(&shouldUsePortal);
   if (shouldUsePortal && gtk_check_version(3, 22, 0) == nullptr) {
     nsCOMPtr<nsIWidget> widget = WidgetUtils::DOMWindowToWidget(aParent);
@@ -1062,18 +1062,18 @@ nsPrintDialogServiceGTK::Show(nsPIDOMWin
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsPrintDialogServiceGTK::ShowPageSetup(nsPIDOMWindowOuter *aParent,
                                        nsIPrintSettings *aNSSettings)
 {
-  NS_PRECONDITION(aParent, "aParent must not be null");
-  NS_PRECONDITION(aNSSettings, "aSettings must not be null");
+  MOZ_ASSERT(aParent, "aParent must not be null");
+  MOZ_ASSERT(aNSSettings, "aSettings must not be null");
   NS_ENSURE_TRUE(aNSSettings, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIWidget> widget = WidgetUtils::DOMWindowToWidget(aParent);
   NS_ASSERTION(widget, "Need a widget for dialog to be modal.");
   GtkWindow* gtkParent = get_gtk_window_for_nsiwidget(widget);
   NS_ASSERTION(gtkParent, "Need a GTK window for dialog to be modal.");
 
   nsCOMPtr<nsPrintSettingsGTK> aNSSettingsGTK(do_QueryInterface(aNSSettings));
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -626,17 +626,17 @@ EnsureInvisibleContainer()
 
     }
     return gInvisibleContainer;
 }
 
 static void
 CheckDestroyInvisibleContainer()
 {
-    NS_PRECONDITION(gInvisibleContainer, "oh, no");
+    MOZ_ASSERT(gInvisibleContainer, "oh, no");
 
     if (!gdk_window_peek_children(gtk_widget_get_window(gInvisibleContainer))) {
         // No children, so not in use.
         // Make sure to destroy the GtkWindow also.
         gtk_widget_destroy(gtk_widget_get_parent(gInvisibleContainer));
         gInvisibleContainer = nullptr;
     }
 }
@@ -882,17 +882,17 @@ bool
 nsWindow::WidgetTypeSupportsAcceleration()
 {
   return !IsSmallPopup();
 }
 
 void
 nsWindow::ReparentNativeWidget(nsIWidget* aNewParent)
 {
-    NS_PRECONDITION(aNewParent, "");
+    MOZ_ASSERT(aNewParent, "null widget");
     NS_ASSERTION(!mIsDestroyed, "");
     NS_ASSERTION(!static_cast<nsWindow*>(aNewParent)->mIsDestroyed, "");
 
     GtkWidget* oldContainer = GetMozContainerWidget();
     if (!oldContainer) {
         // The GdkWindows have been destroyed so there is nothing else to
         // reparent.
         MOZ_ASSERT(gdk_window_is_destroyed(mGdkWindow),
--- a/widget/nsBaseFilePicker.cpp
+++ b/widget/nsBaseFilePicker.cpp
@@ -164,17 +164,17 @@ nsBaseFilePicker::~nsBaseFilePicker()
 {
 
 }
 
 NS_IMETHODIMP nsBaseFilePicker::Init(mozIDOMWindowProxy* aParent,
                                      const nsAString& aTitle,
                                      int16_t aMode)
 {
-  NS_PRECONDITION(aParent, "Null parent passed to filepicker, no file "
+  MOZ_ASSERT(aParent, "Null parent passed to filepicker, no file "
                   "picker for you!");
 
   mParent = nsPIDOMWindowOuter::From(aParent);
 
   nsCOMPtr<nsIWidget> widget = WidgetUtils::DOMWindowToWidget(mParent->GetOuterWindow());
   NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
 
 
--- a/widget/nsNativeTheme.cpp
+++ b/widget/nsNativeTheme.cpp
@@ -583,17 +583,17 @@ nsNativeTheme::IsVerticalProgress(nsIFra
     return false;
   }
   return IsVerticalMeter(aFrame);
 }
 
 bool
 nsNativeTheme::IsVerticalMeter(nsIFrame* aFrame)
 {
-  NS_PRECONDITION(aFrame, "You have to pass a non-null aFrame");
+  MOZ_ASSERT(aFrame, "You have to pass a non-null aFrame");
   switch (aFrame->StyleDisplay()->mOrient) {
     case StyleOrient::Horizontal:
       return false;
     case StyleOrient::Vertical:
       return true;
     case StyleOrient::Inline:
       return aFrame->GetWritingMode().IsVertical();
     case StyleOrient::Block:
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -1296,17 +1296,17 @@ IMMHandler::GetTextEventDispatcherFor(ns
   return aWindow == mComposingWindow && mDispatcher ?
     mDispatcher.get() : aWindow->GetTextEventDispatcher();
 }
 
 void
 IMMHandler::HandleStartComposition(nsWindow* aWindow,
                                    const IMEContext& aContext)
 {
-  NS_PRECONDITION(!mIsComposing,
+  MOZ_ASSERT(!mIsComposing,
     "HandleStartComposition is called but mIsComposing is TRUE");
 
   Selection& selection = GetSelection();
   if (!selection.EnsureValidSelection(aWindow)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("HandleStartComposition, FAILED, due to "
        "Selection::EnsureValidSelection() failure"));
     return;
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -794,17 +794,17 @@ WinUtils::WaitForMessage(DWORD aTimeoutM
 /* static */
 bool
 WinUtils::GetRegistryKey(HKEY aRoot,
                          char16ptr_t aKeyName,
                          char16ptr_t aValueName,
                          wchar_t* aBuffer,
                          DWORD aBufferLength)
 {
-  NS_PRECONDITION(aKeyName, "The key name is NULL");
+  MOZ_ASSERT(aKeyName, "The key name is NULL");
 
   HKEY key;
   LONG result =
     ::RegOpenKeyExW(aRoot, aKeyName, 0, KEY_READ | KEY_WOW64_32KEY, &key);
   if (result != ERROR_SUCCESS) {
     result =
       ::RegOpenKeyExW(aRoot, aKeyName, 0, KEY_READ | KEY_WOW64_64KEY, &key);
     if (result != ERROR_SUCCESS) {
@@ -1346,17 +1346,17 @@ AsyncEncodeAndWriteIcon::AsyncEncodeAndW
   mStride(aStride),
   mWidth(aWidth),
   mHeight(aHeight)
 {
 }
 
 NS_IMETHODIMP AsyncEncodeAndWriteIcon::Run()
 {
-  NS_PRECONDITION(!NS_IsMainThread(), "Should not be called on the main thread.");
+  MOZ_ASSERT(!NS_IsMainThread(), "Should not be called on the main thread.");
 
   // Note that since we're off the main thread we can't use
   // gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()
   RefPtr<DataSourceSurface> surface =
     Factory::CreateWrappingDataSourceSurface(mBuffer.get(), mStride,
                                              IntSize(mWidth, mHeight),
                                              SurfaceFormat::B8G8R8A8);
 
--- a/widget/windows/nsColorPicker.cpp
+++ b/widget/windows/nsColorPicker.cpp
@@ -191,17 +191,17 @@ nsColorPicker::~nsColorPicker()
 
 NS_IMPL_ISUPPORTS(nsColorPicker, nsIColorPicker)
 
 NS_IMETHODIMP
 nsColorPicker::Init(mozIDOMWindowProxy* parent,
                     const nsAString& title,
                     const nsAString& aInitialColor)
 {
-  NS_PRECONDITION(parent,
+  MOZ_ASSERT(parent,
       "Null parent passed to colorpicker, no color picker for you!");
   mParentWidget =  WidgetUtils::DOMWindowToWidget(nsPIDOMWindowOuter::From(parent));
   mInitialColor = ColorStringToRGB(aInitialColor);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsColorPicker::Open(nsIColorPickerShownCallback* aCallback)
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1268,17 +1268,17 @@ nsWindow::SetParent(nsIWidget *aNewParen
     // If we have no parent, SetParent should return the desktop.
     VERIFY(::SetParent(mWnd, nullptr));
   }
 }
 
 void
 nsWindow::ReparentNativeWidget(nsIWidget* aNewParent)
 {
-  NS_PRECONDITION(aNewParent, "");
+  MOZ_ASSERT(aNewParent, "null widget");
 
   mParent = aNewParent;
   if (mWindowType == eWindowType_popup) {
     return;
   }
   HWND newParent = (HWND)aNewParent->GetNativeData(NS_NATIVE_WINDOW);
   NS_ASSERTION(newParent, "Parent widget has a null native window handle");
   if (newParent && mWnd) {
--- a/xpcom/base/nsAutoPtr.h
+++ b/xpcom/base/nsAutoPtr.h
@@ -191,17 +191,17 @@ public:
     T* temp = mRawPtr;
     mRawPtr = 0;
     return temp;
   }
 
   T*
   operator->() const
   {
-    NS_PRECONDITION(mRawPtr != 0,
+    MOZ_ASSERT(mRawPtr != 0,
                     "You can't dereference a NULL nsAutoPtr with operator->().");
     return get();
   }
 
   template <typename R, typename... Args>
   class Proxy
   {
     typedef R (T::*member_function)(Args...);
@@ -218,17 +218,17 @@ public:
     {
       return ((*mRawPtr).*mFunction)(mozilla::Forward<ActualArgs>(aArgs)...);
     }
   };
 
   template <typename R, typename C, typename... Args>
   Proxy<R, Args...> operator->*(R (C::*aFptr)(Args...)) const
   {
-    NS_PRECONDITION(mRawPtr != 0,
+    MOZ_ASSERT(mRawPtr != 0,
                     "You can't dereference a NULL nsAutoPtr with operator->*().");
     return Proxy<R, Args...>(get(), aFptr);
   }
 
   nsAutoPtr<T>*
   get_address()
   // This is not intended to be used by clients.  See |address_of|
   // below.
@@ -243,17 +243,17 @@ public:
   {
     return this;
   }
 
 public:
   T&
   operator*() const
   {
-    NS_PRECONDITION(mRawPtr != 0,
+    MOZ_ASSERT(mRawPtr != 0,
                     "You can't dereference a NULL nsAutoPtr with operator*().");
     return *get();
   }
 
   T**
   StartAssignment()
   {
 #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT
--- a/xpcom/base/nsCycleCollectionParticipant.h
+++ b/xpcom/base/nsCycleCollectionParticipant.h
@@ -325,17 +325,17 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCOMCyc
 // The IIDs for nsXPCOMCycleCollectionParticipant and nsCycleCollectionISupports
 // are special in that they only differ in their last byte.  This allows for the
 // optimization below where we first check the first three words of the IID and
 // if we find a match we check the last word to decide which case we have to
 // deal with.
 #define NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(_class)            \
   NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr)    \
   {                                                                           \
-    NS_PRECONDITION(aInstancePtr, "null out param");                          \
+    MOZ_ASSERT(aInstancePtr, "null out param");                               \
                                                                               \
     if (TopThreeWordsEquals(aIID, NS_GET_IID(nsXPCOMCycleCollectionParticipant), \
                             NS_GET_IID(nsCycleCollectionISupports))) {        \
       if (LowWordEquals(aIID, NS_GET_IID(nsXPCOMCycleCollectionParticipant))) { \
         *aInstancePtr = NS_CYCLE_COLLECTION_PARTICIPANT(_class);              \
         return NS_OK;                                                         \
       }                                                                       \
       if (LowWordEquals(aIID, NS_GET_IID(nsCycleCollectionISupports))) {      \
--- a/xpcom/base/nsIInterfaceRequestorUtils.h
+++ b/xpcom/base/nsIInterfaceRequestorUtils.h
@@ -10,18 +10,18 @@
 #include "nsCOMPtr.h"
 
 // a type-safe shortcut for calling the |GetInterface()| member function
 // T must inherit from nsIInterfaceRequestor, but the cast may be ambiguous.
 template<class T, class DestinationType>
 inline nsresult
 CallGetInterface(T* aSource, DestinationType** aDestination)
 {
-  NS_PRECONDITION(aSource, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aSource, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return aSource->GetInterface(NS_GET_TEMPLATE_IID(DestinationType),
                                reinterpret_cast<void**>(aDestination));
 }
 
 class MOZ_STACK_CLASS nsGetInterface final : public nsCOMPtr_helper
 {
 public:
--- a/xpcom/base/nsISupportsImpl.h
+++ b/xpcom/base/nsISupportsImpl.h
@@ -676,17 +676,17 @@ NS_IMETHODIMP_(MozExternalRefCountType) 
  * interface(s) for its owner
  * @param _class The name of the class implementing the method
  * @param _aggregator the owning/containing object
  */
 #define NS_IMPL_ADDREF_USING_AGGREGATOR(_class, _aggregator)                  \
 NS_IMETHODIMP_(MozExternalRefCountType) _class::AddRef(void)                  \
 {                                                                             \
   MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class)                                  \
-  NS_PRECONDITION(_aggregator, "null aggregator");                            \
+  MOZ_ASSERT(_aggregator, "null aggregator");                                 \
   return (_aggregator)->AddRef();                                             \
 }
 
 // We decrement the refcnt before logging the actual release, but when logging
 // named things, accessing the name may not be valid after the refcnt
 // decrement, because the object may have been destroyed on a different thread.
 // Use this macro to ensure that we have a local copy of the name prior to
 // the refcnt decrement.  (We use a macro to make absolutely sure the name
@@ -763,17 +763,17 @@ NS_IMETHODIMP_(MozExternalRefCountType) 
  * implemented as a wholly owned aggregated object intended to implement
  * interface(s) for its owner
  * @param _class The name of the class implementing the method
  * @param _aggregator the owning/containing object
  */
 #define NS_IMPL_RELEASE_USING_AGGREGATOR(_class, _aggregator)                 \
 NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void)                 \
 {                                                                             \
-  NS_PRECONDITION(_aggregator, "null aggregator");                            \
+  MOZ_ASSERT(_aggregator, "null aggregator");                                 \
   return (_aggregator)->Release();                                            \
 }
 
 
 #define NS_IMPL_CYCLE_COLLECTING_ADDREF(_class)                               \
 NS_IMETHODIMP_(MozExternalRefCountType) _class::AddRef(void)                  \
 {                                                                             \
   MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class)                                  \
--- a/xpcom/base/nsISupportsUtils.h
+++ b/xpcom/base/nsISupportsUtils.h
@@ -123,18 +123,18 @@ inline nsresult
 CallQueryInterface(T* aSource, DestinationType** aDestination)
 {
   // We permit nsISupports-to-nsISupports here so that one can still obtain
   // the canonical nsISupports pointer with CallQueryInterface.
   static_assert(!mozilla::IsSame<T, DestinationType>::value ||
                 mozilla::IsSame<DestinationType, nsISupports>::value,
                 "don't use CallQueryInterface for compile-time-determinable casts");
 
-  NS_PRECONDITION(aSource, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aSource, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return aSource->QueryInterface(NS_GET_TEMPLATE_IID(DestinationType),
                                  reinterpret_cast<void**>(aDestination));
 }
 
 template <class SourceType, class DestinationType>
 inline nsresult
 CallQueryInterface(RefPtr<SourceType>& aSourcePtr, DestinationType** aDestPtr)
--- a/xpcom/base/nsIWeakReferenceUtils.h
+++ b/xpcom/base/nsIWeakReferenceUtils.h
@@ -17,18 +17,18 @@ typedef nsCOMPtr<nsIWeakReference> nsWea
  */
 
 // a type-safe shortcut for calling the |QueryReferent()| member function
 // T must inherit from nsIWeakReference, but the cast may be ambiguous.
 template<class T, class DestinationType>
 inline nsresult
 CallQueryReferent(T* aSource, DestinationType** aDestination)
 {
-  NS_PRECONDITION(aSource, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aSource, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return aSource->QueryReferent(NS_GET_TEMPLATE_IID(DestinationType),
                                 reinterpret_cast<void**>(aDestination));
 }
 
 
 inline const nsQueryReferent
 do_QueryReferent(nsIWeakReference* aRawPtr, nsresult* aError = 0)
--- a/xpcom/components/nsComponentManagerUtils.h
+++ b/xpcom/components/nsComponentManagerUtils.h
@@ -148,100 +148,100 @@ do_GetClassObject(const char* aContractI
 
 // type-safe shortcuts for calling |CreateInstance|
 template<class DestinationType>
 inline nsresult
 CallCreateInstance(const nsCID& aClass,
                    nsISupports* aDelegate,
                    DestinationType** aDestination)
 {
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallCreateInstance(aClass, aDelegate,
                             NS_GET_TEMPLATE_IID(DestinationType),
                             reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallCreateInstance(const nsCID& aClass, DestinationType** aDestination)
 {
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallCreateInstance(aClass, nullptr,
                             NS_GET_TEMPLATE_IID(DestinationType),
                             reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallCreateInstance(const char* aContractID,
                    nsISupports* aDelegate,
                    DestinationType** aDestination)
 {
-  NS_PRECONDITION(aContractID, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aContractID, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallCreateInstance(aContractID,
                             aDelegate,
                             NS_GET_TEMPLATE_IID(DestinationType),
                             reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallCreateInstance(const char* aContractID, DestinationType** aDestination)
 {
-  NS_PRECONDITION(aContractID, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aContractID, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallCreateInstance(aContractID, nullptr,
                             NS_GET_TEMPLATE_IID(DestinationType),
                             reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallCreateInstance(nsIFactory* aFactory,
                    nsISupports* aDelegate,
                    DestinationType** aDestination)
 {
-  NS_PRECONDITION(aFactory, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aFactory, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return aFactory->CreateInstance(aDelegate,
                                   NS_GET_TEMPLATE_IID(DestinationType),
                                   reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallCreateInstance(nsIFactory* aFactory, DestinationType** aDestination)
 {
-  NS_PRECONDITION(aFactory, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aFactory, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return aFactory->CreateInstance(nullptr,
                                   NS_GET_TEMPLATE_IID(DestinationType),
                                   reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallGetClassObject(const nsCID& aClass, DestinationType** aDestination)
 {
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallGetClassObject(aClass, NS_GET_TEMPLATE_IID(DestinationType),
                             reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallGetClassObject(const char* aContractID, DestinationType** aDestination)
 {
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallGetClassObject(aContractID, NS_GET_TEMPLATE_IID(DestinationType),
                             reinterpret_cast<void**>(aDestination));
 }
 
 #endif /* nsComponentManagerUtils_h__ */
--- a/xpcom/components/nsServiceManagerUtils.h
+++ b/xpcom/components/nsServiceManagerUtils.h
@@ -66,29 +66,29 @@ nsresult CallGetService(const char* aCon
                         void** aResult);
 
 // type-safe shortcuts for calling |GetService|
 template<class DestinationType>
 inline nsresult
 CallGetService(const nsCID& aClass,
                DestinationType** aDestination)
 {
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallGetService(aClass,
                         NS_GET_TEMPLATE_IID(DestinationType),
                         reinterpret_cast<void**>(aDestination));
 }
 
 template<class DestinationType>
 inline nsresult
 CallGetService(const char* aContractID,
                DestinationType** aDestination)
 {
-  NS_PRECONDITION(aContractID, "null parameter");
-  NS_PRECONDITION(aDestination, "null parameter");
+  MOZ_ASSERT(aContractID, "null parameter");
+  MOZ_ASSERT(aDestination, "null parameter");
 
   return CallGetService(aContractID,
                         NS_GET_TEMPLATE_IID(DestinationType),
                         reinterpret_cast<void**>(aDestination));
 }
 
 #endif
--- a/xpcom/ds/nsArrayEnumerator.cpp
+++ b/xpcom/ds/nsArrayEnumerator.cpp
@@ -40,17 +40,17 @@ protected:
   uint32_t mIndex;
 };
 
 NS_IMPL_ISUPPORTS(nsSimpleArrayEnumerator, nsISimpleEnumerator)
 
 NS_IMETHODIMP
 nsSimpleArrayEnumerator::HasMoreElements(bool* aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   if (!mValueArray) {
     *aResult = false;
     return NS_OK;
   }
@@ -62,17 +62,17 @@ nsSimpleArrayEnumerator::HasMoreElements
   }
   *aResult = (mIndex < cnt);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSimpleArrayEnumerator::GetNext(nsISupports** aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   if (!mValueArray) {
     *aResult = nullptr;
     return NS_OK;
   }
@@ -146,29 +146,29 @@ nsCOMArrayEnumerator::~nsCOMArrayEnumera
   for (; mIndex < mArraySize; ++mIndex) {
     NS_IF_RELEASE(mValueArray[mIndex]);
   }
 }
 
 NS_IMETHODIMP
 nsCOMArrayEnumerator::HasMoreElements(bool* aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   *aResult = (mIndex < mArraySize);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCOMArrayEnumerator::GetNext(nsISupports** aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   if (mIndex >= mArraySize) {
     return NS_ERROR_UNEXPECTED;
   }
 
--- a/xpcom/ds/nsEnumeratorUtils.cpp
+++ b/xpcom/ds/nsEnumeratorUtils.cpp
@@ -124,30 +124,30 @@ nsSingletonEnumerator::nsSingletonEnumer
 
 nsSingletonEnumerator::~nsSingletonEnumerator() = default;
 
 NS_IMPL_ISUPPORTS(nsSingletonEnumerator, nsISimpleEnumerator)
 
 NS_IMETHODIMP
 nsSingletonEnumerator::HasMoreElements(bool* aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   *aResult = !mConsumed;
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsSingletonEnumerator::GetNext(nsISupports** aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   if (mConsumed) {
     return NS_ERROR_UNEXPECTED;
   }
 
@@ -201,17 +201,17 @@ nsUnionEnumerator::nsUnionEnumerator(nsI
 
 nsUnionEnumerator::~nsUnionEnumerator() = default;
 
 NS_IMPL_ISUPPORTS(nsUnionEnumerator, nsISimpleEnumerator)
 
 NS_IMETHODIMP
 nsUnionEnumerator::HasMoreElements(bool* aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   nsresult rv;
 
   if (mConsumed) {
     *aResult = false;
@@ -243,17 +243,17 @@ nsUnionEnumerator::HasMoreElements(bool*
   *aResult = false;
   mConsumed = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsUnionEnumerator::GetNext(nsISupports** aResult)
 {
-  NS_PRECONDITION(aResult != 0, "null ptr");
+  MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
   if (mConsumed) {
     return NS_ERROR_UNEXPECTED;
   }
 
--- a/xpcom/ds/nsTObserverArray.cpp
+++ b/xpcom/ds/nsTObserverArray.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsTObserverArray.h"
 
 void
 nsTObserverArray_base::AdjustIterators(index_type aModPos,
                                        diff_type aAdjustment)
 {
-  NS_PRECONDITION(aAdjustment == -1 || aAdjustment == 1, "invalid adjustment");
+  MOZ_ASSERT(aAdjustment == -1 || aAdjustment == 1, "invalid adjustment");
   Iterator_base* iter = mIterators;
   while (iter) {
     if (iter->mPosition > aModPos) {
       iter->mPosition += aAdjustment;
     }
     iter = iter->mNext;
   }
 }
--- a/xpcom/io/nsBinaryStream.cpp
+++ b/xpcom/io/nsBinaryStream.cpp
@@ -706,17 +706,17 @@ struct WriteStringClosure
 static nsresult
 WriteSegmentToString(nsIInputStream* aStream,
                      void* aClosure,
                      const char* aFromSegment,
                      uint32_t aToOffset,
                      uint32_t aCount,
                      uint32_t* aWriteCount)
 {
-  NS_PRECONDITION(aCount > 0, "Why are we being told to write 0 bytes?");
+  MOZ_ASSERT(aCount > 0, "Why are we being told to write 0 bytes?");
   static_assert(sizeof(char16_t) == 2, "We can't handle other sizes!");
 
   WriteStringClosure* closure = static_cast<WriteStringClosure*>(aClosure);
   char16_t* cursor = closure->mWriteCursor;
 
   // we're always going to consume the whole buffer no matter what
   // happens, so take care of that right now.. that allows us to
   // tweak aCount later. Do NOT move this!
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -409,17 +409,17 @@ nsStringInputStream::Clone(nsIInputStrea
   return NS_OK;
 }
 
 nsresult
 NS_NewByteInputStream(nsIInputStream** aStreamResult,
                       const char* aStringToRead, int32_t aLength,
                       nsAssignmentType aAssignment)
 {
-  NS_PRECONDITION(aStreamResult, "null out ptr");
+  MOZ_ASSERT(aStreamResult, "null out ptr");
 
   RefPtr<nsStringInputStream> stream = new nsStringInputStream();
 
   nsresult rv;
   switch (aAssignment) {
     case NS_ASSIGNMENT_COPY:
       rv = stream->SetData(aStringToRead, aLength);
       break;
@@ -441,34 +441,34 @@ NS_NewByteInputStream(nsIInputStream** a
   stream.forget(aStreamResult);
   return NS_OK;
 }
 
 nsresult
 NS_NewCStringInputStream(nsIInputStream** aStreamResult,
                          const nsACString& aStringToRead)
 {
-  NS_PRECONDITION(aStreamResult, "null out ptr");
+  MOZ_ASSERT(aStreamResult, "null out ptr");
 
   RefPtr<nsStringInputStream> stream = new nsStringInputStream();
 
   nsresult rv = stream->SetData(aStringToRead);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   stream.forget(aStreamResult);
   return NS_OK;
 }
 
 nsresult
 NS_NewCStringInputStream(nsIInputStream** aStreamResult,
                          nsCString&& aStringToRead)
 {
-  NS_PRECONDITION(aStreamResult, "null out ptr");
+  MOZ_ASSERT(aStreamResult, "null out ptr");
 
   RefPtr<nsStringInputStream> stream = new nsStringInputStream();
 
   nsresult rv = stream->Init(Move(aStringToRead));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
--- a/xpfe/components/directory/nsDirectoryViewer.cpp
+++ b/xpfe/components/directory/nsDirectoryViewer.cpp
@@ -184,17 +184,17 @@ nsHTTPIndex::SetEncoding(const char *enc
 {
     mEncoding = encoding;
     return(NS_OK);
 }
 
 NS_IMETHODIMP
 nsHTTPIndex::GetEncoding(char **encoding)
 {
-  NS_PRECONDITION(encoding, "null ptr");
+  MOZ_ASSERT(encoding, "null ptr");
   if (! encoding)
     return(NS_ERROR_NULL_POINTER);
 
   *encoding = ToNewCString(mEncoding);
   if (!*encoding)
     return(NS_ERROR_OUT_OF_MEMORY);
 
   return(NS_OK);
@@ -614,17 +614,17 @@ nsHTTPIndex::Init()
 	return(NS_OK);
 }
 
 
 
 nsresult
 nsHTTPIndex::Init(nsIURI* aBaseURL)
 {
-  NS_PRECONDITION(aBaseURL != nullptr, "null ptr");
+  MOZ_ASSERT(aBaseURL != nullptr, "null ptr");
   if (! aBaseURL)
     return NS_ERROR_NULL_POINTER;
 
   nsresult rv;
 
   rv = CommonInit();
   if (NS_FAILED(rv))	return(rv);