Backed out 16 changesets (bug 1402519) for conflicts during merge r=backout on a CLOSED TREE
authorshindli <shindli@mozilla.com>
Thu, 23 Nov 2017 00:11:44 +0200
changeset 393180 ffc12802d5585e08de1a9ae4f2939e05bbea5767
parent 393179 019c7b6b48a1aaf3e05b05c49fda9917523c20cc
child 393233 c01eab6a9e8065c42b69ef4a5e9616cdb90bdace
push id97612
push usershindli@mozilla.com
push dateWed, 22 Nov 2017 22:12:09 +0000
treeherdermozilla-inbound@ffc12802d558 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1402519
milestone59.0a1
backs out07fcf163241abc77d8d78479eab3880bd6665ffa
c6d2ad45d8e278af877368f68e3872c363dfa4f7
8a3caca6129458a0839b7833b17971e91ff006af
01425eae2c487d4a06c63bfe8f9d37903085f7dc
cf298d3815defcd9464272f456b804e9c49b43aa
e1964f4389cd6897dafe96be88074b909f555b60
f405337f35698ea0b1ee5106f4593a5fa57a41b6
a76356fd33597807fc6e4c21d5308f8fd2eff01b
d3bb350d1c3429d1feb37a8a0b287055de531d4b
9d3bfd9f932c80c21f517da02981f565686f0e32
e3dd6e5b073f05e639ced9cb4e61b269f94e5411
e801b0c001346e17c845849f4769827c25bd49ec
8a4139fa5dcaf970dabc628f0230f54467f84d61
8d01c14ac1cae6a43244fae77527bf0ae1d414fd
24e0dcd018987af240baa09fd8d3112fae9913e3
f8fdf450613ff65c9574a172dfee97995349998a
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 16 changesets (bug 1402519) for conflicts during merge r=backout on a CLOSED TREE Backed out changeset 07fcf163241a (bug 1402519) Backed out changeset c6d2ad45d8e2 (bug 1402519) Backed out changeset 8a3caca61294 (bug 1402519) Backed out changeset 01425eae2c48 (bug 1402519) Backed out changeset cf298d3815de (bug 1402519) Backed out changeset e1964f4389cd (bug 1402519) Backed out changeset f405337f3569 (bug 1402519) Backed out changeset a76356fd3359 (bug 1402519) Backed out changeset d3bb350d1c34 (bug 1402519) Backed out changeset 9d3bfd9f932c (bug 1402519) Backed out changeset e3dd6e5b073f (bug 1402519) Backed out changeset e801b0c00134 (bug 1402519) Backed out changeset 8a4139fa5dca (bug 1402519) Backed out changeset 8d01c14ac1ca (bug 1402519) Backed out changeset 24e0dcd01898 (bug 1402519) Backed out changeset f8fdf450613f (bug 1402519)
accessible/base/nsAccessibilityService.cpp
accessible/windows/msaa/Compatibility.cpp
accessible/windows/msaa/LazyInstantiator.cpp
accessible/windows/msaa/LazyInstantiator.h
browser/base/content/test/general/browser_restore_isAppTab.js
docshell/base/nsDocShell.cpp
dom/base/nsDocument.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/ProcessHangMonitor.cpp
dom/ipc/TabChild.cpp
dom/ipc/TabMessageUtils.h
dom/media/gmp/GMPChild.cpp
dom/media/gmp/GMPParent.cpp
dom/media/gmp/GMPParent.h
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginsDirDarwin.cpp
dom/plugins/ipc/PluginMessageUtils.h
dom/plugins/ipc/PluginModuleChild.cpp
dom/plugins/ipc/PluginModuleParent.cpp
dom/plugins/ipc/PluginModuleParent.h
gfx/gl/GfxTexturesReporter.cpp
gfx/ipc/GPUChild.cpp
gfx/ipc/GPUParent.cpp
gfx/ipc/GPUProcessManager.cpp
gfx/src/DriverCrashGuard.cpp
gfx/src/gfxCrashReporterUtils.cpp
gfx/tests/gtest/TestGfxPrefs.cpp
gfx/thebes/DeviceManagerDx.cpp
gfx/thebes/gfxPlatform.cpp
ipc/glue/CrashReporterClient.cpp
ipc/glue/CrashReporterClient.h
ipc/glue/CrashReporterHost.cpp
ipc/glue/CrashReporterHost.h
ipc/glue/CrashReporterMetadataShmem.cpp
ipc/glue/CrashReporterMetadataShmem.h
ipc/glue/GeckoChildProcessHost.cpp
ipc/glue/IPCMessageUtils.h
ipc/glue/MessageChannel.cpp
ipc/glue/MessageLink.cpp
ipc/glue/ProtocolUtils.cpp
ipc/glue/ProtocolUtils.h
ipc/ipdl/ipdl/lower.py
ipc/mscom/COMPtrHolder.h
ipc/mscom/Interceptor.cpp
ipc/mscom/MainThreadRuntime.cpp
ipc/mscom/ProxyStream.cpp
ipc/mscom/RegistrationAnnotator.h
ipc/mscom/moz.build
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCShellImpl.cpp
layout/style/ServoBindings.cpp
layout/style/nsLayoutStylesheetCache.cpp
memory/gtest/TestJemalloc.cpp
mobile/android/chrome/content/browser.js
mobile/android/components/SessionStore.js
modules/libpref/Preferences.cpp
netwerk/ipc/NeckoMessageUtils.h
security/sandbox/linux/glue/SandboxCrash.cpp
storage/mozStorageService.cpp
testing/gtest/mozilla/GTestRunner.cpp
testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
toolkit/components/crashes/moz.build
toolkit/components/moz.build
toolkit/components/places/tests/gtest/places_test_harness_tail.h
toolkit/components/terminator/nsTerminator.cpp
toolkit/crashreporter/jar.mn
toolkit/crashreporter/moz.build
toolkit/crashreporter/nsDummyExceptionHandler.cpp
toolkit/crashreporter/nsExceptionHandler.cpp
toolkit/crashreporter/nsExceptionHandler.h
toolkit/crashreporter/nsExceptionHandlerUtils.cpp
toolkit/crashreporter/nsExceptionHandlerUtils.h
toolkit/moz.build
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
toolkit/xre/nsAndroidStartup.cpp
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsEmbedFunctions.cpp
toolkit/xre/nsX11ErrorHandler.cpp
widget/ContentCache.cpp
widget/ContentCache.h
widget/GfxInfoBase.cpp
widget/GfxInfoX11.cpp
widget/android/GfxInfo.cpp
widget/android/jni/Utils.cpp
widget/android/nsAppShell.cpp
widget/cocoa/GfxInfo.mm
widget/cocoa/nsChildView.mm
widget/nsBaseAppShell.cpp
widget/windows/GfxInfo.cpp
widget/windows/KeyboardLayout.cpp
widget/windows/moz.build
widget/windows/nsAppShell.cpp
xpcom/base/CycleCollectedJSContext.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/nsCrashOnException.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/base/nsDebugImpl.cpp
xpcom/base/nsObjCExceptions.h
xpcom/build/nsXULAppAPI.h
xpcom/system/moz.build
xpcom/tests/gtest/TestDeadlockDetector.cpp
xpcom/tests/gtest/TestPLDHash.cpp
xpcom/tests/gtest/TestSTLWrappers.cpp
xpcom/threads/HangMonitor.cpp
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
xpcom/threads/nsThreadUtils.cpp
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -48,17 +48,20 @@
 #include "HTMLWin32ObjectAccessible.h"
 #include "mozilla/StaticPtr.h"
 #endif
 
 #ifdef A11Y_LOG
 #include "Logging.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
+
 #include "nsImageFrame.h"
 #include "nsINamed.h"
 #include "nsIObserverService.h"
 #include "nsLayoutUtils.h"
 #include "nsPluginFrame.h"
 #include "SVGGeometryFrame.h"
 #include "nsTreeBodyFrame.h"
 #include "nsTreeColumns.h"
@@ -1361,19 +1364,21 @@ nsAccessibilityService::Init()
 #else
     gApplicationAccessible = new ApplicationAccessible();
 #endif // defined(XP_WIN)
   }
 
   NS_ADDREF(gApplicationAccessible); // will release in Shutdown()
   gApplicationAccessible->Init();
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporter::
     AnnotateCrashReport(NS_LITERAL_CSTRING("Accessibility"),
                         NS_LITERAL_CSTRING("Active"));
+#endif
 
 #ifdef XP_WIN
   sPendingPlugins = new nsTArray<nsCOMPtr<nsIContent> >;
   sPluginTimers = new nsTArray<nsCOMPtr<nsITimer> >;
 #endif
 
   // Now its safe to start platform accessibility.
   if (XRE_IsParentProcess())
--- a/accessible/windows/msaa/Compatibility.cpp
+++ b/accessible/windows/msaa/Compatibility.cpp
@@ -2,18 +2,20 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Compatibility.h"
 
 #include "mozilla/WindowsVersion.h"
+#if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
 #include "nsPrintfCString.h"
+#endif // defined(MOZ_CRASHREPORTER)
 #include "nsUnicharUtils.h"
 #include "nsWindowsDllInterceptor.h"
 #include "nsWinUtils.h"
 #include "Statistics.h"
 
 #include "mozilla/Preferences.h"
 
 #include <shlobj.h>
@@ -212,19 +214,21 @@ Compatibility::HasKnownNonUiaConsumer()
 }
 
 void
 Compatibility::Init()
 {
   // Note we collect some AT statistics/telemetry here for convenience.
   InitConsumers();
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporter::
     AnnotateCrashReport(NS_LITERAL_CSTRING("AccessibilityInProcClient"),
                         nsPrintfCString("0x%X", sConsumers));
+#endif
 
   // Gather telemetry
   uint32_t temp = sConsumers;
   for (int i = 0; temp; i++) {
     if (temp & 0x1)
       statistics::A11yConsumers(i);
 
     temp >>= 1;
@@ -402,21 +406,23 @@ UseIAccessibleProxyStub()
     return false;
   }
 
   // Otherwise we try the proxy/stub
   if (IsIAccessiblePSRegistered()) {
     return true;
   }
 
+#if defined(MOZ_CRASHREPORTER)
   // If we reach this point then something is seriously wrong with the
   // IAccessible configuration in the computer's registry. Let's annotate this
   // so that we can easily determine this condition during crash analysis.
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IAccessibleConfig"),
                                      NS_LITERAL_CSTRING("NoSystemTypeLibOrPS"));
+#endif // defined(MOZ_CRASHREPORTER)
   return false;
 }
 
 #endif // !defined(HAVE_64BIT_BUILD)
 
 uint16_t
 Compatibility::GetActCtxResourceId()
 {
--- a/accessible/windows/msaa/LazyInstantiator.cpp
+++ b/accessible/windows/msaa/LazyInstantiator.cpp
@@ -12,26 +12,29 @@
 #include "mozilla/a11y/Platform.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/mscom/MainThreadRuntime.h"
 #include "mozilla/mscom/Registration.h"
 #include "mozilla/UniquePtr.h"
 #include "nsAccessibilityService.h"
 #include "nsWindowsHelpers.h"
 #include "nsCOMPtr.h"
-#include "nsExceptionHandler.h"
 #include "nsIFile.h"
 #include "nsXPCOM.h"
 #include "RootAccessibleWrap.h"
 #include "WinUtils.h"
 
 #if defined(MOZ_TELEMETRY_REPORTING)
 #include "mozilla/Telemetry.h"
 #endif // defined(MOZ_TELEMETRY_REPORTING)
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #include <oaidl.h>
 
 #if !defined(STATE_SYSTEM_NORMAL)
 #define STATE_SYSTEM_NORMAL (0)
 #endif // !defined(STATE_SYSTEM_NORMAL)
 
 /**
  * Because our wrapped accessible is cycle-collected, we can't safely AddRef()
@@ -297,35 +300,35 @@ LazyInstantiator::ShouldInstantiate(cons
 
   // Store full path to executable for support purposes.
   nsAutoString filePath;
   nsresult rv = clientExe->GetPath(filePath);
   if (NS_SUCCEEDED(rv)) {
     a11y::SetInstantiator(filePath);
   }
 
-#if defined(MOZ_TELEMETRY_REPORTING)
+#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
   if (!mTelemetryThread) {
     // Call GatherTelemetry on a background thread because it does I/O on
     // the executable file to retrieve version information.
     nsCOMPtr<nsIRunnable> runnable(
         NewRunnableMethod<nsCOMPtr<nsIFile>, RefPtr<AccumulateRunnable>>(
                                              "LazyInstantiator::GatherTelemetry",
                                              this,
                                              &LazyInstantiator::GatherTelemetry,
                                              clientExe,
                                              new AccumulateRunnable(this)));
     NS_NewThread(getter_AddRefs(mTelemetryThread), runnable);
   }
-#endif // defined(MOZ_TELEMETRY_REPORTING)
+#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
 
   return true;
 }
 
-#if defined(MOZ_TELEMETRY_REPORTING)
+#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
 /**
  * Appends version information in the format "|a.b.c.d".
  * If there is no version information, we append nothing.
  */
 void
 LazyInstantiator::AppendVersionInfo(nsIFile* aClientExe,
                                     nsAString& aStrToAppend)
 {
@@ -398,27 +401,29 @@ LazyInstantiator::AccumulateTelemetry(co
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!aValue.IsEmpty()) {
 #if defined(MOZ_TELEMETRY_REPORTING)
     Telemetry::ScalarSet(Telemetry::ScalarID::A11Y_INSTANTIATORS,
                          aValue);
 #endif // defined(MOZ_TELEMETRY_REPORTING)
+#if defined(MOZ_CRASHREPORTER)
     CrashReporter::
       AnnotateCrashReport(NS_LITERAL_CSTRING("AccessibilityClient"),
                           NS_ConvertUTF16toUTF8(aValue));
+#endif // defined(MOZ_CRASHREPORTER)
   }
 
   if (mTelemetryThread) {
     mTelemetryThread->Shutdown();
     mTelemetryThread = nullptr;
   }
 }
-#endif // defined(MOZ_TELEMETRY_REPORTING)
+#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
 
 RootAccessibleWrap*
 LazyInstantiator::ResolveRootAccWrap()
 {
   Accessible* acc = widget::WinUtils::GetRootAccessibleForHWND(mHwnd);
   if (!acc || !acc->IsRoot()) {
     return nullptr;
   }
--- a/accessible/windows/msaa/LazyInstantiator.h
+++ b/accessible/windows/msaa/LazyInstantiator.h
@@ -82,17 +82,17 @@ public:
 private:
   explicit LazyInstantiator(HWND aHwnd);
   ~LazyInstantiator();
 
   bool IsBlockedInjection();
   bool ShouldInstantiate(const DWORD aClientTid);
 
   bool GetClientExecutableName(const DWORD aClientTid, nsIFile** aOutClientExe);
-#if defined(MOZ_TELEMETRY_REPORTING)
+#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
   class AccumulateRunnable final : public Runnable
   {
   public:
     explicit AccumulateRunnable(LazyInstantiator* aObj)
       : Runnable("mozilla::a11y::LazyInstantiator::AccumulateRunnable")
       , mObj(aObj)
     {
       MOZ_ASSERT(NS_IsMainThread());
@@ -115,17 +115,17 @@ private:
     nsString                              mData;
   };
 
   friend class AccumulateRunnable;
 
   void AppendVersionInfo(nsIFile* aClientExe, nsAString& aStrToAppend);
   void GatherTelemetry(nsIFile* aClientExe, AccumulateRunnable* aRunnable);
   void AccumulateTelemetry(const nsString& aValue);
-#endif // defined(MOZ_TELEMETRY_REPORTING)
+#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
 
   /**
    * @return S_OK if we have a valid mRealRoot to invoke methods on
    */
   HRESULT MaybeResolveRoot();
 
   /**
    * @return S_OK if we have a valid mWeakDispatch to invoke methods on
@@ -147,18 +147,18 @@ private:
    * are interfaces that come from objects that we aggregate. Aggregated object
    * interfaces share refcount methods with ours, so if we were to hold strong
    * references to them, we would be holding strong references to ourselves,
    * creating a cycle.
    */
   RootAccessibleWrap* mWeakRootAccWrap;
   IAccessible*        mWeakAccessible;
   IDispatch*          mWeakDispatch;
-#if defined(MOZ_TELEMETRY_REPORTING)
+#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
   nsCOMPtr<nsIThread> mTelemetryThread;
-#endif // defined(MOZ_TELEMETRY_REPORTING)
+#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER)
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif // mozilla_a11y_LazyInstantiator_h
 
--- a/browser/base/content/test/general/browser_restore_isAppTab.js
+++ b/browser/base/content/test/general/browser_restore_isAppTab.js
@@ -81,19 +81,18 @@ add_task(async function navigate() {
   loadFrameScript(browser);
   isAppTab = await isBrowserAppTab(browser);
   ok(isAppTab, "Docshell should think it is an app tab");
 
   gBrowser.removeCurrentTab();
 });
 
 add_task(async function crash() {
-  if (!gMultiProcessBrowser || !AppConstants.MOZ_CRASHREPORTER) {
+  if (!gMultiProcessBrowser || !("nsICrashReporter" in Ci))
     return;
-  }
 
   let tab = BrowserTestUtils.addTab(gBrowser, DUMMY);
   let browser = tab.linkedBrowser;
   gBrowser.selectedTab = tab;
   await BrowserTestUtils.browserStopped(gBrowser);
   loadFrameScript(browser);
   let isAppTab = await isBrowserAppTab(browser);
   ok(!isAppTab, "Docshell shouldn't think it is an app tab");
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -2419,20 +2419,22 @@ nsDocShell::GetUseRemoteTabs(bool* aUseR
 
   *aUseRemoteTabs = mUseRemoteTabs;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetRemoteTabs(bool aUseRemoteTabs)
 {
+#ifdef MOZ_CRASHREPORTER
   if (aUseRemoteTabs) {
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("DOMIPCEnabled"),
                                        NS_LITERAL_CSTRING("1"));
   }
+#endif
 
   mUseRemoteTabs = aUseRemoteTabs;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime)
 {
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -7931,17 +7931,17 @@ StyleDataTypesWithNode(nsINode* aNode)
 static void
 CheckCrossStyleBackendAdoption(nsIDocument* aOldDoc,
                                nsIDocument* aNewDoc, nsINode* aAdoptedNode)
 {
   EnumSet<StyleDataType> styleDataTypes = StyleDataTypesWithNode(aAdoptedNode);
   if (styleDataTypes.isEmpty()) {
     return;
   }
-
+#ifdef MOZ_CRASHREPORTER
   // We are adopting node with pre-existing style data across style
   // backend. We want some more information to help diagnose when that
   // can happen.
   nsAutoCString note;
   nsIDocument* geckoDoc;
   if (aOldDoc->GetStyleBackendType() == StyleBackendType::Servo) {
     note.AppendLiteral("Servo -> Gecko");
     geckoDoc = aNewDoc;
@@ -7996,17 +7996,17 @@ CheckCrossStyleBackendAdoption(nsIDocume
       nsAutoCString scheme;
       geckoURI->GetScheme(scheme);
       note.Append(scheme);
       note.AppendLiteral(": (omitted)");
     }
   }
   note.Append('\n');
   CrashReporter::AppendAppNotesToCrashReport(note);
-
+#endif // MOZ_CRASHREPORTER
   MOZ_CRASH("Must not adopt a node with pre-existing style data "
             "into a document with different style backend");
 }
 
 nsINode*
 nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
 {
   nsINode* adoptedNode = &aAdoptedNode;
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -209,31 +209,33 @@
 #include "ClearOnShutdown.h"
 #include "ProcessUtils.h"
 #include "URIUtils.h"
 #include "nsContentUtils.h"
 #include "nsIPrincipal.h"
 #include "DomainPolicy.h"
 #include "mozilla/dom/ipc/StructuredCloneData.h"
 #include "mozilla/dom/time/DateCacheCleaner.h"
-#include "mozilla/ipc/CrashReporterClient.h"
 #include "mozilla/net/NeckoMessageUtils.h"
 #include "mozilla/widget/PuppetBidiKeyboard.h"
 #include "mozilla/RemoteSpellCheckEngineChild.h"
 #include "GMPServiceChild.h"
 #include "GfxInfoBase.h"
 #include "gfxPlatform.h"
 #include "nscore.h" // for NS_FREE_PERMANENT_DATA
 #include "VRManagerChild.h"
 #include "private/pprio.h"
 #include "nsString.h"
 
 #ifdef MOZ_WIDGET_GTK
 #include "nsAppRunner.h"
 #endif
+#ifdef MOZ_CRASHREPORTER
+#include "mozilla/ipc/CrashReporterClient.h"
+#endif
 
 #ifdef MOZ_CODE_COVERAGE
 #include "mozilla/CodeCoverageHandler.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::docshell;
 using namespace mozilla::dom::ipc;
@@ -642,17 +644,19 @@ ContentChild::Init(MessageLoop* aIOLoop,
   if (!gfxPlatform::IsHeadless()) {
     // Send the parent our X socket to act as a proxy reference for our X
     // resources.
     int xSocketFd = ConnectionNumber(DefaultXDisplay());
     SendBackUpXResources(FileDescriptor(xSocketFd));
   }
 #endif
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporterClient::InitSingleton(this);
+#endif
 
   mID = aChildID;
   mIsForBrowser = aIsForBrowser;
 
 #ifdef NS_PRINTING
   // Force the creation of the nsPrintingProxy so that it's IPC counterpart,
   // PrintingParent, is always available for printing initiated from the parent.
   RefPtr<nsPrintingProxy> printingProxy = nsPrintingProxy::GetInstance();
@@ -1692,28 +1696,30 @@ ContentChild::RecvSetProcessSandbox(cons
                                               syscallWhitelist);
   }
 #elif defined(XP_WIN)
   mozilla::SandboxTarget::Instance()->StartSandbox();
 #elif defined(XP_MACOSX)
   sandboxEnabled = StartMacOSContentSandbox();
 #endif
 
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("ContentSandboxEnabled"),
     sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
 #if defined(XP_LINUX) && !defined(OS_ANDROID)
   nsAutoCString flagsString;
   flagsString.AppendInt(SandboxInfo::Get().AsInteger());
 
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
 #endif /* XP_LINUX && !OS_ANDROID */
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("RemoteType"),
                                      NS_ConvertUTF16toUTF8(GetRemoteType()));
+#endif /* MOZ_CRASHREPORTER */
 #endif /* MOZ_CONTENT_SANDBOX */
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL,
                                      const bool& aHaveBidiKeyboards)
@@ -2338,18 +2344,19 @@ ContentChild::ActorDestroy(ActorDestroyR
 
   nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
   if (svc) {
     svc->UnregisterListener(mConsoleListener);
     mConsoleListener->mChild = nullptr;
   }
   mIsAlive = false;
 
+# ifdef MOZ_CRASHREPORTER
   CrashReporterClient::DestroySingleton();
-
+# endif
   XRE_ShutdownChildProcess();
 #endif // NS_FREE_PERMANENT_DATA
 }
 
 void
 ContentChild::ProcessingError(Result aCode, const char* aReason)
 {
   switch (aCode) {
@@ -2364,19 +2371,20 @@ ContentChild::ProcessingError(Result aCo
     case MsgRouteError:
     case MsgValueError:
       break;
 
     default:
       MOZ_CRASH("not reached");
   }
 
+#if defined(MOZ_CRASHREPORTER)
   nsDependentCString reason(aReason);
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ipc_channel_error"), reason);
-
+#endif
   MOZ_CRASH("Content child abort due to IPC error");
 }
 
 nsresult
 ContentChild::AddRemoteAlertObserver(const nsString& aData,
                                      nsIObserver* aObserver)
 {
   NS_ASSERTION(aObserver, "Adding a null observer?");
@@ -2947,19 +2955,20 @@ ContentChild::ForceKillTimerCallback(nsI
 
 mozilla::ipc::IPCResult
 ContentChild::RecvShutdown()
 {
   // If we receive the shutdown message from within a nested event loop, we want
   // to wait for that event loop to finish. Otherwise we could prematurely
   // terminate an "unload" or "pagehide" event handler (which might be doing a
   // sync XHR, for example).
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
                                      NS_LITERAL_CSTRING("RecvShutdown"));
-
+#endif
   MOZ_ASSERT(NS_IsMainThread());
   RefPtr<nsThread> mainThread = nsThreadManager::get().GetCurrentThread();
   // Note that we only have to check the recursion count for the current
   // cooperative thread. Since the Shutdown message is not labeled with a
   // SchedulerGroup, there can be no other cooperative threads doing work while
   // we're running.
   if (mainThread && mainThread->RecursionDepth() > 1) {
     // We're in a nested event loop. Let's delay for an arbitrary period of
@@ -3005,23 +3014,28 @@ ContentChild::RecvShutdown()
   }
 #endif
 
   // Start a timer that will insure we quickly exit after a reasonable
   // period of time. Prevents shutdown hangs after our connection to the
   // parent closes.
   StartForceKillTimer();
 
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
                                      NS_LITERAL_CSTRING("SendFinishShutdown (sending)"));
   bool sent = SendFinishShutdown();
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
                                      sent ? NS_LITERAL_CSTRING("SendFinishShutdown (sent)")
                                           : NS_LITERAL_CSTRING("SendFinishShutdown (failed)"));
-
+#else
+  // Ignore errors here. If this fails, the parent will kill us after a
+  // timeout.
+  Unused << SendFinishShutdown();
+#endif
   return IPC_OK();
 }
 
 PBrowserOrId
 ContentChild::GetBrowserOrId(TabChild* aTabChild)
 {
   if (!aTabChild ||
     this == aTabChild->Manager()) {
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -62,17 +62,16 @@
 #include "mozilla/dom/URLClassifierParent.h"
 #include "mozilla/embedding/printingui/PrintingParent.h"
 #include "mozilla/extensions/StreamFilterParent.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/GPUProcessManager.h"
 #include "mozilla/hal_sandbox/PHalParent.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
-#include "mozilla/ipc/CrashReporterHost.h"
 #include "mozilla/ipc/FileDescriptorUtils.h"
 #include "mozilla/ipc/PChildToParentStreamParent.h"
 #include "mozilla/ipc/TestShellParent.h"
 #include "mozilla/ipc/IPCStreamUtils.h"
 #include "mozilla/intl/LocaleService.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "mozilla/layers/PAPZParent.h"
 #include "mozilla/layers/CompositorThread.h"
@@ -146,17 +145,16 @@
 #include "nsISupportsPrimitives.h"
 #include "nsITimer.h"
 #include "nsIURIFixup.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIXULWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIWindowWatcher.h"
 #include "nsPIWindowWatcher.h"
-#include "nsThread.h"
 #include "nsWindowWatcher.h"
 #include "nsIXULRuntime.h"
 #include "mozilla/dom/nsMixedContentBlocker.h"
 #include "nsMemoryInfoDumper.h"
 #include "nsMemoryReporterManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStyleSheetService.h"
 #include "nsThreadUtils.h"
@@ -245,16 +243,21 @@
 #include "nsIBrowserSearchService.h"
 #endif
 
 #ifdef XP_WIN
 #include "mozilla/audio/AudioNotificationSender.h"
 #include "mozilla/widget/AudioSession.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsThread.h"
+#include "mozilla/ipc/CrashReporterHost.h"
+#endif
+
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 
 #ifdef MOZ_GECKO_PROFILER
 #include "nsIProfiler.h"
 #include "ProfilerParent.h"
 #endif
@@ -265,17 +268,19 @@
 
 // For VP9Benchmark::sBenchmarkFpsPref
 #include "Benchmark.h"
 
 static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
 
 using base::KillProcess;
 
+#ifdef MOZ_CRASHREPORTER
 using namespace CrashReporter;
+#endif
 using namespace mozilla::dom::power;
 using namespace mozilla::media;
 using namespace mozilla::embedding;
 using namespace mozilla::gfx;
 using namespace mozilla::gmp;
 using namespace mozilla::hal;
 using namespace mozilla::ipc;
 using namespace mozilla::intl;
@@ -1720,32 +1725,34 @@ ContentParent::ActorDestroy(ActorDestroy
     props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
 
     if (AbnormalShutdown == why) {
       Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
                             NS_LITERAL_CSTRING("content"), 1);
 
       props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true);
 
+#ifdef MOZ_CRASHREPORTER
       // There's a window in which child processes can crash
       // after IPC is established, but before a crash reporter
       // is created.
       if (mCrashReporter) {
         // if mCreatedPairedMinidumps is true, we've already generated
         // parent/child dumps for desktop crashes.
         if (!mCreatedPairedMinidumps) {
           mCrashReporter->GenerateCrashReport(OtherPid());
         }
 
         nsAutoString dumpID;
         if (mCrashReporter->HasMinidump()) {
           dumpID = mCrashReporter->MinidumpID();
         }
         props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID);
       }
+#endif
     }
     nsAutoString cpId;
     cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
     obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", cpId.get());
   }
 
   // Remove any and all idle listeners.
   nsCOMPtr<nsIIdleService> idleService =
@@ -3048,16 +3055,17 @@ ContentParent::KillHard(const char* aRea
   // process handle becomes invalid on the first call, causing a second call
   // to crash our process - more details in bug 890840.
   if (mCalledKillHard) {
     return;
   }
   mCalledKillHard = true;
   mForceKillTimer = nullptr;
 
+#if defined(MOZ_CRASHREPORTER)
   // We're about to kill the child process associated with this content.
   // Something has gone wrong to get us here, so we generate a minidump
   // of the parent and child for submission to the crash server.
   if (mCrashReporter) {
     // GeneratePairedMinidump creates two minidumps for us - the main
     // one is for the content process we're about to kill, and the other
     // one is for the main browser process. That second one is the extra
     // minidump tagging along, so we have to tell the crash reporter that
@@ -3080,27 +3088,29 @@ ContentParent::KillHard(const char* aRea
     // Generate the report and insert into the queue for submittal.
     mCrashReporter->GenerateMinidumpAndPair(Process(),
                                             nullptr,
                                             NS_LITERAL_CSTRING("browser"),
                                             Move(callback),
                                             true);
     return;
   }
-
+#endif
   OnGenerateMinidumpComplete(false);
 }
 
 void
 ContentParent::OnGenerateMinidumpComplete(bool aDumpResult)
 {
+#if defined(MOZ_CRASHREPORTER)
   if (mCrashReporter && aDumpResult) {
     // CrashReporterHost::GenerateMinidumpAndPair() is successful.
     mCreatedPairedMinidumps = mCrashReporter->FinalizeCrashReport();
   }
+#endif
 
   Unused << aDumpResult; // Don't care about result if no minidump was requested.
 
   ProcessHandle otherProcessHandle;
   if (!base::OpenProcessHandle(OtherPid(), &otherProcessHandle)) {
     NS_ERROR("Failed to open child process when attempting kill.");
     return;
   }
@@ -3131,21 +3141,22 @@ ContentParent::FriendlyName(nsAString& a
   } else {
     aName.AssignLiteral("???");
   }
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId)
 {
+#ifdef MOZ_CRASHREPORTER
   mCrashReporter = MakeUnique<CrashReporterHost>(
     GeckoProcessType_Content,
     aShmem,
     aThreadId);
-
+#endif
   return IPC_OK();
 }
 
 hal_sandbox::PHalParent*
 ContentParent::AllocPHalParent()
 {
   return hal_sandbox::CreateHalParent();
 }
@@ -4931,17 +4942,19 @@ ContentParent::RecvNotifyPushSubscriptio
 
 mozilla::ipc::IPCResult
 ContentParent::RecvNotifyLowMemory()
 {
   MarkAsTroubled();
 
   Telemetry::ScalarAdd(Telemetry::ScalarID::DOM_CONTENTPROCESS_TROUBLED_DUE_TO_MEMORY, 1);
 
+#ifdef MOZ_CRASHREPORTER
   nsThread::SaveMemoryReportNearOOM(nsThread::ShouldSaveMemoryReport::kForceReport);
+#endif
 
   return IPC_OK();
 }
 
 /* static */ void
 ContentParent::BroadcastBlobURLRegistration(const nsACString& aURI,
                                             BlobImpl* aBlobImpl,
                                             nsIPrincipal* aPrincipal,
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -1278,18 +1278,19 @@ private:
 
   // This hashtable is used to run GetFilesHelper objects in the parent process.
   // GetFilesHelper can be aborted by receiving RecvDeleteGetFilesRequest.
   nsRefPtrHashtable<nsIDHashKey, GetFilesHelper> mGetFilesPendingRequests;
 
   nsTHashtable<nsCStringHashKey> mActivePermissionKeys;
 
   nsTArray<nsCString> mBlobURLs;
-
+#ifdef MOZ_CRASHREPORTER
   UniquePtr<mozilla::ipc::CrashReporterHost> mCrashReporter;
+#endif
 
   static uint64_t sNextTabParentId;
   static nsDataHashtable<nsUint64HashKey, TabParent*> sNextTabParents;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -18,22 +18,24 @@
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/ipc/TaskFactory.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/plugins/PluginBridge.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Unused.h"
 #include "mozilla/WeakPtr.h"
 
-#include "nsExceptionHandler.h"
 #include "nsIFrameLoader.h"
 #include "nsIHangReport.h"
 #include "nsITabParent.h"
 #include "nsPluginHost.h"
 #include "nsThreadUtils.h"
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
 
 #include "base/task.h"
 #include "base/thread.h"
 
 #ifdef XP_WIN
 // For IsDebuggerPresent()
 #include <windows.h>
 #endif
@@ -603,24 +605,26 @@ HangMonitorParent::HangMonitorParent(Pro
     sInited = true;
     Preferences::AddBoolVarCache(&sShouldForcePaint,
                                  "browser.tabs.remote.force-paint", true);
   }
 }
 
 HangMonitorParent::~HangMonitorParent()
 {
+#ifdef MOZ_CRASHREPORTER
   MutexAutoLock lock(mBrowserCrashDumpHashLock);
 
   for (auto iter = mBrowserCrashDumpIds.Iter(); !iter.Done(); iter.Next()) {
     nsString crashId = iter.UserData();
     if (!crashId.IsEmpty()) {
       CrashReporter::DeleteMinidumpFilesForID(crashId);
     }
   }
+#endif
 }
 
 void
 HangMonitorParent::Shutdown()
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   MonitorAutoLock lock(mMonitor);
@@ -763,31 +767,33 @@ HangMonitorParent::ClearHangNotification
 
 // Take a minidump of the browser process if one wasn't already taken for the
 // plugin that caused the hang. Return false if a dump was already available or
 // true if new one has been taken.
 bool
 HangMonitorParent::TakeBrowserMinidump(const PluginHangData& aPhd,
                                        nsString& aCrashId)
 {
+#ifdef MOZ_CRASHREPORTER
   MutexAutoLock lock(mBrowserCrashDumpHashLock);
   if (!mBrowserCrashDumpIds.Get(aPhd.pluginId(), &aCrashId)) {
     nsCOMPtr<nsIFile> browserDump;
     if (CrashReporter::TakeMinidump(getter_AddRefs(browserDump), true)) {
       if (!CrashReporter::GetIDFromMinidump(browserDump, aCrashId)
           || aCrashId.IsEmpty()) {
         browserDump->Remove(false);
         NS_WARNING("Failed to generate timely browser stack, "
                    "this is bad for plugin hang analysis!");
       } else {
         mBrowserCrashDumpIds.Put(aPhd.pluginId(), aCrashId);
         return true;
       }
     }
   }
+#endif // MOZ_CRASHREPORTER
 
   return false;
 }
 
 mozilla::ipc::IPCResult
 HangMonitorParent::RecvHangEvidence(const HangData& aHangData)
 {
   // chrome process, background thread
@@ -880,20 +886,21 @@ void
 HangMonitorParent::CleanupPluginHang(uint32_t aPluginId, bool aRemoveFiles)
 {
   MutexAutoLock lock(mBrowserCrashDumpHashLock);
   nsAutoString crashId;
   if (!mBrowserCrashDumpIds.Get(aPluginId, &crashId)) {
     return;
   }
   mBrowserCrashDumpIds.Remove(aPluginId);
-
+#ifdef MOZ_CRASHREPORTER
   if (aRemoveFiles && !crashId.IsEmpty()) {
     CrashReporter::DeleteMinidumpFilesForID(crashId);
   }
+#endif
 }
 
 void
 HangMonitorParent::UpdateMinidump(uint32_t aPluginId, const nsString& aDumpId)
 {
   if (aDumpId.IsEmpty()) {
     return;
   }
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -54,17 +54,19 @@
 #include "mozilla/TouchEvents.h"
 #include "mozilla/Unused.h"
 #include "nsContentUtils.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsDocShell.h"
 #include "nsEmbedCID.h"
 #include "nsGlobalWindow.h"
 #include <algorithm>
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 #include "nsFilePickerProxy.h"
 #include "mozilla/dom/Element.h"
 #include "nsGlobalWindow.h"
 #include "nsIBaseWindow.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsIDocumentInlines.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDOMChromeWindow.h"
@@ -1187,17 +1189,19 @@ TabChild::RecvLoadURL(const nsCString& a
     WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI).get(),
                              nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
                              nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL,
                              nullptr, nullptr, nullptr, nsContentUtils::GetSystemPrincipal());
   if (NS_FAILED(rv)) {
       NS_WARNING("WebNavigation()->LoadURI failed. Eating exception, what else can I do?");
   }
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), aURI);
+#endif
 
   return IPC_OK();
 }
 
 void
 TabChild::DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
                      const uint64_t& aLayersId,
                      const CompositorOptions& aCompositorOptions,
--- a/dom/ipc/TabMessageUtils.h
+++ b/dom/ipc/TabMessageUtils.h
@@ -3,33 +3,41 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TABMESSAGE_UTILS_H
 #define TABMESSAGE_UTILS_H
 
 #include "ipc/IPCMessageUtils.h"
-#include "nsExceptionHandler.h"
 #include "nsIDOMEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsCOMPtr.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 namespace mozilla {
 namespace dom {
 struct RemoteDOMEvent
 {
   // Make sure to set the owner after deserializing.
   nsCOMPtr<nsIDOMEvent> mEvent;
 };
 
 bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter,
                      mozilla::dom::RemoteDOMEvent* aResult);
 
+#ifdef MOZ_CRASHREPORTER
 typedef CrashReporter::ThreadId NativeThreadId;
+#else
+// unused in this case
+typedef int32_t NativeThreadId;
+#endif
 
 } // namespace dom
 } // namespace mozilla
 
 namespace IPC {
 
 template<>
 struct ParamTraits<mozilla::dom::RemoteDOMEvent>
--- a/dom/media/gmp/GMPChild.cpp
+++ b/dom/media/gmp/GMPChild.cpp
@@ -241,17 +241,19 @@ GMPChild::Init(const nsAString& aPluginP
                IPC::Channel* aChannel)
 {
   LOGD("%s pluginPath=%s", __FUNCTION__, NS_ConvertUTF16toUTF8(aPluginPath).get());
 
   if (NS_WARN_IF(!Open(aChannel, aParentPid, aIOLoop))) {
     return false;
   }
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporterClient::InitSingleton(this);
+#endif
 
   mPluginPath = aPluginPath;
 
   return true;
 }
 
 GMPErr
 GMPChild::GetAPI(const char* aAPIName,
@@ -610,18 +612,19 @@ GMPChild::ActorDestroy(ActorDestroyReaso
   if (mGMPLoader) {
     mGMPLoader->Shutdown();
   }
   if (AbnormalShutdown == aWhy) {
     NS_WARNING("Abnormal shutdown of GMP process!");
     ProcessChild::QuickExit();
   }
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporterClient::DestroySingleton();
-
+#endif
   XRE_ShutdownChildProcess();
 }
 
 void
 GMPChild::ProcessingError(Result aCode, const char* aReason)
 {
   switch (aCode) {
     case MsgDropped:
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -2,41 +2,43 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GMPParent.h"
 #include "mozilla/Logging.h"
 #include "nsComponentManagerUtils.h"
 #include "nsComponentManagerUtils.h"
-#include "nsPrintfCString.h"
 #include "nsThreadUtils.h"
 #include "nsIRunnable.h"
 #include "nsIWritablePropertyBag2.h"
 #include "mozIGeckoMediaPluginService.h"
 #include "mozilla/AbstractThread.h"
-#include "mozilla/ipc/CrashReporterHost.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 #include "mozilla/SSE.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/Unused.h"
 #include "nsIObserverService.h"
 #include "GMPTimerParent.h"
 #include "runnable_utils.h"
 #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
 #include "mozilla/SandboxInfo.h"
 #endif
 #include "GMPContentParent.h"
 #include "MediaPrefs.h"
 #include "VideoUtils.h"
 
 using mozilla::ipc::GeckoChildProcessHost;
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsPrintfCString.h"
+#include "mozilla/ipc/CrashReporterHost.h"
 using CrashReporter::AnnotationTable;
 using CrashReporter::GetIDFromMinidump;
+#endif
 
 #include "mozilla/Telemetry.h"
 
 #ifdef XP_WIN
 #include "WMFDecoderModule.h"
 #endif
 
 #include "mozilla/dom/WidevineCDMManifestBinding.h"
@@ -445,16 +447,17 @@ GMPParent::EnsureProcessLoaded()
     return false;
   }
 
   nsresult rv = LoadProcess();
 
   return NS_SUCCEEDED(rv);
 }
 
+#ifdef MOZ_CRASHREPORTER
 void
 GMPParent::WriteExtraDataForMinidump()
 {
   mCrashReporter->AddNote(NS_LITERAL_CSTRING("GMPPlugin"), NS_LITERAL_CSTRING("1"));
   mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginFilename"), NS_ConvertUTF16toUTF8(mName));
   mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginName"), mDisplayName);
   mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginVersion"), mVersion);
 }
@@ -489,39 +492,39 @@ GMPNotifyObservers(const uint32_t aPlugi
   }
 
   RefPtr<gmp::GeckoMediaPluginService> service =
     gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
   if (service) {
     service->RunPluginCrashCallbacks(aPluginID, aPluginName);
   }
 }
-
+#endif
 void
 GMPParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   LOGD("%s: (%d)", __FUNCTION__, (int)aWhy);
-
+#ifdef MOZ_CRASHREPORTER
   if (AbnormalShutdown == aWhy) {
     Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
                           NS_LITERAL_CSTRING("gmplugin"), 1);
     nsString dumpID;
     if (!GetCrashID(dumpID)) {
       NS_WARNING("GMP crash without crash report");
       dumpID = mName;
       dumpID += '-';
       AppendUTF8toUTF16(mVersion, dumpID);
     }
 
     // NotifyObservers is mainthread-only
     nsCOMPtr<nsIRunnable> r = WrapRunnableNM(
       &GMPNotifyObservers, mPluginId, mDisplayName, dumpID);
     mMainThread->Dispatch(r.forget());
   }
-
+#endif
   // warn us off trying to close again
   mState = GMPStateClosing;
   mAbnormalShutdownInProgress = true;
   CloseActive(false);
 
   // Normal Shutdown() will delete the process on unwind.
   if (AbnormalShutdown == aWhy) {
     RefPtr<GMPParent> self(this);
@@ -532,21 +535,22 @@ GMPParent::ActorDestroy(ActorDestroyReas
     // Note: final destruction will be Dispatched to ourself
     mService->ReAddOnGMPThread(self);
   }
 }
 
 mozilla::ipc::IPCResult
 GMPParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId)
 {
+#ifdef MOZ_CRASHREPORTER
   mCrashReporter = MakeUnique<ipc::CrashReporterHost>(
     GeckoProcessType_GMPlugin,
     aShmem,
     aThreadId);
-
+#endif
   return IPC_OK();
 }
 
 PGMPStorageParent*
 GMPParent::AllocPGMPStorageParent()
 {
   GMPStorageParent* p = new GMPStorageParent(mNodeId, this);
   mStorage.AppendElement(p); // Addrefs, released in DeallocPGMPStorageParent.
--- a/dom/media/gmp/GMPParent.h
+++ b/dom/media/gmp/GMPParent.h
@@ -148,18 +148,20 @@ private:
   ~GMPParent();
 
   RefPtr<GeckoMediaPluginServiceParent> mService;
   bool EnsureProcessLoaded();
   RefPtr<GenericPromise> ReadGMPMetaData();
   RefPtr<GenericPromise> ReadGMPInfoFile(nsIFile* aFile);
   RefPtr<GenericPromise> ParseChromiumManifest(const nsAString& aJSON); // Main thread.
   RefPtr<GenericPromise> ReadChromiumManifestFile(nsIFile* aFile); // GMP thread.
+#ifdef MOZ_CRASHREPORTER
   void WriteExtraDataForMinidump();
   bool GetCrashID(nsString& aResult);
+#endif
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
   mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override;
 
   mozilla::ipc::IPCResult RecvPGMPStorageConstructor(PGMPStorageParent* actor) override;
   PGMPStorageParent* AllocPGMPStorageParent() override;
   bool DeallocPGMPStorageParent(PGMPStorageParent* aActor) override;
 
@@ -210,17 +212,19 @@ private:
   int mChildPid;
 
   // We hold a self reference to ourself while the child process is alive.
   // This ensures that if the GMPService tries to shut us down and drops
   // its reference to us, we stay alive long enough for the child process
   // to terminate gracefully.
   bool mHoldingSelfRef;
 
+#ifdef MOZ_CRASHREPORTER
   UniquePtr<ipc::CrashReporterHost> mCrashReporter;
+#endif
 
   const RefPtr<AbstractThread> mMainThread;
 };
 
 } // namespace gmp
 } // namespace mozilla
 
 #endif // GMPParent_h_
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -6,17 +6,16 @@
 /* nsPluginHost.cpp - top-level plugin management code */
 
 #include "nscore.h"
 #include "nsPluginHost.h"
 
 #include <cstdlib>
 #include <stdio.h>
 #include "prio.h"
