Merge mozilla-central to autoland. CLOSED TREE
authorCsoregi Natalia <ncsoregi@mozilla.com>
Sat, 16 Mar 2019 12:25:06 +0200
changeset 464690 1b9bfa6dab28e2824ea695dedc76f64e0636d0f3
parent 464689 8f2a6dbf221ca51fcb80f1a94eea41d377a0c91c (current diff)
parent 464367 124ee436c4214fbb5c770c87054a7484c31772f5 (diff)
child 464691 b12dda048dd5b1d0bed3d3e0cb7387c4cb6b66cf
push id112465
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:50:10 +0000
treeherdermozilla-inbound@e0861be8d6c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-central to autoland. CLOSED TREE
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,5 +1,5 @@
 This is the PDF.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 2.2.67
+Current extension version is: 2.2.71
 
-Taken from upstream commit: d587abbc
+Taken from upstream commit: 80135378
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.2.67';
-var pdfjsBuild = 'd587abbc';
+var pdfjsVersion = '2.2.71';
+var pdfjsBuild = '80135378';
 
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 
 var pdfjsDisplayAPI = __w_pdfjs_require__(6);
 
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(18);
 
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(19);
@@ -191,16 +191,17 @@ Object.defineProperty(exports, "__esModu
 exports.arrayByteLength = arrayByteLength;
 exports.arraysToBytes = arraysToBytes;
 exports.assert = assert;
 exports.bytesToString = bytesToString;
 exports.createPromiseCapability = createPromiseCapability;
 exports.getVerbosityLevel = getVerbosityLevel;
 exports.info = info;
 exports.isArrayBuffer = isArrayBuffer;
+exports.isArrayEqual = isArrayEqual;
 exports.isBool = isBool;
 exports.isEmptyObj = isEmptyObj;
 exports.isNum = isNum;
 exports.isString = isString;
 exports.isSpace = isSpace;
 exports.isSameOrigin = isSameOrigin;
 exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
 exports.isLittleEndian = isLittleEndian;
@@ -969,16 +970,26 @@ function isNum(v) {
 function isString(v) {
   return typeof v === 'string';
 }
 
 function isArrayBuffer(v) {
   return typeof v === 'object' && v !== null && v.byteLength !== undefined;
 }
 
+function isArrayEqual(arr1, arr2) {
+  if (arr1.length !== arr2.length) {
+    return false;
+  }
+
+  return arr1.every(function (element, index) {
+    return element === arr2[index];
+  });
+}
+
 function isSpace(ch) {
   return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
 }
 
 function createPromiseCapability() {
   const capability = Object.create(null);
   let isSettled = false;
   Object.defineProperty(capability, 'settled', {
@@ -1285,17 +1296,17 @@ function _fetchDocument(worker, source, 
 
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
   }
 
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
     docId,
-    apiVersion: '2.2.67',
+    apiVersion: '2.2.71',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -1413,18 +1424,17 @@ class PDFDataRangeTransport {
 
   abort() {}
 
 }
 
 exports.PDFDataRangeTransport = PDFDataRangeTransport;
 
 class PDFDocumentProxy {
-  constructor(pdfInfo, transport, loadingTask) {
-    this.loadingTask = loadingTask;
+  constructor(pdfInfo, transport) {
     this._pdfInfo = pdfInfo;
     this._transport = transport;
   }
 
   get numPages() {
     return this._pdfInfo.numPages;
   }
 
@@ -1499,16 +1509,20 @@ class PDFDocumentProxy {
   destroy() {
     return this.loadingTask.destroy();
   }
 
   get loadingParams() {
     return this._transport.loadingParams;
   }
 
+  get loadingTask() {
+    return this._transport.loadingTask;
+  }
+
 }
 
 exports.PDFDocumentProxy = PDFDocumentProxy;
 
 class PDFPageProxy {
   constructor(pageIndex, pageInfo, transport, pdfBug = false) {
     this.pageIndex = pageIndex;
     this._pageInfo = pageInfo;
@@ -2366,20 +2380,19 @@ class WorkerTransport {
 
       sink.onCancel = reason => {
         rangeReader.cancel(reason);
       };
     }, this);
     messageHandler.on('GetDoc', function ({
       pdfInfo
     }) {
-      this.numPages = pdfInfo.numPages;
-      this.pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
-
-      loadingTask._capability.resolve(this.pdfDocument);
+      this._numPages = pdfInfo.numPages;
+
+      loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
     }, this);
     messageHandler.on('PasswordRequest', function (exception) {
       this._passwordCapability = (0, _util.createPromiseCapability)();
 
       if (loadingTask.onPassword) {
         const updatePassword = password => {
           this._passwordCapability.resolve({
             password
@@ -2666,17 +2679,17 @@ class WorkerTransport {
     }
   }
 
   getData() {
     return this.messageHandler.sendWithPromise('GetData', null);
   }
 
   getPage(pageNumber) {
-    if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
+    if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
       return Promise.reject(new Error('Invalid page request'));
     }
 
     const pageIndex = pageNumber - 1;
 
     if (pageIndex in this.pagePromises) {
       return this.pagePromises[pageIndex];
     }
@@ -3028,19 +3041,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.2.67';
+const version = '2.2.71';
 exports.version = version;
-const build = 'd587abbc';
+const build = '80135378';
 exports.build = build;
 
 /***/ }),
 /* 7 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-const pdfjsVersion = '2.2.67';
-const pdfjsBuild = 'd587abbc';
+const pdfjsVersion = '2.2.71';
+const pdfjsBuild = '80135378';
 
 const pdfjsCoreWorker = __w_pdfjs_require__(1);
 
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -373,17 +373,17 @@ var WorkerMessageHandler = {
 
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     const verbosity = (0, _util.getVerbosityLevel)();
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '2.2.67';
+    let workerVersion = '2.2.71';
 
     if (apiVersion !== workerVersion) {
       throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
     }
 
     var docId = docParams.docId;
     var docBaseUrl = docParams.docBaseUrl;
     var workerHandlerName = docParams.docId + '_worker';
@@ -839,16 +839,17 @@ Object.defineProperty(exports, "__esModu
 exports.arrayByteLength = arrayByteLength;
 exports.arraysToBytes = arraysToBytes;
 exports.assert = assert;
 exports.bytesToString = bytesToString;
 exports.createPromiseCapability = createPromiseCapability;
 exports.getVerbosityLevel = getVerbosityLevel;
 exports.info = info;
 exports.isArrayBuffer = isArrayBuffer;
+exports.isArrayEqual = isArrayEqual;
 exports.isBool = isBool;
 exports.isEmptyObj = isEmptyObj;
 exports.isNum = isNum;
 exports.isString = isString;
 exports.isSpace = isSpace;
 exports.isSameOrigin = isSameOrigin;
 exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
 exports.isLittleEndian = isLittleEndian;
@@ -1617,16 +1618,26 @@ function isNum(v) {
 function isString(v) {
   return typeof v === 'string';
 }
 
 function isArrayBuffer(v) {
   return typeof v === 'object' && v !== null && v.byteLength !== undefined;
 }
 
+function isArrayEqual(arr1, arr2) {
+  if (arr1.length !== arr2.length) {
+    return false;
+  }
+
+  return arr1.every(function (element, index) {
+    return element === arr2[index];
+  });
+}
+
 function isSpace(ch) {
   return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
 }
 
 function createPromiseCapability() {
   const capability = Object.create(null);
   let isSettled = false;
   Object.defineProperty(capability, 'settled', {
@@ -20796,22 +20807,21 @@ var PartialEvaluator = function PartialE
             descent: font.descent,
             vertical: !!font.vertical
           };
         }
 
         textContentItem.fontName = font.loadedName;
         var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
 
-        if (font.isType3Font && textState.fontMatrix !== _util.FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
-          var glyphHeight = font.bbox[3] - font.bbox[1];
+        if (font.isType3Font && textState.fontSize <= 1 && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
+          const glyphHeight = font.bbox[3] - font.bbox[1];
 
           if (glyphHeight > 0) {
-            glyphHeight = glyphHeight * textState.fontMatrix[3];
-            tsm[3] *= glyphHeight;
+            tsm[3] *= glyphHeight * textState.fontMatrix[3];
           }
         }
 
         var trm = _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
 
         textContentItem.transform = trm;
 
         if (!font.vertical) {
--- a/browser/extensions/pdfjs/moz.yaml
+++ b/browser/extensions/pdfjs/moz.yaml
@@ -15,15 +15,15 @@ origin:
   description: Portable Document Format (PDF) viewer that is built with HTML5
 
   # Full URL for the package's homepage/etc
   # Usually different from repository url
   url: https://github.com/mozilla/pdf.js
 
   # Human-readable identifier for this version/release
   # Generally "version NNN", "tag SSS", "bookmark SSS"
-  release: version 2.2.67
+  release: version 2.2.71
 
   # The package's license, where possible using the mnemonic from
   # https://spdx.org/licenses/
   # Multiple licenses can be specified (as a YAML list)
   # A "LICENSE" file must exist containing the full license text
   license: Apache-2.0
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -218,17 +218,17 @@ nsresult OSFileConstantsService::InitOSF
 
   GetPathToSpecialDir(NS_OS_TEMP_DIR, paths->tmpDir);
 
   mPaths = std::move(paths);
 
   // Get the umask from the system-info service.
   // The property will always be present, but it will be zero on
   // non-Unix systems.
-  // nsSystemInfo::gUserUmask is initialized by NS_InitXPCOM2 so we don't need
+  // nsSystemInfo::gUserUmask is initialized by NS_InitXPCOM so we don't need
   // to initialize the service.
   mUserUmask = nsSystemInfo::gUserUmask;
 
   mInitialized = true;
   return NS_OK;
 }
 
 /**
--- a/js/xpconnect/src/XPCShellImpl.cpp
+++ b/js/xpconnect/src/XPCShellImpl.cpp
@@ -1228,19 +1228,19 @@ int XRE_XPCShellMain(int argc, char** ar
       }
 
       XRE_InitOmnijar(greOmni, appOmni);
       argc -= 2;
       argv += 2;
     }
 
     nsCOMPtr<nsIServiceManager> servMan;
-    rv = NS_InitXPCOM2(getter_AddRefs(servMan), appDir, &dirprovider);
+    rv = NS_InitXPCOM(getter_AddRefs(servMan), appDir, &dirprovider);
     if (NS_FAILED(rv)) {
-      printf("NS_InitXPCOM2 failed!\n");
+      printf("NS_InitXPCOM failed!\n");
       return 1;
     }
 
     // xpc::ErrorReport::LogToConsoleWithStack needs this to print errors
     // to stderr.
     Preferences::SetBool("browser.dom.window.dump.enabled", true);
     Preferences::SetBool("devtools.console.stdout.chrome", true);
 
--- a/layout/style/test/ParseCSS.cpp
+++ b/layout/style/test/ParseCSS.cpp
@@ -52,17 +52,17 @@ static int ParseCSSFile(nsIURI *aSheetUR
   if (!complete) return -2;
   return 0;
 }
 
 int main(int argc, char **argv) {
   if (argc < 2) {
     fprintf(stderr, "%s [FILE]...\n", argv[0]);
   }
-  nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
+  nsresult rv = NS_InitXPCOM(nullptr, nullptr, nullptr);
   if (NS_FAILED(rv)) return (int)rv;
 
   int res = 0;
   for (int i = 1; i < argc; ++i) {
     const char *filename = argv[i];
 
     printf("\nParsing %s.\n", filename);
 
--- a/layout/style/test/TestCSSPropertyLookup.cpp
+++ b/layout/style/test/TestCSSPropertyLookup.cpp
@@ -79,17 +79,17 @@ bool TestKeywords() {
     }
   }
 
   nsCSSKeywords::ReleaseTable();
   return success;
 }
 
 int main(void) {
-  nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
+  nsresult rv = NS_InitXPCOM(nullptr, nullptr, nullptr);
   NS_ENSURE_SUCCESS(rv, 2);
 
   bool testOK = true;
   testOK &= TestProps();
   testOK &= TestKeywords();
 
   rv = NS_ShutdownXPCOM(nullptr);
   NS_ENSURE_SUCCESS(rv, 2);
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1288,18 +1288,18 @@ static const mozilla::Module kXREModule 
 
 NSMODULE_DEFN(Apprunner) = &kXREModule;
 
 nsresult ScopedXPCOMStartup::Initialize() {
   NS_ASSERTION(gDirServiceProvider, "Should not get here!");
 
   nsresult rv;
 
-  rv = NS_InitXPCOM2(&mServiceManager, gDirServiceProvider->GetAppDir(),
-                     gDirServiceProvider);
+  rv = NS_InitXPCOM(&mServiceManager, gDirServiceProvider->GetAppDir(),
+                    gDirServiceProvider);
   if (NS_FAILED(rv)) {
     NS_ERROR("Couldn't start xpcom!");
     mServiceManager = nullptr;
   } else {
 #ifdef DEBUG
     nsCOMPtr<nsIComponentRegistrar> reg = do_QueryInterface(mServiceManager);
     NS_ASSERTION(reg, "Service Manager doesn't QI to Registrar.");
 #endif
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -185,17 +185,17 @@ nsresult XRE_InitEmbedding2(nsIFile* aLi
 
   new nsXREDirProvider;  // This sets gDirServiceProvider
   if (!gDirServiceProvider) return NS_ERROR_OUT_OF_MEMORY;
 
   rv = gDirServiceProvider->Initialize(aAppDirectory, aLibXULDirectory,
                                        aAppDirProvider);
   if (NS_FAILED(rv)) return rv;
 
-  rv = NS_InitXPCOM2(nullptr, aAppDirectory, gDirServiceProvider);
+  rv = NS_InitXPCOM(nullptr, aAppDirectory, gDirServiceProvider);
   if (NS_FAILED(rv)) return rv;
 
   // We do not need to autoregister components here. The CheckCompatibility()
   // bits in nsAppRunner.cpp check for an invalidation flag in
   // compatibility.ini.
   // If the app wants to autoregister every time (for instance, if it's debug),
   // it can do so after we return from this function.
 
--- a/tools/fuzzing/interface/harness/FuzzerTestHarness.h
+++ b/tools/fuzzing/interface/harness/FuzzerTestHarness.h
@@ -62,19 +62,19 @@ class ScopedXPCOM : public nsIDirectoryS
   NS_DECL_ISUPPORTS
 
   explicit ScopedXPCOM(const char *testName,
                        nsIDirectoryServiceProvider *dirSvcProvider = nullptr)
       : mDirSvcProvider(dirSvcProvider) {
     mTestName = testName;
     printf("Running %s tests...\n", mTestName);
 
-    nsresult rv = NS_InitXPCOM2(&mServMgr, nullptr, this);
+    nsresult rv = NS_InitXPCOM(&mServMgr, nullptr, this);
     if (NS_FAILED(rv)) {
-      fail("NS_InitXPCOM2 returned failure code 0x%" PRIx32,
+      fail("NS_InitXPCOM returned failure code 0x%" PRIx32,
            static_cast<uint32_t>(rv));
       mServMgr = nullptr;
       return;
     }
   }
 
   ~ScopedXPCOM() {
     // If we created a profile directory, we need to remove it.
--- a/xpcom/base/LogModulePrefWatcher.cpp
+++ b/xpcom/base/LogModulePrefWatcher.cpp
@@ -29,17 +29,17 @@ NS_IMPL_ISUPPORTS(LogModulePrefWatcher, 
 /**
  * Resets all the preferences in the logging. branch
  * This is needed because we may crash while logging, and this would cause us
  * to log after restarting as well.
  *
  * If logging after restart is desired, set the logging.config.clear_on_startup
  * pref to false, or use the MOZ_LOG_FILE and MOZ_LOG_MODULES env vars.
  */
-void ResetExistingPrefs() {
+static void ResetExistingPrefs() {
   uint32_t count;
   char** names;
   nsresult rv = Preferences::GetRootBranch()->GetChildList(kLoggingPrefPrefix,
                                                            &count, &names);
   if (NS_SUCCEEDED(rv) && count) {
     for (size_t i = 0; i < count; i++) {
       // Clearing the pref will cause it to reload, thus resetting the log level
       Preferences::ClearUser(names[i]);
@@ -101,17 +101,17 @@ static void LoadPrefValue(const char* aN
       logLevel = LogLevel::Verbose;
     }
   }
 
   const char* moduleName = aName + strlen(kLoggingPrefPrefix);
   LogModule::Get(moduleName)->SetLevel(logLevel);
 }
 
-void LoadExistingPrefs() {
+static void LoadExistingPrefs() {
   nsIPrefBranch* root = Preferences::GetRootBranch();
   if (!root) {
     return;
   }
 
   uint32_t count;
   char** names;
   nsresult rv = root->GetChildList(kLoggingPrefPrefix, &count, &names);
--- a/xpcom/base/Logging.cpp
+++ b/xpcom/base/Logging.cpp
@@ -75,17 +75,17 @@ void log_print(const LogModule* aModule,
 }  // namespace detail
 
 LogLevel ToLogLevel(int32_t aLevel) {
   aLevel = std::min(aLevel, static_cast<int32_t>(LogLevel::Verbose));
   aLevel = std::max(aLevel, static_cast<int32_t>(LogLevel::Disabled));
   return static_cast<LogLevel>(aLevel);
 }
 
-const char* ToLogStr(LogLevel aLevel) {
+static const char* ToLogStr(LogLevel aLevel) {
   switch (aLevel) {
     case LogLevel::Error:
       return "E";
     case LogLevel::Warning:
       return "W";
     case LogLevel::Info:
       return "I";
     case LogLevel::Debug:
@@ -122,17 +122,18 @@ class LogFile {
   }
 
   FILE* File() const { return mFile; }
   uint32_t Num() const { return mFileNum; }
 
   LogFile* mNextToRelease;
 };
 
-const char* ExpandPIDMarker(const char* aFilename, char (&buffer)[2048]) {
+static const char* ExpandPIDMarker(const char* aFilename,
+                                   char (&buffer)[2048]) {
   MOZ_ASSERT(aFilename);
   static const char kPIDToken[] = "%PID";
   const char* pidTokenPtr = strstr(aFilename, kPIDToken);
   if (pidTokenPtr &&
       SprintfLiteral(
           buffer, "%.*s%s%d%s", static_cast<int>(pidTokenPtr - aFilename),
           aFilename, XRE_IsParentProcess() ? "-main." : "-child.",
           base::GetCurrentProcId(), pidTokenPtr + strlen(kPIDToken)) > 0) {
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -204,19 +204,19 @@ struct NurseryPurpleBufferEntry {
 
 #define NURSERY_PURPLE_BUFFER_SIZE 2048
 bool gNurseryPurpleBufferEnabled = true;
 NurseryPurpleBufferEntry gNurseryPurpleBufferEntry[NURSERY_PURPLE_BUFFER_SIZE];
 uint32_t gNurseryPurpleBufferEntryCount = 0;
 
 void ClearNurseryPurpleBuffer();
 
-void SuspectUsingNurseryPurpleBuffer(void* aPtr,
-                                     nsCycleCollectionParticipant* aCp,
-                                     nsCycleCollectingAutoRefCnt* aRefCnt) {
+static void SuspectUsingNurseryPurpleBuffer(
+    void* aPtr, nsCycleCollectionParticipant* aCp,
+    nsCycleCollectingAutoRefCnt* aRefCnt) {
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
   MOZ_ASSERT(gNurseryPurpleBufferEnabled);
   if (gNurseryPurpleBufferEntryCount == NURSERY_PURPLE_BUFFER_SIZE) {
     ClearNurseryPurpleBuffer();
   }
 
   gNurseryPurpleBufferEntry[gNurseryPurpleBufferEntryCount] = {aPtr, aCp,
                                                                aRefCnt};
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -61,17 +61,17 @@
 #ifdef XP_MACOSX
 #  include <sys/sysctl.h>
 #endif
 
 #if defined(XP_LINUX) && defined(MOZ_SANDBOX)
 #  include "mozilla/SandboxInfo.h"
 #endif
 
-// Slot for NS_InitXPCOM2 to pass information to nsSystemInfo::Init.
+// Slot for NS_InitXPCOM to pass information to nsSystemInfo::Init.
 // Only set to nonzero (potentially) if XP_UNIX.  On such systems, the
 // system call to discover the appropriate value is not thread-safe,
 // so we must call it before going multithreaded, but nsSystemInfo::Init
 // only happens well after that point.
 uint32_t nsSystemInfo::gUserUmask = 0;
 
 using namespace mozilla::dom;
 
--- a/xpcom/base/nsSystemInfo.h
+++ b/xpcom/base/nsSystemInfo.h
@@ -27,18 +27,18 @@ class nsSystemInfo final : public nsHash
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIOBSERVER
 #endif  // defined(XP_WIN)
 
   nsSystemInfo();
 
   nsresult Init();
 
-  // Slot for NS_InitXPCOM2 to pass information to nsSystemInfo::Init.
-  // See comments above the variable definition and in NS_InitXPCOM2.
+  // Slot for NS_InitXPCOM to pass information to nsSystemInfo::Init.
+  // See comments above the variable definition and in NS_InitXPCOM.
   static uint32_t gUserUmask;
 
 #ifdef MOZ_WIDGET_ANDROID
   static void GetAndroidSystemInfo(mozilla::dom::AndroidSystemInfo* aInfo);
 
  protected:
   void SetupAndroidInfo(const mozilla::dom::AndroidSystemInfo&);
 #endif
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -198,21 +198,16 @@ NSMODULE_DEFN(Dummy8) = &kDummy8;
 // gDebug will be freed during shutdown.
 static nsIDebug2* gDebug = nullptr;
 
 EXPORT_XPCOM_API(nsresult)
 NS_GetDebug(nsIDebug2** aResult) {
   return nsDebugImpl::Create(nullptr, NS_GET_IID(nsIDebug2), (void**)aResult);
 }
 
-EXPORT_XPCOM_API(nsresult)
-NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory) {
-  return NS_InitXPCOM2(aResult, aBinDirectory, nullptr);
-}
-
 class ICUReporter final : public nsIMemoryReporter,
                           public CountingAllocatorBase<ICUReporter> {
  public:
   NS_DECL_ISUPPORTS
 
   static void* Alloc(const void*, size_t aSize) {
     return CountingMalloc(aSize);
   }
@@ -268,18 +263,18 @@ NS_IMPL_ISUPPORTS(OggReporter, nsIMemory
 /* static */ template <>
 CountingAllocatorBase<OggReporter>::AmountType
     CountingAllocatorBase<OggReporter>::sAmount(0);
 
 static bool sInitializedJS = false;
 
 // Note that on OSX, aBinDirectory will point to .app/Contents/Resources/browser
 EXPORT_XPCOM_API(nsresult)
-NS_InitXPCOM2(nsIServiceManager** aResult, nsIFile* aBinDirectory,
-              nsIDirectoryServiceProvider* aAppFileLocationProvider) {
+NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory,
+            nsIDirectoryServiceProvider* aAppFileLocationProvider) {
   static bool sInitialized = false;
   if (sInitialized) {
     return NS_ERROR_FAILURE;
   }
 
   sInitialized = true;
 
   mozPoisonValueInit();
--- a/xpcom/build/nsXPCOM.h
+++ b/xpcom/build/nsXPCOM.h
@@ -68,18 +68,18 @@ struct Module;
  *
  * @return NS_OK for success;
  *         NS_ERROR_NOT_INITIALIZED if static globals were not initialized,
  *         which can happen if XPCOM is reloaded, but did not completly
  *         shutdown. Other error codes indicate a failure during
  *         initialisation.
  */
 XPCOM_API(nsresult)
-NS_InitXPCOM2(nsIServiceManager** aResult, nsIFile* aBinDirectory,
-              nsIDirectoryServiceProvider* aAppFileLocationProvider);
+NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory,
+             nsIDirectoryServiceProvider* aAppFileLocationProvider);
 
 /**
  * Initialize only minimal components of XPCOM. This ensures nsThreadManager,
  * logging, and timers will work.
  */
 XPCOM_API(nsresult)
 NS_InitMinimalXPCOM();
 
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -1,16 +1,16 @@
 /* -*- 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 "nsICategoryManager.h"
 #include "nsCategoryManager.h"
+#include "nsCategoryManagerUtils.h"
 
 #include "prio.h"
 #include "prlock.h"
 #include "nsArrayEnumerator.h"
 #include "nsCOMPtr.h"
 #include "nsTHashtable.h"
 #include "nsClassHashtable.h"
 #include "nsIFactory.h"
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -413,23 +413,23 @@ extern mozilla::Module const* const __st
     "section$start$__DATA$.kPStaticModules");
 extern mozilla::Module const* const __stop_kPStaticModules __asm(
     "section$end$__DATA$.kPStaticModules");
 
 #  else
 #    error Do not know how to find NSModules.
 #  endif
 
-mozilla::Module const* const* begin(AllStaticModules& _) {
+static mozilla::Module const* const* begin(AllStaticModules& _) {
   return &__start_kPStaticModules;
 }
 
 #endif
 
-mozilla::Module const* const* end(AllStaticModules& _) {
+static mozilla::Module const* const* end(AllStaticModules& _) {
   return &__stop_kPStaticModules;
 }
 
 /* static */
 void nsComponentManagerImpl::InitializeStaticModules() {
   if (sExtraStaticModules) {
     return;
   }
--- a/xpcom/ds/Dafsa.cpp
+++ b/xpcom/ds/Dafsa.cpp
@@ -15,18 +15,18 @@
 
 const int mozilla::Dafsa::kKeyNotFound = -1;
 
 // Note the DAFSA implementation was lifted from eTLD code in Chromium that was
 // originally lifted from Firefox.
 
 // Read next offset from pos.
 // Returns true if an offset could be read, false otherwise.
-bool GetNextOffset(const unsigned char** pos, const unsigned char* end,
-                   const unsigned char** offset) {
+static bool GetNextOffset(const unsigned char** pos, const unsigned char* end,
+                          const unsigned char** offset) {
   if (*pos == end) return false;
 
   // When reading an offset the byte array must always contain at least
   // three more bytes to consume. First the offset to read, then a node
   // to skip over and finally a destination node. No object can be smaller
   // than one byte.
   MOZ_ASSERT(*pos + 2 < end);
   size_t bytes_consumed;
@@ -47,54 +47,54 @@ bool GetNextOffset(const unsigned char**
     *pos = end;
   } else {
     *pos += bytes_consumed;
   }
   return true;
 }
 
 // Check if byte at offset is last in label.
-bool IsEOL(const unsigned char* offset, const unsigned char* end) {
+static bool IsEOL(const unsigned char* offset, const unsigned char* end) {
   MOZ_ASSERT(offset < end);
   return (*offset & 0x80) != 0;
 }
 
 // Check if byte at offset matches first character in key.
 // This version matches characters not last in label.
-bool IsMatch(const unsigned char* offset, const unsigned char* end,
-             const char* key) {
+static bool IsMatch(const unsigned char* offset, const unsigned char* end,
+                    const char* key) {
   MOZ_ASSERT(offset < end);
   return *offset == *key;
 }
 
 // Check if byte at offset matches first character in key.
 // This version matches characters last in label.
-bool IsEndCharMatch(const unsigned char* offset, const unsigned char* end,
-                    const char* key) {
+static bool IsEndCharMatch(const unsigned char* offset,
+                           const unsigned char* end, const char* key) {
   MOZ_ASSERT(offset < end);
   return *offset == (*key | 0x80);
 }
 
 // Read return value at offset.
 // Returns true if a return value could be read, false otherwise.
-bool GetReturnValue(const unsigned char* offset, const unsigned char* end,
-                    int* return_value) {
+static bool GetReturnValue(const unsigned char* offset,
+                           const unsigned char* end, int* return_value) {
   MOZ_ASSERT(offset < end);
   if ((*offset & 0xE0) == 0x80) {
     *return_value = *offset & 0x0F;
     return true;
   }
   return false;
 }
 
 // Lookup a domain key in a byte array generated by make_dafsa.py.
 // The rule type is returned if key is found, otherwise kKeyNotFound is
 // returned.
-int LookupString(const unsigned char* graph, size_t length, const char* key,
-                 size_t key_length) {
+static int LookupString(const unsigned char* graph, size_t length,
+                        const char* key, size_t key_length) {
   const unsigned char* pos = graph;
   const unsigned char* end = graph + length;
   const unsigned char* offset = pos;
   const char* key_end = key + key_length;
   while (GetNextOffset(&pos, end, &offset)) {
     //   char <char>+ end_char offsets
     //   char <char>+ return value
     //   char end_char offsets
--- a/xpcom/io/CocoaFileUtils.mm
+++ b/xpcom/io/CocoaFileUtils.mm
@@ -187,26 +187,26 @@ void AddOriginMetadataToFile(const CFStr
 
   mdItemSetAttributeFunc(mdItem, kMDItemWhereFroms, list);
 
   ::CFRelease(list);
   ::CFRelease(mdItem);
 }
 
 // Can be called off of the main thread.
-CFStringRef GetQuarantinePropKey() {
+static CFStringRef GetQuarantinePropKey() {
   if (nsCocoaFeatures::OnYosemiteOrLater()) {
     return kCFURLQuarantinePropertiesKey;
   }
   return kLSItemQuarantineProperties;
 }
 
 // Can be called off of the main thread.
-CFMutableDictionaryRef CreateQuarantineDictionary(const CFURLRef aFileURL,
-                                                  const bool aCreateProps) {
+static CFMutableDictionaryRef CreateQuarantineDictionary(const CFURLRef aFileURL,
+                                                         const bool aCreateProps) {
   // The properties key changed in 10.10:
   CFDictionaryRef quarantineProps = NULL;
   if (aCreateProps) {
     quarantineProps = ::CFDictionaryCreate(NULL, NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks,
                                            &kCFTypeDictionaryValueCallBacks);
   } else {
     Boolean success =
         ::CFURLCopyResourcePropertyForKey(aFileURL, GetQuarantinePropKey(), &quarantineProps, NULL);
--- a/xpcom/io/nsDirectoryServiceDefs.h
+++ b/xpcom/io/nsDirectoryServiceDefs.h
@@ -35,17 +35,17 @@
 #define NS_OS_DESKTOP_DIR "Desk"
 
 /* Property returns the directory in which the procces was started from.
  */
 #define NS_OS_CURRENT_PROCESS_DIR "CurProcD"
 
 /* This location is similar to NS_OS_CURRENT_PROCESS_DIR, however,
  * NS_XPCOM_CURRENT_PROCESS_DIR can be overriden by passing a "bin
- * directory" to NS_InitXPCOM2().
+ * directory" to NS_InitXPCOM().
  */
 #define NS_XPCOM_CURRENT_PROCESS_DIR "XCurProcD"
 
 /* Property will return the location of the the XPCOM Shared Library.
  */
 #define NS_XPCOM_LIBRARY_FILE "XpcomLib"
 
 /* Property will return the current location of the GRE directory.
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -17,16 +17,17 @@
 #include "nsSegmentedBuffer.h"
 #include "nsStreamUtils.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "mozilla/Logging.h"
 #include "nsIClassInfoImpl.h"
 #include "nsAlgorithm.h"
 #include "nsMemory.h"
+#include "nsPipe.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIAsyncOutputStream.h"
 
 using namespace mozilla;
 
 #ifdef LOG
 #  undef LOG
 #endif
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -19,16 +19,17 @@
 #include "nsCRT.h"
 #include "prerror.h"
 #include "plstr.h"
 #include "nsIClassInfoImpl.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "nsIIPCSerializableInputStream.h"
+#include "XPCOMModule.h"
 
 using namespace mozilla::ipc;
 using mozilla::Maybe;
 using mozilla::Some;
 
 //-----------------------------------------------------------------------------
 // nsIStringInputStream implementation
 //-----------------------------------------------------------------------------
--- a/xpcom/rust/gtest/bench-collections/Bench.cpp
+++ b/xpcom/rust/gtest/bench-collections/Bench.cpp
@@ -57,17 +57,17 @@
 
 using namespace mozilla;
 
 // This function gives a pseudo-random sequence with the following properties:
 // - Deterministic and platform-independent.
 // - No duplicates in the first VALS_LEN results, which is useful for ensuring
 //   the tables get to a particular size, and also for guaranteeing lookups
 //   that fail.
-uintptr_t MyRand() {
+static uintptr_t MyRand() {
   static uintptr_t s = 0;
   s = s * 1103515245 + 12345;
   return s;
 }
 
 // Keep this in sync with Params in bench.rs.
 struct Params {
   const char* mConfigName;
@@ -77,17 +77,18 @@ struct Params {
   size_t mNumIterations;         // Iterates the full table each time
   bool mRemoveInserts;           // Remove all entries at end?
 };
 
 // We don't use std::unordered_{set,map}, but it's an interesting thing to
 // benchmark against.
 //
 // Keep this in sync with all the other Bench_*() functions.
-void Bench_Cpp_unordered_set(const Params* aParams, void** aVals, size_t aLen) {
+static void Bench_Cpp_unordered_set(const Params* aParams, void** aVals,
+                                    size_t aLen) {
   std::unordered_set<void*> hs;
 
   for (size_t j = 0; j < aParams->mNumInserts; j++) {
     hs.insert(aVals[j]);
   }
 
   for (size_t i = 0; i < aParams->mNumSuccessfulLookups; i++) {
     for (size_t j = 0; j < aParams->mNumInserts; j++) {
@@ -117,17 +118,18 @@ void Bench_Cpp_unordered_set(const Param
     }
     MOZ_RELEASE_ASSERT(hs.size() == 0);
   } else {
     MOZ_RELEASE_ASSERT(hs.size() == aParams->mNumInserts);
   }
 }
 
 // Keep this in sync with all the other Bench_*() functions.
-void Bench_Cpp_PLDHashTable(const Params* aParams, void** aVals, size_t aLen) {
+static void Bench_Cpp_PLDHashTable(const Params* aParams, void** aVals,
+                                   size_t aLen) {
   PLDHashTable hs(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub));
 
   for (size_t j = 0; j < aParams->mNumInserts; j++) {
     auto entry = static_cast<PLDHashEntryStub*>(hs.Add(aVals[j]));
     MOZ_RELEASE_ASSERT(!entry->key);
     entry->key = aVals[j];
   }
 
@@ -158,17 +160,18 @@ void Bench_Cpp_PLDHashTable(const Params
     }
     MOZ_RELEASE_ASSERT(hs.EntryCount() == 0);
   } else {
     MOZ_RELEASE_ASSERT(hs.EntryCount() == aParams->mNumInserts);
   }
 }
 
 // Keep this in sync with all the other Bench_*() functions.
-void Bench_Cpp_MozHashSet(const Params* aParams, void** aVals, size_t aLen) {
+static void Bench_Cpp_MozHashSet(const Params* aParams, void** aVals,
+                                 size_t aLen) {
   mozilla::HashSet<void*, mozilla::DefaultHasher<void*>, MallocAllocPolicy> hs;
 
   for (size_t j = 0; j < aParams->mNumInserts; j++) {
     MOZ_RELEASE_ASSERT(hs.put(aVals[j]));
   }
 
   for (size_t i = 0; i < aParams->mNumSuccessfulLookups; i++) {
     for (size_t j = 0; j < aParams->mNumInserts; j++) {
--- a/xpcom/tests/RegFactory.cpp
+++ b/xpcom/tests/RegFactory.cpp
@@ -96,17 +96,17 @@ int ProcessArgs(nsIComponentRegistrar *r
   return 0;
 }
 
 int main(int argc, char *argv[]) {
   int ret = 0;
   nsresult rv;
   {
     nsCOMPtr<nsIServiceManager> servMan;
-    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
+    rv = NS_InitXPCOM(getter_AddRefs(servMan), nullptr, nullptr);
     if (NS_FAILED(rv)) return -1;
     nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
     NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
 
     /* With no arguments, RegFactory will autoregister */
     if (argc <= 1) {
       rv = registrar->AutoRegister(nullptr);
       ret = (NS_FAILED(rv)) ? -1 : 0;
--- a/xpcom/tests/TestHarness.h
+++ b/xpcom/tests/TestHarness.h
@@ -77,19 +77,19 @@ class ScopedXPCOM : public nsIDirectoryS
   NS_DECL_ISUPPORTS
 
   explicit ScopedXPCOM(const char* testName,
                        nsIDirectoryServiceProvider* dirSvcProvider = nullptr)
       : mServMgr(nullptr), mDirSvcProvider(dirSvcProvider) {
     mTestName = testName;
     printf("Running %s tests...\n", mTestName);
 
-    nsresult rv = NS_InitXPCOM2(&mServMgr, nullptr, this);
+    nsresult rv = NS_InitXPCOM(&mServMgr, nullptr, this);
     if (NS_FAILED(rv)) {
-      fail("NS_InitXPCOM2 returned failure code 0x%" PRIx32,
+      fail("NS_InitXPCOM returned failure code 0x%" PRIx32,
            static_cast<uint32_t>(rv));
       mServMgr = nullptr;
       return;
     }
   }
 
   ~ScopedXPCOM() {
     // If we created a profile directory, we need to remove it.
--- a/xpcom/tests/TestShutdown.cpp
+++ b/xpcom/tests/TestShutdown.cpp
@@ -3,20 +3,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 "nsIServiceManager.h"
 
 // Gee this seems simple! It's for testing for memory leaks with Purify.
 
 void main(int argc, char* argv[]) {
-  nsresult rv;
   nsIServiceManager* servMgr;
-  rv = NS_InitXPCOM2(&servMgr, nullptr, nullptr);
-  NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
+  nsresult rv = NS_InitXPCOM(&servMgr, nullptr, nullptr);
+  MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
 
   // try loading a component and releasing it to see if it leaks
   if (argc > 1 && argv[1] != nullptr) {
     char* cidStr = argv[1];
     nsISupports* obj = nullptr;
     if (cidStr[0] == '{') {
       nsCID cid;
       cid.Parse(cidStr);
@@ -29,10 +28,10 @@ void main(int argc, char* argv[]) {
       printf("Successfully created %s\n", cidStr);
       NS_RELEASE(obj);
     } else {
       printf("Failed to create %s (%x)\n", cidStr, rv);
     }
   }
 
   rv = NS_ShutdownXPCOM(servMgr);
-  NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
+  MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
 }
--- a/xpcom/tests/TestStreamUtils.cpp
+++ b/xpcom/tests/TestStreamUtils.cpp
@@ -46,17 +46,17 @@ static const struct Test {
   const char* name;
   TestFunc func;
 } tests[] = {DECL_TEST(test_consume_stream), {nullptr, nullptr}};
 
 int main(int argc, char** argv) {
   int count = 1;
   if (argc > 1) count = atoi(argv[1]);
 
-  if (NS_FAILED(NS_InitXPCOM2(nullptr, nullptr, nullptr))) return -1;
+  if (NS_FAILED(NS_InitXPCOM(nullptr, nullptr, nullptr))) return -1;
 
   while (count--) {
     for (const Test* t = tests; t->name != nullptr; ++t) {
       printf("%25s : %s\n", t->name, t->func() ? "SUCCESS" : "FAILURE");
     }
   }
 
   NS_ShutdownXPCOM(nullptr);
--- a/xpcom/tests/gtest/TestAtoms.cpp
+++ b/xpcom/tests/gtest/TestAtoms.cpp
@@ -106,17 +106,17 @@ TEST(Atoms, Invalid) {
   }
 #endif
 }
 
 #define FIRST_ATOM_STR "first static atom. Hello!"
 #define SECOND_ATOM_STR "second static atom. @World!"
 #define THIRD_ATOM_STR "third static atom?!"
 
-bool isStaticAtom(nsAtom* atom) {
+static bool isStaticAtom(nsAtom* atom) {
   // Don't use logic && in order to ensure that all addrefs/releases are always
   // run, even if one of the tests fail. This allows us to run this code on a
   // non-static atom without affecting its refcount.
   bool rv = (atom->AddRef() == 2);
   rv &= (atom->AddRef() == 2);
   rv &= (atom->AddRef() == 2);
 
   rv &= (atom->Release() == 1);
--- a/xpcom/tests/gtest/TestCOMPtr.cpp
+++ b/xpcom/tests/gtest/TestCOMPtr.cpp
@@ -79,35 +79,35 @@ nsresult IFoo::QueryInterface(const nsII
   }
 
   NS_IF_ADDREF(rawPtr);
   *aResult = rawPtr;
 
   return status;
 }
 
-nsresult CreateIFoo(void** result)
+static nsresult CreateIFoo(void** result)
 // a typical factory function (that calls AddRef)
 {
   auto* foop = new IFoo;
 
   foop->AddRef();
   *result = foop;
 
   return NS_OK;
 }
 
-void set_a_IFoo(nsCOMPtr<IFoo>* result) {
+static void set_a_IFoo(nsCOMPtr<IFoo>* result) {
   // Various places in this file do a static_cast to nsISupports* in order to
   // make the QI non-trivial, to avoid hitting a static assert.
   nsCOMPtr<IFoo> foop(do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
   *result = foop;
 }
 
-nsCOMPtr<IFoo> return_a_IFoo() {
+static nsCOMPtr<IFoo> return_a_IFoo() {
   nsCOMPtr<IFoo> foop(do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
   return foop;
 }
 
 #define NS_IBAR_IID                                  \
   {                                                  \
     0x6f7652e1, 0xee43, 0x11d1, {                    \
       0x9c, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 \
@@ -156,32 +156,32 @@ nsresult IBar::QueryInterface(const nsID
   }
 
   NS_IF_ADDREF(rawPtr);
   *aResult = rawPtr;
 
   return status;
 }
 
-nsresult CreateIBar(void** result)
+static nsresult CreateIBar(void** result)
 // a typical factory function (that calls AddRef)
 {
   auto* barp = new IBar;
 
   barp->AddRef();
   *result = barp;
 
   return NS_OK;
 }
 
-void AnIFooPtrPtrContext(IFoo**) {}
+static void AnIFooPtrPtrContext(IFoo**) {}
 
-void AVoidPtrPtrContext(void**) {}
+static void AVoidPtrPtrContext(void**) {}
 
-void AnISupportsPtrPtrContext(nsISupports**) {}
+static void AnISupportsPtrPtrContext(nsISupports**) {}
 
 }  // namespace TestCOMPtr
 
 using namespace TestCOMPtr;
 
 TEST(COMPtr, Bloat_Raw_Unsafe) {
   // ER: I'm not sure what this is testing...
   IBar* barP = 0;
@@ -255,17 +255,17 @@ TEST(COMPtr, AddRefAndRelease) {
   {
     nsCOMPtr<IFoo> foop(do_QueryInterface(static_cast<nsISupports*>(new IBar)));
     mozilla::Unused << foop;
   }
 
   ASSERT_EQ(IBar::total_destructions_, 1);
 }
 
-void Comparison() {
+TEST(COMPtr, Comparison) {
   IFoo::total_constructions_ = 0;
   IFoo::total_destructions_ = 0;
 
   {
     nsCOMPtr<IFoo> foo1p(
         do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
     nsCOMPtr<IFoo> foo2p(
         do_QueryInterface(static_cast<nsISupports*>(new IFoo)));
@@ -290,17 +290,17 @@ void Comparison() {
 
     ASSERT_EQ(foo1p->refcount_, (unsigned int)2);
     ASSERT_EQ(foo2p->refcount_, (unsigned int)2);
   }
 
   ASSERT_EQ(IFoo::total_destructions_, 2);
 }
 
-void DontAddRef() {
+TEST(COMPtr, DontAddRef) {
   {
     auto* raw_foo1p = new IFoo;
     raw_foo1p->AddRef();
 
     auto* raw_foo2p = new IFoo;
     raw_foo2p->AddRef();
 
     nsCOMPtr<IFoo> foo1p(dont_AddRef(raw_foo1p));
--- a/xpcom/tests/gtest/TestCRT.cpp
+++ b/xpcom/tests/gtest/TestCRT.cpp
@@ -9,17 +9,17 @@
 #include "plstr.h"
 #include <stdlib.h>
 #include "gtest/gtest.h"
 
 namespace TestCRT {
 
 // The return from strcmp etc is only defined to be postive, zero or
 // negative. The magnitude of a non-zero return is irrelevant.
-int sign(int val) {
+static int sign(int val) {
   if (val == 0) {
     return 0;
   } else {
     if (val > 0) {
       return 1;
     } else {
       return -1;
     }
--- a/xpcom/tests/gtest/TestCallTemplates.cpp
+++ b/xpcom/tests/gtest/TestCallTemplates.cpp
@@ -64,17 +64,17 @@ NS_IMPL_ISUPPORTS(nsTestService, nsITest
 #define NS_TEST_SERVICE_CID                          \
   {                                                  \
     0xa00c1406, 0x283a, 0x45c9, {                    \
       0xae, 0xd2, 0x1a, 0xb6, 0xdd, 0xba, 0xfe, 0x53 \
     }                                                \
   }
 static NS_DEFINE_CID(kTestServiceCID, NS_TEST_SERVICE_CID);
 
-void JustTestingCompilation() {
+inline void JustTestingCompilation() {
   /*
    * NOTE:  This does NOT demonstrate how these functions are
    * intended to be used.  They are intended for filling in out
    * parameters that need to be |AddRef|ed.  I'm just too lazy
    * to write lots of little getter functions for a test program
    * when I don't need to.
    */
 
--- a/xpcom/tests/gtest/TestDeadlockDetector.cpp
+++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp
@@ -54,29 +54,29 @@ class TESTNAME(DeadlockDetectorTest) : p
   }
 
   void TearDown() final { ::_gdb_sleep_duration = mOldSleepDuration; }
 
  private:
   unsigned int mOldSleepDuration;
 };
 
-void DisableCrashReporter() {
+static void DisableCrashReporter() {
   nsCOMPtr<nsICrashReporter> crashreporter =
       do_GetService("@mozilla.org/toolkit/crash-reporter;1");
   if (crashreporter) {
     crashreporter->SetEnabled(false);
   }
 }
 
 //-----------------------------------------------------------------------------
 // Single-threaded sanity tests
 
 // Stupidest possible deadlock.
-int Sanity_Child() {
+static int Sanity_Child() {
   DisableCrashReporter();
 
   MUTEX m1("dd.sanity.m1");
   m1.Lock();
   m1.Lock();
   return 0;  // not reached
 }
 
@@ -87,17 +87,17 @@ TEST_F(TESTNAME(DeadlockDetectorTest), T
       "=== Cycle completed at.*--- Mutex : dd.sanity.m1.*"
       "###!!! Deadlock may happen NOW!.*"  // better catch these easy cases...
       "###!!! ASSERTION: Potential deadlock detected.*";
 
   ASSERT_DEATH_IF_SUPPORTED(Sanity_Child(), regex);
 }
 
 // Slightly less stupid deadlock.
-int Sanity2_Child() {
+static int Sanity2_Child() {
   DisableCrashReporter();
 
   MUTEX m1("dd.sanity2.m1");
   MUTEX m2("dd.sanity2.m2");
   m1.Lock();
   m2.Lock();
   m1.Lock();
   return 0;  // not reached
@@ -151,17 +151,17 @@ TEST_F(TESTNAME(DeadlockDetectorTest), T
         "--- Next dependency:.*--- Mutex : dd.sanity3.m4.*"
         "=== Cycle completed at.*--- Mutex : dd.sanity3.m1.*"
         "###!!! ASSERTION: Potential deadlock detected.*";
 
     ASSERT_DEATH_IF_SUPPORTED(Sanity3_Child(), regex);
 }
 #endif
 
-int Sanity4_Child() {
+static int Sanity4_Child() {
   DisableCrashReporter();
 
   mozilla::ReentrantMonitor m1("dd.sanity4.m1");
   MUTEX m2("dd.sanity4.m2");
   m1.Enter();
   m2.Lock();
   m1.Enter();
   return 0;
@@ -174,17 +174,17 @@ TEST_F(TESTNAME(DeadlockDetectorTest), T
       "=== Cyclical dependency starts at.*--- ReentrantMonitor : "
       "dd.sanity4.m1.*"
       "--- Next dependency:.*--- Mutex : dd.sanity4.m2.*"
       "=== Cycle completed at.*--- ReentrantMonitor : dd.sanity4.m1.*"
       "###!!! ASSERTION: Potential deadlock detected.*";
   ASSERT_DEATH_IF_SUPPORTED(Sanity4_Child(), regex);
 }
 
-int Sanity5_Child() {
+static int Sanity5_Child() {
   DisableCrashReporter();
 
   mozilla::RecursiveMutex m1("dd.sanity4.m1");
   MUTEX m2("dd.sanity4.m2");
   m1.Lock();
   m2.Lock();
   m1.Lock();
   return 0;
@@ -295,17 +295,17 @@ static void ContentionNoDeadlock_thread(
     for (int32_t i = starti; i < (int32_t)cndMs.Length(); ++i) cndMs[i]->Lock();
     // comment out the next two lines for deadlocking fun!
     for (int32_t i = cndMs.Length() - 1; i >= starti; --i) cndMs[i]->Unlock();
 
     starti = (starti + 1) % 3;
   }
 }
 
-int ContentionNoDeadlock_Child() {
+static int ContentionNoDeadlock_Child() {
   const size_t kMutexCount = 4;
 
   PRThread* threads[3];
   nsTArray<MUTEX*> locks;
   ThreadState states[] = {{locks, 0}, {locks, 1}, {locks, 2}};
 
   for (uint32_t i = 0; i < kMutexCount; ++i)
     locks.AppendElement(new MUTEX("dd.cnd.ms"));
--- a/xpcom/tests/gtest/TestHashtables.cpp
+++ b/xpcom/tests/gtest/TestHashtables.cpp
@@ -32,17 +32,17 @@ class TestUniChar  // for nsClassHashtab
   uint32_t mWord;
 };
 
 struct EntityNode {
   const char* mStr;  // never owns buffer
   uint32_t mUnicode;
 };
 
-EntityNode gEntities[] = {
+static const EntityNode gEntities[] = {
     {"nbsp", 160},   {"iexcl", 161}, {"cent", 162},   {"pound", 163},
     {"curren", 164}, {"yen", 165},   {"brvbar", 166}, {"sect", 167},
     {"uml", 168},    {"copy", 169},  {"ordf", 170},   {"laquo", 171},
     {"not", 172},    {"shy", 173},   {"reg", 174},    {"macr", 175}};
 
 #define ENTITY_COUNT (unsigned(sizeof(gEntities) / sizeof(EntityNode)))
 
 class EntityToUnicodeEntry : public PLDHashEntryHdr {
@@ -80,18 +80,18 @@ static uint32_t nsTIterPrintRemove(nsTHa
   uint32_t n = 0;
   for (auto iter = hash.Iter(); !iter.Done(); iter.Next()) {
     iter.Remove();
     n++;
   }
   return n;
 }
 
-void testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash,
-                    uint32_t numEntries) {
+static void testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash,
+                           uint32_t numEntries) {
   uint32_t i;
   for (i = 0; i < numEntries; ++i) {
     EntityToUnicodeEntry* entry = hash.PutEntry(gEntities[i].mStr);
 
     EXPECT_TRUE(entry);
 
     EXPECT_FALSE(entry->mNode);
     entry->mNode = &gEntities[i];
@@ -197,17 +197,17 @@ nsresult IFoo::SetString(const nsACStrin
   return NS_OK;
 }
 
 nsresult IFoo::GetString(nsACString& aString) {
   aString = mString;
   return NS_OK;
 }
 
-nsresult CreateIFoo(IFoo** result)
+static nsresult CreateIFoo(IFoo** result)
 // a typical factory function (that calls AddRef)
 {
   auto* foop = new IFoo();
 
   foop->AddRef();
   *result = foop;
 
   return NS_OK;
--- a/xpcom/tests/gtest/TestMoveString.cpp
+++ b/xpcom/tests/gtest/TestMoveString.cpp
@@ -17,32 +17,32 @@
 
 namespace TestMoveString {
 
 #define NEW_VAL "**new value**"
 #define OLD_VAL "old value"
 
 typedef mozilla::detail::StringDataFlags Df;
 
-void SetAsOwned(nsACString& aStr, const char* aValue) {
+static void SetAsOwned(nsACString& aStr, const char* aValue) {
   size_t len = strlen(aValue);
   char* data = new char[len + 1];
   memcpy(data, aValue, len + 1);
   aStr.Adopt(data, len);
   EXPECT_EQ(aStr.GetDataFlags(), Df::OWNED | Df::TERMINATED);
   EXPECT_STREQ(aStr.BeginReading(), aValue);
 }
 
-void ExpectTruncated(const nsACString& aStr) {
+static void ExpectTruncated(const nsACString& aStr) {
   EXPECT_EQ(aStr.Length(), uint32_t(0));
   EXPECT_STREQ(aStr.BeginReading(), "");
   EXPECT_EQ(aStr.GetDataFlags(), Df::TERMINATED);
 }
 
-void ExpectNew(const nsACString& aStr) {
+static void ExpectNew(const nsACString& aStr) {
   EXPECT_EQ(aStr.Length(), strlen(NEW_VAL));
   EXPECT_TRUE(aStr.EqualsASCII(NEW_VAL));
 }
 
 TEST(MoveString, SharedIntoOwned) {
   nsCString out;
   SetAsOwned(out, OLD_VAL);
   EXPECT_EQ(out.GetDataFlags(), Df::OWNED | Df::TERMINATED);
--- a/xpcom/tests/gtest/TestMruCache.cpp
+++ b/xpcom/tests/gtest/TestMruCache.cpp
@@ -44,17 +44,17 @@ struct StringStructMap
 // Helper for emulating convertable holders such as RefPtr.
 template <typename T>
 struct Convertable {
   T mItem;
   operator T() const { return mItem; }
 };
 
 // Helper to create a StringStructMap key.
-nsCString MakeStringKey(char aKey) {
+static nsCString MakeStringKey(char aKey) {
   nsCString key;
   key.Append(aKey);
   return key;
 }
 
 TEST(MruCache, TestNullChecker) {
   using mozilla::detail::EmptyChecker;
 
--- a/xpcom/tests/gtest/TestMultiplexInputStream.cpp
+++ b/xpcom/tests/gtest/TestMultiplexInputStream.cpp
@@ -98,17 +98,17 @@ TEST(MultiplexInputStream, Seek_SET) {
   ASSERT_TRUE(NS_SUCCEEDED(rv));
   ASSERT_EQ((uint64_t)6, count);
   rv = stream->Available(&length);
   ASSERT_TRUE(NS_SUCCEEDED(rv));
   ASSERT_EQ((uint64_t)buf2.Length() - 6 + buf3.Length(), length);
   ASSERT_EQ(0, strncmp(readBuf, "The qu", count));
 }
 
-already_AddRefed<nsIInputStream> CreateStreamHelper() {
+static already_AddRefed<nsIInputStream> CreateStreamHelper() {
   nsCOMPtr<nsIMultiplexInputStream> multiplexStream =
       do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1");
 
   nsCString buf1;
   buf1.AssignLiteral("Hello");
 
   nsCOMPtr<nsIInputStream> inputStream1 = new testing::AsyncStringStream(buf1);
   multiplexStream->AppendStream(inputStream1);
--- a/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
+++ b/xpcom/tests/gtest/TestNonBlockingAsyncInputStream.cpp
@@ -54,19 +54,19 @@ class ReadSegmentsData {
  public:
   ReadSegmentsData(nsIInputStream* aStream, char* aBuffer)
       : mStream(aStream), mBuffer(aBuffer) {}
 
   nsIInputStream* mStream;
   char* mBuffer;
 };
 
-nsresult ReadSegmentsFunction(nsIInputStream* aInStr, void* aClosure,
-                              const char* aBuffer, uint32_t aOffset,
-                              uint32_t aCount, uint32_t* aCountWritten) {
+static nsresult ReadSegmentsFunction(nsIInputStream* aInStr, void* aClosure,
+                                     const char* aBuffer, uint32_t aOffset,
+                                     uint32_t aCount, uint32_t* aCountWritten) {
   ReadSegmentsData* data = static_cast<ReadSegmentsData*>(aClosure);
   if (aInStr != data->mStream) return NS_ERROR_FAILURE;
   memcpy(&data->mBuffer[aOffset], aBuffer, aCount);
   *aCountWritten = aCount;
   return NS_OK;
 }
 
 TEST(TestNonBlockingAsyncInputStream, ReadSegments) {
--- a/xpcom/tests/gtest/TestNsDeque.cpp
+++ b/xpcom/tests/gtest/TestNsDeque.cpp
@@ -232,17 +232,17 @@ TEST(NsDeque, TestPushFront) {
   d.PushFront(pool + kMaxSizeBeforeGrowth + 1);
   EXPECT_EQ(kMaxSizeBeforeGrowth + 2, d.GetSize()) << "verify size";
 
   static const int t3[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
   EXPECT_TRUE(VerifyContents(d, t3, kMaxSizeBeforeGrowth + 2))
       << "verify pushfront 3";
 }
 
-void CheckIfQueueEmpty(nsDeque& d) {
+static void CheckIfQueueEmpty(nsDeque& d) {
   EXPECT_EQ(0u, d.GetSize()) << "Size should be 0";
   EXPECT_EQ(nullptr, d.Pop()) << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.PopFront()) << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.Peek()) << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.PeekFront())
       << "Invalid operation should return nullptr";
   EXPECT_EQ(nullptr, d.ObjectAt(0u))
       << "Invalid operation should return nullptr";
--- a/xpcom/tests/gtest/TestNsRefPtr.cpp
+++ b/xpcom/tests/gtest/TestNsRefPtr.cpp
@@ -97,35 +97,35 @@ nsresult Foo::QueryInterface(const nsIID
 
 void Foo::MemberFunction(int aArg1, int* aArgPtr, int& aArgRef) {}
 
 void Foo::VirtualMemberFunction(int aArg1, int* aArgPtr, int& aArgRef) {}
 
 void Foo::VirtualConstMemberFunction(int aArg1, int* aArgPtr,
                                      int& aArgRef) const {}
 
-nsresult CreateFoo(void** result)
+static nsresult CreateFoo(void** result)
 // a typical factory function (that calls AddRef)
 {
   auto* foop = new Foo;
 
   foop->AddRef();
   *result = foop;
 
   return NS_OK;
 }
 
-void set_a_Foo(RefPtr<Foo>* result) {
+static void set_a_Foo(RefPtr<Foo>* result) {
   assert(result);
 
   RefPtr<Foo> foop(do_QueryObject(new Foo));
   *result = foop;
 }
 
-RefPtr<Foo> return_a_Foo() {
+static RefPtr<Foo> return_a_Foo() {
   RefPtr<Foo> foop(do_QueryObject(new Foo));
   return foop;
 }
 
 #define NS_BAR_IID                                   \
   {                                                  \
     0x6f7652e1, 0xee43, 0x11d1, {                    \
       0x9c, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 \
@@ -383,18 +383,18 @@ class ObjectForConstPtr {
 
  public:
   NS_INLINE_DECL_THREADSAFE_MUTABLE_REFCOUNTING(ObjectForConstPtr)
   void ConstMemberFunction(int aArg1, int* aArgPtr, int& aArgRef) const {}
 };
 #undef NS_INLINE_DECL_THREADSAFE_MUTABLE_REFCOUNTING
 
 namespace TestNsRefPtr {
-void AnFooPtrPtrContext(Foo**) {}
-void AVoidPtrPtrContext(void**) {}
+static void AnFooPtrPtrContext(Foo**) {}
+static void AVoidPtrPtrContext(void**) {}
 }  // namespace TestNsRefPtr
 
 TEST(nsRefPtr, RefPtrCompilationTests) {
   {
     RefPtr<Foo> fooP;
 
     AnFooPtrPtrContext(getter_AddRefs(fooP));
     AVoidPtrPtrContext(getter_AddRefs(fooP));
--- a/xpcom/tests/gtest/TestPLDHash.cpp
+++ b/xpcom/tests/gtest/TestPLDHash.cpp
@@ -25,17 +25,17 @@ extern unsigned int _gdb_sleep_duration;
 // 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.
-void TestCrashyOperation(void (*aCrashyOperation)()) {
+static void TestCrashyOperation(void (*aCrashyOperation)()) {
 #if defined(XP_UNIX) && defined(DEBUG) && !defined(MOZ_ASAN)
   // We're about to trigger a crash. When it happens don't pause to allow GDB
   // to be attached.
   unsigned int old_gdb_sleep_duration = _gdb_sleep_duration;
   _gdb_sleep_duration = 0;
 
   int pid = fork();
   ASSERT_NE(pid, -1);
@@ -82,29 +82,29 @@ void TestCrashyOperation(void (*aCrashyO
       ASSERT_TRUE(false);
     }
   }
 
   _gdb_sleep_duration = old_gdb_sleep_duration;
 #endif
 }
 
-void InitCapacityOk_InitialLengthTooBig() {
+static void InitCapacityOk_InitialLengthTooBig() {
   PLDHashTable t(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub),
                  PLDHashTable::kMaxInitialLength + 1);
 }
 
-void InitCapacityOk_InitialEntryStoreTooBig() {
+static void InitCapacityOk_InitialEntryStoreTooBig() {
   // Try the smallest disallowed power-of-two entry store size, which is 2^32
   // bytes (which overflows to 0). (Note that the 2^23 *length* gets converted
   // to a 2^24 *capacity*.)
   PLDHashTable t(PLDHashTable::StubOps(), (uint32_t)1 << 8, (uint32_t)1 << 23);
 }
 
-void InitCapacityOk_EntrySizeTooBig() {
+static void InitCapacityOk_EntrySizeTooBig() {
   // Try the smallest disallowed entry size, which is 256 bytes.
   PLDHashTable t(PLDHashTable::StubOps(), 256);
 }
 
 TEST(PLDHashTableTest, InitCapacityOk) {
   // Try the largest allowed capacity.  With kMaxCapacity==1<<26, this
   // would allocate (if we added an element) 0.5GB of entry store on 32-bit
   // platforms and 1GB on 64-bit platforms.
--- a/xpcom/tests/gtest/TestPipes.cpp
+++ b/xpcom/tests/gtest/TestPipes.cpp
@@ -90,17 +90,17 @@ class nsReceiver final : public nsIRunna
 
  protected:
   nsCOMPtr<nsIInputStream> mIn;
   uint32_t mCount;
 };
 
 NS_IMPL_ISUPPORTS(nsReceiver, nsIRunnable)
 
-nsresult TestPipe(nsIInputStream* in, nsIOutputStream* out) {
+static nsresult TestPipe(nsIInputStream* in, nsIOutputStream* out) {
   RefPtr<nsReceiver> receiver = new nsReceiver(in);
   if (!receiver) return NS_ERROR_OUT_OF_MEMORY;
 
   nsresult rv;
 
   nsCOMPtr<nsIThread> thread;
   rv = NS_NewNamedThread("TestPipe", getter_AddRefs(thread), receiver);
   if (NS_FAILED(rv)) return rv;
@@ -204,17 +204,17 @@ class nsShortReader final : public nsIRu
  protected:
   nsCOMPtr<nsIInputStream> mIn;
   uint32_t mReceived;
   ReentrantMonitor* mMon;
 };
 
 NS_IMPL_ISUPPORTS(nsShortReader, nsIRunnable)
 
-nsresult TestShortWrites(nsIInputStream* in, nsIOutputStream* out) {
+static nsresult TestShortWrites(nsIInputStream* in, nsIOutputStream* out) {
   RefPtr<nsShortReader> receiver = new nsShortReader(in);
   if (!receiver) return NS_ERROR_OUT_OF_MEMORY;
 
   nsresult rv;
 
   nsCOMPtr<nsIThread> thread;
   rv = NS_NewNamedThread("TestShortWrites", getter_AddRefs(thread), receiver);
   if (NS_FAILED(rv)) return rv;
@@ -346,17 +346,17 @@ TEST(Pipes, ChainedPipes) {
   if (NS_FAILED(rv)) return;
 
   thread->Shutdown();
   receiverThread->Shutdown();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-void RunTests(uint32_t segSize, uint32_t segCount) {
+static void RunTests(uint32_t segSize, uint32_t segCount) {
   nsresult rv;
   nsCOMPtr<nsIInputStream> in;
   nsCOMPtr<nsIOutputStream> out;
   uint32_t bufSize = segSize * segCount;
   if (gTrace) {
     printf("Testing New Pipes: segment size %d buffer size %d\n", segSize,
            bufSize);
     printf("Testing long writes...\n");
--- a/xpcom/tests/gtest/TestSlicedInputStream.cpp
+++ b/xpcom/tests/gtest/TestSlicedInputStream.cpp
@@ -103,33 +103,35 @@ class NonSeekableStringStream final : pu
 
  private:
   ~NonSeekableStringStream() {}
 };
 
 NS_IMPL_ISUPPORTS(NonSeekableStringStream, nsIInputStream, nsIAsyncInputStream)
 
 // Helper function for creating a seekable nsIInputStream + a SlicedInputStream.
-SlicedInputStream* CreateSeekableStreams(uint32_t aSize, uint64_t aStart,
-                                         uint64_t aLength, nsCString& aBuffer) {
+static SlicedInputStream* CreateSeekableStreams(uint32_t aSize, uint64_t aStart,
+                                                uint64_t aLength,
+                                                nsCString& aBuffer) {
   aBuffer.SetLength(aSize);
   for (uint32_t i = 0; i < aSize; ++i) {
     aBuffer.BeginWriting()[i] = i % 10;
   }
 
   nsCOMPtr<nsIInputStream> stream;
   NS_NewCStringInputStream(getter_AddRefs(stream), aBuffer);
   return new SlicedInputStream(stream.forget(), aStart, aLength);
 }
 
 // Helper function for creating a non-seekable nsIInputStream + a
 // SlicedInputStream.
-SlicedInputStream* CreateNonSeekableStreams(uint32_t aSize, uint64_t aStart,
-                                            uint64_t aLength,
-                                            nsCString& aBuffer) {
+static SlicedInputStream* CreateNonSeekableStreams(uint32_t aSize,
+                                                   uint64_t aStart,
+                                                   uint64_t aLength,
+                                                   nsCString& aBuffer) {
   aBuffer.SetLength(aSize);
   for (uint32_t i = 0; i < aSize; ++i) {
     aBuffer.BeginWriting()[i] = i % 10;
   }
 
   RefPtr<NonSeekableStringStream> stream = new NonSeekableStringStream(aBuffer);
   return new SlicedInputStream(stream.forget(), aStart, aLength);
 }
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -463,17 +463,17 @@ class Strings : public ::testing::Test {
   nsCString mRuThousandUtf8;
   nsCString mThThousandUtf8;
   nsCString mJaThousandUtf8;
   nsCString mKoThousandUtf8;
   nsCString mTrThousandUtf8;
   nsCString mViThousandUtf8;
 };
 
-void test_assign_helper(const nsACString& in, nsACString& _retval) {
+static void test_assign_helper(const nsACString& in, nsACString& _retval) {
   _retval = in;
 }
 
 // Simple helper struct to test if conditionally enabled string functions are
 // working.
 template <typename T>
 struct EnableTest {
   template <typename Q = T, typename EnableIfChar16 = mozilla::Char16OnlyT<Q>>
--- a/xpcom/tests/gtest/TestTArray.cpp
+++ b/xpcom/tests/gtest/TestTArray.cpp
@@ -52,29 +52,29 @@ struct nsTArray_CopyChooser<TestTArray::
 
 template <>
 struct nsTArray_CopyChooser<TestTArray::Movable> {
   typedef nsTArray_CopyWithConstructors<TestTArray::Movable> Type;
 };
 
 namespace TestTArray {
 
-const nsTArray<int>& DummyArray() {
+static const nsTArray<int>& DummyArray() {
   static nsTArray<int> sArray;
   if (sArray.IsEmpty()) {
     const int data[] = {4, 1, 2, 8};
     sArray.AppendElements(data, ArrayLength(data));
   }
   return sArray;
 }
 
 // This returns an invalid nsTArray with a huge length in order to test that
 // fallible operations actually fail.
 #ifdef DEBUG
-const nsTArray<int>& FakeHugeArray() {
+static const nsTArray<int>& FakeHugeArray() {
   static nsTArray<int> sArray;
   if (sArray.IsEmpty()) {
     sArray.AppendElement();
     ((nsTArrayHeader*)sArray.DebugGetHeader())->mLength = UINT32_MAX;
   }
   return sArray;
 }
 #endif
--- a/xpcom/tests/gtest/TestThrottledEventQueue.cpp
+++ b/xpcom/tests/gtest/TestThrottledEventQueue.cpp
@@ -88,17 +88,17 @@ struct RunnableQueue : nsISerialEventTar
   NS_DECL_THREADSAFE_ISUPPORTS
 
  private:
   virtual ~RunnableQueue() {}
 };
 
 NS_IMPL_ISUPPORTS(RunnableQueue, nsIEventTarget, nsISerialEventTarget)
 
-void Enqueue(nsIEventTarget* target, function<void()>&& aCallable) {
+static void Enqueue(nsIEventTarget* target, function<void()>&& aCallable) {
   nsresult rv =
       target->Dispatch(NS_NewRunnableFunction("TEQ GTest", move(aCallable)));
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv));
 }
 
 }  // namespace TestThrottledEventQueue
 
 using namespace TestThrottledEventQueue;
--- a/xpcom/tests/gtest/TestUTF.cpp
+++ b/xpcom/tests/gtest/TestUTF.cpp
@@ -111,17 +111,17 @@ TEST(UTF, Hash16) {
     EXPECT_TRUE(err);
   }
 }
 
 /**
  * This tests the handling of a non-ascii character at various locations in a
  * UTF-16 string that is being converted to UTF-8.
  */
-void NonASCII16_helper(const size_t aStrSize) {
+static void NonASCII16_helper(const size_t aStrSize) {
   const size_t kTestSize = aStrSize;
   const size_t kMaxASCII = 0x80;
   const char16_t kUTF16Char = 0xC9;
   const char kUTF8Surrogates[] = {char(0xC3), char(0x89)};
 
   // Generate a string containing only ASCII characters.
   nsString asciiString;
   asciiString.SetLength(kTestSize);
@@ -149,29 +149,38 @@ void NonASCII16_helper(const size_t aStr
     EXPECT_EQ(dest.Length(), unicodeString.Length() + 1);
 
     // Build up the expected UTF-8 string.
     nsCString expected;
 
     // First add the leading ASCII chars.
     expected.Append(asciiCString.BeginReading(), i);
 
-    // Now append the UTF-8 surrogate pair we expect the UTF-16 unicode char to
+    // Now append the UTF-8 pair we expect the UTF-16 unicode char to
     // be converted to.
     for (auto& c : kUTF8Surrogates) {
       expected.Append(c);
     }
 
     // And finish with the trailing ASCII chars.
     expected.Append(asciiCString.BeginReading() + i + 1, kTestSize - i - 1);
 
     EXPECT_STREQ(dest.BeginReading(), expected.BeginReading());
   }
 }
 
+TEST(UTF, NonASCII16) {
+  // Test with various string sizes to catch any special casing.
+  NonASCII16_helper(1);
+  NonASCII16_helper(8);
+  NonASCII16_helper(16);
+  NonASCII16_helper(32);
+  NonASCII16_helper(512);
+}
+
 TEST(UTF, UTF8CharEnumerator) {
   const char* p =
       "\x61\xC0\xC2\xC2\x80\xE0\x80\x80\xE0\xA0\x80\xE1\x80\x80\xED\xBF\xBF\xED"
       "\x9F\xBF\xEE\x80\x80\xEE\x80\xFF\xF0\x90\x80\x80\xF0\x80\x80\x80\xF1\x80"
       "\x80\x80\xF4\x8F\xBF\xF4\x8F\xBF\xBF\xF4\xBF\xBF\xBF";
   const char* end = p + 49;
   EXPECT_EQ(UTF8CharEnumerator::NextChar(&p, end), 0x0061U);
   EXPECT_EQ(UTF8CharEnumerator::NextChar(&p, end), 0xFFFDU);
--- a/xpcom/tests/windows/TestHelloXPLoop.cpp
+++ b/xpcom/tests/windows/TestHelloXPLoop.cpp
@@ -27,17 +27,17 @@ int WINAPI WinMain(HINSTANCE inst, HINST
   char* lpszAppName = "HelloWorld";
   HWND wnd;
   WNDCLASSEX wndclass;
   int retCode;
 
   {  //  Needed to scope all nsCOMPtr within XPCOM Init and Shutdown
     nsresult rv;
     nsCOMPtr<nsIServiceManager> servMan;
-    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
+    rv = NS_InitXPCOM(getter_AddRefs(servMan), nullptr, nullptr);
     if (NS_FAILED(rv)) {
       ErrorBox("Failed to initialize xpcom.");
       return -1;
     }
 
     nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
     NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
     registrar->AutoRegister(nullptr);
--- a/xpcom/threads/BlockingResourceBase.cpp
+++ b/xpcom/threads/BlockingResourceBase.cpp
@@ -78,17 +78,17 @@ void BlockingResourceBase::GetStackTrace
  * negative.
  *
  * *NOT* thread safe.  Calls |Print()|.
  *
  * FIXME bug 456272 hack alert: because we can't write call
  * contexts into strings, all info is written to stderr, but only
  * some info is written into |aOut|
  */
-bool PrintCycle(
+static bool PrintCycle(
     const BlockingResourceBase::DDT::ResourceAcquisitionArray* aCycle,
     nsACString& aOut) {
   NS_ASSERTION(aCycle->Length() > 1, "need > 1 element for cycle!");
 
   bool maybeImminent = true;
 
   fputs("=== Cyclical dependency starts at\n", stderr);
   aOut += "Cyclical dependency starts at\n";
--- a/xpcom/threads/CPUUsageWatcher.cpp
+++ b/xpcom/threads/CPUUsageWatcher.cpp
@@ -33,27 +33,28 @@ struct CPUStats {
 };
 
 #  ifdef XP_MACOSX
 
 static const uint64_t kMicrosecondsPerSecond = 1000000LL;
 static const uint64_t kNanosecondsPerMicrosecond = 1000LL;
 static const uint64_t kCPUCheckInterval = kMicrosecondsPerSecond / 2LL;
 
-uint64_t GetMicroseconds(timeval time) {
+static uint64_t GetMicroseconds(timeval time) {
   return ((uint64_t)time.tv_sec) * kMicrosecondsPerSecond +
          (uint64_t)time.tv_usec;
 }
 
-uint64_t GetMicroseconds(mach_timespec_t time) {
+static uint64_t GetMicroseconds(mach_timespec_t time) {
   return ((uint64_t)time.tv_sec) * kMicrosecondsPerSecond +
          ((uint64_t)time.tv_nsec) / kNanosecondsPerMicrosecond;
 }
 
-Result<CPUStats, CPUUsageWatcherError> GetProcessCPUStats(int32_t numCPUs) {
+static Result<CPUStats, CPUUsageWatcherError> GetProcessCPUStats(
+    int32_t numCPUs) {
   CPUStats result = {};
   rusage usage;
   int32_t rusageResult = getrusage(RUSAGE_SELF, &usage);
   if (rusageResult == -1) {
     return Err(GetProcessTimesError);
   }
   result.usageTime =
       GetMicroseconds(usage.ru_utime) + GetMicroseconds(usage.ru_stime);
@@ -72,17 +73,17 @@ Result<CPUStats, CPUUsageWatcherError> G
   result.updateTime = GetMicroseconds(time);
 
   // getrusage will give us the sum of the values across all
   // of our cores. Divide by the number of CPUs to get an average.
   result.usageTime /= numCPUs;
   return result;
 }
 
-Result<CPUStats, CPUUsageWatcherError> GetGlobalCPUStats() {
+static Result<CPUStats, CPUUsageWatcherError> GetGlobalCPUStats() {
   CPUStats result = {};
   host_cpu_load_info_data_t loadInfo;
   mach_msg_type_number_t loadInfoCount = HOST_CPU_LOAD_INFO_COUNT;
   kern_return_t statsResult =
       host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO,
                       (host_info_t)&loadInfo, &loadInfoCount);
   if (statsResult != KERN_SUCCESS) {
     return Err(HostStatisticsError);
--- a/xpcom/threads/ThreadDelay.cpp
+++ b/xpcom/threads/ThreadDelay.cpp
@@ -1,14 +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 "ThreadDelay.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/ChaosMode.h"
 
 #if defined(XP_WIN)
 #  include <windows.h>
 #else
 #  include <unistd.h>
 #endif
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -188,17 +188,17 @@ nsresult NS_NewTimerWithFuncCallback(nsI
 // This will show how often each unique line appears, with the most common ones
 // first.
 //
 // More detailed docs are here:
 // https://developer.mozilla.org/en-US/docs/Mozilla/Performance/TimerFirings_logging
 //
 static mozilla::LazyLogModule sTimerFiringsLog("TimerFirings");
 
-mozilla::LogModule* GetTimerFiringsLog() { return sTimerFiringsLog; }
+static mozilla::LogModule* GetTimerFiringsLog() { return sTimerFiringsLog; }
 
 #include <math.h>
 
 double nsTimerImpl::sDeltaSumSquared = 0;
 double nsTimerImpl::sDeltaSum = 0;
 double nsTimerImpl::sDeltaNum = 0;
 
 static void myNS_MeanAndStdDev(double n, double sumOfValues,