-#include "nsExceptionHandler.h"
 #include "nsNPAPIPlugin.h"
 #include "nsNPAPIPluginStreamListener.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsPluginInstanceOwner.h"
 #include "nsObjectLoadingContent.h"
 #include "nsIHTTPHeaderListener.h"
 #include "nsIHttpHeaderVisitor.h"
 #include "nsIObserverService.h"
@@ -99,16 +98,20 @@
 
 #if defined(XP_WIN)
 #include "nsIWindowMediator.h"
 #include "nsIBaseWindow.h"
 #include "windows.h"
 #include "winbase.h"
 #endif
 
+#if MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #include "npapi.h"
 
 using namespace mozilla;
 using mozilla::TimeStamp;
 using mozilla::plugins::FakePluginTag;
 using mozilla::plugins::PluginTag;
 using mozilla::dom::FakePluginTagInit;
 using mozilla::dom::FakePluginMimeEntry;
--- a/dom/plugins/base/nsPluginsDirDarwin.cpp
+++ b/dom/plugins/base/nsPluginsDirDarwin.cpp
@@ -21,17 +21,19 @@
 #include "nsPluginsDir.h"
 #include "nsNPAPIPlugin.h"
 #include "nsPluginsDirUtils.h"
 
 #include "nsILocalFileMac.h"
 #include "mozilla/UniquePtr.h"
 
 #include "nsCocoaFeatures.h"
+#if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
+#endif
 
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
 
 #include <Carbon/Carbon.h>
 #include <CoreServices/CoreServices.h>
@@ -417,40 +419,41 @@ nsresult nsPluginFile::GetPluginInfo(nsP
     if (fileName.EqualsLiteral("fbplugin") ||
         StringBeginsWith(fileName, NS_LITERAL_CSTRING("fbplugin_"))) {
       nsAutoCString msg;
       msg.AppendPrintf("Preventing load of %s (see bug 1086977)",
                        fileName.get());
       NS_WARNING(msg.get());
       return NS_ERROR_FAILURE;
     }
-
+#if defined(MOZ_CRASHREPORTER)
     // The block above assumes that "fbplugin" is the filename of the plugin
     // to be blocked, or that the filename starts with "fbplugin_".  But we
     // don't yet know for sure if this is always true.  So for the time being
     // record extra information in our crash logs.
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"),
                                        fileName);
+#endif
   }
 
   // It's possible that our plugin has 2 entry points that'll give us mime type
   // info. Quicktime does this to get around the need of having admin rights to
   // change mime info in the resource fork. We need to use this info instead of
   // the resource. See bug 113464.
 
   // Sadly we have to load the library for this to work.
   rv = LoadPlugin(outLibrary);
-
+#if defined(MOZ_CRASHREPORTER)
   if (nsCocoaFeatures::OnYosemiteOrLater()) {
     // If we didn't crash in LoadPlugin(), change the previous annotation so we
     // don't sow confusion.
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"),
                                        NS_LITERAL_CSTRING("Didn't crash, please ignore"));
   }
-
+#endif
   if (NS_FAILED(rv))
     return rv;
 
   // Try to get data from NP_GetMIMEDescription
   if (pLibrary) {
     NP_GETMIMEDESCRIPTION pfnGetMimeDesc = (NP_GETMIMEDESCRIPTION)PR_FindFunctionSymbol(pLibrary, NP_GETMIMEDESCRIPTION_NAME);
     if (pfnGetMimeDesc)
       ParsePluginMimeDescription(pfnGetMimeDesc(), info);
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -17,19 +17,20 @@
 #include "gfxipc/ShadowLayerUtils.h"
 
 #include "npapi.h"
 #include "npruntime.h"
 #include "npfunctions.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "mozilla/Logging.h"
-#include "nsExceptionHandler.h"
 #include "nsHashKeys.h"
-
+#ifdef MOZ_CRASHREPORTER
+#  include "nsExceptionHandler.h"
+#endif
 #ifdef XP_MACOSX
 #include "PluginInterposeOSX.h"
 #else
 namespace mac_plugin_interposing { class NSCursorInfo { }; }
 #endif
 using mac_plugin_interposing::NSCursorInfo;
 #ifdef XP_WIN
 #include "commdlg.h"
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -22,18 +22,16 @@
 #include "nsCOMPtr.h"
 #include "nsPluginsDir.h"
 #include "nsXULAppAPI.h"
 
 #ifdef MOZ_X11
 # include "nsX11ErrorHandler.h"
 # include "mozilla/X11Util.h"
 #endif
-
-#include "mozilla/ipc/CrashReporterClient.h"
 #include "mozilla/ipc/ProcessChild.h"
 #include "mozilla/plugins/PluginInstanceChild.h"
 #include "mozilla/plugins/StreamNotifyChild.h"
 #include "mozilla/plugins/BrowserStreamChild.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Unused.h"
 
 #include "nsNPAPIPlugin.h"
@@ -45,16 +43,20 @@
 #include <shlobj.h>
 #endif
 
 #ifdef MOZ_WIDGET_COCOA
 #include "PluginInterposeOSX.h"
 #include "PluginUtilsOSX.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "mozilla/ipc/CrashReporterClient.h"
+#endif
+
 #ifdef MOZ_GECKO_PROFILER
 #include "ChildProfilerController.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::ipc;
 using namespace mozilla::plugins;
 using namespace mozilla::widget;
@@ -743,19 +745,20 @@ PluginModuleChild::RecvInitPluginModuleC
     }
     return IPC_OK();
 }
 
 
 mozilla::ipc::IPCResult
 PluginModuleChild::AnswerInitCrashReporter(Shmem&& aShmem, mozilla::dom::NativeThreadId* aOutId)
 {
+#ifdef MOZ_CRASHREPORTER
     CrashReporterClient::InitSingletonWithShmem(aShmem);
     *aOutId = CrashReporter::CurrentThreadId();
-
+#endif
     return IPC_OK();
 }
 
 void
 PluginModuleChild::ActorDestroy(ActorDestroyReason why)
 {
 #ifdef MOZ_GECKO_PROFILER
     if (mProfilerController) {
@@ -784,18 +787,19 @@ PluginModuleChild::ActorDestroy(ActorDes
 
     if (!mHasShutdown) {
         MOZ_ASSERT(gChromeInstance == this);
         NP_Shutdown();
     }
 
     // doesn't matter why we're being destroyed; it's up to us to
     // initiate (clean) shutdown
+#ifdef MOZ_CRASHREPORTER
     CrashReporterClient::DestroySingleton();
-
+#endif
     XRE_ShutdownChildProcess();
 }
 
 void
 PluginModuleChild::CleanUp()
 {
 }
 
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -5,18 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/plugins/PluginModuleParent.h"
 
 #include "base/process_util.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentChild.h"
-#include "mozilla/ipc/CrashReporterClient.h"
-#include "mozilla/ipc/CrashReporterHost.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 #include "mozilla/ipc/MessageChannel.h"
 #include "mozilla/ipc/ProtocolUtils.h"
 #include "mozilla/plugins/BrowserStreamParent.h"
 #include "mozilla/plugins/PluginBridge.h"
 #include "mozilla/plugins/PluginInstanceParent.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ProcessHangMonitor.h"
@@ -62,17 +60,22 @@ using base::KillProcess;
 using mozilla::PluginLibrary;
 using mozilla::ipc::MessageChannel;
 using mozilla::ipc::GeckoChildProcessHost;
 
 using namespace mozilla;
 using namespace mozilla::plugins;
 using namespace mozilla::plugins::parent;
 
+#ifdef MOZ_CRASHREPORTER
+#include "mozilla/ipc/CrashReporterClient.h"
+#include "mozilla/ipc/CrashReporterHost.h"
+
 using namespace CrashReporter;
+#endif
 
 static const char kContentTimeoutPref[] = "dom.ipc.plugins.contentTimeoutSecs";
 static const char kChildTimeoutPref[] = "dom.ipc.plugins.timeoutSecs";
 static const char kParentTimeoutPref[] = "dom.ipc.plugins.parentTimeoutSecs";
 static const char kLaunchTimeoutPref[] = "dom.ipc.plugins.processLaunchTimeoutSecs";
 #ifdef XP_WIN
 static const char kHangUITimeoutPref[] = "dom.ipc.plugins.hangUITimeoutSecs";
 static const char kHangUIMinDisplayPref[] = "dom.ipc.plugins.hangUIMinDisplaySecs";
@@ -517,23 +520,25 @@ PluginModuleChromeParent::OnProcessLaunc
     Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this);
 #ifdef XP_WIN
     Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
     Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
 #endif
 
     RegisterSettingsCallbacks();
 
+#ifdef MOZ_CRASHREPORTER
     // If this fails, we're having IPC troubles, and we're doomed anyways.
     if (!InitCrashReporter()) {
         mShutdown = true;
         Close();
         OnInitFailure();
         return;
     }
+#endif
 
 #if defined(XP_WIN) && defined(_X86_)
     // Protected mode only applies to Windows and only to x86.
     if (!mIsBlocklisted && mIsFlashPlugin &&
         (Preferences::GetBool("dom.ipc.plugins.flash.disable-protected-mode", false) ||
          mSandboxLevel >= 2)) {
         Unused << SendDisableFlashProtectedMode();
     }
@@ -542,16 +547,17 @@ PluginModuleChromeParent::OnProcessLaunc
 #ifdef MOZ_GECKO_PROFILER
     Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
 #endif
 }
 
 bool
 PluginModuleChromeParent::InitCrashReporter()
 {
+#ifdef MOZ_CRASHREPORTER
     ipc::Shmem shmem;
     if (!ipc::CrashReporterClient::AllocShmem(this, &shmem)) {
         return false;
     }
 
     NativeThreadId threadId;
     if (!CallInitCrashReporter(shmem, &threadId)) {
         return false;
@@ -559,16 +565,17 @@ PluginModuleChromeParent::InitCrashRepor
 
     {
       mozilla::MutexAutoLock lock(mCrashReporterMutex);
       mCrashReporter = MakeUnique<ipc::CrashReporterHost>(
         GeckoProcessType_Plugin,
         shmem,
         threadId);
     }
+#endif
 
     return true;
 }
 
 PluginModuleParent::PluginModuleParent(bool aIsChrome)
     : mQuirks(QUIRKS_NOT_INITIALIZED)
     , mIsChrome(aIsChrome)
     , mShutdown(false)
@@ -576,17 +583,19 @@ PluginModuleParent::PluginModuleParent(b
     , mClearSiteDataSupported(false)
     , mGetSitesWithDataSupported(false)
     , mNPNIface(nullptr)
     , mNPPIface(nullptr)
     , mPlugin(nullptr)
     , mTaskFactory(this)
     , mSandboxLevel(0)
     , mIsFlashPlugin(false)
+#ifdef MOZ_CRASHREPORTER
     , mCrashReporterMutex("PluginModuleChromeParent::mCrashReporterMutex")
+#endif
 {
 }
 
 PluginModuleParent::~PluginModuleParent()
 {
     if (!OkToCleanup()) {
         MOZ_CRASH("unsafe destruction");
     }
@@ -688,16 +697,17 @@ PluginModuleChromeParent::~PluginModuleC
         delete mHangUIParent;
         mHangUIParent = nullptr;
     }
 #endif
 
     mozilla::HangMonitor::UnregisterAnnotator(*this);
 }
 
+#ifdef MOZ_CRASHREPORTER
 void
 PluginModuleChromeParent::WriteExtraDataForMinidump()
 {
     // mCrashReporterMutex is already held by the caller
     mCrashReporterMutex.AssertCurrentThreadOwns();
 
     typedef nsDependentCString CS;
 
@@ -729,16 +739,17 @@ PluginModuleChromeParent::WriteExtraData
                 tempStr.AppendFloat(std::ceil(mPluginCpuUsageOnHang[i] * 100) / 100);
                 mCrashReporter->AddNote(nsPrintfCString("CpuUsageFlashProcess%d", i), tempStr);
             }
 #endif
         }
 #endif
     }
 }
+#endif  // MOZ_CRASHREPORTER
 
 void
 PluginModuleParent::SetChildTimeout(const int32_t aChildTimeout)
 {
     int32_t timeoutMs = (aChildTimeout > 0) ? (1000 * aChildTimeout) :
                       MessageChannel::kNoTimeout;
     SetReplyTimeoutMs(timeoutMs);
 }
@@ -984,27 +995,29 @@ PluginModuleChromeParent::AnnotateHang(m
                                        true);
         }
         aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginName"), mPluginName);
         aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginVersion"),
                                    mPluginVersion);
     }
 }
 
+#ifdef MOZ_CRASHREPORTER
 static bool
 CreatePluginMinidump(base::ProcessId processId, ThreadId childThread,
                      nsIFile* parentMinidump, const nsACString& name)
 {
   mozilla::ipc::ScopedProcessHandle handle;
   if (processId == 0 ||
       !base::OpenPrivilegedProcessHandle(processId, &handle.rwget())) {
     return false;
   }
   return CreateAdditionalChildMinidump(handle, 0, parentMinidump, name);
 }
+#endif
 
 bool
 PluginModuleChromeParent::ShouldContinueFromReplyTimeout()
 {
     if (mIsFlashPlugin) {
         MessageLoop::current()->PostTask(
             mTaskFactory.NewRunnableMethod(
                 &PluginModuleChromeParent::NotifyFlashHang));
@@ -1049,16 +1062,17 @@ PluginModuleContentParent::OnExitedSyncS
 }
 
 void
 PluginModuleChromeParent::TakeFullMinidump(base::ProcessId aContentPid,
                                            const nsAString& aBrowserDumpId,
                                            std::function<void(nsString)>&& aCallback,
                                            bool aAsync)
 {
+#ifdef MOZ_CRASHREPORTER
     mozilla::MutexAutoLock lock(mCrashReporterMutex);
 
     if (!mCrashReporter || !mTakeFullMinidumpCallback.IsEmpty()) {
         aCallback(EmptyString());
         return;
     }
     mTakeFullMinidumpCallback.Init(Move(aCallback), aAsync);
 
@@ -1092,18 +1106,22 @@ PluginModuleChromeParent::TakeFullMinidu
         // We have a single browser report, generate a new plugin process parent
         // report and pair it up with the browser report handed in.
         mCrashReporter->GenerateMinidumpAndPair(Process(), mBrowserDumpFile,
                                                 NS_LITERAL_CSTRING("browser"),
                                                 Move(callback), aAsync);
     } else {
         TakeBrowserAndPluginMinidumps(false, aContentPid, browserDumpId, aAsync);
     }
+#else // MOZ_CRASHREPORTER
+    aCallback(NS_LITERAL_STRING(""));
+#endif
 }
 
+#ifdef MOZ_CRASHREPORTER
 void
 PluginModuleChromeParent::RetainPluginRef()
 {
     if (!mPlugin) {
         return;
     }
 
     if (NS_IsMainThread()) {
@@ -1212,30 +1230,33 @@ PluginModuleChromeParent::OnTakeFullMini
 
         mTakeFullMinidumpCallback.Invoke(mCrashReporter->MinidumpID());
     } else {
         mTakeFullMinidumpCallback.Invoke(EmptyString());
         NS_WARNING("failed to capture paired minidumps from hang");
     }
 }
 
+#endif // MOZ_CRASHREPORTER
+
 void
 PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop,
                                                 base::ProcessId aContentPid,
                                                 const nsCString& aMonitorDescription,
                                                 const nsAString& aDumpId,
                                                 std::function<void(bool)>&& aCallback,
                                                 bool aAsync)
 {
     if (!mTerminateChildProcessCallback.IsEmpty()) {
         aCallback(false);
         return;
     }
     mTerminateChildProcessCallback.Init(Move(aCallback), aAsync);
 
+#ifdef MOZ_CRASHREPORTER
     // Start by taking a full minidump if necessary, this is done early
     // because it also needs to lock the mCrashReporterMutex and Mutex doesn't
     // support recursive locking.
     if (aDumpId.IsEmpty()) {
 
       RetainPluginRef();
       std::function<void(nsString)> callback =
             [this, aMsgLoop, aMonitorDescription, aAsync](nsString aResult) {
@@ -1250,22 +1271,27 @@ PluginModuleChromeParent::TerminateChild
 
                 this->ReleasePluginRef();
             };
 
         TakeFullMinidump(aContentPid, EmptyString(), Move(callback), aAsync);
     } else {
         TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription);
     }
+
+#else
+    TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription);
+#endif
 }
 
 void
 PluginModuleChromeParent::TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop,
                                                               const nsCString& aMonitorDescription)
 {
+#ifdef MOZ_CRASHREPORTER
     mCrashReporterMutex.AssertCurrentThreadOwns();
 
     if (!mCrashReporter) {
         // If mCrashReporter is null then the hang has ended, the plugin module
         // is shutting down. There's nothing to do here.
         mTerminateChildProcessCallback.Invoke(true);
         return;
     }
@@ -1279,16 +1305,17 @@ PluginModuleChromeParent::TerminateChild
         if (hangUIDuration) {
             nsPrintfCString strHangUIDuration("%u", hangUIDuration);
             mCrashReporter->AddNote(
                     NS_LITERAL_CSTRING("PluginHangUIDuration"),
                     strHangUIDuration);
         }
     }
 #endif // XP_WIN
+#endif // MOZ_CRASHREPORTER
 
     mozilla::ipc::ScopedProcessHandle geckoChildProcess;
     bool childOpened = base::OpenProcessHandle(OtherPid(),
                                                &geckoChildProcess.rwget());
 
 #ifdef XP_WIN
     // collect cpu usage for plugin processes
 
@@ -1309,17 +1336,17 @@ PluginModuleChromeParent::TerminateChild
         base::OpenProcessHandle(mFlashProcess2, &flashSandboxProcess.rwget())) {
         processHandles.AppendElement(flashSandboxProcess);
     }
 #endif
 
     if (!GetProcessCpuUsage(processHandles, mPluginCpuUsageOnHang)) {
       mPluginCpuUsageOnHang.Clear();
     }
-#endif
+#endif // MOZ_CRASHREPORTER
 
     // this must run before the error notification from the channel,
     // or not at all
     bool isFromHangUI = aMsgLoop != MessageLoop::current();
     aMsgLoop->PostTask(
         mChromeTaskFactory.NewRunnableMethod(
             &PluginModuleChromeParent::CleanupFromTimeout, isFromHangUI));
 
@@ -1454,16 +1481,17 @@ PluginModuleChromeParent::FinishHangUI()
 
 void
 PluginModuleChromeParent::OnHangUIContinue()
 {
     mHangAnnotationFlags |= kHangUIContinued;
 }
 #endif // XP_WIN
 
+#ifdef MOZ_CRASHREPORTER
 #ifdef MOZ_CRASHREPORTER_INJECTOR
 static void
 RemoveMinidump(nsIFile* minidump)
 {
     if (!minidump)
         return;
 
     minidump->Remove(false);
@@ -1545,16 +1573,17 @@ PluginModuleChromeParent::ProcessFirstMi
     PLUGIN_LOG_DEBUG(("got child minidump: %s",
                       NS_ConvertUTF16toUTF8(mCrashReporter->MinidumpID()).get()));
 
     if (!flashProcessType.IsEmpty()) {
         mCrashReporter->AddNote(NS_LITERAL_CSTRING("FlashProcessDump"), flashProcessType);
     }
     mCrashReporter->FinalizeCrashReport();
 }
+#endif
 
 void
 PluginModuleParent::ActorDestroy(ActorDestroyReason why)
 {
     switch (why) {
     case AbnormalShutdown: {
         mShutdown = true;
         // Defer the PluginCrashed method so that we don't re-enter
@@ -1583,17 +1612,19 @@ PluginModuleParent::GetRunID(uint32_t* a
     *aRunID = mRunID;
     return NS_OK;
 }
 
 void
 PluginModuleChromeParent::ActorDestroy(ActorDestroyReason why)
 {
     if (why == AbnormalShutdown) {
+#ifdef MOZ_CRASHREPORTER
         ProcessFirstMinidump();
+#endif
         Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
                               NS_LITERAL_CSTRING("plugin"), 1);
     }
 
     // We can't broadcast settings changes anymore.
     UnregisterSettingsCallbacks();
 
     PluginModuleParent::ActorDestroy(why);
@@ -1620,21 +1651,21 @@ PluginModuleParent::NotifyPluginCrashed(
     }
 
     if (!mPlugin) {
         return;
     }
 
     nsString dumpID;
     nsString browserDumpID;
-
+#ifdef MOZ_CRASHREPORTER
     if (mCrashReporter && mCrashReporter->HasMinidump()) {
         dumpID = mCrashReporter->MinidumpID();
     }
-
+#endif
     mPlugin->PluginCrashed(dumpID, browserDumpID);
 }
 
 PPluginInstanceParent*
 PluginModuleParent::AllocPPluginInstanceParent(const nsCString& aMimeType,
                                                const InfallibleTArray<nsCString>& aNames,
                                                const InfallibleTArray<nsCString>& aValues)
 {
--- a/dom/plugins/ipc/PluginModuleParent.h
+++ b/dom/plugins/ipc/PluginModuleParent.h
@@ -16,27 +16,30 @@
 #include "mozilla/plugins/PPluginModuleParent.h"
 #include "mozilla/plugins/PluginMessageUtils.h"
 #include "mozilla/plugins/PluginTypes.h"
 #include "mozilla/ipc/TaskFactory.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Unused.h"
 #include "npapi.h"
 #include "npfunctions.h"
-#include "nsExceptionHandler.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsIObserver.h"
 #ifdef XP_WIN
 #include "nsWindowsHelpers.h"
 #if defined(MOZ_SANDBOX)
 #include "sandboxPermissions.h"
 #endif
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 class nsPluginTag;
 
 namespace mozilla {
 
 namespace layers {
 class TextureClientRecycleAllocator;
 } // namespace layers
 
@@ -326,24 +329,26 @@ protected:
     bool
     GetPluginDetails();
 
     uint32_t          mRunID;
 
     RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDirectBitmap;
     RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDXGISurface;
 
+#ifdef MOZ_CRASHREPORTER
     /**
      * This mutex protects the crash reporter when the Plugin Hang UI event
      * handler is executing off main thread. It is intended to protect both
      * the mCrashReporter variable in addition to the CrashReporterHost object
      * that mCrashReporter refers to.
      */
     mozilla::Mutex mCrashReporterMutex;
     UniquePtr<ipc::CrashReporterHost> mCrashReporter;
+#endif // MOZ_CRASHREPORTER
 };
 
 class PluginModuleContentParent : public PluginModuleParent
 {
   public:
     explicit PluginModuleContentParent();
 
     static PluginLibrary* LoadModule(uint32_t aPluginId, nsPluginTag* aPluginTag);
@@ -448,27 +453,28 @@ class PluginModuleChromeParent
      */
     template<typename T>
     static std::function<void(T)> DummyCallback()
     {
         return std::function<void(T)>([](T aResult) { });
     }
 
   private:
+#ifdef MOZ_CRASHREPORTER
     // The following methods are callbacks invoked after calling
     // TakeFullMinidump(). The methods are invoked in the following order:
     void TakeBrowserAndPluginMinidumps(bool aReportsReady,
                                        base::ProcessId aContentPid,
                                        const nsAString& aBrowserDumpId,
                                        bool aAsync);
     void OnTakeFullMinidumpComplete(bool aReportsReady,
                                     base::ProcessId aContentPid,
                                     const nsAString& aBrowserDumpId);
 
-
+#endif
     // The following method is the callback invoked after calling
     // TerminateChidlProcess().
     void TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop,
                                              const nsCString& aMonitorDescription);
   public:
 
 #ifdef XP_WIN
     /**
@@ -507,20 +513,22 @@ private:
     mozilla::ipc::IProtocol* GetInvokingProtocol();
     PluginInstanceParent* GetManagingInstance(mozilla::ipc::IProtocol* aProtocol);
 
     virtual void
     AnnotateHang(mozilla::HangMonitor::HangAnnotations& aAnnotations) override;
 
     virtual bool ShouldContinueFromReplyTimeout() override;
 
+#ifdef MOZ_CRASHREPORTER
     void ProcessFirstMinidump();
     void WriteExtraDataForMinidump();
     void RetainPluginRef();
     void ReleasePluginRef();
+#endif
 
     PluginProcessParent* Process() const { return mSubprocess; }
     base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
 
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
     virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) override;
 #else
     virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
@@ -628,18 +636,19 @@ private:
     friend class LaunchedTask;
 
     nsCOMPtr<nsIObserver> mPluginOfflineObserver;
     bool mIsBlocklisted;
 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
     mozilla::SandboxPermissions mSandboxPermissions;
 #endif
 
+#ifdef MOZ_CRASHREPORTER
     nsCOMPtr<nsIFile> mBrowserDumpFile;
     TakeFullMinidumpCallback mTakeFullMinidumpCallback;
-
+#endif
     TerminateChildProcessCallback mTerminateChildProcessCallback;
 };
 
 } // namespace plugins
 } // namespace mozilla
 
 #endif // mozilla_plugins_PluginModuleParent_h
--- a/gfx/gl/GfxTexturesReporter.cpp
+++ b/gfx/gl/GfxTexturesReporter.cpp
@@ -1,20 +1,23 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set ts=8 sts=4 et sw=4 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <string>
 #include <sstream>
-#include "nsExceptionHandler.h"
 #include "GfxTexturesReporter.h"
 #include "gfxPrefs.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 using namespace mozilla;
 using namespace mozilla::gl;
 
 NS_IMPL_ISUPPORTS(GfxTexturesReporter, nsIMemoryReporter)
 
 Atomic<size_t> GfxTexturesReporter::sAmount(0);
 Atomic<size_t> GfxTexturesReporter::sPeakAmount(0);
 Atomic<size_t> GfxTexturesReporter::sTileWasteAmount(0);
@@ -68,10 +71,12 @@ GfxTexturesReporter::UpdateAmount(Memory
         if (sAmount > sPeakAmount) {
             sPeakAmount.exchange(sAmount);
             if (gfxPrefs::GfxLoggingPeakTextureUsageEnabled()) {
                 printf_stderr("Peak texture usage: %s\n", FormatBytes(sPeakAmount).c_str());
             }
         }
     }
 
+#ifdef MOZ_CRASHREPORTER
     CrashReporter::AnnotateTexturesSize(sAmount);
+#endif
 }
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -139,21 +139,22 @@ GPUChild::RecvGraphicsError(const nsCStr
     lf->UpdateStringsVector(message.str());
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId)
 {
+#ifdef MOZ_CRASHREPORTER
   mCrashReporter = MakeUnique<ipc::CrashReporterHost>(
     GeckoProcessType_GPU,
     aShmem,
     aThreadId);
-
+#endif
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvNotifyUiObservers(const nsCString& aTopic)
 {
   nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
   MOZ_ASSERT(obsSvc);
@@ -246,20 +247,22 @@ GPUChild::RecvFinishMemoryReport(const u
   }
   return IPC_OK();
 }
 
 void
 GPUChild::ActorDestroy(ActorDestroyReason aWhy)
 {
   if (aWhy == AbnormalShutdown) {
+#ifdef MOZ_CRASHREPORTER
     if (mCrashReporter) {
       mCrashReporter->GenerateCrashReport(OtherPid());
       mCrashReporter = nullptr;
     }
+#endif
 
     Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
         nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_GPU)), 1);
 
     // Notify the Telemetry environment so that we can refresh and do a subsession split
     if (nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService()) {
       obsvc->NotifyObservers(nullptr, "compositor:process-aborted", nullptr);
     }
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -95,18 +95,20 @@ GPUParent::Init(base::ProcessId aParentP
 
   nsDebugImpl::SetMultiprocessMode("GPU");
 
   // This must be sent before any IPDL message, which may hit sentinel
   // errors due to parent and content processes having different
   // versions.
   GetIPCChannel()->SendBuildID();
 
+#ifdef MOZ_CRASHREPORTER
   // Init crash reporter support.
   CrashReporterClient::InitSingleton(this);
+#endif
 
   // Ensure gfxPrefs are initialized.
   gfxPrefs::GetSingleton();
   gfxConfig::Init();
   gfxVars::Initialize();
   gfxPlatform::InitNullMetadata();
   // Ensure our Factory is initialised, mainly for gfx logging to work.
   gfxPlatform::InitMoz2DLogging();
@@ -464,14 +466,16 @@ GPUParent::ActorDestroy(ActorDestroyReas
   Factory::ShutDown();
 #if defined(XP_WIN)
   DeviceManagerDx::Shutdown();
 #endif
   LayerTreeOwnerTracker::Shutdown();
   gfxVars::Shutdown();
   gfxConfig::Shutdown();
   gfxPrefs::DestroySingleton();
+#ifdef MOZ_CRASHREPORTER
   CrashReporterClient::DestroySingleton();
+#endif
   XRE_ShutdownChildProcess();
 }
 
 } // namespace gfx
 } // namespace mozilla
--- a/gfx/ipc/GPUProcessManager.cpp
+++ b/gfx/ipc/GPUProcessManager.cpp
@@ -34,19 +34,22 @@
 #include "VRManagerChild.h"
 #include "VRManagerParent.h"
 #include "VsyncBridgeChild.h"
 #include "VsyncIOThreadHolder.h"
 #include "VsyncSource.h"
 #include "mozilla/dom/VideoDecoderManagerChild.h"
 #include "mozilla/dom/VideoDecoderManagerParent.h"
 #include "MediaPrefs.h"
-#include "nsExceptionHandler.h"
 #include "nsPrintfCString.h"
 
+#ifdef MOZ_CRASHREPORTER
+# include "nsExceptionHandler.h"
+#endif
+
 #if defined(MOZ_WIDGET_ANDROID)
 #include "mozilla/widget/AndroidUiThread.h"
 #include "mozilla/layers/UiCompositorControllerChild.h"
 #endif // defined(MOZ_WIDGET_ANDROID)
 
 namespace mozilla {
 namespace gfx {
 
@@ -360,23 +363,25 @@ GPUProcessManager::OnProcessLaunchComple
   if (NS_FAILED(rv)) {
     DisableGPUProcess("Failed to create PVsyncBridge endpoints");
     return;
   }
 
   mVsyncBridge = VsyncBridgeChild::Create(mVsyncIOThread, mProcessToken, Move(vsyncChild));
   mGPUChild->SendInitVsyncBridge(Move(vsyncParent));
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("GPUProcessStatus"),
     NS_LITERAL_CSTRING("Running"));
 
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("GPUProcessLaunchCount"),
     nsPrintfCString("%d", mNumProcessAttempts));
+#endif
 }
 
 static bool
 ShouldLimitDeviceResets(uint32_t count, int32_t deltaMilliseconds)
 {
   // We decide to limit by comparing the amount of resets that have happened
   // and time since the last reset to two prefs.
   int32_t timeLimit = gfxPrefs::DeviceResetThresholdMilliseconds();
@@ -707,19 +712,21 @@ GPUProcessManager::DestroyProcess()
   mProcessToken = 0;
   mProcess = nullptr;
   mGPUChild = nullptr;
   if (mVsyncBridge) {
     mVsyncBridge->Close();
     mVsyncBridge = nullptr;
   }
 
+#ifdef MOZ_CRASHREPORTER
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("GPUProcessStatus"),
     NS_LITERAL_CSTRING("Destroyed"));
+#endif
 }
 
 already_AddRefed<CompositorSession>
 GPUProcessManager::CreateTopLevelCompositor(nsBaseWidget* aWidget,
                                             LayerManager* aLayerManager,
                                             CSSToLayoutDeviceScale aScale,
                                             const CompositorOptions& aOptions,
                                             bool aUseExternalSurfaceSize,
--- a/gfx/src/DriverCrashGuard.cpp
+++ b/gfx/src/DriverCrashGuard.cpp
@@ -4,17 +4,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "DriverCrashGuard.h"
 #include "gfxEnv.h"
 #include "gfxPrefs.h"
 #include "gfxConfig.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Services.h"
 #include "mozilla/gfx/Logging.h"
 #include "mozilla/dom/ContentChild.h"
@@ -160,19 +162,21 @@ DriverCrashGuard::~DriverCrashGuard()
     // proceed to mark the status as okay.
     if (GetStatus() != DriverInitStatus::Crashed) {
       SetStatus(DriverInitStatus::Okay);
     }
   } else {
     dom::ContentChild::GetSingleton()->SendEndDriverCrashGuard(uint32_t(mType));
   }
 
+#ifdef MOZ_CRASHREPORTER
   // Remove the crash report annotation.
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"),
                                      NS_LITERAL_CSTRING(""));
+#endif
 }
 
 bool
 DriverCrashGuard::Crashed()
 {
   InitializeIfNeeded();
 
   // Note, we read mCrashDetected instead of GetStatus(), since in child
@@ -201,23 +205,25 @@ DriverCrashGuard::GetGuardFile()
   return file;
 }
 
 void
 DriverCrashGuard::ActivateGuard()
 {
   mGuardActivated = true;
 
+#ifdef MOZ_CRASHREPORTER
   // Anotate crash reports only if we're a real guard. Otherwise, we could
   // attribute a random parent process crash to a graphics problem in a child
   // process.
   if (mMode != Mode::Proxy) {
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"),
                                        NS_LITERAL_CSTRING("1"));
   }
+#endif
 
   // If we're in the content process, the rest of the guarding is handled
   // in the parent.
   if (XRE_IsContentProcess()) {
     return;
   }
 
   SetStatus(DriverInitStatus::Attempting);
--- a/gfx/src/gfxCrashReporterUtils.cpp
+++ b/gfx/src/gfxCrashReporterUtils.cpp
@@ -1,15 +1,22 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gfxCrashReporterUtils.h"
+
+#if defined(MOZ_CRASHREPORTER)
+#define MOZ_GFXFEATUREREPORTER 1
+#endif
+
+#ifdef MOZ_GFXFEATUREREPORTER
+#include "gfxCrashReporterUtils.h"
 #include <string.h>                     // for strcmp
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
 #include "mozilla/Services.h"           // for GetObserverService
 #include "mozilla/StaticMutex.h"
 #include "mozilla/SystemGroup.h"        // for SystemGroup
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "MainThreadUtils.h"            // for NS_IsMainThread
@@ -125,8 +132,18 @@ ScopedGfxFeatureReporter::AppNote(const 
     CrashReporter::AppendAppNotesToCrashReport(aMessage);
   } else {
     nsCOMPtr<nsIRunnable> r = new AppendAppNotesRunnable(aMessage);
     SystemGroup::Dispatch(TaskCategory::Other, r.forget());
   }
 }
   
 } // end namespace mozilla
+
+#else
+
+namespace mozilla {
+void ScopedGfxFeatureReporter::WriteAppNote(char) {}
+void ScopedGfxFeatureReporter::AppNote(const nsACString&) {}
+  
+} // namespace mozilla
+
+#endif
--- a/gfx/tests/gtest/TestGfxPrefs.cpp
+++ b/gfx/tests/gtest/TestGfxPrefs.cpp
@@ -76,16 +76,17 @@ TEST(GfxPrefs, Set) {
   // Once float, default -1
   ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f);
   gfxPrefs::SetAPZMaxVelocity(1.75f);
   ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == 1.75f);
   gfxPrefs::SetAPZMaxVelocity(-1.0f);
   ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f);
 }
 
+#ifdef MOZ_CRASHREPORTER
 // Randomly test the function we use in nsExceptionHandler.cpp here:
 extern bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength);
 TEST(GfxPrefs, StringUtility)
 {
   char testBuffer[64];
   double testVal[] = {13.4,
                       3324243.42,
                       0.332424342,
@@ -98,8 +99,9 @@ TEST(GfxPrefs, StringUtility)
   }
 
   // We do not like negative numbers (random limitation)
   ASSERT_FALSE(SimpleNoCLibDtoA(-864.0, testBuffer, sizeof(testBuffer)));
 
   // It won't fit into 32:
   ASSERT_FALSE(SimpleNoCLibDtoA(testVal[4], testBuffer, sizeof(testBuffer)/2));
 }
+#endif
--- a/gfx/thebes/DeviceManagerDx.cpp
+++ b/gfx/thebes/DeviceManagerDx.cpp
@@ -16,23 +16,26 @@
 #include "mozilla/gfx/GraphicsMessages.h"
 #include "mozilla/gfx/Logging.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/DeviceAttachmentsD3D11.h"
 #include "mozilla/layers/MLGDeviceD3D11.h"
 #include "mozilla/layers/PaintThread.h"
-#include "nsExceptionHandler.h"
 #include "nsIGfxInfo.h"
-#include "nsPrintfCString.h"
 #include "nsString.h"
 #include <d3d11.h>
 #include <ddraw.h>
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#include "nsPrintfCString.h"
+#endif
+
 namespace mozilla {
 namespace gfx {
 
 using namespace mozilla::widget;
 using namespace mozilla::layers;
 
 StaticAutoPtr<DeviceManagerDx> DeviceManagerDx::sInstance;
 
@@ -764,20 +767,22 @@ DeviceManagerDx::MaybeResetAndReacquireD
   if (!HasDeviceReset(&resetReason)) {
     return false;
   }
 
   if (resetReason != DeviceResetReason::FORCED_RESET) {
     Telemetry::Accumulate(Telemetry::DEVICE_RESET_REASON, uint32_t(resetReason));
   }
 
+#ifdef MOZ_CRASHREPORTER
   nsPrintfCString reasonString("%d", int(resetReason));
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("DeviceResetReason"),
     reasonString);
+#endif
 
   bool createCompositorDevice = !!mCompositorDevice;
   bool createContentDevice = !!mContentDevice;
 
   ResetDevices();
 
   if (createCompositorDevice && !CreateCompositorDevices()) {
     // Just stop, don't try anything more
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -65,24 +65,26 @@
 #include "gfxImageSurface.h"
 #include "nsUnicodeProperties.h"
 #include "harfbuzz/hb.h"
 #include "gfxGraphiteShaper.h"
 #include "gfx2DGlue.h"
 #include "gfxGradientCache.h"
 #include "gfxUtils.h" // for NextPowerOfTwo
 
-#include "nsExceptionHandler.h"
 #include "nsUnicodeRange.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTArray.h"
 #include "nsIObserverService.h"
 #include "nsIScreenManager.h"
 #include "FrameMetrics.h"
 #include "MainThreadUtils.h"
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
 
 #include "nsWeakReference.h"
 
 #include "cairo.h"
 #include "qcms.h"
 
 #include "imgITools.h"
 
@@ -291,19 +293,22 @@ void CrashStatsLogForwarder::UpdateCrash
     logAnnotation = "|[X";
     break;
   }
 
   for (auto& it : mBuffer) {
     message << logAnnotation << Get<0>(it) << "]" << Get<1>(it) << " (t=" << Get<2>(it) << ") ";
   }
 
+#ifdef MOZ_CRASHREPORTER
   nsCString reportString(message.str().c_str());
   nsresult annotated = CrashReporter::AnnotateCrashReport(mCrashCriticalKey, reportString);
-
+#else
+  nsresult annotated = NS_ERROR_NOT_IMPLEMENTED;
+#endif
   if (annotated != NS_OK) {
     printf("Crash Annotation %s: %s",
            mCrashCriticalKey.get(), message.str().c_str());
   }
 }
 
 class LogForwarderEvent : public Runnable
 {
--- a/ipc/glue/CrashReporterClient.cpp
+++ b/ipc/glue/CrashReporterClient.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CrashReporterClient.h"
 #include "CrashReporterMetadataShmem.h"
 #include "nsISupportsImpl.h"
 
+#ifdef MOZ_CRASHREPORTER
 namespace mozilla {
 namespace ipc {
 
 StaticMutex CrashReporterClient::sLock;
 StaticRefPtr<CrashReporterClient> CrashReporterClient::sClientSingleton;
 
 CrashReporterClient::CrashReporterClient(const Shmem& aShmem)
  : mMetadata(new CrashReporterMetadataShmem(aShmem))
@@ -59,8 +60,9 @@ CrashReporterClient::DestroySingleton()
 CrashReporterClient::GetSingleton()
 {
   StaticMutexAutoLock lock(sLock);
   return sClientSingleton;
 }
 
 } // namespace ipc
 } // namespace mozilla
+#endif // MOZ_CRASHREPORTER
--- a/ipc/glue/CrashReporterClient.h
+++ b/ipc/glue/CrashReporterClient.h
@@ -7,16 +7,17 @@
 #ifndef mozilla_ipc_CrashReporterClient_h
 #define mozilla_ipc_CrashReporterClient_h
 
 #include "mozilla/StaticMutex.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Unused.h"
 #include "mozilla/ipc/Shmem.h"
 
+#ifdef MOZ_CRASHREPORTER
 namespace mozilla {
 namespace ipc {
 
 class CrashReporterMetadataShmem;
 
 class CrashReporterClient
 {
 public:
@@ -72,11 +73,12 @@ private:
   static StaticRefPtr<CrashReporterClient> sClientSingleton;
 
 private:
   UniquePtr<CrashReporterMetadataShmem> mMetadata;
 };
 
 } // namespace ipc
 } // namespace mozilla
+#endif // MOZ_CRASHREPORTER
 
 #endif // mozilla_ipc_CrashReporterClient_h
 
--- a/ipc/glue/CrashReporterHost.cpp
+++ b/ipc/glue/CrashReporterHost.cpp
@@ -5,34 +5,37 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CrashReporterHost.h"
 #include "CrashReporterMetadataShmem.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/Telemetry.h"
-#include "nsExceptionHandler.h"
-#include "nsIAsyncShutdown.h"
-#include "nsICrashService.h"
+#ifdef MOZ_CRASHREPORTER
+# include "nsExceptionHandler.h"
+# include "nsIAsyncShutdown.h"
+# include "nsICrashService.h"
+#endif
 
 namespace mozilla {
 namespace ipc {
 
 CrashReporterHost::CrashReporterHost(GeckoProcessType aProcessType,
                                      const Shmem& aShmem,
                                      ThreadId aThreadId)
  : mProcessType(aProcessType),
    mShmem(aShmem),
    mThreadId(aThreadId),
    mStartTime(::time(nullptr)),
    mFinalized(false)
 {
 }
 
+#ifdef MOZ_CRASHREPORTER
 bool
 CrashReporterHost::GenerateCrashReport(base::ProcessId aPid)
 {
   if (!TakeCrashedChildMinidump(aPid, nullptr)) {
     return false;
   }
   return FinalizeCrashReport();
 }
@@ -280,11 +283,12 @@ CrashReporterHost::NotifyCrashService(Ge
   Telemetry::Accumulate(Telemetry::SUBPROCESS_CRASHES_WITH_DUMP, telemetryKey, 1);
 }
 
 void
 CrashReporterHost::AddNote(const nsCString& aKey, const nsCString& aValue)
 {
   mExtraNotes.Put(aKey, aValue);
 }
+#endif
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/glue/CrashReporterHost.h
+++ b/ipc/glue/CrashReporterHost.h
@@ -7,34 +7,41 @@
 #ifndef mozilla_ipc_CrashReporterHost_h
 #define mozilla_ipc_CrashReporterHost_h
 
 #include <functional>
 
 #include "mozilla/UniquePtr.h"
 #include "mozilla/ipc/Shmem.h"
 #include "base/process.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace ipc {
 
 class GeckoChildProcessHost;
 
 // This is the newer replacement for CrashReporterParent. It is created in
 // response to a InitCrashReporter message on a top-level actor, and simply
 // holds the metadata shmem alive until the process ends. When the process
 // terminates abnormally, the top-level should call GenerateCrashReport to
 // automatically integrate metadata.
 class CrashReporterHost
 {
   typedef mozilla::ipc::Shmem Shmem;
+#ifdef MOZ_CRASHREPORTER
   typedef CrashReporter::AnnotationTable AnnotationTable;
   typedef CrashReporter::ThreadId ThreadId;
+#else
+  // unused in this case
+  typedef int32_t ThreadId;
+#endif
 
 public:
 
   template <typename T>
   class CallbackWrapper {
   public:
     void Init(std::function<void(T)>&& aCallback, bool aAsync)
     {
@@ -87,16 +94,17 @@ public:
     std::function<void(T)> mCallback;
     nsCOMPtr<nsIThread> mTargetThread;
   };
 
   CrashReporterHost(GeckoProcessType aProcessType,
                     const Shmem& aShmem,
                     ThreadId aThreadId);
 
+#ifdef MOZ_CRASHREPORTER
   // Helper function for generating a crash report for a process that probably
   // crashed (i.e., had an AbnormalShutdown in ActorDestroy). Returns true if
   // the process has a minidump attached and we were able to generate a report.
   bool GenerateCrashReport(base::ProcessId aPid);
 
   // Given an existing minidump for a crashed child process, take ownership of
   // it from IPDL. After this, FinalizeCrashReport may be called.
   RefPtr<nsIFile> TakeCrashedChildMinidump(base::ProcessId aPid, uint32_t* aOutSequence);
@@ -136,28 +144,31 @@ public:
 
   bool HasMinidump() const {
     return !mDumpID.IsEmpty();
   }
   const nsString& MinidumpID() const {
     MOZ_ASSERT(HasMinidump());
     return mDumpID;
   }
+#endif
 
 private:
   static void AsyncAddCrash(int32_t aProcessType, int32_t aCrashType,
                             const nsString& aChildDumpID);
 
 private:
   CallbackWrapper<bool> mCreateMinidumpCallback;
   GeckoProcessType mProcessType;
   Shmem mShmem;
   ThreadId mThreadId;
   time_t mStartTime;
+#ifdef MOZ_CRASHREPORTER
   AnnotationTable mExtraNotes;
+#endif
   nsString mDumpID;
   bool mFinalized;
   nsCOMPtr<nsIFile> mTargetDump;
 };
 
 } // namespace ipc
 } // namespace mozilla
 
--- a/ipc/glue/CrashReporterMetadataShmem.cpp
+++ b/ipc/glue/CrashReporterMetadataShmem.cpp
@@ -203,16 +203,17 @@ private:
   }
 
 private:
   const uint8_t* mCursor;
   const uint8_t* mEnd;
   EntryType mEntryType;
 };
 
+#ifdef MOZ_CRASHREPORTER
 void
 CrashReporterMetadataShmem::ReadAppNotes(const Shmem& aShmem, CrashReporter::AnnotationTable* aNotes)
 {
   for (MetadataShmemReader reader(aShmem); !reader.Done(); reader.Next()) {
     switch (reader.Type()) {
       case EntryType::Annotation: {
         nsCString key, value;
         if (!reader.Read(key) || !reader.Read(value)) {
@@ -223,11 +224,12 @@ CrashReporterMetadataShmem::ReadAppNotes
         break;
       }
       default:
         NS_ASSERTION(false, "Unknown metadata entry type");
         break;
     }
   }
 }
+#endif
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/glue/CrashReporterMetadataShmem.h
+++ b/ipc/glue/CrashReporterMetadataShmem.h
@@ -23,17 +23,19 @@ class CrashReporterMetadataShmem
 public:
   explicit CrashReporterMetadataShmem(const Shmem& aShmem);
   ~CrashReporterMetadataShmem();
 
   // Metadata writers. These must only be called in child processes.
   void AnnotateCrashReport(const nsCString& aKey, const nsCString& aData);
   void AppendAppNotes(const nsCString& aData);
 
+#ifdef MOZ_CRASHREPORTER
   static void ReadAppNotes(const Shmem& aShmem, CrashReporter::AnnotationTable* aNotes);
+#endif
 
 private:
   void SyncNotesToShmem();
 
 private:
   Shmem mShmem;
 
   AnnotationTable mNotes;
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -219,19 +219,21 @@ uint32_t
 GeckoChildProcessHost::GetUniqueID()
 {
   return sNextUniqueID++;
 }
 
 void
 GeckoChildProcessHost::PrepareLaunch()
 {
+#ifdef MOZ_CRASHREPORTER
   if (CrashReporter::GetEnabled()) {
     CrashReporter::OOPInit();
   }
+#endif
 
 #if defined(XP_LINUX) && defined(MOZ_SANDBOX)
   SandboxLaunchPrepare(mProcessType, mLaunchOptions.get());
 #endif
 
 #ifdef XP_WIN
   if (mProcessType == GeckoProcessType_Plugin) {
     InitWindowsGroupID();
@@ -748,46 +750,48 @@ GeckoChildProcessHost::PerformAsyncLaunc
 
   // Add the application directory path (-appdir path)
   AddAppDirToCommandLine(childArgv);
 
   // Tmp dir that the GPU process should use for crash reports. This arg is
   // always populated (but possibly with an empty value) for a GPU child process.
   if (mProcessType == GeckoProcessType_GPU) {
     nsCOMPtr<nsIFile> file;
+# ifdef MOZ_CRASHREPORTER
     CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file));
+# endif // MOZ_CRASHREPORTER
     nsAutoCString path;
     if (file) {
       file->GetNativePath(path);
     }
     childArgv.push_back(path.get());
   }
 
   childArgv.push_back(pidstring);
 
-  if (!CrashReporter::IsDummy()) {
-# if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
-    int childCrashFd, childCrashRemapFd;
-    if (!CrashReporter::CreateNotificationPipeForChild(
-        &childCrashFd, &childCrashRemapFd)) {
-      return false;
-    }
-
-    if (0 <= childCrashFd) {
+# if defined(MOZ_CRASHREPORTER)
+#  if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+  int childCrashFd, childCrashRemapFd;
+  if (!CrashReporter::CreateNotificationPipeForChild(
+        &childCrashFd, &childCrashRemapFd))
+    return false;
+  if (0 <= childCrashFd) {
     mLaunchOptions->fds_to_remap
       .push_back(std::pair<int,int>(childCrashFd, childCrashRemapFd));
-      childArgv.push_back("true");
-    } else {
-      // "false" == crash reporting disabled
-      childArgv.push_back("false");
-    }
-# elif defined(MOZ_WIDGET_COCOA) // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
-    childArgv.push_back(CrashReporter::GetChildNotificationPipe());
-# endif  // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+    // "true" == crash reporting enabled
+    childArgv.push_back("true");
   }
+  else {
+    // "false" == crash reporting disabled
+    childArgv.push_back("false");
+  }
+#  elif defined(MOZ_WIDGET_COCOA) // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+  childArgv.push_back(CrashReporter::GetChildNotificationPipe());
+#  endif  // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
+# endif // defined(MOZ_CRASHREPORTER)
 
 # ifdef MOZ_WIDGET_COCOA
   // Add a mach port to the command line so the child can communicate its
   // 'task_t' back to the parent.
   //
   // Put a random number into the channel name, so that a compromised renderer
   // can't pretend being the child that's forked off.
   std::string mach_connection_name = StringPrintf("org.mozilla.machname.%d",
@@ -991,30 +995,34 @@ GeckoChildProcessHost::PerformAsyncLaunc
 
   // Win app model id
   cmdLine.AppendLooseValue(mGroupId.get());
 
   // Tmp dir that the GPU process should use for crash reports. This arg is
   // always populated (but possibly with an empty value) for a GPU child process.
   if (mProcessType == GeckoProcessType_GPU) {
     nsCOMPtr<nsIFile> file;
+# ifdef MOZ_CRASHREPORTER
     CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file));
+# endif // MOZ_CRASHREPORTER
     nsString path;
     if (file) {
       MOZ_ALWAYS_SUCCEEDS(file->GetPath(path));
     }
     std::wstring wpath(path.get());
     cmdLine.AppendLooseValue(wpath);
   }
 
   // Process id
   cmdLine.AppendLooseValue(UTF8ToWide(pidstring));
 
+# if defined(MOZ_CRASHREPORTER)
   cmdLine.AppendLooseValue(
     UTF8ToWide(CrashReporter::GetChildNotificationPipe()));
+# endif // defined(MOZ_CRASHREPORTER)
 
   // Process type
   cmdLine.AppendLooseValue(UTF8ToWide(childProcessType));
 
 # if defined(XP_WIN) && defined(MOZ_SANDBOX)
   if (shouldSandboxCurrentProcess) {
     if (mSandboxBroker.LaunchApp(cmdLine.program().c_str(),
                                  cmdLine.command_line_string().c_str(),
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -20,17 +20,19 @@
 #ifdef XP_WIN
 #include "mozilla/TimeStamp_windows.h"
 #endif
 #include "mozilla/TypeTraits.h"
 #include "mozilla/IntegerTypeTraits.h"
 
 #include <stdint.h>
 
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 #include "nsID.h"
 #include "nsIWidget.h"
 #include "nsMemory.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "js/StructuredClone.h"
 #include "nsCSSPropertyID.h"
 
@@ -120,22 +122,26 @@ struct EnumSerializer {
   static void Write(Message* aMsg, const paramType& aValue) {
     MOZ_RELEASE_ASSERT(EnumValidator::IsLegalValue(aValue));
     WriteParam(aMsg, uintParamType(aValue));
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) {
     uintParamType value;
     if (!ReadParam(aMsg, aIter, &value)) {
+#ifdef MOZ_CRASHREPORTER
       CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"),
                                          NS_LITERAL_CSTRING("Bad iter"));
+#endif
       return false;
     } else if (!EnumValidator::IsLegalValue(paramType(value))) {
+#ifdef MOZ_CRASHREPORTER
       CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"),
                                          NS_LITERAL_CSTRING("Illegal value"));
+#endif
       return false;
     }
     *aResult = paramType(value);
     return true;
   }
 };
 
 template <typename E,
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -669,18 +669,20 @@ MessageChannel::CanSend() const
     MonitorAutoLock lock(*mMonitor);
     return Connected();
 }
 
 void
 MessageChannel::WillDestroyCurrentMessageLoop()
 {
 #if defined(DEBUG)
+#if defined(MOZ_CRASHREPORTER)
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProtocolName"),
                                        nsDependentCString(mName));
+#endif
     MOZ_CRASH("MessageLoop destroyed before MessageChannel that's bound to it");
 #endif
 
     // Clear mWorkerThread to avoid posting to it in the future.
     MonitorAutoLock lock(*mMonitor);
     mWorkerLoop = nullptr;
 }
 
@@ -694,18 +696,20 @@ MessageChannel::Clear()
     // through this channel after it's Clear()'ed can cause this process to
     // crash.
     //
     // In practice, mListener owns the channel, so the channel gets deleted
     // before mListener.  But just to be safe, mListener is a weak pointer.
 
 #if !defined(ANDROID)
     if (!Unsound_IsClosed()) {
+#if defined(MOZ_CRASHREPORTER)
         CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProtocolName"),
                                            nsDependentCString(mName));
+#endif
         MOZ_CRASH("MessageChannel destroyed without being closed");
     }
 #endif
 
     if (gParentProcessBlocker == this) {
         gParentProcessBlocker = nullptr;
     }
 
--- a/ipc/glue/MessageLink.cpp
+++ b/ipc/glue/MessageLink.cpp
@@ -9,17 +9,19 @@
 #include "mozilla/ipc/MessageChannel.h"
 #include "mozilla/ipc/BrowserProcessSubThread.h"
 #include "mozilla/ipc/ProtocolUtils.h"
 #include "chrome/common/ipc_channel.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/DebugOnly.h"
 #include "nsDebug.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 #include "nsISupportsImpl.h"
 #include "nsPrintfCString.h"
 #include "nsXULAppAPI.h"
 
 using namespace mozilla;
 using namespace std;
 
 // We rely on invariants about the lifetime of the transport:
@@ -154,18 +156,20 @@ ProcessLink::EchoMessage(Message *msg)
                                            msg));
     // OnEchoMessage takes ownership of |msg|
 }
 
 void
 ProcessLink::SendMessage(Message *msg)
 {
     if (msg->size() > IPC::Channel::kMaximumMessageSize) {
+#ifdef MOZ_CRASHREPORTER
       CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCMessageName"), nsDependentCString(msg->name()));
       CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCMessageSize"), nsPrintfCString("%d", msg->size()));
+#endif
       MOZ_CRASH("IPC message size is too large");
     }
 
     if (!mChan->mIsPostponingSends) {
         mChan->AssertWorkerThread();
     }
     mChan->mMonitor->AssertCurrentThreadOwns();
 
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -23,34 +23,34 @@
 #include "mozilla/Unused.h"
 #include "nsPrintfCString.h"
 
 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
 #define TARGET_SANDBOX_EXPORTS
 #include "mozilla/sandboxTarget.h"
 #endif
 
-#if defined(XP_WIN)
+#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN)
 #include "aclapi.h"
 #include "sddl.h"
 
 #include "mozilla/TypeTraits.h"
 #endif
 
 #include "nsAutoPtr.h"
 
 using namespace IPC;
 
 using base::GetCurrentProcId;
 using base::ProcessHandle;
 using base::ProcessId;
 
 namespace mozilla {
 
-#if defined(XP_WIN)
+#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN)
 // Generate RAII classes for LPTSTR and PSECURITY_DESCRIPTOR.
 MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedLPTStr, \
                                           RemovePointer<LPTSTR>::Type, \
                                           ::LocalFree)
 MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPSecurityDescriptor, \
                                           RemovePointer<PSECURITY_DESCRIPTOR>::Type, \
                                           ::LocalFree)
 #endif
@@ -204,45 +204,49 @@ bool DuplicateHandle(HANDLE aSourceHandl
   }
 #endif
 
   // Finally, see if we already have access to the process.
   ScopedProcessHandle targetProcess(OpenProcess(PROCESS_DUP_HANDLE,
                                                 FALSE,
                                                 aTargetProcessId));
   if (!targetProcess) {
+#ifdef MOZ_CRASHREPORTER
     CrashReporter::AnnotateCrashReport(
       NS_LITERAL_CSTRING("IPCTransportFailureReason"),
       NS_LITERAL_CSTRING("Failed to open target process."));
+#endif
     return false;
   }
 
   return !!::DuplicateHandle(::GetCurrentProcess(), aSourceHandle,
                               targetProcess, aTargetHandle,
                               aDesiredAccess, FALSE, aOptions);
 }
 #endif
 
+#ifdef MOZ_CRASHREPORTER
 void
 AnnotateSystemError()
 {
   int64_t error = 0;
 #if defined(XP_WIN)
   error = ::GetLastError();
 #elif defined(OS_POSIX)
   error = errno;
 #endif
   if (error) {
     CrashReporter::AnnotateCrashReport(
       NS_LITERAL_CSTRING("IPCSystemError"),
       nsPrintfCString("%" PRId64, error));
   }
 }
+#endif
 
-#if defined(XP_MACOSX)
+#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX)
 void
 AnnotateCrashReportWithErrno(const char* tag, int error)
 {
   CrashReporter::AnnotateCrashReport(
     nsCString(tag),
     nsPrintfCString("%d", error));
 }
 #endif
@@ -279,26 +283,28 @@ FatalError(const char* aProtocolName, co
 {
   ProtocolErrorBreakpoint(aMsg);
 
   nsAutoCString formattedMessage("IPDL error [");
   formattedMessage.AppendASCII(aProtocolName);
   formattedMessage.AppendLiteral("]: \"");
   formattedMessage.AppendASCII(aMsg);
   if (aIsParent) {
+#ifdef MOZ_CRASHREPORTER
     // We're going to crash the parent process because at this time
     // there's no other really nice way of getting a minidump out of
     // this process if we're off the main thread.
     formattedMessage.AppendLiteral("\". Intentionally crashing.");
     NS_ERROR(formattedMessage.get());
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorProtocol"),
                                        nsDependentCString(aProtocolName));
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorMsg"),
                                        nsDependentCString(aMsg));
     AnnotateSystemError();
+#endif
     MOZ_CRASH("IPC FatalError in the parent process!");
   } else {
     formattedMessage.AppendLiteral("\". abort()ing as a result.");
     MOZ_CRASH_UNSAFE_OOL(formattedMessage.get());
   }
 }
 
 void
@@ -606,17 +612,21 @@ IToplevelProtocol::SetOtherProcessId(bas
 {
   mOtherPid = aOtherPid;
 }
 
 bool
 IToplevelProtocol::TakeMinidump(nsIFile** aDump, uint32_t* aSequence)
 {
   MOZ_RELEASE_ASSERT(GetSide() == ParentSide);
+#ifdef MOZ_CRASHREPORTER
   return XRE_TakeMinidumpForChild(OtherPid(), aDump, aSequence);
+#else
+  return false;
+#endif
 }
 
 bool
 IToplevelProtocol::Open(mozilla::ipc::Transport* aTransport,
                         base::ProcessId aOtherPid,
                         MessageLoop* aThread,
                         mozilla::ipc::Side aSide)
 {
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -568,17 +568,21 @@ DuplicateHandle(HANDLE aSourceHandle,
                 DWORD aDesiredAccess,
                 DWORD aOptions);
 #endif
 
 /**
  * Annotate the crash reporter with the error code from the most recent system
  * call. Returns the system error.
  */
+#ifdef MOZ_CRASHREPORTER
 void AnnotateSystemError();
+#else
+#define AnnotateSystemError() do { } while (0)
+#endif
 
 /**
  * An endpoint represents one end of a partially initialized IPDL channel. To
  * set up a new top-level protocol:
  *
  * Endpoint<PFooParent> parentEp;
  * Endpoint<PFooChild> childEp;
  * nsresult rv;
@@ -687,17 +691,17 @@ private:
     Endpoint& operator=(const Endpoint&) = delete;
 
     bool mValid;
     mozilla::ipc::Transport::Mode mMode;
     TransportDescriptor mTransport;
     ProcessId mMyPid, mOtherPid;
 };
 
-#if defined(XP_MACOSX)
+#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX)
 void AnnotateCrashReportWithErrno(const char* tag, int error);
 #else
 static inline void AnnotateCrashReportWithErrno(const char* tag, int error)
 {}
 #endif
 
 // This function is used internally to create a pair of Endpoints. See the
 // comment above Endpoint for a description of how it might be used.
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -2561,16 +2561,23 @@ class _GenerateProtocolActorCode(ipdl.as
         cf.addthings([
             _DISCLAIMER,
             Whitespace.NL,
             CppDirective(
                 'include',
                 '"'+ _protocolHeaderName(self.protocol, self.side) +'.h"') ]
             + setToIncludes(self.externalIncludes))
 
+        if self.protocol.decl.type.isToplevel():
+            cf.addthings([
+                CppDirective('ifdef', 'MOZ_CRASHREPORTER'),
+                CppDirective('  include', '"nsXULAppAPI.h"'),
+                CppDirective('endif')
+            ])
+
         cppheaders = [CppDirective('include', '"%s"' % filename)
                       for filename in ipdl.builtin.CppIncludes]
 
         cf.addthings((
             [ Whitespace.NL ]
             + [ CppDirective(
                 'include',
                 '"%s.h"' % (inc)) for inc in self.protocolCxxIncludes ]
--- a/ipc/mscom/COMPtrHolder.h
+++ b/ipc/mscom/COMPtrHolder.h
@@ -11,17 +11,19 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Move.h"
 #include "mozilla/mscom/ProxyStream.h"
 #include "mozilla/mscom/Ptr.h"
 #if defined(MOZ_CONTENT_SANDBOX)
 #include "mozilla/SandboxSettings.h"
 #endif // defined(MOZ_CONTENT_SANDBOX)
+#if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
+#endif // defined(MOZ_CRASHREPORTER)
 
 namespace mozilla {
 namespace mscom {
 
 template<typename Interface, const IID& _IID>
 class COMPtrHolder
 {
 public:
@@ -205,18 +207,20 @@ struct ParamTraits<mozilla::mscom::COMPt
         return false;
       }
     }
 
     paramType::EnvType env;
 
     mozilla::mscom::ProxyStream proxyStream(_IID, buf.get(), length, &env);
     if (!proxyStream.IsValid()) {
+#if defined(MOZ_CRASHREPORTER)
       CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamValid"),
                                          NS_LITERAL_CSTRING("false"));
+#endif // defined(MOZ_CRASHREPORTER)
       return false;
     }
 
     typename paramType::COMPtrType ptr;
     if (!proxyStream.GetInterface(mozilla::mscom::getter_AddRefs(ptr))) {
       return false;
     }
 
--- a/ipc/mscom/Interceptor.cpp
+++ b/ipc/mscom/Interceptor.cpp
@@ -17,31 +17,43 @@
 #include "mozilla/mscom/Registration.h"
 #include "mozilla/mscom/Utils.h"
 #include "mozilla/ThreadLocal.h"
 #include "MainThreadUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/DebugOnly.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
-#include "nsExceptionHandler.h"
-#include "nsPrintfCString.h"
 #include "nsRefPtrHashtable.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 
+#if defined(MOZ_CRASHREPORTER)
+
+#include "nsExceptionHandler.h"
+#include "nsPrintfCString.h"
+
 #define ENSURE_HR_SUCCEEDED(hr) \
   if (FAILED((HRESULT)hr)) { \
     nsPrintfCString location("ENSURE_HR_SUCCEEDED \"%s\": %u", __FILE__, __LINE__); \
     nsPrintfCString hrAsStr("0x%08X", (HRESULT)hr); \
     CrashReporter::AnnotateCrashReport(location, hrAsStr); \
     MOZ_DIAGNOSTIC_ASSERT(SUCCEEDED((HRESULT)hr)); \
     return hr; \
   }
 
+#else
+
+#define ENSURE_HR_SUCCEEDED(hr) \
+  if (FAILED((HRESULT)hr)) { \
+    return hr; \
+  }
+
+#endif // defined(MOZ_CRASHREPORTER)
+
 namespace mozilla {
 namespace mscom {
 namespace detail {
 
 class LiveSet final
 {
 public:
   LiveSet()
--- a/ipc/mscom/MainThreadRuntime.cpp
+++ b/ipc/mscom/MainThreadRuntime.cpp
@@ -8,19 +8,19 @@
 
 #if defined(ACCESSIBILITY)
 #include "mozilla/a11y/Compatibility.h"
 #endif
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
-#if defined(ACCESSIBILITY)
+#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
-#endif // defined(ACCESSIBILITY)
+#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
 #include "nsWindowsHelpers.h"
 #include "nsXULAppAPI.h"
 
 #include <accctrl.h>
 #include <aclapi.h>
 #include <objbase.h>
 #include <objidl.h>
 
@@ -45,32 +45,32 @@ namespace mscom {
 MainThreadRuntime* MainThreadRuntime::sInstance = nullptr;
 
 MainThreadRuntime::MainThreadRuntime()
   : mInitResult(E_UNEXPECTED)
 #if defined(ACCESSIBILITY)
   , mActCtxRgn(a11y::Compatibility::GetActCtxResourceId())
 #endif // defined(ACCESSIBILITY)
 {
-#if defined(ACCESSIBILITY)
+#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
   GeckoProcessType procType = XRE_GetProcessType();
   if (procType == GeckoProcessType_Default ||
       procType == GeckoProcessType_Content) {
     auto actctx = ActivationContext::GetCurrent();
     nsAutoCString strActCtx;
     if (actctx.isOk()) {
       strActCtx.AppendPrintf("0x%p", actctx.unwrap());
     } else {
       strActCtx.AppendPrintf("HRESULT 0x%08X", actctx.unwrapErr());
     }
 
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AssemblyManifestCtx"),
                                        strActCtx);
   }
-#endif // defined(ACCESSIBILITY)
+#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
 
   // We must be the outermost COM initialization on this thread. The COM runtime
   // cannot be configured once we start manipulating objects
   MOZ_ASSERT(mStaRegion.IsValidOutermost());
   if (NS_WARN_IF(!mStaRegion.IsValidOutermost())) {
     return;
   }
 
--- a/ipc/mscom/ProxyStream.cpp
+++ b/ipc/mscom/ProxyStream.cpp
@@ -1,29 +1,31 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Move.h"
-#if defined(ACCESSIBILITY)
+#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
 #include "HandlerData.h"
 #include "mozilla/a11y/Platform.h"
 #include "mozilla/mscom/ActivationContext.h"
-#endif // defined(ACCESSIBILITY)
+#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
 #include "mozilla/mscom/EnsureMTA.h"
 #include "mozilla/mscom/ProxyStream.h"
 #include "mozilla/mscom/Utils.h"
 #include "mozilla/ScopeExit.h"
 
+#if defined(MOZ_CRASHREPORTER)
 #include "mozilla/mscom/Objref.h"
 #include "nsExceptionHandler.h"
 #include "nsPrintfCString.h"
 #include "RegistrationAnnotator.h"
+#endif
 
 #include <windows.h>
 #include <objbase.h>
 #include <shlwapi.h>
 
 namespace mozilla {
 namespace mscom {
 
@@ -39,60 +41,68 @@ ProxyStream::ProxyStream()
 // reconstructing the stream from a buffer anyway.
 ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf,
                          const int aInitBufSize, Environment* aEnv)
   : mGlobalLockedBuf(nullptr)
   , mHGlobal(nullptr)
   , mBufSize(aInitBufSize)
   , mPreserveStream(false)
 {
+#if defined(MOZ_CRASHREPORTER)
   NS_NAMED_LITERAL_CSTRING(kCrashReportKey, "ProxyStreamUnmarshalStatus");
+#endif
 
   if (!aInitBufSize) {
+#if defined(MOZ_CRASHREPORTER)
     CrashReporter::AnnotateCrashReport(kCrashReportKey,
                                        NS_LITERAL_CSTRING("!aInitBufSize"));
+#endif // defined(MOZ_CRASHREPORTER)
     // We marshaled a nullptr. Nothing else to do here.
     return;
   }
 
   HRESULT createStreamResult = CreateStream(aInitBuf, aInitBufSize,
                                             getter_AddRefs(mStream));
   if (FAILED(createStreamResult)) {
+#if defined(MOZ_CRASHREPORTER)
     nsPrintfCString hrAsStr("0x%08X", createStreamResult);
     CrashReporter::AnnotateCrashReport(kCrashReportKey, hrAsStr);
+#endif // defined(MOZ_CRASHREPORTER)
     return;
   }
 
   // NB: We can't check for a null mStream until after we have checked for
   // the zero aInitBufSize above. This is because InitStream will also fail
   // in that case, even though marshaling a nullptr is allowable.
   MOZ_ASSERT(mStream);
   if (!mStream) {
+#if defined(MOZ_CRASHREPORTER)
     CrashReporter::AnnotateCrashReport(kCrashReportKey,
                                        NS_LITERAL_CSTRING("!mStream"));
+#endif // defined(MOZ_CRASHREPORTER)
     return;
   }
 
-#if defined(ACCESSIBILITY)
+#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
   const uint32_t expectedStreamLen = GetOBJREFSize(WrapNotNull(mStream));
   nsAutoCString strActCtx;
   nsAutoString manifestPath;
-#endif // defined(ACCESSIBILITY)
+#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
 
   HRESULT unmarshalResult = S_OK;
 
   // We need to convert to an interface here otherwise we mess up const
   // correctness with IPDL. We'll request an IUnknown and then QI the
   // actual interface later.
 
-#if defined(ACCESSIBILITY)
+#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
   auto marshalFn = [this, &strActCtx, &manifestPath, &unmarshalResult, &aIID, aEnv]() -> void
 #else
   auto marshalFn = [this, &unmarshalResult, &aIID, aEnv]() -> void
-#endif // defined(ACCESSIBILITY)
+#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
   {
     if (aEnv) {
       bool pushOk = aEnv->Push();
       MOZ_DIAGNOSTIC_ASSERT(pushOk);
       if (!pushOk) {
         return;
       }
     }
@@ -101,26 +111,26 @@ ProxyStream::ProxyStream(REFIID aIID, co
       if (!aEnv) {
         return;
       }
 
       bool popOk = aEnv->Pop();
       MOZ_DIAGNOSTIC_ASSERT(popOk);
     });
 
-#if defined(ACCESSIBILITY)
+#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
     auto curActCtx = ActivationContext::GetCurrent();
     if (curActCtx.isOk()) {
       strActCtx.AppendPrintf("0x%p", curActCtx.unwrap());
     } else {
       strActCtx.AppendPrintf("HRESULT 0x%08X", curActCtx.unwrapErr());
     }
 
     ActivationContext::GetCurrentManifestPath(manifestPath);
-#endif // defined(ACCESSIBILITY)
+#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
 
     unmarshalResult =
       ::CoUnmarshalInterface(mStream, aIID, getter_AddRefs(mUnmarshaledProxy));
     MOZ_ASSERT(SUCCEEDED(unmarshalResult));
   };
 
   if (XRE_IsParentProcess()) {
     // We'll marshal this stuff directly using the current thread, therefore its
@@ -128,16 +138,17 @@ ProxyStream::ProxyStream(REFIID aIID, co
     marshalFn();
   } else {
     // When marshaling in child processes, we want to force the MTA.
     EnsureMTA mta(marshalFn);
   }
 
   mStream = nullptr;
 
+#if defined(MOZ_CRASHREPORTER)
   if (FAILED(unmarshalResult) || !mUnmarshaledProxy) {
     nsPrintfCString hrAsStr("0x%08X", unmarshalResult);
     CrashReporter::AnnotateCrashReport(
         NS_LITERAL_CSTRING("CoUnmarshalInterfaceResult"), hrAsStr);
     AnnotateInterfaceRegistration(aIID);
     if (!mUnmarshaledProxy) {
       CrashReporter::AnnotateCrashReport(kCrashReportKey,
                                          NS_LITERAL_CSTRING("!mUnmarshaledProxy"));
@@ -160,16 +171,17 @@ ProxyStream::ProxyStream(REFIID aIID, co
                                        strExpectedStreamLen);
 
     nsAutoCString actualStreamLen;
     actualStreamLen.AppendInt(aInitBufSize);
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ActualStreamLen"),
                                        actualStreamLen);
 #endif // defined(ACCESSIBILITY)
   }
+#endif // defined(MOZ_CRASHREPORTER)
 }
 
 ProxyStream::ProxyStream(ProxyStream&& aOther)
   : mGlobalLockedBuf(nullptr)
   , mHGlobal(nullptr)
   , mBufSize(0)
   , mPreserveStream(false)
 {
@@ -291,21 +303,27 @@ ProxyStream::ProxyStream(REFIID aIID, IU
   int streamSize = 0;
   DWORD mshlFlags = mPreserveStream ? MSHLFLAGS_TABLESTRONG : MSHLFLAGS_NORMAL;
 
   HRESULT createStreamResult = S_OK;
   HRESULT marshalResult = S_OK;
   HRESULT statResult = S_OK;
   HRESULT getHGlobalResult = S_OK;
 
+#if defined(MOZ_CRASHREPORTER)
   nsAutoString manifestPath;
 
   auto marshalFn = [this, &aIID, aObject, mshlFlags, &stream, &streamSize,
                     &hglobal, &createStreamResult, &marshalResult, &statResult,
                     &getHGlobalResult, aEnv, &manifestPath]() -> void
+#else
+  auto marshalFn = [this, &aIID, aObject, mshlFlags, &stream, &streamSize,
+                    &hglobal, &createStreamResult, &marshalResult, &statResult,
+                    &getHGlobalResult, aEnv]() -> void
+#endif // defined(MOZ_CRASHREPORTER)
   {
     if (aEnv) {
       bool pushOk = aEnv->Push();
       MOZ_DIAGNOSTIC_ASSERT(pushOk);
       if (!pushOk) {
         return;
       }
     }
@@ -320,19 +338,19 @@ ProxyStream::ProxyStream(REFIID aIID, IU
     });
 
     createStreamResult = ::CreateStreamOnHGlobal(nullptr, TRUE,
                                                  getter_AddRefs(stream));
     if (FAILED(createStreamResult)) {
       return;
     }
 
-#if defined(ACCESSIBILITY)
+#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER)
     ActivationContext::GetCurrentManifestPath(manifestPath);
-#endif // defined(ACCESSIBILITY)
+#endif // defined(MOZ_CRASHREPORTER)
 
     marshalResult = ::CoMarshalInterface(stream, aIID, aObject, MSHCTX_LOCAL,
                                          nullptr, mshlFlags);
     MOZ_DIAGNOSTIC_ASSERT(marshalResult != E_INVALIDARG);
     if (FAILED(marshalResult)) {
       return;
     }
 
@@ -352,16 +370,17 @@ ProxyStream::ProxyStream(REFIID aIID, IU
     // We'll marshal this stuff directly using the current thread, therefore its
     // stub will reside in the same apartment as the current thread.
     marshalFn();
   } else {
     // When marshaling in child processes, we want to force the MTA.
     EnsureMTA mta(marshalFn);
   }
 
+#if defined(MOZ_CRASHREPORTER)
   if (FAILED(createStreamResult)) {
     nsPrintfCString hrAsStr("0x%08X", createStreamResult);
     CrashReporter::AnnotateCrashReport(
         NS_LITERAL_CSTRING("CreateStreamOnHGlobalFailure"),
         hrAsStr);
   }
 
   if (FAILED(marshalResult)) {
@@ -381,43 +400,50 @@ ProxyStream::ProxyStream(REFIID aIID, IU
   }
 
   if (FAILED(getHGlobalResult)) {
     nsPrintfCString hrAsStr("0x%08X", getHGlobalResult);
     CrashReporter::AnnotateCrashReport(
         NS_LITERAL_CSTRING("GetHGlobalFromStreamFailure"),
         hrAsStr);
   }
+#endif // defined(MOZ_CRASHREPORTER)
 
   mStream = mozilla::Move(stream);
 
   if (streamSize) {
+#if defined(MOZ_CRASHREPORTER)
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSizeFrom"),
                                        NS_LITERAL_CSTRING("IStream::Stat"));
+#endif // defined(MOZ_CRASHREPORTER)
     mBufSize = streamSize;
   }
 
   if (!hglobal) {
     return;
   }
 
   mGlobalLockedBuf = reinterpret_cast<BYTE*>(::GlobalLock(hglobal));
   mHGlobal = hglobal;
 
   // If we couldn't get the stream size directly from mStream, we may use
   // the size of the memory block allocated by the HGLOBAL, though it might
   // be larger than the actual stream size.
   if (!streamSize) {
+#if defined(MOZ_CRASHREPORTER)
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSizeFrom"),
                                        NS_LITERAL_CSTRING("GlobalSize"));
+#endif // defined(MOZ_CRASHREPORTER)
     mBufSize = static_cast<int>(::GlobalSize(hglobal));
   }
 
+#if defined(MOZ_CRASHREPORTER)
   nsAutoCString strBufSize;
   strBufSize.AppendInt(mBufSize);
 
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSize"),
                                      strBufSize);
+#endif // defined(MOZ_CRASHREPORTER)
 }
 
 } // namespace mscom
 } // namespace mozilla
 
--- a/ipc/mscom/RegistrationAnnotator.h
+++ b/ipc/mscom/RegistrationAnnotator.h
@@ -2,16 +2,20 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_mscom_RegistrationAnnotator_h
 #define mozilla_mscom_RegistrationAnnotator_h
 
+#if !defined(MOZ_CRASHREPORTER)
+#error "This header requires crash reporting to be enabled"
+#endif
+
 namespace mozilla {
 namespace mscom {
 
 void AnnotateInterfaceRegistration(REFIID aIid);
 void AnnotateClassRegistration(REFCLSID aClsid);
 
 } // namespace mscom
 } // namespace mozilla
--- a/ipc/mscom/moz.build
+++ b/ipc/mscom/moz.build
@@ -27,20 +27,24 @@ SOURCES += [
 UNIFIED_SOURCES += [
     'AgileReference.cpp',
     'EnsureMTA.cpp',
     'MainThreadClientInfo.cpp',
     'MainThreadRuntime.cpp',
     'Objref.cpp',
     'PassthruProxy.cpp',
     'ProxyStream.cpp',
-    'RegistrationAnnotator.cpp',
     'Utils.cpp',
 ]
 
+if CONFIG['MOZ_CRASHREPORTER']:
+    UNIFIED_SOURCES += [
+        'RegistrationAnnotator.cpp',
+    ]
+
 if CONFIG['ACCESSIBILITY']:
     DIRS += [
         'oop',
     ]
 
     EXPORTS.mozilla.mscom += [
         'ActivationContext.h',
         'DispatchForwarder.h',
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -13,17 +13,16 @@
 #include "xpcpublic.h"
 #include "XPCWrapper.h"
 #include "XPCJSMemoryReporter.h"
 #include "WrapperFactory.h"
 #include "mozJSComponentLoader.h"
 #include "nsAutoPtr.h"
 #include "nsNetUtil.h"
 
-#include "nsExceptionHandler.h"
 #include "nsIMemoryInfoDumper.h"
 #include "nsIMemoryReporter.h"
 #include "nsIObserverService.h"
 #include "nsIDebug2.h"
 #include "nsIDocShell.h"
 #include "nsIRunnable.h"
 #include "amIAddonManager.h"
 #include "nsPIDOMWindow.h"
@@ -56,16 +55,20 @@
 #include "nsGlobalWindow.h"
 #include "nsAboutProtocolUtils.h"
 
 #include "GeckoProfiler.h"
 #include "nsIInputStream.h"
 #include "nsIXULRuntime.h"
 #include "nsJSPrincipals.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
 using namespace mozilla;
 using namespace xpc;
 using namespace JS;
 using mozilla::dom::PerThreadAtomCache;
@@ -744,17 +747,19 @@ xpc_UnmarkSkippableJSHolders()
 XPCJSRuntime::GCSliceCallback(JSContext* cx,
                               JS::GCProgress progress,
                               const JS::GCDescription& desc)
 {
     XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
     if (!self)
         return;
 
+#ifdef MOZ_CRASHREPORTER
     CrashReporter::SetGarbageCollecting(progress == JS::GC_CYCLE_BEGIN);
+#endif
 
     if (self->mPrevGCSliceCallback)
         (*self->mPrevGCSliceCallback)(cx, progress, desc);
 }
 
 /* static */ void
 XPCJSRuntime::DoCycleCollectionCallback(JSContext* cx)
 {
--- a/js/xpconnect/src/XPCShellImpl.cpp
+++ b/js/xpconnect/src/XPCShellImpl.cpp
@@ -8,17 +8,16 @@
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "jsprf.h"
 #include "mozilla/ChaosMode.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/Preferences.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
-#include "nsExceptionHandler.h"
 #include "nsIServiceManager.h"
 #include "nsIFile.h"
 #include "nsString.h"
 #include "nsIDirectoryService.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nscore.h"
 #include "nsArrayEnumerator.h"
@@ -57,16 +56,21 @@
 #include <errno.h>
 #ifdef HAVE_IO_H
 #include <io.h>     /* for isatty() */
 #endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>     /* for isatty() */
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#include "nsICrashReporter.h"
+#endif
+
 #ifdef ENABLE_TESTS
 #include "xpctest_private.h"
 #endif
 
 using namespace mozilla;
 using namespace JS;
 using mozilla::dom::AutoJSAPI;
 using mozilla::dom::AutoEntryScript;
@@ -1184,25 +1188,27 @@ XRE_XPCShellMain(int argc, char** argv, 
                 return 1;
             }
             XRE_AddManifestLocation(NS_APP_LOCATION, lf);
 
             argc -= 2;
             argv += 2;
         }
 
+#ifdef MOZ_CRASHREPORTER
         const char* val = getenv("MOZ_CRASHREPORTER");
-        if (val && *val && !CrashReporter::IsDummy()) {
+        if (val && *val) {
             rv = CrashReporter::SetExceptionHandler(greDir, true);
             if (NS_FAILED(rv)) {
                 printf("CrashReporter::SetExceptionHandler failed!\n");
                 return 1;
             }
             MOZ_ASSERT(CrashReporter::GetEnabled());
         }
+#endif
 
         if (argc > 1 && !strcmp(argv[1], "--greomni")) {
             nsCOMPtr<nsIFile> greOmni;
             nsCOMPtr<nsIFile> appOmni;
             XRE_GetFileFromPath(argv[2], getter_AddRefs(greOmni));
             if (argc > 3 && !strcmp(argv[3], "--appomni")) {
                 XRE_GetFileFromPath(argv[4], getter_AddRefs(appOmni));
                 argc-=2;
@@ -1384,20 +1390,21 @@ XRE_XPCShellMain(int argc, char** argv, 
 
     if (!XRE_ShutdownTestShell())
         NS_ERROR("problem shutting down testshell");
 
     // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
     rv = NS_ShutdownXPCOM( nullptr );
     MOZ_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
 
+#ifdef MOZ_CRASHREPORTER
     // Shut down the crashreporter service to prevent leaking some strings it holds.
-    if (CrashReporter::GetEnabled()) {
+    if (CrashReporter::GetEnabled())
         CrashReporter::UnsetExceptionHandler();
-    }
+#endif
 
 #ifdef MOZ_GECKO_PROFILER
     // This must precede NS_LogTerm(), otherwise xpcshell return non-zero
     // during some tests, which causes failures.
     profiler_shutdown();
 #endif
 
     NS_LogTerm();
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -20,17 +20,16 @@
 #include "nsCSSParser.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsCSSRules.h"
 #include "nsContentUtils.h"
 #include "nsDOMTokenList.h"
 #include "nsDeviceContext.h"
 #include "nsIContentInlines.h"
-#include "nsICrashReporter.h"
 #include "nsIDOMNode.h"
 #include "nsIDocumentInlines.h"
 #include "nsILoadContext.h"
 #include "nsIFrame.h"
 #include "nsIMemoryReporter.h"
 #include "nsINode.h"
 #include "nsIPresShell.h"
 #include "nsIPresShellInlines.h"
@@ -71,16 +70,20 @@
 #include "mozilla/dom/HTMLBodyElement.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/URLExtraData.h"
 
 #if defined(MOZ_MEMORY)
 # include "mozmemory.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsICrashReporter.h"
+#endif
+
 using namespace mozilla;
 using namespace mozilla::css;
 using namespace mozilla::dom;
 
 #define SERVO_ARC_TYPE(name_, type_) \
   already_AddRefed<type_>            \
   type_##Strong::Consume() {         \
     RefPtr<type_> result;            \
@@ -2814,30 +2817,34 @@ Gecko_ReportUnexpectedCSSError(ErrorRepo
   nsDependentCSubstring sourceValue(source, sourceLen);
   reporter->OutputError(lineNumber, colNumber, sourceValue);
 }
 
 void
 Gecko_AddBufferToCrashReport(const void* addr, size_t len)
 {
   MOZ_ASSERT(NS_IsMainThread());
+#ifdef MOZ_CRASHREPORTER
   nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1");
   NS_ENSURE_TRUE_VOID(cr);
   cr->RegisterAppMemory((uint64_t) addr, len);
+#endif
 }
 
 void
 Gecko_AnnotateCrashReport(const char* key_str, const char* value_str)
 {
   MOZ_ASSERT(NS_IsMainThread());
   nsDependentCString key(key_str);
   nsDependentCString value(value_str);
+#ifdef MOZ_CRASHREPORTER
   nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1");
   NS_ENSURE_TRUE_VOID(cr);
   cr->AnnotateCrashReport(key, value);
+#endif
 }
 
 void
 Gecko_ContentList_AppendAll(
   nsSimpleContentList* aList,
   const Element** aElements,
   size_t aLength)
 {
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -4,42 +4,45 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsLayoutStylesheetCache.h"
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/Omnijar.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/SRIMetadata.h"
 #include "MainThreadUtils.h"
 #include "nsColor.h"
+#include "nsIConsoleService.h"
+#include "nsIFile.h"
+#include "nsNetUtil.h"
+#include "nsIObserverService.h"
+#include "nsServiceManagerUtils.h"
+#include "nsIXULRuntime.h"
+#include "nsPresContext.h"
+#include "nsPrintfCString.h"
+#include "nsXULAppAPI.h"
+
+// Includes for the crash report annotation in ErrorLoadingSheet.
+#ifdef MOZ_CRASHREPORTER
+#include "mozilla/Omnijar.h"
+#include "nsDirectoryService.h"
 #include "nsDirectoryServiceDefs.h"
-#include "nsDirectoryService.h"
 #include "nsExceptionHandler.h"
 #include "nsIChromeRegistry.h"
-#include "nsIConsoleService.h"
-#include "nsIFile.h"
-#include "nsIObserverService.h"
 #include "nsISimpleEnumerator.h"
 #include "nsISubstitutingProtocolHandler.h"
-#include "nsIXULRuntime.h"
-#include "nsNetUtil.h"
-#include "nsPresContext.h"
-#include "nsPrintfCString.h"
-#include "nsServiceManagerUtils.h"
-#include "nsXULAppAPI.h"
+#include "zlib.h"
 #include "nsZipArchive.h"
-
-#include "zlib.h"
+#endif
 
 using namespace mozilla;
 using namespace mozilla::css;
 
 static bool sNumberControlEnabled;
 
 #define NUMBER_CONTROL_PREF "dom.forms.number"
 
@@ -469,16 +472,17 @@ nsLayoutStylesheetCache::LoadSheetFile(n
   if (!exists) return;
 
   nsCOMPtr<nsIURI> uri;
   NS_NewFileURI(getter_AddRefs(uri), aFile);
 
   LoadSheet(uri, aSheet, aParsingMode, aFailureAction);
 }
 
+#ifdef MOZ_CRASHREPORTER
 static inline nsresult
 ComputeCRC32(nsIFile* aFile, uint32_t* aResult)
 {
   PRFileDesc* fd;
   nsresult rv = aFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t crc = crc32(0, nullptr, 0);
@@ -745,32 +749,36 @@ AnnotateCrashReport(nsIURI* aURI)
     }
   } else {
     annotation.AppendLiteral("No GRE omnijar\n");
   }
 
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("SheetLoadFailure"),
                                      NS_ConvertUTF16toUTF8(annotation));
 }
+#endif
 
 static void
 ErrorLoadingSheet(nsIURI* aURI, const char* aMsg, FailureAction aFailureAction)
 {
   nsPrintfCString errorMessage("%s loading built-in stylesheet '%s'",
                                aMsg,
                                aURI ? aURI->GetSpecOrDefault().get() : "");
   if (aFailureAction == eLogToConsole) {
     nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
     if (cs) {
       cs->LogStringMessage(NS_ConvertUTF8toUTF16(errorMessage).get());
       return;
     }
   }
 
+#ifdef MOZ_CRASHREPORTER
   AnnotateCrashReport(aURI);
+#endif
+
   MOZ_CRASH_UNSAFE_OOL(errorMessage.get());
 }
 
 void
 nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
                                    RefPtr<StyleSheet>* aSheet,
                                    SheetParsingMode aParsingMode,
                                    FailureAction aFailureAction)
@@ -787,18 +795,19 @@ nsLayoutStylesheetCache::LoadSheet(nsIUR
   if (!loader) {
     loader = new Loader(mBackendType, nullptr);
     if (!loader) {
       ErrorLoadingSheet(aURI, "no Loader", eCrash);
       return;
     }
   }
 
+#ifdef MOZ_CRASHREPORTER
   nsZipArchive::sFileCorruptedReason = nullptr;
-
+#endif
   nsresult rv = loader->LoadSheetSync(aURI, aParsingMode, true, aSheet);
   if (NS_FAILED(rv)) {
     ErrorLoadingSheet(aURI,
       nsPrintfCString("LoadSheetSync failed with error %" PRIx32, static_cast<uint32_t>(rv)).get(),
       aFailureAction);
   }
 }
 
--- a/memory/gtest/TestJemalloc.cpp
+++ b/memory/gtest/TestJemalloc.cpp
@@ -3,39 +3,43 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/mozalloc.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Vector.h"
 #include "mozmemory.h"
-#include "nsCOMPtr.h"
-#include "nsICrashReporter.h"
-#include "nsServiceManagerUtils.h"
 #include "Utils.h"
 
 #include "gtest/gtest.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsCOMPtr.h"
+#include "nsICrashReporter.h"
+#include "nsServiceManagerUtils.h"
+#endif
 
 #ifdef NIGHTLY_BUILD
 #if defined(DEBUG) && !defined(XP_WIN) && !defined(ANDROID)
 #define HAS_GDB_SLEEP_DURATION 1
 extern unsigned int _gdb_sleep_duration;
 #endif
 
 // Death tests are too slow on OSX because of the system crash reporter.
 #ifndef XP_DARWIN
 static void DisableCrashReporter()
 {
+#ifdef MOZ_CRASHREPORTER
   nsCOMPtr<nsICrashReporter> crashreporter =
     do_GetService("@mozilla.org/toolkit/crash-reporter;1");
   if (crashreporter) {
     crashreporter->SetEnabled(false);
   }
+#endif
 }
 
 // Wrap ASSERT_DEATH_IF_SUPPORTED to disable the crash reporter
 // when entering the subprocess, so that the expected crashes don't
 // create a minidump that the gtest harness will interpret as an error.
 #define ASSERT_DEATH_WRAP(a, b) \
   ASSERT_DEATH_IF_SUPPORTED({ DisableCrashReporter(); a; }, b)
 #else
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1986,17 +1986,19 @@ var BrowserApp = {
           case "privacy.trackingprotection.state": {
             aSubject.setAsAString(this.getTrackingProtectionState());
             break;
           }
 
           // Crash reporter submit pref must be fetched from nsICrashReporter
           // service.
           case "datareporting.crashreporter.submitEnabled":
-            if (AppConstants.MOZ_CRASHREPORTER) {
+            let crashReporterBuilt = "nsICrashReporter" in Ci &&
+                Services.appinfo instanceof Ci.nsICrashReporter;
+            if (crashReporterBuilt) {
               aSubject.setAsBool(Services.appinfo.submitReports);
             }
             break;
         }
         break;
       }
 
       case "android-set-pref": {
@@ -2039,17 +2041,19 @@ var BrowserApp = {
                 break;
             }
             aSubject.setAsEmpty();
             break;
           }
 
           // Crash reporter preference is in a service; set and return.
           case "datareporting.crashreporter.submitEnabled":
-            if (AppConstants.MOZ_CRASHREPORTER) {
+            let crashReporterBuilt = "nsICrashReporter" in Ci &&
+                Services.appinfo instanceof Ci.nsICrashReporter;
+            if (crashReporterBuilt) {
               Services.appinfo.submitReports = value;
               aSubject.setAsEmpty();
             }
             break;
         }
         break;
       }
 
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -1234,17 +1234,18 @@ SessionStore.prototype = {
     aFileTemp.renameTo(null, aFile.leafName);
     log("_write() writing synchronously");
 
     // Return a resolved promise to make the caller happy
     return Promise.resolve();
   },
 
   _updateCrashReportURL: function ss_updateCrashReportURL(aWindow) {
-    if (!AppConstants.MOZ_CRASHREPORTER) {
+    let crashReporterBuilt = "nsICrashReporter" in Ci && Services.appinfo instanceof Ci.nsICrashReporter;
+    if (!crashReporterBuilt) {
       return;
     }
 
     if (!aWindow.BrowserApp.selectedBrowser) {
       return;
     }
 
     try {
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -76,16 +76,20 @@
 #include "nsXPCOM.h"
 #include "nsXULAppAPI.h"
 #include "nsZipArchive.h"
 #include "plbase64.h"
 #include "PLDHashTable.h"
 #include "plstr.h"
 #include "prlink.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsICrashReporter.h"
+#endif
+
 #ifdef XP_WIN
 #include "windows.h"
 #endif
 
 using namespace mozilla;
 
 #ifdef DEBUG
 
--- a/netwerk/ipc/NeckoMessageUtils.h
+++ b/netwerk/ipc/NeckoMessageUtils.h
@@ -4,23 +4,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_net_NeckoMessageUtils_h
 #define mozilla_net_NeckoMessageUtils_h
 
 #include "mozilla/DebugOnly.h"
 
 #include "ipc/IPCMessageUtils.h"
-#include "nsExceptionHandler.h"
-#include "nsPrintfCString.h"
 #include "nsStringGlue.h"
 #include "prio.h"
 #include "mozilla/net/DNS.h"
 #include "TimingStruct.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#include "nsPrintfCString.h"
+#endif
 
 namespace IPC {
 
 // nsIPermissionManager utilities
 
 struct Permission
 {
   nsCString origin, type;
@@ -95,21 +97,22 @@ struct ParamTraits<mozilla::net::NetAddr
 #if defined(XP_UNIX)
     } else if (aParam.raw.family == AF_LOCAL) {
       // Train's already off the rails:  let's get a stack trace at least...
       MOZ_CRASH("Error: please post stack trace to "
                       "https://bugzilla.mozilla.org/show_bug.cgi?id=661158");
       aMsg->WriteBytes(aParam.local.path, sizeof(aParam.local.path));
 #endif
     } else {
+#ifdef MOZ_CRASHREPORTER
       if (XRE_IsParentProcess()) {
         nsPrintfCString msg("%d", aParam.raw.family);
         CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Unknown NetAddr socket family"), msg);
       }
-
+#endif
       MOZ_CRASH("Unknown socket family");
     }
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter, mozilla::net::NetAddr* aResult)
   {
     if (!ReadParam(aMsg, aIter, &aResult->raw.family))
       return false;
--- a/security/sandbox/linux/glue/SandboxCrash.cpp
+++ b/security/sandbox/linux/glue/SandboxCrash.cpp
@@ -13,17 +13,19 @@
 #include "SandboxLogging.h"
 
 #include <unistd.h>
 #include <sys/syscall.h>
 
 #include "mozilla/Unused.h"
 #include "mozilla/dom/Exceptions.h"
 #include "nsContentUtils.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 #include "mozilla/StackWalk.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 
 // Log JS stack info in the same place as the sandbox violation
 // message.  Useful in case the responsible code is JS and all we have
@@ -99,18 +101,21 @@ SandboxLogCStack()
   MozStackWalk(SandboxPrintStackFrame, /* skip */ 3, /* max */ 0, nullptr);
   SANDBOX_LOG_ERROR("end of stack.");
 }
 
 static void
 SandboxCrash(int nr, siginfo_t *info, void *void_context)
 {
   pid_t pid = getpid(), tid = syscall(__NR_gettid);
-  bool dumped = CrashReporter::WriteMinidumpForSigInfo(nr, info, void_context);
+  bool dumped = false;
 
+#ifdef MOZ_CRASHREPORTER
+  dumped = CrashReporter::WriteMinidumpForSigInfo(nr, info, void_context);
+#endif
   if (!dumped) {
     SANDBOX_LOG_ERROR("crash reporter is disabled (or failed);"
                       " trying stack trace:");
     SandboxLogCStack();
   }
 
   // Do this last, in case it crashes or deadlocks.
   SandboxLogJSStack();
--- a/storage/mozStorageService.cpp
+++ b/storage/mozStorageService.cpp
@@ -7,31 +7,34 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 
 #include "mozStorageService.h"
 #include "mozStorageConnection.h"
 #include "nsAutoPtr.h"
 #include "nsCollationCID.h"
 #include "nsEmbedCID.h"
-#include "nsExceptionHandler.h"
 #include "nsThreadUtils.h"
 #include "mozStoragePrivateHelpers.h"
 #include "nsIXPConnect.h"
 #include "nsIObserverService.h"
 #include "nsIPropertyBag2.h"
 #include "mozilla/Services.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/LateWriteChecks.h"
 #include "mozIStorageCompletionCallback.h"
 #include "mozIStoragePendingStatement.h"
 
 #include "sqlite3.h"
 #include "mozilla/AutoSQLiteLifetime.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #ifdef XP_WIN
 // "windows.h" was included and it can #define lots of things we care about...
 #undef CompareString
 #endif
 
 #include "nsIPromptService.h"
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -793,21 +796,23 @@ Service::Observe(nsISupports *, const ch
       return true;
     });
 
     if (gShutdownChecks == SCM_CRASH) {
       nsTArray<RefPtr<Connection> > connections;
       getConnections(connections);
       for (uint32_t i = 0, n = connections.Length(); i < n; i++) {
         if (!connections[i]->isClosed()) {
+#ifdef MOZ_CRASHREPORTER
           // getFilename is only the leaf name for the database file,
           // so it shouldn't contain privacy-sensitive information.
           CrashReporter::AnnotateCrashReport(
             NS_LITERAL_CSTRING("StorageConnectionNotClosed"),
             connections[i]->getFilename());
+#endif
 #ifdef DEBUG
           printf_stderr("Storage connection not closed: %s",
                         connections[i]->getFilename().get());
 #endif
           MOZ_CRASH();
         }
       }
     }
--- a/testing/gtest/mozilla/GTestRunner.cpp
+++ b/testing/gtest/mozilla/GTestRunner.cpp
@@ -1,17 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * * This Source Code Form is subject to the terms of the Mozilla Public
  * * License, v. 2.0. If a copy of the MPL was not distributed with this
  * * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GTestRunner.h"
 #include "gtest/gtest.h"
 #include "mozilla/Attributes.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsICrashReporter.h"
+#endif
 #include "testing/TestHarness.h"
 #include "prenv.h"
 #ifdef XP_WIN
 #include "mozilla/ipc/WindowsMessageLoop.h"
 #endif
 
 using ::testing::EmptyTestEventListener;
 using ::testing::InitGoogleTest;
@@ -84,16 +86,17 @@ int RunGTestFunc(int* argc, char** argv)
 
   PR_SetEnv("XPCOM_DEBUG_BREAK=stack-and-abort");
 
   ScopedXPCOM xpcom("GTest");
 
 #ifdef XP_WIN
   mozilla::ipc::windows::InitUIThread();
 #endif
+#ifdef MOZ_CRASHREPORTER
   nsCOMPtr<nsICrashReporter> crashreporter;
   char *crashreporterStr = PR_GetEnv("MOZ_CRASHREPORTER");
   if (crashreporterStr && !strcmp(crashreporterStr, "1")) {
     //TODO: move this to an even-more-common location to use in all
     // C++ unittests
     crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1");
     if (crashreporter) {
       std::cerr << "Setting up crash reporting" << std::endl;
@@ -104,16 +107,17 @@ int RunGTestFunc(int* argc, char** argv)
       nsresult rv = dirsvc->Get(NS_OS_CURRENT_WORKING_DIR,
                        NS_GET_IID(nsIFile),
                        getter_AddRefs(cwd));
       MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
       crashreporter->SetEnabled(true);
       crashreporter->SetMinidumpPath(cwd);
     }
   }
+#endif
 
   return RUN_ALL_TESTS();
 }
 
 // We use a static var 'RunGTest' defined in nsAppRunner.cpp.
 // RunGTest is initialized to nullptr but if GTest (this file)
 // is linked in then RunGTest will be set here indicating
 // GTest is supported.
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -1083,17 +1083,17 @@ this.BrowserTestUtils = {
         // we might see this called as the process terminates due to previous tests.
         // We are only looking for "abnormal" exits...
         if (!subject.hasKey("abnormal")) {
           dump("\nThis is a normal termination and isn't the one we are looking for...\n");
           return;
         }
 
         let dumpID;
-        if (AppConstants.MOZ_CRASHREPORTER) {
+        if ('nsICrashReporter' in Ci) {
           dumpID = subject.getPropertyAsAString('dumpID');
           if (!dumpID) {
             return reject("dumpID was not present despite crash reporting " +
                           "being enabled");
           }
         }
 
         let removalPromise = Promise.resolve();
--- a/toolkit/components/crashes/moz.build
+++ b/toolkit/components/crashes/moz.build
@@ -1,33 +1,31 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SPHINX_TREES['crash-manager'] = 'docs'
 
+EXTRA_COMPONENTS += [
+    'CrashService.js',
+    'CrashService.manifest',
+]
+
+EXTRA_JS_MODULES += [
+    'CrashManager.jsm',
+]
+
+TESTING_JS_MODULES += [
+    'CrashManagerTest.jsm',
+]
+
+XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
+
 XPIDL_MODULE = 'toolkit_crashservice'
 
 XPIDL_SOURCES += [
     'nsICrashService.idl',
 ]
 
-if CONFIG['MOZ_CRASHREPORTER']:
-    EXTRA_COMPONENTS += [
-        'CrashService.js',
-        'CrashService.manifest',
-    ]
-
-    EXTRA_JS_MODULES += [
-        'CrashManager.jsm',
-    ]
-
-    TESTING_JS_MODULES += [
-        'CrashManagerTest.jsm',
-    ]
-
-    XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
-
 with Files('**'):
     BUG_COMPONENT = ('Toolkit', 'Crash Reporting')
-
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -21,17 +21,16 @@ DIRS += [
     'apppicker',
     'asyncshutdown',
     'backgroundhangmonitor',
     'browser',
     'cloudstorage',
     'commandlines',
     'contentprefs',
     'contextualidentity',
-    'crashes',
     'crashmonitor',
     'diskspacewatcher',
     'downloads',
     'extensions',
     'filewatcher',
     'finalizationwitness',
     'find',
     'jsdownloads',
@@ -76,16 +75,19 @@ DIRS += [
 ]
 
 if CONFIG['MOZ_BUILD_APP'] != 'mobile/android':
     DIRS += ['narrate', 'viewsource'];
 
     if CONFIG['NS_PRINTING']:
         DIRS += ['printing']
 
+if CONFIG['MOZ_CRASHREPORTER']:
+    DIRS += ['crashes']
+
 if CONFIG['BUILD_CTYPES']:
     DIRS += ['ctypes']
 
 if CONFIG['MOZ_FEEDS']:
     DIRS += ['feeds']
 
 if CONFIG['MOZ_XUL']:
     DIRS += ['autocomplete', 'printingui', 'satchel']
--- a/toolkit/components/places/tests/gtest/places_test_harness_tail.h
+++ b/toolkit/components/places/tests/gtest/places_test_harness_tail.h
@@ -1,17 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsWidgetsCID.h"
 #include "nsIComponentRegistrar.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsICrashReporter.h"
+#endif
 
 #ifndef TEST_NAME
 #error "Must #define TEST_NAME before including places_test_harness_tail.h"
 #endif
 
 int gTestsIndex = 0;
 
 #define TEST_INFO_STR "TEST-INFO | "
--- a/toolkit/components/terminator/nsTerminator.cpp
+++ b/toolkit/components/terminator/nsTerminator.cpp
@@ -24,17 +24,19 @@
 
 #include "nsString.h"
 #include "nsServiceManagerUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 
 #include "nsIObserverService.h"
 #include "nsIPrefService.h"
+#if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
+#endif
 #include "GeckoProfiler.h"
 #include "nsThreadUtils.h"
 
 #if defined(XP_WIN)
 #include <windows.h>
 #else
 #include <unistd.h>
 #endif
@@ -158,18 +160,19 @@ RunWatchdog(void* arg)
 
     mozilla::dom::workers::RuntimeService* runtimeService =
       mozilla::dom::workers::RuntimeService::GetService();
     if (runtimeService) {
      runtimeService->CrashIfHanging();
     }
 
     // Shutdown is apparently dead. Crash the process.
+#if defined(MOZ_CRASHREPORTER)
     CrashReporter::SetMinidumpAnalysisAllThreads();
-
+#endif
     MOZ_CRASH("Shutdown too long, probably frozen, causing a crash.");
   }
 }
 
 ////////////////////////////////////////////
 //
 // Writer thread
 //
@@ -547,17 +550,19 @@ nsTerminator::UpdateTelemetry()
   PR_EnterMonitor(gWriteReady);
   PR_Notify(gWriteReady);
   PR_ExitMonitor(gWriteReady);
 }
 
 void
 nsTerminator::UpdateCrashReport(const char* aTopic)
 {
+#if defined(MOZ_CRASHREPORTER)
   // In case of crash, we wish to know where in shutdown we are
   nsAutoCString report(aTopic);
 
   Unused << CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ShutdownProgress"),
                                                report);
+#endif // defined(MOZ_CRASHREPORTER)
 }
 
 
 } // namespace mozilla
--- a/toolkit/crashreporter/jar.mn
+++ b/toolkit/crashreporter/jar.mn
@@ -1,9 +1,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 toolkit.jar:
-#ifdef MOZ_CRASHREPORTER
   content/global/crashes.xhtml            (content/crashes.xhtml)
   content/global/crashes.js               (content/crashes.js)
-#endif
--- a/toolkit/crashreporter/moz.build
+++ b/toolkit/crashreporter/moz.build
@@ -1,125 +1,115 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SPHINX_TREES['crashreporter'] = 'docs'
 
+if CONFIG['OS_ARCH'] == 'WINNT':
+    DIRS += [
+        'google-breakpad/src/common',
+        'google-breakpad/src/processor',
+        'breakpad-windows-libxul',
+    ]
+
+    if CONFIG['MSVC_HAS_DIA_SDK']:
+        DIRS += ['google-breakpad/src/tools/windows/dump_syms']
+
+    if CONFIG['MOZ_CRASHREPORTER_INJECTOR']:
+        DIRS += ['breakpad-windows-standalone']
+
+elif CONFIG['OS_ARCH'] == 'Darwin':
+    DIRS += [
+        'breakpad-client',
+        'breakpad-client/mac/crash_generation',
+        'breakpad-client/mac/handler',
+        'google-breakpad/src/common',
+        'google-breakpad/src/common/mac',
+        'google-breakpad/src/processor',
+        'google-breakpad/src/tools/mac/dump_syms',
+    ]
+
+elif CONFIG['OS_ARCH'] == 'Linux':
+    DIRS += [
+        'breakpad-client',
+        'breakpad-client/linux/',
+        'google-breakpad/src/common',
+        'google-breakpad/src/common/linux',
+        'google-breakpad/src/processor',
+        'google-breakpad/src/tools/linux/dump_syms',
+    ]
+
+
+DIRS += [
+    'client',
+    'minidump-analyzer',
+]
+
+if CONFIG['MOZ_CRASHREPORTER_INJECTOR']:
+    DIRS += ['injector']
+    UNIFIED_SOURCES += [
+        'InjectCrashReporter.cpp',
+        'LoadLibraryRemote.cpp',
+    ]
+
+if CONFIG['ENABLE_TESTS']:
+    DIRS += ['test/gtest']
+
+TEST_DIRS += ['test']
+
 EXPORTS += [
     'nsExceptionHandler.h',
 ]
 
-JAR_MANIFESTS += ['jar.mn']
+UNIFIED_SOURCES += [
+    'nsExceptionHandler.cpp',
+    'ThreadAnnotation.cpp',
+]
 
-UNIFIED_SOURCES = [
-    'nsExceptionHandlerUtils.cpp',
+if CONFIG['OS_ARCH'] == 'Darwin':
+    UNIFIED_SOURCES += [
+        'mac_utils.mm',
+    ]
+
+EXTRA_JS_MODULES += [
+    'CrashReports.jsm',
+    'CrashSubmit.jsm',
+    'KeyValueParser.jsm',
 ]
 
+include('/ipc/chromium/chromium-config.mozbuild')
+
 FINAL_LIBRARY = 'xul'
 
-if CONFIG['MOZ_CRASHREPORTER']:
-    if CONFIG['OS_ARCH'] == 'WINNT':
-        DIRS += [
-            'google-breakpad/src/common',
-            'google-breakpad/src/processor',
-            'breakpad-windows-libxul',
-        ]
-
-        if CONFIG['MSVC_HAS_DIA_SDK']:
-            DIRS += ['google-breakpad/src/tools/windows/dump_syms']
-
-        if CONFIG['MOZ_CRASHREPORTER_INJECTOR']:
-            DIRS += ['breakpad-windows-standalone']
-
-    elif CONFIG['OS_ARCH'] == 'Darwin':
-        DIRS += [
-            'breakpad-client',
-            'breakpad-client/mac/crash_generation',
-            'breakpad-client/mac/handler',
-            'google-breakpad/src/common',
-            'google-breakpad/src/common/mac',
-            'google-breakpad/src/processor',
-            'google-breakpad/src/tools/mac/dump_syms',
-        ]
-
-    elif CONFIG['OS_ARCH'] == 'Linux':
-        DIRS += [
-            'breakpad-client',
-            'breakpad-client/linux/',
-            'google-breakpad/src/common',
-            'google-breakpad/src/common/linux',
-            'google-breakpad/src/processor',
-            'google-breakpad/src/tools/linux/dump_syms',
-        ]
-
-
-    DIRS += [
-        'client',
-        'minidump-analyzer',
+if CONFIG['OS_TARGET'] == 'Android':
+    DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION']
+    DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION']
+    DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME']
+    # NDK5 workarounds
+    DEFINES['_STLP_CONST_CONSTRUCTOR_BUG'] = True
+    DEFINES['_STLP_NO_MEMBER_TEMPLATES'] = True
+    LOCAL_INCLUDES += [
+        '/toolkit/crashreporter/google-breakpad/src/common/android/include',
     ]
 
-    if CONFIG['MOZ_CRASHREPORTER_INJECTOR']:
-        DIRS += ['injector']
-        UNIFIED_SOURCES += [
-            'InjectCrashReporter.cpp',
-            'LoadLibraryRemote.cpp',
-        ]
-
-    if CONFIG['ENABLE_TESTS']:
-        DIRS += ['test/gtest']
-
-    TEST_DIRS += ['test']
+DEFINES['UNICODE'] = True
+DEFINES['_UNICODE'] = True
 
-    UNIFIED_SOURCES += [
-        'nsExceptionHandler.cpp',
-        'ThreadAnnotation.cpp',
-    ]
-
-    if CONFIG['OS_ARCH'] == 'Darwin':
-        UNIFIED_SOURCES += [
-            'mac_utils.mm',
-        ]
-
-    EXTRA_JS_MODULES += [
-        'CrashReports.jsm',
-        'CrashSubmit.jsm',
-        'KeyValueParser.jsm',
-    ]
-
-    include('/ipc/chromium/chromium-config.mozbuild')
+JAR_MANIFESTS += ['jar.mn']
 
-    if CONFIG['OS_TARGET'] == 'Android':
-        DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION']
-        DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION']
-        DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME']
-        # NDK5 workarounds
-        DEFINES['_STLP_CONST_CONSTRUCTOR_BUG'] = True
-        DEFINES['_STLP_NO_MEMBER_TEMPLATES'] = True
-        LOCAL_INCLUDES += [
-            '/toolkit/crashreporter/google-breakpad/src/common/android/include',
-        ]
-
-    DEFINES['UNICODE'] = True
-    DEFINES['_UNICODE'] = True
+LOCAL_INCLUDES += [
+    'google-breakpad/src',
+]
 
-    LOCAL_INCLUDES += [
-        'google-breakpad/src',
-    ]
-
-    PYTHON_UNITTEST_MANIFESTS += [
-        'tools/python.ini',
-    ]
+PYTHON_UNITTEST_MANIFESTS += [
+    'tools/python.ini',
+]
 
-    include('/toolkit/crashreporter/crashreporter.mozbuild')
-
-    if CONFIG['GNU_CXX']:
-        CXXFLAGS += ['-Wno-shadow']
-else:
-    UNIFIED_SOURCES += [
-        'nsDummyExceptionHandler.cpp',
-    ]
-
+include('/toolkit/crashreporter/crashreporter.mozbuild')
 
 with Files('**'):
     BUG_COMPONENT = ('Toolkit', 'Crash Reporting')
+
+if CONFIG['GNU_CXX']:
+    CXXFLAGS += ['-Wno-shadow']
deleted file mode 100644
--- a/toolkit/crashreporter/nsDummyExceptionHandler.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsExceptionHandler.h"
-#include "nsExceptionHandlerUtils.h"
-
-namespace CrashReporter {
-
-void
-AnnotateOOMAllocationSize(size_t size)
-{
-}
-
-void
-AnnotateTexturesSize(size_t size)
-{
-}
-
-void
-AnnotatePendingIPC(size_t aNumOfPendingIPC,
-                   uint32_t aTopPendingIPCCount,
-                   const char* aTopPendingIPCName,
-                   uint32_t aTopPendingIPCType)
-{
-}
-
-nsresult
-SetExceptionHandler(nsIFile* aXREDirectory,
-                    bool force/*=false*/)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-bool
-GetEnabled()
-{
-  return false;
-}
-
-bool
-GetMinidumpPath(nsAString& aPath)
-{
-  return false;
-}
-
-nsresult
-SetMinidumpPath(const nsAString& aPath)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-SetupExtraData(nsIFile* aAppDataDirectory,
-               const nsACString& aBuildID)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-UnsetExceptionHandler()
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-AnnotateCrashReport(const nsACString& key,
-                    const nsACString& data)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-RemoveCrashReportAnnotation(const nsACString& key)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-SetGarbageCollecting(bool collecting)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-void
-SetEventloopNestingLevel(uint32_t level)
-{
-}
-
-void
-SetMinidumpAnalysisAllThreads()
-{
-}
-
-nsresult
-AppendAppNotesToCrashReport(const nsACString& data)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-bool
-GetAnnotation(const nsACString& key, nsACString& data)
-{
-  return false;
-}
-
-nsresult
-RegisterAppMemory(void* ptr, size_t length)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-UnregisterAppMemory(void* ptr)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-void
-SetIncludeContextHeap(bool aValue)
-{
-}
-
-bool
-GetServerURL(nsACString& aServerURL)
-{
-  return false;
-}
-
-nsresult
-SetServerURL(const nsACString& aServerURL)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-SetRestartArgs(int argc, char** argv)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-#ifdef XP_WIN32
-nsresult
-WriteMinidumpForException(EXCEPTION_POINTERS* aExceptionInfo)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-#endif
-
-#ifdef XP_LINUX
-bool
-WriteMinidumpForSigInfo(int signo,
-                        siginfo_t* info,
-                        void* uc)
-{
-  return false;
-}
-#endif
-
-#ifdef XP_MACOSX
-nsresult
-AppendObjCExceptionInfoToAppNotes(void *inException)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-#endif
-
-nsresult
-GetSubmitReports(bool* aSubmitReports)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-SetSubmitReports(bool aSubmitReports)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-void
-SetProfileDirectory(nsIFile* aDir)
-{
-}
-
-void
-SetUserAppDataDirectory(nsIFile* aDir)
-{
-}
-
-void
-UpdateCrashEventsDir()
-{
-}
-
-bool
-GetCrashEventsDir(nsAString& aPath)
-{
-  return false;
-}
-
-void
-SetMemoryReportFile(nsIFile* aFile)
-{
-}
-
-nsresult
-GetDefaultMemoryReportFile(nsIFile** aFile)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-void
-SetTelemetrySessionId(const nsACString& id)
-{
-}
-
-void
-DeleteMinidumpFilesForID(const nsAString& id)
-{
-}
-
-bool
-GetMinidumpForID(const nsAString& id, nsIFile** minidump)
-{
-  return false;
-}
-
-bool
-GetIDFromMinidump(nsIFile* minidump, nsAString& id)
-{
-  return false;
-}
-
-bool
-GetExtraFileForID(const nsAString& id,
-                  nsIFile** extraFile)
-{
-  return false;
-}
-
-bool
-GetExtraFileForMinidump(nsIFile* minidump,
-                        nsIFile** extraFile)
-{
-  return false;
-}
-
-bool
-AppendExtraData(const nsAString& id,
-                const AnnotationTable& data)
-{
-  return false;
-}
-
-bool
-AppendExtraData(nsIFile* extraFile,
-                const AnnotationTable& data)
-{
-  return false;
-}
-
-void
-OOPInit()
-{
-}
-
-void
-GetChildProcessTmpDir(nsIFile** aOutTmpDir)
-{
-}
-
-#if defined(XP_WIN) || defined(XP_MACOSX)
-const char*
-GetChildNotificationPipe()
-{
-  return nullptr;
-}
-#endif
-
-#ifdef MOZ_CRASHREPORTER_INJECTOR
-void
-InjectCrashReporterIntoProcess(DWORD processID, InjectorCrashCallback* cb)
-{
-}
-
-void
-UnregisterInjectorCallback(DWORD processID)
-{
-}
-
-#endif // MOZ_CRASHREPORTER_INJECTOR
-
-bool
-GetLastRunCrashID(nsAString& id)
-{
-  return false;
-}
-
-#if defined(XP_WIN) || defined(XP_MACOSX)
-void
-InitChildProcessTmpDir(nsIFile* aDirOverride)
-{
-}
-#endif // defined(XP_WIN) || defined(XP_MACOSX)
-
-#if defined(XP_WIN)
-bool
-SetRemoteExceptionHandler(const nsACString& crashPipe)
-{
-  return false;
-}
-
-#elif defined(XP_LINUX)
-
-bool
-CreateNotificationPipeForChild(int* childCrashFd, int* childCrashRemapFd)
-{
-  return false;
-}
-
-bool
-SetRemoteExceptionHandler()
-{
-  return false;
-}
-
-#elif defined(XP_MACOSX)
-
-bool
-SetRemoteExceptionHandler(const nsACString& crashPipe)
-{
-  return false;
-}
-#endif  // XP_WIN
-
-bool
-TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, uint32_t* aSequence)
-{
-  return false;
-}
-
-void
-RenameAdditionalHangMinidump(nsIFile* minidump, nsIFile* childMinidump,
-                             const nsACString& name)
-{
-}
-
-ThreadId
-CurrentThreadId()
-{
-  return -1;
-}
-
-bool
-TakeMinidump(nsIFile** aResult, bool aMoveToPending)
-{
-  return false;
-}
-
-void
-CreateMinidumpsAndPair(ProcessHandle aTargetPid,
-                       ThreadId aTargetBlamedThread,
-                       const nsACString& aIncomingPairName,
-                       nsIFile* aIncomingDumpToPair,
-                       nsIFile** aMainDumpOut,
-                       std::function<void(bool)>&& aCallback,
-                       bool aAsync)
-{
-}
-
-bool
-CreateAdditionalChildMinidump(ProcessHandle childPid,
-                              ThreadId childBlamedThread,
-                              nsIFile* parentMinidump,
-                              const nsACString& name)
-{
-  return false;
-}
-
-bool
-UnsetRemoteExceptionHandler()
-{
-  return false;
-}
-
-#if defined(MOZ_WIDGET_ANDROID)
-void
-SetNotificationPipeForChild(int childCrashFd)
-{
-}
-
-void
-AddLibraryMapping(const char* library_name,
-                  uintptr_t   start_address,
-                  size_t      mapping_length,
-                  size_t      file_offset)
-{
-}
-#endif
-
-// From ThreadAnnotation.cpp
-
-void
-InitThreadAnnotation()
-{
-}
-
-void
-SetCurrentThreadName(const char* aName)
-{
-}
-
-void
-GetFlatThreadAnnotation(const std::function<void(const char*)>& aCallback)
-{
-}
-
-void
-ShutdownThreadAnnotation()
-{
-}
-
-} // namespace CrashReporter
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsExceptionHandler.h"
-#include "nsExceptionHandlerUtils.h"
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryService.h"
 #include "nsDataHashtable.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Services.h"
 #include "nsIObserverService.h"
@@ -83,16 +82,17 @@ using mozilla::InjectCrashRunnable;
 #include <prio.h>
 #include "mozilla/Mutex.h"
 #include "nsDebug.h"
 #include "nsCRT.h"
 #include "nsIFile.h"
 #include <map>
 #include <vector>
 
+#include "mozilla/double-conversion.h"
 #include "mozilla/IOInterposer.h"
 #include "mozilla/mozalloc_oom.h"
 #include "mozilla/WindowsDllBlocklist.h"
 
 #if defined(XP_MACOSX)
 CFStringRef reporterClientAppID = CFSTR("org.mozilla.crashreporter");
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
@@ -408,16 +408,64 @@ typedef struct {
   size_t      length;
   size_t      file_offset;
 } mapping_info;
 static std::vector<mapping_info> library_mappings;
 typedef std::map<uint32_t,google_breakpad::MappingList> MappingMap;
 #endif
 }
 
+// Format a non-negative double to a string, without using C-library functions,
+// which need to be avoided (.e.g. bug 1240160, comment 10).  Leave the utility
+// non-file static so that we can gtest it.  Return false if we failed to
+// get the formatting done correctly.
+bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength)
+{
+  // aBufferLength is the size of the buffer.  Be paranoid.
+  aBuffer[aBufferLength-1] = '\0';
+
+  if (aValue < 0) {
+    return false;
+  }
+
+  int length, point, i;
+  bool sign;
+  bool ok = true;
+  double_conversion::DoubleToStringConverter::DoubleToAscii(
+                                     aValue,
+                                     double_conversion::DoubleToStringConverter::SHORTEST,
+                                     8,
+                                     aBuffer,
+                                     aBufferLength,
+                                     &sign,
+                                     &length,
+                                     &point);
+
+  // length does not account for the 0 terminator.
+  if (length > point && (length+1) < (aBufferLength-1)) {
+    // We have to insert a decimal point.  Not worried about adding a leading zero
+    // in the < 1 (point == 0) case.
+    aBuffer[length+1] = '\0';
+    for (i=length; i>point; i-=1) {
+      aBuffer[i] = aBuffer[i-1];
+    }
+    aBuffer[i] = '.'; // Not worried about locales
+  } else if (length < point) {
+    // Trailing zeros scenario
+    for (i=length; i<point; i+=1) {
+      if (i >= aBufferLength-2) {
+        ok = false;
+      }
+      aBuffer[i] = '0';
+    }
+    aBuffer[i] = '\0';
+  }
+  return ok;
+}
+
 namespace CrashReporter {
 
 #ifdef XP_LINUX
 static inline void
 my_inttostring(intmax_t t, char* buffer, size_t buffer_length)
 {
   my_memset(buffer, 0, buffer_length);
   my_uitos(buffer, t, my_uint_len(t));
--- a/toolkit/crashreporter/nsExceptionHandler.h
+++ b/toolkit/crashreporter/nsExceptionHandler.h
@@ -1,19 +1,13 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-// This header has two implementations, the real one in nsExceptionHandler.cpp
-// and a dummy in nsDummyExceptionHandler.cpp. The latter is used in builds
-// configured with --disable-crashreporter. If you add or remove a function
-// from this header you must update both implementations otherwise you'll break
-// builds that disable the crash reporter.
-
 #ifndef nsExceptionHandler_h__
 #define nsExceptionHandler_h__
 
 #include "mozilla/Assertions.h"
 
 #include <functional>
 #include <stddef.h>
 #include <stdint.h>
@@ -35,29 +29,16 @@
 #include <signal.h>
 #endif
 
 class nsIFile;
 template<class KeyClass, class DataType> class nsDataHashtable;
 class nsCStringHashKey;
 
 namespace CrashReporter {
-
-/**
- * Returns true if the crash reporter is using the dummy implementation.
- */
-static inline bool
-IsDummy() {
-#ifdef MOZ_CRASHREPORTER
-  return false;
-#else
-  return true;
-#endif
-}
-
 nsresult SetExceptionHandler(nsIFile* aXREDirectory, bool force=false);
 nsresult UnsetExceptionHandler();
 
 /**
  * Tell the crash reporter to recalculate where crash events files should go.
  * SetCrashEventsDir is used before XPCOM is initialized from the startup
  * code.
  *
deleted file mode 100644
--- a/toolkit/crashreporter/nsExceptionHandlerUtils.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsExceptionHandlerUtils.h"
-
-#include "mozilla/double-conversion.h"
-
-// Format a non-negative double to a string, without using C-library functions,
-// which need to be avoided (.e.g. bug 1240160, comment 10).  Return false if
-// we failed to get the formatting done correctly.
-bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength)
-{
-  // aBufferLength is the size of the buffer.  Be paranoid.
-  aBuffer[aBufferLength-1] = '\0';
-
-  if (aValue < 0) {
-    return false;
-  }
-
-  int length, point, i;
-  bool sign;
-  bool ok = true;
-  double_conversion::DoubleToStringConverter::DoubleToAscii(
-                                     aValue,
-                                     double_conversion::DoubleToStringConverter::SHORTEST,
-                                     8,
-                                     aBuffer,
-                                     aBufferLength,
-                                     &sign,
-                                     &length,
-                                     &point);
-
-  // length does not account for the 0 terminator.
-  if (length > point && (length+1) < (aBufferLength-1)) {
-    // We have to insert a decimal point.  Not worried about adding a leading zero
-    // in the < 1 (point == 0) case.
-    aBuffer[length+1] = '\0';
-    for (i=length; i>point; i-=1) {
-      aBuffer[i] = aBuffer[i-1];
-    }
-    aBuffer[i] = '.'; // Not worried about locales
-  } else if (length < point) {
-    // Trailing zeros scenario
-    for (i=length; i<point; i+=1) {
-      if (i >= aBufferLength-2) {
-        ok = false;
-      }
-      aBuffer[i] = '0';
-    }
-    aBuffer[i] = '\0';
-  }
-  return ok;
-}
deleted file mode 100644
--- a/toolkit/crashreporter/nsExceptionHandlerUtils.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsExceptionHandlerUtils_h__
-#define nsExceptionHandlerUtils_h__
-
-bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength);
-
-#endif // nsExceptionHandlerUtils_h__
--- a/toolkit/moz.build
+++ b/toolkit/moz.build
@@ -2,17 +2,16 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DIRS += [
     'components',
     'content',
-    'crashreporter',
     'forgetaboutsite',
     'locales',
     'modules',
     'mozapps/downloads',
     'mozapps/extensions',
     'mozapps/handling',
     'mozapps/preferences',
     'pluginproblem',
@@ -42,16 +41,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk
     DIRS += ['system/unixproxy']
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     DIRS += ['system/osxproxy']
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     DIRS += ['system/windowsproxy']
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     DIRS += ['system/androidproxy']
 
+if CONFIG['MOZ_CRASHREPORTER']:
+    DIRS += ['crashreporter']
+
 TEST_HARNESS_FILES.testing.mochitest.browser.toolkit.crashreporter.test.browser += [
     'crashreporter/test/browser/crashreport.sjs',
 ]
 
 with Files('moz.*'):
     BUG_COMPONENT = ('Core', 'Build Config')
 
 with Files('toolkit.mozbuild'):
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -2196,17 +2196,18 @@ this.XPIProvider = {
         // UI displayed early in startup (like the compatibility UI) may have
         // caused us to cache parts of the skin or locale in memory. These must
         // be flushed to allow extension provided skins and locales to take full
         // effect
         Services.obs.notifyObservers(null, "chrome-flush-skin-caches");
         Services.obs.notifyObservers(null, "chrome-flush-caches");
       }
 
-      if (AppConstants.MOZ_CRASHREPORTER) {
+      if ("nsICrashReporter" in Ci &&
+          Services.appinfo instanceof Ci.nsICrashReporter) {
         // Annotate the crash report with relevant add-on information.
         try {
           Services.appinfo.annotateCrashReport("Theme", this.currentSkin);
         } catch (e) { }
         try {
           Services.appinfo.annotateCrashReport("EMCheckCompatibility",
                                                AddonManager.checkCompatibility);
         } catch (e) { }
@@ -2757,26 +2758,24 @@ this.XPIProvider = {
       logger.error("XPI_verifySignature: " + err);
     }
   },
 
   /**
    * Adds a list of currently active add-ons to the next crash report.
    */
   addAddonsToCrashReporter() {
-    if (!(Services.appinfo instanceof Ci.nsICrashReporter) ||
-        !AppConstants.MOZ_CRASHREPORTER) {
+    if (!("nsICrashReporter" in Ci) ||
+        !(Services.appinfo instanceof Ci.nsICrashReporter))
       return;
-    }
 
     // In safe mode no add-ons are loaded so we should not include them in the
     // crash report
-    if (Services.appinfo.inSafeMode) {
+    if (Services.appinfo.inSafeMode)
       return;
-    }
 
     let data = Array.from(XPIStates.enabledAddons(),
                           a => encoded`${a.id}:${a.version}`).join(",");
 
     try {
       Services.appinfo.annotateCrashReport("Add-ons", data);
     } catch (e) { }
 
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -35,17 +35,16 @@ const TIMEOUT_MS = 900000;
 // still passes.
 const MAX_TIME_DIFFERENCE = 3000;
 
 // Time to reset file modified time relative to Date.now() so we can test that
 // times are modified (10 hours old).
 const MAKE_FILE_OLD_DIFFERENCE = 10 * 3600 * 1000;
 
 Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm");
-Components.utils.import("resource://gre/modules/AppConstants.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/FileUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 const { OS } = Components.utils.import("resource://gre/modules/osfile.jsm", {});
 Components.utils.import("resource://gre/modules/AsyncShutdown.jsm");
 
 Components.utils.import("resource://testing-common/AddonTestUtils.jsm");
@@ -366,19 +365,18 @@ function isNightlyChannel() {
  * crash reporting is enabled. The test will fail if the add-on is not in the
  * annotation.
  * @param  aId
  *         The ID of the add-on
  * @param  aVersion
  *         The version of the add-on
  */
 function do_check_in_crash_annotation(aId, aVersion) {
-  if (!AppConstants.MOZ_CRASHREPORTER) {
+  if (!("nsICrashReporter" in AM_Ci))
     return;
-  }
 
   if (!("Add-ons" in gAppInfo.annotations)) {
     do_check_false(true);
     return;
   }
 
   let addons = gAppInfo.annotations["Add-ons"].split(",");
   do_check_true(addons.includes(`${encodeURIComponent(aId)}:${encodeURIComponent(aVersion)}`));
@@ -389,19 +387,18 @@ function do_check_in_crash_annotation(aI
  * crash reporting is enabled. The test will fail if the add-on is in the
  * annotation.
  * @param  aId
  *         The ID of the add-on
  * @param  aVersion
  *         The version of the add-on
  */
 function do_check_not_in_crash_annotation(aId, aVersion) {
-  if (!AppConstants.MOZ_CRASHREPORTER) {
+  if (!("nsICrashReporter" in AM_Ci))
     return;
-  }
 
   if (!("Add-ons" in gAppInfo.annotations)) {
     do_check_true(true);
     return;
   }
 
   let addons = gAppInfo.annotations["Add-ons"].split(",");
   do_check_false(addons.includes(`${encodeURIComponent(aId)}:${encodeURIComponent(aVersion)}`));
--- a/toolkit/xre/nsAndroidStartup.cpp
+++ b/toolkit/xre/nsAndroidStartup.cpp
@@ -24,22 +24,24 @@
 
 using namespace mozilla;
 
 extern "C" NS_EXPORT void
 GeckoStart(JNIEnv* env, char** argv, int argc, const StaticXREAppData& aAppData)
 {
     mozilla::jni::SetGeckoThreadEnv(env);
 
+#ifdef MOZ_CRASHREPORTER
     const struct mapping_info *info = getLibraryMapping();
     while (info->name) {
       CrashReporter::AddLibraryMapping(info->name, info->base,
                                        info->len, info->offset);
       info++;
     }
+#endif
 
     if (!argv) {
         LOG("Failed to get arguments for GeckoStart\n");
         return;
     }
 
     BootstrapConfig config;
     config.appData = &aAppData;
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -195,24 +195,26 @@
 #ifdef DEBUG
 #include "mozilla/Logging.h"
 #endif
 
 #ifdef MOZ_JPROF
 #include "jprof.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #include "nsICrashReporter.h"
 #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
 #include "nsIPrefService.h"
 #include "nsIMemoryInfoDumper.h"
 #if defined(XP_LINUX) && !defined(ANDROID)
 #include "mozilla/widget/LSBUtils.h"
 #endif
+#endif
 
 #include "base/command_line.h"
 #include "GTestRunner.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "GeneratedJNIWrappers.h"
 #endif
 
@@ -697,44 +699,50 @@ bool gSafeMode = false;
  * The nsXULAppInfo object implements nsIFactory so that it can be its own
  * singleton.
  */
 class nsXULAppInfo : public nsIXULAppInfo,
                      public nsIObserver,
 #ifdef XP_WIN
                      public nsIWinAppHelper,
 #endif
+#ifdef MOZ_CRASHREPORTER
                      public nsICrashReporter,
                      public nsIFinishDumpingCallback,
+#endif
                      public nsIXULRuntime
 
 {
 public:
   constexpr nsXULAppInfo() {}
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIPLATFORMINFO
   NS_DECL_NSIXULAPPINFO
   NS_DECL_NSIXULRUNTIME
   NS_DECL_NSIOBSERVER
+#ifdef MOZ_CRASHREPORTER
   NS_DECL_NSICRASHREPORTER
   NS_DECL_NSIFINISHDUMPINGCALLBACK
+#endif
 #ifdef XP_WIN
   NS_DECL_NSIWINAPPHELPER
 #endif
 };
 
 NS_INTERFACE_MAP_BEGIN(nsXULAppInfo)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXULRuntime)
   NS_INTERFACE_MAP_ENTRY(nsIXULRuntime)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
 #ifdef XP_WIN
   NS_INTERFACE_MAP_ENTRY(nsIWinAppHelper)
 #endif
+#ifdef MOZ_CRASHREPORTER
   NS_INTERFACE_MAP_ENTRY(nsICrashReporter)
   NS_INTERFACE_MAP_ENTRY(nsIFinishDumpingCallback)
+#endif
   NS_INTERFACE_MAP_ENTRY(nsIPlatformInfo)
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIXULAppInfo, gAppData ||
                                      XRE_IsContentProcess())
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP_(MozExternalRefCountType)
 nsXULAppInfo::AddRef()
 {
@@ -1193,16 +1201,17 @@ nsXULAppInfo::GetUserCanElevate(bool *aU
 
   if (hToken)
     CloseHandle(hToken);
 
   return NS_OK;
 }
 #endif
 
+#ifdef MOZ_CRASHREPORTER
 NS_IMETHODIMP
 nsXULAppInfo::GetEnabled(bool *aEnabled)
 {
   *aEnabled = CrashReporter::GetEnabled();
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -1422,16 +1431,17 @@ NS_IMETHODIMP
 nsXULAppInfo::Callback(nsISupports* aData)
 {
   nsCOMPtr<nsIFile> file = do_QueryInterface(aData);
   MOZ_ASSERT(file);
 
   CrashReporter::SetMemoryReportFile(file);
   return NS_OK;
 }
+#endif
 
 static const nsXULAppInfo kAppInfo;
 static nsresult AppInfoConstructor(nsISupports* aOuter,
                                    REFNSIID aIID, void **aResult)
 {
   NS_ENSURE_NO_AGGREGATION(aOuter);
 
   return const_cast<nsXULAppInfo*>(&kAppInfo)->
@@ -1529,17 +1539,17 @@ static const mozilla::Module::CIDEntry k
   { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kXREContracts[] = {
   { XULAPPINFO_SERVICE_CONTRACTID, &kAPPINFO_CID },
   { XULRUNTIME_SERVICE_CONTRACTID, &kAPPINFO_CID },
 #ifdef MOZ_CRASHREPORTER
   { NS_CRASHREPORTER_CONTRACTID, &kAPPINFO_CID },
-#endif // MOZ_CRASHREPORTER
+#endif
   { NS_PROFILESERVICE_CONTRACTID, &kProfileServiceCID },
   { NS_NATIVEAPPSUPPORT_CONTRACTID, &kNativeAppSupportCID },
   { nullptr }
 };
 
 static const mozilla::Module kXREModule = {
   mozilla::Module::kVersion,
   kXRECIDs,
@@ -2889,16 +2899,17 @@ static void SaveStateForAppInitiatedRest
 static void RestoreStateForAppInitiatedRestart()
 {
   for (auto & savedVar : gSavedVars) {
     if (savedVar.value)
       PR_SetEnv(savedVar.value);
   }
 }
 
+#ifdef MOZ_CRASHREPORTER
 // When we first initialize the crash reporter we don't have a profile,
 // so we set the minidump path to $TEMP.  Once we have a profile,
 // we set it to $PROFILE/minidumps, creating the directory
 // if needed.
 static void MakeOrSetMinidumpPath(nsIFile* profD)
 {
   nsCOMPtr<nsIFile> dumpD;
   profD->Clone(getter_AddRefs(dumpD));
@@ -2913,16 +2924,17 @@ static void MakeOrSetMinidumpPath(nsIFil
       NS_ENSURE_SUCCESS_VOID(rv);
     }
 
     nsAutoString pathStr;
     if (NS_SUCCEEDED(dumpD->GetPath(pathStr)))
       CrashReporter::SetMinidumpPath(pathStr);
   }
 }
+#endif
 
 const XREAppData* gAppData = nullptr;
 
 #ifdef MOZ_WIDGET_GTK
 static void MOZ_gdk_display_close(GdkDisplay *display)
 {
 #if CLEANUP_MEMORY
   // XXX wallpaper for bug 417163: don't close the Display if we're using the
@@ -3303,16 +3315,17 @@ XREMain::XRE_mainInit(bool* aExitFlag)
            (const char*) mAppData->maxVersion);
     return 1;
   }
 
   rv = mDirProvider.Initialize(mAppData->directory, mAppData->xreDirectory);
   if (NS_FAILED(rv))
     return 1;
 
+#ifdef MOZ_CRASHREPORTER
   if (EnvHasValue("MOZ_CRASHREPORTER")) {
     mAppData->flags |= NS_XRE_ENABLE_CRASH_REPORTER;
   }
 
   nsCOMPtr<nsIFile> xreBinDirectory;
   xreBinDirectory = mDirProvider.GetGREBinDir();
 
   if ((mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) &&
@@ -3388,16 +3401,17 @@ XREMain::XRE_mainInit(bool* aExitFlag)
         nsAutoCString overridePath;
         overrideini->GetNativePath(overridePath);
 #endif
 
         SaveWordToEnv("MOZ_CRASHREPORTER_STRINGS_OVERRIDE", overridePath);
       }
     }
   }
+#endif
 
 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
   if (mAppData->sandboxBrokerServices) {
     SandboxBroker::Initialize(mAppData->sandboxBrokerServices);
   } else {
 #if defined(MOZ_CONTENT_SANDBOX)
     // If we're sandboxing content and we fail to initialize, then crashing here
     // seems like the sensible option.
@@ -3537,27 +3551,31 @@ XREMain::XRE_mainInit(bool* aExitFlag)
           } else if (vtype == REG_DWORD && len == sizeof(updateRevision[0])) {
             cpuUpdateRevision = static_cast<int>(updateRevision[0]);
             break;
           }
         }
       }
     }
 
+#ifdef MOZ_CRASHREPORTER
     if (cpuUpdateRevision > 0) {
       CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CPUMicrocodeVersion"),
                                          nsPrintfCString("0x%x",
                                                          cpuUpdateRevision));
     }
+#endif
   }
 #endif
 
+#ifdef MOZ_CRASHREPORTER
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("SafeMode"),
                                        gSafeMode ? NS_LITERAL_CSTRING("1") :
                                                    NS_LITERAL_CSTRING("0"));
+#endif
 
   // Handle --no-remote and --new-instance command line arguments. Setup
   // the environment to better accommodate other components and various
   // restart scenarios.
   ar = CheckArg("no-remote", true);
   if (ar == ARG_BAD) {
     PR_fprintf(PR_STDERR, "Error: argument --no-remote is invalid when argument --osint is specified\n");
     return 1;
@@ -3611,16 +3629,17 @@ XREMain::XRE_mainInit(bool* aExitFlag)
     }
     *aExitFlag = true;
     return 0;
   }
 
   return 0;
 }
 
+#ifdef MOZ_CRASHREPORTER
 #ifdef XP_WIN
 /**
  * Uses WMI to read some manufacturer information that may be useful for
  * diagnosing hardware-specific crashes. This function is best-effort; failures
  * shouldn't burden the caller. COM must be initialized before calling.
  */
 static void AnnotateSystemManufacturer()
 {
@@ -3704,16 +3723,18 @@ AnnotateLSBRelease(void*)
   nsCString dist, desc, release, codename;
   if (widget::lsb::GetLSBRelease(dist, desc, release, codename)) {
     CrashReporter::AppendAppNotesToCrashReport(desc);
   }
 }
 
 #endif // defined(XP_LINUX) && !defined(ANDROID)
 
+#endif
+
 #ifdef XP_WIN
 static void ReadAheadDll(const wchar_t* dllName) {
   wchar_t dllPath[MAX_PATH];
   if (ConstructSystem32Path(dllName, dllPath, MAX_PATH)) {
     ReadAheadLib(dllPath);
   }
 }
 
@@ -4162,20 +4183,22 @@ XREMain::XRE_mainStartup(bool* aExitFlag
 
   rv = mDirProvider.SetProfile(mProfD, mProfLD);
   NS_ENSURE_SUCCESS(rv, 1);
 
   //////////////////////// NOW WE HAVE A PROFILE ////////////////////////
 
   mozilla::Telemetry::SetProfileDir(mProfD);
 
+#ifdef MOZ_CRASHREPORTER
   if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
       MakeOrSetMinidumpPath(mProfD);
 
   CrashReporter::SetProfileDirectory(mProfD);
+#endif
 
   nsAutoCString version;
   BuildVersion(version);
 
 #ifdef TARGET_OS_ABI
   NS_NAMED_LITERAL_CSTRING(osABI, TARGET_OS_ABI);
 #else
   // No TARGET_XPCOM_ABI, but at least the OS is known
@@ -4256,16 +4279,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
 
   if (flagFile) {
     flagFile->Remove(true);
   }
 
   return 0;
 }
 
+#if defined(MOZ_CRASHREPORTER)
 #if defined(MOZ_CONTENT_SANDBOX)
 void AddSandboxAnnotations()
 {
   // Include the sandbox content level, regardless of platform
   int level = GetEffectiveContentSandboxLevel();
 
   nsAutoCString levelString;
   levelString.AppendInt(level);
@@ -4286,16 +4310,17 @@ void AddSandboxAnnotations()
   sandboxCapable = SandboxInfo::Get().CanSandboxContent();
 #endif
 
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("ContentSandboxCapable"),
     sandboxCapable ? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
 }
 #endif /* MOZ_CONTENT_SANDBOX */
+#endif /* MOZ_CRASHREPORTER */
 
 /*
  * XRE_mainRun - Command line startup, profile migration, and
  * the calling of appStartup->Run().
  */
 nsresult
 XREMain::XRE_mainRun()
 {
@@ -4320,16 +4345,17 @@ XREMain::XRE_mainRun()
 
     comp = do_GetService("@mozilla.org/focus-event-suppressor-service;1");
   }
 #endif
 
   rv = mScopedXPCOM->SetWindowCreator(mNativeApp);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
+#ifdef MOZ_CRASHREPORTER
   // tell the crash reporter to also send the release channel
   nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIPrefBranch> defaultPrefBranch;
     rv = prefs->GetDefaultBranch(nullptr, getter_AddRefs(defaultPrefBranch));
 
     if (NS_SUCCEEDED(rv)) {
       nsAutoCString sval;
@@ -4355,16 +4381,18 @@ XREMain::XRE_mainRun()
                   PR_PRIORITY_LOW, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);
 #endif
 
 #if defined(XP_LINUX) && !defined(ANDROID)
   PR_CreateThread(PR_USER_THREAD, AnnotateLSBRelease, 0, PR_PRIORITY_LOW,
                   PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);
 #endif
 
+#endif
+
   if (mStartOffline) {
     nsCOMPtr<nsIIOService> io(do_GetService("@mozilla.org/network/io-service;1"));
     NS_ENSURE_TRUE(io, NS_ERROR_FAILURE);
     io->SetManageOfflineStatus(false);
     io->SetOffline(true);
   }
 
 
@@ -4482,19 +4510,21 @@ XREMain::XRE_mainRun()
   nsCOMPtr<nsIAppStartup> appStartup
     (do_GetService(NS_APPSTARTUP_CONTRACTID));
   NS_ENSURE_TRUE(appStartup, NS_ERROR_FAILURE);
 
   mDirProvider.DoStartup();
 
   OverrideDefaultLocaleIfNeeded();
 
+#ifdef MOZ_CRASHREPORTER
   nsCString userAgentLocale;
   LocaleService::GetInstance()->GetAppLocaleAsLangTag(userAgentLocale);
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("useragent_locale"), userAgentLocale);
+#endif
 
   appStartup->GetShuttingDown(&mShuttingDown);
 
   nsCOMPtr<nsICommandLineRunner> cmdLine;
 
   nsCOMPtr<nsIFile> workingDir;
   rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir));
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
@@ -4575,18 +4605,20 @@ XREMain::XRE_mainRun()
 
     nsCOMPtr<nsIObserverService> obsService =
       mozilla::services::GetObserverService();
     if (obsService)
       obsService->NotifyObservers(nullptr, "final-ui-startup", nullptr);
 
     (void)appStartup->DoneStartingUp();
 
+#ifdef MOZ_CRASHREPORTER
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("StartupCrash"),
                                        NS_LITERAL_CSTRING("0"));
+#endif
 
     appStartup->GetShuttingDown(&mShuttingDown);
   }
 
   if (!mShuttingDown) {
     rv = cmdLine->Run();
     NS_ENSURE_SUCCESS_LOG(rv, NS_ERROR_FAILURE);
 
@@ -4629,26 +4661,30 @@ XREMain::XRE_mainRun()
   Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES_PRIVILEGED,
                         sandboxInfo.Test(SandboxInfo::kHasPrivilegedUserNamespaces));
   Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES,
                         sandboxInfo.Test(SandboxInfo::kHasUserNamespaces));
   Telemetry::Accumulate(Telemetry::SANDBOX_CONTENT_ENABLED,
                         sandboxInfo.Test(SandboxInfo::kEnabledForContent));
   Telemetry::Accumulate(Telemetry::SANDBOX_MEDIA_ENABLED,
                         sandboxInfo.Test(SandboxInfo::kEnabledForMedia));
+#if defined(MOZ_CRASHREPORTER)
   nsAutoCString flagsString;
   flagsString.AppendInt(sandboxInfo.AsInteger());
 
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
+#endif /* MOZ_CRASHREPORTER */
 #endif /* MOZ_SANDBOX && XP_LINUX */
 
+#if defined(MOZ_CRASHREPORTER)
 #if defined(MOZ_CONTENT_SANDBOX)
   AddSandboxAnnotations();
 #endif /* MOZ_CONTENT_SANDBOX */
+#endif /* MOZ_CRASHREPORTER */
 
   {
     rv = appStartup->Run();
     if (NS_FAILED(rv)) {
       NS_ERROR("failed to run appstartup");
       gLogConsoleErrors = true;
     }
   }
@@ -4863,32 +4899,35 @@ XREMain::XRE_main(int argc, char* argv[]
       MOZ_gdk_display_close(mGdkDisplay);
     }
 #endif
 
     {
       rv = LaunchChild(mNativeApp, true);
     }
 
+#ifdef MOZ_CRASHREPORTER
     if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
       CrashReporter::UnsetExceptionHandler();
-
+#endif
     return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1;
   }
 
 #ifdef MOZ_WIDGET_GTK
   // gdk_display_close also calls gdk_display_manager_set_default_display
   // appropriately when necessary.
   if (!gfxPlatform::IsHeadless()) {
     MOZ_gdk_display_close(mGdkDisplay);
   }
 #endif
 
+#ifdef MOZ_CRASHREPORTER
   if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
       CrashReporter::UnsetExceptionHandler();
+#endif
 
   XRE_DeinitCommandLine();
 
   return NS_FAILED(rv) ? 1 : 0;
 }
 
 void
 XRE_StopLateWriteChecks(void) {
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -238,17 +238,19 @@ GeckoProcessType sChildProcessType = Gec
 } // namespace startup
 } // namespace mozilla
 
 #if defined(MOZ_WIDGET_ANDROID)
 void
 XRE_SetAndroidChildFds (JNIEnv* env, int crashFd, int ipcFd)
 {
   mozilla::jni::SetGeckoThreadEnv(env);
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::SetNotificationPipeForChild(crashFd);
+#endif // defined(MOZ_CRASHREPORTER)
   IPC::Channel::SetClientChannelFd(ipcFd);
 }
 #endif // defined(MOZ_WIDGET_ANDROID)
 
 void
 XRE_SetProcessType(const char* aProcessTypeString)
 {
   static bool called = false;
@@ -263,16 +265,17 @@ XRE_SetProcessType(const char* aProcessT
        ++i) {
     if (!strcmp(kGeckoProcessTypeString[i], aProcessTypeString)) {
       sChildProcessType = static_cast<GeckoProcessType>(i);
       return;
     }
   }
 }
 
+#if defined(MOZ_CRASHREPORTER)
 // FIXME/bug 539522: this out-of-place function is stuck here because
 // IPDL wants access to this crashreporter interface, and
 // crashreporter is built in such a way to make that awkward
 bool
 XRE_TakeMinidumpForChild(uint32_t aChildPid, nsIFile** aDump,
                          uint32_t* aSequence)
 {
   return CrashReporter::TakeMinidumpForChild(aChildPid, aDump, aSequence);
@@ -284,40 +287,43 @@ XRE_SetRemoteExceptionHandler(const char
 #if defined(XP_WIN) || defined(XP_MACOSX)
   return CrashReporter::SetRemoteExceptionHandler(nsDependentCString(aPipe));
 #elif defined(OS_LINUX)
   return CrashReporter::SetRemoteExceptionHandler();
 #else
 #  error "OOP crash reporter unsupported on this platform"
 #endif
 }
+#endif // if defined(MOZ_CRASHREPORTER)
 
 #if defined(XP_WIN)
 void
 SetTaskbarGroupId(const nsString& aId)
 {
     if (FAILED(SetCurrentProcessExplicitAppUserModelID(aId.get()))) {
         NS_WARNING("SetCurrentProcessExplicitAppUserModelID failed for child process.");
     }
 }
 #endif
 
+#if defined(MOZ_CRASHREPORTER)
 #if defined(MOZ_CONTENT_SANDBOX)
 void
 AddContentSandboxLevelAnnotation()
 {
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     int level = GetEffectiveContentSandboxLevel();
     nsAutoCString levelString;
     levelString.AppendInt(level);
     CrashReporter::AnnotateCrashReport(
       NS_LITERAL_CSTRING("ContentSandboxLevel"), levelString);
   }
 }
 #endif /* MOZ_CONTENT_SANDBOX */
+#endif /* MOZ_CRASHREPORTER */
 
 namespace {
 
 int GetDebugChildPauseTime() {
   auto pauseStr = PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE");
   if (pauseStr && *pauseStr) {
     int pause = atoi(pauseStr);
     if (pause != 1) { // must be !=1 since =1 enables the default pause time
@@ -472,47 +478,45 @@ XRE_InitChildProcess(int aArgc,
     NS_WARNING("child task_set_bootstrap_port() failed");
     return NS_ERROR_FAILURE;
   }
 
 #endif
 
   SetupErrorHandling(aArgv[0]);
 
-  if (!CrashReporter::IsDummy()) {
-    if (aArgc < 1) {
-      return NS_ERROR_FAILURE;
-    }
-
-    const char* const crashReporterArg = aArgv[--aArgc];
+#if defined(MOZ_CRASHREPORTER)
+  if (aArgc < 1)
+    return NS_ERROR_FAILURE;
+  const char* const crashReporterArg = aArgv[--aArgc];
 
-#if defined(XP_WIN) || defined(XP_MACOSX)
-    // on windows and mac, |crashReporterArg| is the named pipe on which the
-    // server is listening for requests, or "-" if crash reporting is
-    // disabled.
-    if (0 != strcmp("-", crashReporterArg) &&
-        !XRE_SetRemoteExceptionHandler(crashReporterArg)) {
-      // Bug 684322 will add better visibility into this condition
-      NS_WARNING("Could not setup crash reporting\n");
-    }
-#elif defined(OS_LINUX)
-    // on POSIX, |crashReporterArg| is "true" if crash reporting is
-    // enabled, false otherwise
-    if (0 != strcmp("false", crashReporterArg) &&
-        !XRE_SetRemoteExceptionHandler(nullptr)) {
-      // Bug 684322 will add better visibility into this condition
-      NS_WARNING("Could not setup crash reporting\n");
-    }
-#else
-#  error "OOP crash reporting unsupported on this platform"
-#endif
+#  if defined(XP_WIN) || defined(XP_MACOSX)
+  // on windows and mac, |crashReporterArg| is the named pipe on which the
+  // server is listening for requests, or "-" if crash reporting is
+  // disabled.
+  if (0 != strcmp("-", crashReporterArg) &&
+      !XRE_SetRemoteExceptionHandler(crashReporterArg)) {
+    // Bug 684322 will add better visibility into this condition
+    NS_WARNING("Could not setup crash reporting\n");
   }
+#  elif defined(OS_LINUX)
+  // on POSIX, |crashReporterArg| is "true" if crash reporting is
+  // enabled, false otherwise
+  if (0 != strcmp("false", crashReporterArg) &&
+      !XRE_SetRemoteExceptionHandler(nullptr)) {
+    // Bug 684322 will add better visibility into this condition
+    NS_WARNING("Could not setup crash reporting\n");
+  }
+#  else
+#    error "OOP crash reporting unsupported on this platform"
+#  endif
 
   // For Init/Shutdown thread name annotations in the crash reporter.
   CrashReporter::InitThreadAnnotationRAII annotation;
+#endif // if defined(MOZ_CRASHREPORTER)
 
   gArgv = aArgv;
   gArgc = aArgc;
 
 #ifdef MOZ_X11
   XInitThreads();
 #endif
 #if MOZ_WIDGET_GTK == 2
@@ -663,38 +667,42 @@ XRE_InitChildProcess(int aArgc,
       default:
         MOZ_CRASH("Unknown main thread class");
       }
 
       if (!process->Init(aArgc, aArgv)) {
         return NS_ERROR_FAILURE;
       }
 
+#ifdef MOZ_CRASHREPORTER
 #if defined(XP_WIN) || defined(XP_MACOSX)
       CrashReporter::InitChildProcessTmpDir(crashReportTmpDir);
 #endif
+#endif
 
 #if defined(XP_WIN)
       // Set child processes up such that they will get killed after the
       // chrome process is killed in cases where the user shuts the system
       // down or logs off.
       ::SetProcessShutdownParameters(0x280 - 1, SHUTDOWN_NORETRY);
 #endif
 
 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
       // We need to do this after the process has been initialised, as
       // InitLoggingIfRequired may need access to prefs.
       mozilla::sandboxing::InitLoggingIfRequired(aChildData->ProvideLogFunction);
 #endif
 
       OverrideDefaultLocaleIfNeeded();
 
+#if defined(MOZ_CRASHREPORTER)
 #if defined(MOZ_CONTENT_SANDBOX)
       AddContentSandboxLevelAnnotation();
 #endif
+#endif
 
       // Run the UI event loop on the main thread.
       uiMessageLoop.MessageLoop::Run();
 
       // Allow ProcessChild to clean up after itself before going out of
       // scope and being deleted
       process->CleanUp();
       mozilla::Omnijar::CleanUp();
--- a/toolkit/xre/nsX11ErrorHandler.cpp
+++ b/toolkit/xre/nsX11ErrorHandler.cpp
@@ -112,25 +112,27 @@ X11Error(Display *display, XErrorEvent *
       notes.AppendLiteral("; sync");
     } else {
       notes.AppendLiteral("; ");
       notes.AppendInt(uint32_t(age));
       notes.AppendLiteral(" requests ago");
     }
   }
 
+#ifdef MOZ_CRASHREPORTER
   switch (XRE_GetProcessType()) {
   case GeckoProcessType_Default:
   case GeckoProcessType_Plugin:
   case GeckoProcessType_Content:
     CrashReporter::AppendAppNotesToCrashReport(notes);
     break;
   default:
     ; // crash report notes not supported.
   }
+#endif
 
 #ifdef DEBUG
   // The resource id is unlikely to be useful in a crash report without
   // context of other ids, but add it to the debug console output.
   notes.AppendLiteral("; id=0x");
   notes.AppendInt(uint32_t(event->resourceid), 16);
 #ifdef MOZ_X11
   // Actually, for requests where Xlib gets the reply synchronously,
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -10,17 +10,19 @@
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Move.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/TabParent.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif // #ifdef MOZ_CRASHREPORTER
 #include "nsIWidget.h"
 
 namespace mozilla {
 
 using namespace dom;
 using namespace widget;
 
 static const char*
@@ -1106,17 +1108,19 @@ ContentCacheInParent::OnCompositionEvent
      "mPendingEventsNeedingAck=%u, mWidgetHasComposition=%s, "
      "mPendingCompositionCount=%u, mCommitStringByRequest=0x%p",
      this, ToChar(aEvent.mMessage),
      GetEscapedUTF8String(aEvent.mData).get(), aEvent.mData.Length(),
      aEvent.mRanges ? aEvent.mRanges->Length() : 0, mPendingEventsNeedingAck,
      GetBoolName(mWidgetHasComposition), mPendingCompositionCount,
      mCommitStringByRequest));
 
+#ifdef MOZ_CRASHREPORTER
   mDispatchedEventMessages.AppendElement(aEvent.mMessage);
+#endif // #ifdef MOZ_CRASHREPORTER
 
   // We must be able to simulate the selection because
   // we might not receive selection updates in time
   if (!mWidgetHasComposition) {
     if (aEvent.mWidget && aEvent.mWidget->PluginHasFocus()) {
       // If focus is on plugin, we cannot get selection range
       mCompositionStart = 0;
     } else if (mCompositionStartInChild != UINT32_MAX) {
@@ -1184,49 +1188,56 @@ ContentCacheInParent::OnSelectionEvent(
      "mPendingCompositionCount=%u",
      this, ToChar(aSelectionEvent.mMessage),
      aSelectionEvent.mOffset, aSelectionEvent.mLength,
      GetBoolName(aSelectionEvent.mReversed),
      GetBoolName(aSelectionEvent.mExpandToClusterBoundary),
      GetBoolName(aSelectionEvent.mUseNativeLineBreak), mPendingEventsNeedingAck,
      GetBoolName(mWidgetHasComposition), mPendingCompositionCount));
 
+#ifdef MOZ_CRASHREPORTER
   mDispatchedEventMessages.AppendElement(aSelectionEvent.mMessage);
+#endif // #ifdef MOZ_CRASHREPORTER
 
   mPendingEventsNeedingAck++;
 }
 
 void
 ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget,
                                                 EventMessage aMessage)
 {
   // This is called when the child process receives WidgetCompositionEvent or
   // WidgetSelectionEvent.
 
   MOZ_LOG(sContentCacheLog, LogLevel::Info,
     ("0x%p OnEventNeedingAckHandled(aWidget=0x%p, "
      "aMessage=%s), mPendingEventsNeedingAck=%u, mPendingCompositionCount=%" PRIu8,
      this, aWidget, ToChar(aMessage), mPendingEventsNeedingAck, mPendingCompositionCount));
 
+#ifdef MOZ_CRASHREPORTER
   mReceivedEventMessages.AppendElement(aMessage);
+#endif // #ifdef MOZ_CRASHREPORTER
 
   if (WidgetCompositionEvent::IsFollowedByCompositionEnd(aMessage) ||
       aMessage == eCompositionCommitRequestHandled) {
 
+#ifdef MOZ_CRASHREPORTER
     if (mPendingCompositionCount == 1) {
       RemoveUnnecessaryEventMessageLog();
     }
+#endif // #ifdef MOZ_CRASHREPORTER
 
     if (NS_WARN_IF(!mPendingCompositionCount)) {
+#ifdef MOZ_CRASHREPORTER
       nsPrintfCString info("\nThere is no pending composition but received %s "
                            "message from the remote child\n\n",
                            ToChar(aMessage));
       AppendEventMessageLog(info);
       CrashReporter::AppendAppNotesToCrashReport(info);
-
+#endif // #ifdef MOZ_CRASHREPORTER
       MOZ_CRASH("No pending composition but received unexpected commit event");
     }
 
     mPendingCompositionCount--;
     // Forget composition string only when the latest composition string is
     // handled in the remote process because if there is 2 or more pending
     // composition, this value shouldn't be referred.
     if (!mPendingCompositionCount) {
@@ -1236,21 +1247,23 @@ ContentCacheInParent::OnEventNeedingAckH
     // Forget pending commit string length if it's handled in the remote
     // process.  Note that this doesn't care too old composition's commit
     // string because in such case, we cannot return proper information
     // to IME synchornously.
     mPendingCommitLength = 0;
   }
 
   if (NS_WARN_IF(!mPendingEventsNeedingAck)) {
+#ifdef MOZ_CRASHREPORTER
     nsPrintfCString info("\nThere is no pending events but received %s "
                          "message from the remote child\n\n",
                          ToChar(aMessage));
     AppendEventMessageLog(info);
     CrashReporter::AppendAppNotesToCrashReport(info);
+#endif // #ifdef MOZ_CRASHREPORTER
     MOZ_CRASH("No pending event message but received unexpected event");
   }
   if (--mPendingEventsNeedingAck) {
     return;
   }
 
   FlushPendingNotifications(aWidget);
 }
@@ -1272,60 +1285,63 @@ ContentCacheInParent::RequestIMEToCommit
   MOZ_ASSERT(!mCommitStringByRequest);
 
   // If there are 2 or more pending compositions, we already sent
   // eCompositionCommit(AsIs) to the remote process.  So, this request is
   // too late for IME.  The remote process should wait following
   // composition events for cleaning up TextComposition and handle the
   // request as it's handled asynchronously.
   if (mPendingCompositionCount > 1) {
+#ifdef MOZ_CRASHREPORTER
     mRequestIMEToCommitCompositionResults.
       AppendElement(RequestIMEToCommitCompositionResult::
                       eToOldCompositionReceived);
-
+#endif // #ifdef MOZ_CRASHREPORTER
     return false;
   }
 
   // If there is no pending composition, we may have already sent
   // eCompositionCommit(AsIs) event for the active composition.  If so, the
   // remote process will receive composition events which causes cleaning up
   // TextComposition.  So, this shouldn't do nothing and TextComposition
   // should handle the request as it's handled asynchronously.
   if (mIsPendingLastCommitEvent) {
+#ifdef MOZ_CRASHREPORTER
     mRequestIMEToCommitCompositionResults.
       AppendElement(RequestIMEToCommitCompositionResult::
                       eToCommittedCompositionReceived);
-
+#endif // #ifdef MOZ_CRASHREPORTER
     return false;
   }
 
   // If TabParent which has IME focus was already changed to different one, the
   // request shouldn't be sent to IME because it's too late.
   if (!IMEStateManager::DoesTabParentHaveIMEFocus(&mTabParent)) {
     // Use the latest composition string which may not be handled in the
     // remote process for avoiding data loss.
+#ifdef MOZ_CRASHREPORTER
     mRequestIMEToCommitCompositionResults.
       AppendElement(RequestIMEToCommitCompositionResult::
                       eReceivedAfterTabParentBlur);
-
+#endif // #ifdef MOZ_CRASHREPORTER
     aCommittedString = mCompositionString;
     return true;
   }
 
   RefPtr<TextComposition> composition =
     IMEStateManager::GetTextCompositionFor(aWidget);
   if (NS_WARN_IF(!composition)) {
     MOZ_LOG(sContentCacheLog, LogLevel::Warning,
       ("  0x%p RequestToCommitComposition(), "
        "does nothing due to no composition", this));
-
+#ifdef MOZ_CRASHREPORTER
     mRequestIMEToCommitCompositionResults.
       AppendElement(RequestIMEToCommitCompositionResult::
                       eReceivedButNoTextComposition);
-
+#endif // #ifdef MOZ_CRASHREPORTER
     return false;
   }
 
   mCommitStringByRequest = &aCommittedString;
 
   aWidget->NotifyIME(IMENotification(aCancel ? REQUEST_TO_CANCEL_COMPOSITION :
                                                REQUEST_TO_COMMIT_COMPOSITION));
 
@@ -1342,34 +1358,36 @@ ContentCacheInParent::RequestIMEToCommit
     // TextComposition instance will synthesize commit events and wait to
     // receive delayed composition events.  When TextComposition instances both
     // in this process and the remote process will be destroyed when delayed
     // composition events received. TextComposition instance in the parent
     // process will dispatch following composition events and be destroyed
     // normally. On the other hand, TextComposition instance in the remote
     // process won't dispatch following composition events and will be
     // destroyed by IMEStateManager::DispatchCompositionEvent().
+#ifdef MOZ_CRASHREPORTER
     mRequestIMEToCommitCompositionResults.
       AppendElement(RequestIMEToCommitCompositionResult::
                       eHandledAsynchronously);
-
+#endif // #ifdef MOZ_CRASHREPORTER
     return false;
   }
 
   // When the composition is committed synchronously, the commit string will be
   // returned to the remote process. Then, PuppetWidget will dispatch
   // eCompositionCommit event with the returned commit string (i.e., the value
   // is aCommittedString of this method).  Finally, TextComposition instance in
   // the remote process will be destroyed by
   // IMEStateManager::DispatchCompositionEvent() at receiving the
   // eCompositionCommit event (Note that TextComposition instance in this
   // process was already destroyed).
+#ifdef MOZ_CRASHREPORTER
   mRequestIMEToCommitCompositionResults.
     AppendElement(RequestIMEToCommitCompositionResult::eHandledSynchronously);
-
+#endif // #ifdef MOZ_CRASHREPORTER
   return true;
 }
 
 void
 ContentCacheInParent::MaybeNotifyIME(nsIWidget* aWidget,
                                      const IMENotification& aNotification)
 {
   if (!mPendingEventsNeedingAck) {
@@ -1456,16 +1474,18 @@ ContentCacheInParent::FlushPendingNotifi
       (mPendingTextChange.HasNotification() ||
        mPendingSelectionChange.HasNotification() ||
        mPendingLayoutChange.HasNotification() ||
        mPendingCompositionUpdate.HasNotification())) {
     FlushPendingNotifications(widget);
   }
 }
 
+#ifdef MOZ_CRASHREPORTER
+
 void
 ContentCacheInParent::RemoveUnnecessaryEventMessageLog()
 {
   bool foundLastCompositionStart = false;
   for (size_t i = mDispatchedEventMessages.Length(); i > 1; i--) {
     if (mDispatchedEventMessages[i - 1] != eCompositionStart) {
       continue;
     }
@@ -1543,16 +1563,18 @@ ContentCacheInParent::AppendEventMessage
          mRequestIMEToCommitCompositionResults) {
     aLog.AppendLiteral("  ");
     aLog.Append(ToReadableText(result));
     aLog.AppendLiteral("\n");
   }
   aLog.AppendLiteral("\n");
 }
 
+#endif // #ifdef MOZ_CRASHREPORTER
+
 /*****************************************************************************
  * mozilla::ContentCache::TextRectArray
  *****************************************************************************/
 
 LayoutDeviceIntRect
 ContentCache::TextRectArray::GetRect(uint32_t aOffset) const
 {
   LayoutDeviceIntRect rect;
--- a/widget/ContentCache.h
+++ b/widget/ContentCache.h
@@ -405,16 +405,17 @@ public:
                       const IMENotification& aNotification);
 
 private:
   IMENotification mPendingSelectionChange;
   IMENotification mPendingTextChange;
   IMENotification mPendingLayoutChange;
   IMENotification mPendingCompositionUpdate;
 
+#ifdef MOZ_CRASHREPORTER
   // Log of event messages to be output to crash report.
   nsTArray<EventMessage> mDispatchedEventMessages;
   nsTArray<EventMessage> mReceivedEventMessages;
   // Log of RequestIMEToCommitComposition() in the last 2 compositions.
   enum class RequestIMEToCommitCompositionResult : uint8_t
   {
     eToOldCompositionReceived,
     eToCommittedCompositionReceived,
@@ -444,16 +445,17 @@ private:
       case RequestIMEToCommitCompositionResult::eHandledSynchronously:
         return "Commit reqeust is handled synchronously";
       default:
         return "Unknown reason";
     }
   }
   nsTArray<RequestIMEToCommitCompositionResult>
     mRequestIMEToCommitCompositionResults;
+#endif // #ifdef MOZ_CRASHREPORTER
 
   // mTabParent is owner of the instance.
   dom::TabParent& MOZ_NON_OWNING_REF mTabParent;
   // mCompositionString is composition string which were sent to the remote
   // process but not yet committed in the remote process.
   nsString mCompositionString;
   // This is not nullptr only while the instance is requesting IME to
   // composition.  Then, data value of dispatched composition events should
@@ -500,23 +502,25 @@ private:
                    LayoutDeviceIntRect& aTextRect) const;
   bool GetUnionTextRects(uint32_t aOffset,
                          uint32_t aLength,
                          bool aRoundToExistingOffset,
                          LayoutDeviceIntRect& aUnionTextRect) const;
 
   void FlushPendingNotifications(nsIWidget* aWidget);
 
+#ifdef MOZ_CRASHREPORTER
   /**
    * Remove unnecessary messages from mDispatchedEventMessages and
    * mReceivedEventMessages.
    */
   void RemoveUnnecessaryEventMessageLog();
 
   /**
    * Append event message log to aLog.
    */
   void AppendEventMessageLog(nsACString& aLog) const;
+#endif // #ifdef MOZ_CRASHREPORTER
 };
 
 } // namespace mozilla
 
 #endif // mozilla_ContentCache_h
--- a/widget/GfxInfoBase.cpp
+++ b/widget/GfxInfoBase.cpp
@@ -33,16 +33,20 @@
 #include "mozilla/gfx/Logging.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "MediaPrefs.h"
 #include "gfxPrefs.h"
 #include "gfxPlatform.h"
 #include "gfxConfig.h"
 #include "DriverCrashGuard.h"
 
+#if defined(MOZ_CRASHREPORTER)
+#include "nsExceptionHandler.h"
+#endif
+
 using namespace mozilla::widget;
 using namespace mozilla;
 using mozilla::MutexAutoLock;
 
 nsTArray<GfxDriverInfo>* GfxInfoBase::mDriverInfo;
 nsTArray<dom::GfxInfoFeatureStatus>* GfxInfoBase::mFeatureStatus;
 bool GfxInfoBase::mDriverInfoObserverInitialized;
 bool GfxInfoBase::mShutdownOccurred;
--- a/widget/GfxInfoX11.cpp
+++ b/widget/GfxInfoX11.cpp
@@ -6,22 +6,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <sys/utsname.h>
 #include "nsCRTGlue.h"
-#include "nsExceptionHandler.h"
-#include "nsICrashReporter.h"
 #include "prenv.h"
 
 #include "GfxInfoX11.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#include "nsICrashReporter.h"
+#endif
 
 namespace mozilla {
 namespace widget {
 
 #ifdef DEBUG
 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
 #endif
 
@@ -169,35 +171,37 @@ GfxInfo::GetData()
             mAdapterDescription.AppendPrintf(" (exited with status %d)", WEXITSTATUS(glxtest_status));
         if (received_signal)
             mAdapterDescription.AppendPrintf(" (received signal %d)", WTERMSIG(glxtest_status));
         if (bytesread) {
             mAdapterDescription.AppendLiteral(": ");
             mAdapterDescription.Append(nsDependentCString(buf));
             mAdapterDescription.Append('\n');
         }
-
+#ifdef MOZ_CRASHREPORTER
         CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription);
+#endif
         return;
     }
 
     mAdapterDescription.Append(mVendor);
     mAdapterDescription.AppendLiteral(" -- ");
     mAdapterDescription.Append(mRenderer);
 
     nsAutoCString note;
     note.AppendLiteral("OpenGL: ");
     note.Append(mAdapterDescription);
     note.AppendLiteral(" -- ");
     note.Append(mVersion);
     if (mHasTextureFromPixmap)
         note.AppendLiteral(" -- texture_from_pixmap");
     note.Append('\n');
-
+#ifdef MOZ_CRASHREPORTER
     CrashReporter::AppendAppNotesToCrashReport(note);
+#endif
 
     // determine the major OpenGL version. That's the first integer in the version string.
     mGLMajorVersion = strtol(mVersion.get(), 0, 10);
 
     // determine driver type (vendor) and where in the version string
     // the actual driver version numbers should be expected to be found (whereToReadVersionNumbers)
     const char *whereToReadVersionNumbers = nullptr;
     const char *Mesa_in_version_string = strstr(mVersion.get(), "Mesa");
--- a/widget/android/GfxInfo.cpp
+++ b/widget/android/GfxInfo.cpp
@@ -3,25 +3,27 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GfxInfo.h"
 #include "GLContext.h"
 #include "GLContextProvider.h"
 #include "nsUnicharUtils.h"
 #include "prenv.h"
-#include "nsExceptionHandler.h"
 #include "nsHashKeys.h"
-#include "nsICrashReporter.h"
 #include "nsVersionComparator.h"
 #include "AndroidBridge.h"
 #include "nsIWindowWatcher.h"
 #include "nsServiceManagerUtils.h"
 
+#if defined(MOZ_CRASHREPORTER)
+#include "nsExceptionHandler.h"
+#include "nsICrashReporter.h"
 #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
+#endif
 
 namespace mozilla {
 namespace widget {
 
 class GfxInfo::GLStrings
 {
   nsCString mVendor;
   nsCString mRenderer;
@@ -343,29 +345,31 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Ac
 {
   EnsureInitialized();
   return NS_ERROR_FAILURE;
 }
 
 void
 GfxInfo::AddCrashReportAnnotations()
 {
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"),
                                      mGLStrings->Vendor());
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"),
                                      mGLStrings->Renderer());
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"),
                                      mGLStrings->Version());
 
   /* Add an App Note for now so that we get the data immediately. These
    * can go away after we store the above in the socorro db */
   nsAutoCString note;
   note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get());
 
   CrashReporter::AppendAppNotesToCrashReport(note);
+#endif
 }
 
 const nsTArray<GfxDriverInfo>&
 GfxInfo::GetGfxDriverInfo()
 {
   if (mDriverInfo->IsEmpty()) {
     APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Android,
       (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices,
--- a/widget/android/jni/Utils.cpp
+++ b/widget/android/jni/Utils.cpp
@@ -4,17 +4,20 @@
 #include <android/log.h>
 #include <pthread.h>
 
 #include "mozilla/Assertions.h"
 
 #include "GeneratedJNIWrappers.h"
 #include "AndroidBuild.h"
 #include "nsAppShell.h"
+
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 
 namespace mozilla {
 namespace jni {
 
 namespace detail {
 
 #define DEFINE_PRIMITIVE_TYPE_ADAPTER(NativeType, JNIType, JNIName, ABIName) \
     \
@@ -198,28 +201,30 @@ bool HandleUncaughtException(JNIEnv* aEn
 
     return true;
 }
 
 bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack)
 {
     bool result = true;
 
+#ifdef MOZ_CRASHREPORTER
     result &= NS_SUCCEEDED(CrashReporter::AnnotateCrashReport(
             NS_LITERAL_CSTRING("JavaStackTrace"),
             String::Ref::From(aStack)->ToCString()));
 
     auto appNotes = java::GeckoAppShell::GetAppNotes();
     if (NS_WARN_IF(aEnv->ExceptionCheck())) {
         aEnv->ExceptionDescribe();
         aEnv->ExceptionClear();
     } else if (appNotes) {
         CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\n") +
                                                    appNotes->ToCString());
     }
+#endif // MOZ_CRASHREPORTER
 
     if (sOOMErrorClass && aEnv->IsInstanceOf(aExc, sOOMErrorClass)) {
         NS_ABORT_OOM(0); // Unknown OOM size
     }
     return result;
 }
 
 namespace {
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -4,23 +4,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsAppShell.h"
 
 #include "base/basictypes.h"
 #include "base/message_loop.h"
 #include "base/task.h"
 #include "mozilla/Hal.h"
-#include "nsExceptionHandler.h"
 #include "nsIScreen.h"
 #include "nsIScreenManager.h"
 #include "nsWindow.h"
 #include "nsThreadUtils.h"
 #include "nsICommandLineRunner.h"
-#include "nsICrashReporter.h"
 #include "nsIObserverService.h"
 #include "nsIAppStartup.h"
 #include "nsIGeolocationProvider.h"
 #include "nsCacheService.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMClientRectList.h"
 #include "nsIDOMClientRect.h"
 #include "nsIDOMWakeLockListener.h"
@@ -55,16 +53,21 @@
 #include "nsIURI.h"
 #include "IHistory.h"
 #endif
 
 #ifdef MOZ_LOGGING
 #include "mozilla/Logging.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsICrashReporter.h"
+#include "nsExceptionHandler.h"
+#endif
+
 #include "AndroidAlerts.h"
 #include "AndroidUiThread.h"
 #include "ANRReporter.h"
 #include "GeckoBatteryManager.h"
 #include "GeckoNetworkManager.h"
 #include "GeckoProcessManager.h"
 #include "GeckoScreenOrientation.h"
 #include "GeckoVRManager.h"
--- a/widget/cocoa/GfxInfo.mm
+++ b/widget/cocoa/GfxInfo.mm
@@ -5,27 +5,29 @@
 
 #include <OpenGL/OpenGL.h>
 #include <OpenGL/CGLRenderers.h>
 
 #include "mozilla/ArrayUtils.h"
 
 #include "GfxInfo.h"
 #include "nsUnicharUtils.h"
-#include "nsExceptionHandler.h"
 #include "nsCocoaFeatures.h"
-#include "nsICrashReporter.h"
 #include "mozilla/Preferences.h"
 #include <algorithm>
 
 #import <Foundation/Foundation.h>
 #import <IOKit/IOKitLib.h>
 #import <Cocoa/Cocoa.h>
 
+#if defined(MOZ_CRASHREPORTER)
+#include "nsExceptionHandler.h"
+#include "nsICrashReporter.h"
 #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
+#endif
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 #ifdef DEBUG
 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
 #endif
 
@@ -268,16 +270,17 @@ NS_IMETHODIMP
 GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
 {
   return NS_ERROR_FAILURE;
 }
 
 void
 GfxInfo::AddCrashReportAnnotations()
 {
+#if defined(MOZ_CRASHREPORTER)
   nsString deviceID, vendorID, driverVersion;
   nsAutoCString narrowDeviceID, narrowVendorID, narrowDriverVersion;
 
   GetAdapterDeviceID(deviceID);
   CopyUTF16toUTF8(deviceID, narrowDeviceID);
   GetAdapterVendorID(vendorID);
   CopyUTF16toUTF8(vendorID, narrowVendorID);
   GetAdapterDriverVersion(driverVersion);
@@ -293,16 +296,17 @@ GfxInfo::AddCrashReportAnnotations()
    * can go away after we store the above in the socorro db */
   nsAutoCString note;
   /* AppendPrintf only supports 32 character strings, mrghh. */
   note.AppendLiteral("AdapterVendorID: ");
   note.Append(narrowVendorID);
   note.AppendLiteral(", AdapterDeviceID: ");
   note.Append(narrowDeviceID);
   CrashReporter::AppendAppNotesToCrashReport(note);
+#endif
 }
 
 // We don't support checking driver versions on Mac.
 #define IMPLEMENT_MAC_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn, ruleId) \
   APPEND_TO_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn,           \
                              DRIVER_COMPARISON_IGNORED, V(0,0,0,0), ruleId, "")
 
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -14,17 +14,16 @@
 #include "nsCocoaWindow.h"
 
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 
 #include "nsArrayUtils.h"
-#include "nsExceptionHandler.h"
 #include "nsObjCExceptions.h"
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
 #include "nsToolkit.h"
 #include "nsCRT.h"
 
 #include "nsFontMetrics.h"
 #include "nsIRollupListener.h"
@@ -79,16 +78,19 @@
 #include "gfxPrefs.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/BorrowedContext.h"
 #include "mozilla/gfx/MacIOSurface.h"
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #include "mozilla/a11y/Platform.h"
 #endif
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
 
 #include "mozilla/Preferences.h"
 
 #include <dlfcn.h>
 
 #include <ApplicationServices/ApplicationServices.h>
 
 #include "GeckoProfiler.h"
@@ -5512,40 +5514,41 @@ GetIntegerDeltaForEvent(NSEvent* aEvent)
   NSWindow *viewWindow = [self window];
   if (viewWindow && [viewWindow isKeyWindow]) {
     [viewWindow orderWindow:NSWindowAbove relativeTo:0];
   }
 
 #if !defined(RELEASE_OR_BETA) || defined(DEBUG)
   if (!Preferences::GetBool("intl.allow-insecure-text-input", false) &&
       mGeckoChild && mTextInputHandler && mTextInputHandler->IsFocused()) {
+#ifdef MOZ_CRASHREPORTER
     NSWindow* window = [self window];
     NSString* info = [NSString stringWithFormat:@"\nview [%@], window [%@], window is key %i, is fullscreen %i, app is active %i",
                       self, window, [window isKeyWindow], ([window styleMask] & (1 << 14)) != 0,
                       [NSApp isActive]];
     nsAutoCString additionalInfo([info UTF8String]);
-
+#endif
     if (mGeckoChild->GetInputContext().IsPasswordEditor() &&
                !TextInputHandler::IsSecureEventInputEnabled()) {
       #define CRASH_MESSAGE "A password editor has focus, but not in secure input mode"
-
+#ifdef MOZ_CRASHREPORTER
       CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") +
                                                  NS_LITERAL_CSTRING(CRASH_MESSAGE));
       CrashReporter::AppendAppNotesToCrashReport(additionalInfo);
-
+#endif
       MOZ_CRASH(CRASH_MESSAGE);
       #undef CRASH_MESSAGE
     } else if (!mGeckoChild->GetInputContext().IsPasswordEditor() &&
                TextInputHandler::IsSecureEventInputEnabled()) {
       #define CRASH_MESSAGE "A non-password editor has focus, but in secure input mode"
-
+#ifdef MOZ_CRASHREPORTER
       CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") +
                                                  NS_LITERAL_CSTRING(CRASH_MESSAGE));
       CrashReporter::AppendAppNotesToCrashReport(additionalInfo);
-
+#endif
       MOZ_CRASH(CRASH_MESSAGE);
       #undef CRASH_MESSAGE
     }
   }
 #endif // #if !defined(RELEASE_OR_BETA) || defined(DEBUG)
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
   if (mGeckoChild) {
--- a/widget/nsBaseAppShell.cpp
+++ b/widget/nsBaseAppShell.cpp
@@ -1,17 +1,19 @@
 /* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "base/message_loop.h"
 
 #include "nsBaseAppShell.h"
+#if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
+#endif
 #include "nsThreadUtils.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/Services.h"
 #include "nsXULAppAPI.h"
 
 // When processing the next thread event, the appshell may process native
 // events (if not in performance mode), which can result in suppressing the
@@ -313,24 +315,28 @@ nsBaseAppShell::DispatchDummyEvent(nsITh
 
   return NS_SUCCEEDED(aTarget->Dispatch(mDummyEvent, NS_DISPATCH_NORMAL));
 }
 
 void
 nsBaseAppShell::IncrementEventloopNestingLevel()
 {
   ++mEventloopNestingLevel;
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel);
+#endif
 }
 
 void
 nsBaseAppShell::DecrementEventloopNestingLevel()
 {
   --mEventloopNestingLevel;
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel);
+#endif
 }
 
 // Called from the main thread
 NS_IMETHODIMP
 nsBaseAppShell::AfterProcessNextEvent(nsIThreadInternal *thr,
                                       bool eventWasProcessed)
 {
   return NS_OK;
--- a/widget/windows/GfxInfo.cpp
+++ b/widget/windows/GfxInfo.cpp
@@ -13,23 +13,25 @@
 #include "GfxInfoWebGL.h"
 #include "nsUnicharUtils.h"
 #include "prenv.h"
 #include "prprf.h"
 #include "GfxDriverInfo.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/gfx/DeviceManagerDx.h"
 #include "mozilla/gfx/Logging.h"
-#include "nsExceptionHandler.h"
-#include "nsICrashReporter.h"
 #include "nsPrintfCString.h"
 #include "jsapi.h"
 #include <intrin.h>
 
+#if defined(MOZ_CRASHREPORTER)
+#include "nsExceptionHandler.h"
+#include "nsICrashReporter.h"
 #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
+#endif
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::widget;
 
 #ifdef DEBUG
 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
 #endif
@@ -847,34 +849,37 @@ NS_IMETHODIMP
 GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
 {
   // This is never the case, as the active GPU ends up being
   // the first one.  It should probably be removed.
   *aIsGPU2Active = false;
   return NS_OK;
 }
 
+#if defined(MOZ_CRASHREPORTER)
 /* Cisco's VPN software can cause corruption of the floating point state.
  * Make a note of this in our crash reports so that some weird crashes
  * make more sense */
 static void
 CheckForCiscoVPN() {
   LONG result;
   HKEY key;
   /* This will give false positives, but hopefully no false negatives */
   result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Cisco Systems\\VPN Client", 0, KEY_QUERY_VALUE, &key);
   if (result == ERROR_SUCCESS) {
     RegCloseKey(key);
     CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Cisco VPN\n"));
   }
 }
+#endif
 
 void
 GfxInfo::AddCrashReportAnnotations()
 {
+#if defined(MOZ_CRASHREPORTER)
   CheckForCiscoVPN();
 
   if (mHasDriverVersionMismatch) {
     CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("DriverVersionMismatch\n"));
   }
 
   nsString deviceID, vendorID, driverVersion, subsysID;
   nsCString narrowDeviceID, narrowVendorID, narrowDriverVersion, narrowSubsysID;
@@ -944,16 +949,18 @@ GfxInfo::AddCrashReportAnnotations()
     note.AppendLiteral(", AdapterDeviceID2: ");
     note.Append(narrowDeviceID2);
     note.AppendLiteral(", AdapterSubsysID2: ");
     note.Append(narrowSubsysID2);
     note.AppendLiteral(", AdapterDriverVersion2: ");
     note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2));
   }
   CrashReporter::AppendAppNotesToCrashReport(note);
+
+#endif
 }
 
 static OperatingSystem
 WindowsVersionToOperatingSystem(int32_t aWindowsVersion)
 {
   switch(aWindowsVersion) {
     case kWindows7:
       return OperatingSystem::Windows7;
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -7,17 +7,19 @@
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/TextEvents.h"
 
 #include "nsAlgorithm.h"
+#ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
+#endif
 #include "nsGkAtoms.h"
 #include "nsIIdleServiceInternal.h"
 #include "nsIWindowsRegKey.h"
 #include "nsMemory.h"
 #include "nsPrintfCString.h"
 #include "nsQuickSort.h"
 #include "nsServiceManagerUtils.h"
 #include "nsToolkit.h"
@@ -2689,16 +2691,18 @@ NativeKey::NeedsToHandleWithoutFollowing
     return false;
   }
 
   // Even if the key is a printable key, it might cause non-printable character
   // input with modifier key(s).
   return mIsPrintableKey;
 }
 
+#ifdef MOZ_CRASHREPORTER
+
 static nsCString
 GetResultOfInSendMessageEx()
 {
   DWORD ret = ::InSendMessageEx(nullptr);
   if (!ret) {
     return NS_LITERAL_CSTRING("ISMEX_NOSEND");
   }
   nsAutoCString result;
@@ -2721,16 +2725,18 @@ GetResultOfInSendMessageEx()
     if (!result.IsEmpty()) {
       result += " | ";
     }
     result += "ISMEX_SEND";
   }
   return result;
 }
 
+#endif // #ifdef MOZ_CRASHREPORTER
+
 bool
 NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1,
                                 const MSG& aCharMsg2) const
 {
   // NOTE: Although, we don't know when this case occurs, the scan code value
   //       in lParam may be changed from 0 to something.  The changed value
   //       is different from the scan code of handling keydown message.
   static const LPARAM kScanCodeMask = 0x00FF0000;
@@ -2964,16 +2970,17 @@ NativeKey::GetFollowingCharMessage(MSG& 
       }
       MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
         ("%p   NativeKey::GetFollowingCharMessage(), FAILED, lost target "
          "message to remove, nextKeyMsg=%s",
          this, ToString(nextKeyMsg).get()));
     }
 
     if (doCrash) {
+#ifdef MOZ_CRASHREPORTER
       nsPrintfCString info("\nPeekMessage() failed to remove char message! "
                            "\nActive keyboard layout=0x%08X (%s), "
                            "\nHandling message: %s, InSendMessageEx()=%s, "
                            "\nFound message: %s, "
                            "\nWM_NULL has been removed: %d, "
                            "\nNext key message in all windows: %s, "
                            "time=%d, ",
                            KeyboardLayout::GetActiveLayout(),
@@ -2989,17 +2996,17 @@ NativeKey::GetFollowingCharMessage(MSG& 
                                 PM_NOREMOVE | PM_NOYIELD)) {
         nsPrintfCString info("\nNext message in all windows: %s, time=%d",
                              ToString(nextMsg).get(), nextMsg.time);
         CrashReporter::AppendAppNotesToCrashReport(info);
       } else {
         CrashReporter::AppendAppNotesToCrashReport(
           NS_LITERAL_CSTRING("\nThere is no message in any window"));
       }
-
+#endif // #ifdef MOZ_CRASHREPORTER
       MOZ_CRASH("We lost the following char message");
     }
 
     // We're still not sure why ::PeekMessage() may return WM_NULL even with
     // its first message and its last message are same message.  However,
     // at developing Metrofox, we met this case even with usual keyboard
     // layouts.  So, it might be possible in desktop application or it really
     // occurs with some odd keyboard layouts which perhaps hook API.
@@ -3108,16 +3115,17 @@ NativeKey::GetFollowingCharMessage(MSG& 
     //       in lParam may be changed from 0 to something.  The changed value
     //       is different from the scan code of handling keydown message.
     MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
       ("%p   NativeKey::GetFollowingCharMessage(), FAILED, removed message "
        "is really different from what we have already found, removedMsg=%s, "
        "nextKeyMsg=%s, kFoundCharMsg=%s",
        this, ToString(removedMsg).get(), ToString(nextKeyMsg).get(),
        ToString(kFoundCharMsg).get()));
+#ifdef MOZ_CRASHREPORTER
     nsPrintfCString info("\nPeekMessage() removed unexpcted char message! "
                          "\nActive keyboard layout=0x%08X (%s), "
                          "\nHandling message: %s, InSendMessageEx()=%s, "
                          "\nFound message: %s, "
                          "\nRemoved message: %s, ",
                          KeyboardLayout::GetActiveLayout(),
                          KeyboardLayout::GetActiveLayoutName().get(),
                          ToString(mMsg).get(),
@@ -3145,33 +3153,35 @@ NativeKey::GetFollowingCharMessage(MSG& 
                               PM_NOREMOVE | PM_NOYIELD)) {
       nsPrintfCString info("\nNext key message in all windows: %s.",
                            ToString(nextKeyMsgInAllWindows).get());
       CrashReporter::AppendAppNotesToCrashReport(info);
     } else {
       CrashReporter::AppendAppNotesToCrashReport(
         NS_LITERAL_CSTRING("\nThere is no key message in any windows."));
     }
-
+#endif // #ifdef MOZ_CRASHREPORTER
     MOZ_CRASH("PeekMessage() removed unexpected message");
   }
   MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
     ("%p   NativeKey::GetFollowingCharMessage(), FAILED, removed messages "
      "are all WM_NULL, nextKeyMsg=%s",
      this, ToString(nextKeyMsg).get()));
+#ifdef MOZ_CRASHREPORTER
   nsPrintfCString info("\nWe lost following char message! "
                        "\nActive keyboard layout=0x%08X (%s), "
                        "\nHandling message: %s, InSendMessageEx()=%s, \n"
                        "Found message: %s, removed a lot of WM_NULL",
                        KeyboardLayout::GetActiveLayout(),
                        KeyboardLayout::GetActiveLayoutName().get(),
                        ToString(mMsg).get(),
                        GetResultOfInSendMessageEx().get(),
                        ToString(kFoundCharMsg).get());
   CrashReporter::AppendAppNotesToCrashReport(info);
+#endif // #ifdef MOZ_CRASHREPORTER
   MOZ_CRASH("We lost the following char message");
   return false;
 }
 
 bool
 NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages() const
 {
   MOZ_ASSERT(IsKeyDownMessage());
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -37,17 +37,16 @@ UNIFIED_SOURCES += [
     'CompositorWidgetParent.cpp',
     'GfxInfo.cpp',
     'IEnumFE.cpp',
     'IMMHandler.cpp',
     'InkCollector.cpp',
     'InProcessWinCompositorWidget.cpp',
     'JumpListItem.cpp',
     'KeyboardLayout.cpp',
-    'LSPAnnotator.cpp',
     'nsAppShell.cpp',
     'nsClipboard.cpp',
     'nsColorPicker.cpp',
     'nsDataObj.cpp',
     'nsDataObjCollection.cpp',
     'nsDragService.cpp',
     'nsIdleServiceWin.cpp',
     'nsImageClipboard.cpp',
@@ -83,16 +82,21 @@ SOURCES += [
     'nsBidiKeyboard.cpp',
     'nsFilePicker.cpp',
     'nsWidgetFactory.cpp',
     'WinCompositorWidget.cpp',
     'WindowsUIUtils.cpp',
     'WinMouseScrollHandler.cpp',
 ]
 
+if CONFIG['MOZ_CRASHREPORTER']:
+    UNIFIED_SOURCES += [
+        'LSPAnnotator.cpp',
+    ]
+
 if CONFIG['NS_PRINTING']:
     UNIFIED_SOURCES += [
         'nsDeviceContextSpecWin.cpp',
         'nsPrintDialogUtil.cpp',
         'nsPrintDialogWin.cpp',
         'nsPrintOptionsWin.cpp',
         'nsPrintSettingsWin.cpp',
     ]
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -159,17 +159,19 @@ nsAppShell::~nsAppShell()
     // the UI thread.
     SendMessage(mEventWnd, WM_CLOSE, 0, 0);
   }
 }
 
 nsresult
 nsAppShell::Init()
 {
+#ifdef MOZ_CRASHREPORTER
   LSPAnnotate();
+#endif
 
   mLastNativeEventScheduled = TimeStamp::NowLoRes();
 
   mozilla::ipc::windows::InitUIThread();
 
   sTaskbarButtonCreatedMsg = ::RegisterWindowMessageW(kTaskbarButtonEventId);
   NS_ASSERTION(sTaskbarButtonCreatedMsg, "Could not register taskbar button creation message");
 
--- a/xpcom/base/CycleCollectedJSContext.cpp
+++ b/xpcom/base/CycleCollectedJSContext.cpp
@@ -32,16 +32,20 @@
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollector.h"
 #include "nsDOMJSUtils.h"
 #include "nsDOMMutationObserver.h"
 #include "nsJSUtils.h"
 #include "nsWrapperCache.h"
 #include "nsStringBuffer.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #include "nsIException.h"
 #include "nsIPlatformInfo.h"
 #include "nsThread.h"
 #include "nsThreadUtils.h"
 #include "xpcpublic.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -76,26 +76,29 @@
 #include "jsprf.h"
 #include "js/Debug.h"
 #include "js/GCAPI.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollector.h"
 #include "nsDOMJSUtils.h"
-#include "nsExceptionHandler.h"
 #include "nsJSUtils.h"
 #include "nsWrapperCache.h"
 #include "nsStringBuffer.h"
 #include "GeckoProfiler.h"
 
 #ifdef MOZ_GECKO_PROFILER
 #include "ProfilerMarkerPayload.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #include "nsIException.h"
 #include "nsIPlatformInfo.h"
 #include "nsThread.h"
 #include "nsThreadUtils.h"
 #include "xpcpublic.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -537,19 +540,20 @@ CycleCollectedJSRuntime::CycleCollectedJ
       aCx, GCNurseryCollectionCallback);
   }
 
   JS_SetObjectsTenuredCallback(aCx, JSObjectsTenuredCb, this);
   JS::SetOutOfMemoryCallback(aCx, OutOfMemoryCallback, this);
   JS_SetExternalStringSizeofCallback(aCx, SizeofExternalStringCallback);
   JS::SetBuildIdOp(aCx, GetBuildId);
   JS::SetWarningReporter(aCx, MozCrashWarningReporter);
-
-  js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback(
-    CrashReporter::AnnotateOOMAllocationSize);
+#ifdef MOZ_CRASHREPORTER
+    js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback(
+            CrashReporter::AnnotateOOMAllocationSize);
+#endif
 
   static js::DOMCallbacks DOMcallbacks = {
     InstanceClassHasProtoAtDepth
   };
   SetDOMCallbacks(aCx, &DOMcallbacks);
   js::SetScriptEnvironmentPreparer(aCx, &mEnvironmentPreparer);
 
   JS::dbg::SetDebuggerMallocSizeOf(aCx, moz_malloc_size_of);
@@ -1438,42 +1442,46 @@ CycleCollectedJSRuntime::FinalizeDeferre
   }
 }
 
 void
 CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr,
                                                    OOMState aNewState)
 {
   *aStatePtr = aNewState;
+#ifdef MOZ_CRASHREPORTER
   CrashReporter::AnnotateCrashReport(aStatePtr == &mOutOfMemoryState
                                      ? NS_LITERAL_CSTRING("JSOutOfMemory")
                                      : NS_LITERAL_CSTRING("JSLargeAllocationFailure"),
                                      aNewState == OOMState::Reporting
                                      ? NS_LITERAL_CSTRING("Reporting")
                                      : aNewState == OOMState::Reported
                                      ? NS_LITERAL_CSTRING("Reported")
                                      : NS_LITERAL_CSTRING("Recovered"));
+#endif
 }
 
 void
 CycleCollectedJSRuntime::OnGC(JSContext* aContext,
                               JSGCStatus aStatus)
 {
   switch (aStatus) {
     case JSGC_BEGIN:
       nsCycleCollector_prepareForGarbageCollection();
       mZonesWaitingForGC.Clear();
       break;
     case JSGC_END: {
+#ifdef MOZ_CRASHREPORTER
       if (mOutOfMemoryState == OOMState::Reported) {
         AnnotateAndSetOutOfMemory(&mOutOfMemoryState, OOMState::Recovered);
       }
       if (mLargeAllocationFailureState == OOMState::Reported) {
         AnnotateAndSetOutOfMemory(&mLargeAllocationFailureState, OOMState::Recovered);
       }
+#endif
 
       // Do any deferred finalization of native objects. Normally we do this
       // incrementally for an incremental GC, and immediately for a
       // non-incremental GC, on the basis that the type of GC reflects how
       // urgently resources should be destroyed. However under some circumstances
       // (such as in js::InternalCallOrConstruct) we can end up running a
       // non-incremental GC when there is a pending exception, and the finalizers
       // are not set up to handle that. In that case, just run them later, after
--- a/xpcom/base/nsCrashOnException.cpp
+++ b/xpcom/base/nsCrashOnException.cpp
@@ -1,31 +1,34 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCrashOnException.h"
 #include "nsCOMPtr.h"
-#include "nsICrashReporter.h"
 #include "nsServiceManagerUtils.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsICrashReporter.h"
+#endif
 
 namespace mozilla {
 
 static int
 ReportException(EXCEPTION_POINTERS* aExceptionInfo)
 {
+#ifdef MOZ_CRASHREPORTER
   nsCOMPtr<nsICrashReporter> cr =
     do_GetService("@mozilla.org/toolkit/crash-reporter;1");
   if (cr) {
     cr->WriteMinidumpForException(aExceptionInfo);
   }
-
+#endif
   return EXCEPTION_EXECUTE_HANDLER;
 }
 
 XPCOM_API(LRESULT)
 CallWindowProcCrashProtected(WNDPROC aWndProc, HWND aHWnd, UINT aMsg,
                              WPARAM aWParam, LPARAM aLParam)
 {
   MOZ_SEH_TRY {
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -162,17 +162,16 @@
 #include "mozilla/LinkedList.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/SegmentedVector.h"
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsDeque.h"
-#include "nsExceptionHandler.h"
 #include "nsCycleCollector.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "prenv.h"
 #include "nsPrintfCString.h"
 #include "nsTArray.h"
 #include "nsIConsoleService.h"
 #include "mozilla/Attributes.h"
@@ -187,16 +186,20 @@
 #include <stdio.h>
 
 #include "mozilla/AutoGlobalTimelineMarker.h"
 #include "mozilla/Likely.h"
 #include "mozilla/PoisonIOInterposer.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/ThreadLocal.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 using namespace mozilla;
 
 struct NurseryPurpleBufferEntry
 {
   void* mPtr;
   nsCycleCollectionParticipant* mParticipant;
   nsCycleCollectingAutoRefCnt* mRefCnt;
 };
@@ -660,22 +663,24 @@ public:
 
 void
 PtrInfo::AnnotatedReleaseAssert(bool aCondition, const char* aMessage)
 {
   if (aCondition) {
     return;
   }
 
+#ifdef MOZ_CRASHREPORTER
   const char* piName = "Unknown";
   if (mParticipant) {
     piName = mParticipant->ClassName();
   }
   nsPrintfCString msg("%s, for class %s", aMessage, piName);
   CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CycleCollector"), msg);
+#endif
 
   MOZ_CRASH();
 }
 
 /**
  * A structure designed to be used like a linked list of PtrInfo, except
  * it allocates many PtrInfos at a time.
  */
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -8,17 +8,19 @@
 #include "base/process_util.h"
 
 #include "mozilla/Atomics.h"
 #include "mozilla/Printf.h"
 
 #include "MainThreadUtils.h"
 #include "nsDebugImpl.h"
 #include "nsDebug.h"
-#include "nsExceptionHandler.h"
+#ifdef MOZ_CRASHREPORTER
+# include "nsExceptionHandler.h"
+#endif
 #include "nsString.h"
 #include "nsXULAppAPI.h"
 #include "prprf.h"
 #include "nsError.h"
 #include "prerror.h"
 #include "prerr.h"
 #include "prenv.h"
 
@@ -385,29 +387,31 @@ NS_DebugBreak(uint32_t aSeverity, const 
     case NS_DEBUG_WARNING:
       return;
 
     case NS_DEBUG_BREAK:
       Break(buf.buffer);
       return;
 
     case NS_DEBUG_ABORT: {
+#if defined(MOZ_CRASHREPORTER)
       // Updating crash annotations in the child causes us to do IPC. This can
       // really cause trouble if we're asserting from within IPC code. So we
       // have to do without the annotations in that case.
       if (XRE_IsParentProcess()) {
         // Don't include the PID in the crash report annotation to
         // allow faceting on crash-stats.mozilla.org.
         nsCString note("xpcom_runtime_abort(");
         note += nonPIDBuf.buffer;
         note += ")";
         CrashReporter::AppendAppNotesToCrashReport(note);
         CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AbortMessage"),
                                            nsDependentCString(nonPIDBuf.buffer));
       }
+#endif  // MOZ_CRASHREPORTER
 
 #if defined(DEBUG) && defined(_WIN32)
       RealBreak();
 #endif
 #if defined(DEBUG)
       nsTraceRefcnt::WalkTheStack(stderr);
 #endif
       Abort(buf.buffer);
@@ -605,11 +609,13 @@ NS_ErrorAccordingToNSPR()
     case PR_NO_ACCESS_RIGHTS_ERROR:      return NS_ERROR_FILE_ACCESS_DENIED;
     default:                             return NS_ERROR_FAILURE;
   }
 }
 
 void
 NS_ABORT_OOM(size_t aSize)
 {
+#if defined(MOZ_CRASHREPORTER)
   CrashReporter::AnnotateOOMAllocationSize(aSize);
+#endif
   MOZ_CRASH("OOM");
 }
--- a/xpcom/base/nsObjCExceptions.h
+++ b/xpcom/base/nsObjCExceptions.h
@@ -12,17 +12,17 @@
 #define nsObjCExceptions_h_
 
 #import <Foundation/Foundation.h>
 
 #ifdef DEBUG
 #import <ExceptionHandling/NSExceptionHandler.h>
 #endif
 
-#if defined(__cplusplus)
+#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus)
 #include "nsICrashReporter.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #endif
 
 #include <unistd.h>
 #include <signal.h>
 #include "nsError.h"
@@ -42,17 +42,17 @@
 
 __attribute__((unused))
 static void
 nsObjCExceptionLog(NSException* aException)
 {
   NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]",
         [aException name], [aException reason]);
 
-#if defined(__cplusplus)
+#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus)
   // Attach exception info to the crash report.
   nsCOMPtr<nsICrashReporter> crashReporter =
     do_GetService("@mozilla.org/toolkit/crash-reporter;1");
   if (crashReporter) {
     crashReporter->AppendObjCExceptionInfoToAppNotes(static_cast<void*>(aException));
   }
 #endif
 
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -398,24 +398,26 @@ XRE_API(const char*,
 #if defined(MOZ_WIDGET_ANDROID)
 XRE_API(void,
         XRE_SetAndroidChildFds, (JNIEnv* env, int crashFd, int ipcFd))
 #endif // defined(MOZ_WIDGET_ANDROID)
 
 XRE_API(void,
         XRE_SetProcessType, (const char* aProcessTypeString))
 
+#if defined(MOZ_CRASHREPORTER)
 // Used in the "master" parent process hosting the crash server
 XRE_API(bool,
         XRE_TakeMinidumpForChild, (uint32_t aChildPid, nsIFile** aDump,
                                    uint32_t* aSequence))
 
 // Used in child processes.
 XRE_API(bool,
         XRE_SetRemoteExceptionHandler, (const char* aPipe))
+#endif
 
 namespace mozilla {
 namespace gmp {
 class GMPLoader;
 } // namespace gmp
 } // namespace mozilla
 
 XRE_API(nsresult,
--- a/xpcom/system/moz.build
+++ b/xpcom/system/moz.build
@@ -1,21 +1,25 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIBlocklistService.idl',
-    'nsICrashReporter.idl',
     'nsIDeviceSensors.idl',
     'nsIGConfService.idl',
     'nsIGeolocationProvider.idl',
     'nsIGIOService.idl',
     'nsIGSettingsService.idl',
     'nsIHapticFeedback.idl',
     'nsIPlatformInfo.idl',
     'nsIXULAppInfo.idl',
     'nsIXULRuntime.idl',
 ]
 
+if CONFIG['MOZ_CRASHREPORTER']:
+    XPIDL_SOURCES += [
+        'nsICrashReporter.idl',
+    ]
+
 XPIDL_MODULE = 'xpcom_system'
--- a/xpcom/tests/gtest/TestDeadlockDetector.cpp
+++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp
@@ -3,27 +3,30 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 
 #include "prthread.h"
 
-#include "nsCOMPtr.h"
-#include "nsICrashReporter.h"
+#include "nsTArray.h"
 #include "nsMemory.h"
-#include "nsServiceManagerUtils.h"
-#include "nsTArray.h"
 
 #include "mozilla/CondVar.h"
 #include "mozilla/RecursiveMutex.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/Mutex.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsCOMPtr.h"
+#include "nsICrashReporter.h"
+#include "nsServiceManagerUtils.h"
+#endif
+
 #include "gtest/gtest.h"
 
 using namespace mozilla;
 
 // The code in this file is also used by
 // storage/test/gtest/test_deadlock_detector.cpp. The following two macros are
 // used to provide the necessary differentiation between this file and that
 // file.
@@ -66,21 +69,23 @@ protected:
   }
 
 private:
   unsigned int mOldSleepDuration;
 };
 
 void DisableCrashReporter()
 {
+#ifdef MOZ_CRASHREPORTER
     nsCOMPtr<nsICrashReporter> crashreporter =
         do_GetService("@mozilla.org/toolkit/crash-reporter;1");
     if (crashreporter) {
       crashreporter->SetEnabled(false);
     }
+#endif
 }
 
 //-----------------------------------------------------------------------------
 // Single-threaded sanity tests
 
 // Stupidest possible deadlock.
 int
 Sanity_Child()
--- a/xpcom/tests/gtest/TestPLDHash.cpp
+++ b/xpcom/tests/gtest/TestPLDHash.cpp
@@ -1,32 +1,35 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "PLDHashTable.h"
 #include "nsCOMPtr.h"
-#include "nsICrashReporter.h"
 #include "nsServiceManagerUtils.h"
 #include "gtest/gtest.h"
 
 // This test mostly focuses on edge cases. But more coverage of normal
 // operations wouldn't be a bad thing.
 
 #ifdef XP_UNIX
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
 // This global variable is defined in toolkit/xre/nsSigHandlers.cpp.
 extern unsigned int _gdb_sleep_duration;
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsICrashReporter.h"
+#endif
+
 // We can test that certain operations cause expected aborts by forking
 // and then checking that the child aborted in the expected way (i.e. via
 // MOZ_CRASH). We skip this for the following configurations.
 // - On Windows, because it doesn't have fork().
 // - On non-DEBUG builds, because the crashes cause the crash reporter to pop
 //   up when running this test locally, which is surprising and annoying.
 // - On ASAN builds, because ASAN alters the way a MOZ_CRASHing process
 //   terminates, which makes it harder to test if the right thing has occurred.
@@ -41,21 +44,23 @@ TestCrashyOperation(void (*aCrashyOperat
 
   int pid = fork();
   ASSERT_NE(pid, -1);
 
   if (pid == 0) {
     // Disable the crashreporter -- writing a crash dump in the child will
     // prevent the parent from writing a subsequent dump. Crashes here are
     // expected, so we don't want their stacks to show up in the log anyway.
+#ifdef MOZ_CRASHREPORTER
     nsCOMPtr<nsICrashReporter> crashreporter =
       do_GetService("@mozilla.org/toolkit/crash-reporter;1");
     if (crashreporter) {
       crashreporter->SetEnabled(false);
     }
+#endif
 
     // Child: perform the crashy operation.
     fprintf(stderr, "TestCrashyOperation: The following crash is expected. Do not panic.\n");
     aCrashyOperation();
     fprintf(stderr, "TestCrashyOperation: didn't crash?!\n");
     ASSERT_TRUE(false);   // shouldn't reach here
   }
 
--- a/xpcom/tests/gtest/TestSTLWrappers.cpp
+++ b/xpcom/tests/gtest/TestSTLWrappers.cpp
@@ -5,19 +5,21 @@
 #  error "failed to wrap <algorithm>"
 #endif
 
 #include <vector>
 #ifndef mozilla_vector_h
 #  error "failed to wrap <vector>"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
 #include "nsCOMPtr.h"
 #include "nsICrashReporter.h"
 #include "nsServiceManagerUtils.h"
+#endif
 
 // gcc errors out if we |try ... catch| with -fno-exceptions, but we
 // can still test on windows
 #ifdef _MSC_VER
    // C4530 will be generated whenever try...catch is used without
    // enabling exceptions. We know we don't enbale exceptions.
 #  pragma warning( disable : 4530 )
 #  define TRY       try
@@ -34,21 +36,23 @@ extern unsigned int _gdb_sleep_duration;
 #endif
 
 void ShouldAbort()
 {
 #if defined(XP_UNIX)
     _gdb_sleep_duration = 0;
 #endif
 
+#ifdef MOZ_CRASHREPORTER
     nsCOMPtr<nsICrashReporter> crashreporter =
         do_GetService("@mozilla.org/toolkit/crash-reporter;1");
     if (crashreporter) {
       crashreporter->SetEnabled(false);
     }
+#endif
 
     std::vector<int> v;
     int rv = 1;
 
     TRY {
       // v.at(1) on empty v should abort; NOT throw an exception
 
       // (Do some arithmetic with result of v.at() to avoid
--- a/xpcom/threads/HangMonitor.cpp
+++ b/xpcom/threads/HangMonitor.cpp
@@ -9,24 +9,27 @@
 #include "mozilla/Atomics.h"
 #include "mozilla/BackgroundHangMonitor.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ProcessedStack.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/UniquePtr.h"
-#include "nsExceptionHandler.h"
 #include "nsReadableUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/StackWalk.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "GeckoProfiler.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
 #if defined(MOZ_GECKO_PROFILER) && defined(MOZ_PROFILING) && defined(XP_WIN)
   #define REPORT_CHROME_HANGS
 #endif
 
@@ -102,23 +105,25 @@ Crash()
   }
 
 #ifdef XP_WIN
   if (::IsDebuggerPresent()) {
     return;
   }
 #endif
 
+#ifdef MOZ_CRASHREPORTER
   // If you change this, you must also deal with the threadsafety of AnnotateCrashReport in
   // non-chrome processes!
   if (GeckoProcessType_Default == XRE_GetProcessType()) {
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Hang"),
                                        NS_LITERAL_CSTRING("1"));
     CrashReporter::SetMinidumpAnalysisAllThreads();
   }
+#endif
 
   MOZ_CRASH("HangMonitor triggered");
 }
 
 #ifdef REPORT_CHROME_HANGS
 
 static void
 ChromeStackWalker(uint32_t aFrameNumber, void* aPC, void* aSP, void* aClosure)
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -33,24 +33,26 @@
 #include "mozilla/Services.h"
 #include "mozilla/SystemGroup.h"
 #include "nsXPCOMPrivate.h"
 #include "mozilla/ChaosMode.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/ScriptSettings.h"
-#include "nsICrashReporter.h"
 #include "nsThreadSyncDispatch.h"
-#include "nsServiceManagerUtils.h"
 #include "GeckoProfiler.h"
 #include "InputEventStatistics.h"
 #include "ThreadEventTarget.h"
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsServiceManagerUtils.h"
+#include "nsICrashReporter.h"
 #include "mozilla/dom/ContentChild.h"
+#endif
 
 #ifdef XP_LINUX
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sched.h>
 #endif
 
 #define HAVE_UALARM _BSD_SOURCE || (_XOPEN_SOURCE >= 500 ||                 \
@@ -469,16 +471,17 @@ nsThread::ThreadFunc(void* aArg)
   FreeTraceInfo();
 #endif
 
   NS_RELEASE(self);
 }
 
 //-----------------------------------------------------------------------------
 
+#ifdef MOZ_CRASHREPORTER
 // Tell the crash reporter to save a memory report if our heuristics determine
 // that an OOM failure is likely to occur soon.
 // Memory usage will not be checked more than every 30 seconds or saved more
 // than every 3 minutes
 // If |aShouldSave == kForceReport|, a report will be saved regardless of
 // whether the process is low on memory or not. However, it will still not be
 // saved if a report was saved less than 3 minutes ago.
 bool
@@ -533,16 +536,17 @@ nsThread::SaveMemoryReportNearOOM(Should
     nextCheck = now + TimeDuration::FromSeconds(kLowMemorySaveSeconds);
   } else {
     recentlySavedReport = false;
     nextCheck = now + TimeDuration::FromSeconds(kLowMemoryCheckSeconds);
   }
 
   return recentlySavedReport;
 }
+#endif
 
 #ifdef MOZ_CANARY
 int sCanaryOutputFD = -1;
 #endif
 
 nsThread::nsThread(NotNull<SynchronizedEventQueue*> aQueue,
                    MainThreadFlag aMainThread,
                    uint32_t aStackSize)
@@ -1198,19 +1202,21 @@ nsThread::DoMainThreadSpecificProcessing
                             mpPending == MemPressure_New ? u"low-memory-no-forward" :
                             u"low-memory-ongoing-no-forward");
       } else {
         NS_WARNING("Can't get observer service!");
       }
     }
   }
 
+#ifdef MOZ_CRASHREPORTER
   if (!ShuttingDown()) {
     SaveMemoryReportNearOOM(ShouldSaveMemoryReport::kMaybeReport);
   }
+#endif
 }
 
 NS_IMETHODIMP
 nsThread::GetEventTarget(nsIEventTarget** aEventTarget)
 {
   nsCOMPtr<nsIEventTarget> target = this;
   target.forget(aEventTarget);
   return NS_OK;
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -82,23 +82,25 @@ public:
 
   uint32_t
   RecursionDepth() const;
 
   void ShutdownComplete(NotNull<struct nsThreadShutdownContext*> aContext);
 
   void WaitForAllAsynchronousShutdowns();
 
+#ifdef MOZ_CRASHREPORTER
   enum class ShouldSaveMemoryReport
   {
     kMaybeReport,
     kForceReport
   };
 
   static bool SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave);
+#endif
 
   static const uint32_t kRunnableNameBufSize = 1000;
   static mozilla::Array<char, kRunnableNameBufSize> sMainThreadRunnableName;
 
   void EnableInputEventPrioritization()
   {
     EventQueue()->EnableInputEventPrioritization();
   }
--- a/xpcom/threads/nsThreadUtils.cpp
+++ b/xpcom/threads/nsThreadUtils.cpp
@@ -5,33 +5,38 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Likely.h"
 #include "mozilla/TimeStamp.h"
 #include "LeakRefPtr.h"
 #include "nsComponentManagerUtils.h"
-#include "nsExceptionHandler.h"
 #include "nsITimer.h"
 
+#include "nsComponentManagerUtils.h"
+
 #ifdef MOZILLA_INTERNAL_API
 # include "nsThreadManager.h"
 #else
 # include "nsXPCOMCIDInternal.h"
 # include "nsIThreadManager.h"
 # include "nsServiceManagerUtils.h"
 #endif
 
 #ifdef XP_WIN
 #include <windows.h>
 #elif defined(XP_MACOSX)
 #include <sys/resource.h>
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 using namespace mozilla;
 
 #ifndef XPCOM_GLUE_AVOID_NSPR
 
 NS_IMPL_ISUPPORTS(IdlePeriod, nsIIdlePeriod)
 
 NS_IMETHODIMP
 IdlePeriod::GetIdlePeriodHint(TimeStamp* aIdleDeadline)
@@ -507,17 +512,19 @@ NS_ProcessNextEvent(nsIThread* aThread, 
   bool val;
   return NS_SUCCEEDED(aThread->ProcessNextEvent(aMayWait, &val)) && val;
 }
 
 void
 NS_SetCurrentThreadName(const char* aName)
 {
   PR_SetCurrentThreadName(aName);
+#ifdef MOZ_CRASHREPORTER
   CrashReporter::SetCurrentThreadName(aName);
+#endif
 }
 
 #ifdef MOZILLA_INTERNAL_API
 nsIThread*
 NS_GetCurrentThread()
 {
   return nsThreadManager::get().GetCurrentThread();
 }