Merge m-c to fx-team a=merge
authorWes Kocher <wkocher@mozilla.com>
Mon, 05 Jan 2015 17:29:14 -0800
changeset 248054 77c0488fa25d712dfc3f0d1fb9161e07cf2a2693
parent 248053 121c15407fbdf9755828d1c9202cfa1882e40b9c (current diff)
parent 247915 2a193b7f395c8e6f3c21e83777ce2f540e4c04fe (diff)
child 248055 9477cb31bf80a66b74c27a3848891f1f13a4667f
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone37.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 m-c to fx-team a=merge
b2g/app/b2g.js
browser/app/profile/firefox.js
build/autoconf/gcc-pr39608.m4
mobile/android/app/mobile.js
mobile/android/chrome/content/browser.js
modules/libpref/init/all.js
xpcom/glue/tests/gtest/TestCRT.cpp
xpcom/glue/tests/gtest/TestEncoding.cpp
xpcom/glue/tests/gtest/TestExpirationTracker.cpp
xpcom/glue/tests/gtest/TestStrings.cpp
--- a/accessible/atk/Platform.cpp
+++ b/accessible/atk/Platform.cpp
@@ -13,16 +13,19 @@
 #include "AtkSocketAccessible.h"
 #include "prenv.h"
 #include "prlink.h"
 
 #ifdef MOZ_ENABLE_DBUS
 #include <dbus/dbus.h>
 #endif
 #include <gtk/gtk.h>
+#if (MOZ_WIDGET_GTK == 3)
+#include <atk-bridge.h>
+#endif
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 int atkMajorVersion = 1, atkMinorVersion = 12;
 
 extern "C" {
 typedef GType (* AtkGetTypeType) (void);
@@ -38,16 +41,17 @@ static const char sATKHyperlinkImplGetTy
 gboolean toplevel_event_watcher(GSignalInvocationHint*, guint, const GValue*,
                                 gpointer);
 static bool sToplevel_event_hook_added = false;
 static gulong sToplevel_show_hook = 0;
 static gulong sToplevel_hide_hook = 0;
 
 GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
 
+#if (MOZ_WIDGET_GTK == 2)
 struct GnomeAccessibilityModule
 {
     const char *libName;
     PRLibrary *lib;
     const char *initName;
     GnomeAccessibilityInit init;
     const char *shutdownName;
     GnomeAccessibilityShutdown shutdown;
@@ -114,16 +118,17 @@ LoadGtkModule(GnomeAccessibilityModule& 
 
         //fail, :(
         PR_UnloadLibrary(aModule.lib);
         aModule.lib = nullptr;
         return NS_ERROR_FAILURE;
     }
     return NS_OK;
 }
+#endif // (MOZ_WIDGET_GTK == 2)
 
 void
 a11y::PlatformInit()
 {
   if (!ShouldA11yBeEnabled())
     return;
 
   sATKLib = PR_LoadLibrary(sATKLibName);
@@ -153,30 +158,36 @@ a11y::PlatformInit()
     if (version) {
       char* endPtr = nullptr;
       atkMajorVersion = strtol(version, &endPtr, 10);
       if (*endPtr == '.')
         atkMinorVersion = strtol(endPtr + 1, &endPtr, 10);
     }
   }
 
+#if (MOZ_WIDGET_GTK == 2)
   // Load and initialize gail library.
   nsresult rv = LoadGtkModule(sGail);
   if (NS_SUCCEEDED(rv))
     (*sGail.init)();
+#endif
 
   // Initialize the MAI Utility class, it will overwrite gail_util.
   g_type_class_unref(g_type_class_ref(mai_util_get_type()));
 
   // Init atk-bridge now
   PR_SetEnv("NO_AT_BRIDGE=0");
+#if (MOZ_WIDGET_GTK == 2)
   rv = LoadGtkModule(sAtkBridge);
   if (NS_SUCCEEDED(rv)) {
     (*sAtkBridge.init)();
   }
+#else
+  atk_bridge_adaptor_init(nullptr, nullptr);
+#endif
 
   if (!sToplevel_event_hook_added) {
     sToplevel_event_hook_added = true;
     sToplevel_show_hook =
       g_signal_add_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
                                  0, toplevel_event_watcher,
                                  reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW),
                                  nullptr);
@@ -194,16 +205,17 @@ a11y::PlatformShutdown()
     if (sToplevel_event_hook_added) {
       sToplevel_event_hook_added = false;
       g_signal_remove_emission_hook(g_signal_lookup("show", GTK_TYPE_WINDOW),
                                     sToplevel_show_hook);
       g_signal_remove_emission_hook(g_signal_lookup("hide", GTK_TYPE_WINDOW),
                                     sToplevel_hide_hook);
     }
 
+#if (MOZ_WIDGET_GTK == 2)
     if (sAtkBridge.lib) {
         // Do not shutdown/unload atk-bridge,
         // an exit function registered will take care of it
         // if (sAtkBridge.shutdown)
         //     (*sAtkBridge.shutdown)();
         // PR_UnloadLibrary(sAtkBridge.lib);
         sAtkBridge.lib = nullptr;
         sAtkBridge.init = nullptr;
@@ -215,16 +227,17 @@ a11y::PlatformShutdown()
         // 2) We need it to avoid assert in spi_atk_tidy_windows
         // if (sGail.shutdown)
         //   (*sGail.shutdown)();
         // PR_UnloadLibrary(sGail.lib);
         sGail.lib = nullptr;
         sGail.init = nullptr;
         sGail.shutdown = nullptr;
     }
+#endif
     // if (sATKLib) {
     //     PR_UnloadLibrary(sATKLib);
     //     sATKLib = nullptr;
     // }
 }
 
   static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
 #ifdef MOZ_ENABLE_DBUS
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -15,17 +15,16 @@ builtin(include, build/autoconf/nss.m4)d
 builtin(include, build/autoconf/pkg.m4)dnl
 builtin(include, build/autoconf/codeset.m4)dnl
 builtin(include, build/autoconf/altoptions.m4)dnl
 builtin(include, build/autoconf/mozprog.m4)dnl
 builtin(include, build/autoconf/mozheader.m4)dnl
 builtin(include, build/autoconf/mozcommonheader.m4)dnl
 builtin(include, build/autoconf/lto.m4)dnl
 builtin(include, build/autoconf/gcc-pr49911.m4)dnl
-builtin(include, build/autoconf/gcc-pr39608.m4)dnl
 builtin(include, build/autoconf/llvm-pr8927.m4)dnl
 builtin(include, build/autoconf/frameptr.m4)dnl
 builtin(include, build/autoconf/compiler-opts.m4)dnl
 builtin(include, build/autoconf/expandlibs.m4)dnl
 builtin(include, build/autoconf/arch.m4)dnl
 builtin(include, build/autoconf/android.m4)dnl
 builtin(include, build/autoconf/zlib.m4)dnl
 builtin(include, build/autoconf/linux.m4)dnl
--- a/b2g/config/dolphin/sources.xml
+++ b/b2g/config/dolphin/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="e0c735ec89df011ea7dd435087a9045ecff9ff9e">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="a1e239a0bb5cd1d69680bf1075883aa9a7bf2429"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="c7931763d41be602407ed9d71e2c0292c6597e00"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="83760d213fb3bec7b4117d266fcfbf6fe2ba14ab"/>
   <project name="device/common" path="device/common" revision="6a2995683de147791e516aae2ccb31fdfbe2ad30"/>
--- a/b2g/config/emulator-ics/sources.xml
+++ b/b2g/config/emulator-ics/sources.xml
@@ -14,23 +14,23 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="df362ace56338da8173d30d3e09e08c42c1accfa">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="6fa7a4936414ceb4055fd27f7a30e76790f834fb"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform/external/bluetooth/bluez" path="external/bluetooth/bluez" revision="52a1a862a8bac319652b8f82d9541ba40bfa45ce"/>
--- a/b2g/config/emulator-jb/sources.xml
+++ b/b2g/config/emulator-jb/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="0e94c080bee081a50aa2097527b0b40852f9143f">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
--- a/b2g/config/emulator-kk/sources.xml
+++ b/b2g/config/emulator-kk/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="e0c735ec89df011ea7dd435087a9045ecff9ff9e">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="1950e4760fa14688b83cdbb5acaa1af9f82ef434"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="ac6eb97a37035c09fb5ede0852f0881e9aadf9ad"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="737f591c5f95477148d26602c7be56cbea0cdeb9"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="51da9b1981be481b92a59a826d4d78dc73d0989a"/>
   <project name="device/common" path="device/common" revision="798a3664597e6041985feab9aef42e98d458bc3d"/>
--- a/b2g/config/emulator/sources.xml
+++ b/b2g/config/emulator/sources.xml
@@ -14,23 +14,23 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="df362ace56338da8173d30d3e09e08c42c1accfa">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="6fa7a4936414ceb4055fd27f7a30e76790f834fb"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform/external/bluetooth/bluez" path="external/bluetooth/bluez" revision="52a1a862a8bac319652b8f82d9541ba40bfa45ce"/>
--- a/b2g/config/flame-kk/sources.xml
+++ b/b2g/config/flame-kk/sources.xml
@@ -10,25 +10,25 @@
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="e0c735ec89df011ea7dd435087a9045ecff9ff9e">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="a1e239a0bb5cd1d69680bf1075883aa9a7bf2429"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="c7931763d41be602407ed9d71e2c0292c6597e00"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="a32003194f707f66a2d8cdb913ed1869f1926c5d"/>
   <project name="device/common" path="device/common" revision="96d4d2006c4fcb2f19a3fa47ab10cb409faa017b"/>
--- a/b2g/config/flame/sources.xml
+++ b/b2g/config/flame/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="0e94c080bee081a50aa2097527b0b40852f9143f">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="e95b4ce22c825da44d14299e1190ea39a5260bde"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="471afab478649078ad7c75ec6b252481a59e19b8"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,9 +1,9 @@
 {
     "git": {
         "git_revision": "", 
         "remote": "", 
         "branch": ""
     }, 
-    "revision": "ff1669229bb0dae8647a88dfe82a683e88f8c32b", 
+    "revision": "c175a29477e68e70142687587844423a75dcf4cc", 
     "repo_path": "integration/gaia-central"
 }
--- a/b2g/config/hamachi/sources.xml
+++ b/b2g/config/hamachi/sources.xml
@@ -12,21 +12,21 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="b2g/ics_strawberry" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="df362ace56338da8173d30d3e09e08c42c1accfa">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="746bc48f34f5060f90801925dcdd964030c1ab6d"/>
   <project name="platform/development" path="development" revision="2460485184bc8535440bb63876d4e63ec1b4770c"/>
   <project name="device/common" path="device/common" revision="0dcc1e03659db33b77392529466f9eb685cdd3c7"/>
   <project name="device/sample" path="device/sample" revision="68b1cb978a20806176123b959cb05d4fa8adaea4"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
--- a/b2g/config/helix/sources.xml
+++ b/b2g/config/helix/sources.xml
@@ -10,17 +10,17 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <default remote="caf" revision="b2g/ics_strawberry" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="df362ace56338da8173d30d3e09e08c42c1accfa">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
   <project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>
--- a/b2g/config/nexus-4/sources.xml
+++ b/b2g/config/nexus-4/sources.xml
@@ -12,20 +12,20 @@
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="0e94c080bee081a50aa2097527b0b40852f9143f">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
--- a/b2g/config/wasabi/sources.xml
+++ b/b2g/config/wasabi/sources.xml
@@ -12,22 +12,22 @@
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <default remote="caf" revision="ics_chocolate_rb4.2" sync-j="4"/>
   <!-- Gonk specific things and forks -->
   <project name="platform_build" path="build" remote="b2g" revision="df362ace56338da8173d30d3e09e08c42c1accfa">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="4ceeff19086b2a2955f044ad923dcfa63a293de3"/>
+  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="b77e0d56d197e0ee02d801a25c784130d888c9db"/>
   <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
   <project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="5ddb92ff090d40d2d5339e5f07b3a0ce10885462"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="f59d8671fff36da22236a4b270b93195889b7ff1"/>
   <project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
   <project name="platform/bionic" path="bionic" revision="cd5dfce80bc3f0139a56b58aca633202ccaee7f8"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="e0a9ac010df3afaa47ba107192c05ac8b5516435"/>
   <project name="platform/development" path="development" revision="a384622f5fcb1d2bebb9102591ff7ae91fe8ed2d"/>
   <project name="device/common" path="device/common" revision="7c65ea240157763b8ded6154a17d3c033167afb7"/>
   <project name="device/sample" path="device/sample" revision="c328f3d4409db801628861baa8d279fb8855892f"/>
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1744,55 +1744,16 @@ pref("ui.key.menuAccessKeyFocuses", true
 
 // Encrypted media extensions.
 #ifdef RELEASE_BUILD
 pref("media.eme.enabled", false);
 #else
 pref("media.eme.enabled", true);
 #endif
 
-// GMPInstallManager prefs
-
-// Enables some extra logging (can reduce performance)
-pref("media.gmp-manager.log", false);
-
-// User-settable override to media.gmp-manager.url for testing purposes.
-//pref("media.gmp-manager.url.override", "");
-
-// Update service URL for GMP install/updates:
-pref("media.gmp-manager.url", "https://aus4.mozilla.org/update/3/GMP/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml");
-
-// When |media.gmp-manager.cert.requireBuiltIn| is true or not specified the
-// final certificate and all certificates the connection is redirected to before
-// the final certificate for the url specified in the |media.gmp-manager.url|
-// preference must be built-in.
-pref("media.gmp-manager.cert.requireBuiltIn", true);
-
-// The |media.gmp-manager.certs.| preference branch contains branches that are
-// sequentially numbered starting at 1 that contain attribute name / value
-// pairs for the certificate used by the server that hosts the update xml file
-// as specified in the |media.gmp-manager.url| preference. When these preferences are
-// present the following conditions apply for a successful update check:
-// 1. the uri scheme must be https
-// 2. the preference name must exist as an attribute name on the certificate and
-//    the value for the name must be the same as the value for the attribute name
-//    on the certificate.
-// If these conditions aren't met it will be treated the same as when there is
-// no update available. This validation will not be performed when the
-// |media.gmp-manager.url.override| user preference has been set for testing updates or
-// when the |media.gmp-manager.cert.checkAttributes| preference is set to false. Also,
-// the |media.gmp-manager.url.override| preference should ONLY be used for testing.
-// IMPORTANT! app.update.certs.* prefs should also be updated if these
-// are updated.
-pref("media.gmp-manager.cert.checkAttributes", true);
-pref("media.gmp-manager.certs.1.issuerName", "CN=DigiCert Secure Server CA,O=DigiCert Inc,C=US");
-pref("media.gmp-manager.certs.1.commonName", "aus4.mozilla.org");
-pref("media.gmp-manager.certs.2.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US");
-pref("media.gmp-manager.certs.2.commonName", "aus4.mozilla.org");
-
 // Play with different values of the decay time and get telemetry,
 // 0 means to randomize (and persist) the experiment value in users' profiles,
 // -1 means no experiment is run and we use the preferred value for frecency (6h)
 pref("browser.cache.frecency_experiment", 0);
 
 pref("browser.translation.detectLanguage", false);
 pref("browser.translation.neverForLanguages", "");
 // Show the translation UI bits, like the info bar, notification icon and preferences.
--- a/browser/components/places/tests/browser/browser.ini
+++ b/browser/components/places/tests/browser/browser.ini
@@ -43,17 +43,17 @@ skip-if = e10s # Bug ?????? - test fails
 skip-if = true
 
 [browser_library_infoBox.js]
 [browser_markPageAsFollowedLink.js]
 skip-if = e10s # Bug 933103 - mochitest's EventUtils.synthesizeMouse functions not e10s friendly (test does EventUtils.sendMouseEvent...)
 [browser_toolbar_migration.js]
 [browser_library_batch_delete.js]
 [browser_555547.js]
-skip-if = e10s
+skip-if = e10s || (os == "win" && !debug) # Bug 1115276
 [browser_416459_cut.js]
 skip-if = e10s # Bug ?????? - clipboard operations don't seem to work in this test?
 [browser_library_downloads.js]
 [browser_library_left_pane_select_hierarchy.js]
 [browser_435851_copy_query.js]
 skip-if = e10s
 [browser_toolbarbutton_menu_context.js]
 skip-if = e10s
--- a/browser/devtools/webide/test/test_zoom.html
+++ b/browser/devtools/webide/test/test_zoom.html
@@ -62,14 +62,16 @@
 
             roundZoom = Math.round(10 * viewer.fullZoom) / 10;
             is(roundZoom, 1.4, "Zoom restored");
 
             win.Cmds.resetZoom();
 
             is(viewer.fullZoom, 1, "Zoom reset");
 
+            yield closeWebIDE(win);
+
             SimpleTest.finish();
         });
       }
     </script>
   </body>
 </html>
--- a/browser/experiments/Experiments.jsm
+++ b/browser/experiments/Experiments.jsm
@@ -1320,16 +1320,17 @@ Experiments.Experiments.prototype = {
     if (activeChanged || this._firstEvaluate) {
       Services.obs.notifyObservers(null, EXPERIMENTS_CHANGED_TOPIC, null);
       this._firstEvaluate = false;
     }
 
     if ("@mozilla.org/toolkit/crash-reporter;1" in Cc && activeExperiment) {
       try {
         gCrashReporter.annotateCrashReport("ActiveExperiment", activeExperiment.id);
+        gCrashReporter.annotateCrashReport("ActiveExperimentBranch", activeExperiment.branch);
       } catch (e) {
         // It's ok if crash reporting is disabled.
       }
     }
   },
 
   /*
    * Schedule the soonest re-check of experiment applicability that is needed.
deleted file mode 100644
--- a/build/autoconf/gcc-pr39608.m4
+++ /dev/null
@@ -1,37 +0,0 @@
-dnl This Source Code Form is subject to the terms of the Mozilla Public
-dnl License, v. 2.0. If a copy of the MPL was not distributed with this
-dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-dnl Check if the compiler is gcc and has pr39608. If so
-dnl disable vrp.
-
-AC_DEFUN([MOZ_GCC_PR39608],
-[
-AC_MSG_CHECKING(for gcc pr39608)
-ac_have_gcc_pr39608="yes"
-AC_LANG_SAVE
-AC_LANG_CPLUSPLUS
-
-AC_TRY_COMPILE([
-typedef void (*FuncType)();
-template<FuncType Impl>
-void f();
-template<typename T> class C {
-  typedef C<T> ThisC;
-  template<int g()>
-  static void h() {
-    f<ThisC::h<g> >();
-  }
-};
-], true,
-   ac_have_gcc_pr39608="no",
-   true)
-
-AC_LANG_RESTORE
-
-AC_MSG_RESULT($ac_have_gcc_pr39608)
-if test "$ac_have_gcc_pr39608" = "yes"; then
-   echo This compiler would fail to build firefox, please upgrade.
-   exit 1
-fi
-])
--- a/config/system-headers
+++ b/config/system-headers
@@ -184,16 +184,17 @@ app/MessageRunner.h
 arpa/inet.h
 arpa/nameser.h
 asm/page.h
 asm/sigcontext.h
 asm/signal.h
 ASRegistry.h
 assert.h
 atk/atk.h
+atk-bridge.h
 atlcom.h
 atlconv.h
 atlctl.cpp
 atlctl.h
 ATLCTL.H
 atlhost.h
 atlimpl.cpp
 atlwin.cpp
--- a/configure.in
+++ b/configure.in
@@ -756,26 +756,24 @@ AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
 
 dnl ========================================================
 dnl Checks for programs.
 dnl ========================================================
 AC_PROG_INSTALL
 AC_PROG_LN_S
 
-if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
 _perl_res=$?
 AC_MSG_RESULT([$_perl_version])
 
 if test "$_perl_res" != 0; then
     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
 fi
-fi
 
 AC_MSG_CHECKING([for full perl installation])
 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
 _perl_res=$?
 if test "$_perl_res" != 0; then
     AC_MSG_RESULT([no])
     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
 else
@@ -2668,17 +2666,16 @@ WINNT|Darwin|Android)
   WRAP_STL_INCLUDES=1
   ;;
 esac
 
 AC_SUBST(WRAP_SYSTEM_INCLUDES)
 AC_SUBST(VISIBILITY_FLAGS)
 
 MOZ_GCC_PR49911
-MOZ_GCC_PR39608
 MOZ_LLVM_PR8927
 
 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
 dnl ========================================================
 if test "$GNU_CC"; then
   CFLAGS_save="${CFLAGS}"
   CFLAGS="${CFLAGS} -Werror"
   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
@@ -3289,30 +3286,16 @@ AC_CACHE_CHECK(for C++ dynamic_cast to v
                             }],
                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
                            ac_cv_cpp_dynamic_cast_void_ptr=no,
                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
 fi
 
-dnl note that this one is reversed - if the test fails, then
-dnl we require implementations of unused virtual methods. Which
-dnl really blows because it means we'll have useless vtable
-dnl bloat.
-AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
-               ac_cv_cpp_unused_required,
-               [AC_TRY_LINK(class X {private: virtual void never_called();};,
-                               X x;,
-                               ac_cv_cpp_unused_required=no,
-                               ac_cv_cpp_unused_required=yes)])
-if test "$ac_cv_cpp_unused_required" = yes ; then
-   AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
-fi
-
 
 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
 # linking XUL.
 _SAVE_LDFLAGS=$LDFLAGS
 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
 AC_CACHE_CHECK(for __thread keyword for TLS variables,
@@ -4421,17 +4404,17 @@ if test "$MOZ_ENABLE_XREMOTE"; then
 fi
 
 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
 fi
 
 if test "$COMPILE_ENVIRONMENT"; then
   if test "$MOZ_ENABLE_GTK3"; then
-    PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
+    PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 atk-bridge-2.0 $GDK_PACKAGES)
     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
     dnl Contrary to MOZ_GTK2_LIBS, MOZ_GTK3_LIBS needs to be literally added to TK_LIBS instead
     dnl of a make reference because of how TK_LIBS is mangled in toolkit/library/moz.build
     dnl for GTK+3 builds.
     TK_LIBS=$MOZ_GTK3_LIBS
   fi
   if test "$MOZ_ENABLE_GTK"; then
     if test "$MOZ_X11"; then
@@ -9022,17 +9005,16 @@ dnl Spit out some output
 dnl ========================================================
 
 dnl The following defines are used by xpcom
 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
 CPP_THROW_NEW
 HAVE_CPP_AMBIGUITY_RESOLVING_USING
 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
 HAVE_CPP_PARTIAL_SPECIALIZATION
-NEED_CPP_UNUSED_IMPLEMENTATIONS
 HAVE_GETPAGESIZE
 HAVE_ICONV
 HAVE_ICONV_WITH_CONST_INPUT
 HAVE_MBRTOWC
 HAVE_WCRTOMB
 HAVE_STATVFS64
 HAVE_STATVFS
 HAVE_STATFS64
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -128,35 +128,55 @@ AnimationPlayer::SetSource(Animation* aS
   if (mSource) {
     mSource->SetParentTime(GetCurrentTime());
   }
 }
 
 void
 AnimationPlayer::Tick()
 {
+  // FIXME (bug 1112969): Check if we are pending but have lost access to the
+  // pending player tracker. If that's the case we should probably trigger the
+  // animation now.
+
   UpdateSourceContent();
 }
 
 void
 AnimationPlayer::StartNow()
 {
-  // Currently we only expect this method to be called when we are in the
-  // middle of initiating/resuming playback so we should have an unresolved
-  // start time to update and a fixed current time to seek to.
-  MOZ_ASSERT(mStartTime.IsNull() && !mHoldTime.IsNull(),
-             "Resolving the start time but we don't appear to be waiting"
-             " to begin playback");
+  // This method is only expected to be called for an animation that is
+  // waiting to play. We can easily adapt it to handle other states
+  // but it's currently not necessary.
+  MOZ_ASSERT(PlayState() == AnimationPlayState::Pending,
+             "Expected to start a pending player");
+  MOZ_ASSERT(!mHoldTime.IsNull(),
+             "A player in the pending state should have a resolved hold time");
 
   Nullable<TimeDuration> readyTime = mTimeline->GetCurrentTime();
-  // Bug 1096776: Once we support disappearing or inactive timelines we
-  // will need special handling here.
+
+  // FIXME (bug 1096776): If readyTime.IsNull(), we should return early here.
+  // This will leave mIsPending = true but the caller will remove us from the
+  // PendingPlayerTracker if we were added there.
+  // Then, in Tick(), if we have:
+  // - a resolved timeline, and
+  // - mIsPending = true, and
+  // - *no* document or we are *not* in the PendingPlayerTracker
+  // then we should call StartNow.
+  //
+  // For now, however, we don't support inactive/missing timelines so
+  // |readyTime| should be resolved.
   MOZ_ASSERT(!readyTime.IsNull(), "Missing or inactive timeline");
+
   mStartTime.SetValue(readyTime.Value() - mHoldTime.Value());
   mHoldTime.SetNull();
+  mIsPending = false;
+
+  UpdateSourceContent();
+  PostUpdate();
 
   if (mReady) {
     mReady->MaybeResolve(this);
   }
 }
 
 void
 AnimationPlayer::Cancel()
@@ -241,17 +261,37 @@ AnimationPlayer::DoPlay()
   } else if (mHoldTime.IsNull()) {
     // If the hold time is null, we are already playing normally
     return;
   }
 
   // Clear ready promise. We'll create a new one lazily.
   mReady = nullptr;
 
-  StartNow();
+  mIsPending = true;
+
+  nsIDocument* doc = GetRenderedDocument();
+  if (!doc) {
+    // If we have no rendered document (e.g. because the source content's
+    // target element is orphaned), then treat the animation as ready and
+    // start it immediately. It is probably preferable to make playing
+    // *always* asynchronous (e.g. by setting some additional state that
+    // marks this player as pending and queueing a runnable to resolve the
+    // start time). That situation, however, is currently rare enough that
+    // we don't bother for now.
+    StartNow();
+    return;
+  }
+
+  PendingPlayerTracker* tracker = doc->GetOrCreatePendingPlayerTracker();
+  tracker->AddPlayPending(*this);
+
+  // We may have updated the current time when we set the hold time above
+  // so notify source content.
+  UpdateSourceContent();
 }
 
 void
 AnimationPlayer::DoPause()
 {
   if (mIsPending) {
     CancelPendingPlay();
     // Resolve the ready promise since we currently only use it for
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -90,18 +90,37 @@ public:
   // PauseFromJS is currently only here for symmetry with PlayFromJS but
   // in future we will likely have to flush style in
   // CSSAnimationPlayer::PauseFromJS so we leave it for now.
   void PauseFromJS() { Pause(); }
 
   void SetSource(Animation* aSource);
   void Tick();
 
-  // Sets the start time of a player that is waiting to play to the current
-  // time of its timeline.
+  /**
+   * Sets the start time of a player that is waiting to play to the current
+   * time of its timeline.
+   *
+   * This will reset the pending flag if the call succeeded. The caller is
+   * responsible for removing the player from the PendingPlayerTracker though.
+   *
+   * Typically, when a player is played, it does not start immediately but is
+   * added to a table of pending players on the document of its source content.
+   * In the meantime it sets its hold time to the time from which should
+   * begin playback.
+   *
+   * When the document finishes painting, any pending players in its table
+   * are started by calling this method.
+   *
+   * This approach means that any setup time required for performing the
+   * initial paint of an animation such as layerization is not deducted from
+   * the running time of the animation. Without this we can easily drop the
+   * first few frames of an animation, or, on slower devices, the whole
+   * animation.
+   */
   void StartNow();
   void Cancel();
 
   const nsString& Name() const {
     return mSource ? mSource->Name() : EmptyString();
   }
 
   bool IsPaused() const { return PlayState() == AnimationPlayState::Paused; }
--- a/dom/animation/test/chrome/test_running_on_compositor.html
+++ b/dom/animation/test/chrome/test_running_on_compositor.html
@@ -39,28 +39,26 @@ const OMTAPrefKey = 'layers.offmainthrea
 var omtaEnabled = SpecialPowers.DOMWindowUtils.layerManagerRemote &&
                   SpecialPowers.getBoolPref(OMTAPrefKey);
 
 // FIXME: When we implement Element.animate, use that here instead of CSS
 // so that we remove any dependency on the CSS mapping.
 div.style.animation = 'anim 100s';
 var player = div.getAnimationPlayers()[0];
 
-// Wait so that animation can be set up.
-// FIXME: When we implement the AnimationPlayer.ready promise we should wait
-// on that here.
-window.requestAnimationFrame(function() {
+player.ready.then(function() {
   is(player.isRunningOnCompositor, omtaEnabled,
      'AnimationPlayer reports that it is running on the compositor'
      + ' during playback');
 
   div.style.animationPlayState = 'paused';
   window.getComputedStyle(div).animationPlayState;
 
-  // FIXME: Likewise, we should wait on AnimationPlayer.ready here too.
+  // FIXME: When we implement deferred pausing (bug 1109390), we should wait
+  // on player.ready here.
   window.requestAnimationFrame(function() {
     is(player.isRunningOnCompositor, false,
        'AnimationPlayer reports that it is NOT running on the compositor'
        + ' when paused');
     SimpleTest.finish();
   });
 });
 </script>
--- a/dom/animation/test/css-animations/test_animation-player-playstate.html
+++ b/dom/animation/test/css-animations/test_animation-player-playstate.html
@@ -11,18 +11,17 @@
 'use strict';
 
 async_test(function(t) {
   var div = addDiv(t);
   var cs = window.getComputedStyle(div);
   div.style.animation = 'anim 1000s';
 
   var player = div.getAnimationPlayers()[0];
-  assert_equals(player.playState, 'running');
-  // Bug 927349: Check for pending state here
+  assert_equals(player.playState, 'pending');
 
   player.ready.then(t.step_func(function() {
     assert_equals(player.playState, 'running');
     t.done();
   }));
 }, 'Player returns correct playState when running');
 
 test(function(t) {
@@ -47,13 +46,14 @@ test(function(t) {
 test(function(t) {
   var div = addDiv(t);
   var cs = window.getComputedStyle(div);
   div.style.animation = 'anim 1000s paused';
 
   var player = div.getAnimationPlayers()[0];
   div.style.animationPlayState = 'running';
   // This test also checks that calling playState flushes style
-  // Bug 927349: Make this check for 'pending'
-  assert_equals(player.playState, 'running');
+  assert_equals(player.playState, 'pending',
+                'Player.playState reports pending after updating'
+                + ' animation-play-state (got: ' + player.playState + ')');
 }, 'Player.playState updates when resumed by setting style');
 
 </script>
--- a/dom/animation/test/css-animations/test_animation-player-ready.html
+++ b/dom/animation/test/css-animations/test_animation-player-ready.html
@@ -70,9 +70,67 @@ async_test(function(t) {
   player.ready.then(function(resolvedPlayer) {
     assert_equals(resolvedPlayer, player,
                   'Object identity of player passed to Promise callback'
                   + ' matches the player object owning the Promise');
     t.done();
   });
 }, 'The ready promise is fulfilled with its AnimationPlayer');
 
+async_test(function(t) {
+  var div = addDiv(t);
+
+  // Set up pending animation
+  div.style.animation = 'abc 100s';
+  var player = div.getAnimationPlayers()[0];
+  assert_equals(player.playState, 'pending', 'Player is initially pending');
+
+  // Set up listeners on ready promise
+  player.ready.then(t.step_func(function() {
+    assert_unreached('ready promise is fulfilled');
+  })).catch(t.step_func(function(err) {
+    assert_equals(err.name, 'AbortError',
+                  'ready promise is rejected with AbortError');
+    assert_equals(player.playState, 'idle',
+                  'Player is idle after animation was cancelled');
+  })).then(t.step_func(function() {
+    t.done();
+  }));
+
+  // Now cancel the animation and flush styles
+  div.style.animation = '';
+  window.getComputedStyle(div).animation;
+
+}, 'ready promise is rejected when an animation is cancelled by resetting'
+   + ' the animation property');
+
+async_test(function(t) {
+  var div = addDiv(t);
+
+  // As before, but this time instead of removing all animations, simply update
+  // the list of animations. At least for Firefox, updating is a different
+  // code path.
+
+  // Set up pending animation
+  div.style.animation = 'abc 100s';
+  var player = div.getAnimationPlayers()[0];
+  assert_equals(player.playState, 'pending', 'Player is initially pending');
+
+  // Set up listeners on ready promise
+  player.ready.then(t.step_func(function() {
+    assert_unreached('ready promise was fulfilled');
+  })).catch(t.step_func(function(err) {
+    assert_equals(err.name, 'AbortError',
+                  'ready promise is rejected with AbortError');
+    assert_equals(player.playState, 'idle',
+                  'Player is idle after animation was cancelled');
+  })).then(t.step_func(function() {
+    t.done();
+  }));
+
+  // Now update the animation and flush styles
+  div.style.animation = 'def 100s';
+  window.getComputedStyle(div).animation;
+
+}, 'ready promise is rejected when an animation is cancelled by updating'
+   + ' the animation property');
+
 </script>
--- a/dom/animation/test/css-transitions/test_animation-player-ready.html
+++ b/dom/animation/test/css-transitions/test_animation-player-ready.html
@@ -30,9 +30,41 @@ async_test(function(t) {
     assert_not_equals(player.ready, originalReadyPromise,
                       'Ready promise object identity differs after calling'
                       + ' play()');
     t.done();
   }));
 }, 'A new ready promise is created each time play() is called'
    + ' the animation property');
 
+async_test(function(t) {
+  var div = addDiv(t);
+
+  // Set up pending transition
+  div.style.transform = 'translate(0px)';
+  window.getComputedStyle(div).transform;
+  div.style.transition = 'transform 100s';
+  div.style.transform = 'translate(10px)';
+  window.getComputedStyle(div).transform;
+
+  var player = div.getAnimationPlayers()[0];
+  assert_equals(player.playState, 'pending', 'Player is initially pending');
+
+  // Set up listeners on ready promise
+  player.ready.then(t.step_func(function() {
+    assert_unreached('ready promise was fulfilled');
+  })).catch(t.step_func(function(err) {
+    assert_equals(err.name, 'AbortError',
+                  'ready promise is rejected with AbortError');
+    assert_equals(player.playState, 'idle',
+                  'Player is idle after transition was cancelled');
+  })).then(t.step_func(function() {
+    t.done();
+  }));
+
+  // Now remove transform from transition-property and flush styles
+  div.style.transitionProperty = 'none';
+  window.getComputedStyle(div).transitionProperty;
+
+}, 'ready promise is rejected when a transition is cancelled by updating'
+   + ' transition-property');
+
 </script>
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -2,19 +2,22 @@
 support-files =
   testcommon.js
 
 [animation-timeline/test_animation-timeline.html]
 skip-if = buildapp == 'mulet'
 [css-animations/test_animations-dynamic-changes.html]
 [css-animations/test_animation-effect-name.html]
 [css-animations/test_animation-pausing.html]
+skip-if = os == "mac" && os_version == "10.8" # disabled until bug 1112480 lands
 [css-animations/test_animation-player-playstate.html]
 [css-animations/test_animation-player-ready.html]
 [css-animations/test_animation-target.html]
 [css-animations/test_element-get-animation-players.html]
 skip-if = buildapp == 'mulet'
 [css-transitions/test_animation-effect-name.html]
 [css-transitions/test_animation-pausing.html]
 [css-transitions/test_animation-player-ready.html]
 [css-transitions/test_animation-target.html]
 [css-transitions/test_element-get-animation-players.html]
 skip-if = buildapp == 'mulet'
+[mozilla/test_deferred_start.html]
+skip-if = buildapp == 'mulet' || (buildapp == 'b2g' && toolkit != 'gonk') # bug 1113425
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/mozilla/test_deferred_start.html
@@ -0,0 +1,115 @@
+<!doctype html>
+<meta charset=utf-8>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<div id="log"></div>
+<style>
+@keyframes empty { }
+@keyframes animTransform {
+  from { transform: translate(0px); }
+  to { transform: translate(100px); }
+}
+.target {
+  // Element needs geometry to be eligible for layerization
+  width: 100px;
+  height: 100px;
+  background-color: white;
+}
+</style>
+<script>
+'use strict';
+
+function waitForDocLoad() {
+  return new Promise(function(resolve, reject) {
+    if (document.readyState === 'complete') {
+      resolve();
+    } else {
+      window.addEventListener('load', resolve);
+    }
+  });
+}
+
+async_test(function(t) {
+  var div = addDiv(t);
+  var cs = window.getComputedStyle(div);
+
+  // Test that empty animations actually start.
+  //
+  // Normally we tie the start of animations to when their first frame of
+  // the animation is rendered. However, for animations that don't actually
+  // trigger a paint (e.g. because they are empty, or are animating something
+  // that doesn't render or is offscreen) we want to make sure they still
+  // start.
+  //
+  // Before we start, wait for the document to finish loading. This is because
+  // during loading we will have other paint events taking place which might,
+  // by luck, happen to trigger animations that otherwise would not have been
+  // triggered, leading to false positives.
+  //
+  // As a result, it's better to wait until we have a more stable state before
+  // continuing.
+  var promiseCallbackDone = false;
+  waitForDocLoad().then(function() {
+    div.style.animation = 'empty 1000s';
+    var player = div.getAnimationPlayers()[0];
+
+    player.ready.then(function() {
+      promiseCallbackDone = true;
+    }).catch(function() {
+      assert_unreached('ready promise was rejected');
+    });
+
+  }).then(waitForFrame).then(t.step_func(function() {
+    assert_true(promiseCallbackDone,
+                'ready promise callback was called before the next'
+                + ' requestAnimationFrame callback');
+    t.done();
+  }));
+}, 'AnimationPlayer.ready is resolved for an empty animation');
+
+// Test that compositor animations with delays get synced correctly
+//
+// NOTE: It is important that we DON'T use
+// SpecialWindows.DOMWindowUtils.advanceTimeAndRefresh here since that takes
+// us through a different code path.
+async_test(function(t) {
+  // This test only applies to compositor animations
+  const OMTAPrefKey = 'layers.offmainthreadcomposition.async-animations';
+  var omtaEnabled = SpecialPowers.DOMWindowUtils.layerManagerRemote &&
+                    SpecialPowers.getBoolPref(OMTAPrefKey);
+  if (!omtaEnabled) {
+    t.done();
+    return;
+  }
+
+  // Setup animation
+  var div = addDiv(t);
+  div.classList.add('target');
+  div.style.animation = 'animTransform 100s -50s forwards';
+  var player = div.getAnimationPlayers()[0];
+
+  player.ready.then(t.step_func(function() {
+    var transformStr =
+      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
+
+    var matrixComponents =
+      transformStr.startsWith('matrix(')
+      ? transformStr.substring('matrix('.length, transformStr.length-1)
+                    .split(',')
+                    .map(component => Number(component))
+      : [];
+    assert_equals(matrixComponents.length, 6,
+                  'Got a valid transform matrix on the compositor'
+                  + ' (got: "' + transformStr + '")');
+
+    // If the delay has been applied correctly we should be at least
+    // half-way through the animation
+    assert_true(matrixComponents[4] >= 50,
+                'Animation is at least half-way through on the compositor'
+                + ' (got translation of ' + matrixComponents[4] + ')');
+    t.done();
+  }));
+}, 'Starting an animation with a delay starts from the correct point');
+
+</script>
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -10,16 +10,17 @@
 #include "base/basictypes.h"
 
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/unused.h"
 
 #include "mozilla/dom/ContentParent.h"
 
+#include "nsContentUtils.h"
 #include "nsISupportsPrimitives.h"
 #include "nsThreadUtils.h"
 #include "nsHashPropertyBag.h"
 #include "nsComponentManagerUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/dom/SettingChangeNotificationBinding.h"
 
@@ -823,21 +824,18 @@ AudioChannelService::Observe(nsISupports
       NS_WARNING("ipc:content-shutdown message without childID property");
     }
   }
 
 #ifdef MOZ_WIDGET_GONK
   // To process the volume control on each audio channel according to
   // change of settings
   else if (!strcmp(aTopic, "mozsettings-changed")) {
-    AutoJSAPI jsapi;
-    jsapi.Init();
-    JSContext* cx = jsapi.cx();
-    RootedDictionary<SettingChangeNotification> setting(cx);
-    if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+    RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
+    if (!WrappedJSToDictionary(aSubject, setting)) {
       return NS_OK;
     }
     if (!StringBeginsWith(setting.mKey, NS_LITERAL_STRING("audio.volume."))) {
       return NS_OK;
     }
     if (!setting.mValue.isNumber()) {
       return NS_OK;
     }
--- a/dom/base/ImageEncoder.cpp
+++ b/dom/base/ImageEncoder.cpp
@@ -23,17 +23,17 @@ class SurfaceHelper : public nsRunnable 
 public:
   explicit SurfaceHelper(TemporaryRef<layers::Image> aImage) : mImage(aImage) {}
 
   // It retrieves a SourceSurface reference and convert color format on main
   // thread and passes DataSourceSurface to caller thread.
   NS_IMETHOD Run() {
     // It guarantees the reference will be released on main thread.
     nsCountedRef<nsMainThreadSourceSurfaceRef> surface;
-    surface.own(mImage->GetAsSourceSurface().drop());
+    surface.own(mImage->GetAsSourceSurface().take());
 
     if (surface->GetFormat() == gfx::SurfaceFormat::B8G8R8A8) {
       mDataSourceSurface = surface->GetDataSurface();
     } else {
       mDataSourceSurface = gfxUtils::
         CopySurfaceToDataSourceSurfaceWithFormat(surface,
                                                  gfx::SurfaceFormat::B8G8R8A8);
     }
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1571,16 +1571,18 @@ public:
 
   static nsIScriptContext* GetContextForEventHandlers(nsINode* aNode,
                                                       nsresult* aRv);
 
   static JSContext *GetCurrentJSContext();
   static JSContext *GetSafeJSContext();
   static JSContext *GetCurrentJSContextForThread();
   static JSContext *GetDefaultJSContextForThread();
+  inline static JSContext *RootingCx() { return GetSafeJSContext(); }
+  inline static JSContext *RootingCxForThread() { return GetDefaultJSContextForThread(); }
 
   /**
    * Case insensitive comparison between two strings. However it only ignores
    * case for ASCII characters a-z.
    */
   static bool EqualsIgnoreASCIICase(const nsAString& aStr1,
                                     const nsAString& aStr2);
 
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -540,21 +540,18 @@ BluetoothService::HandleStartupSettingsC
 nsresult
 BluetoothService::HandleSettingsChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"bluetooth.enabled","value":true}
 
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return NS_OK;
   }
   if (setting.mKey.EqualsASCII(BLUETOOTH_DEBUGGING_SETTING)) {
     if (!setting.mValue.isBoolean()) {
       MOZ_ASSERT(false, "Expecting a boolean for 'bluetooth.debugging.enabled'!");
       return NS_ERROR_UNEXPECTED;
     }
 
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -611,21 +611,18 @@ public:
 void
 BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"volumeup", "value":10}
   //  {"key":"volumedown", "value":2}
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<dom::SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return;
   }
   if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
     return;
   }
   if (!setting.mValue.isNumber()) {
     return;
   }
@@ -678,19 +675,17 @@ BluetoothHfpManager::HandleVoiceConnecti
   if (service != mService) {
     // Notify BluetoothRilListener of service change
     mListener->ServiceChanged(aClientId, service);
   }
   mService = service ? HFP_NETWORK_STATE_AVAILABLE :
                        HFP_NETWORK_STATE_NOT_AVAILABLE;
 
   // Signal
-  JSContext* cx = nsContentUtils::GetSafeJSContext();
-  NS_ENSURE_TRUE_VOID(cx);
-  JS::Rooted<JS::Value> value(cx);
+  JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
   voiceInfo->GetRelSignalStrength(&value);
   NS_ENSURE_TRUE_VOID(value.isNumber());
   mSignal = (int)ceil(value.toNumber() / 20.0);
 
   UpdateDeviceCIND();
 
   // Operator name
   nsCOMPtr<nsIMobileNetworkInfo> network;
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -560,21 +560,18 @@ void
 BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"volumeup", "value":10}
   //  {"key":"volumedown", "value":2}
 
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return;
   }
   if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
     return;
   }
   if (!setting.mValue.isNumber()) {
     return;
   }
@@ -621,19 +618,17 @@ BluetoothHfpManager::HandleVoiceConnecti
   voiceInfo->GetState(regState);
   bool service = regState.EqualsLiteral("registered");
   if (service != sCINDItems[CINDType::SERVICE].value) {
     // Notify BluetoothRilListener of service change
     mListener->ServiceChanged(aClientId, service);
   }
   UpdateCIND(CINDType::SERVICE, service);
 
-  JSContext* cx = nsContentUtils::GetSafeJSContext();
-  NS_ENSURE_TRUE_VOID(cx);
-  JS::Rooted<JS::Value> value(cx);
+  JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
   voiceInfo->GetRelSignalStrength(&value);
   NS_ENSURE_TRUE_VOID(value.isNumber());
   uint8_t signal = ceil(value.toNumber() / 20.0);
   UpdateCIND(CINDType::SIGNAL, signal);
 
   /**
    * Possible return values for mode are:
    * - -1 (unknown): set mNetworkSelectionMode to 0 (auto)
--- a/dom/bluetooth2/BluetoothService.cpp
+++ b/dom/bluetooth2/BluetoothService.cpp
@@ -494,21 +494,18 @@ BluetoothService::HandleStartupSettingsC
 nsresult
 BluetoothService::HandleSettingsChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"bluetooth.enabled","value":true}
 
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return NS_OK;
   }
   if (!setting.mKey.EqualsASCII(BLUETOOTH_DEBUGGING_SETTING)) {
     return NS_OK;
   }
   if (!setting.mValue.isBoolean()) {
     MOZ_ASSERT(false, "Expecting a boolean for 'bluetooth.debugging.enabled'!");
     return NS_ERROR_UNEXPECTED;
--- a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -605,21 +605,18 @@ void
 BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"volumeup", "value":10}
   //  {"key":"volumedown", "value":2}
 
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<dom::SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return;
   }
   if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
     return;
   }
   if (!setting.mValue.isNumber()) {
     return;
   }
@@ -673,19 +670,17 @@ BluetoothHfpManager::HandleVoiceConnecti
                                              HFP_NETWORK_STATE_NOT_AVAILABLE;
   if (service != mService) {
     // Notify BluetoothRilListener of service change
     mListener->ServiceChanged(aClientId, service);
   }
   mService = service;
 
   // Signal
-  JSContext* cx = nsContentUtils::GetSafeJSContext();
-  NS_ENSURE_TRUE_VOID(cx);
-  JS::Rooted<JS::Value> value(cx);
+  JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
   voiceInfo->GetRelSignalStrength(&value);
   NS_ENSURE_TRUE_VOID(value.isNumber());
   mSignal = (int)ceil(value.toNumber() / 20.0);
 
   UpdateDeviceCIND();
 
   // Operator name
   nsCOMPtr<nsIMobileNetworkInfo> network;
--- a/dom/bluetooth2/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth2/bluez/BluetoothHfpManager.cpp
@@ -562,21 +562,18 @@ void
 BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"volumeup", "value":10}
   //  {"key":"volumedown", "value":2}
 
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<dom::SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return;
   }
   if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
     return;
   }
   if (!setting.mValue.isNumber()) {
     return;
   }
@@ -623,19 +620,17 @@ BluetoothHfpManager::HandleVoiceConnecti
   voiceInfo->GetState(regState);
   bool service = regState.EqualsLiteral("registered");
   if (service != sCINDItems[CINDType::SERVICE].value) {
     // Notify BluetoothRilListener of service change
     mListener->ServiceChanged(aClientId, service);
   }
   UpdateCIND(CINDType::SERVICE, service);
 
-  JSContext* cx = nsContentUtils::GetSafeJSContext();
-  NS_ENSURE_TRUE_VOID(cx);
-  JS::Rooted<JS::Value> value(cx);
+  JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
   voiceInfo->GetRelSignalStrength(&value);
   NS_ENSURE_TRUE_VOID(value.isNumber());
   uint8_t signal = ceil(value.toNumber() / 20.0);
   UpdateCIND(CINDType::SIGNAL, signal);
 
   /**
    * Possible return values for mode are:
    * - -1 (unknown): set mNetworkSelectionMode to 0 (auto)
--- a/dom/events/DOMEventTargetHelper.h
+++ b/dom/events/DOMEventTargetHelper.h
@@ -38,16 +38,23 @@ public:
   }
   explicit DOMEventTargetHelper(nsPIDOMWindow* aWindow)
     : mParentObject(nullptr)
     , mOwnerWindow(nullptr)
     , mHasOrHasHadOwnerWindow(false)
   {
     BindToOwner(aWindow);
   }
+  explicit DOMEventTargetHelper(nsIGlobalObject* aGlobalObject)
+    : mParentObject(nullptr)
+    , mOwnerWindow(nullptr)
+    , mHasOrHasHadOwnerWindow(false)
+  {
+    BindToOwner(aGlobalObject);
+  }
   explicit DOMEventTargetHelper(DOMEventTargetHelper* aOther)
     : mParentObject(nullptr)
     , mOwnerWindow(nullptr)
     , mHasOrHasHadOwnerWindow(false)
   {
     BindToOwner(aOther);
   }
 
--- a/dom/fmradio/FMRadioService.cpp
+++ b/dom/fmradio/FMRadioService.cpp
@@ -5,16 +5,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "FMRadioService.h"
 #include "mozilla/Hal.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "nsIAudioManager.h"
 #include "AudioManager.h"
 #include "nsDOMClassInfo.h"
+#include "nsContentUtils.h"
 #include "mozilla/LazyIdleThread.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/FMRadioChild.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
 #include "nsJSUtils.h"
 #include "mozilla/dom/BindingUtils.h"
@@ -834,21 +835,18 @@ FMRadioService::Observe(nsISupports* aSu
   MOZ_ASSERT(sFMRadioService);
 
   if (strcmp(aTopic, MOZSETTINGS_CHANGED_ID) != 0) {
     return NS_OK;
   }
 
   // The string that we're interested in will be a JSON string looks like:
   //  {"key":"airplaneMode.enabled","value":true}
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<dom::SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return NS_OK;
   }
   if (!setting.mKey.EqualsASCII(SETTING_KEY_AIRPLANEMODE_ENABLED)) {
     return NS_OK;
   }
   if (!setting.mValue.isBoolean()) {
     return NS_OK;
   }
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -836,21 +836,18 @@ nsGeolocationService::~nsGeolocationServ
 }
 
 void
 nsGeolocationService::HandleMozsettingChanged(nsISupports* aSubject)
 {
     // The string that we're interested in will be a JSON string that looks like:
     //  {"key":"gelocation.enabled","value":true}
 
-    AutoJSAPI jsapi;
-    jsapi.Init();
-    JSContext* cx = jsapi.cx();
-    RootedDictionary<SettingChangeNotification> setting(cx);
-    if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+    RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
+    if (!WrappedJSToDictionary(aSubject, setting)) {
       return;
     }
     if (!setting.mKey.EqualsASCII(GEO_SETTINGS_ENABLED)) {
       return;
     }
     if (!setting.mValue.isBoolean()) {
       return;
     }
--- a/dom/geolocation/nsGeolocationSettings.cpp
+++ b/dom/geolocation/nsGeolocationSettings.cpp
@@ -144,21 +144,18 @@ nsGeolocationSettings::HandleGeolocation
   }
 }
 
 void
 nsGeolocationSettings::HandleMozsettingsChanged(nsISupports* aSubject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return;
   }
 
   GPSLOG("mozsettings changed: %s", NS_ConvertUTF16toUTF8(setting.mKey).get());
 
   // and handle the geolocation settings change...
   HandleGeolocationSettingsChange(setting.mKey, setting.mValue);
 }
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1823,16 +1823,17 @@ HTMLMediaElement::CaptureStreamInternal(
         hints = DOMMediaStream::HINT_CONTENTS_AUDIO;
       }
     }
 #endif
   }
   out->mStream = DOMMediaStream::CreateTrackUnionStream(window, hints);
   nsRefPtr<nsIPrincipal> principal = GetCurrentPrincipal();
   out->mStream->CombineWithPrincipal(principal);
+  out->mStream->SetCORSMode(mCORSMode);
   out->mFinishWhenEnded = aFinishWhenEnded;
 
   mAudioCaptured = true;
   // Block the output stream initially.
   // Decoders are responsible for removing the block while they are playing
   // back into the output stream.
   out->mStream->GetStream()->ChangeExplicitBlockerCount(1);
   if (mDecoder) {
@@ -2654,26 +2655,26 @@ nsresult HTMLMediaElement::FinishDecoder
   mDecoder->SetAudioCaptured(mAudioCaptured);
   mDecoder->SetVolume(mMuted ? 0.0 : mVolume);
   mDecoder->SetPreservesPitch(mPreservesPitch);
   mDecoder->SetPlaybackRate(mPlaybackRate);
   if (mPreloadAction == HTMLMediaElement::PRELOAD_METADATA) {
     mDecoder->SetMinimizePrerollUntilPlaybackStarts();
   }
 
-  // Update decoder principal before we start decoding, since it
-  // can affect how we feed data to MediaStreams
-  NotifyDecoderPrincipalChanged();
-
   for (uint32_t i = 0; i < mOutputStreams.Length(); ++i) {
     OutputMediaStream* ms = &mOutputStreams[i];
     aDecoder->AddOutputStream(ms->mStream->GetStream()->AsProcessedStream(),
         ms->mFinishWhenEnded);
   }
 
+  // Update decoder principal before we start decoding, since it
+  // can affect how we feed data to MediaStreams
+  NotifyDecoderPrincipalChanged();
+
   nsresult rv = aDecoder->Load(aListener, aCloneDonor);
   if (NS_FAILED(rv)) {
     mDecoder = nullptr;
     LOG(PR_LOG_DEBUG, ("%p Failed to load for decoder %p", this, aDecoder));
     return rv;
   }
 
 #ifdef MOZ_EME
@@ -3506,20 +3507,22 @@ already_AddRefed<nsIPrincipal> HTMLMedia
 
 void HTMLMediaElement::NotifyDecoderPrincipalChanged()
 {
   nsRefPtr<nsIPrincipal> principal = GetCurrentPrincipal();
 
   bool subsumes;
   mDecoder->UpdateSameOriginStatus(
     !principal ||
-    (NS_SUCCEEDED(NodePrincipal()->Subsumes(principal, &subsumes)) && subsumes));
+    (NS_SUCCEEDED(NodePrincipal()->Subsumes(principal, &subsumes)) && subsumes) ||
+    mCORSMode != CORS_NONE);
 
   for (uint32_t i = 0; i < mOutputStreams.Length(); ++i) {
     OutputMediaStream* ms = &mOutputStreams[i];
+    ms->mStream->SetCORSMode(mCORSMode);
     ms->mStream->CombineWithPrincipal(principal);
   }
 #ifdef MOZ_EME
   if (mMediaKeys && NS_FAILED(mMediaKeys->CheckPrincipals())) {
     mMediaKeys->Shutdown();
   }
 #endif
 }
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -139,17 +139,17 @@ NS_IMPL_ADDREF_INHERITED(DOMAudioNodeMed
 NS_IMPL_RELEASE_INHERITED(DOMAudioNodeMediaStream, DOMMediaStream)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMAudioNodeMediaStream)
 NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
 
 DOMMediaStream::DOMMediaStream()
   : mLogicalStreamStartTime(0),
     mStream(nullptr), mHintContents(0), mTrackTypesAvailable(0),
-    mNotifiedOfMediaStreamGraphShutdown(false)
+    mNotifiedOfMediaStreamGraphShutdown(false), mCORSMode(CORS_NONE)
 {
 }
 
 DOMMediaStream::~DOMMediaStream()
 {
   Destroy();
 }
 
@@ -296,16 +296,30 @@ DOMMediaStream::CombineWithPrincipal(nsI
 void
 DOMMediaStream::SetPrincipal(nsIPrincipal* aPrincipal)
 {
   mPrincipal = aPrincipal;
   NotifyPrincipalChanged();
 }
 
 void
+DOMMediaStream::SetCORSMode(CORSMode aCORSMode)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  mCORSMode = aCORSMode;
+}
+
+CORSMode
+DOMMediaStream::GetCORSMode()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  return mCORSMode;
+}
+
+void
 DOMMediaStream::NotifyPrincipalChanged()
 {
   for (uint32_t i = 0; i < mPrincipalChangeObservers.Length(); ++i) {
     mPrincipalChangeObservers[i]->PrincipalChanged(this);
   }
 }
 
 
--- a/dom/media/DOMMediaStream.h
+++ b/dom/media/DOMMediaStream.h
@@ -8,16 +8,17 @@
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "StreamBuffer.h"
 #include "nsIDOMWindow.h"
 #include "nsIPrincipal.h"
 #include "mozilla/PeerIdentity.h"
 #include "mozilla/DOMEventTargetHelper.h"
+#include "mozilla/CORSMode.h"
 
 class nsXPCClassInfo;
 
 // GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
 // GetTickCount() and conflicts with NS_DECL_NSIDOMMEDIASTREAM, containing
 // currentTime getter.
 #ifdef GetCurrentTime
 #undef GetCurrentTime
@@ -120,16 +121,18 @@ public:
   virtual DOMLocalMediaStream* AsDOMLocalMediaStream() { return nullptr; }
 
   bool IsFinished();
   /**
    * Returns a principal indicating who may access this stream. The stream contents
    * can only be accessed by principals subsuming this principal.
    */
   nsIPrincipal* GetPrincipal() { return mPrincipal; }
+  mozilla::CORSMode GetCORSMode();
+  void SetCORSMode(mozilla::CORSMode aCORSMode);
 
   /**
    * These are used in WebRTC.  A peerIdentity constrained MediaStream cannot be sent
    * across the network to anything other than a peer with the provided identity.
    * If this is set, then mPrincipal should be an instance of nsNullPrincipal.
    */
   PeerIdentity* GetPeerIdentity() const { return mPeerIdentity; }
   void SetPeerIdentity(PeerIdentity* aPeerIdentity)
@@ -308,16 +311,17 @@ private:
 
   // Principal identifying who may access the contents of this stream.
   // If null, this stream can be used by anyone because it has no content yet.
   nsCOMPtr<nsIPrincipal> mPrincipal;
   nsTArray<PrincipalChangeObserver*> mPrincipalChangeObservers;
   // this is used in gUM and WebRTC to identify peers that this stream
   // is allowed to be sent to
   nsAutoPtr<PeerIdentity> mPeerIdentity;
+  CORSMode mCORSMode;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(DOMMediaStream,
                               NS_DOMMEDIASTREAM_IID)
 
 #define NS_DOMLOCALMEDIASTREAM_IID \
 { 0xb1437260, 0xec61, 0x4dfa, \
   { 0x92, 0x54, 0x04, 0x44, 0xe2, 0xb5, 0x94, 0x9c } }
--- a/dom/media/gmp/GMPLoader.cpp
+++ b/dom/media/gmp/GMPLoader.cpp
@@ -67,16 +67,53 @@ private:
   GMPGetAPIFunc mGetAPIFunc;
   SandboxStarter* mSandboxStarter;
 };
 
 GMPLoader* CreateGMPLoader(SandboxStarter* aStarter) {
   return static_cast<GMPLoader*>(new GMPLoaderImpl(aStarter));
 }
 
+#if defined(XP_WIN) && defined(HASH_NODE_ID_WITH_DEVICE_ID)
+MOZ_NEVER_INLINE
+static bool
+GetStackAfterCurrentFrame(uint8_t** aOutTop, uint8_t** aOutBottom)
+{
+  // "Top" of the free space on the stack is directly after the memory
+  // holding our return address.
+  uint8_t* top = (uint8_t*)_AddressOfReturnAddress();
+
+  // Look down the stack until we find the guard page...
+  MEMORY_BASIC_INFORMATION memInfo = {0};
+  uint8_t* bottom = top;
+  while (1) {
+    if (!VirtualQuery(bottom, &memInfo, sizeof(memInfo))) {
+      return false;
+    }
+    if ((memInfo.Protect & PAGE_GUARD) == PAGE_GUARD) {
+      bottom = (uint8_t*)memInfo.BaseAddress + memInfo.RegionSize;
+#ifdef DEBUG
+      if (!VirtualQuery(bottom, &memInfo, sizeof(memInfo))) {
+        return false;
+      }
+      assert(!(memInfo.Protect & PAGE_GUARD)); // Should have found boundary.
+#endif
+      break;
+    } else if (memInfo.State != MEM_COMMIT ||
+               (memInfo.AllocationProtect & PAGE_READWRITE) != PAGE_READWRITE) {
+      return false;
+    }
+    bottom = (uint8_t*)memInfo.BaseAddress - 1;
+  }
+  *aOutTop = top;
+  *aOutBottom = bottom;
+  return true;
+}
+#endif
+
 bool
 GMPLoaderImpl::Load(const char* aLibPath,
                     uint32_t aLibPathLen,
                     char* aOriginSalt,
                     uint32_t aOriginSaltLen,
                     const GMPPlatformAPI* aPlatformAPI)
 {
   std::string nodeId;
@@ -104,19 +141,33 @@ GMPLoaderImpl::Load(const char* aLibPath
     memset(aOriginSalt, 0, aOriginSaltLen);
     volumeId = 0;
     memset(&deviceId[0], '*', sizeof(string16::value_type) * deviceId.size());
     deviceId = L"";
 
     if (!rlz_lib::BytesToString(digest, SHA256_LENGTH, &nodeId)) {
       return false;
     }
-    // TODO: (Bug 1114867) Clear any memory on the stack that may have been
-    // used by functions we've called that may have left behind data that
-    // can be used to uniquely identify the user.
+    // We've successfully bound the origin salt to node id.
+    // rlz_lib::GetRawMachineId and/or the system functions it
+    // called could have left user identifiable data on the stack,
+    // so carefully zero the stack down to the guard page.
+    uint8_t* top;
+    uint8_t* bottom;
+    if (!GetStackAfterCurrentFrame(&top, &bottom)) {
+      return false;
+    }
+    assert(top >= bottom);
+    // Inline instructions equivalent to RtlSecureZeroMemory().
+    // We can't just use RtlSecureZeroMemory here directly, as in debug
+    // builds, RtlSecureZeroMemory() can't be inlined, and the stack
+    // memory it uses would get wiped by itself running, causing crashes.
+    for (volatile uint8_t* p = (volatile uint8_t*)bottom; p < top; p++) {
+      *p = 0;
+    }
   } else
 #endif
   {
     nodeId = std::string(aOriginSalt, aOriginSalt + aOriginSaltLen);
   }
 
   // Start the sandbox now that we've generated the device bound node id.
   // This must happen after the node id is bound to the device id, as
--- a/dom/media/webaudio/AnalyserNode.h
+++ b/dom/media/webaudio/AnalyserNode.h
@@ -48,17 +48,17 @@ public:
   }
   void SetMaxDecibels(double aValue, ErrorResult& aRv);
   double SmoothingTimeConstant() const
   {
     return mSmoothingTimeConstant;
   }
   void SetSmoothingTimeConstant(double aValue, ErrorResult& aRv);
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "AnalyserNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/AudioBufferSourceNode.cpp
+++ b/dom/media/webaudio/AudioBufferSourceNode.cpp
@@ -87,59 +87,59 @@ public:
     case AudioBufferSourceNode::PLAYBACKRATE:
       mPlaybackRateTimeline = aValue;
       WebAudioUtils::ConvertAudioParamToTicks(mPlaybackRateTimeline, mSource, mDestination);
       break;
     default:
       NS_ERROR("Bad AudioBufferSourceNodeEngine TimelineParameter");
     }
   }
-  virtual void SetStreamTimeParameter(uint32_t aIndex, StreamTime aParam)
+  virtual void SetStreamTimeParameter(uint32_t aIndex, StreamTime aParam) MOZ_OVERRIDE
   {
     switch (aIndex) {
     case AudioBufferSourceNode::STOP: mStop = aParam; break;
     default:
       NS_ERROR("Bad AudioBufferSourceNodeEngine StreamTimeParameter");
     }
   }
-  virtual void SetDoubleParameter(uint32_t aIndex, double aParam)
+  virtual void SetDoubleParameter(uint32_t aIndex, double aParam) MOZ_OVERRIDE
   {
     switch (aIndex) {
     case AudioBufferSourceNode::START:
       MOZ_ASSERT(!mStart, "Another START?");
       mStart =
         mSource->FractionalTicksFromDestinationTime(mDestination, aParam);
       // Round to nearest
       mBeginProcessing = mStart + 0.5;
       break;
     case AudioBufferSourceNode::DOPPLERSHIFT:
       mDopplerShift = (aParam <= 0 || mozilla::IsNaN(aParam)) ? 1.0 : aParam;
       break;
     default:
       NS_ERROR("Bad AudioBufferSourceNodeEngine double parameter.");
     };
   }
-  virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam)
+  virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam) MOZ_OVERRIDE
   {
     switch (aIndex) {
     case AudioBufferSourceNode::SAMPLE_RATE: mBufferSampleRate = aParam; break;
     case AudioBufferSourceNode::BUFFERSTART:
       if (mBufferPosition == 0) {
         mBufferPosition = aParam;
       }
       break;
     case AudioBufferSourceNode::BUFFEREND: mBufferEnd = aParam; break;
     case AudioBufferSourceNode::LOOP: mLoop = !!aParam; break;
     case AudioBufferSourceNode::LOOPSTART: mLoopStart = aParam; break;
     case AudioBufferSourceNode::LOOPEND: mLoopEnd = aParam; break;
     default:
       NS_ERROR("Bad AudioBufferSourceNodeEngine Int32Parameter");
     }
   }
-  virtual void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer)
+  virtual void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer) MOZ_OVERRIDE
   {
     mBuffer = aBuffer;
   }
 
   bool BegunResampling()
   {
     return mBeginProcessing == -STREAM_TIME_MAX;
   }
@@ -422,17 +422,17 @@ public:
 
     int32_t outRate = ComputeFinalOutSampleRate(playbackRate);
     UpdateResampler(outRate, aChannels);
   }
 
   virtual void ProcessBlock(AudioNodeStream* aStream,
                             const AudioChunk& aInput,
                             AudioChunk* aOutput,
-                            bool* aFinished)
+                            bool* aFinished) MOZ_OVERRIDE
   {
     if (!mBuffer || !mBufferEnd) {
       aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
       return;
     }
 
     uint32_t channels = mBuffer->GetChannels();
     if (!channels) {
--- a/dom/media/webaudio/AudioBufferSourceNode.h
+++ b/dom/media/webaudio/AudioBufferSourceNode.h
@@ -87,17 +87,17 @@ public:
     SendLoopParametersToStream();
   }
   void SendDopplerShiftToStream(double aDopplerShift);
 
   IMPL_EVENT_HANDLER(ended)
 
   virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "AudioBufferSourceNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -445,28 +445,28 @@ AudioContext::Listener()
     mListener = new AudioListener(this);
   }
   return mListener;
 }
 
 already_AddRefed<Promise>
 AudioContext::DecodeAudioData(const ArrayBuffer& aBuffer,
                               const Optional<OwningNonNull<DecodeSuccessCallback> >& aSuccessCallback,
-                              const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback)
+                              const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback,
+                              ErrorResult& aRv)
 {
-  ErrorResult rv;
   nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
   nsRefPtr<Promise> promise;
   AutoJSAPI jsapi;
   jsapi.Init();
   JSContext* cx = jsapi.cx();
   JSAutoCompartment ac(cx, aBuffer.Obj());
 
-  promise = Promise::Create(parentObject, rv);
-  if (rv.Failed()) {
+  promise = Promise::Create(parentObject, aRv);
+  if (aRv.Failed()) {
     return nullptr;
   }
 
   aBuffer.ComputeLengthAndData();
 
   // Neuter the array buffer
   size_t length = aBuffer.Length();
   JS::RootedObject obj(cx, aBuffer.Obj());
--- a/dom/media/webaudio/AudioContext.h
+++ b/dom/media/webaudio/AudioContext.h
@@ -187,17 +187,18 @@ public:
 
   already_AddRefed<PeriodicWave>
   CreatePeriodicWave(const Float32Array& aRealData, const Float32Array& aImagData,
                      ErrorResult& aRv);
 
   already_AddRefed<Promise>
   DecodeAudioData(const ArrayBuffer& aBuffer,
                   const Optional<OwningNonNull<DecodeSuccessCallback> >& aSuccessCallback,
-                  const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback);
+                  const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback,
+                  ErrorResult& aRv);
 
   // OfflineAudioContext methods
   already_AddRefed<Promise> StartRendering(ErrorResult& aRv);
   IMPL_EVENT_HANDLER(complete)
 
   bool IsOffline() const { return mIsOffline; }
 
   MediaStreamGraph* Graph() const;
@@ -256,17 +257,17 @@ private:
    */
   double ExtraCurrentTime() const;
 
   void RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob);
   void ShutdownDecoder();
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
   NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                            nsISupports* aData, bool aAnonymize);
+                            nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE;
 
   friend struct ::mozilla::WebAudioDecodeJob;
 
 private:
   // Note that it's important for mSampleRate to be initialized before
   // mDestination, as mDestination's constructor needs to access it!
   const float mSampleRate;
   nsRefPtr<AudioDestinationNode> mDestination;
--- a/dom/media/webaudio/AudioDestinationNode.h
+++ b/dom/media/webaudio/AudioDestinationNode.h
@@ -54,34 +54,34 @@ public:
   void Mute();
   void Unmute();
 
   void StartRendering(Promise* aPromise);
 
   void OfflineShutdown();
 
   // nsIDOMEventListener - by proxy
-  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
+  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE;
 
   AudioChannel MozAudioChannelType() const;
   void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
 
   virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
   void FireOfflineCompletionEvent();
 
   // An amount that should be added to the MediaStream's current time to
   // get the AudioContext.currentTime.
   double ExtraCurrentTime();
 
   // When aIsOnlyNode is true, this is the only node for the AudioContext.
   void SetIsOnlyNodeForContext(bool aIsOnlyNode);
 
   void CreateAudioChannelAgent();
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "AudioDestinationNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
   void InputMuted(bool aInputMuted);
--- a/dom/media/webaudio/BiquadFilterNode.h
+++ b/dom/media/webaudio/BiquadFilterNode.h
@@ -51,17 +51,17 @@ public:
   {
     return mGain;
   }
 
   void GetFrequencyResponse(const Float32Array& aFrequencyHz,
                             const Float32Array& aMagResponse,
                             const Float32Array& aPhaseResponse);
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "BiquadFilterNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/ChannelMergerNode.h
+++ b/dom/media/webaudio/ChannelMergerNode.h
@@ -21,17 +21,17 @@ public:
                     uint16_t aInputCount);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   virtual uint16_t NumberOfInputs() const MOZ_OVERRIDE { return mInputCount; }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "ChannelMergerNode";
   }
 
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
   {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
--- a/dom/media/webaudio/ChannelSplitterNode.h
+++ b/dom/media/webaudio/ChannelSplitterNode.h
@@ -21,17 +21,17 @@ public:
                       uint16_t aOutputCount);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   virtual uint16_t NumberOfOutputs() const MOZ_OVERRIDE { return mOutputCount; }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "ChannelSplitterNode";
   }
 
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
   {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
--- a/dom/media/webaudio/ConvolverNode.cpp
+++ b/dom/media/webaudio/ConvolverNode.cpp
@@ -68,17 +68,17 @@ public:
     case SAMPLE_RATE:
       mSampleRate = aParam;
       AdjustReverb();
       break;
     default:
       NS_ERROR("Bad ConvolverNodeEngine DoubleParameter");
     }
   }
-  virtual void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer)
+  virtual void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer) MOZ_OVERRIDE
   {
     mBuffer = aBuffer;
     AdjustReverb();
   }
 
   void AdjustReverb()
   {
     // Note about empirical tuning (this is copied from Blink)
@@ -99,17 +99,17 @@ public:
                                   WEBAUDIO_BLOCK_SIZE,
                                   MaxFFTSize, 2, mUseBackgroundThreads,
                                   mNormalize, mSampleRate);
   }
 
   virtual void ProcessBlock(AudioNodeStream* aStream,
                             const AudioChunk& aInput,
                             AudioChunk* aOutput,
-                            bool* aFinished)
+                            bool* aFinished) MOZ_OVERRIDE
   {
     if (!mReverb) {
       *aOutput = aInput;
       return;
     }
 
     AudioChunk input = aInput;
     if (aInput.IsNull()) {
--- a/dom/media/webaudio/ConvolverNode.h
+++ b/dom/media/webaudio/ConvolverNode.h
@@ -49,17 +49,17 @@ public:
   {
     if (aMode == ChannelCountMode::Max) {
       aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
       return;
     }
     AudioNode::SetChannelCountModeValue(aMode, aRv);
   }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "ConvolverNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/DelayNode.cpp
+++ b/dom/media/webaudio/DelayNode.cpp
@@ -42,17 +42,17 @@ public:
               WebAudioUtils::ComputeSmoothingRate(0.02,
                                                   mDestination->SampleRate()))
     , mMaxDelay(aMaxDelayTicks)
     , mHaveProducedBeforeInput(false)
     , mLeftOverData(INT32_MIN)
   {
   }
 
-  virtual DelayNodeEngine* AsDelayNodeEngine()
+  virtual DelayNodeEngine* AsDelayNodeEngine() MOZ_OVERRIDE
   {
     return this;
   }
 
   void SetSourceStream(AudioNodeStream* aSource)
   {
     mSource = aSource;
   }
--- a/dom/media/webaudio/DelayNode.h
+++ b/dom/media/webaudio/DelayNode.h
@@ -25,17 +25,17 @@ public:
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   AudioParam* DelayTime() const
   {
     return mDelay;
   }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "DelayNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/DynamicsCompressorNode.h
+++ b/dom/media/webaudio/DynamicsCompressorNode.h
@@ -51,17 +51,17 @@ public:
   }
 
   // Called GetRelease to prevent clashing with the nsISupports::Release name
   AudioParam* GetRelease() const
   {
     return mRelease;
   }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "DynamicsCompressorNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/GainNode.cpp
+++ b/dom/media/webaudio/GainNode.cpp
@@ -56,17 +56,17 @@ public:
     default:
       NS_ERROR("Bad GainNodeEngine TimelineParameter");
     }
   }
 
   virtual void ProcessBlock(AudioNodeStream* aStream,
                             const AudioChunk& aInput,
                             AudioChunk* aOutput,
-                            bool* aFinished)
+                            bool* aFinished) MOZ_OVERRIDE
   {
     MOZ_ASSERT(mSource == aStream, "Invalid source stream");
 
     if (aInput.IsNull()) {
       // If input is silent, so is the output
       aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
     } else if (mGain.HasSimpleValue()) {
       // Optimize the case where we only have a single value set as the volume
--- a/dom/media/webaudio/GainNode.h
+++ b/dom/media/webaudio/GainNode.h
@@ -25,17 +25,17 @@ public:
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   AudioParam* Gain() const
   {
     return mGain;
   }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "GainNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/MediaElementAudioSourceNode.h
+++ b/dom/media/webaudio/MediaElementAudioSourceNode.h
@@ -15,17 +15,17 @@ namespace dom {
 class MediaElementAudioSourceNode : public MediaStreamAudioSourceNode
 {
 public:
   MediaElementAudioSourceNode(AudioContext* aContext,
                               DOMMediaStream* aStream);
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "MediaElementAudioSourceNode";
   }
 
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
   {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
--- a/dom/media/webaudio/MediaStreamAudioDestinationNode.h
+++ b/dom/media/webaudio/MediaStreamAudioDestinationNode.h
@@ -29,17 +29,17 @@ public:
 
   virtual void DestroyMediaStream() MOZ_OVERRIDE;
 
   DOMMediaStream* DOMStream() const
   {
     return mDOMStream;
   }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "MediaStreamAudioDestinationNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
+++ b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
@@ -4,16 +4,17 @@
  * 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 "MediaStreamAudioSourceNode.h"
 #include "mozilla/dom/MediaStreamAudioSourceNodeBinding.h"
 #include "AudioNodeEngine.h"
 #include "AudioNodeExternalInputStream.h"
 #include "nsIDocument.h"
+#include "mozilla/CORSMode.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(MediaStreamAudioSourceNode)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MediaStreamAudioSourceNode)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputStream)
@@ -65,32 +66,33 @@ MediaStreamAudioSourceNode::~MediaStream
  * media that they are not authorized to receive.
  *
  * One solution is to block the altered content, call this method, then dispatch
  * another change request to the MediaStreamGraph thread that allows the content
  * under the new principal to flow.  This might be unnecessary if the principal
  * change is changing to be the document principal.
  */
 void
-MediaStreamAudioSourceNode::PrincipalChanged(DOMMediaStream* ms)
+MediaStreamAudioSourceNode::PrincipalChanged(DOMMediaStream* aDOMMediaStream)
 {
   bool subsumes = false;
   nsPIDOMWindow* parent = Context()->GetParentObject();
   if (parent) {
     nsIDocument* doc = parent->GetExtantDoc();
     if (doc) {
       nsIPrincipal* docPrincipal = doc->NodePrincipal();
       nsIPrincipal* streamPrincipal = mInputStream->GetPrincipal();
       if (NS_FAILED(docPrincipal->Subsumes(streamPrincipal, &subsumes))) {
         subsumes = false;
       }
     }
   }
   auto stream = static_cast<AudioNodeExternalInputStream*>(mStream.get());
-  stream->SetInt32Parameter(MediaStreamAudioSourceNodeEngine::ENABLE, subsumes);
+  stream->SetInt32Parameter(MediaStreamAudioSourceNodeEngine::ENABLE,
+                            subsumes || aDOMMediaStream->GetCORSMode() != CORS_NONE);
 }
 
 size_t
 MediaStreamAudioSourceNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
 {
   // Future:
   // - mInputStream
   size_t amount = AudioNode::SizeOfExcludingThis(aMallocSizeOf);
--- a/dom/media/webaudio/MediaStreamAudioSourceNode.h
+++ b/dom/media/webaudio/MediaStreamAudioSourceNode.h
@@ -49,17 +49,17 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamAudioSourceNode, AudioNode)
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   virtual void DestroyMediaStream() MOZ_OVERRIDE;
 
   virtual uint16_t NumberOfInputs() const MOZ_OVERRIDE { return 0; }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "MediaStreamAudioSourceNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
   virtual void PrincipalChanged(DOMMediaStream* aMediaStream) MOZ_OVERRIDE;
--- a/dom/media/webaudio/OscillatorNode.cpp
+++ b/dom/media/webaudio/OscillatorNode.cpp
@@ -111,27 +111,27 @@ public:
       mDetune = aValue;
       WebAudioUtils::ConvertAudioParamToTicks(mDetune, mSource, mDestination);
       break;
     default:
       NS_ERROR("Bad OscillatorNodeEngine TimelineParameter");
     }
   }
 
-  virtual void SetStreamTimeParameter(uint32_t aIndex, StreamTime aParam)
+  virtual void SetStreamTimeParameter(uint32_t aIndex, StreamTime aParam) MOZ_OVERRIDE
   {
     switch (aIndex) {
     case START: mStart = aParam; break;
     case STOP: mStop = aParam; break;
     default:
       NS_ERROR("Bad OscillatorNodeEngine StreamTimeParameter");
     }
   }
 
-  virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam)
+  virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam) MOZ_OVERRIDE
   {
     switch (aIndex) {
       case TYPE:
         // Set the new type.
         mType = static_cast<OscillatorType>(aParam);
         if (mType != OscillatorType::Custom) {
           // Forget any previous custom data.
           mCustomLength = 0;
@@ -178,17 +178,17 @@ public:
         mCustomLength = static_cast<uint32_t>(aParam);
         break;
       default:
         NS_ERROR("Bad OscillatorNodeEngine Int32Parameter.");
     }
     // End index switch.
   }
 
-  virtual void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer)
+  virtual void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer) MOZ_OVERRIDE
   {
     MOZ_ASSERT(mCustomLength, "Custom buffer sent before length");
     mCustom = aBuffer;
     MOZ_ASSERT(mCustom->GetChannels() == 2,
                "PeriodicWave should have sent two channels");
     mPeriodicWave = WebCore::PeriodicWave::create(mSource->SampleRate(),
     mCustom->GetData(0), mCustom->GetData(1), mCustomLength);
   }
--- a/dom/media/webaudio/OscillatorNode.h
+++ b/dom/media/webaudio/OscillatorNode.h
@@ -75,17 +75,17 @@ public:
     mType = OscillatorType::Custom;
     SendTypeToStream();
   }
 
   IMPL_EVENT_HANDLER(ended)
 
   virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "OscillatorNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/PannerNode.h
+++ b/dom/media/webaudio/PannerNode.h
@@ -190,17 +190,17 @@ public:
     SendDoubleParameterToStream(CONE_OUTER_GAIN, mConeOuterGain);
   }
 
   float ComputeDopplerShift();
   void SendDopplerToSourcesIfNeeded();
   void FindConnectedSources();
   void FindConnectedSources(AudioNode* aNode, nsTArray<AudioBufferSourceNode*>& aSources, std::set<AudioNode*>& aSeenNodes);
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "PannerNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/ScriptProcessorNode.h
+++ b/dom/media/webaudio/ScriptProcessorNode.h
@@ -83,17 +83,17 @@ public:
 
   uint32_t NumberOfOutputChannels() const
   {
     return mNumberOfOutputChannels;
   }
 
   using DOMEventTargetHelper::DispatchTrustedEvent;
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "ScriptProcessorNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/StereoPannerNode.h
+++ b/dom/media/webaudio/StereoPannerNode.h
@@ -43,17 +43,17 @@ public:
   AudioParam* Pan() const
   {
     return mPan;
   }
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(StereoPannerNode, AudioNode)
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "StereoPannerNode";
   }
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 protected:
--- a/dom/media/webaudio/WaveShaperNode.cpp
+++ b/dom/media/webaudio/WaveShaperNode.cpp
@@ -212,17 +212,17 @@ public:
         }
       }
     }
   }
 
   virtual void ProcessBlock(AudioNodeStream* aStream,
                             const AudioChunk& aInput,
                             AudioChunk* aOutput,
-                            bool* aFinished)
+                            bool* aFinished) MOZ_OVERRIDE
   {
     uint32_t channelCount = aInput.mChannelData.Length();
     if (!mCurve.Length() || !channelCount) {
       // Optimize the case where we don't have a curve buffer,
       // or the input is null.
       *aOutput = aInput;
       return;
     }
--- a/dom/media/webaudio/WaveShaperNode.h
+++ b/dom/media/webaudio/WaveShaperNode.h
@@ -43,17 +43,17 @@ public:
 
   virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
   {
     // Possibly track in the future:
     // - mCurve
     return AudioNode::SizeOfExcludingThis(aMallocSizeOf);
   }
 
-  virtual const char* NodeType() const
+  virtual const char* NodeType() const MOZ_OVERRIDE
   {
     return "WaveShaperNode";
   }
 
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
   {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/corsServer.sjs
@@ -0,0 +1,26 @@
+function handleRequest(request, response)
+{
+  var file = Components.classes["@mozilla.org/file/directory_service;1"].
+                        getService(Components.interfaces.nsIProperties).
+                        get("CurWorkD", Components.interfaces.nsILocalFile);
+  var fis  = Components.classes['@mozilla.org/network/file-input-stream;1'].
+                        createInstance(Components.interfaces.nsIFileInputStream);
+  var bis  = Components.classes["@mozilla.org/binaryinputstream;1"].
+                        createInstance(Components.interfaces.nsIBinaryInputStream);
+  var paths = "tests/dom/media/webaudio/test/small-shot.ogg";
+  var split = paths.split("/");
+  for(var i = 0; i < split.length; ++i) {
+    file.append(split[i]);
+  }
+  fis.init(file, -1, -1, false);
+  bis.setInputStream(fis);
+  var bytes = bis.readBytes(bis.available());
+  response.setHeader("Content-Duration", "0.233", false);
+  response.setHeader("Content-Type", "video/ogg", false);
+  response.setHeader("Content-Length", ""+ bytes.length, false);
+  response.setHeader("Access-Control-Allow-Origin", "*", false);
+  response.write(bytes, bytes.length);
+  response.processAsync();
+  response.finish();
+  bis.close();
+}
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -2,16 +2,17 @@
 skip-if = ((buildapp == 'mulet' || buildapp == 'b2g') && (toolkit != 'gonk' || debug)) || (os == 'win' && strictContentSandbox) #b2g-debug,b2g-desktop(bug 916135); strictContentSandbox(Bug 1042735)
 support-files =
   audio-expected.wav
   audio-mono-expected-2.wav
   audio-mono-expected.wav
   audio-quad.wav
   audio.ogv
   audioBufferSourceNodeNeutered_worker.js
+  corsServer.sjs
   invalid.txt
   layouttest-glue.js
   noaudio.webm
   small-shot-expected.wav
   small-shot-mono-expected.wav
   small-shot.ogg
   small-shot.mp3
   ting-44.1k-1ch.ogg
@@ -104,16 +105,17 @@ skip-if = toolkit == 'android' # bug 105
 [test_dynamicsCompressorNodePassThrough.html]
 [test_gainNode.html]
 [test_gainNodeInLoop.html]
 [test_gainNodePassThrough.html]
 [test_maxChannelCount.html]
 [test_mediaDecoding.html]
 [test_mediaElementAudioSourceNode.html]
 [test_mediaElementAudioSourceNodePassThrough.html]
+[test_mediaElementAudioSourceNodeCrossOrigin.html]
 [test_mediaStreamAudioDestinationNode.html]
 [test_mediaStreamAudioSourceNode.html]
 [test_mediaStreamAudioSourceNodeCrossOrigin.html]
 [test_mediaStreamAudioSourceNodePassThrough.html]
 [test_mediaStreamAudioSourceNodeResampling.html]
 [test_mixingRules.html]
 skip-if = android_version == '10' # bug 1091965
 [test_mozaudiochannel.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/test_mediaElementAudioSourceNodeCrossOrigin.html
@@ -0,0 +1,89 @@
+<!DOCTYPE HTML>
+<html>
+<meta charset="utf-8">
+<head>
+  <title>Test MediaStreamAudioSourceNode doesn't get data from cross-origin media resources</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+var tests = [
+  // Not the same origin no CORS asked for, should have silence
+  { url: "http://example.org:80/tests/dom/media/webaudio/test/small-shot.ogg",
+    cors: null,
+    expectSilence: true },
+  // Same origin, should have sound
+  { url: "small-shot.ogg",
+    cors: null,
+    expectSilence: false },
+  // Cross-origin but we asked for CORS and the server answered with the right
+  // header, should have
+  { url: "http://example.org:80/tests/dom/media/webaudio/test/corsServer.sjs",
+    cors: "anonymous",
+    expectSilence: false }
+];
+
+var testsRemaining = tests.length;
+
+tests.forEach(function(e) {
+  e.ac = new AudioContext();
+  var a = new Audio();
+  a.loop = true;
+  if (e.cors) {
+    a.crossOrigin = e.cors;
+  }
+  a.src = e.url;
+  a.controls = true;
+  var measn = e.ac.createMediaElementSource(a);
+  var sp = e.ac.createScriptProcessor(2048, 1);
+  // Set a couple expandos to track the status of the test
+  sp.iterationsLeft = 20;
+  sp.seenSound = false;
+
+  measn.connect(sp);
+  a.play();
+  document.body.appendChild(a);
+
+  function checkFinished(sp) {
+    if (--sp.iterationsLeft == 0) {
+      sp.onaudioprocess = null;
+      a.pause();
+      var not = e.expectSilence ? "" : "not";
+      is(e.expectSilence, !sp.seenSound,
+         "Buffer is " + not + " silent as expected, for " +
+         e.url + " (cors: " + e.cors + ")");
+      if (--testsRemaining == 0) {
+        SimpleTest.finish();
+      }
+    }
+  }
+
+  function checkBufferSilent(e) {
+    var inputArrayBuffer = e.inputBuffer.getChannelData(0);
+    var silent = true;
+    for (var i = 0; i < inputArrayBuffer.length; i++) {
+      if (inputArrayBuffer[i] != 0.0) {
+        silent = false;
+        break;
+      }
+    }
+    // It is acceptable to find a full buffer of silence here, even if we expect
+    // sound, because Gecko's looping on media elements is not seamless and we
+    // can underrun. We are looking for at least one buffer of non-silent data.
+    e.target.seenSound = !silent || e.target.seenSound;
+    checkFinished(e.target);
+    return silent;
+  }
+
+  a.onplaying = function () {
+    sp.onaudioprocess = checkBufferSilent;
+  }
+});
+</script>
+</pre>
+</body>
+</html>
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -808,17 +808,17 @@ PluginInstanceParent::CreateBackground(c
     // can read from the region while we're writing to it.
     mBackground =
         gfxSharedImageSurface::CreateUnsafe(
             this,
             gfxIntSize(aSize.width, aSize.height),
             gfxImageFormat::RGB24);
     return !!mBackground;
 #else
-    return nullptr;
+    return false;
 #endif
 }
 
 void
 PluginInstanceParent::DestroyBackground()
 {
     if (!mBackground) {
         return;
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -375,21 +375,18 @@ AudioManager::Observe(nsISupports* aSubj
   else if (!strcmp(aTopic, AUDIO_CHANNEL_PROCESS_CHANGED)) {
     HandleAudioChannelProcessChanged();
     return NS_OK;
   }
 
   // To process the volume control on each audio channel according to
   // change of settings
   else if (!strcmp(aTopic, MOZ_SETTINGS_CHANGE_ID)) {
-    AutoJSAPI jsapi;
-    jsapi.Init();
-    JSContext* cx = jsapi.cx();
-    RootedDictionary<dom::SettingChangeNotification> setting(cx);
-    if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+    RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
+    if (!WrappedJSToDictionary(aSubject, setting)) {
       return NS_OK;
     }
     if (!setting.mKey.EqualsASCII("audio.volume.bt_sco")) {
       return NS_OK;
     }
     if (!setting.mValue.isNumber()) {
       return NS_OK;
     }
--- a/dom/system/gonk/AutoMounterSetting.cpp
+++ b/dom/system/gonk/AutoMounterSetting.cpp
@@ -4,16 +4,17 @@
 
 #include "AutoMounter.h"
 #include "AutoMounterSetting.h"
 
 #include "base/message_loop.h"
 #include "jsapi.h"
 #include "mozilla/Services.h"
 #include "nsCOMPtr.h"
+#include "nsContentUtils.h"
 #include "nsDebug.h"
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
 #include "nsJSUtils.h"
 #include "nsPrintfCString.h"
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
@@ -119,18 +120,17 @@ AutoMounterSetting::AutoMounterSetting()
     do_GetService("@mozilla.org/settingsService;1");
   if (!settingsService) {
     ERR("Failed to get settingsLock service!");
     return;
   }
   nsCOMPtr<nsISettingsServiceLock> lock;
   settingsService->CreateLock(nullptr, getter_AddRefs(lock));
   nsCOMPtr<nsISettingsServiceCallback> callback = new SettingsServiceCallback();
-  mozilla::AutoSafeJSContext cx;
-  JS::Rooted<JS::Value> value(cx);
+  JS::Rooted<JS::Value> value(nsContentUtils::RootingCx());
   value.setInt32(AUTOMOUNTER_DISABLE);
   lock->Set(UMS_MODE, value, callback, nullptr);
   value.setInt32(mStatus);
   lock->Set(UMS_STATUS, value, nullptr, nullptr);
 }
 
 AutoMounterSetting::~AutoMounterSetting()
 {
@@ -235,21 +235,18 @@ AutoMounterSetting::Observe(nsISupports*
   }
 
   // Note that this function gets called for any and all settings changes,
   // so we need to carefully check if we have the one we're interested in.
   //
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"ums.autoMount","value":true}
 
-  AutoJSAPI jsapi;
-  jsapi.Init();
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<SettingChangeNotification> setting(cx);
-  if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+  RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
+  if (!WrappedJSToDictionary(aSubject, setting)) {
     return NS_OK;
   }
 
   // Check for ums.mode changes
   if (setting.mKey.EqualsASCII(UMS_MODE)) {
     if (!setting.mValue.isInt32()) {
       return NS_OK;
     }
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -1019,21 +1019,18 @@ GonkGPSGeolocationProvider::Observe(nsIS
     }
 
     RequestSettingValue("ril.supl.apn");
   }
 #endif
 
   if (!strcmp(aTopic, kMozSettingsChangedTopic)) {
     // Read changed setting value
-    AutoJSAPI jsapi;
-    jsapi.Init();
-    JSContext* cx = jsapi.cx();
-    RootedDictionary<SettingChangeNotification> setting(cx);
-    if (!WrappedJSToDictionary(cx, aSubject, setting)) {
+    RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
+    if (!WrappedJSToDictionary(aSubject, setting)) {
       return NS_OK;
     }
 
     if (setting.mKey.EqualsASCII(kSettingDebugGpsIgnored)) {
       nsContentUtils::LogMessageToConsole("geo: received mozsettings-changed: ignoring\n");
       gDebug_isGPSLocationIgnored =
         setting.mValue.isBoolean() ? setting.mValue.toBoolean() : false;
       if (gDebug_isLoggingEnabled) {
--- a/dom/webidl/AudioContext.webidl
+++ b/dom/webidl/AudioContext.webidl
@@ -20,16 +20,17 @@ interface AudioContext : EventTarget {
     readonly attribute AudioDestinationNode destination;
     readonly attribute float sampleRate;
     readonly attribute double currentTime;
     readonly attribute AudioListener listener;
 
     [NewObject, Throws]
     AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long length, float sampleRate);
 
+    [Throws]
     Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData,
                                          optional DecodeSuccessCallback successCallback,
                                          optional DecodeErrorCallback errorCallback);
 
     // AudioNode creation
     [NewObject]
     AudioBufferSourceNode createBufferSource();
 
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -38,53 +38,53 @@ typedef any Transferable;
   [Throws] readonly attribute History history;
   [Replaceable, Throws] readonly attribute BarProp locationbar;
   [Replaceable, Throws] readonly attribute BarProp menubar;
   [Replaceable, Throws] readonly attribute BarProp personalbar;
   [Replaceable, Throws] readonly attribute BarProp scrollbars;
   [Replaceable, Throws] readonly attribute BarProp statusbar;
   [Replaceable, Throws] readonly attribute BarProp toolbar;
   [Throws] attribute DOMString status;
-  [Throws, CrossOriginCallable] void close();
+  [Throws, CrossOriginCallable, UnsafeInPrerendering] void close();
   [Throws, CrossOriginReadable] readonly attribute boolean closed;
   [Throws] void stop();
-  [Throws, CrossOriginCallable] void focus();
+  [Throws, CrossOriginCallable, UnsafeInPrerendering] void focus();
   [Throws, CrossOriginCallable] void blur();
 
   // other browsing contexts
   [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy frames;
   [Replaceable, CrossOriginReadable] readonly attribute unsigned long length;
   //[Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy top;
   [Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy? top;
   [Throws, CrossOriginReadable] attribute any opener;
   //[Throws] readonly attribute WindowProxy parent;
   [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy? parent;
   [Throws] readonly attribute Element? frameElement;
   //[Throws] WindowProxy open(optional DOMString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "", optional boolean replace = false);
-  [Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = "");
+  [Throws, UnsafeInPrerendering] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = "");
   // We think the indexed getter is a bug in the spec, it actually needs to live
   // on the WindowProxy
   //getter WindowProxy (unsigned long index);
   getter object (DOMString name);
 
   // the user agent
   [Throws] readonly attribute Navigator navigator; 
 #ifdef HAVE_SIDEBAR
   [Replaceable, Throws] readonly attribute External external;
 #endif
   [Throws] readonly attribute ApplicationCache applicationCache;
 
   // user prompts
-  [Throws] void alert();
-  [Throws] void alert(DOMString message);
-  [Throws] boolean confirm(optional DOMString message = "");
-  [Throws] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
-  [Throws] void print();
+  [Throws, UnsafeInPrerendering] void alert();
+  [Throws, UnsafeInPrerendering] void alert(DOMString message);
+  [Throws, UnsafeInPrerendering] boolean confirm(optional DOMString message = "");
+  [Throws, UnsafeInPrerendering] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
+  [Throws, UnsafeInPrerendering] void print();
   //[Throws] any showModalDialog(DOMString url, optional any argument);
-  [Throws, Func="nsGlobalWindow::IsShowModalDialogEnabled"]
+  [Throws, Func="nsGlobalWindow::IsShowModalDialogEnabled", UnsafeInPrerendering]
   any showModalDialog(DOMString url, optional any argument, optional DOMString options = "");
 
   [Throws, CrossOriginCallable] void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);
 
   // also has obsolete members
 };
 Window implements GlobalEventHandlers;
 Window implements WindowEventHandlers;
@@ -163,20 +163,20 @@ partial interface Window {
   //[SameObject]
   [Throws] readonly attribute Screen screen;
 
   // browsing context
   //[Throws] void moveTo(double x, double y);
   //[Throws] void moveBy(double x, double y);
   //[Throws] void resizeTo(double x, double y);
   //[Throws] void resizeBy(double x, double y);
-  [Throws] void moveTo(long x, long y);
-  [Throws] void moveBy(long x, long y);
-  [Throws] void resizeTo(long x, long y);
-  [Throws] void resizeBy(long x, long y);
+  [Throws, UnsafeInPrerendering] void moveTo(long x, long y);
+  [Throws, UnsafeInPrerendering] void moveBy(long x, long y);
+  [Throws, UnsafeInPrerendering] void resizeTo(long x, long y);
+  [Throws, UnsafeInPrerendering] void resizeBy(long x, long y);
 
   // viewport
   //[Throws] readonly attribute double innerWidth;
   //[Throws] readonly attribute double innerHeight;
   [Throws] attribute long innerWidth;
   [Throws] attribute long innerHeight;
 
   // viewport scrolling
@@ -281,59 +281,59 @@ partial interface Window {
   /**
    * Method for scrolling this window by a number of pages.
    */
   void                      scrollByPages(long numPages, optional ScrollOptions options);
 
   /**
    * Method for sizing this window to the content in the window.
    */
-  [Throws] void             sizeToContent();
+  [Throws, UnsafeInPrerendering] void             sizeToContent();
 
   // XXX Shouldn't this be in nsIDOMChromeWindow?
   [ChromeOnly, Replaceable, Throws] readonly attribute MozControllers controllers;
 
   [ChromeOnly, Throws] readonly attribute Element? realFrameElement;
 
   [Throws] readonly attribute float               mozInnerScreenX;
   [Throws] readonly attribute float               mozInnerScreenY;
   [Throws] readonly attribute float               devicePixelRatio;
 
   /* The maximum offset that the window can be scrolled to
      (i.e., the document width/height minus the scrollport width/height) */
   [Replaceable, Throws] readonly attribute long   scrollMaxX;
   [Replaceable, Throws] readonly attribute long   scrollMaxY;
 
-  [Throws] attribute boolean                            fullScreen;
+  [Throws, UnsafeInPrerendering] attribute boolean            fullScreen;
 
-  [Throws, ChromeOnly] void             back();
-  [Throws, ChromeOnly] void             forward();
-  [Throws, ChromeOnly] void             home();
+  [Throws, ChromeOnly, UnsafeInPrerendering] void             back();
+  [Throws, ChromeOnly, UnsafeInPrerendering] void             forward();
+  [Throws, ChromeOnly, UnsafeInPrerendering] void             home();
 
   // XXX Should this be in nsIDOMChromeWindow?
   void                      updateCommands(DOMString action,
                                            optional Selection? sel = null,
                                            optional short reason = 0);
 
   /* Find in page.
    * @param str: the search pattern
    * @param caseSensitive: is the search caseSensitive
    * @param backwards: should we search backwards
    * @param wrapAround: should we wrap the search
    * @param wholeWord: should we search only for whole words
    * @param searchInFrames: should we search through all frames
    * @param showDialog: should we show the Find dialog
    */
-  [Throws] boolean          find(optional DOMString str = "",
-                                 optional boolean caseSensitive = false,
-                                 optional boolean backwards = false,
-                                 optional boolean wrapAround = false,
-                                 optional boolean wholeWord = false,
-                                 optional boolean searchInFrames = false,
-                                 optional boolean showDialog = false);
+  [Throws, UnsafeInPrerendering] boolean    find(optional DOMString str = "",
+                                                 optional boolean caseSensitive = false,
+                                                 optional boolean backwards = false,
+                                                 optional boolean wrapAround = false,
+                                                 optional boolean wholeWord = false,
+                                                 optional boolean searchInFrames = false,
+                                                 optional boolean showDialog = false);
 
   /**
    * Returns the number of times this document for this window has
    * been painted to the screen.
    */
   [Throws] readonly attribute unsigned long long mozPaintCount;
 
   /**
@@ -368,20 +368,20 @@ partial interface Window {
   void                      setResizable(boolean resizable);
 
   /**
    * This is the scriptable version of
    * nsIDOMWindow::openDialog() that takes 3 optional
    * arguments, plus any additional arguments are passed on as
    * arguments on the dialog's window object (window.arguments).
    */
-  [Throws, ChromeOnly] WindowProxy? openDialog(optional DOMString url = "",
-                                               optional DOMString name = "",
-                                               optional DOMString options = "",
-                                               any... extraArguments);
+  [Throws, ChromeOnly, UnsafeInPrerendering] WindowProxy? openDialog(optional DOMString url = "",
+                                                                   optional DOMString name = "",
+                                                                   optional DOMString options = "",
+                                                                   any... extraArguments);
 
   [Replaceable, Throws] readonly attribute object? content;
 
   [ChromeOnly, Throws] readonly attribute object? __content;
 
   [Throws, ChromeOnly] any getInterface(IID iid);
 };
 
@@ -429,21 +429,21 @@ interface ChromeWindow {
   void                      getAttention();
 
   [Throws, Func="nsGlobalWindow::IsChromeWindow"]
   void                      getAttentionWithCycleCount(long aCycleCount);
 
   [Throws, Func="nsGlobalWindow::IsChromeWindow"]
   void                      setCursor(DOMString cursor);
 
-  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
+  [Throws, Func="nsGlobalWindow::IsChromeWindow", UnsafeInPrerendering]
   void                      maximize();
-  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
+  [Throws, Func="nsGlobalWindow::IsChromeWindow", UnsafeInPrerendering]
   void                      minimize();
-  [Throws, Func="nsGlobalWindow::IsChromeWindow"]
+  [Throws, Func="nsGlobalWindow::IsChromeWindow", UnsafeInPrerendering]
   void                      restore();
 
   /**
    * Notify a default button is loaded on a dialog or a wizard.
    * defaultButton is the default button.
    */
   [Throws, Func="nsGlobalWindow::IsChromeWindow"]
   void notifyDefaultButtonLoaded(Element defaultButton);
--- a/dom/workers/DataStore.cpp
+++ b/dom/workers/DataStore.cpp
@@ -24,17 +24,17 @@ BEGIN_WORKERS_NAMESPACE
 
 NS_IMPL_ADDREF_INHERITED(WorkerDataStore, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(WorkerDataStore, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN(WorkerDataStore)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 WorkerDataStore::WorkerDataStore(WorkerGlobalScope* aScope)
-  : DOMEventTargetHelper(aScope)
+  : DOMEventTargetHelper(static_cast<DOMEventTargetHelper*>(aScope))
 {}
 
 already_AddRefed<WorkerDataStore>
 WorkerDataStore::Constructor(GlobalObject& aGlobal, ErrorResult& aRv)
 {
   // We don't allow Gecko to create WorkerDataStore through JS codes like
   // window.DataStore() on the worker, so disable this for now.
   NS_NOTREACHED("Cannot use the chrome constructor on the worker!");
--- a/dom/xul/templates/nsTemplateMatch.cpp
+++ b/dom/xul/templates/nsTemplateMatch.cpp
@@ -1,21 +1,16 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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 "nsTemplateMatch.h"
 #include "nsTemplateRule.h"
 
-#ifdef NEED_CPP_UNUSED_IMPLEMENTATIONS
-nsTemplateMatch::nsTemplateMatch(const nsTemplateMatch& aMatch) {}
-void nsTemplateMatch::operator=(const nsTemplateMatch& aMatch) {}
-#endif
-
 // static
 void
 nsTemplateMatch::Destroy(nsTemplateMatch*& aMatch, bool aRemoveResult)
 {
     if (aRemoveResult && aMatch->mResult)
         aMatch->mResult->HasBeenRemoved();
     ::delete aMatch;
     aMatch = nullptr;
--- a/dom/xul/templates/nsTemplateMatch.h
+++ b/dom/xul/templates/nsTemplateMatch.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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 nsTemplateMatch_h__
 #define nsTemplateMatch_h__
 
+#include "mozilla/Attributes.h"
 #include "nsIContent.h"
 #include "nsIXULTemplateQueryProcessor.h"
 #include "nsIXULTemplateResult.h"
 #include "nsRuleNetwork.h"
 
 /**
  * A match object, where each match object is associated with one result.
  * There will be one match list for each unique id generated. However, since
@@ -125,14 +126,14 @@ public:
      * match that has a rule set (mRule) is the active match and generates
      * content. The next match is owned by the builder, which will delete
      * template matches when needed.
      */
     nsTemplateMatch *mNext;
 
 private:
 
-    nsTemplateMatch(const nsTemplateMatch& aMatch); // not to be implemented
-    void operator=(const nsTemplateMatch& aMatch); // not to be implemented
+    nsTemplateMatch(const nsTemplateMatch& aMatch) MOZ_DELETE;
+    void operator=(const nsTemplateMatch& aMatch) MOZ_DELETE;
 };
 
 #endif // nsTemplateMatch_h__
 
--- a/extensions/spellcheck/locales/en-US/hunspell/dictionary-sources/upstream-hunspell.diff
+++ b/extensions/spellcheck/locales/en-US/hunspell/dictionary-sources/upstream-hunspell.diff
@@ -10112,1308 +10112,1310 @@ 26915,26916c32636
 < heat's
 < heat/ADGS
 ---
 > heat/ADGSM
 27167c32887
 < hexane
 ---
 > hexane/SM
-27256,27257c32976
+27227a32948
+> hijab/S
+27256,27257c32977
 < hinge's
 < hinge/UDSG
 ---
 > hinge/UDSGM
-27273a32993
+27273a32994
 > hippopotami
-27276,27277c32996
+27276,27277c32997
 < hire's
 < hire/AGDS
 ---
 > hire/AGDSM
-27302,27303c33021
+27302,27303c33022
 < hitch's
 < hitch/UDSG
 ---
 > hitch/UDSGM
-27512,27513c33230
+27512,27513c33231
 < hook's
 < hook/UDSG
 ---
 > hook/UDSGM
-27575,27576c33292
+27575,27576c33293
 < horse's
 < horse/UDSG
 ---
 > horse/UDSGM
-27666,27667c33382
+27666,27667c33383
 < house's
 < house/ADSG
 ---
 > house/ADSGM
-27841c33556
+27841c33557
 < hurrah's
 ---
 > hurrah/M
-27875d33589
+27875d33590
 < hyaena/SM
-27883,27884c33597
+27883,27884c33598
 < hydrate's
 < hydrate/CGNDS
 ---
 > hydrate/CGNDSM
-28017c33730
+28017c33731
 < iPod/M
 ---
 > iPod/MS
-28029,28030c33742
+28029,28030c33743
 < ice's
 < ice/CDSG
 ---
 > ice/CDSGM
-28105a33818
+28105a33819
 > idolator/SM
-28227c33940
+28227c33941
 < immerse/XDSGN
 ---
 > immerse/XDSGNV
-28513c34226
+28513c34227
 < inbound
 ---
 > inbound/s
-28531,28532c34244,34245
+28531,28532c34245,34246
 < incentive's
 < incentive/ES
 ---
 > incentive/ESM
 > incentivize/SDG
-28560,28561c34273
+28560,28561c34274
 < incline's
 < incline/EGDS
 ---
 > incline/EGDSM
-28590,28591c34302
+28590,28591c34303
 < incorrigibility/M
 < incorrigible
 ---
 > incorrigibleness
-28593d34303
+28593d34304
 < incorruptibly
-28650a34361
+28650a34362
 > indices
-28812d34522
+28812d34523
 < inflexion/SM
-28981,28982c34691
+28981,28982c34692
 < insert's
 < insert/AGSD
 ---
 > insert/AGSDM
-29204a34914
+29204a34915
 > intermediacy/S
-29206c34916,34918
+29206c34917,34919
 < intermediate/SMY
 ---
 > intermediate/SMYPGD
 > intermediation/SE
 > intermediator/SM
-29216a34929
+29216a34930
 > intern/GDL
-29266a34980
+29266a34981
 > interruptible/U
-29272a34987,34990
+29272a34988,34991
 > intersex
 > intersexual/MS
 > intersexualism
 > intersexuality
-29446c35164
+29446c35165
 < ironic
 ---
 > ironic/U
-29447a35166
+29447a35167
 > ironically/U
-29724c35443
+29724c35444
 < jewellery's
 ---
 > jewellery/M
-29733,29734c35452
+29733,29734c35453
 < jig's
 < jig/AS
 ---
 > jig/ASM
-29736,29737c35454
+29736,29737c35455
 < jigger's
 < jigger/ASDG
 ---
 > jigger/ASDGM
-29799,29800c35516
+29799,29800c35517
 < join's
 < join/AFDSG
 ---
 > join/AFDSGM
-29803,29804c35519
+29803,29804c35520
 < joint's
 < joint/EGSD
 ---
 > joint/EGSDM
-29869,29870c35584,35585
+29869,29870c35585,35586
 < judge's
 < judge/ADSG
 ---
 > judge/ADSGM
 > judgement/MS
-30035a35751,35752
+30035a35752,35753
 > keylogger/MS
 > keylogging/MS
-30066c35783
+30066c35784
 < kiddie/M
 ---
 > kiddie/SM
-30102,30103c35819
+30102,30103c35820
 < kind's
 < kind/UPRYT
 ---
 > kind/UPRYTM
-30262,30263c35978
+30262,30263c35979
 < kraut's
 < kraut/S!
 ---
 > kraut/MS!
-30283,30284c35998
+30283,30284c35999
 < label's
 < label/ASDG
 ---
 > label/ASDGM
-30302,30303c36016
+30302,30303c36017
 < lace's
 < lace/UGDS
 ---
 > lace/UGDSM
-30497,30498c36210
+30497,30498c36211
 < latch's
 < latch/UDSG
 ---
 > latch/UDSGM
-30637c36349
+30637c36350
 < learning's
 ---
 > learning/M
-30643,30644c36355
+30643,30644c36356
 < leash's
 < leash/UDSG
 ---
 > leash/UDSGM
-30665a36377
+30665a36378
 > lector/MS
-30700c36412
+30700c36413
 < legation's/AC
 ---
 > legation/ACM
-30927,30928c36639
+30927,30928c36640
 < light's/C
 < light/CASTGD
 ---
 > light/CASTGDM
-30938c36649
+30938c36650
 < lighting's
 ---
 > lighting/M
-30981,30982c36692
+30981,30982c36693
 < limit's
 < limit/CSZGDR
 ---
 > limit/CSZGDRM
-30986c36696
+30986c36697
 < limiter's
 ---
 > limiter/M
-30990a36701,36703
+30990a36702,36704
 > limnological
 > limnologist/MS
 > limnology/M
-31031c36744
+31031c36745
 < linguini's
 ---
 > linguini/M
-31034c36747
+31034c36748
 < linguistically
 ---
 > linguistical/Y
-31047,31048c36760
+31047,31048c36761
 < lint's
 < lint/CDSG
 ---
 > lint/CDSGM
-31058a36771
+31058a36772
 > lepidopterist/SM
-31151,31152c36864
+31151,31152c36865
 < liver's
 < liver/S
 ---
 > liver/MS
-31170,31171c36882
+31170,31171c36883
 < load's
 < load/AUGSD
 ---
 > load/AUGSDM
-31211,31212c36922
+31211,31212c36923
 < location's/A
 < location/ESM
 ---
 > location/ESMA
-31291,31292c37001
+31291,31292c37002
 < long's
 < long/KDSTG
 ---
 > long/KDSTGM
-31379,31380c37088
+31379,31380c37089
 < louse's
 < louse/CDSG
 ---
 > louse/CDSGM
-31639a37348
+31639a37349
 > mage/SM
-31741,31742c37450
+31741,31742c37451
 < make's/A
 < make/UAGS
 ---
 > make/UAGSM
-31806a37515
+31806a37516
 > malware/MS
-31822,31823c37531
+31822,31823c37532
 < man's/F
 < man/USY
 ---
 > man/USYMF
-31924,31925c37632
+31924,31925c37633
 < mantle's
 < mantle/EGDS
 ---
 > mantle/EGDSM
-31940,31941c37647
+31940,31941c37648
 < map's
 < map/AS
 ---
 > map/ASM
-32061,32062c37767
+32061,32062c37768
 < mask's
 < mask/UDSG
 ---
 > mask/UDSGM
-32084,32085c37789
+32084,32085c37790
 < master's
 < master/ADGS
 ---
 > master/ADGSM
-32230c37934
+32230c37935
 < meanie/M
 ---
 > meanie/MS
-32246,32247c37950
+32246,32247c37951
 < measure's
 < measure/ADSG
 ---
 > measure/ADSGM
-32317,32318c38020
+32317,32318c38021
 < megadeath/M
 < megadeaths
 ---
 > megadeath/SM
-32320c38022
+32320c38023
 < megajoules
 ---
 > megajoule/SM
-32329c38031
+32329c38032
 < megapixel/S
 ---
 > megapixel/MS
-32361,32362c38063
+32361,32362c38064
 < melt's
 < melt/ADSG
 ---
 > melt/ADSGM
-32365,32366c38066
+32365,32366c38067
 < member's
 < member/EAS
 ---
 > member/EASM
-32386c38086
+32386c38087
 < men
 ---
 > men/M
-32708a38409
+32708a38410
 > might've
-32717a38419
+32717a38420
 > migrator/SM
-32760a38463
+32760a38464
 > millennia
-32777d38479
+32777d38480
 < millionnaire/M
-32806,32807c38508
+32806,32807c38509
 < mind's
 < mind/ADRSZG
 ---
 > mind/ADRSZGM
-32934a38636
+32934a38637
 > miscommunication/S
-32991a38694
+32991a38695
 > misjudgement/MS
-33027,33028c38730
+33027,33028c38731
 < miss's
 < miss/EDSGV
 ---
 > miss/EDSGVM
-33051,33052c38753
+33051,33052c38754
 < mist's
 < mist/CDRSZG
 ---
 > mist/CDRSZGM
-33056c38757
+33056c38758
 < mister's
 ---
 > mister/M
-33083c38784
+33083c38785
 < mitigation/M
 ---
 > mitigation/MS
-33107,33108c38808
+33107,33108c38809
 < mob's
 < mob/CS
 ---
 > mob/CSM
-33448,33449c39148
+33448,33449c39149
 < mortgage's
 < mortgage/AGDS
 ---
 > mortgage/AGDSM
-33471,33472c39170
+33471,33472c39171
 < mote's
 < mote/KCXSVN
 ---
 > mote/KCXSVNM
-33539,33540c39237
+33539,33540c39238
 < mounting's
 < mountings
 ---
 > mounting/MS
-33784a39482
+33784a39483
 > must've
-33887,33888c39585
+33887,33888c39586
 < name's
 < name/AGDS
 ---
 > name/AGDSM
-33963c39660
+33963c39661
 < native/MS
 ---
 > native/MSY
-33970,33971c39667
+33970,33971c39668
 < natural's
 < natural/UPY
 ---
 > natural/UPYM
-33979,33980c39675
+33979,33980c39676
 < nature's
 < nature/CS
 ---
 > nature/CSM
-34133,34134c39828
+34133,34134c39829
 < nerve's
 < nerve/UDSG
 ---
 > nerve/UDSGM
-34169,34171c39863,39865
+34169,34171c39864,39866
 < neurone/S
 < neurophysiology
 < neuroscience
 ---
 > neurophysiology/M
 > neuroscience/MS
 > neuroscientist/MS
-34175a39870
+34175a39871
 > neurosurgical
-34275c39970
+34275c39971
 < nightie/M
 ---
 > nightie/SM
-34388,34389c40083
+34388,34389c40084
 < nomination's/A
 < nomination/CSM
 ---
 > nomination/CSMA
-34755,34756c40449
+34755,34756c40450
 < note's
 < note/FCSDG
 ---
 > note/FCSDGM
-34840,34841c40533
+34840,34841c40534
 < number's
 < number/ASDG
 ---
 > number/ASDGM
-35104a40797
+35104a40798
 > octopi
-35137,35138c40830
+35137,35138c40831
 < offensive's
 < offensive/IYP
 ---
 > offensive/IYPM
-35219d40910
+35219d40911
 < oleomargarin/M
-35226a40918
+35226a40919
 > oligo
-35345c41037
+35345c41038
 < oppose/DSG
 ---
 > oppose/DSGRB
-35452,35453c41144
+35452,35453c41145
 < orient's
 < orient/AEDGS
 ---
 > orient/AEDGSM
-35913c41604
+35913c41605
 < oversize/D
 ---
 > oversize
-36031,36032c41722
+36031,36032c41723
 < pack's
 < pack/UADSG
 ---
 > pack/UADSGM
-36034,36035c41724
+36034,36035c41725
 < package's
 < package/AGDS
 ---
 > package/AGDSM
-36041c41730
+36041c41731
 < packing's
 ---
 > packing/M
-36056,36059d41744
+36056,36059d41745
 < paederast/S
 < paediatrician's
 < paediatricians
 < paediatrics/M
-36290a41976,41977
+36290a41977,41978
 > parallelization/SM
 > parallelize/SGD
-36291a41979
+36291a41980
 > paralyses
-36377a42066
+36377a42067
 > parkour
-36403d42091
+36403d42092
 < parrakeet/MS
-36418,36419c42106
+36418,36419c42107
 < part's
 < part/CDSG
 ---
 > part/CDSGM
-36445,36447c42132
+36445,36447c42133
 < partition's
 < partition/ADG
 < partitions
 ---
 > partition/ADGMS
-36449d42133
+36449d42134
 < partizan/SM
-36621,36622c42305
+36621,36622c42306
 < pay's
 < pay/ASGBL
 ---
 > pay/ASGBLM
-37093a42777
+37093a42778
 > petabyte/MS
-37102c42786
+37102c42787
 < petitioner/M
 ---
 > petitioner/MS
-37221a42906,42907
+37221a42907,42908
 > phlebotomist/SM
 > phlebotomize/SGD
-37228a42915
+37228a42916
 > pho
-37264a42952
+37264a42953
 > phosphorylate/DSGN
-37310,37311c42998
+37310,37311c42999
 < phrase's
 < phrase/AGDS
 ---
 > phrase/AGDSM
-37316d43002
+37316d43003
 < phrenetic
-37469,37470c43155
+37469,37470c43156
 < pine's
 < pine/AGDS
 ---
 > pine/AGDSM
-37596,37597c43281
+37596,37597c43282
 < place's
 < place/EAGLDS
 ---
 > place/EAGLDSM
-37630a43315
+37630a43316
 > plaintext
-37636,37637c43321
+37636,37637c43322
 < plane's
 < plane/CGDS
 ---
 > plane/CGDSM
-37786,37787c43470
+37786,37787c43471
 < ploy's
 < ploy/S
 ---
 > ploy/SM
-37792,37793c43475
+37792,37793c43476
 < plug's
 < plug/US
 ---
 > plug/USM
-37796a43479
+37796a43480
 > plugin/MS
-37987c43670
+37987c43671
 < polypeptide/S
 ---
 > polypeptide/MS
-38106,38107c43789
+38106,38107c43790
 < port's
 < port/CAEGDS
 ---
 > port/CAEGDSM
-38134,38135c43816
+38134,38135c43817
 < pose's/A
 < pose/CAKEGDS
 ---
 > pose/CAKEGDSM
-38140,38141c43821
+38140,38141c43822
 < position's/KC
 < position/ACKES
 ---
 > position/ACKESM
-38260,38261c43940
+38260,38261c43941
 < pound's
 < pound/KDSG
 ---
 > pound/KDSGM
-38266a43946
+38266a43947
 > poutine/S
-38291d43970
+38291d43971
 < practise's
-38451a44131
+38451a44132
 > prejudgement/MS
-38568,38569c44248
+38568,38569c44249
 < press's
 < press/ACGSD
 ---
 > press/ACGSDM
-38638,38639c44317
+38638,38639c44318
 < price's
 < price/AGDS
 ---
 > price/AGDSM
-38756,38757c44434
+38756,38757c44435
 < process's
 < process/AGDS
 ---
 > process/AGDSM
-38780,38781c44457
+38780,38781c44458
 < produce's
 < produce/AZGDRS
 ---
 > produce/AZGDRSM
-38805a44482
+38805a44483
 > profiler/SM
-38835a44513
+38835a44514
 > programmatically
-38891a44570,44571
+38891a44571,44572
 > pronate/DSGN
 > pronator/MS
-38951c44631
+38951c44632
 < proprietorship/M
 ---
 > proprietorship/MS
-39039a44720
+39039a44721
 > provender/M
-39095a44777
+39095a44778
 > pseudorandom/Y
-39564a45247
+39564a45248
 > quinoa
-39581,39582c45264
+39581,39582c45265
 < quire's
 < quire/IAS
 ---
 > quire/IASM
-39614,39615c45296
+39614,39615c45297
 < quote's
 < quote/UDSG
 ---
 > quote/UDSGM
-39653,39654c45334
+39653,39654c45335
 < racoon's
 < racoons
 ---
 > racoon/MS
-39738,39739c45418
+39738,39739c45419
 < rail's
 < rail/CGDS
 ---
 > rail/CGDSM
-39816,39817c45495
+39816,39817c45496
 < range's
 < range/CGDS
 ---
 > range/CGDSM
-39873a45552,45553
+39873a45553,45554
 > rasterization/M
 > rasterize/SGDR
-39925,39926c45605
+39925,39926c45606
 < ravel's
 < ravel/UDSG
 ---
 > ravel/UDSGM
-40036a45716
+40036a45717
 > recency
-40140a45821
+40140a45822
 > recurse/DGSV
-40141a45823
+40141a45824
 > recuse/DGS
-40204,40205c45886
+40204,40205c45887
 < reel's
 < reel/UGDS
 ---
 > reel/UGDSM
-40208a45890
+40208a45891
 > refactor/SMDG
-40244d45925
+40244d45926
 < reflexion/SM
-40659d46339
+40659d46340
 < resizing
-40829c46509
+40829c46510
 < reverie/M
 ---
 > reverie/MS
-40895a46576,46578
+40895a46577,46579
 > rheumatological
 > rheumatology/M
 > rheumatologist/SM
-40944,40945c46627
+40944,40945c46628
 < ride's
 < ride/CZGS
 ---
 > ride/CZGSM
-41104,41105c46786
+41104,41105c46787
 < robe's
 < robe/EGDS
 ---
 > robe/EGDSM
-41132,41133c46813
+41132,41133c46814
 < rogue's
 < rogue/KS
 ---
 > rogue/KSM
-41185a46866
+41185a46867
 > rootkit/MS
-41258,41259c46939
+41258,41259c46940
 < route's
 < route/ADSG
 ---
 > route/ADSGM
-41415a47096
+41415a47097
 > sabre/MS
-41447,41448c47128
+41447,41448c47129
 < saddle's
 < saddle/UDSG
 ---
 > saddle/UDSGM
-41463,41464c47143
+41463,41464c47144
 < safe's
 < safe/UYTPR
 ---
 > safe/UYTPRM
-41544,41545c47223
+41544,41545c47224
 < salt's
 < salt/CTGDS
 ---
 > salt/CTGDSM
-41765,41766c47443
+41765,41766c47444
 < say's
 < say/USG
 ---
 > say/USGM
-41787,41788c47464
+41787,41788c47465
 < scale's
 < scale/ACSDG
 ---
 > scale/ACSDGM
-41806,41807c47482
+41806,41807c47483
 < scan's
 < scan/AS
 ---
 > scan/ASM
-41880,41881c47555
+41880,41881c47556
 < schedule's
 < schedule/ADSG
 ---
 > schedule/ADSGM
-41914c47588
+41914c47589
 < schnaps's
 ---
 > schnaps/M
-41949c47623
+41949c47624
 < schrod's
 ---
 > schrod/SM
-41998a47673
+41998a47674
 > scot-free
-42016,42017c47691
+42016,42017c47692
 < scramble's
 < scramble/UGDS
 ---
 > scramble/UGDSM
-42055,42056c47729
+42055,42056c47730
 < screw's
 < screw/UDSG
 ---
 > screw/UDSGM
-42065,42066c47738
+42065,42066c47739
 < scribe's
 < scribe/IKCGSD
 ---
 > scribe/IKCGSDM
-42170,42171c47842
+42170,42171c47843
 < seal's
 < seal/AUSDG
 ---
 > seal/AUSDGM
-42204,42205c47875
+42204,42205c47876
 < seat's
 < seat/UGDS
 ---
 > seat/UGDSM
-42288,42289c47958
+42288,42289c47959
 < seed's
 < seed/AGDS
 ---
 > seed/AGDSM
-42359c48028,48029
+42359c48029,48030
 < self/M
 ---
 > self/MG
 > selfie/S
-42361a48032,48033
+42361a48033,48034
 > selfism
 > selfist/S
-42365,42367c48037,48038
+42365,42367c48038,48039
 < sell's
 < sell/AZGRS
 < seller's
 ---
 > sell/AZGRSM
 > seller/M
-42524c48195
+42524c48196
 < seraphim's
 ---
 > seraphim/M
-42558,42559c48229
+42558,42559c48230
 < serve's/AF
 < serve/FACGDS
 ---
 > serve/FACGDSM
-42574,42575c48244
+42574,42575c48245
 < serving's
 < servings
 ---
 > serving/MS
-42594,42595c48263
+42594,42595c48264
 < settle's
 < settle/AUGDS
 ---
 > settle/AUGDSM
-42647,42648c48315
+42647,42648c48316
 < shackle's
 < shackle/UGDS
 ---
 > shackle/UGDSM
-42716,42717c48383
+42716,42717c48384
 < shape's
 < shape/AGDS
 ---
 > shape/AGDSM
-42851,42852c48517
+42851,42852c48518
 < ship's
 < ship/ALS
 ---
 > ship/ALSM
-42883,42885c48548
+42883,42885c48549
 < shit's
 < shit/S!
 < shite/S!
 ---
 > shit/MS!
-42887,42888c48550,48551
+42887,42888c48551,48552
 < shithead/S!
 < shitload/!
 ---
 > shithead/MS!
 > shitload/MS!
-42891c48554
+42891c48555
 < shitty/RT!
 ---
 > shitty/TR!
-42976a48640
+42976a48641
 > should've
-43008c48672
+43008c48673
 < showtime
 ---
 > showtime/MS
-43090,43091c48754
+43090,43091c48755
 < side's
 < side/AGDS
 ---
 > side/AGDSM
-43143,43144c48806
+43143,43144c48807
 < sign's
 < sign/AFCGDS
 ---
 > sign/AFCGDSM
-43163,43164c48825
+43163,43164c48826
 < signing's/C
 < signings
 ---
 > signing/MCS
-43328c48989
+43328c48990
 < size/MGBDRS
 ---
 > size/AMGBDRS
-43368,43369c49029
+43368,43369c49030
 < skill's
 < skill/CSD
 ---
 > skill/CSDM
-43724,43726c49384
+43724,43726c49385
 < smoulder's
 < smouldered
 < smoulders
 ---
 > smoulder/GSMD
-43752,43753c49410
+43752,43753c49411
 < snap's
 < snap/US
 ---
 > snap/USM
-43767,43768c49424,49426
+43767,43768c49425,49427
 < snarl's
 < snarl/USDG
 ---
 > snarkily
 > snarky/TR
 > snarl/USDGM
-44012,44013c49670
+44012,44013c49671
 < solute's
 < solute/XN
 ---
 > solute/XNM
-44015c49672
+44015c49673
 < solution's/EA
 ---
 > solution/EAM
-44021c49678
+44021c49679
 < solver's
 ---
 > solver/M
-44041a49699
+44041a49700
 > sommelier/SM
-44062c49720
+44062c49721
 < sonofabitch
 ---
 > sonofabitch/!
-44177,44178c49835
+44177,44178c49836
 < sow's
 < sow/ASGD
 ---
 > sow/ASGDM
-44346a50004
+44346a50005
 > spelled
-44348a50007
+44348a50008
 > spelt
-44371a50031
+44371a50032
 > spick/S!
-44383c50043
+44383c50044
 < spik/S
 ---
 > spik/S!
-44413,44414c50073
+44413,44414c50074
 < spire's
 < spire/IFAS
 ---
 > spire/IFASM
-44416,44417c50075
+44416,44417c50076
 < spirit's
 < spirit/ISGD
 ---
 > spirit/ISGDM
-44475,44476c50133
+44475,44476c50134
 < spoil's
 < spoil/CSDRZG
 ---
 > spoil/CSDRZGM
-44549,44550c50206
+44549,44550c50207
 < spray's
 < spray/ASDG
 ---
 > spray/ASDGM
-44688,44689c50344
+44688,44689c50345
 < staff's
 < staff/ASDG
 ---
 > staff/ASDGM
-44729,44730c50384
+44729,44730c50385
 < stall's
 < stall/SDG
 ---
 > stall/SDGM
-44871a50526
+44871a50527
 > steampunk
-44985,44986c50640
+44985,44986c50641
 < still's
 < still/ITGSD
 ---
 > still/ITGSDM
-45024,45025c50678
+45024,45025c50679
 < stitch's
 < stitch/ADSG
 ---
 > stitch/ADSGM
-45030,45031c50683
+45030,45031c50684
 < stock's
 < stock/AGSD
 ---
 > stock/AGSDM
-45090,45091c50742
+45090,45091c50743
 < stop's
 < stop/US
 ---
 > stop/USM
-45105,45106c50756
+45105,45106c50757
 < store's
 < store/ADSG
 ---
 > store/ADSGM
-45148,45149c50798
+45148,45149c50799
 < strain's
 < strain/FADSG
 ---
 > strain/FADSGM
-45164,45165c50813
+45164,45165c50814
 < strap's
 < strap/US
 ---
 > strap/USM
-45290,45291c50938
+45290,45291c50939
 < structure's
 < structure/AGDS
 ---
 > structure/AGDSM
-45330,45331c50977
+45330,45331c50978
 < study's
 < study/AGDS
 ---
 > study/AGDSM
-45368,45369c51014
+45368,45369c51015
 < style's
 < style/ADSG
 ---
 > style/ADSGM
-45455,45456c51100
+45455,45456c51101
 < submission's
 < submission/AS
 ---
 > submission/ASM
-45872,45873c51516
+45872,45873c51517
 < surface's
 < surface/AGDS
 ---
 > surface/AGDSM
-45918,45919c51561
+45918,45919c51562
 < survey's
 < survey/ADGS
 ---
 > survey/ADGSM
-46106a51749
+46106a51750
 > syllabi
-46160c51803
+46160c51804
 < synch/GMD
 ---
 > synch/GMDS
-46167d51809
+46167d51810
 < synchs
-46178a51821,51823
+46178a51822,51824
 > synesthesia
 > synesthete/S
 > synesthetic
-46203,46204c51848,51849
+46203,46204c51849,51850
 < sysadmin/S
 < sysop/S
 ---
 > sysadmin/MS
 > sysop/MS
-46363,46364c52008
+46363,46364c52009
 < tangle's
 < tangle/UDSG
 ---
 > tangle/UDSGM
-46632a52277,52278
+46632a52278,52279
 > teleport/SGD
 > teleportation
-46675,46676c52321
+46675,46676c52322
 < template's
 < template/S
 ---
 > template/SM
-46752a52398
+46752a52399
 > terabit/MS
-46753a52400,52401
+46753a52401,52402
 > terahertz/M
 > terapixel/MS
-46806,46807c52454
+46806,46807c52455
 < test's/AFK
 < test/AKFCDGS
 ---
 > test/AKFCDGSM
-46817a52465
+46817a52466
 > testcase/MS
-46831a52480
+46831a52481
 > testsuite/MS
-46845a52495
+46845a52496
 > textbox/SM
-46925a52576
+46925a52577
 > theremin/MS
-46999c52650
+46999c52651
 < thinking's
 ---
 > thinking/M
-47095,47096c52746
+47095,47096c52747
 < throne's
 < throne/CDS
 ---
 > throne/CDSM
-47188,47189c52838
+47188,47189c52839
 < tie's
 < tie/AUSD
 ---
 > tie/AUSDM
-47213,47214c52862
+47213,47214c52863
 < till's
 < till/EDRZGS
 ---
 > till/EDRZGSM
-47303,47304c52951
+47303,47304c52952
 < tire's
 < tire/AGDS
 ---
 > tire/AGDSM
-47433,47434c53080
+47433,47434c53081
 < tone's
 < tone/IZGDRS
 ---
 > tone/IZGDRSM
-47453,47455c53099,53100
+47453,47455c53100,53101
 < tool's
 < tool/ADGS
 < toolbar
 ---
 > tool/ADGSM
 > toolbar/MS
-47540,47541c53185
+47540,47541c53186
 < tort's
 < tort/FEAS
 ---
 > tort/FEASM
-47644a53289
+47644a53290
 > traceur/SM
-47657,47658c53302
+47657,47658c53303
 < tract's
 < tract/CEKFAS
 ---
 > tract/CEKFASM
-47755a53400
+47755a53401
 > transfect/DSMG
-47774a53420,53421
+47774a53421,53422
 > transgenderism
 > transgene/MS
-47807,47808c53454
+47807,47808c53455
 < transmission's
 < transmission/AS
 ---
 > transmission/ASM
-47928,47929c53574
+47928,47929c53575
 < trench's
 < trench/AIGSD
 ---
 > trench/AIGSDM
-47951c53596
+47951c53597
 < triage/M
 ---
 > triage/MGS
-47976,47977c53621
+47976,47977c53622
 < tribute's
 < tribute/FS
 ---
 > tribute/FSM
-47997a53642
+47997a53643
 > trifecta/S
-48165,48166c53810
+48165,48166c53811
 < trust's/E
 < trust/IESGD
 ---
 > trust/IESGDM
-48180,48181c53824
+48180,48181c53825
 < try's
 < try/AGDS
 ---
 > try/AGDSM
-48271a53915
+48271a53916
 > turducken
-48334a53979
+48334a53980
 > tweep/S
-48371,48372c54016
+48371,48372c54017
 < twist's
 < twist/USDG
 ---
 > twist/USDGM
-48396,48397c54040
+48396,48397c54041
 < type's
 < type/AGDS
 ---
 > type/AGDSM
-48869a54513
+48869a54514
 > unlikeable
-49163,49164c54807
+49163,49164c54808
 < usual's
 < usual/UY
 ---
 > usual/UYM
-49211c54854
+49211c54855
 < vagina/M
 ---
 > vagina/MS
-49249,49250c54892
+49249,49250c54893
 < value's
 < value/CAGSD
 ---
 > value/CAGSDM
-49292,49293c54934
+49292,49293c54935
 < variant's
 < variant/IS
 ---
 > variant/ISM
-49356,49357c54997
+49356,49357c54998
 < veil's
 < veil/UDGS
 ---
 > veil/UDGSM
-49368,49369c55008
+49368,49369c55009
 < velour's
 < velours's
 ---
 > velour/MS
-49398,49399c55037
+49398,49399c55038
 < vent's
 < vent/DGS
 ---
 > vent/DGSM
-49435,49436c55073
+49435,49436c55074
 < verge's
 < verge/FDSG
 ---
 > verge/FDSGM
-49478a55116
+49478a55117
 > vertices
-49488,49489c55126
+49488,49489c55127
 < vest's
 < vest/ILDGS
 ---
 > vest/ILDGSM
-49681,49682c55318
+49681,49682c55319
 < visit's
 < visit/ASGD
 ---
 > visit/ASGDM
-49772a55409,55411
+49772a55410,55412
 > volcanological
 > volcanologist/MS
 > volcanology/M
-49807,49808c55446
+49807,49808c55447
 < vote's
 < vote/CGVDS
 ---
 > vote/CGVDSM
-50148a55787
+50148a55788
 > weaponize/DSG
-50215,50216c55854
+50215,50216c55855
 < weigh's
 < weigh/AGD
 ---
 > weigh/AGDM
-50260,50261d55897
+50260,50261d55898
 < werwolf/M
 < werwolves
-50555,50556c56191
+50555,50556c56192
 < wind's
 < wind/UASG
 ---
 > wind/UASGM
-50626,50627c56261
+50626,50627c56262
 < wire's
 < wire/AGDS
 ---
 > wire/AGDSM
-50728c56362
+50728c56363
 < women
 ---
 > women/M
-50794,50796c56428,56429
+50794,50796c56429,56430
 < wop/S!
 < word's
 < word/AJDSG
 ---
 > wop/MS!
 > word/AJDSGM
-50801c56434
+50801c56435
 < wording's
 ---
 > wording/M
-50808,50809c56441
+50808,50809c56442
 < work's
 < work/ADJSG
 ---
 > work/ADJSGM
-50824c56456
+50824c56457
 < working's
 ---
 > working/M
-50884,50885c56516
+50884,50885c56517
 < worthy's
 < worthy/UPRT
 ---
 > worthy/UPRTM
-50903,50904c56534
+50903,50904c56535
 < wrap's
 < wrap/US
 ---
 > wrap/USM
-50945c56575
+50945c56576
 < writing's
 ---
 > writing/M
-51118,51119c56748
+51118,51119c56749
 < yoke's
 < yoke/UGDS
 ---
 > yoke/UGDSM
-51212,51213c56841
+51212,51213c56842
 < zip's
 < zip/US
 ---
 > zip/USM
-51228,51229c56856
+51228,51229c56857
 < zone's
 < zone/AGDS
 ---
 > zone/AGDSM
--- a/extensions/spellcheck/locales/en-US/hunspell/en-US.dic
+++ b/extensions/spellcheck/locales/en-US/hunspell/en-US.dic
@@ -1,9 +1,9 @@
-57243
+57244
 0/nm
 0th/pt
 1/n1
 1st/p
 1th/tc
 2/nm
 2nd/p
 2th/tc
@@ -33228,16 +33228,17 @@ highness/M
 highpoint
 highrise/MS
 highroad/MS
 highs
 hightail/DSG
 highway/MS
 highwayman/M
 highwaymen
+hijab/S
 hijack/SJZGMDR
 hijacker/M
 hijacking/M
 hijinks
 hike/MZGDRS
 hiker/M
 hiking/M
 hilarious/PY
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -389,17 +389,17 @@ GetCairoSurfaceForSourceSurface(SourceSu
       return result;
     }
     data->Unmap();
     return nullptr;
   }
 
   cairo_surface_set_user_data(surf,
                               &surfaceDataKey,
-                              data.forget().drop(),
+                              data.forget().take(),
                               ReleaseData);
   return surf;
 }
 
 // An RAII class to temporarily clear any device offset set
 // on a surface. Note that this does not take a reference to the
 // surface.
 class AutoClearDeviceOffset
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -141,17 +141,17 @@ ImageContainer::ImageContainer(int flag)
   mImageFactory(new ImageFactory()),
   mRecycleBin(new BufferRecycleBin()),
   mCompositionNotifySink(nullptr),
   mImageClient(nullptr)
 {
   if (flag == ENABLE_ASYNC && ImageBridgeChild::IsCreated()) {
     // the refcount of this ImageClient is 1. we don't use a RefPtr here because the refcount
     // of this class must be done on the ImageBridge thread.
-    mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(CompositableType::IMAGE).drop();
+    mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(CompositableType::IMAGE).take();
     MOZ_ASSERT(mImageClient);
   }
 }
 
 ImageContainer::~ImageContainer()
 {
   if (IsAsync()) {
     ImageBridgeChild::DispatchReleaseImageClient(mImageClient);
@@ -164,17 +164,17 @@ ImageContainer::CreateImage(ImageFormat 
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
 #ifdef MOZ_WIDGET_GONK
   if (aFormat == ImageFormat::OVERLAY_IMAGE) {
     if (mImageClient && mImageClient->GetTextureInfo().mCompositableType != CompositableType::IMAGE_OVERLAY) {
       // If this ImageContainer is async but the image type mismatch, fix it here
       if (ImageBridgeChild::IsCreated()) {
         ImageBridgeChild::DispatchReleaseImageClient(mImageClient);
-        mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(CompositableType::IMAGE_OVERLAY).drop();
+        mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(CompositableType::IMAGE_OVERLAY).take();
       }
     }
   }
 #endif
   if (mImageClient) {
     nsRefPtr<Image> img = mImageClient->CreateImage(aFormat);
     if (img) {
       return img.forget();
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -16,17 +16,16 @@
 #include "mozilla/dom/AnimationPlayer.h" // for AnimationPlayer
 #include "mozilla/gfx/BaseRect.h"       // for BaseRect
 #include "mozilla/gfx/Point.h"          // for RoundedToInt, PointTyped
 #include "mozilla/gfx/Rect.h"           // for RoundedToInt, RectTyped
 #include "mozilla/gfx/ScaleFactor.h"    // for ScaleFactor
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorParent.h" // for CompositorParent, etc
 #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
-#include "nsCSSPropList.h"
 #include "nsCoord.h"                    // for NSAppUnitsToFloatPixels, etc
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #include "nsDeviceContext.h"            // for nsDeviceContext
 #include "nsDisplayList.h"              // for nsDisplayTransform, etc
 #include "nsMathUtils.h"                // for NS_round
 #include "nsPoint.h"                    // for nsPoint
 #include "nsRect.h"                     // for nsIntRect
 #include "nsRegion.h"                   // for nsIntRegion
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -32,18 +32,18 @@ SharedPlanarYCbCrImage::SharedPlanarYCbC
   MOZ_COUNT_CTOR(SharedPlanarYCbCrImage);
 }
 
 SharedPlanarYCbCrImage::~SharedPlanarYCbCrImage() {
   MOZ_COUNT_DTOR(SharedPlanarYCbCrImage);
 
   if (mCompositable->GetAsyncID() != 0 &&
       !InImageBridgeChildThread()) {
-    ImageBridgeChild::DispatchReleaseTextureClient(mTextureClient.forget().drop());
-    ImageBridgeChild::DispatchReleaseImageClient(mCompositable.forget().drop());
+    ImageBridgeChild::DispatchReleaseTextureClient(mTextureClient.forget().take());
+    ImageBridgeChild::DispatchReleaseImageClient(mCompositable.forget().take());
   }
 }
 
 size_t
 SharedPlanarYCbCrImage::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
 {
   // NB: Explicitly skipping mTextureClient, the memory is already reported
   //     at time of allocation in GfxMemoryImageReporter.
--- a/gfx/layers/ipc/SharedRGBImage.cpp
+++ b/gfx/layers/ipc/SharedRGBImage.cpp
@@ -65,18 +65,18 @@ SharedRGBImage::SharedRGBImage(ImageClie
 }
 
 SharedRGBImage::~SharedRGBImage()
 {
   MOZ_COUNT_DTOR(SharedRGBImage);
 
   if (mCompositable->GetAsyncID() != 0 &&
       !InImageBridgeChildThread()) {
-    ImageBridgeChild::DispatchReleaseTextureClient(mTextureClient.forget().drop());
-    ImageBridgeChild::DispatchReleaseImageClient(mCompositable.forget().drop());
+    ImageBridgeChild::DispatchReleaseTextureClient(mTextureClient.forget().take());
+    ImageBridgeChild::DispatchReleaseImageClient(mCompositable.forget().take());
   }
 }
 
 bool
 SharedRGBImage::Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat)
 {
   mSize = aSize;
   mTextureClient = mCompositable->CreateBufferTextureClient(aFormat, aSize,
--- a/ipc/ipdl/test/cxx/TestUrgentHangs.cpp
+++ b/ipc/ipdl/test/cxx/TestUrgentHangs.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: sw=4 ts=4 et :
  */
 #include "TestUrgentHangs.h"
 
 #include "IPDLUnitTests.h"      // fail etc.
+#include "prthread.h"
 #if defined(OS_POSIX)
 #include <unistd.h>
 #else
 #include <windows.h>
 #endif
 
 template<>
 struct RunnableMethodTraits<mozilla::_ipdltest::TestUrgentHangsParent>
@@ -103,25 +104,25 @@ TestUrgentHangsChild::RecvTest1_1()
         fail("sending Test1_2");
 
     return true;
 }
 
 bool
 TestUrgentHangsChild::RecvTest1_3()
 {
-    sleep(2);
+    PR_Sleep(PR_SecondsToInterval(2));
 
     return true;
 }
 
 bool
 TestUrgentHangsChild::RecvTest2()
 {
-    sleep(2);
+    PR_Sleep(PR_SecondsToInterval(2));
 
     // Should fail because of the timeout.
     if (SendTestInner())
         fail("sending TestInner");
 
     return true;
 }
 
@@ -130,17 +131,17 @@ TestUrgentHangsChild::RecvTest3()
 {
     fail("RecvTest3 should never be called");
     return true;
 }
 
 bool
 TestUrgentHangsChild::RecvTest4()
 {
-    sleep(2);
+    PR_Sleep(PR_SecondsToInterval(2));
 
     // This should fail because Test4_1 timed out and hasn't gotten a response
     // yet.
     if (SendTestInner())
         fail("sending TestInner");
 
     return true;
 }
--- a/js/src/aclocal.m4
+++ b/js/src/aclocal.m4
@@ -14,17 +14,16 @@ builtin(include, ../../build/autoconf/ns
 builtin(include, ../../build/autoconf/nspr-build.m4)dnl
 builtin(include, ../../build/autoconf/codeset.m4)dnl
 builtin(include, ../../build/autoconf/altoptions.m4)dnl
 builtin(include, ../../build/autoconf/mozprog.m4)dnl
 builtin(include, ../../build/autoconf/mozheader.m4)dnl
 builtin(include, ../../build/autoconf/mozcommonheader.m4)dnl
 builtin(include, ../../build/autoconf/lto.m4)dnl
 builtin(include, ../../build/autoconf/gcc-pr49911.m4)dnl
-builtin(include, ../../build/autoconf/gcc-pr39608.m4)dnl
 builtin(include, ../../build/autoconf/llvm-pr8927.m4)dnl
 builtin(include, ../../build/autoconf/frameptr.m4)dnl
 builtin(include, ../../build/autoconf/compiler-opts.m4)dnl
 builtin(include, ../../build/autoconf/expandlibs.m4)dnl
 builtin(include, ../../build/autoconf/arch.m4)dnl
 builtin(include, ../../build/autoconf/android.m4)dnl
 builtin(include, ../../build/autoconf/zlib.m4)dnl
 builtin(include, ../../build/autoconf/linux.m4)dnl
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -580,26 +580,24 @@ AC_PROG_LN_S
 AC_MSG_CHECKING([for tar archiver])
 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
 if test -z "$TAR"; then
     AC_MSG_WARN([no tar archiver found in \$PATH])
 fi
 AC_MSG_RESULT([$TAR])
 AC_SUBST(TAR)
 
-if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
 _perl_res=$?
 AC_MSG_RESULT([$_perl_version])
 
 if test "$_perl_res" != 0; then
     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
 fi
-fi
 
 AC_MSG_CHECKING([for full perl installation])
 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
 _perl_res=$?
 if test "$_perl_res" != 0; then
     AC_MSG_RESULT([no])
     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
 else
@@ -2238,17 +2236,16 @@ WINNT|Darwin|Android)
   WRAP_STL_INCLUDES=1
   ;;
 esac
 
 AC_SUBST(WRAP_SYSTEM_INCLUDES)
 AC_SUBST(VISIBILITY_FLAGS)
 
 MOZ_GCC_PR49911
-MOZ_GCC_PR39608
 MOZ_LLVM_PR8927
 
 dnl Checks for header files.
 dnl ========================================================
 AC_HEADER_DIRENT
 case "$target_os" in
 freebsd*)
 # for stuff like -lXshm
@@ -2645,31 +2642,16 @@ AC_CACHE_CHECK(for C++ dynamic_cast to v
                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
                            ac_cv_cpp_dynamic_cast_void_ptr=no,
                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
 fi
 
 
-dnl note that this one is reversed - if the test fails, then
-dnl we require implementations of unused virtual methods. Which
-dnl really blows because it means we'll have useless vtable
-dnl bloat.
-AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
-               ac_cv_cpp_unused_required,
-               [AC_TRY_LINK(class X {private: virtual void never_called();};,
-                               X x;,
-                               ac_cv_cpp_unused_required=no,
-                               ac_cv_cpp_unused_required=yes)])
-if test "$ac_cv_cpp_unused_required" = yes ; then
-   AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
-fi
-
-
 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
 # linking XUL.
 _SAVE_LDFLAGS=$LDFLAGS
 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
 AC_CACHE_CHECK(for __thread keyword for TLS variables,
                ac_cv_thread_keyword,
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/bug1116306.js
@@ -0,0 +1,8 @@
+const dbg = new Debugger();
+const g = newGlobal();
+dbg.addDebuggee(g);
+dbg.memory.trackingAllocationSites = true;
+g.eval("this.alloc = {}");
+verifyprebarriers();
+schedulegc(3);
+dbg.memory.drainAllocationsLog();
--- a/js/src/jit/RangeAnalysis.cpp
+++ b/js/src/jit/RangeAnalysis.cpp
@@ -2206,25 +2206,25 @@ RangeAnalysis::analyze()
             // methods but it needs the minAsmJSHeapLength().
             if (mir->compilingAsmJS()) {
                 uint32_t minHeapLength = mir->minAsmJSHeapLength();
                 if (iter->isAsmJSLoadHeap()) {
                     MAsmJSLoadHeap *ins = iter->toAsmJSLoadHeap();
                     Range *range = ins->ptr()->range();
                     uint32_t elemSize = TypedArrayElemSize(ins->viewType());
                     if (range && range->hasInt32LowerBound() && range->lower() >= 0 &&
-                        range->hasInt32UpperBound() && uint32_t(range->upper()) + elemSize < minHeapLength) {
+                        range->hasInt32UpperBound() && uint32_t(range->upper()) + elemSize <= minHeapLength) {
                         ins->removeBoundsCheck();
                     }
                 } else if (iter->isAsmJSStoreHeap()) {
                     MAsmJSStoreHeap *ins = iter->toAsmJSStoreHeap();
                     Range *range = ins->ptr()->range();
                     uint32_t elemSize = TypedArrayElemSize(ins->viewType());
                     if (range && range->hasInt32LowerBound() && range->lower() >= 0 &&
-                        range->hasInt32UpperBound() && uint32_t(range->upper()) + elemSize < minHeapLength) {
+                        range->hasInt32UpperBound() && uint32_t(range->upper()) + elemSize <= minHeapLength) {
                         ins->removeBoundsCheck();
                     }
                 }
             }
         }
     }
 
     return true;
--- a/js/src/vm/DebuggerMemory.cpp
+++ b/js/src/vm/DebuggerMemory.cpp
@@ -192,27 +192,29 @@ DebuggerMemory::drainAllocationsLog(JSCo
         return false;
     result->ensureDenseInitializedLength(cx, 0, length);
 
     for (size_t i = 0; i < length; i++) {
         RootedPlainObject obj(cx, NewBuiltinClassInstance<PlainObject>(cx));
         if (!obj)
             return false;
 
-        mozilla::UniquePtr<Debugger::AllocationSite, JS::DeletePolicy<Debugger::AllocationSite> >
-            allocSite(dbg->allocationsLog.popFirst());
+        Debugger::AllocationSite *allocSite = dbg->allocationsLog.getFirst();
         RootedValue frame(cx, ObjectOrNullValue(allocSite->frame));
         if (!JSObject::defineProperty(cx, obj, cx->names().frame, frame))
             return false;
 
         RootedValue timestampValue(cx, NumberValue(allocSite->when));
         if (!JSObject::defineProperty(cx, obj, cx->names().timestamp, timestampValue))
             return false;
 
         result->setDenseElement(i, ObjectValue(*obj));
+
+        MOZ_ALWAYS_TRUE(dbg->allocationsLog.popFirst() == allocSite);
+        js_delete(allocSite);
     }
 
     dbg->allocationsLogLength = 0;
     args.rval().setObject(*result);
     return true;
 }
 
 /* static */ bool
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -2610,17 +2610,17 @@ ElementRestyler::Restyle(nsRestyleHint a
   // List of descendant elements of mContent we know we will eventually need to
   // restyle.  Before we return from this function, we call
   // RestyleTracker::AddRestyleRootsIfAwaitingRestyle to ensure they get
   // restyled in RestyleTracker::DoProcessRestyles.
   nsTArray<nsRefPtr<Element>> descendants;
 
   nsRestyleHint hintToRestore = nsRestyleHint(0);
   if (mContent && mContent->IsElement() &&
-      // If we're we're resolving from the root of the frame tree (which
+      // If we're resolving from the root of the frame tree (which
       // we do in DoRebuildAllStyleData), we need to avoid getting the
       // root's restyle data until we get to its primary frame, since
       // it's the primary frame that has the styles for the root element
       // (rather than the ancestors of the primary frame whose mContent
       // is the root node but which have different styles).  If we use
       // up the hint for one of the ancestors that we hit first, then
       // we'll fail to do the restyling we need to do.
       (mContent->GetParent() || mContent->GetPrimaryFrame() == mFrame)) {
@@ -2631,22 +2631,16 @@ ElementRestyler::Restyle(nsRestyleHint a
         mChangeList->AppendChange(mFrame, mContent, restyleData->mChangeHint);
       }
       hintToRestore = restyleData->mRestyleHint;
       aRestyleHint = nsRestyleHint(aRestyleHint | restyleData->mRestyleHint);
       descendants.SwapElements(restyleData->mDescendants);
     }
   }
 
-  // Some changes to animations don't affect the computed style and yet still
-  // require the layer to be updated. For example, pausing an animation via
-  // the Web Animations API won't affect an element's style but still
-  // requires us to pull the animation off the layer.
-  AddLayerChangesForAnimation();
-
   // If we are restyling this frame with eRestyle_Self or weaker hints,
   // we restyle children with nsRestyleHint(0).  But we pass the
   // eRestyle_ChangeAnimationPhaseDescendants and eRestyle_ForceDescendants
   // flags down too.
   nsRestyleHint childRestyleHint =
     nsRestyleHint(aRestyleHint & (eRestyle_Subtree |
                                   eRestyle_ChangeAnimationPhaseDescendants |
                                   eRestyle_ForceDescendants));
@@ -2689,16 +2683,29 @@ ElementRestyler::Restyle(nsRestyleHint a
       // with this frame and its descendants.  Higher RestyleResult values
       // represent a superset of the work done by lower values.
       result = thisResult;
     }
 
     f = GetNextContinuationWithSameStyle(f, oldContext, &haveMoreContinuations);
   }
 
+  // Some changes to animations don't affect the computed style and yet still
+  // require the layer to be updated. For example, pausing an animation via
+  // the Web Animations API won't affect an element's style but still
+  // requires us to pull the animation off the layer.
+  //
+  // Although we only expect this code path to be called when computed style
+  // is not changing, we can sometimes reach this at the end of a transition
+  // when the animated style is being removed. Since
+  // AddLayerChangesForAnimation checks if mFrame has a transform style or not,
+  // we need to call it *after* calling RestyleSelf to ensure the animated
+  // transform has been removed first.
+  AddLayerChangesForAnimation();
+
   if (haveMoreContinuations && hintToRestore) {
     // If we have more continuations with different style (e.g., because
     // we're inside a ::first-letter or ::first-line), put the restyle
     // hint back.
     mRestyleTracker.AddPendingRestyleToTable(mContent->AsElement(),
                                              hintToRestore, nsChangeHint(0));
   }
 
--- a/layout/base/SelectionCarets.cpp
+++ b/layout/base/SelectionCarets.cpp
@@ -257,17 +257,23 @@ SelectionCarets::HandleEvent(WidgetEvent
     nsPoint delta = mDownPoint - ptInRoot;
     if (NS_hypot(delta.x, delta.y) >
           nsPresContext::AppUnitsPerCSSPixel() * kMoveStartTolerancePx) {
       CancelLongTapDetector();
     }
   } else if (aEvent->message == NS_MOUSE_MOZLONGTAP) {
     if (!mVisible) {
       SELECTIONCARETS_LOG("SelectWord from APZ");
-      SelectWord();
+      nsresult wordSelected = SelectWord();
+
+      if (NS_FAILED(wordSelected)) {
+        SELECTIONCARETS_LOG("SelectWord from APZ failed!")
+        return nsEventStatus_eIgnore;
+      }
+
       return nsEventStatus_eConsumeNoDefault;
     }
   }
   return nsEventStatus_eIgnore;
 }
 
 static void
 SetElementVisibility(dom::Element* aElement, bool aVisible)
@@ -548,35 +554,35 @@ SelectionCarets::UpdateSelectionCarets()
   }
   SetTilted(isTilt);
 }
 
 nsresult
 SelectionCarets::SelectWord()
 {
   if (!mPresShell) {
-    return NS_OK;
+    return NS_ERROR_UNEXPECTED;
   }
 
   nsIFrame* rootFrame = mPresShell->GetRootFrame();
   if (!rootFrame) {
-    return NS_OK;
+    return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Find content offsets for mouse down point
   nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, mDownPoint,
     nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | nsLayoutUtils::IGNORE_CROSS_DOC);
   if (!ptFrame) {
-    return NS_OK;
+    return NS_ERROR_FAILURE;
   }
 
   bool selectable;
   ptFrame->IsSelectable(&selectable, nullptr);
   if (!selectable) {
-    return NS_OK;
+    return NS_ERROR_FAILURE;
   }
 
   nsPoint ptInFrame = mDownPoint;
   nsLayoutUtils::TransformPoint(rootFrame, ptFrame, ptInFrame);
 
   // If target frame is editable, we should move focus to targe frame. If
   // target frame isn't editable and our focus content is editable, we should
   // clear focus.
@@ -1207,17 +1213,21 @@ SelectionCarets::CancelLongTapDetector()
 /* static */void
 SelectionCarets::FireLongTap(nsITimer* aTimer, void* aSelectionCarets)
 {
   nsRefPtr<SelectionCarets> self = static_cast<SelectionCarets*>(aSelectionCarets);
   NS_PRECONDITION(aTimer == self->mLongTapDetectorTimer,
                   "Unexpected timer");
 
   SELECTIONCARETS_LOG_STATIC("SelectWord from non-APZ");
-  self->SelectWord();
+  nsresult wordSelected = self->SelectWord();
+
+  if (NS_FAILED(wordSelected)) {
+    SELECTIONCARETS_LOG_STATIC("SelectWord from non-APZ failed!");
+  }
 }
 
 void
 SelectionCarets::LaunchScrollEndDetector()
 {
   if (!mScrollEndDetectorTimer) {
     mScrollEndDetectorTimer = do_CreateInstance("@mozilla.org/timer;1");
   }
--- a/layout/base/SelectionCarets.h
+++ b/layout/base/SelectionCarets.h
@@ -116,18 +116,18 @@ private:
   void SetVisibility(bool aVisible);
 
   /**
    * Update selection caret position base on current selection range.
    */
   void UpdateSelectionCarets();
 
   /**
-   * Select word base on current position, only active when element
-   * is focused. Triggered by long tap event.
+   * Select a word base on current position, which activates only if element is
+   * selectable. Triggered by long tap event.
    */
   nsresult SelectWord();
 
   /**
    * Move selection base on current touch/mouse point
    */
   nsEventStatus DragSelection(const nsPoint &movePoint);
 
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -341,17 +341,17 @@ nsDisplayCanvasBackgroundImage::Paint(ns
 
   PaintInternal(aBuilder,
                 dt ? &context : aCtx,
                 dt ? bgClipRect: mVisibleRect,
                 &bgClipRect);
 
   if (dt) {
     BlitSurface(dest->GetDrawTarget(), destRect, dt);
-    frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), dt.forget().drop());
+    frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), dt.forget().take());
   }
 }
 
 void
 nsDisplayCanvasThemedBackground::Paint(nsDisplayListBuilder* aBuilder,
                                        nsRenderingContext* aCtx)
 {
   nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -535,18 +535,22 @@ nsTransitionManager::ConsiderStartingTra
   AnimationPropertySegment& segment = *prop.mSegments.AppendElement();
   segment.mFromValue = startValue;
   segment.mToValue = endValue;
   segment.mFromKey = 0;
   segment.mToKey = 1;
   segment.mTimingFunction.Init(tf);
 
   nsRefPtr<CSSTransitionPlayer> player = new CSSTransitionPlayer(timeline);
+  // The order of the following two calls is important since PlayFromStyle
+  // will add the player to the PendingPlayerTracker of its source content's
+  // document. When we come to make source writeable (bug 1049975) we should
+  // remove this dependency.
+  player->SetSource(pt);
   player->PlayFromStyle();
-  player->SetSource(pt);
 
   if (!aElementTransitions) {
     aElementTransitions =
       GetAnimationPlayers(aElement, aNewStyleContext->GetPseudoType(), true);
     if (!aElementTransitions) {
       NS_WARNING("allocating CommonAnimationManager failed");
       return;
     }
--- a/layout/tools/reftest/remotereftest.py
+++ b/layout/tools/reftest/remotereftest.py
@@ -371,16 +371,18 @@ class RemoteReftest(RefTest):
         # Make sure AddonRepository won't hit the network
         prefs["extensions.getAddons.maxResults"] = 0
         prefs["extensions.getAddons.get.url"] = "http://127.0.0.1:8888/extensions-dummy/repositoryGetURL"
         prefs["extensions.getAddons.getWithPerformance.url"] = "http://127.0.0.1:8888/extensions-dummy/repositoryGetWithPerformanceURL"
         prefs["extensions.getAddons.search.browseURL"] = "http://127.0.0.1:8888/extensions-dummy/repositoryBrowseURL"
         prefs["extensions.getAddons.search.url"] = "http://127.0.0.1:8888/extensions-dummy/repositorySearchURL"
         # Make sure that opening the plugins check page won't hit the network
         prefs["plugins.update.url"] = "http://127.0.0.1:8888/plugins-dummy/updateCheckURL"
+        # Make sure the GMPInstallManager won't hit the network
+        prefs["media.gmp-manager.url.override"] = "http://127.0.0.1:8888/dummy-gmp-manager.xml";
         prefs["layout.css.devPixelsPerPx"] = "1.0"
 
         # Disable skia-gl: see bug 907351
         prefs["gfx.canvas.azure.accelerated"] = False
 
         # Set the extra prefs.
         profile.set_preferences(prefs)
 
new file mode 100644
--- /dev/null
+++ b/media/libtremor/bug1117571-r19420.patch
@@ -0,0 +1,18 @@
+diff -r 55f3224d7513 media/libtremor/lib/tremor_synthesis.c
+--- a/media/libtremor/lib/tremor_synthesis.c	Sat Jan 03 20:02:33 2015 -0800
++++ b/media/libtremor/lib/tremor_synthesis.c	Sun Jan 04 11:17:29 2015 -0800
+@@ -119,13 +119,13 @@ long vorbis_packet_blocksize(vorbis_info
+     while(v>1){
+       modebits++;
+       v>>=1;
+     }
+ 
+     /* read our mode and pre/post windowsize */
+     mode=oggpack_read(&opb,modebits);
+   }
+-  if(mode==-1)return(OV_EBADPACKET);
++  if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET);
+   return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
+ }
+ 
+ 
--- a/media/libtremor/lib/tremor_synthesis.c
+++ b/media/libtremor/lib/tremor_synthesis.c
@@ -119,13 +119,13 @@ long vorbis_packet_blocksize(vorbis_info
     while(v>1){
       modebits++;
       v>>=1;
     }
 
     /* read our mode and pre/post windowsize */
     mode=oggpack_read(&opb,modebits);
   }
-  if(mode==-1)return(OV_EBADPACKET);
+  if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET);
   return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
 }
 
 
--- a/media/libtremor/update.sh
+++ b/media/libtremor/update.sh
@@ -26,8 +26,9 @@ cp $1/synthesis.c ./lib/tremor_synthesis
 cp $1/window_lookup.h ./lib/window_lookup.h
 cp $1/window.c ./lib/tremor_window.c
 cp $1/window.h ./lib/window.h
 cp $1/ivorbiscodec.h ./include/tremor/ivorbiscodec.h
 cp $1/os.h ./lib/os.h
 cp $1/COPYING ./COPYING
 cp $1/README ./README
 patch -p3 < ./bug719612.patch
+patch -p3 < ./bug1117571-r19420.patch
new file mode 100644
--- /dev/null
+++ b/media/libvorbis/bug1117571-r19419.patch
@@ -0,0 +1,22 @@
+diff -r 55f3224d7513 media/libvorbis/lib/vorbis_synthesis.c
+--- a/media/libvorbis/lib/vorbis_synthesis.c	Sat Jan 03 20:02:33 2015 -0800
++++ b/media/libvorbis/lib/vorbis_synthesis.c	Sun Jan 04 11:17:02 2015 -0800
+@@ -159,17 +159,17 @@ long vorbis_packet_blocksize(vorbis_info
+     while(v>1){
+       modebits++;
+       v>>=1;
+     }
+ 
+     /* read our mode and pre/post windowsize */
+     mode=oggpack_read(&opb,modebits);
+   }
+-  if(mode==-1)return(OV_EBADPACKET);
++  if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET);
+   return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
+ }
+ 
+ int vorbis_synthesis_halfrate(vorbis_info *vi,int flag){
+   /* set / clear half-sample-rate mode */
+   codec_setup_info     *ci=vi->codec_setup;
+ 
+   /* right now, our MDCT can't handle < 64 sample windows. */
--- a/media/libvorbis/lib/vorbis_synthesis.c
+++ b/media/libvorbis/lib/vorbis_synthesis.c
@@ -159,17 +159,17 @@ long vorbis_packet_blocksize(vorbis_info
     while(v>1){
       modebits++;
       v>>=1;
     }
 
     /* read our mode and pre/post windowsize */
     mode=oggpack_read(&opb,modebits);
   }
-  if(mode==-1)return(OV_EBADPACKET);
+  if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET);
   return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
 }
 
 int vorbis_synthesis_halfrate(vorbis_info *vi,int flag){
   /* set / clear half-sample-rate mode */
   codec_setup_info     *ci=vi->codec_setup;
 
   /* right now, our MDCT can't handle < 64 sample windows. */
--- a/media/libvorbis/update.sh
+++ b/media/libvorbis/update.sh
@@ -76,8 +76,9 @@ mkdir -p ./lib/books/coupled
 mkdir -p ./lib/books/floor
 mkdir -p ./lib/books/uncoupled
 cp $1/lib/books/coupled/res_books_stereo.h ./lib/books/coupled/
 cp $1/lib/books/coupled/res_books_51.h ./lib/books/coupled/
 cp $1/lib/books/floor/floor_books.h ./lib/books/floor/
 cp $1/lib/books/uncoupled/res_books_uncoupled.h ./lib/books/uncoupled/
 
 # Add any patches against upstream here.
+patch -p3 < ./bug1117571-r19419.patch
--- a/media/webrtc/signaling/test/mediaconduit_unittests.cpp
+++ b/media/webrtc/signaling/test/mediaconduit_unittests.cpp
@@ -778,17 +778,17 @@ class TransportConduitTest : public ::te
     cerr << "    3. Null Codec Parameter  " << endl;
     cerr << "   *************************************************" << endl;
 
     err = videoSession->ConfigureSendMediaCodec(nullptr);
     EXPECT_TRUE(err != mozilla::kMediaConduitNoError);
 
     mozilla::SyncRunnable::DispatchToThread(gMainThread,
                                             WrapRunnable(
-                                                videoSession.forget().drop(),
+                                                videoSession.forget().take(),
                                                 &mozilla::VideoSessionConduit::Release));
   }
 
   void DumpMaxFs(int orig_width, int orig_height, int max_fs,
                  int new_width, int new_height)
   {
     cerr << "Applying max_fs=" << max_fs << " to input resolution " <<
                  orig_width << "x" << orig_height << endl;
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -156,21 +156,23 @@ public:
 
 private:
   mutable typename Conditional<Atomicity == AtomicRefCount,
                                Atomic<MozRefCountType>,
                                MozRefCountType>::Type mRefCnt;
 };
 
 #ifdef MOZ_REFCOUNTED_LEAK_CHECKING
-#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T) \
-  virtual const char* typeName() const { return #T; } \
-  virtual size_t typeSize() const { return sizeof(*this); }
+// Passing MOZ_OVERRIDE for the optional argument marks the typeName and
+// typeSize functions defined by this macro as overrides.
+#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...) \
+  virtual const char* typeName() const __VA_ARGS__ { return #T; } \
+  virtual size_t typeSize() const __VA_ARGS__ { return sizeof(*this); }
 #else
-#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T)
+#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...)
 #endif
 
 // Note that this macro is expanded unconditionally because it declares only
 // two small inline functions which will hopefully get eliminated by the linker
 // in non-leak-checking builds.
 #define MOZ_DECLARE_REFCOUNTED_TYPENAME(T) \
   const char* typeName() const { return #T; } \
   size_t typeSize() const { return sizeof(*this); }
@@ -228,32 +230,32 @@ class RefPtr
   friend class TemporaryRef<T>;
   friend class OutParamRef<T>;
 
   struct DontRef {};
 
 public:
   RefPtr() : mPtr(0) {}
   RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.mPtr)) {}
-  MOZ_IMPLICIT RefPtr(const TemporaryRef<T>& aOther) : mPtr(aOther.drop()) {}
+  MOZ_IMPLICIT RefPtr(const TemporaryRef<T>& aOther) : mPtr(aOther.take()) {}
   MOZ_IMPLICIT RefPtr(T* aVal) : mPtr(ref(aVal)) {}
 
   template<typename U>
   RefPtr(const RefPtr<U>& aOther) : mPtr(ref(aOther.get())) {}
 
   ~RefPtr() { unref(mPtr); }
 
   RefPtr& operator=(const RefPtr& aOther)
   {
     assign(ref(aOther.mPtr));
     return *this;
   }
   RefPtr& operator=(const TemporaryRef<T>& aOther)
   {
-    assign(aOther.drop());
+    assign(aOther.take());
     return *this;
   }
   RefPtr& operator=(T* aVal)
   {
     assign(ref(aVal));
     return *this;
   }
 
@@ -314,24 +316,24 @@ class TemporaryRef
 {
   // To allow it to construct TemporaryRef from a bare T*
   friend class RefPtr<T>;
 
   typedef typename RefPtr<T>::DontRef DontRef;
 
 public:
   MOZ_IMPLICIT TemporaryRef(T* aVal) : mPtr(RefPtr<T>::ref(aVal)) {}
-  TemporaryRef(const TemporaryRef& aOther) : mPtr(aOther.drop()) {}
+  TemporaryRef(const TemporaryRef& aOther) : mPtr(aOther.take()) {}
 
   template<typename U>
-  TemporaryRef(const TemporaryRef<U>& aOther) : mPtr(aOther.drop()) {}
+  TemporaryRef(const TemporaryRef<U>& aOther) : mPtr(aOther.take()) {}
 
   ~TemporaryRef() { RefPtr<T>::unref(mPtr); }
 
-  T* drop() const
+  MOZ_WARN_UNUSED_RESULT T* take() const
   {
     T* tmp = mPtr;
     mPtr = nullptr;
     return tmp;
   }
 
 private:
   TemporaryRef(T* aVal, const DontRef&) : mPtr(aVal) {}
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -838,8 +838,11 @@ pref("home.sync.updateMode", 0);
 // How frequently to check if we should sync home provider data.
 pref("home.sync.checkIntervalSecs", 3600);
 
 // Enable device storage API
 pref("device.storage.enabled", true);
 
 // Enable meta-viewport support for font inflation code
 pref("dom.meta-viewport.enabled", true);
+
+// Enable the OpenH264 plugin support in the addon manager.
+pref("media.gmp-gmpopenh264.provider.enabled", true);
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -107,16 +107,19 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/SharedPreferences.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Notifications",
                                   "resource://gre/modules/Notifications.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
                                   "resource://gre/modules/ReaderMode.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "GMPInstallManager",
+                                  "resource://gre/modules/GMPInstallManager.jsm");
+
 // Lazily-loaded browser scripts:
 [
   ["SelectHelper", "chrome://browser/content/SelectHelper.js"],
   ["InputWidgetHelper", "chrome://browser/content/InputWidgetHelper.js"],
   ["AboutReader", "chrome://global/content/reader/aboutReader.js"],
   ["MasterPassword", "chrome://browser/content/MasterPassword.js"],
   ["PluginHelper", "chrome://browser/content/PluginHelper.js"],
   ["OfflineApps", "chrome://browser/content/OfflineApps.js"],
@@ -337,16 +340,19 @@ var BrowserApp = {
 
         // Queue up some other performance-impacting initializations
         Services.tm.mainThread.dispatch(function() {
           // Init LoginManager
           Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
           CastingApps.init();
         }, Ci.nsIThread.DISPATCH_NORMAL);
 
+        BrowserApp.gmpInstallManager = new GMPInstallManager();
+        BrowserApp.gmpInstallManager.simpleCheckAndInstall().then(null, () => {});
+
 #ifdef MOZ_SAFE_BROWSING
         Services.tm.mainThread.dispatch(function() {
           // Bug 778855 - Perf regression if we do this here. To be addressed in bug 779008.
           SafeBrowsing.init();
         }, Ci.nsIThread.DISPATCH_NORMAL);
 #endif
 #ifdef NIGHTLY_BUILD
         WebcompatReporter.init();
@@ -1188,16 +1194,20 @@ var BrowserApp = {
     this.selectedTab = aTab;
 
     let evt = document.createEvent("UIEvents");
     evt.initUIEvent("TabSelect", true, false, window, null);
     aTab.browser.dispatchEvent(evt);
   },
 
   quit: function quit(aClear = { sanitize: {}, dontSaveSession: false }) {
+    if (this.gmpInstallManager) {
+      this.gmpInstallManager.uninit();
+    }
+
     // Figure out if there's at least one other browser window around.
     let lastBrowser = true;
     let e = Services.wm.getEnumerator("navigator:browser");
     while (e.hasMoreElements() && lastBrowser) {
       let win = e.getNext();
       if (!win.closed && win != window)
         lastBrowser = false;
     }
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -121,16 +121,17 @@
 @BINPATH@/components/browser-feeds.xpt
 @BINPATH@/components/caps.xpt
 @BINPATH@/components/chardet.xpt
 @BINPATH@/components/chrome.xpt
 @BINPATH@/components/commandhandler.xpt
 @BINPATH@/components/commandlines.xpt
 @BINPATH@/components/composer.xpt
 @BINPATH@/components/content_events.xpt
+@BINPATH@/components/content_geckomediaplugins.xpt
 @BINPATH@/components/content_html.xpt
 @BINPATH@/components/content_webrtc.xpt
 @BINPATH@/components/content_xslt.xpt
 @BINPATH@/components/cookie.xpt
 @BINPATH@/components/directory.xpt
 @BINPATH@/components/docshell.xpt
 @BINPATH@/components/dom.xpt
 @BINPATH@/components/dom_activities.xpt
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4450,8 +4450,50 @@ pref("browser.search.geoip.url", "https:
 // NOTE: this timeout figure is also the "high" value for the telemetry probe
 // SEARCH_SERVICE_COUNTRY_FETCH_MS - if you change this also change that probe.
 pref("browser.search.geoip.timeout", 2000);
 
 #ifdef MOZ_OFFICIAL_BRANDING
 // {moz:official} expands to "official"
 pref("browser.search.official", true);
 #endif
+
+#ifndef MOZ_WIDGET_GONK
+// GMPInstallManager prefs
+
+// Enables some extra logging (can reduce performance)
+pref("media.gmp-manager.log", false);
+
+// User-settable override to media.gmp-manager.url for testing purposes.
+//pref("media.gmp-manager.url.override", "");
+
+// Update service URL for GMP install/updates:
+pref("media.gmp-manager.url", "https://aus4.mozilla.org/update/3/GMP/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml");
+
+// When |media.gmp-manager.cert.requireBuiltIn| is true or not specified the
+// final certificate and all certificates the connection is redirected to before
+// the final certificate for the url specified in the |media.gmp-manager.url|
+// preference must be built-in.
+pref("media.gmp-manager.cert.requireBuiltIn", true);
+
+// The |media.gmp-manager.certs.| preference branch contains branches that are
+// sequentially numbered starting at 1 that contain attribute name / value
+// pairs for the certificate used by the server that hosts the update xml file
+// as specified in the |media.gmp-manager.url| preference. When these preferences are
+// present the following conditions apply for a successful update check:
+// 1. the uri scheme must be https
+// 2. the preference name must exist as an attribute name on the certificate and
+//    the value for the name must be the same as the value for the attribute name
+//    on the certificate.
+// If these conditions aren't met it will be treated the same as when there is
+// no update available. This validation will not be performed when the
+// |media.gmp-manager.url.override| user preference has been set for testing updates or
+// when the |media.gmp-manager.cert.checkAttributes| preference is set to false. Also,
+// the |media.gmp-manager.url.override| preference should ONLY be used for testing.
+// IMPORTANT! app.update.certs.* prefs should also be updated if these
+// are updated.
+pref("media.gmp-manager.cert.checkAttributes", true);
+pref("media.gmp-manager.certs.1.issuerName", "CN=DigiCert Secure Server CA,O=DigiCert Inc,C=US");
+pref("media.gmp-manager.certs.1.commonName", "aus4.mozilla.org");
+pref("media.gmp-manager.certs.2.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US");
+pref("media.gmp-manager.certs.2.commonName", "aus4.mozilla.org");
+#endif
+
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -547,21 +547,28 @@ nsHttpTransaction::OnTransportStatus(nsI
     // nsHttpChannel synthesizes progress events in OnDataAvailable
     if (status == NS_NET_STATUS_RECEIVING_FROM)
         return;
 
     uint64_t progressMax;
 
     if (status == NS_NET_STATUS_SENDING_TO) {
         // suppress progress when only writing request headers
-        if (!mHasRequestBody)
+        if (!mHasRequestBody) {
+            LOG(("nsHttpTransaction::OnTransportStatus %p "
+                 "SENDING_TO without request body\n", this));
             return;
+        }
 
         nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mRequestStream);
-        MOZ_ASSERT(seekable, "Request stream isn't seekable?!?");
+        if (!seekable) {
+            LOG(("nsHttpTransaction::OnTransportStatus %p "
+                 "SENDING_TO without seekable request stream\n", this));
+            return;
+        }
 
         int64_t prog = 0;
         seekable->Tell(&prog);
         progress = prog;
 
         // when uploading, we include the request headers in the progress
         // notifications.
         progressMax = mRequestSize; // XXX mRequestSize is 32-bit!
--- a/security/pkix/include/pkix/Input.h
+++ b/security/pkix/include/pkix/Input.h
@@ -119,17 +119,17 @@ public:
   // Don't use this. It is here because we have some "friend" functions that we
   // don't want to declare in this header file.
   const uint8_t* UnsafeGetData() const { return data; }
 
 private:
   const uint8_t* data;
   size_t len;
 
-  void operator=(const Input&) = delete; // Use Init instead.
+  void operator=(const Input&) /* = delete */; // Use Init instead.
 };
 
 inline bool
 InputsAreEqual(const Input& a, const Input& b)
 {
   return a.GetLength() == b.GetLength() &&
          !std::memcmp(a.UnsafeGetData(), b.UnsafeGetData(), a.GetLength());
 }
@@ -286,17 +286,17 @@ public:
 
   class Mark
   {
   private:
     friend class Reader;
     Mark(const Reader& input, const uint8_t* mark) : input(input), mark(mark) { }
     const Reader& input;
     const uint8_t* const mark;
-    void operator=(const Mark&) = delete;
+    void operator=(const Mark&) /* = delete */;
   };
 
   Mark GetMark() const { return Mark(*this, input); }
 
   Result GetInput(const Mark& mark, /*out*/ Input& item)
   {
     if (&mark.input != this || mark.mark > input) {
       return NotReached("invalid mark", Result::FATAL_ERROR_INVALID_ARGS);
@@ -315,18 +315,18 @@ private:
     input = data;
     end = data + len;
     return Success;
   }
 
   const uint8_t* input;
   const uint8_t* end;
 
-  Reader(const Reader&) = delete;
-  void operator=(const Reader&) = delete;
+  Reader(const Reader&) /* = delete */;
+  void operator=(const Reader&) /* = delete */;
 };
 
 inline bool
 InputContains(const Input& input, uint8_t toFind)
 {
   Reader reader(input);
   for (;;) {
     uint8_t b;
--- a/security/pkix/include/pkix/ScopedPtr.h
+++ b/security/pkix/include/pkix/ScopedPtr.h
@@ -64,18 +64,18 @@ public:
     return result;
   }
 
   void reset() { *this = nullptr; }
 
 protected:
   T* mValue;
 
-  ScopedPtr(const ScopedPtr&) = delete;
-  void operator=(const ScopedPtr&) = delete;
+  ScopedPtr(const ScopedPtr&) /* = delete */;
+  void operator=(const ScopedPtr&) /* = delete */;
 };
 
 template <typename T, void(&Destroyer)(T*)>
 inline bool
 operator==(T* a, const ScopedPtr<T, Destroyer>& b)
 {
   return a == b.get();
 }
--- a/security/pkix/include/pkix/bind.h
+++ b/security/pkix/include/pkix/bind.h
@@ -75,47 +75,47 @@ class Bind1
 {
 public:
   typedef R (&F)(P1&, B1&);
   Bind1(F f, B1& b1) : f(f), b1(b1) { }
   R operator()(P1& p1) const { return f(p1, b1); }
 private:
   F f;
   B1& b1;
-  void operator=(const Bind1&) = delete;
+  void operator=(const Bind1&) /*= delete*/;
 };
 
 template <typename R, typename P1, typename B1, typename B2>
 class Bind2
 {
 public:
   typedef R (&F)(P1&, B1&, B2&);
   Bind2(F f, B1& b1, B2& b2) : f(f), b1(b1), b2(b2) { }
   R operator()(P1& p1) const { return f(p1, b1, b2); }
 private:
   F f;
   B1& b1;
   B2& b2;
-  void operator=(const Bind2&) = delete;
+  void operator=(const Bind2&) /*= delete*/;
 };
 
 template <typename R, typename P1, typename B1, typename B2, typename B3>
 class Bind3
 {
 public:
   typedef R (&F)(P1&, B1, B2, B3&);
   Bind3(F f, B1& b1, B2& b2, B3& b3)
     : f(f), b1(b1), b2(b2), b3(b3) { }
   R operator()(P1& p1) const { return f(p1, b1, b2, b3); }
 private:
   F f;
   B1& b1;
   B2& b2;
   B3& b3;
-  void operator=(const Bind3&) = delete;
+  void operator=(const Bind3&) /*= delete*/;
 };
 
 template <typename R, typename P1, typename B1, typename B2, typename B3,
           typename B4>
 class Bind4
 {
 public:
   typedef R (&F)(P1&, B1, B2, B3&, B4&);
@@ -123,17 +123,17 @@ public:
     : f(f), b1(b1), b2(b2), b3(b3), b4(b4) { }
   R operator()(P1& p1) const { return f(p1, b1, b2, b3, b4); }
 private:
   F f;
   B1& b1;
   B2& b2;
   B3& b3;
   B4& b4;
-  void operator=(const Bind4&) = delete;
+  void operator=(const Bind4&) /*= delete*/;
 };
 
 template <typename R, typename C1, typename P1, typename P2, typename P3,
           typename P4>
 class BindToMemberFunction4
 {
 public:
   // XXX: C++ doesn't have reference-to-member function, only
@@ -143,17 +143,17 @@ public:
   BindToMemberFunction4(F f, C1& that) : f(f), that(that) { }
   R operator()(P1& p1, P2& p2, P3 p3, P4& p4) const
   {
     return (that.*f)(p1, p2, p3, p4);
   }
 private:
   const F f;
   C1& that;
-  void operator=(const BindToMemberFunction4&) = delete;
+  void operator=(const BindToMemberFunction4&) /*= delete*/;
 };
 
 template <typename R, typename P1, typename B1, typename B2, typename B3,
           typename B4, typename B5>
 class Bind5
 {
 public:
   typedef R (&F)(P1&, B1, B2, B3, B4, B5);
@@ -162,17 +162,17 @@ public:
   R operator()(P1& p1) const { return f(p1, b1, b2, b3, b4, b5); }
 private:
   F f;
   B1 b1;
   B2 b2;
   B3 b3;
   B4 b4;
   B5 b5;
-  void operator=(const Bind5&) = delete;
+  void operator=(const Bind5&) /*= delete*/;
 };
 
 } // namespace internal
 
 template <typename R, typename P1, typename B1>
 inline internal::Bind1<R, P1, B1>
 bind(R (&f)(P1&, B1&), Placeholder1&, B1& b1)
 {
--- a/security/pkix/include/pkix/pkixtypes.h
+++ b/security/pkix/include/pkix/pkixtypes.h
@@ -75,17 +75,18 @@ MOZILLA_PKIX_ENUM_CLASS SignatureAlgorit
 
 struct SignedDataWithSignature
 {
 public:
   Input data;
   SignatureAlgorithm algorithm;
   Input signature;
 
-  void operator=(const SignedDataWithSignature&) = delete;
+private:
+  void operator=(const SignedDataWithSignature&) /*= delete*/;
 };
 
 MOZILLA_PKIX_ENUM_CLASS EndEntityOrCA { MustBeEndEntity = 0, MustBeCA = 1 };
 
 MOZILLA_PKIX_ENUM_CLASS KeyUsage : uint8_t {
   digitalSignature = 0,
   nonRepudiation   = 1,
   keyEncipherment  = 2,
@@ -142,18 +143,18 @@ public:
     : issuer(issuer)
     , issuerSubjectPublicKeyInfo(issuerSubjectPublicKeyInfo)
     , serialNumber(serialNumber)
   {
   }
   const Input issuer;
   const Input issuerSubjectPublicKeyInfo;
   const Input serialNumber;
-
-  void operator=(const CertID&) = delete;
+private:
+  void operator=(const CertID&) /*= delete*/;
 };
 
 class DERArray
 {
 public:
   // Returns the number of DER-encoded items in the array.
   virtual size_t GetLength() const = 0;
 
@@ -203,19 +204,19 @@ public:
     // constraints will be checked in addition to any any name constraints
     // contained in potentialIssuerDER.
     virtual Result Check(Input potentialIssuerDER,
             /*optional*/ const Input* additionalNameConstraints,
                  /*out*/ bool& keepGoing) = 0;
   protected:
     IssuerChecker();
     virtual ~IssuerChecker();
-
-    IssuerChecker(const IssuerChecker&) = delete;
-    void operator=(const IssuerChecker&) = delete;
+  private:
+    IssuerChecker(const IssuerChecker&) /*= delete*/;
+    void operator=(const IssuerChecker&) /*= delete*/;
   };
 
   // Search for a CA certificate with the given name. The implementation must
   // call checker.Check with the DER encoding of the potential issuer
   // certificate. The implementation must follow these rules:
   //
   // * The implementation must be reentrant and must limit the amount of stack
   //   space it uses; see the note on reentrancy and stack usage below.
@@ -319,15 +320,16 @@ public:
   // other, extensive, memory safety efforts in mozilla::pkix, and we should
   // find a way to provide a more-obviously-safe interface.
   static const size_t DIGEST_LENGTH = 20; // length of SHA-1 digest
   virtual Result DigestBuf(Input item, /*out*/ uint8_t* digestBuf,
                            size_t digestBufLen) = 0;
 protected:
   TrustDomain() { }
 
-  TrustDomain(const TrustDomain&) = delete;
-  void operator=(const TrustDomain&) = delete;
+private:
+  TrustDomain(const TrustDomain&) /* = delete */;
+  void operator=(const TrustDomain&) /* = delete */;
 };
 
 } } // namespace mozilla::pkix
 
 #endif // mozilla_pkix__pkixtypes_h
--- a/security/pkix/lib/pkixbuild.cpp
+++ b/security/pkix/lib/pkixbuild.cpp
@@ -79,18 +79,18 @@ private:
   /*optional*/ Input const* const stapledOCSPResponse;
   const unsigned int subCACount;
   const Result deferredSubjectError;
 
   Result RecordResult(Result currentResult, /*out*/ bool& keepGoing);
   Result result;
   bool resultWasSet;
 
-  PathBuildingStep(const PathBuildingStep&) = delete;
-  void operator=(const PathBuildingStep&) = delete;
+  PathBuildingStep(const PathBuildingStep&) /*= delete*/;
+  void operator=(const PathBuildingStep&) /*= delete*/;
 };
 
 Result
 PathBuildingStep::RecordResult(Result newResult, /*out*/ bool& keepGoing)
 {
   if (newResult == Result::ERROR_UNTRUSTED_CERT) {
     newResult = Result::ERROR_UNTRUSTED_ISSUER;
   } else if (newResult == Result::ERROR_EXPIRED_CERTIFICATE) {
--- a/security/pkix/lib/pkixocsp.cpp
+++ b/security/pkix/lib/pkixocsp.cpp
@@ -66,18 +66,19 @@ public:
   const CertID& certID;
   const Time time;
   const uint16_t maxLifetimeInDays;
   CertStatus certStatus;
   Time* thisUpdate;
   Time* validThrough;
   bool expired;
 
-  Context(const Context&) = delete;
-  void operator=(const Context&) = delete;
+private:
+  Context(const Context&); // delete
+  void operator=(const Context&); // delete
 };
 
 // Verify that potentialSigner is a valid delegated OCSP response signing cert
 // according to RFC 6960 section 4.2.2.2.
 static Result
 CheckOCSPResponseSignerCert(TrustDomain& trustDomain,
                             BackCert& potentialSigner,
                             Input issuerSubject,
--- a/security/pkix/lib/pkixutil.h
+++ b/security/pkix/lib/pkixutil.h
@@ -138,18 +138,18 @@ private:
   Input keyUsage;
   Input nameConstraints;
   Input subjectAltName;
   Input criticalNetscapeCertificateType;
 
   Result RememberExtension(Reader& extnID, const Input& extnValue,
                            bool critical, /*out*/ bool& understood);
 
-  BackCert(const BackCert&) = delete;
-  void operator=(const BackCert&) = delete;
+  BackCert(const BackCert&) /* = delete */;
+  void operator=(const BackCert&); /* = delete */;
 };
 
 class NonOwningDERArray : public DERArray
 {
 public:
   NonOwningDERArray()
     : numItems(0)
   {
@@ -178,18 +178,18 @@ public:
   }
 
   // Public so we can static_assert on this. Keep in sync with MAX_SUBCA_COUNT.
   static const size_t MAX_LENGTH = 8;
 private:
   Input items[MAX_LENGTH]; // avoids any heap allocations
   size_t numItems;
 
-  NonOwningDERArray(const NonOwningDERArray&) = delete;
-  void operator=(const NonOwningDERArray&) = delete;
+  NonOwningDERArray(const NonOwningDERArray&) /* = delete*/;
+  void operator=(const NonOwningDERArray&) /* = delete*/;
 };
 
 inline unsigned int
 DaysBeforeYear(unsigned int year)
 {
   assert(year <= 9999);
   return ((year - 1u) * 365u)
        + ((year - 1u) / 4u)    // leap years are every 4 years,
--- a/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
+++ b/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
@@ -81,18 +81,19 @@ public:
     return TestDigestBuf(item, digestBuf, digestBufLen);
   }
 
   virtual Result CheckPublicKey(Input subjectPublicKeyInfo)
   {
     return TestCheckPublicKey(subjectPublicKeyInfo);
   }
 
-  OCSPTestTrustDomain(const OCSPTestTrustDomain&) = delete;
-  void operator=(const OCSPTestTrustDomain&) = delete;
+private:
+  OCSPTestTrustDomain(const OCSPTestTrustDomain&) /*delete*/;
+  void operator=(const OCSPTestTrustDomain&) /*delete*/;
 };
 
 namespace {
 char const* const rootName = "Test CA 1";
 void deleteCertID(CertID* certID) { delete certID; }
 } // unnamed namespace
 
 class pkixocsp_VerifyEncodedResponse : public ::testing::Test
--- a/security/pkix/test/lib/pkixtestutil.h
+++ b/security/pkix/test/lib/pkixtestutil.h
@@ -242,18 +242,18 @@ public:
   virtual TestKeyPair* Clone() const = 0;
 protected:
   TestKeyPair(const ByteString& spki, const ByteString& spk)
     : subjectPublicKeyInfo(spki)
     , subjectPublicKey(spk)
   {
   }
 
-  TestKeyPair(const TestKeyPair&) = delete;
-  void operator=(const TestKeyPair&) = delete;
+  TestKeyPair(const TestKeyPair&) /*= delete*/;
+  void operator=(const TestKeyPair&) /*= delete*/;
 };
 
 TestKeyPair* CloneReusedKeyPair();
 TestKeyPair* GenerateKeyPair();
 TestKeyPair* GenerateDSSKeyPair();
 inline void DeleteTestKeyPair(TestKeyPair* keyPair) { delete keyPair; }
 typedef ScopedPtr<TestKeyPair, DeleteTestKeyPair> ScopedTestKeyPair;
 
--- a/toolkit/devtools/server/actors/animation.js
+++ b/toolkit/devtools/server/actors/animation.js
@@ -173,16 +173,17 @@ let AnimationPlayerActor = ActorClass({
     response: {}
   }),
 
   /**
    * Play the player.
    */
   play: method(function() {
     this.player.play();
+    return this.player.ready;
   }, {
     request: {},
     response: {}
   })
 });
 
 let AnimationPlayerFront = FrontClass(AnimationPlayerActor, {
   AUTO_REFRESH_EVENT: "updated-state",
--- a/toolkit/devtools/server/tests/browser/browser_animation_actors_04.js
+++ b/toolkit/devtools/server/tests/browser/browser_animation_actors_04.js
@@ -33,18 +33,21 @@ function* playStateIsUpdatedDynamically(
   // using the CPOW.
   let cpow = content.document.querySelector(".short-animation");
   cpow.classList.remove("short-animation");
   let reflow = cpow.offsetWidth;
   cpow.classList.add("short-animation");
 
   let [player] = yield front.getAnimationPlayersForNode(node);
 
-  is(player.initialState.playState, "running",
-    "The playState is running while the transition is running");
+  // Bug 1113091 - We should wait for the player to become ready then
+  // test for the "running" state only
+  ok(player.initialState.playState == "running" ||
+     player.initialState.playState == "pending",
+    "The playState is running or pending while the transition is running");
 
   info("Wait until the animation stops (more than 1000ms)");
   yield wait(1500); // Waiting 1.5sec for good measure
 
   let state = yield player.getCurrentState();
   is(state.playState, "finished",
     "The animation has ended and the state has been updated");
   ok(state.currentTime > player.initialState.currentTime,
--- a/toolkit/modules/GMPInstallManager.jsm
+++ b/toolkit/modules/GMPInstallManager.jsm
@@ -111,16 +111,17 @@ let GMPPrefs = {
   _getPrefKey: function(key, addon) {
     return  key.replace("{0}", addon || "");
   },
 
   /**
    * List of keys which can be used in get and set
    */
   KEY_LOG_ENABLED: "media.gmp-manager.log",
+  KEY_ADDON_ENABLED: "media.{0}.enabled",
   KEY_ADDON_LAST_UPDATE: "media.{0}.lastUpdate",
   KEY_ADDON_VERSION: "media.{0}.version",
   KEY_ADDON_AUTOUPDATE: "media.{0}.autoupdate",
   KEY_URL: "media.gmp-manager.url",
   KEY_URL_OVERRIDE: "media.gmp-manager.url.override",
   KEY_CERT_CHECKATTRS: "media.gmp-manager.cert.checkAttributes",
   KEY_CERT_REQUIREBUILTIN: "media.gmp-manager.cert.requireBuiltIn",
   KEY_UPDATE_LAST_CHECK: "media.gmp-manager.lastCheck",
@@ -429,18 +430,20 @@ GMPInstallManager.prototype = {
   /**
    * Wrapper for checkForAddons and installAddon.
    * Will only install if not already installed and will log the results.
    * This will only install/update the OpenH264 plugin
    */
   simpleCheckAndInstall: function() {
     let log = getScopedLogger("simpleCheckAndInstall");
 
-    let autoUpdate = GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE,
-                                  OPEN_H264_ID, true);
+    let autoUpdate = GMPPrefs.get(GMPPrefs.KEY_ADDON_ENABLED, OPEN_H264_ID,
+                                  true) &&
+                     GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE, OPEN_H264_ID,
+                                  true);
     if (!autoUpdate) {
         log.info("Auto-update is off for openh264, aborting check.");
         return Promise.resolve({status: "check-disabled"});
     }
 
     let secondsBetweenChecks =
       GMPPrefs.get(GMPPrefs.KEY_UPDATE_SECONDS_BETWEEN_CHECKS, undefined,
                    DEFAULT_SECONDS_BETWEEN_CHECKS)
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -57,28 +57,28 @@ EXTRA_JS_MODULES += [
     'TelemetryTimestamps.jsm',
     'Timer.jsm',
     'WebChannel.jsm',
     'ZipUtils.jsm',
 ]
 
 EXTRA_PP_JS_MODULES += [
     'CertUtils.jsm',
+    'GMPInstallManager.jsm',
     'ResetProfile.jsm',
     'secondscreen/RokuApp.jsm',
     'Services.jsm',
     'Troubleshoot.jsm',
     'UpdateChannel.jsm',
     'WindowDraggingUtils.jsm',
     'WindowsPrefSync.jsm',
 ]
 
 if 'Android' != CONFIG['OS_TARGET']:
     EXTRA_PP_JS_MODULES += [
-        'GMPInstallManager.jsm',
         'LightweightThemeConsumer.jsm',
     ]
 else:
     DEFINES['ANDROID'] = True
 
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     EXTRA_JS_MODULES += [
--- a/toolkit/modules/tests/xpcshell/xpcshell.ini
+++ b/toolkit/modules/tests/xpcshell/xpcshell.ini
@@ -8,18 +8,16 @@ support-files =
   chromeappsstore.sqlite
   zips/zen.zip
 
 [test_BinarySearch.js]
 [test_DeferredTask.js]
 [test_dict.js]
 [test_FileUtils.js]
 [test_GMPInstallManager.js]
-# GMPInstallManager is not shipped on Android
-skip-if = os == 'android'
 [test_Http.js]
 [test_Log.js]
 [test_NewTabUtils.js]
 [test_PermissionsUtils.js]
 [test_Preferences.js]
 [test_Promise.js]
 [test_PromiseUtils.js]
 [test_propertyListsUtils.js]
--- a/toolkit/mozapps/extensions/extensions.manifest
+++ b/toolkit/mozapps/extensions/extensions.manifest
@@ -10,11 +10,11 @@ component {7beb3ba8-6ec3-41b4-b67c-da89b
 contract @mozilla.org/uriloader/content-handler;1?type=application/x-xpinstall {7beb3ba8-6ec3-41b4-b67c-da89b8518922}
 component {0f38e086-89a3-40a5-8ffc-9b694de1d04a} amWebInstallListener.js
 contract @mozilla.org/addons/web-install-listener;1 {0f38e086-89a3-40a5-8ffc-9b694de1d04a}
 component {9df8ef2b-94da-45c9-ab9f-132eb55fddf1} amInstallTrigger.js
 contract @mozilla.org/addons/installtrigger;1 {9df8ef2b-94da-45c9-ab9f-132eb55fddf1}
 category JavaScript-global-property InstallTrigger @mozilla.org/addons/installtrigger;1
 #ifndef MOZ_WIDGET_ANDROID
 category addon-provider-module PluginProvider resource://gre/modules/addons/PluginProvider.jsm
+#endif
 category addon-provider-module OpenH264Provider resource://gre/modules/addons/OpenH264Provider.jsm
 #endif
-#endif
--- a/toolkit/mozapps/extensions/internal/moz.build
+++ b/toolkit/mozapps/extensions/internal/moz.build
@@ -6,23 +6,23 @@
 
 EXTRA_JS_MODULES.addons += [
     'AddonLogging.jsm',
     'AddonRepository.jsm',
     'AddonRepository_SQLiteMigrator.jsm',
     'AddonUpdateChecker.jsm',
     'Content.js',
     'LightweightThemeImageOptimizer.jsm',
+    'OpenH264Provider.jsm',
     'SpellCheckDictionaryBootstrap.js',
 ]
 
 # Don't ship unused providers on Android
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
     EXTRA_JS_MODULES.addons += [
-        'OpenH264Provider.jsm',
         'PluginProvider.jsm',
     ]
 
 EXTRA_PP_JS_MODULES.addons += [
     'XPIProvider.jsm',
     'XPIProviderUtils.js',
 ]
 
--- a/toolkit/mozapps/extensions/test/browser/browser.ini
+++ b/toolkit/mozapps/extensions/test/browser/browser.ini
@@ -40,18 +40,16 @@ skip-if = e10s
 [browser_bug616841.js]
 [browser_cancelCompatCheck.js]
 [browser_checkAddonCompatibility.js]
 [browser_hotfix.js]
 [browser_installssl.js]
 [browser_newaddon.js]
 skip-if = e10s
 [browser_openH264.js]
-# OpenH264Provider.jsm is not shipped on Android
-skip-if = os == "android"
 [browser_select_compatoverrides.js]
 [browser_select_confirm.js]
 [browser_select_selection.js]
 [browser_select_update.js]
 [browser_updatessl.js]
 [browser_task_next_test.js]
 
 [include:browser-common.ini]
--- a/widget/cocoa/nsCocoaUtils.mm
+++ b/widget/cocoa/nsCocoaUtils.mm
@@ -391,17 +391,17 @@ nsresult nsCocoaUtils::CreateCGImageFrom
   if (!dataSurface->Map(DataSourceSurface::MapType::READ, &map)) {
     return NS_ERROR_FAILURE;
   }
   // The Unmap() call happens in data_ss_release_callback
 
   // Create a CGImageRef with the bits from the image, taking into account
   // the alpha ordering and endianness of the machine so we don't have to
   // touch the bits ourselves.
-  CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(dataSurface.forget().drop(),
+  CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(dataSurface.forget().take(),
                                                                   map.mData,
                                                                   map.mStride * height,
                                                                   data_ss_release_callback);
   CGColorSpaceRef colorSpace = ::CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
   *aResult = ::CGImageCreate(width,
                              height,
                              8,
                              32,
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1734,69 +1734,69 @@ public:
 
   NS_DECL_ISUPPORTS
 
   void SetAllTraces()
   {
     mWantAllTraces = true;
   }
 
-  NS_IMETHOD AllTraces(nsICycleCollectorListener** aListener)
+  NS_IMETHOD AllTraces(nsICycleCollectorListener** aListener) MOZ_OVERRIDE
   {
     SetAllTraces();
     NS_ADDREF(*aListener = this);
     return NS_OK;
   }
 
-  NS_IMETHOD GetWantAllTraces(bool* aAllTraces)
+  NS_IMETHOD GetWantAllTraces(bool* aAllTraces) MOZ_OVERRIDE
   {
     *aAllTraces = mWantAllTraces;
     return NS_OK;
   }
 
-  NS_IMETHOD GetDisableLog(bool* aDisableLog)
+  NS_IMETHOD GetDisableLog(bool* aDisableLog) MOZ_OVERRIDE
   {
     *aDisableLog = mDisableLog;
     return NS_OK;
   }
 
-  NS_IMETHOD SetDisableLog(bool aDisableLog)
+  NS_IMETHOD SetDisableLog(bool aDisableLog) MOZ_OVERRIDE
   {
     mDisableLog = aDisableLog;
     return NS_OK;
   }
 
-  NS_IMETHOD GetWantAfterProcessing(bool* aWantAfterProcessing)
+  NS_IMETHOD GetWantAfterProcessing(bool* aWantAfterProcessing) MOZ_OVERRIDE
   {
     *aWantAfterProcessing = mWantAfterProcessing;
     return NS_OK;
   }
 
-  NS_IMETHOD SetWantAfterProcessing(bool aWantAfterProcessing)
+  NS_IMETHOD SetWantAfterProcessing(bool aWantAfterProcessing) MOZ_OVERRIDE
   {
     mWantAfterProcessing = aWantAfterProcessing;
     return NS_OK;
   }
 
-  NS_IMETHOD GetLogSink(nsICycleCollectorLogSink** aLogSink)
+  NS_IMETHOD GetLogSink(nsICycleCollectorLogSink** aLogSink) MOZ_OVERRIDE
   {
     NS_ADDREF(*aLogSink = mLogSink);
     return NS_OK;
   }
 
-  NS_IMETHOD SetLogSink(nsICycleCollectorLogSink* aLogSink)
+  NS_IMETHOD SetLogSink(nsICycleCollectorLogSink* aLogSink) MOZ_OVERRIDE
   {
     if (!aLogSink) {
       return NS_ERROR_INVALID_ARG;
     }
     mLogSink = aLogSink;
     return NS_OK;
   }
 
-  NS_IMETHOD Begin()
+  NS_IMETHOD Begin() MOZ_OVERRIDE
   {
     nsresult rv;
 
     mCurrentAddress.AssignLiteral("0x");
     ClearDescribers();
     if (mDisableLog) {
       return NS_OK;
     }
@@ -1811,17 +1811,17 @@ public:
     }
     rv = mLogSink->CloseGCLog();
     NS_ENSURE_SUCCESS(rv, rv);
 
     fprintf(mCCLog, "# WantAllTraces=%s\n", mWantAllTraces ? "true" : "false");
     return NS_OK;
   }
   NS_IMETHOD NoteRefCountedObject(uint64_t aAddress, uint32_t aRefCount,
-                                  const char* aObjectDescription)
+                                  const char* aObjectDescription) MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fprintf(mCCLog, "%p [rc=%u] %s\n", (void*)aAddress, aRefCount,
               aObjectDescription);
     }
     if (mWantAfterProcessing) {
       CCGraphDescriber* d =  new CCGraphDescriber();
       mDescribers.insertBack(d);
@@ -1831,17 +1831,17 @@ public:
       d->mAddress = mCurrentAddress;
       d->mCnt = aRefCount;
       d->mName.Append(aObjectDescription);
     }
     return NS_OK;
   }
   NS_IMETHOD NoteGCedObject(uint64_t aAddress, bool aMarked,
                             const char* aObjectDescription,
-                            uint64_t aCompartmentAddress)
+                            uint64_t aCompartmentAddress) MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fprintf(mCCLog, "%p [gc%s] %s\n", (void*)aAddress,
               aMarked ? ".marked" : "", aObjectDescription);
     }
     if (mWantAfterProcessing) {
       CCGraphDescriber* d =  new CCGraphDescriber();
       mDescribers.insertBack(d);
@@ -1855,95 +1855,95 @@ public:
         d->mCompartmentOrToAddress.AssignLiteral("0x");
         d->mCompartmentOrToAddress.AppendInt(aCompartmentAddress, 16);
       } else {
         d->mCompartmentOrToAddress.SetIsVoid(true);
       }
     }
     return NS_OK;
   }
-  NS_IMETHOD NoteEdge(uint64_t aToAddress, const char* aEdgeName)
+  NS_IMETHOD NoteEdge(uint64_t aToAddress, const char* aEdgeName) MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fprintf(mCCLog, "> %p %s\n", (void*)aToAddress, aEdgeName);
     }
     if (mWantAfterProcessing) {
       CCGraphDescriber* d =  new CCGraphDescriber();
       mDescribers.insertBack(d);
       d->mType = CCGraphDescriber::eEdge;
       d->mAddress = mCurrentAddress;
       d->mCompartmentOrToAddress.AssignLiteral("0x");
       d->mCompartmentOrToAddress.AppendInt(aToAddress, 16);
       d->mName.Append(aEdgeName);
     }
     return NS_OK;
   }
   NS_IMETHOD NoteWeakMapEntry(uint64_t aMap, uint64_t aKey,
-                              uint64_t aKeyDelegate, uint64_t aValue)
+                              uint64_t aKeyDelegate, uint64_t aValue) MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fprintf(mCCLog, "WeakMapEntry map=%p key=%p keyDelegate=%p value=%p\n",
               (void*)aMap, (void*)aKey, (void*)aKeyDelegate, (void*)aValue);
     }
     // We don't support after-processing for weak map entries.
     return NS_OK;
   }
-  NS_IMETHOD NoteIncrementalRoot(uint64_t aAddress)
+  NS_IMETHOD NoteIncrementalRoot(uint64_t aAddress) MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fprintf(mCCLog, "IncrementalRoot %p\n", (void*)aAddress);
     }
     // We don't support after-processing for incremental roots.
     return NS_OK;
   }
-  NS_IMETHOD BeginResults()
+  NS_IMETHOD BeginResults() MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fputs("==========\n", mCCLog);
     }
     return NS_OK;
   }
-  NS_IMETHOD DescribeRoot(uint64_t aAddress, uint32_t aKnownEdges)
+  NS_IMETHOD DescribeRoot(uint64_t aAddress, uint32_t aKnownEdges) MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fprintf(mCCLog, "%p [known=%u]\n", (void*)aAddress, aKnownEdges);
     }
     if (mWantAfterProcessing) {
       CCGraphDescriber* d =  new CCGraphDescriber();
       mDescribers.insertBack(d);
       d->mType = CCGraphDescriber::eRoot;
       d->mAddress.AppendInt(aAddress, 16);
       d->mCnt = aKnownEdges;
     }
     return NS_OK;
   }
-  NS_IMETHOD DescribeGarbage(uint64_t aAddress)
+  NS_IMETHOD DescribeGarbage(uint64_t aAddress) MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       fprintf(mCCLog, "%p [garbage]\n", (void*)aAddress);
     }
     if (mWantAfterProcessing) {
       CCGraphDescriber* d =  new CCGraphDescriber();
       mDescribers.insertBack(d);
       d->mType = CCGraphDescriber::eGarbage;
       d->mAddress.AppendInt(aAddress, 16);
     }
     return NS_OK;
   }
-  NS_IMETHOD End()
+  NS_IMETHOD End() MOZ_OVERRIDE
   {
     if (!mDisableLog) {
       mCCLog = nullptr;
       nsresult rv = mLogSink->CloseCCLog();
       NS_ENSURE_SUCCESS(rv, rv);
     }
     return NS_OK;
   }
   NS_IMETHOD ProcessNext(nsICycleCollectorHandler* aHandler,
-                         bool* aCanContinue)
+                         bool* aCanContinue) MOZ_OVERRIDE
   {
     if (NS_WARN_IF(!aHandler) || NS_WARN_IF(!mWantAfterProcessing)) {
       return NS_ERROR_UNEXPECTED;
     }
     CCGraphDescriber* d = mDescribers.popFirst();
     if (d) {
       switch (d->mType) {
         case CCGraphDescriber::eRefCountedObject:
--- a/xpcom/base/nsDumpUtils.h
+++ b/xpcom/base/nsDumpUtils.h
@@ -57,18 +57,18 @@ public:
    * Open the fd to watch.  If we encounter an error, return -1.
    */
   virtual int OpenFd() = 0;
 
   /**
    * Called when you can read() from the fd without blocking.  Note that this
    * function is also called when you're at eof (read() returns 0 in this case).
    */
-  virtual void OnFileCanReadWithoutBlocking(int aFd) = 0;
-  virtual void OnFileCanWriteWithoutBlocking(int aFd) {};
+  virtual void OnFileCanReadWithoutBlocking(int aFd) MOZ_OVERRIDE = 0;
+  virtual void OnFileCanWriteWithoutBlocking(int aFd) MOZ_OVERRIDE {};
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
   /**
    * Initialize this object.  This should be called right after the object is
    * constructed.  (This would go in the constructor, except we interact with
    * XPCOM, which we can't do from a constructor because our refcount is 0 at
    * that point.)
@@ -79,17 +79,17 @@ public:
 
   virtual void StartWatching();
 
   // Since implementations can call StartWatching() multiple times, they can of
   // course call StopWatching() multiple times.
   virtual void StopWatching();
 
   NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
-                     const char16_t* aData)
+                     const char16_t* aData) MOZ_OVERRIDE
   {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown"));
 
     XRE_GetIOMessageLoop()->PostTask(
       FROM_HERE,
       NewRunnableMethod(this, &FdWatcher::StopWatching));
 
--- a/xpcom/base/nsIStatusReporter.idl
+++ b/xpcom/base/nsIStatusReporter.idl
@@ -64,21 +64,21 @@ interface nsIStatusReporterManager : nsI
 /*
  * Note that this defaults 'process' to "", which is usually what's desired.
  */
 #define NS_STATUS_REPORTER_IMPLEMENT(_classname, _name, _desc_Function)       \
     class StatusReporter_##_classname MOZ_FINAL : public nsIStatusReporter {  \
       ~StatusReporter_##_classname() {}                                       \
     public:                                                                   \
       NS_DECL_ISUPPORTS                                                       \
-      NS_IMETHOD GetName(nsACString &name)                                    \
+      NS_IMETHOD GetName(nsACString &name) MOZ_OVERRIDE                       \
         { name.AssignLiteral(_name); return NS_OK; }                          \
-      NS_IMETHOD GetProcess(nsACString &process)                              \
+      NS_IMETHOD GetProcess(nsACString &process) MOZ_OVERRIDE                 \
         { process.Truncate(); return NS_OK; }                                 \
-      NS_IMETHOD GetDescription(nsACString &desc)                             \
+      NS_IMETHOD GetDescription(nsACString &desc) MOZ_OVERRIDE                \
         { _desc_Function(desc); return NS_OK; }                               \
     };                                                                        \
     NS_IMPL_ISUPPORTS(StatusReporter_##_classname, nsIStatusReporter)
 
 #define NS_STATUS_REPORTER_NAME(_classname)  StatusReporter_##_classname
 
 nsresult NS_RegisterStatusReporter(nsIStatusReporter *reporter);
 nsresult NS_UnregisterStatusReporter(nsIStatusReporter *reporter);
--- a/xpcom/base/nsMemoryImpl.h
+++ b/xpcom/base/nsMemoryImpl.h
@@ -15,22 +15,22 @@
 // nsMemoryImpl is a static object. We can do this because it doesn't have
 // a constructor/destructor or any instance members. Please don't add
 // instance member variables, only static member variables.
 
 class nsMemoryImpl : public nsIMemory
 {
 public:
   // We don't use the generic macros because we are a special static object
-  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void)
+  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult) MOZ_OVERRIDE;
+  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) MOZ_OVERRIDE
   {
     return 1;
   }
-  NS_IMETHOD_(MozExternalRefCountType) Release(void)
+  NS_IMETHOD_(MozExternalRefCountType) Release(void) MOZ_OVERRIDE
   {
     return 1;
   }
 
   NS_DECL_NSIMEMORY
 
   static nsresult Create(nsISupports* aOuter,
                          const nsIID& aIID, void** aResult);
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -324,22 +324,22 @@ class nsDumpGCAndCCLogsCallbackHolder MO
 public:
   NS_DECL_ISUPPORTS
 
   explicit nsDumpGCAndCCLogsCallbackHolder(nsIDumpGCAndCCLogsCallback* aCallback)
     : mCallback(aCallback)
   {
   }
 
-  NS_IMETHODIMP OnFinish()
+  NS_IMETHODIMP OnFinish() MOZ_OVERRIDE
   {
     return NS_ERROR_UNEXPECTED;
   }
 
-  NS_IMETHODIMP OnDump(nsIFile* aGCLog, nsIFile* aCCLog, bool aIsParent)
+  NS_IMETHODIMP OnDump(nsIFile* aGCLog, nsIFile* aCCLog, bool aIsParent) MOZ_OVERRIDE
   {
     return mCallback->OnDump(aGCLog, aCCLog, aIsParent);
   }
 
 private:
   ~nsDumpGCAndCCLogsCallbackHolder()
   {
     unused << mCallback->OnFinish();
@@ -470,17 +470,17 @@ public:
     , mFinishDumpingData(aFinishDumpingData)
   {
   }
 
   // This is the callback for nsIHandleReportCallback.
   NS_IMETHOD Callback(const nsACString& aProcess, const nsACString& aPath,
                       int32_t aKind, int32_t aUnits, int64_t aAmount,
                       const nsACString& aDescription,
-                      nsISupports* aData)
+                      nsISupports* aData) MOZ_OVERRIDE
   {
     nsAutoCString process;
     if (aProcess.IsEmpty()) {
       // If the process is empty, the report originated with the process doing
       // the dumping.  In that case, generate the process identifier, which is
       // of the form "$PROCESS_NAME (pid $PID)", or just "(pid $PID)" if we
       // don't have a process name.  If we're the main process, we let
       // $PROCESS_NAME be "Main Process".
@@ -510,17 +510,17 @@ public:
                               PromiseFlatCString(aDescription).get());
     }
     mWriter->EndObject();
 
     return NS_OK;
   }
 
   // This is the callback for nsIFinishReportingCallback.
-  NS_IMETHOD Callback(nsISupports* aData)
+  NS_IMETHOD Callback(nsISupports* aData) MOZ_OVERRIDE
   {
     mWriter->EndArray();  // end of "reports" array
     mWriter->End();
 
     // The call to Finish() deallocates the memory allocated by the first Write
     // call. Because that memory was live while the memory reporters ran and
     // was measured by them -- by "heap-allocated" if nothing else -- we want
     // DMD to see it as well. So we deliberately don't call Finish() until
@@ -553,17 +553,17 @@ public:
 
   TempDirFinishCallback(nsIFile* aReportsTmpFile,
                         const nsCString& aReportsFinalFilename)
     : mReportsTmpFile(aReportsTmpFile)
     , mReportsFilename(aReportsFinalFilename)
   {
   }
 
-  NS_IMETHOD Callback(nsISupports* aData)
+  NS_IMETHOD Callback(nsISupports* aData) MOZ_OVERRIDE
   {
     // Rename the memory reports file, now that we're done writing all the
     // files. Its final name is "memory-report<-identifier>-<pid>.json.gz".
 
     nsCOMPtr<nsIFile> reportsFinalFile;
     nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR,
                                          getter_AddRefs(reportsFinalFile));
     if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -597,17 +597,17 @@ NS_IMPL_ISUPPORTS(PrivateReporter, nsIMe
 class VsizeReporter MOZ_FINAL : public nsIMemoryReporter
 {
   ~VsizeReporter() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                           nsISupports* aData, bool aAnonymize)
+                           nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE
   {
     int64_t amount;
     nsresult rv = VsizeDistinguishedAmount(&amount);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return MOZ_COLLECT_REPORT(
       "vsize", KIND_OTHER, UNITS_BYTES, amount,
 "Memory mapped by the process, including code and data segments, the heap, "
@@ -624,17 +624,17 @@ NS_IMPL_ISUPPORTS(VsizeReporter, nsIMemo
 class ResidentReporter MOZ_FINAL : public nsIMemoryReporter
 {
   ~ResidentReporter() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                           nsISupports* aData, bool aAnonymize)
+                           nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE
   {
     int64_t amount;
     nsresult rv = ResidentDistinguishedAmount(&amount);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return MOZ_COLLECT_REPORT(
       "resident", KIND_OTHER, UNITS_BYTES, amount,
 "Memory mapped by the process that is present in physical memory, also known "
@@ -658,17 +658,17 @@ NS_IMPL_ISUPPORTS(ResidentReporter, nsIM
 class PageFaultsSoftReporter MOZ_FINAL : public nsIMemoryReporter
 {
   ~PageFaultsSoftReporter() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                           nsISupports* aData, bool aAnonymize)
+                           nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE
   {
     struct rusage usage;
     int err = getrusage(RUSAGE_SELF, &usage);
     if (err != 0) {
       return NS_ERROR_FAILURE;
     }
     int64_t amount = usage.ru_minflt;
 
@@ -702,17 +702,17 @@ PageFaultsHardDistinguishedAmount(int64_
 class PageFaultsHardReporter MOZ_FINAL : public nsIMemoryReporter
 {
   ~PageFaultsHardReporter() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                           nsISupports* aData, bool aAnonymize)
+                           nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE
   {
     int64_t amount = 0;
     nsresult rv = PageFaultsHardDistinguishedAmount(&amount);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return MOZ_COLLECT_REPORT(
       "page-faults-hard", KIND_OTHER, UNITS_COUNT_CUMULATIVE, amount,
 "The number of hard page faults (also known as 'major page faults') that have "
@@ -751,17 +751,17 @@ HeapOverheadRatio(jemalloc_stats_t* aSta
 class JemallocHeapReporter MOZ_FINAL : public nsIMemoryReporter
 {
   ~JemallocHeapReporter() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                           nsISupports* aData, bool aAnonymize)
+                           nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE
   {
     jemalloc_stats_t stats;
     jemalloc_stats(&stats);
 
     nsresult rv;
 
     rv = MOZ_COLLECT_REPORT(
       "heap-allocated", KIND_OTHER, UNITS_BYTES, stats.allocated,
@@ -857,17 +857,17 @@ class AtomTablesReporter MOZ_FINAL : pub
   MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
 
   ~AtomTablesReporter() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                           nsISupports* aData, bool aAnonymize)
+                           nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE
   {
     size_t Main, Static;
     NS_SizeOfAtomTablesIncludingThis(MallocSizeOf, &Main, &Static);
 
     nsresult rv;
     rv = MOZ_COLLECT_REPORT(
       "explicit/atom-tables/main", KIND_HEAP, UNITS_BYTES, Main,
       "Memory used by the main atoms table.");
@@ -894,17 +894,17 @@ class DeadlockDetectorReporter MOZ_FINAL
   MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
 
   ~DeadlockDetectorReporter() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                           nsISupports* aData, bool aAnonymize)
+                           nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE
   {
     return MOZ_COLLECT_REPORT(
       "explicit/deadlock-detector", KIND_HEAP, UNITS_BYTES,
       BlockingResourceBase::SizeOfDeadlockDetector(MallocSizeOf),
       "Memory used by the deadlock detector.");
   }
 };
 NS_IMPL_ISUPPORTS(DeadlockDetectorReporter, nsIMemoryReporter)
@@ -1573,17 +1573,17 @@ class ExplicitCallback MOZ_FINAL : publi
   ~ExplicitCallback() {}
 
 public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Callback(const nsACString& aProcess, const nsACString& aPath,
                       int32_t aKind, int32_t aUnits, int64_t aAmount,
                       const nsACString& aDescription,
-                      nsISupports* aWrappedExplicit)
+                      nsISupports* aWrappedExplicit) MOZ_OVERRIDE
   {
     // Using the "heap-allocated" reporter here instead of
     // nsMemoryReporterManager.heapAllocated goes against the usual
     // pattern.  But it's for a good reason:  in tests, we can easily
     // create artificial (i.e. deterministic) reporters -- which allows us
     // to precisely test nsMemoryReporterManager.explicit -- but we can't
     // do that for distinguished amounts.
     if (aPath.EqualsLiteral("heap-allocated") ||
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -376,17 +376,17 @@ public:
   static void Free(const void*, void* aPtr)
   {
     return CountingFree(aPtr);
   }
 
 private:
   NS_IMETHODIMP
   CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
-                 bool aAnonymize)
+                 bool aAnonymize) MOZ_OVERRIDE
   {
     return MOZ_COLLECT_REPORT(
       "explicit/icu", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
       "Memory used by ICU, a Unicode and globalization support library.");
   }
 
   ~ICUReporter() {}
 };
@@ -401,17 +401,17 @@ class OggReporter MOZ_FINAL
   , public CountingAllocatorBase<OggReporter>
 {
 public:
   NS_DECL_ISUPPORTS
 
 private:
   NS_IMETHODIMP
   CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
-                 bool aAnonymize)
+                 bool aAnonymize) MOZ_OVERRIDE
   {
     return MOZ_COLLECT_REPORT(
       "explicit/media/libogg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
       "Memory allocated through libogg for Ogg, Theora, and related media files.");
   }
 
   ~OggReporter() {}
 };
@@ -427,17 +427,17 @@ class VPXReporter MOZ_FINAL
   , public CountingAllocatorBase<VPXReporter>
 {
 public:
   NS_DECL_ISUPPORTS
 
 private:
   NS_IMETHODIMP
   CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
-                 bool aAnonymize)
+                 bool aAnonymize) MOZ_OVERRIDE
   {
     return MOZ_COLLECT_REPORT(
       "explicit/media/libvpx", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
       "Memory allocated through libvpx for WebM media files.");
   }
 
   ~VPXReporter() {}
 };
@@ -454,17 +454,17 @@ class NesteggReporter MOZ_FINAL
   , public CountingAllocatorBase<NesteggReporter>
 {
 public:
   NS_DECL_ISUPPORTS
 
 private:
   NS_IMETHODIMP
   CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
-                 bool aAnonymize)
+                 bool aAnonymize) MOZ_OVERRIDE
   {
     return MOZ_COLLECT_REPORT(
       "explicit/media/libnestegg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
       "Memory allocated through libnestegg for WebM media files.");
   }
 
   ~NesteggReporter() {}
 };
--- a/xpcom/ds/nsExpirationTracker.h
+++ b/xpcom/ds/nsExpirationTracker.h
@@ -1,28 +1,26 @@
 /* -*- 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/. */
 
 #ifndef NSEXPIRATIONTRACKER_H_
 #define NSEXPIRATIONTRACKER_H_
 
-#include "mozilla/Attributes.h"
-
 #include "prlog.h"
 #include "nsTArray.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
+#include "mozilla/Attributes.h"
 #include "mozilla/Services.h"
-#include "mozilla/Attributes.h"
 
 /**
  * Data used to track the expiration state of an object. We promise that this
  * is 32 bits so that objects that includes this as a field can pad and align
  * efficiently.
  */
 struct nsExpirationState
 {
--- a/xpcom/ds/nsStringEnumerator.cpp
+++ b/xpcom/ds/nsStringEnumerator.cpp
@@ -50,17 +50,17 @@ public:
     , mIsUnicode(false)
   {}
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIUTF8STRINGENUMERATOR
 
   // have to declare nsIStringEnumerator manually, because of
   // overlapping method names
-  NS_IMETHOD GetNext(nsAString& aResult);
+  NS_IMETHOD GetNext(nsAString& aResult) MOZ_OVERRIDE;
   NS_DECL_NSISIMPLEENUMERATOR
 
 private:
   ~nsStringEnumerator()
   {
     if (mOwnsArray) {
       // const-casting is safe here, because the NS_New*
       // constructors make sure mOwnsArray is consistent with
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -447,25 +447,25 @@ nsSupportsArray::RemoveElementsAt(uint32
       ::memmove(mArray + aIndex, mArray + aIndex + aCount,
                 slide * sizeof(nsISupports*));
     }
     return true;
   }
   return false;
 }
 
-NS_IMETHODIMP_(bool)
-nsSupportsArray::RemoveElement(const nsISupports* aElement, uint32_t aStartIndex)
+NS_IMETHODIMP
+nsSupportsArray::RemoveElement(nsISupports* aElement)
 {
-  int32_t theIndex = IndexOfStartingAt(aElement, aStartIndex);
+  int32_t theIndex = IndexOfStartingAt(aElement, 0);
   if (theIndex >= 0) {
-    return RemoveElementAt(theIndex);
+    return RemoveElementAt(theIndex) ? NS_OK : NS_ERROR_FAILURE;
   }
 
-  return false;
+  return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP_(bool)
 nsSupportsArray::RemoveLastElement(const nsISupports* aElement)
 {
   int32_t theIndex = LastIndexOf(aElement);
   if (theIndex >= 0) {
     return RemoveElementAt(theIndex);
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -21,119 +21,113 @@ public:
   nsSupportsArray(void);
   static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
   NS_DECL_NSISERIALIZABLE
 
   // nsICollection methods:
-  NS_IMETHOD Count(uint32_t* aResult)
+  NS_IMETHOD Count(uint32_t* aResult) MOZ_OVERRIDE
   {
     *aResult = mCount;
     return NS_OK;
   }
-  NS_IMETHOD GetElementAt(uint32_t aIndex, nsISupports** aResult);
-  NS_IMETHOD QueryElementAt(uint32_t aIndex, const nsIID& aIID, void** aResult)
+  NS_IMETHOD GetElementAt(uint32_t aIndex, nsISupports** aResult) MOZ_OVERRIDE;
+  NS_IMETHOD QueryElementAt(uint32_t aIndex, const nsIID& aIID, void** aResult) MOZ_OVERRIDE
   {
     if (aIndex < mCount) {
       nsISupports* element = mArray[aIndex];
       if (element) {
         return element->QueryInterface(aIID, aResult);
       }
     }
     return NS_ERROR_FAILURE;
   }
-  NS_IMETHOD SetElementAt(uint32_t aIndex, nsISupports* aValue)
+  NS_IMETHOD SetElementAt(uint32_t aIndex, nsISupports* aValue) MOZ_OVERRIDE
   {
     return ReplaceElementAt(aValue, aIndex) ? NS_OK : NS_ERROR_FAILURE;
   }
-  NS_IMETHOD AppendElement(nsISupports* aElement)
+  NS_IMETHOD AppendElement(nsISupports* aElement) MOZ_OVERRIDE
   {
     // XXX Invalid cast of bool to nsresult (bug 778110)
     return (nsresult)InsertElementAt(aElement, mCount)/* ? NS_OK : NS_ERROR_FAILURE*/;
   }
   // XXX this is badly named - should be RemoveFirstElement
-  NS_IMETHOD RemoveElement(nsISupports* aElement)
-  {
-    // XXX Invalid cast of bool to nsresult (bug 778110)
-    return (nsresult)RemoveElement(aElement, 0)/* ? NS_OK : NS_ERROR_FAILURE*/;
-  }
-  NS_IMETHOD_(bool) MoveElement(int32_t aFrom, int32_t aTo);
-  NS_IMETHOD Enumerate(nsIEnumerator** aResult);
-  NS_IMETHOD Clear(void);
+  NS_IMETHOD RemoveElement(nsISupports* aElement) MOZ_OVERRIDE;
+  NS_IMETHOD_(bool) MoveElement(int32_t aFrom, int32_t aTo) MOZ_OVERRIDE;
+  NS_IMETHOD Enumerate(nsIEnumerator** aResult) MOZ_OVERRIDE;
+  NS_IMETHOD Clear(void) MOZ_OVERRIDE;
 
   // nsISupportsArray methods:
-  NS_IMETHOD_(bool) Equals(const nsISupportsArray* aOther);
+  NS_IMETHOD_(bool) Equals(const nsISupportsArray* aOther) MOZ_OVERRIDE;
 
-  NS_IMETHOD_(int32_t) IndexOf(const nsISupports* aPossibleElement);
+  NS_IMETHOD_(int32_t) IndexOf(const nsISupports* aPossibleElement) MOZ_OVERRIDE;
   NS_IMETHOD_(int32_t) IndexOfStartingAt(const nsISupports* aPossibleElement,
-                                         uint32_t aStartIndex = 0);
-  NS_IMETHOD_(int32_t) LastIndexOf(const nsISupports* aPossibleElement);
+                                         uint32_t aStartIndex = 0) MOZ_OVERRIDE;
+  NS_IMETHOD_(int32_t) LastIndexOf(const nsISupports* aPossibleElement) MOZ_OVERRIDE;
 
-  NS_IMETHOD GetIndexOf(nsISupports* aPossibleElement, int32_t* aResult)
+  NS_IMETHOD GetIndexOf(nsISupports* aPossibleElement, int32_t* aResult) MOZ_OVERRIDE
   {
     *aResult = IndexOf(aPossibleElement);
     return NS_OK;
   }
 
   NS_IMETHOD GetIndexOfStartingAt(nsISupports* aPossibleElement,
-                                  uint32_t aStartIndex, int32_t* aResult)
+                                  uint32_t aStartIndex, int32_t* aResult) MOZ_OVERRIDE
   {
     *aResult = IndexOfStartingAt(aPossibleElement, aStartIndex);
     return NS_OK;
   }
 
-  NS_IMETHOD GetLastIndexOf(nsISupports* aPossibleElement, int32_t* aResult)
+  NS_IMETHOD GetLastIndexOf(nsISupports* aPossibleElement, int32_t* aResult) MOZ_OVERRIDE
   {
     *aResult = LastIndexOf(aPossibleElement);
     return NS_OK;
   }
 
-  NS_IMETHOD_(bool) InsertElementAt(nsISupports* aElement, uint32_t aIndex);
+  NS_IMETHOD_(bool) InsertElementAt(nsISupports* aElement, uint32_t aIndex) MOZ_OVERRIDE;
 
-  NS_IMETHOD_(bool) ReplaceElementAt(nsISupports* aElement, uint32_t aIndex);
+  NS_IMETHOD_(bool) ReplaceElementAt(nsISupports* aElement, uint32_t aIndex) MOZ_OVERRIDE;
 
-  NS_IMETHOD_(bool) RemoveElementAt(uint32_t aIndex)
+  NS_IMETHOD_(bool) RemoveElementAt(uint32_t aIndex) MOZ_OVERRIDE
   {
     return RemoveElementsAt(aIndex, 1);
   }
-  NS_IMETHOD_(bool) RemoveElement(const nsISupports* aElement,
-                                  uint32_t aStartIndex = 0);
-  NS_IMETHOD_(bool) RemoveLastElement(const nsISupports* aElement);
+  NS_IMETHOD_(bool) RemoveLastElement(const nsISupports* aElement) MOZ_OVERRIDE;
 
-  NS_IMETHOD DeleteLastElement(nsISupports* aElement)
+  NS_IMETHOD DeleteLastElement(nsISupports* aElement) MOZ_OVERRIDE
   {
     return (RemoveLastElement(aElement) ? NS_OK : NS_ERROR_FAILURE);
   }
 
-  NS_IMETHOD DeleteElementAt(uint32_t aIndex)
+  NS_IMETHOD DeleteElementAt(uint32_t aIndex) MOZ_OVERRIDE
   {
     return (RemoveElementAt(aIndex) ? NS_OK : NS_ERROR_FAILURE);
   }
 
-  NS_IMETHOD_(bool) AppendElements(nsISupportsArray* aElements)
+  NS_IMETHOD_(bool) AppendElements(nsISupportsArray* aElements) MOZ_OVERRIDE
   {
     return InsertElementsAt(aElements, mCount);
   }
 
-  NS_IMETHOD Compact(void);
+  NS_IMETHOD Compact(void) MOZ_OVERRIDE;
 
-  NS_IMETHOD Clone(nsISupportsArray** aResult);
+  NS_IMETHOD Clone(nsISupportsArray** aResult) MOZ_OVERRIDE;
 
   NS_IMETHOD_(bool) InsertElementsAt(nsISupportsArray* aOther,
-                                     uint32_t aIndex);
+                                     uint32_t aIndex) MOZ_OVERRIDE;
 
-  NS_IMETHOD_(bool) RemoveElementsAt(uint32_t aIndex, uint32_t aCount);
+  NS_IMETHOD_(bool) RemoveElementsAt(uint32_t aIndex, uint32_t aCount) MOZ_OVERRIDE;
 
-  NS_IMETHOD_(bool) SizeTo(int32_t aSize);
+  NS_IMETHOD_(bool) SizeTo(int32_t aSize) MOZ_OVERRIDE;
 protected:
   void DeleteArray(void);
 
-  NS_IMETHOD_(void) GrowArrayBy(int32_t aGrowBy);
+  void GrowArrayBy(int32_t aGrowBy);
 
   nsISupports** mArray;
   uint32_t mArraySize;
   uint32_t mCount;
   nsISupports*  mAutoArray[kAutoArraySize];
 #if DEBUG_SUPPORTSARRAY
   uint32_t mMaxCount;
   uint32_t mMaxSize;
--- a/xpcom/glue/nsCycleCollectionParticipant.h
+++ b/xpcom/glue/nsCycleCollectionParticipant.h
@@ -478,26 +478,36 @@ DowncastCCParticipant(void* aPtr)
 
 ///////////////////////////////////////////////////////////////////////////////
 // Helpers for implementing a concrete nsCycleCollectionParticipant
 ///////////////////////////////////////////////////////////////////////////////
 
 // If a class defines a participant, then QIing an instance of that class to
 // nsXPCOMCycleCollectionParticipant should produce that participant.
 #ifdef DEBUG
-#define NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL(_class)                            \
-    virtual void CheckForRightParticipant()                                    \
+#define NS_CHECK_FOR_RIGHT_PARTICIPANT_BASE                                    \
+    virtual void CheckForRightParticipant()
+#define NS_CHECK_FOR_RIGHT_PARTICIPANT_DERIVED                                 \
+    virtual void CheckForRightParticipant() MOZ_OVERRIDE
+#define NS_CHECK_FOR_RIGHT_PARTICIPANT_BODY(_class)                            \
     {                                                                          \
       nsXPCOMCycleCollectionParticipant *p;                                    \
       CallQueryInterface(this, &p);                                            \
       MOZ_ASSERT(p == &NS_CYCLE_COLLECTION_INNERNAME,                          \
                  #_class " should QI to its own CC participant");              \
     }
+#define NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL(_class)                            \
+    NS_CHECK_FOR_RIGHT_PARTICIPANT_BASE                                        \
+    NS_CHECK_FOR_RIGHT_PARTICIPANT_BODY(_class)
+#define NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL_INHERITED(_class)                  \
+    NS_CHECK_FOR_RIGHT_PARTICIPANT_DERIVED                                     \
+    NS_CHECK_FOR_RIGHT_PARTICIPANT_BODY(_class)
 #else
 #define NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL(_class)
+#define NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL_INHERITED(_class)
 #endif
 
 #define NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base)           \
 public:                                                                        \
   NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb);        \
   NS_IMETHOD_(void) DeleteCycleCollectable(void *p)                            \
   {                                                                            \
     DowncastCCParticipant<_class>(p)->DeleteCycleCollectable();                \
@@ -616,17 +626,17 @@ class NS_CYCLE_COLLECTION_INNERCLASS    
 {                                                                                      \
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class)                   \
   NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure);           \
   NS_IMETHOD_(bool) CanSkipReal(void *p, bool aRemovingAllowed);                       \
   NS_IMETHOD_(bool) CanSkipInCCReal(void *p);                                          \
   NS_IMETHOD_(bool) CanSkipThisReal(void *p);                                          \
   NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                               \
 }; \
-NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL(_class)  \
+NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL_INHERITED(_class)  \
 static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
 
 #define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(_class)  \
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class)
 
 #define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class,        \
                                                                 _base_class)   \
 public:                                                                        \
@@ -644,41 +654,41 @@ public:                                 
 #define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(_class, _base_class)          \
 class NS_CYCLE_COLLECTION_INNERCLASS                                           \
  : public NS_CYCLE_COLLECTION_CLASSNAME(_base_class)                           \
 {                                                                              \
 public:                                                                        \
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class)           \
   NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                       \
 };                                                                             \
-NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL(_class)                                    \
+NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL_INHERITED(_class)                          \
 static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
 
 #define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(_class,             \
                                                            _base_class)        \
 class NS_CYCLE_COLLECTION_INNERCLASS                                           \
  : public NS_CYCLE_COLLECTION_CLASSNAME(_base_class)                           \
 {                                                                              \
 public:                                                                        \
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \
   NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                       \
 };                                                                             \
-NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL(_class)                                    \
+NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL_INHERITED(_class)                          \
 static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
 
 #define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(_class,                 \
                                                                _base_class)            \
 class NS_CYCLE_COLLECTION_INNERCLASS                                                   \
  : public NS_CYCLE_COLLECTION_CLASSNAME(_base_class)                                   \
 {                                                                                      \
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class)                   \
   NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure);           \
   NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                               \
 };                                                                                     \
-NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL(_class)                                            \
+NS_CHECK_FOR_RIGHT_PARTICIPANT_IMPL_INHERITED(_class)                                  \
 static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
 
 // Cycle collector participant declarations.
 
 #define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class)                     \
   public:                                                                      \
     NS_IMETHOD_(void) Root(void *n);                                           \
     NS_IMETHOD_(void) Unlink(void *n);                                         \
--- a/xpcom/glue/nsEnumeratorUtils.cpp
+++ b/xpcom/glue/nsEnumeratorUtils.cpp
@@ -24,17 +24,17 @@ public:
   // nsISupports interface
   NS_DECL_ISUPPORTS_INHERITED  // not really inherited, but no mRefCnt
 
   // nsISimpleEnumerator
   NS_DECL_NSISIMPLEENUMERATOR
   NS_DECL_NSIUTF8STRINGENUMERATOR
   // can't use NS_DECL_NSISTRINGENUMERATOR because they share the
   // HasMore() signature
-  NS_IMETHOD GetNext(nsAString& aResult);
+  NS_IMETHOD GetNext(nsAString& aResult) MOZ_OVERRIDE;
 
   static EmptyEnumeratorImpl* GetInstance()
   {
     static const EmptyEnumeratorImpl kInstance;
     return const_cast<EmptyEnumeratorImpl*>(&kInstance);
   }
 };
 
@@ -97,18 +97,18 @@ NS_NewEmptyEnumerator(nsISimpleEnumerato
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsSingletonEnumerator MOZ_FINAL : public nsISimpleEnumerator
 {
 public:
   NS_DECL_ISUPPORTS
 
   // nsISimpleEnumerator methods
-  NS_IMETHOD HasMoreElements(bool* aResult);
-  NS_IMETHOD GetNext(nsISupports** aResult);
+  NS_IMETHOD HasMoreElements(bool* aResult) MOZ_OVERRIDE;
+  NS_IMETHOD GetNext(nsISupports** aResult) MOZ_OVERRIDE;
 
   explicit nsSingletonEnumerator(nsISupports* aValue);
 
 private:
   ~nsSingletonEnumerator();
 
 protected:
   nsCOMPtr<nsISupports> mValue;
@@ -175,18 +175,18 @@ NS_NewSingletonEnumerator(nsISimpleEnume
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsUnionEnumerator MOZ_FINAL : public nsISimpleEnumerator
 {
 public:
   NS_DECL_ISUPPORTS
 
   // nsISimpleEnumerator methods
-  NS_IMETHOD HasMoreElements(bool* aResult);
-  NS_IMETHOD GetNext(nsISupports** aResult);
+  NS_IMETHOD HasMoreElements(bool* aResult) MOZ_OVERRIDE;
+  NS_IMETHOD GetNext(nsISupports** aResult) MOZ_OVERRIDE;
 
   nsUnionEnumerator(nsISimpleEnumerator* aFirstEnumerator,
                     nsISimpleEnumerator* aSecondEnumerator);
 
 private:
   ~nsUnionEnumerator();
 
 protected:
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -503,28 +503,29 @@ public:
  */
 #define NS_INIT_ISUPPORTS() ((void)0)
 
 /**
  * Use this macro to declare and implement the AddRef & Release methods for a
  * given non-XPCOM <i>_class</i>.
  *
  * @param _class The name of the class implementing the method
+ * @param optional MOZ_OVERRIDE Mark the AddRef & Release methods as overrides.
  */
-#define NS_INLINE_DECL_REFCOUNTING(_class)                                    \
+#define NS_INLINE_DECL_REFCOUNTING(_class, ...)                               \
 public:                                                                       \
-  NS_METHOD_(MozExternalRefCountType) AddRef(void) {                          \
+  NS_METHOD_(MozExternalRefCountType) AddRef(void) __VA_ARGS__ {              \
     MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class)                                \
     MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");                      \
     NS_ASSERT_OWNINGTHREAD(_class);                                           \
     ++mRefCnt;                                                                \
     NS_LOG_ADDREF(this, mRefCnt, #_class, sizeof(*this));                     \
     return mRefCnt;                                                           \
   }                                                                           \
-  NS_METHOD_(MozExternalRefCountType) Release(void) {                         \
+  NS_METHOD_(MozExternalRefCountType) Release(void) __VA_ARGS__ {             \
     MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release");                          \
     NS_ASSERT_OWNINGTHREAD(_class);                                           \
     --mRefCnt;                                                                \
     NS_LOG_RELEASE(this, mRefCnt, #_class);                                   \
     if (mRefCnt == 0) {                                                       \
       NS_ASSERT_OWNINGTHREAD(_class);                                         \
       mRefCnt = 1; /* stabilize */                                            \
       delete this;                                                            \
@@ -540,26 +541,26 @@ public:
 /**
  * Use this macro to declare and implement the AddRef & Release methods for a
  * given non-XPCOM <i>_class</i> in a threadsafe manner.
  *
  * DOES NOT DO REFCOUNT STABILIZATION!
  *
  * @param _class The name of the class implementing the method
  */
-#define NS_INLINE_DECL_THREADSAFE_REFCOUNTING(_class)                         \
+#define NS_INLINE_DECL_THREADSAFE_REFCOUNTING(_class, ...)                    \
 public:                                                                       \
-  NS_METHOD_(MozExternalRefCountType) AddRef(void) {                          \
+  NS_METHOD_(MozExternalRefCountType) AddRef(void) __VA_ARGS__ {              \
     MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class)                                \
     MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");                      \
     nsrefcnt count = ++mRefCnt;                                               \
     NS_LOG_ADDREF(this, count, #_class, sizeof(*this));                       \
     return (nsrefcnt) count;                                                  \
   }                                                                           \
-  NS_METHOD_(MozExternalRefCountType) Release(void) {                         \
+  NS_METHOD_(MozExternalRefCountType) Release(void) __VA_ARGS__ {             \
     MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release");                          \
     nsrefcnt count = --mRefCnt;                                               \
     NS_LOG_RELEASE(this, count, #_class);                                     \
     if (count == 0) {                                                         \
       delete (this);                                                          \
       return 0;                                                               \
     }                                                                         \
     return count;                                                             \
--- a/xpcom/glue/nsWeakReference.cpp
+++ b/xpcom/glue/nsWeakReference.cpp
@@ -14,17 +14,17 @@
 class nsWeakReference MOZ_FINAL : public nsIWeakReference
 {
 public:
   // nsISupports...
   NS_DECL_ISUPPORTS
 
   // nsIWeakReference...
   NS_DECL_NSIWEAKREFERENCE
-  virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+  virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
 
 private:
   friend class nsSupportsWeakReference;
 
   explicit nsWeakReference(nsSupportsWeakReference* aReferent)
     : mReferent(aReferent)
     // ...I can only be constructed by an |nsSupportsWeakReference|
   {
--- a/xpcom/glue/tests/gtest/TestArray.cpp
+++ b/xpcom/glue/tests/gtest/TestArray.cpp
@@ -30,18 +30,18 @@ class Foo MOZ_FINAL : public IFoo {
 public:
 
   explicit Foo(int32_t aID);
 
   // nsISupports implementation
   NS_DECL_ISUPPORTS
 
   // IFoo implementation
-  NS_IMETHOD_(nsrefcnt) RefCnt() { return mRefCnt; }
-  NS_IMETHOD_(int32_t) ID() { return mID; }
+  NS_IMETHOD_(nsrefcnt) RefCnt() MOZ_OVERRIDE { return mRefCnt; }
+  NS_IMETHOD_(int32_t) ID() MOZ_OVERRIDE { return mID; }
 
   static int32_t gCount;
 
   int32_t mID;
 
 private:
   ~Foo();
 };
deleted file mode 100644
--- a/xpcom/glue/tests/gtest/TestCRT.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- 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 "nsCRT.h"
-#include "nsString.h"
-#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) {
-    if (val == 0)
-	return 0;
-    else {
-	if (val > 0)
-	    return 1;
-	else
-	    return -1;
-    }
-}
-
-
-// Verify that nsCRT versions of string comparison routines get the
-// same answers as the native non-unicode versions. We only pass in
-// iso-latin-1 strings, so the comparison must be valid.
-static void Check(const char* s1, const char* s2, int n)
-{
-  int clib = PL_strcmp(s1, s2);
-
-  int clib_n = PL_strncmp(s1, s2, n);
-
-  nsAutoString t1,t2; 
-  t1.AssignWithConversion(s1);
-  t2.AssignWithConversion(s2);
-  const char16_t* us1 = t1.get();
-  const char16_t* us2 = t2.get();
-
-  int u2 = nsCRT::strcmp(us1, us2);
-
-  int u2_n = nsCRT::strncmp(us1, us2, n);
-
-  EXPECT_EQ(sign(clib), sign(u2));
-  EXPECT_EQ(sign(clib), sign(u2_n));
-  EXPECT_EQ(sign(clib), sign(clib_n));
-}
-
-struct Test {
-  const char* s1;
-  const char* s2;
-  int n;
-};
-
-static Test tests[] = {
-  { "foo", "foo", 3 },
-  { "foo", "fo", 3 },
-
-  { "foo", "bar", 3 },
-  { "foo", "ba", 3 },
-
-  { "foo", "zap", 3 },
-  { "foo", "za", 3 },
-
-  { "bar", "foo", 3 },
-  { "bar", "fo", 3 },
-
-  { "bar", "foo", 3 },
-  { "bar", "fo", 3 },
-};
-#define NUM_TESTS int((sizeof(tests) / sizeof(tests[0])))
-
-TEST(CRT, main)
-{
-  TestCRT::Test* tp = tests;
-  for (int i = 0; i < NUM_TESTS; i++, tp++) {
-    Check(tp->s1, tp->s2, tp->n);
-  }
-}
-
-}
deleted file mode 100644
--- a/xpcom/glue/tests/gtest/TestEncoding.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- 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 <stdlib.h>
-#include "nsString.h"
-#include "gtest/gtest.h"
-
-TEST(Encoding, GoodSurrogatePair)
-{
-  // When this string is decoded, the surrogate pair is U+10302 and the rest of
-  // the string is specified by indexes 2 onward.
-  const char16_t goodPairData[] = {  0xD800, 0xDF02, 0x65, 0x78, 0x0 };
-  nsDependentString goodPair16(goodPairData);
-
-  uint32_t byteCount = 0;
-  char* goodPair8 = ToNewUTF8String(goodPair16, &byteCount);
-  EXPECT_TRUE(!!goodPair8);
-
-  EXPECT_EQ(byteCount, 6u);
-
-  const unsigned char expected8[] =
-    { 0xF0, 0x90, 0x8C, 0x82, 0x65, 0x78, 0x0 };
-  EXPECT_EQ(0, memcmp(expected8, goodPair8, sizeof(expected8)));
-
-  // This takes a different code path from the above, so test it to make sure
-  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
-  nsDependentCString expected((const char*)expected8);
-  EXPECT_EQ(0, CompareUTF8toUTF16(expected, goodPair16));
-
-  NS_Free(goodPair8);
-}
-
-TEST(Encoding, BackwardsSurrogatePair)
-{
-  // When this string is decoded, the two surrogates are wrongly ordered and
-  // must each be interpreted as U+FFFD.
-  const char16_t backwardsPairData[] = { 0xDDDD, 0xD863, 0x65, 0x78, 0x0 };
-  nsDependentString backwardsPair16(backwardsPairData);
-
-  uint32_t byteCount = 0;
-  char* backwardsPair8 = ToNewUTF8String(backwardsPair16, &byteCount);
-  EXPECT_TRUE(!!backwardsPair8);
-
-  EXPECT_EQ(byteCount, 8u);
-
-  const unsigned char expected8[] =
-    { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0x65, 0x78, 0x0 };
-  EXPECT_EQ(0, memcmp(expected8, backwardsPair8, sizeof(expected8)));
-
-  // This takes a different code path from the above, so test it to make sure
-  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
-  nsDependentCString expected((const char*)expected8);
-  EXPECT_EQ(0, CompareUTF8toUTF16(expected, backwardsPair16));
-
-  NS_Free(backwardsPair8);
-}
-
-TEST(Encoding, MalformedUTF16OrphanHighSurrogate)
-{
-  // When this string is decoded, the high surrogate should be replaced and the
-  // rest of the string is specified by indexes 1 onward.
-  const char16_t highSurrogateData[] = { 0xD863, 0x74, 0x65, 0x78, 0x74, 0x0 };
-  nsDependentString highSurrogate16(highSurrogateData);
-
-  uint32_t byteCount = 0;
-  char* highSurrogate8 = ToNewUTF8String(highSurrogate16, &byteCount);
-  EXPECT_TRUE(!!highSurrogate8);
-
-  EXPECT_EQ(byteCount, 7u);
-
-  const unsigned char expected8[] =
-    { 0xEF, 0xBF, 0xBD, 0x74, 0x65, 0x78, 0x74, 0x0 };
-  EXPECT_EQ(0, memcmp(expected8, highSurrogate8, sizeof(expected8)));
-
-  // This takes a different code path from the above, so test it to make sure
-  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
-  nsDependentCString expected((const char*)expected8);
-  EXPECT_EQ(0, CompareUTF8toUTF16(expected, highSurrogate16));
-
-  NS_Free(highSurrogate8);
-}
-
-TEST(Encoding, MalformedUTF16OrphanLowSurrogate)
-{
-  // When this string is decoded, the low surrogate should be replaced and the
-  // rest of the string is specified by indexes 1 onward.
-  const char16_t lowSurrogateData[] = { 0xDDDD, 0x74, 0x65, 0x78, 0x74, 0x0 };
-  nsDependentString lowSurrogate16(lowSurrogateData);
-
-  uint32_t byteCount = 0;
-  char* lowSurrogate8 = ToNewUTF8String(lowSurrogate16, &byteCount);
-  EXPECT_TRUE(!!lowSurrogate8);
-
-  EXPECT_EQ(byteCount, 7u);
-
-  const unsigned char expected8[] =
-    { 0xEF, 0xBF, 0xBD, 0x74, 0x65, 0x78, 0x74, 0x0 };
-  EXPECT_EQ(0, memcmp(expected8, lowSurrogate8, sizeof(expected8)));
-
-  // This takes a different code path from the above, so test it to make sure
-  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
-  nsDependentCString expected((const char*)expected8);
-  EXPECT_EQ(0, CompareUTF8toUTF16(expected, lowSurrogate16));
-
-  NS_Free(lowSurrogate8);
-}
deleted file mode 100644
--- a/xpcom/glue/tests/gtest/TestExpirationTracker.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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 <stdlib.h>
-#include <stdio.h>
-#include <prthread.h>
-#include "nsExpirationTracker.h"
-#include "nsMemory.h"
-#include "nsAutoPtr.h"
-#include "nsString.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsDirectoryServiceUtils.h"
-#include "nsComponentManagerUtils.h"
-#include "nsXPCOM.h"
-#include "nsIFile.h"
-#include "prinrval.h"
-#include "nsThreadUtils.h"
-#include "gtest/gtest.h"
-
-namespace TestExpirationTracker {
-
-struct Object {
-  Object() : mExpired(false) { Touch(); }
-  void Touch() { mLastUsed = PR_IntervalNow(); mExpired = false; }
-
-  nsExpirationState mExpiration;
-  nsExpirationState* GetExpirationState() { return &mExpiration; }
-
-  PRIntervalTime mLastUsed;
-  bool           mExpired;
-};
-
-static bool error;
-static uint32_t periodMS = 100;
-static uint32_t ops = 1000;
-static uint32_t iterations = 2;
-static bool logging = 0;
-static uint32_t sleepPeriodMS = 50;
-static uint32_t slackMS = 20; // allow this much error
-
-template <uint32_t K> class Tracker : public nsExpirationTracker<Object,K> {
-public:
-  Tracker() : nsExpirationTracker<Object,K>(periodMS) {
-    Object* obj = new Object();
-    mUniverse.AppendElement(obj);
-    LogAction(obj, "Created");
-  }
-
-  nsTArray<nsAutoArrayPtr<Object> > mUniverse;
-
-  void LogAction(Object* aObj, const char* aAction) {
-    if (logging) {
-      printf("%d %p(%d): %s\n", PR_IntervalNow(),
-             static_cast<void*>(aObj), aObj->mLastUsed, aAction);
-    }
-  }
-
-  void DoRandomOperation() {
-    Object* obj;
-    switch (rand() & 0x7) {
-    case 0: {
-      if (mUniverse.Length() < 50) {
-        obj = new Object();
-        mUniverse.AppendElement(obj);
-        nsExpirationTracker<Object,K>::AddObject(obj);
-        LogAction(obj, "Created and added");
-      }
-      break;
-    }
-    case 4: {
-      if (mUniverse.Length() < 50) {
-        obj = new Object();
-        mUniverse.AppendElement(obj);
-        LogAction(obj, "Created");
-      }
-      break;
-    }
-    case 1: {
-      obj = mUniverse[uint32_t(rand())%mUniverse.Length()];
-      if (obj->mExpiration.IsTracked()) {
-        nsExpirationTracker<Object,K>::RemoveObject(obj);
-        LogAction(obj, "Removed");
-      }
-      break;
-    }
-    case 2: {
-      obj = mUniverse[uint32_t(rand())%mUniverse.Length()];
-      if (!obj->mExpiration.IsTracked()) {
-        obj->Touch();
-        nsExpirationTracker<Object,K>::AddObject(obj);
-        LogAction(obj, "Added");
-      }
-      break;
-    }
-    case 3: {
-      obj = mUniverse[uint32_t(rand())%mUniverse.Length()];
-      if (obj->mExpiration.IsTracked()) {
-        obj->Touch();
-        nsExpirationTracker<Object,K>::MarkUsed(obj);
-        LogAction(obj, "Marked used");
-      }
-      break;
-    }
-    }
-  }
-  
-protected:
-  void NotifyExpired(Object* aObj) {
-    LogAction(aObj, "Expired");
-    PRIntervalTime now = PR_IntervalNow();
-    uint32_t timeDiffMS = (now - aObj->mLastUsed)*1000/PR_TicksPerSecond();
-    // See the comment for NotifyExpired in nsExpirationTracker.h for these
-    // bounds
-    uint32_t lowerBoundMS = (K-1)*periodMS - slackMS;
-    uint32_t upperBoundMS = K*(periodMS + sleepPeriodMS) + slackMS;
-    if (logging) {
-      printf("Checking: %d-%d = %d [%d,%d]\n",
-             now, aObj->mLastUsed, timeDiffMS, lowerBoundMS, upperBoundMS);
-    }
-    if (timeDiffMS < lowerBoundMS || timeDiffMS > upperBoundMS) {
-      EXPECT_TRUE(timeDiffMS < periodMS && aObj->mExpired);
-    }
-    aObj->Touch();
-    aObj->mExpired = true;
-    DoRandomOperation();
-    DoRandomOperation();
-    DoRandomOperation();
-  }
-};
-
-template <uint32_t K> static bool test_random() {
-  srand(K);
-  error = false;
- 
-  for (uint32_t j = 0; j < iterations; ++j) {
-    Tracker<K> tracker;
-
-    uint32_t i = 0;
-    for (i = 0; i < ops; ++i) {
-      if ((rand() & 0xF) == 0) {
-        // Simulate work that takes time
-        if (logging) {
-          printf("SLEEPING for %dms (%d)\n", sleepPeriodMS, PR_IntervalNow());
-        }
-        PR_Sleep(PR_MillisecondsToInterval(sleepPeriodMS));
-        // Process pending timer events
-        NS_ProcessPendingEvents(nullptr);
-      }
-      tracker.DoRandomOperation();
-    }
-  }
-  
-  return !error;
-}
-
-static bool test_random3() { return test_random<3>(); }
-static bool test_random4() { return test_random<4>(); }
-static bool test_random8() { return test_random<8>(); }
-
-typedef bool (*TestFunc)();
-#define DECL_TEST(name) { #name, name }
-
-static const struct Test {
-  const char* name;
-  TestFunc    func;
-} tests[] = {
-  DECL_TEST(test_random3),
-  DECL_TEST(test_random4),
-  DECL_TEST(test_random8),
-  { nullptr, nullptr }
-};
-
-TEST(ExpirationTracker, main)
-{
-  for (const TestExpirationTracker::Test* t = tests;
-       t->name != nullptr; ++t) {
-    EXPECT_TRUE(t->func());
-  }
-}
-
-}
deleted file mode 100644
--- a/xpcom/glue/tests/gtest/TestStrings.cpp
+++ /dev/null
@@ -1,981 +0,0 @@
-/* vim:set ts=2 sw=2 et cindent: */
-/* 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 <stdio.h>
-#include <stdlib.h>
-#include "nsString.h"
-#include "nsStringBuffer.h"
-#include "nsReadableUtils.h"
-#include "nsCRTGlue.h"
-#include "nsRefPtr.h"
-#include "nsTArray.h"
-#include "mozilla/fallible.h"
-#include "gtest/gtest.h"
-
-namespace TestStrings {
-
-using mozilla::fallible_t;
-
-void test_assign_helper(const nsACString& in, nsACString &_retval)
-{
-  _retval = in;
-}
-
-TEST(Strings, assign)
-{
-  nsCString result;
-  test_assign_helper(NS_LITERAL_CSTRING("a") + NS_LITERAL_CSTRING("b"), result);
-  EXPECT_STREQ(result.get(), "ab");
-}
-
-TEST(Strings, assign_c)
-{
-  nsCString c; c.Assign('c');
-  EXPECT_STREQ(c.get(), "c");
-}
-
-TEST(Strings, test1)
-{
-  NS_NAMED_LITERAL_STRING(empty, "");
-  const nsAString& aStr = empty;
-
-  nsAutoString buf(aStr);
-
-  int32_t n = buf.FindChar(',');
-
-  n = buf.Length();
-
-  buf.Cut(0, n + 1);
-  n = buf.FindChar(',');
-
-  EXPECT_EQ(n, kNotFound);
-}
-
-TEST(Strings, test2)
-{
-  nsCString data("hello world");
-  const nsACString& aStr = data;
-
-  nsCString temp(aStr);
-  temp.Cut(0, 6);
-
-  EXPECT_STREQ(temp.get(), "world");
-}
-
-TEST(Strings, find)
-{
-  nsCString src("<!DOCTYPE blah blah blah>");
-
-  int32_t i = src.Find("DOCTYPE", true, 2, 1);
-  EXPECT_EQ(i, 2);
-}
-
-TEST(Strings, rfind)
-{
-  const char text[] = "<!DOCTYPE blah blah blah>";
-  const char term[] = "bLaH";
-  nsCString src(text);
-  int32_t i;
-
-  i = src.RFind(term, true, 3, -1); 
-  EXPECT_EQ(i, kNotFound);
-
-  i = src.RFind(term, true, -1, -1);
-  EXPECT_EQ(i, 20);
-
-  i = src.RFind(term, true, 13, -1);
-  EXPECT_EQ(i, 10);
-
-  i = src.RFind(term, true, 22, 3);
-  EXPECT_EQ(i, 20);
-}
-
-TEST(Strings, rfind_2)
-{
-  const char text[] = "<!DOCTYPE blah blah blah>";
-  nsCString src(text);
-  int32_t i = src.RFind("TYPE", false, 5, -1); 
-  EXPECT_EQ(i, 5);
-}
-
-TEST(Strings, rfind_3)
-{
-  const char text[] = "urn:mozilla:locale:en-US:necko";
-  nsAutoCString value(text);
-  int32_t i = value.RFind(":");
-  EXPECT_EQ(i, 24);
-}
-
-TEST(Strings, rfind_4)
-{
-  nsCString value("a.msf");
-  int32_t i = value.RFind(".msf");
-  EXPECT_EQ(i, 1);
-}
-
-TEST(Strings, findinreadable)
-{
-  const char text[] = "jar:jar:file:///c:/software/mozilla/mozilla_2006_02_21.jar!/browser/chrome/classic.jar!/";
-  nsAutoCString value(text);
-
-  nsACString::const_iterator begin, end;
-  value.BeginReading(begin);
-  value.EndReading(end);
-  nsACString::const_iterator delim_begin (begin),
-                             delim_end   (end);
-
-  // Search for last !/ at the end of the string
-  EXPECT_TRUE(FindInReadable(NS_LITERAL_CSTRING("!/"), delim_begin, delim_end));
-  char *r = ToNewCString(Substring(delim_begin, delim_end));
-  // Should match the first "!/" but not the last
-  EXPECT_NE(delim_end, end);
-  EXPECT_STREQ(r, "!/");
-  nsMemory::Free(r);
-
-  delim_begin = begin;
-  delim_end = end;
-
-  // Search for first jar:
-  EXPECT_TRUE(FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
-
-  r = ToNewCString(Substring(delim_begin, delim_end));
-  // Should not match the first jar:, but the second one
-  EXPECT_EQ(delim_begin, begin);
-  EXPECT_STREQ(r, "jar:");
-  nsMemory::Free(r);
-
-  // Search for jar: in a Substring
-  delim_begin = begin; delim_begin++;
-  delim_end = end;
-  EXPECT_TRUE(FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
-
-  r = ToNewCString(Substring(delim_begin, delim_end));
-  // Should not match the first jar:, but the second one
-  EXPECT_NE(delim_begin, begin);
-  EXPECT_STREQ(r, "jar:");
-  nsMemory::Free(r);
-
-  // Should not find a match
-  EXPECT_FALSE(FindInReadable(NS_LITERAL_CSTRING("gecko"), delim_begin, delim_end));
-
-  // When no match is found, range should be empty
-  EXPECT_EQ(delim_begin, delim_end);
-
-  // Should not find a match (search not beyond Substring)
-  delim_begin = begin; for (int i=0;i<6;i++) delim_begin++;
-  delim_end = end;
-  EXPECT_FALSE(FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
-
-  // When no match is found, range should be empty
-  EXPECT_EQ(delim_begin, delim_end);
-
-  // Should not find a match (search not beyond Substring)
-  delim_begin = begin;
-  delim_end = end; for (int i=0;i<7;i++) delim_end--;
-  EXPECT_FALSE(FindInReadable(NS_LITERAL_CSTRING("classic"), delim_begin, delim_end));
-
-  // When no match is found, range should be empty
-  EXPECT_EQ(delim_begin, delim_end);
-}
-
-TEST(Strings, rfindinreadable)
-{
-  const char text[] = "jar:jar:file:///c:/software/mozilla/mozilla_2006_02_21.jar!/browser/chrome/classic.jar!/";
-  nsAutoCString value(text);
-
-  nsACString::const_iterator begin, end;
-  value.BeginReading(begin);
-  value.EndReading(end);
-  nsACString::const_iterator delim_begin (begin),
-                             delim_end   (end);
-
-  // Search for last !/ at the end of the string
-  EXPECT_TRUE(RFindInReadable(NS_LITERAL_CSTRING("!/"), delim_begin, delim_end));
-  char *r = ToNewCString(Substring(delim_begin, delim_end));
-  // Should match the last "!/"
-  EXPECT_EQ(delim_end, end);
-  EXPECT_STREQ(r, "!/");
-  nsMemory::Free(r);
-
-  delim_begin = begin;
-  delim_end = end;
-
-  // Search for last jar: but not the first one...
-  EXPECT_TRUE(RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
-
-  r = ToNewCString(Substring(delim_begin, delim_end));
-  // Should not match the first jar:, but the second one
-  EXPECT_NE(delim_begin, begin);
-  EXPECT_STREQ(r, "jar:");
-  nsMemory::Free(r);
-
-  // Search for jar: in a Substring
-  delim_begin = begin;
-  delim_end = begin; for (int i=0;i<6;i++) delim_end++;
-  EXPECT_TRUE(RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
-
-  r = ToNewCString(Substring(delim_begin, delim_end));
-  // Should not match the first jar:, but the second one
-  EXPECT_EQ(delim_begin, begin);
-  EXPECT_STREQ(r, "jar:");
-  nsMemory::Free(r);
-
-  // Should not find a match
-  delim_begin = begin;
-  delim_end = end;
-  EXPECT_FALSE(RFindInReadable(NS_LITERAL_CSTRING("gecko"), delim_begin, delim_end));
-
-  // When no match is found, range should be empty
-  EXPECT_EQ(delim_begin, delim_end);
-
-  // Should not find a match (search not before Substring)
-  delim_begin = begin; for (int i=0;i<6;i++) delim_begin++;
-  delim_end = end;
-  EXPECT_FALSE(RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
-
-  // When no match is found, range should be empty
-  EXPECT_EQ(delim_begin, delim_end);
-
-  // Should not find a match (search not beyond Substring)
-  delim_begin = begin;
-  delim_end = end; for (int i=0;i<7;i++) delim_end--;
-  EXPECT_FALSE(RFindInReadable(NS_LITERAL_CSTRING("classic"), delim_begin, delim_end));
-
-  // When no match is found, range should be empty
-  EXPECT_EQ(delim_begin, delim_end);
-}
-
-TEST(Strings, distance)
-{
-  const char text[] = "abc-xyz";
-  nsCString s(text);
-  nsCString::const_iterator begin, end;
-  s.BeginReading(begin);
-  s.EndReading(end);
-  size_t d = Distance(begin, end);
-  EXPECT_EQ(d, sizeof(text) - 1);
-}
-
-TEST(Strings, length)
-{
-  const char text[] = "abc-xyz";
-  nsCString s(text);
-  size_t d = s.Length();
-  EXPECT_EQ(d, sizeof(text) - 1);
-}
-
-TEST(Strings, trim)
-{
-  const char text[] = " a\t    $   ";
-  const char set[] = " \t$";
-
-  nsCString s(text);
-  s.Trim(set);
-  EXPECT_STREQ(s.get(), "a");
-}
-
-TEST(Strings, replace_substr)
-{
-  const char text[] = "abc-ppp-qqq-ppp-xyz";
-  nsCString s(text);
-  s.ReplaceSubstring("ppp", "www");
-  EXPECT_STREQ(s.get(), "abc-www-qqq-www-xyz");
-
-  s.Assign("foobar");
-  s.ReplaceSubstring("foo", "bar");
-  s.ReplaceSubstring("bar", "");
-  EXPECT_STREQ(s.get(), "");
-
-  s.Assign("foofoofoo");
-  s.ReplaceSubstring("foo", "foo");
-  EXPECT_STREQ(s.get(), "foofoofoo");
-
-  s.Assign("foofoofoo");
-  s.ReplaceSubstring("of", "fo");
-  EXPECT_STREQ(s.get(), "fofoofooo");
-}
-
-TEST(Strings, replace_substr_2)
-{
-  const char *oldName = nullptr;
-  const char *newName = "user";
-  nsString acctName; acctName.AssignLiteral("forums.foo.com");
-  nsAutoString newAcctName, oldVal, newVal;
-  oldVal.AssignWithConversion(oldName);
-  newVal.AssignWithConversion(newName);
-  newAcctName.Assign(acctName);
-
-  // here, oldVal is empty.  we are testing that this function
-  // does not hang.  see bug 235355.
-  newAcctName.ReplaceSubstring(oldVal, newVal);
-
-  // we expect that newAcctName will be unchanged.
-  EXPECT_TRUE(newAcctName.Equals(acctName));
-}
-
-TEST(Strings, replace_substr_3)
-{
-  nsCString s;
-  s.Assign("abcabcabc");
-  s.ReplaceSubstring("ca", "X");
-  EXPECT_STREQ(s.get(), "abXbXbc");
-
-  s.Assign("abcabcabc");
-  s.ReplaceSubstring("ca", "XYZ");
-  EXPECT_STREQ(s.get(), "abXYZbXYZbc");
-
-  s.Assign("abcabcabc");
-  s.ReplaceSubstring("ca", "XY");
-  EXPECT_STREQ(s.get(), "abXYbXYbc");
-
-  s.Assign("abcabcabc");
-  s.ReplaceSubstring("ca", "XYZ!");
-  EXPECT_STREQ(s.get(), "abXYZ!bXYZ!bc");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("bcd", "X");
-  EXPECT_STREQ(s.get(), "aXaXaX");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("bcd", "XYZ!");
-  EXPECT_STREQ(s.get(), "aXYZ!aXYZ!aXYZ!");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("bcd", "XY");
-  EXPECT_STREQ(s.get(), "aXYaXYaXY");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("bcd", "XYZABC");
-  EXPECT_STREQ(s.get(), "aXYZABCaXYZABCaXYZABC");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("bcd", "XYZ");
-  EXPECT_STREQ(s.get(), "aXYZaXYZaXYZ");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("bcd", "XYZ!");
-  EXPECT_STREQ(s.get(), "aXYZ!aXYZ!aXYZ!");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("ab", "X");
-  EXPECT_STREQ(s.get(), "XcdXcdXcd");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("ab", "XYZABC");
-  EXPECT_STREQ(s.get(), "XYZABCcdXYZABCcdXYZABCcd");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("ab", "XY");
-  EXPECT_STREQ(s.get(), "XYcdXYcdXYcd");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("ab", "XYZ!");
-  EXPECT_STREQ(s.get(), "XYZ!cdXYZ!cdXYZ!cd");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("notfound", "X");
-  EXPECT_STREQ(s.get(), "abcdabcdabcd");
-
-  s.Assign("abcdabcdabcd");
-  s.ReplaceSubstring("notfound", "longlongstring");
-  EXPECT_STREQ(s.get(), "abcdabcdabcd");
-}
-
-TEST(Strings, strip_ws)
-{
-  const char text[] = " a    $   ";
-  nsCString s(text);
-  s.StripWhitespace();
-  EXPECT_STREQ(s.get(), "a$");
-}
-
-TEST(Strings, equals_ic)
-{
-  nsCString s;
-  EXPECT_FALSE(s.LowerCaseEqualsLiteral("view-source"));
-}
-
-TEST(Strings, fixed_string)
-{
-  char buf[256] = "hello world";
-
-  nsFixedCString s(buf, sizeof(buf));
-
-  EXPECT_EQ(s.Length(), strlen(buf));
-
-  EXPECT_STREQ(s.get(), buf);
-
-  s.Assign("foopy doopy doo");
-  EXPECT_EQ(s.get(), buf);
-}
-
-TEST(Strings, concat)
-{
-  nsCString bar("bar");
-  const nsACString& barRef = bar;
-
-  const nsPromiseFlatCString& result =
-      PromiseFlatCString(NS_LITERAL_CSTRING("foo") +
-                         NS_LITERAL_CSTRING(",") +
-                         barRef);
-  EXPECT_STREQ(result.get(), "foo,bar");
-}
-
-TEST(Strings, concat_2)
-{
-  nsCString fieldTextStr("xyz");
-  nsCString text("text");
-  const nsACString& aText = text;
-
-  nsAutoCString result( fieldTextStr + aText );
-
-  EXPECT_STREQ(result.get(), "xyztext");
-}
-
-TEST(Strings, concat_3)
-{
-  nsCString result;
-  nsCString ab("ab"), c("c");
-
-  result = ab + result + c;
-  EXPECT_STREQ(result.get(), "abc");
-}
-
-TEST(Strings, xpidl_string)
-{
-  nsXPIDLCString a, b;
-  a = b;
-  EXPECT_TRUE(a == b);
-
-  a.Adopt(0);
-  EXPECT_TRUE(a == b);
-
-  a.Append("foopy");
-  a.Assign(b);
-  EXPECT_TRUE(a == b);
-
-  a.Insert("", 0);
-  a.Assign(b);
-  EXPECT_TRUE(a == b);
-
-  const char text[] = "hello world";
-  *getter_Copies(a) = NS_strdup(text);
-  EXPECT_STREQ(a, text);
-
-  b = a;
-  EXPECT_STREQ(a, b);
-
-  a.Adopt(0);
-  nsACString::const_iterator begin, end;
-  a.BeginReading(begin);
-  a.EndReading(end);
-  char *r = ToNewCString(Substring(begin, end));
-  EXPECT_STREQ(r, "");
-  nsMemory::Free(r);
-
-  a.Adopt(0);
-  EXPECT_TRUE(a.IsVoid());
-
-  int32_t index = a.FindCharInSet("xyz");
-  EXPECT_EQ(index, kNotFound);
-}
-
-TEST(Strings, empty_assign)
-{
-  nsCString a;
-  a.AssignLiteral("");
-
-  a.AppendLiteral("");
-
-  nsCString b;
-  b.SetCapacity(0);
-}
-
-TEST(Strings, set_length)
-{
-  const char kText[] = "Default Plugin";
-  nsCString buf;
-  buf.SetCapacity(sizeof(kText)-1);
-  buf.Assign(kText);
-  buf.SetLength(sizeof(kText)-1);
-  EXPECT_STREQ(buf.get(), kText);
-}
-
-TEST(Strings, substring)
-{
-  nsCString super("hello world"), sub("hello");
-
-  // this tests that |super| starts with |sub|,
-  
-  EXPECT_TRUE(sub.Equals(StringHead(super, sub.Length())));
-
-  // and verifies that |sub| does not start with |super|.
-
-  EXPECT_FALSE(super.Equals(StringHead(sub, super.Length())));
-}
-
-#define test_append_expect(str, int, suffix, expect) \
-  str.Truncate(); \
-  str.AppendInt(suffix = int); \
-  EXPECT_TRUE(str.EqualsLiteral(expect));
-
-#define test_appends_expect(int, suffix, expect) \
-  test_append_expect(str, int, suffix, expect) \
-  test_append_expect(cstr, int, suffix, expect)
-
-#define test_appendbase(str, prefix, int, suffix, base) \
-  str.Truncate(); \
-  str.AppendInt(suffix = prefix ## int ## suffix, base); \
-  EXPECT_TRUE(str.EqualsLiteral(#int));
-
-#define test_appendbases(prefix, int, suffix, base) \
-  test_appendbase(str, prefix, int, suffix, base) \
-  test_appendbase(cstr, prefix, int, suffix, base)
-
-TEST(Strings, appendint)
-{
-  nsString str;
-  nsCString cstr;
-  int32_t L;
-  uint32_t UL;
-  int64_t LL;
-  uint64_t ULL;
-  test_appends_expect(INT32_MAX, L, "2147483647")
-  test_appends_expect(INT32_MIN, L, "-2147483648")
-  test_appends_expect(UINT32_MAX, UL, "4294967295")
-  test_appends_expect(INT64_MAX, LL, "9223372036854775807")
-  test_appends_expect(INT64_MIN, LL, "-9223372036854775808")
-  test_appends_expect(UINT64_MAX, ULL, "18446744073709551615")
-  test_appendbases(0, 17777777777, L, 8)
-  test_appendbases(0, 20000000000, L, 8)
-  test_appendbases(0, 37777777777, UL, 8)
-  test_appendbases(0, 777777777777777777777, LL, 8)
-  test_appendbases(0, 1000000000000000000000, LL, 8)
-  test_appendbases(0, 1777777777777777777777, ULL, 8)
-  test_appendbases(0x, 7fffffff, L, 16)
-  test_appendbases(0x, 80000000, L, 16)
-  test_appendbases(0x, ffffffff, UL, 16)
-  test_appendbases(0x, 7fffffffffffffff, LL, 16)
-  test_appendbases(0x, 8000000000000000, LL, 16)
-  test_appendbases(0x, ffffffffffffffff, ULL, 16)
-}
-
-TEST(Strings, appendint64)
-{
-  nsCString str;
-
-  int64_t max = INT64_MAX;
-  static const char max_expected[] = "9223372036854775807";
-  int64_t min = INT64_MIN;
-  static const char min_expected[] = "-9223372036854775808";
-  static const char min_expected_oct[] = "1000000000000000000000";
-  int64_t maxint_plus1 = 1LL << 32;
-  static const char maxint_plus1_expected[] = "4294967296";
-  static const char maxint_plus1_expected_x[] = "100000000";
-
-  str.AppendInt(max);
-
-  EXPECT_TRUE(str.Equals(max_expected));
-
-  str.Truncate();
-  str.AppendInt(min);
-  EXPECT_TRUE(str.Equals(min_expected));
-  str.Truncate();
-  str.AppendInt(min, 8);
-  EXPECT_TRUE(str.Equals(min_expected_oct));
-
-
-  str.Truncate();
-  str.AppendInt(maxint_plus1);
-  EXPECT_TRUE(str.Equals(maxint_plus1_expected));
-  str.Truncate();
-  str.AppendInt(maxint_plus1, 16);
-  EXPECT_TRUE(str.Equals(maxint_plus1_expected_x));
-}
-
-TEST(Strings, appendfloat)
-{
-  nsCString str;
-  double bigdouble = 11223344556.66;
-  static const char double_expected[] = "11223344556.66";
-  static const char float_expected[] = "0.01";
-
-  // AppendFloat is used to append doubles, therefore the precision must be
-  // large enough (see bug 327719)
-  str.AppendFloat( bigdouble );
-  EXPECT_TRUE(str.Equals(double_expected));
-
-  str.Truncate();
-  // AppendFloat is used to append floats (bug 327719 #27)
-  str.AppendFloat( 0.1f * 0.1f );
-  EXPECT_TRUE(str.Equals(float_expected));
-}
-
-TEST(Strings, findcharinset)
-{
-  nsCString buf("hello, how are you?");
-
-  int32_t index = buf.FindCharInSet(",?", 5);
-  EXPECT_EQ(index, 5);
-
-  index = buf.FindCharInSet("helo", 0);
-  EXPECT_EQ(index, 0);
-
-  index = buf.FindCharInSet("z?", 6);
-  EXPECT_EQ(index, (int32_t) buf.Length() - 1);
-}
-
-TEST(Strings, rfindcharinset)
-{
-  nsCString buf("hello, how are you?");
-
-  int32_t index = buf.RFindCharInSet(",?", 5);
-  EXPECT_EQ(index, 5);
-
-  index = buf.RFindCharInSet("helo", 0);
-  EXPECT_EQ(index, 0);
-
-  index = buf.RFindCharInSet("z?", 6);
-  EXPECT_EQ(index, kNotFound);
-
-  index = buf.RFindCharInSet("l", 5);
-  EXPECT_EQ(index, 3);
-
-  buf.Assign("abcdefghijkabc");
-
-  index = buf.RFindCharInSet("ab");
-  EXPECT_EQ(index, 12);
-
-  index = buf.RFindCharInSet("ab", 11);
-  EXPECT_EQ(index, 11);
-
-  index = buf.RFindCharInSet("ab", 10);
-  EXPECT_EQ(index, 1);
-
-  index = buf.RFindCharInSet("ab", 0);
-  EXPECT_EQ(index, 0);
-
-  index = buf.RFindCharInSet("cd", 1);
-  EXPECT_EQ(index, kNotFound);
-
-  index = buf.RFindCharInSet("h");
-  EXPECT_EQ(index, 7);
-}
-
-TEST(Strings, stringbuffer)
-{
-  const char kData[] = "hello world";
-
-  nsRefPtr<nsStringBuffer> buf;
-
-  buf = nsStringBuffer::Alloc(sizeof(kData));
-  EXPECT_TRUE(!!buf);
-
-  buf = nsStringBuffer::Alloc(sizeof(kData));
-  EXPECT_TRUE(!!buf);
-  char *data = (char *) buf->Data();
-  memcpy(data, kData, sizeof(kData));
-
-  nsCString str;
-  buf->ToString(sizeof(kData)-1, str);
-
-  nsStringBuffer *buf2;
-  buf2 = nsStringBuffer::FromString(str);
-
-  EXPECT_EQ(buf, buf2);
-}
-
-TEST(Strings, voided)
-{
-  const char kData[] = "hello world";
-
-  nsXPIDLCString str;
-  EXPECT_FALSE(str);
-  EXPECT_TRUE(str.IsVoid());
-  EXPECT_TRUE(str.IsEmpty());
-
-  str.Assign(kData);
-  EXPECT_STREQ(str, kData);
-
-  str.SetIsVoid(true);
-  EXPECT_FALSE(str);
-  EXPECT_TRUE(str.IsVoid());
-  EXPECT_TRUE(str.IsEmpty());
-
-  str.SetIsVoid(false);
-  EXPECT_STREQ(str, "");
-}
-
-TEST(Strings, voided_autostr)
-{
-  const char kData[] = "hello world";
-
-  nsAutoCString str;
-  EXPECT_FALSE(str.IsVoid());
-  EXPECT_TRUE(str.IsEmpty());
-
-  str.Assign(kData);
-  EXPECT_STREQ(str.get(), kData);
-
-  str.SetIsVoid(true);
-  EXPECT_TRUE(str.IsVoid());
-  EXPECT_TRUE(str.IsEmpty());
-
-  str.Assign(kData);
-  EXPECT_FALSE(str.IsVoid());
-  EXPECT_FALSE(str.IsEmpty());
-  EXPECT_STREQ(str.get(), kData);
-}
-
-TEST(Strings, voided_assignment)
-{
-  nsCString a, b;
-  b.SetIsVoid(true);
-  a = b;
-  EXPECT_TRUE(a.IsVoid());
-  EXPECT_EQ(a.get(), b.get());
-}
-
-TEST(Strings, empty_assignment)
-{
-  nsCString a, b;
-  a = b;
-  EXPECT_EQ(a.get(), b.get());
-}
-
-struct ToIntegerTest
-{
-  const char *str;
-  uint32_t radix;
-  int32_t result;
-  nsresult rv;
-};
-
-static const ToIntegerTest kToIntegerTests[] = {
-  { "123", 10, 123, NS_OK },
-  { "7b", 16, 123, NS_OK },
-  { "90194313659", 10, 0, NS_ERROR_ILLEGAL_VALUE },
-  { nullptr, 0, 0, NS_OK }
-};
-
-TEST(Strings, string_tointeger)
-{
-  nsresult rv;
-  for (const ToIntegerTest* t = kToIntegerTests; t->str; ++t) {
-    int32_t result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
-    EXPECT_EQ(rv, t->rv);
-    EXPECT_EQ(result, t->result);
-    result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
-    EXPECT_EQ(rv, t->rv);
-    EXPECT_EQ(result, t->result);
-  }
-}
-
-static void test_parse_string_helper(const char* str, char separator, int len,
-                                       const char* s1, const char* s2)
-{
-  nsCString data(str);
-  nsTArray<nsCString> results;
-  EXPECT_TRUE(ParseString(data, separator, results));
-  EXPECT_EQ(int(results.Length()), len);
-  const char* strings[] = { s1, s2 };
-  for (int i = 0; i < len; ++i) {
-    EXPECT_TRUE(results[i].Equals(strings[i]));
-  }
-}
-
-static void test_parse_string_helper0(const char* str, char separator)
-{
-  test_parse_string_helper(str, separator, 0, nullptr, nullptr);
-}
-
-static void test_parse_string_helper1(const char* str, char separator, const char* s1)
-{
-  test_parse_string_helper(str, separator, 1, s1, nullptr);
-}
-
-static void test_parse_string_helper2(const char* str, char separator, const char* s1, const char* s2)
-{
-  test_parse_string_helper(str, separator, 2, s1, s2);
-}
-
-TEST(String, parse_string)
-{
-  test_parse_string_helper1("foo, bar", '_', "foo, bar");
-  test_parse_string_helper2("foo, bar", ',', "foo", " bar");
-  test_parse_string_helper2("foo, bar ", ' ', "foo,", "bar");
-  test_parse_string_helper2("foo,bar", 'o', "f", ",bar");
-  test_parse_string_helper0("", '_');
-  test_parse_string_helper0("  ", ' ');
-  test_parse_string_helper1(" foo", ' ', "foo");
-  test_parse_string_helper1("  foo", ' ', "foo");
-}
-
-static void test_strip_chars_helper(const char16_t* str, const char16_t* strip, const nsAString& result, uint32_t offset=0)
-{
-  nsAutoString tmp(str);
-  nsAString& data = tmp;
-  data.StripChars(strip, offset);
-  EXPECT_TRUE(data.Equals(result));
-}
-
-TEST(String, strip_chars)
-{
-  test_strip_chars_helper(MOZ_UTF16("foo \r \nbar"),
-                          MOZ_UTF16(" \n\r"),
-                          NS_LITERAL_STRING("foobar"));
-  test_strip_chars_helper(MOZ_UTF16("\r\nfoo\r\n"),
-                          MOZ_UTF16(" \n\r"),
-                          NS_LITERAL_STRING("foo"));
-  test_strip_chars_helper(MOZ_UTF16("foo"),
-                          MOZ_UTF16(" \n\r"),
-                          NS_LITERAL_STRING("foo"));
-  test_strip_chars_helper(MOZ_UTF16("foo"),
-                          MOZ_UTF16("fo"),
-                          NS_LITERAL_STRING(""));
-  test_strip_chars_helper(MOZ_UTF16("foo"),
-                          MOZ_UTF16("foo"),
-                          NS_LITERAL_STRING(""));
-  test_strip_chars_helper(MOZ_UTF16(" foo"),
-                          MOZ_UTF16(" "),
-                          NS_LITERAL_STRING(" foo"), 1);
-}
-
-TEST(Strings, huge_capacity)
-{
-  nsString a, b, c, d, e, f, g, h, i, j, k, l, m, n;
-  nsCString n1;
-
-  // Ignore the result if the address space is less than 64-bit because
-  // some of the allocations above will exhaust the address space.
-  if (sizeof(void*) >= 8) {
-    EXPECT_TRUE(a.SetCapacity(1, fallible_t()));
-    EXPECT_FALSE(a.SetCapacity(nsString::size_type(-1)/2, fallible_t()));
-    EXPECT_TRUE(a.SetCapacity(0, fallible_t()));  // free the allocated memory
-
-    EXPECT_TRUE(b.SetCapacity(1, fallible_t()));
-    EXPECT_FALSE(b.SetCapacity(nsString::size_type(-1)/2 - 1, fallible_t()));
-    EXPECT_TRUE(b.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(c.SetCapacity(1, fallible_t()));
-    EXPECT_FALSE(c.SetCapacity(nsString::size_type(-1)/2, fallible_t()));
-    EXPECT_TRUE(c.SetCapacity(0, fallible_t()));
-
-    EXPECT_FALSE(d.SetCapacity(nsString::size_type(-1)/2 - 1, fallible_t()));
-    EXPECT_FALSE(d.SetCapacity(nsString::size_type(-1)/2, fallible_t()));
-    EXPECT_TRUE(d.SetCapacity(0, fallible_t()));
-
-    EXPECT_FALSE(e.SetCapacity(nsString::size_type(-1)/4, fallible_t()));
-    EXPECT_FALSE(e.SetCapacity(nsString::size_type(-1)/4 + 1, fallible_t()));
-    EXPECT_TRUE(e.SetCapacity(0, fallible_t()));
-
-    EXPECT_FALSE(f.SetCapacity(nsString::size_type(-1)/2, fallible_t()));
-    EXPECT_TRUE(f.SetCapacity(0, fallible_t()));
-
-    EXPECT_FALSE(g.SetCapacity(nsString::size_type(-1)/4 + 1000, fallible_t()));
-    EXPECT_FALSE(g.SetCapacity(nsString::size_type(-1)/4 + 1001, fallible_t()));
-    EXPECT_TRUE(g.SetCapacity(0, fallible_t()));
-
-    EXPECT_FALSE(h.SetCapacity(nsString::size_type(-1)/4+1, fallible_t()));
-    EXPECT_FALSE(h.SetCapacity(nsString::size_type(-1)/2, fallible_t()));
-    EXPECT_TRUE(h.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(i.SetCapacity(1, fallible_t()));
-    EXPECT_TRUE(i.SetCapacity(nsString::size_type(-1)/4 - 1000, fallible_t()));
-    EXPECT_FALSE(i.SetCapacity(nsString::size_type(-1)/4 + 1, fallible_t()));
-    EXPECT_TRUE(i.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(j.SetCapacity(nsString::size_type(-1)/4 - 1000, fallible_t()));
-    EXPECT_FALSE(j.SetCapacity(nsString::size_type(-1)/4 + 1, fallible_t()));
-    EXPECT_TRUE(j.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(k.SetCapacity(nsString::size_type(-1)/8 - 1000, fallible_t()));
-    EXPECT_TRUE(k.SetCapacity(nsString::size_type(-1)/4 - 1001, fallible_t()));
-    EXPECT_TRUE(k.SetCapacity(nsString::size_type(-1)/4 - 998, fallible_t()));
-    EXPECT_FALSE(k.SetCapacity(nsString::size_type(-1)/4 + 1, fallible_t()));
-    EXPECT_TRUE(k.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(l.SetCapacity(nsString::size_type(-1)/8, fallible_t()));
-    EXPECT_TRUE(l.SetCapacity(nsString::size_type(-1)/8 + 1, fallible_t()));
-    EXPECT_TRUE(l.SetCapacity(nsString::size_type(-1)/8 + 2, fallible_t()));
-    EXPECT_TRUE(l.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(m.SetCapacity(nsString::size_type(-1)/8 + 1000, fallible_t()));
-    EXPECT_TRUE(m.SetCapacity(nsString::size_type(-1)/8 + 1001, fallible_t()));
-    EXPECT_TRUE(m.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(n.SetCapacity(nsString::size_type(-1)/8+1, fallible_t()));
-    EXPECT_FALSE(n.SetCapacity(nsString::size_type(-1)/4, fallible_t()));
-    EXPECT_TRUE(n.SetCapacity(0, fallible_t()));
-
-    EXPECT_TRUE(n.SetCapacity(0, fallible_t()));
-    EXPECT_TRUE(n.SetCapacity((nsString::size_type(-1)/2 - sizeof(nsStringBuffer)) / 2 - 2, fallible_t()));
-    EXPECT_TRUE(n.SetCapacity(0, fallible_t()));
-    EXPECT_FALSE(n.SetCapacity((nsString::size_type(-1)/2 - sizeof(nsStringBuffer)) / 2 - 1, fallible_t()));
-    EXPECT_TRUE(n.SetCapacity(0, fallible_t()));
-    EXPECT_TRUE(n1.SetCapacity(0, fallible_t()));
-    EXPECT_TRUE(n1.SetCapacity((nsCString::size_type(-1)/2 - sizeof(nsStringBuffer)) / 1 - 2, fallible_t()));
-    EXPECT_TRUE(n1.SetCapacity(0, fallible_t()));
-    EXPECT_FALSE(n1.SetCapacity((nsCString::size_type(-1)/2 - sizeof(nsStringBuffer)) / 1 - 1, fallible_t()));
-    EXPECT_TRUE(n1.SetCapacity(0, fallible_t()));
-  }
-}
-
-static void test_tofloat_helper(const nsString& aStr, float aExpected, bool aSuccess)
-{
-  nsresult result;
-  EXPECT_EQ(aStr.ToFloat(&result), aExpected);
-  if (aSuccess) {
-    EXPECT_EQ(result, NS_OK);
-  } else {
-    EXPECT_NE(result, NS_OK);
-  }
-}
-
-TEST(Strings, tofloat)
-{
-  test_tofloat_helper(NS_LITERAL_STRING("42"), 42.f, true);
-  test_tofloat_helper(NS_LITERAL_STRING("42.0"), 42.f, true);
-  test_tofloat_helper(NS_LITERAL_STRING("-42"), -42.f, true);
-  test_tofloat_helper(NS_LITERAL_STRING("+42"), 42, true);
-  test_tofloat_helper(NS_LITERAL_STRING("13.37"), 13.37f, true);
-  test_tofloat_helper(NS_LITERAL_STRING("1.23456789"), 1.23456789f, true);
-  test_tofloat_helper(NS_LITERAL_STRING("1.98765432123456"), 1.98765432123456f, true);
-  test_tofloat_helper(NS_LITERAL_STRING("0"), 0.f, true);
-  test_tofloat_helper(NS_LITERAL_STRING("1.e5"), 100000, true);
-  test_tofloat_helper(NS_LITERAL_STRING(""), 0.f, false);
-  test_tofloat_helper(NS_LITERAL_STRING("42foo"), 42.f, false);
-  test_tofloat_helper(NS_LITERAL_STRING("foo"), 0.f, false);
-}
-
-static void test_todouble_helper(const nsString& aStr, double aExpected, bool aSuccess)
-{
-  nsresult result;
-  EXPECT_EQ(aStr.ToDouble(&result), aExpected);
-  if (aSuccess) {
-    EXPECT_EQ(result, NS_OK);
-  } else {
-    EXPECT_NE(result, NS_OK);
-  }
-}
-
-TEST(Strings, todouble)
-{
-  test_todouble_helper(NS_LITERAL_STRING("42"), 42, true);
-  test_todouble_helper(NS_LITERAL_STRING("42.0"), 42, true);
-  test_todouble_helper(NS_LITERAL_STRING("-42"), -42, true);
-  test_todouble_helper(NS_LITERAL_STRING("+42"), 42, true);
-  test_todouble_helper(NS_LITERAL_STRING("13.37"), 13.37, true);
-  test_todouble_helper(NS_LITERAL_STRING("1.23456789"), 1.23456789, true);
-  test_todouble_helper(NS_LITERAL_STRING("1.98765432123456"), 1.98765432123456, true);
-  test_todouble_helper(NS_LITERAL_STRING("123456789.98765432123456"), 123456789.98765432123456, true);
-  test_todouble_helper(NS_LITERAL_STRING("0"), 0, true);
-  test_todouble_helper(NS_LITERAL_STRING("1.e5"), 100000, true);
-  test_todouble_helper(NS_LITERAL_STRING(""), 0, false);
-  test_todouble_helper(NS_LITERAL_STRING("42foo"), 42, false);
-  test_todouble_helper(NS_LITERAL_STRING("foo"), 0, false);
-}
-
-}
--- a/xpcom/glue/tests/gtest/moz.build
+++ b/xpcom/glue/tests/gtest/moz.build
@@ -1,22 +1,18 @@
 # -*- Mode: python; c-basic-offset: 4; 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/.
 
 UNIFIED_SOURCES += [
     'TestArray.cpp',
-    'TestCRT.cpp',
-    'TestEncoding.cpp',
-    'TestExpirationTracker.cpp',
     'TestFileUtils.cpp',
     'TestGCPostBarriers.cpp',
-    'TestStrings.cpp',
 ]
 
 LOCAL_INCLUDES = [
     '../..',
 ]
 
 FAIL_ON_WARNINGS = True
 
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -415,33 +415,33 @@ public:
    */
   nsAppDirectoryEnumerator(nsIDirectoryServiceProvider* aProvider,
                            const char* aKeyList[]) :
     mProvider(aProvider),
     mCurrentKey(aKeyList)
   {
   }
 
-  NS_IMETHOD HasMoreElements(bool* aResult)
+  NS_IMETHOD HasMoreElements(bool* aResult) MOZ_OVERRIDE
   {
     while (!mNext && *mCurrentKey) {
       bool dontCare;
       nsCOMPtr<nsIFile> testFile;
       (void)mProvider->GetFile(*mCurrentKey++, &dontCare, getter_AddRefs(testFile));
       // Don't return a file which does not exist.
       bool exists;
       if (testFile && NS_SUCCEEDED(testFile->Exists(&exists)) && exists) {
         mNext = testFile;
       }
     }
     *aResult = mNext != nullptr;
     return NS_OK;
   }
 
-  NS_IMETHOD GetNext(nsISupports** aResult)
+  NS_IMETHOD GetNext(nsISupports** aResult) MOZ_OVERRIDE
   {
     if (NS_WARN_IF(!aResult)) {
       return NS_ERROR_INVALID_ARG;
     }
     *aResult = nullptr;
 
     bool hasMore;
     HasMoreElements(&hasMore);
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -62,31 +62,31 @@ private:
           nsISupports* sup = event;
           NS_ADDREF(sup);
         }
       }
     }
   }
 
 public:
-  NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream* aStream)
+  NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream* aStream) MOZ_OVERRIDE
   {
     mStream = aStream;
 
     nsresult rv =
       mTarget->Dispatch(this, NS_DISPATCH_NORMAL);
     if (NS_FAILED(rv)) {
       NS_WARNING("Dispatch failed");
       return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
   }
 
-  NS_IMETHOD Run()
+  NS_IMETHOD Run() MOZ_OVERRIDE
   {
     if (mCallback) {
       if (mStream) {
         mCallback->OnInputStreamReady(mStream);
       }
       mCallback = nullptr;
     }
     return NS_OK;
@@ -143,31 +143,31 @@ private:
           nsISupports* sup = event;
           NS_ADDREF(sup);
         }
       }
     }
   }
 
 public:
-  NS_IMETHOD OnOutputStreamReady(nsIAsyncOutputStream* aStream)
+  NS_IMETHOD OnOutputStreamReady(nsIAsyncOutputStream* aStream) MOZ_OVERRIDE
   {
     mStream = aStream;
 
     nsresult rv =
       mTarget->Dispatch(this, NS_DISPATCH_NORMAL);
     if (NS_FAILED(rv)) {
       NS_WARNING("PostEvent failed");
       return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
   }
 
-  NS_IMETHOD Run()
+  NS_IMETHOD Run() MOZ_OVERRIDE
   {
     if (mCallback) {
       if (mStream) {
         mCallback->OnOutputStreamReady(mStream);
       }
       mCallback = nullptr;
     }
     return NS_OK;
@@ -391,30 +391,30 @@ public:
       aReason = NS_BASE_STREAM_CLOSED;
     }
 
     mCanceled = true;
     mCancelStatus = aReason;
     return NS_OK;
   }
 
-  NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream* aSource)
+  NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream* aSource) MOZ_OVERRIDE
   {
     PostContinuationEvent();
     return NS_OK;
   }
 
-  NS_IMETHOD OnOutputStreamReady(nsIAsyncOutputStream* aSink)
+  NS_IMETHOD OnOutputStreamReady(nsIAsyncOutputStream* aSink) MOZ_OVERRIDE
   {
     PostContinuationEvent();
     return NS_OK;
   }
 
   // continuation event handler
-  NS_IMETHOD Run()
+  NS_IMETHOD Run() MOZ_OVERRIDE
   {
     Process();
 
     // clear "in process" flag and post any pending continuation event
     MutexAutoLock lock(mLock);
     mEventInProcess = false;
     if (mEventIsPending) {
       mEventIsPending = false;
--- a/xpcom/reflect/xptcall/xptcprivate.h
+++ b/xpcom/reflect/xptcall/xptcprivate.h
@@ -27,22 +27,22 @@ class nsIXPTCStubBase : public nsISuppor
 public:
 #include "xptcstubsdef.inc"
 };
 
 #undef STUB_ENTRY
 #undef SENTINEL_ENTRY
 
 #if !defined(__ia64) || (!defined(__hpux) && !defined(__linux__) && !defined(__FreeBSD__))
-#define STUB_ENTRY(n) NS_IMETHOD Stub##n();
+#define STUB_ENTRY(n) NS_IMETHOD Stub##n() MOZ_OVERRIDE;
 #else
-#define STUB_ENTRY(n) NS_IMETHOD Stub##n(uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t);
+#define STUB_ENTRY(n) NS_IMETHOD Stub##n(uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t) MOZ_OVERRIDE;
 #endif
 
-#define SENTINEL_ENTRY(n) NS_IMETHOD Sentinel##n();
+#define SENTINEL_ENTRY(n) NS_IMETHOD Sentinel##n() MOZ_OVERRIDE;
 
 class nsXPTCStubBase MOZ_FINAL : public nsIXPTCStubBase
 {
 public:
     NS_DECL_ISUPPORTS_INHERITED
 
 #include "xptcstubsdef.inc"
 
--- a/xpcom/reflect/xptinfo/xptiprivate.h
+++ b/xpcom/reflect/xptinfo/xptiprivate.h
@@ -310,44 +310,44 @@ private:
 };
 
 class xptiInterfaceInfo MOZ_FINAL : public nsIInterfaceInfo
 {
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
 
     // Use delegation to implement (most!) of nsIInterfaceInfo.
-    NS_IMETHOD GetName(char * *aName) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetName(aName); }
-    NS_IMETHOD GetInterfaceIID(nsIID * *aIID) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIID(aIID); }
-    NS_IMETHOD IsScriptable(bool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsScriptable(_retval); }
-    NS_IMETHOD IsBuiltinClass(bool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsBuiltinClass(_retval); }
+    NS_IMETHOD GetName(char * *aName) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetName(aName); }
+    NS_IMETHOD GetInterfaceIID(nsIID * *aIID) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIID(aIID); }
+    NS_IMETHOD IsScriptable(bool *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsScriptable(_retval); }
+    NS_IMETHOD IsBuiltinClass(bool *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsBuiltinClass(_retval); }
     // Except this one.
-    NS_IMETHOD GetParent(nsIInterfaceInfo * *aParent) 
+    NS_IMETHOD GetParent(nsIInterfaceInfo * *aParent) MOZ_OVERRIDE
     {
         if(!EnsureResolved() || !EnsureParent())
             return NS_ERROR_UNEXPECTED;
         NS_IF_ADDREF(*aParent = mParent);
         return NS_OK;
     }
-    NS_IMETHOD GetMethodCount(uint16_t *aMethodCount) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodCount(aMethodCount); }
-    NS_IMETHOD GetConstantCount(uint16_t *aConstantCount) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetConstantCount(aConstantCount); }
-    NS_IMETHOD GetMethodInfo(uint16_t index, const nsXPTMethodInfo * *info) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodInfo(index, info); }
-    NS_IMETHOD GetMethodInfoForName(const char *methodName, uint16_t *index, const nsXPTMethodInfo * *info) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodInfoForName(methodName, index, info); }
-    NS_IMETHOD GetConstant(uint16_t index, JS::MutableHandleValue constant, char** name) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetConstant(index, constant, name); }
-    NS_IMETHOD GetInfoForParam(uint16_t methodIndex, const nsXPTParamInfo * param, nsIInterfaceInfo **_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetInfoForParam(methodIndex, param, _retval); }
-    NS_IMETHOD GetIIDForParam(uint16_t methodIndex, const nsXPTParamInfo * param, nsIID * *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDForParam(methodIndex, param, _retval); }
-    NS_IMETHOD GetTypeForParam(uint16_t methodIndex, const nsXPTParamInfo * param, uint16_t dimension, nsXPTType *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetTypeForParam(methodIndex, param, dimension, _retval); }
-    NS_IMETHOD GetSizeIsArgNumberForParam(uint16_t methodIndex, const nsXPTParamInfo * param, uint16_t dimension, uint8_t *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetSizeIsArgNumberForParam(methodIndex, param, dimension, _retval); }
-    NS_IMETHOD GetInterfaceIsArgNumberForParam(uint16_t methodIndex, const nsXPTParamInfo * param, uint8_t *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetInterfaceIsArgNumberForParam(methodIndex, param, _retval); }
-    NS_IMETHOD IsIID(const nsIID * IID, bool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsIID(IID, _retval); }
-    NS_IMETHOD GetNameShared(const char **name) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetNameShared(name); }
-    NS_IMETHOD GetIIDShared(const nsIID * *iid) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDShared(iid); }
-    NS_IMETHOD IsFunction(bool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsFunction(_retval); }
-    NS_IMETHOD HasAncestor(const nsIID * iid, bool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->HasAncestor(iid, _retval); }
-    NS_IMETHOD GetIIDForParamNoAlloc(uint16_t methodIndex, const nsXPTParamInfo * param, nsIID *iid) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDForParamNoAlloc(methodIndex, param, iid); }
+    NS_IMETHOD GetMethodCount(uint16_t *aMethodCount) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodCount(aMethodCount); }
+    NS_IMETHOD GetConstantCount(uint16_t *aConstantCount) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetConstantCount(aConstantCount); }
+    NS_IMETHOD GetMethodInfo(uint16_t index, const nsXPTMethodInfo * *info) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodInfo(index, info); }
+    NS_IMETHOD GetMethodInfoForName(const char *methodName, uint16_t *index, const nsXPTMethodInfo * *info) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetMethodInfoForName(methodName, index, info); }
+    NS_IMETHOD GetConstant(uint16_t index, JS::MutableHandleValue constant, char** name) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetConstant(index, constant, name); }
+    NS_IMETHOD GetInfoForParam(uint16_t methodIndex, const nsXPTParamInfo * param, nsIInterfaceInfo **_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetInfoForParam(methodIndex, param, _retval); }
+    NS_IMETHOD GetIIDForParam(uint16_t methodIndex, const nsXPTParamInfo * param, nsIID * *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDForParam(methodIndex, param, _retval); }
+    NS_IMETHOD GetTypeForParam(uint16_t methodIndex, const nsXPTParamInfo * param, uint16_t dimension, nsXPTType *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetTypeForParam(methodIndex, param, dimension, _retval); }
+    NS_IMETHOD GetSizeIsArgNumberForParam(uint16_t methodIndex, const nsXPTParamInfo * param, uint16_t dimension, uint8_t *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetSizeIsArgNumberForParam(methodIndex, param, dimension, _retval); }
+    NS_IMETHOD GetInterfaceIsArgNumberForParam(uint16_t methodIndex, const nsXPTParamInfo * param, uint8_t *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetInterfaceIsArgNumberForParam(methodIndex, param, _retval); }
+    NS_IMETHOD IsIID(const nsIID * IID, bool *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsIID(IID, _retval); }
+    NS_IMETHOD GetNameShared(const char **name) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetNameShared(name); }
+    NS_IMETHOD GetIIDShared(const nsIID * *iid) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDShared(iid); }
+    NS_IMETHOD IsFunction(bool *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsFunction(_retval); }
+    NS_IMETHOD HasAncestor(const nsIID * iid, bool *_retval) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->HasAncestor(iid, _retval); }
+    NS_IMETHOD GetIIDForParamNoAlloc(uint16_t methodIndex, const nsXPTParamInfo * param, nsIID *iid) MOZ_OVERRIDE { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIIDForParamNoAlloc(methodIndex, param, iid); }
 
 public:
     explicit xptiInterfaceInfo(xptiInterfaceEntry* entry);
 
     void Invalidate() 
         {NS_IF_RELEASE(mParent); mEntry = nullptr;}
 
 private:
--- a/xpcom/tests/TestHarness.h
+++ b/xpcom/tests/TestHarness.h
@@ -215,17 +215,17 @@ class ScopedXPCOM : public nsIDirectoryS
       nsCOMPtr<nsIFile> copy = mGREBinD;
       return copy.forget();
     }
 
     ////////////////////////////////////////////////////////////////////////////
     //// nsIDirectoryServiceProvider
 
     NS_IMETHODIMP GetFile(const char *aProperty, bool *_persistent,
-                          nsIFile **_result)
+                          nsIFile **_result) MOZ_OVERRIDE
     {
       // If we were supplied a directory service provider, ask it first.
       if (mDirSvcProvider &&
           NS_SUCCEEDED(mDirSvcProvider->GetFile(aProperty, _persistent,
                                                 _result))) {
         return NS_OK;
       }
 
@@ -260,17 +260,17 @@ class ScopedXPCOM : public nsIDirectoryS
       }
 
       return NS_ERROR_FAILURE;
     }
 
     ////////////////////////////////////////////////////////////////////////////
     //// nsIDirectoryServiceProvider2
 
-    NS_IMETHODIMP GetFiles(const char *aProperty, nsISimpleEnumerator **_enum)
+    NS_IMETHODIMP GetFiles(const char *aProperty, nsISimpleEnumerator **_enum) MOZ_OVERRIDE
     {
       // If we were supplied a directory service provider, ask it first.
       nsCOMPtr<nsIDirectoryServiceProvider2> provider =
         do_QueryInterface(mDirSvcProvider);
       if (provider && NS_SUCCEEDED(provider->GetFiles(aProperty, _enum))) {
         return NS_OK;
       }
 
new file mode 100644
--- /dev/null
+++ b/xpcom/tests/gtest/TestCRT.cpp
@@ -0,0 +1,84 @@
+/* -*- 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 "nsCRT.h"
+#include "nsString.h"
+#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) {
+    if (val == 0)
+	return 0;
+    else {
+	if (val > 0)
+	    return 1;
+	else
+	    return -1;
+    }
+}
+
+
+// Verify that nsCRT versions of string comparison routines get the
+// same answers as the native non-unicode versions. We only pass in
+// iso-latin-1 strings, so the comparison must be valid.
+static void Check(const char* s1, const char* s2, int n)
+{
+  int clib = PL_strcmp(s1, s2);
+
+  int clib_n = PL_strncmp(s1, s2, n);
+
+  nsAutoString t1,t2; 
+  t1.AssignWithConversion(s1);
+  t2.AssignWithConversion(s2);
+  const char16_t* us1 = t1.get();
+  const char16_t* us2 = t2.get();
+
+  int u2 = nsCRT::strcmp(us1, us2);
+
+  int u2_n = nsCRT::strncmp(us1, us2, n);
+
+  EXPECT_EQ(sign(clib), sign(u2));
+  EXPECT_EQ(sign(clib), sign(u2_n));
+  EXPECT_EQ(sign(clib), sign(clib_n));
+}
+
+struct Test {
+  const char* s1;
+  const char* s2;
+  int n;
+};
+
+static Test tests[] = {
+  { "foo", "foo", 3 },
+  { "foo", "fo", 3 },
+
+  { "foo", "bar", 3 },
+  { "foo", "ba", 3 },
+
+  { "foo", "zap", 3 },
+  { "foo", "za", 3 },
+
+  { "bar", "foo", 3 },
+  { "bar", "fo", 3 },
+
+  { "bar", "foo", 3 },
+  { "bar", "fo", 3 },
+};
+#define NUM_TESTS int((sizeof(tests) / sizeof(tests[0])))
+
+TEST(CRT, main)
+{
+  TestCRT::Test* tp = tests;
+  for (int i = 0; i < NUM_TESTS; i++, tp++) {
+    Check(tp->s1, tp->s2, tp->n);
+  }
+}
+
+}
new file mode 100644
--- /dev/null
+++ b/xpcom/tests/gtest/TestEncoding.cpp
@@ -0,0 +1,108 @@
+/* -*- 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 <stdlib.h>
+#include "nsString.h"
+#include "gtest/gtest.h"
+
+TEST(Encoding, GoodSurrogatePair)
+{
+  // When this string is decoded, the surrogate pair is U+10302 and the rest of
+  // the string is specified by indexes 2 onward.
+  const char16_t goodPairData[] = {  0xD800, 0xDF02, 0x65, 0x78, 0x0 };
+  nsDependentString goodPair16(goodPairData);
+
+  uint32_t byteCount = 0;
+  char* goodPair8 = ToNewUTF8String(goodPair16, &byteCount);
+  EXPECT_TRUE(!!goodPair8);
+
+  EXPECT_EQ(byteCount, 6u);
+
+  const unsigned char expected8[] =
+    { 0xF0, 0x90, 0x8C, 0x82, 0x65, 0x78, 0x0 };
+  EXPECT_EQ(0, memcmp(expected8, goodPair8, sizeof(expected8)));
+
+  // This takes a different code path from the above, so test it to make sure
+  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
+  nsDependentCString expected((const char*)expected8);
+  EXPECT_EQ(0, CompareUTF8toUTF16(expected, goodPair16));
+
+  NS_Free(goodPair8);
+}
+
+TEST(Encoding, BackwardsSurrogatePair)
+{
+  // When this string is decoded, the two surrogates are wrongly ordered and
+  // must each be interpreted as U+FFFD.
+  const char16_t backwardsPairData[] = { 0xDDDD, 0xD863, 0x65, 0x78, 0x0 };
+  nsDependentString backwardsPair16(backwardsPairData);
+
+  uint32_t byteCount = 0;
+  char* backwardsPair8 = ToNewUTF8String(backwardsPair16, &byteCount);
+  EXPECT_TRUE(!!backwardsPair8);
+
+  EXPECT_EQ(byteCount, 8u);
+
+  const unsigned char expected8[] =
+    { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBD, 0x65, 0x78, 0x0 };
+  EXPECT_EQ(0, memcmp(expected8, backwardsPair8, sizeof(expected8)));
+
+  // This takes a different code path from the above, so test it to make sure
+  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
+  nsDependentCString expected((const char*)expected8);
+  EXPECT_EQ(0, CompareUTF8toUTF16(expected, backwardsPair16));
+
+  NS_Free(backwardsPair8);
+}
+
+TEST(Encoding, MalformedUTF16OrphanHighSurrogate)
+{
+  // When this string is decoded, the high surrogate should be replaced and the
+  // rest of the string is specified by indexes 1 onward.
+  const char16_t highSurrogateData[] = { 0xD863, 0x74, 0x65, 0x78, 0x74, 0x0 };
+  nsDependentString highSurrogate16(highSurrogateData);
+
+  uint32_t byteCount = 0;
+  char* highSurrogate8 = ToNewUTF8String(highSurrogate16, &byteCount);
+  EXPECT_TRUE(!!highSurrogate8);
+
+  EXPECT_EQ(byteCount, 7u);
+
+  const unsigned char expected8[] =
+    { 0xEF, 0xBF, 0xBD, 0x74, 0x65, 0x78, 0x74, 0x0 };
+  EXPECT_EQ(0, memcmp(expected8, highSurrogate8, sizeof(expected8)));
+
+  // This takes a different code path from the above, so test it to make sure
+  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
+  nsDependentCString expected((const char*)expected8);
+  EXPECT_EQ(0, CompareUTF8toUTF16(expected, highSurrogate16));
+
+  NS_Free(highSurrogate8);
+}
+
+TEST(Encoding, MalformedUTF16OrphanLowSurrogate)
+{
+  // When this string is decoded, the low surrogate should be replaced and the
+  // rest of the string is specified by indexes 1 onward.
+  const char16_t lowSurrogateData[] = { 0xDDDD, 0x74, 0x65, 0x78, 0x74, 0x0 };
+  nsDependentString lowSurrogate16(lowSurrogateData);
+
+  uint32_t byteCount = 0;
+  char* lowSurrogate8 = ToNewUTF8String(lowSurrogate16, &byteCount);
+  EXPECT_TRUE(!!lowSurrogate8);
+
+  EXPECT_EQ(byteCount, 7u);
+
+  const unsigned char expected8[] =
+    { 0xEF, 0xBF, 0xBD, 0x74, 0x65, 0x78, 0x74, 0x0 };
+  EXPECT_EQ(0, memcmp(expected8, lowSurrogate8, sizeof(expected8)));
+
+  // This takes a different code path from the above, so test it to make sure
+  // the UTF-16 enumeration remains in sync with the UTF-8 enumeration.
+  nsDependentCString expected((const char*)expected8);
+  EXPECT_EQ(0, CompareUTF8toUTF16(expected, lowSurrogate16));
+
+  NS_Free(lowSurrogate8);
+}
new file mode 100644
--- /dev/null
+++ b/xpcom/tests/gtest/TestExpirationTracker.cpp
@@ -0,0 +1,184 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* 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 <stdlib.h>
+#include <stdio.h>
+#include <prthread.h>
+#include "nsExpirationTracker.h"
+#include "nsMemory.h"
+#include "nsAutoPtr.h"
+#include "nsString.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsDirectoryServiceUtils.h"
+#include "nsComponentManagerUtils.h"
+#include "nsXPCOM.h"
+#include "nsIFile.h"
+#include "prinrval.h"
+#include "nsThreadUtils.h"
+#include "gtest/gtest.h"
+
+namespace TestExpirationTracker {
+
+struct Object {
+  Object() : mExpired(false) { Touch(); }
+  void Touch() { mLastUsed = PR_IntervalNow(); mExpired = false; }
+
+  nsExpirationState mExpiration;
+  nsExpirationState* GetExpirationState() { return &mExpiration; }
+
+  PRIntervalTime mLastUsed;
+  bool           mExpired;
+};
+
+static bool error;
+static uint32_t periodMS = 100;
+static uint32_t ops = 1000;
+static uint32_t iterations = 2;
+static bool logging = 0;
+static uint32_t sleepPeriodMS = 50;
+static uint32_t slackMS = 30; // allow this much error
+
+template <uint32_t K> class Tracker : public nsExpirationTracker<Object,K> {
+public:
+  Tracker() : nsExpirationTracker<Object,K>(periodMS) {
+    Object* obj = new Object();
+    mUniverse.AppendElement(obj);
+    LogAction(obj, "Created");
+  }
+
+  nsTArray<nsAutoArrayPtr<Object> > mUniverse;
+
+  void LogAction(Object* aObj, const char* aAction) {
+    if (logging) {
+      printf("%d %p(%d): %s\n", PR_IntervalNow(),
+             static_cast<void*>(aObj), aObj->mLastUsed, aAction);
+    }
+  }
+
+  void DoRandomOperation() {
+    Object* obj;
+    switch (rand() & 0x7) {
+    case 0: {
+      if (mUniverse.Length() < 50) {
+        obj = new Object();
+        mUniverse.AppendElement(obj);
+        nsExpirationTracker<Object,K>::AddObject(obj);
+        LogAction(obj, "Created and added");
+      }
+      break;
+    }
+    case 4: {
+      if (mUniverse.Length() < 50) {
+        obj = new Object();
+        mUniverse.AppendElement(obj);
+        LogAction(obj, "Created");
+      }
+      break;
+    }
+    case 1: {
+      obj = mUniverse[uint32_t(rand())%mUniverse.Length()];
+      if (obj->mExpiration.IsTracked()) {
+        nsExpirationTracker<Object,K>::RemoveObject(obj);
+        LogAction(obj, "Removed");
+      }
+      break;
+    }
+    case 2: {
+      obj = mUniverse[uint32_t(rand())%mUniverse.Length()];
+      if (!obj->mExpiration.IsTracked()) {
+        obj->Touch();
+        nsExpirationTracker<Object,K>::AddObject(obj);
+        LogAction(obj, "Added");
+      }
+      break;
+    }
+    case 3: {
+      obj = mUniverse[uint32_t(rand())%mUniverse.Length()];
+      if (obj->mExpiration.IsTracked()) {
+        obj->Touch();
+        nsExpirationTracker<Object,K>::MarkUsed(obj);
+        LogAction(obj, "Marked used");
+      }
+      break;
+    }
+    }
+  }
+  
+protected:
+  void NotifyExpired(Object* aObj) {
+    LogAction(aObj, "Expired");
+    PRIntervalTime now = PR_IntervalNow();
+    uint32_t timeDiffMS = (now - aObj->mLastUsed)*1000/PR_TicksPerSecond();
+    // See the comment for NotifyExpired in nsExpirationTracker.h for these
+    // bounds
+    uint32_t lowerBoundMS = (K-1)*periodMS - slackMS;
+    uint32_t upperBoundMS = K*(periodMS + sleepPeriodMS) + slackMS;
+    if (logging) {
+      printf("Checking: %d-%d = %d [%d,%d]\n",
+             now, aObj->mLastUsed, timeDiffMS, lowerBoundMS, upperBoundMS);
+    }
+    if (timeDiffMS < lowerBoundMS || timeDiffMS > upperBoundMS) {
+      EXPECT_TRUE(timeDiffMS < periodMS && aObj->mExpired);
+    }
+    aObj->Touch();
+    aObj->mExpired = true;
+    DoRandomOperation();
+    DoRandomOperation();
+    DoRandomOperation();
+  }
+};
+
+template <uint32_t K> static bool test_random() {
+  srand(K);
+  error = false;
+ 
+  for (uint32_t j = 0; j < iterations; ++j) {
+    Tracker<K> tracker;
+
+    uint32_t i = 0;
+    for (i = 0; i < ops; ++i) {
+      if ((rand() & 0xF) == 0) {
+        // Simulate work that takes time
+        if (logging) {
+          printf("SLEEPING for %dms (%d)\n", sleepPeriodMS, PR_IntervalNow());
+        }
+        PR_Sleep(PR_MillisecondsToInterval(sleepPeriodMS));
+        // Process pending timer events
+        NS_ProcessPendingEvents(nullptr);
+      }
+      tracker.DoRandomOperation();
+    }
+  }
+  
+  return !error;
+}
+
+static bool test_random3() { return test_random<3>(); }
+static bool test_random4() { return test_random<4>(); }
+static bool test_random8() { return test_random<8>(); }
+
+typedef bool (*TestFunc)();
+#define DECL_TEST(name) { #name, name }
+
+static const struct Test {
+  const char* name;
+  TestFunc    func;
+} tests[] = {
+  DECL_TEST(test_random3),
+  DECL_TEST(test_random4),
+  DECL_TEST(test_random8),
+  { nullptr, nullptr }
+};
+
+TEST(ExpirationTracker, main)
+{
+  for (const TestExpirationTracker::Test* t = tests;
+       t->name != nullptr; ++t) {
+    EXPECT_TRUE(t->func());
+  }
+}
+
+}
new file mode 100644
--- /dev/null
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -0,0 +1,981 @@
+/* vim:set ts=2 sw=2 et cindent: */
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include "nsString.h"
+#include "nsStringBuffer.h"
+#include "nsReadableUtils.h"
+#include "nsCRTGlue.h"
+#include "nsRefPtr.h"
+#include "nsTArray.h"
+#include "mozilla/fallible.h"
+#include "gtest/gtest.h"
+
+namespace TestStrings {
+
+using mozilla::fallible_t;
+
+void test_assign_helper(const nsACString& in, nsACString &_retval)
+{
+  _retval = in;
+}
+
+TEST(Strings, assign)
+{
+  nsCString result;
+  test_assign_helper(NS_LITERAL_CSTRING("a") + NS_LITERAL_CSTRING("b"), result);
+  EXPECT_STREQ(result.get(), "ab");
+}
+
+TEST(Strings, assign_c)
+{
+  nsCString c; c.Assign('c');
+  EXPECT_STREQ(c.get(), "c");
+}
+
+TEST(Strings, test1)
+{
+  NS_NAMED_LITERAL_STRING(empty, "");
+  const nsAString& aStr = empty;
+
+  nsAutoString buf(aStr);
+
+  int32_t n = buf.FindChar(',');
+
+  n = buf.Length();
+
+  buf.Cut(0, n + 1);
+  n = buf.FindChar(',');
+
+  EXPECT_EQ(n, kNotFound);
+}
+
+TEST(Strings, test2)
+{
+  nsCString data("hello world");
+  const nsACString& aStr = data;
+
+  nsCString temp(aStr);
+  temp.Cut(0, 6);
+
+  EXPECT_STREQ(temp.get(), "world");
+}
+
+TEST(Strings, find)
+{
+  nsCString src("<!DOCTYPE blah blah blah>");
+
+  int32_t i = src.Find("DOCTYPE", true, 2, 1);
+  EXPECT_EQ(i, 2);
+}
+
+TEST(Strings, rfind)
+{
+  const char text[] = "<!DOCTYPE blah blah blah>";
+  const char term[] = "bLaH";
+  nsCString src(text);
+  int32_t i;
+
+  i = src.RFind(term, true, 3, -1); 
+  EXPECT_EQ(i, kNotFound);
+
+  i = src.RFind(term, true, -1, -1);
+  EXPECT_EQ(i, 20);
+
+  i = src.RFind(term, true, 13, -1);
+  EXPECT_EQ(i, 10);
+
+  i = src.RFind(term, true, 22, 3);
+  EXPECT_EQ(i, 20);
+}
+
+TEST(Strings, rfind_2)
+{
+  const char text[] = "<!DOCTYPE blah blah blah>";
+  nsCString src(text);
+  int32_t i = src.RFind("TYPE", false, 5, -1); 
+  EXPECT_EQ(i, 5);
+}
+
+TEST(Strings, rfind_3)
+{
+  const char text[] = "urn:mozilla:locale:en-US:necko";
+  nsAutoCString value(text);
+  int32_t i = value.RFind(":");
+  EXPECT_EQ(i, 24);
+}
+
+TEST(Strings, rfind_4)
+{
+  nsCString value("a.msf");
+  int32_t i = value.RFind(".msf");
+  EXPECT_EQ(i, 1);
+}
+
+TEST(Strings, findinreadable)
+{
+  const char text[] = "jar:jar:file:///c:/software/mozilla/mozilla_2006_02_21.jar!/browser/chrome/classic.jar!/";
+  nsAutoCString value(text);
+
+  nsACString::const_iterator begin, end;
+  value.BeginReading(begin);
+  value.EndReading(end);
+  nsACString::const_iterator delim_begin (begin),
+                             delim_end   (end);
+
+  // Search for last !/ at the end of the string
+  EXPECT_TRUE(FindInReadable(NS_LITERAL_CSTRING("!/"), delim_begin, delim_end));
+  char *r = ToNewCString(Substring(delim_begin, delim_end));
+  // Should match the first "!/" but not the last
+  EXPECT_NE(delim_end, end);
+  EXPECT_STREQ(r, "!/");
+  nsMemory::Free(r);
+
+  delim_begin = begin;
+  delim_end = end;
+
+  // Search for first jar:
+  EXPECT_TRUE(FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
+
+  r = ToNewCString(Substring(delim_begin, delim_end));
+  // Should not match the first jar:, but the second one
+  EXPECT_EQ(delim_begin, begin);
+  EXPECT_STREQ(r, "jar:");
+  nsMemory::Free(r);
+
+  // Search for jar: in a Substring
+  delim_begin = begin; delim_begin++;
+  delim_end = end;
+  EXPECT_TRUE(FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
+
+  r = ToNewCString(Substring(delim_begin, delim_end));
+  // Should not match the first jar:, but the second one
+  EXPECT_NE(delim_begin, begin);
+  EXPECT_STREQ(r, "jar:");
+  nsMemory::Free(r);
+
+  // Should not find a match
+  EXPECT_FALSE(FindInReadable(NS_LITERAL_CSTRING("gecko"), delim_begin, delim_end));
+
+  // When no match is found, range should be empty
+  EXPECT_EQ(delim_begin, delim_end);
+
+  // Should not find a match (search not beyond Substring)
+  delim_begin = begin; for (int i=0;i<6;i++) delim_begin++;
+  delim_end = end;
+  EXPECT_FALSE(FindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
+
+  // When no match is found, range should be empty
+  EXPECT_EQ(delim_begin, delim_end);
+
+  // Should not find a match (search not beyond Substring)
+  delim_begin = begin;
+  delim_end = end; for (int i=0;i<7;i++) delim_end--;
+  EXPECT_FALSE(FindInReadable(NS_LITERAL_CSTRING("classic"), delim_begin, delim_end));
+
+  // When no match is found, range should be empty
+  EXPECT_EQ(delim_begin, delim_end);
+}
+
+TEST(Strings, rfindinreadable)
+{
+  const char text[] = "jar:jar:file:///c:/software/mozilla/mozilla_2006_02_21.jar!/browser/chrome/classic.jar!/";
+  nsAutoCString value(text);
+
+  nsACString::const_iterator begin, end;
+  value.BeginReading(begin);
+  value.EndReading(end);
+  nsACString::const_iterator delim_begin (begin),
+                             delim_end   (end);
+
+  // Search for last !/ at the end of the string
+  EXPECT_TRUE(RFindInReadable(NS_LITERAL_CSTRING("!/"), delim_begin, delim_end));
+  char *r = ToNewCString(Substring(delim_begin, delim_end));
+  // Should match the last "!/"
+  EXPECT_EQ(delim_end, end);
+  EXPECT_STREQ(r, "!/");
+  nsMemory::Free(r);
+
+  delim_begin = begin;
+  delim_end = end;
+
+  // Search for last jar: but not the first one...
+  EXPECT_TRUE(RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
+
+  r = ToNewCString(Substring(delim_begin, delim_end));
+  // Should not match the first jar:, but the second one
+  EXPECT_NE(delim_begin, begin);
+  EXPECT_STREQ(r, "jar:");
+  nsMemory::Free(r);
+
+  // Search for jar: in a Substring
+  delim_begin = begin;
+  delim_end = begin; for (int i=0;i<6;i++) delim_end++;
+  EXPECT_TRUE(RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
+
+  r = ToNewCString(Substring(delim_begin, delim_end));
+  // Should not match the first jar:, but the second one
+  EXPECT_EQ(delim_begin, begin);
+  EXPECT_STREQ(r, "jar:");
+  nsMemory::Free(r);
+
+  // Should not find a match
+  delim_begin = begin;
+  delim_end = end;
+  EXPECT_FALSE(RFindInReadable(NS_LITERAL_CSTRING("gecko"), delim_begin, delim_end));
+
+  // When no match is found, range should be empty
+  EXPECT_EQ(delim_begin, delim_end);
+
+  // Should not find a match (search not before Substring)
+  delim_begin = begin; for (int i=0;i<6;i++) delim_begin++;
+  delim_end = end;
+  EXPECT_FALSE(RFindInReadable(NS_LITERAL_CSTRING("jar:"), delim_begin, delim_end));
+
+  // When no match is found, range should be empty
+  EXPECT_EQ(delim_begin, delim_end);
+
+  // Should not find a match (search not beyond Substring)
+  delim_begin = begin;
+  delim_end = end; for (int i=0;i<7;i++) delim_end--;
+  EXPECT_FALSE(RFindInReadable(NS_LITERAL_CSTRING("classic"), delim_begin, delim_end));
+
+  // When no match is found, range should be empty
+  EXPECT_EQ(delim_begin, delim_end);
+}
+
+TEST(Strings, distance)
+{
+  const char text[] = "abc-xyz";
+  nsCString s(text);
+  nsCString::const_iterator begin, end;
+  s.BeginReading(begin);
+  s.EndReading(end);
+  size_t d = Distance(begin, end);
+  EXPECT_EQ(d, sizeof(text) - 1);
+}
+
+TEST(Strings, length)
+{
+  const char text[] = "abc-xyz";
+  nsCString s(text);
+  size_t d = s.Length();
+  EXPECT_EQ(d, sizeof(text) - 1);
+}
+
+TEST(Strings, trim)
+{
+  const char text[] = " a\t    $   ";
+  const char set[] = " \t$";
+
+  nsCString s(text);
+  s.Trim(set);
+  EXPECT_STREQ(s.get(), "a");
+}
+
+TEST(Strings, replace_substr)
+{
+  const char text[] = "abc-ppp-qqq-ppp-xyz";
+  nsCString s(text);
+  s.ReplaceSubstring("ppp", "www");
+  EXPECT_STREQ(s.get(), "abc-www-qqq-www-xyz");
+
+  s.Assign("foobar");
+  s.ReplaceSubstring("foo", "bar");
+  s.ReplaceSubstring("bar", "");
+  EXPECT_STREQ(s.get(), "");
+
+  s.Assign("foofoofoo");
+  s.ReplaceSubstring("foo", "foo");
+  EXPECT_STREQ(s.get(), "foofoofoo");
+
+  s.Assign("foofoofoo");
+  s.ReplaceSubstring("of", "fo");
+  EXPECT_STREQ(s.get(), "fofoofooo");
+}
+
+TEST(Strings, replace_substr_2)
+{
+  const char *oldName = nullptr;
+  const char *newName = "user";
+  nsString acctName; acctName.AssignLiteral("forums.foo.com");
+  nsAutoString newAcctName, oldVal, newVal;
+  oldVal.AssignWithConversion(oldName);
+  newVal.AssignWithConversion(newName);
+  newAcctName.Assign(acctName);
+
+  // here, oldVal is empty.  we are testing that this function
+  // does not hang.  see bug 235355.
+  newAcctName.ReplaceSubstring(oldVal, newVal);
+
+  // we expect that newAcctName will be unchanged.
+  EXPECT_TRUE(newAcctName.Equals(acctName));
+}
+
+TEST(Strings, replace_substr_3)
+{
+  nsCString s;
+  s.Assign("abcabcabc");
+  s.ReplaceSubstring("ca", "X");
+  EXPECT_STREQ(s.get(), "abXbXbc");
+
+  s.Assign("abcabcabc");
+  s.ReplaceSubstring("ca", "XYZ");
+  EXPECT_STREQ(s.get(), "abXYZbXYZbc");
+
+  s.Assign("abcabcabc");
+  s.ReplaceSubstring("ca", "XY");
+  EXPECT_STREQ(s.get(), "abXYbXYbc");
+
+  s.Assign("abcabcabc");
+  s.ReplaceSubstring("ca", "XYZ!");
+  EXPECT_STREQ(s.get(), "abXYZ!bXYZ!bc");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("bcd", "X");
+  EXPECT_STREQ(s.get(), "aXaXaX");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("bcd", "XYZ!");
+  EXPECT_STREQ(s.get(), "aXYZ!aXYZ!aXYZ!");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("bcd", "XY");
+  EXPECT_STREQ(s.get(), "aXYaXYaXY");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("bcd", "XYZABC");
+  EXPECT_STREQ(s.get(), "aXYZABCaXYZABCaXYZABC");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("bcd", "XYZ");
+  EXPECT_STREQ(s.get(), "aXYZaXYZaXYZ");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("bcd", "XYZ!");
+  EXPECT_STREQ(s.get(), "aXYZ!aXYZ!aXYZ!");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("ab", "X");
+  EXPECT_STREQ(s.get(), "XcdXcdXcd");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("ab", "XYZABC");
+  EXPECT_STREQ(s.get(), "XYZABCcdXYZABCcdXYZABCcd");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("ab", "XY");
+  EXPECT_STREQ(s.get(), "XYcdXYcdXYcd");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("ab", "XYZ!");
+  EXPECT_STREQ(s.get(), "XYZ!cdXYZ!cdXYZ!cd");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("notfound", "X");
+  EXPECT_STREQ(s.get(), "abcdabcdabcd");
+
+  s.Assign("abcdabcdabcd");
+  s.ReplaceSubstring("notfound", "longlongstring");
+  EXPECT_STREQ(s.get(), "abcdabcdabcd");
+}
+
+TEST(Strings, strip_ws)
+{
+  const char text[] = " a    $   ";
+  nsCString s(text);
+  s.StripWhitespace();
+  EXPECT_STREQ(s.get(), "a$");
+}
+
+TEST(Strings, equals_ic)
+{
+  nsCString s;
+  EXPECT_FALSE(s.LowerCaseEqualsLiteral("view-source"));
+}
+
+TEST(Strings, fixed_string)
+{
+  char buf[256] = "hello world";
+
+  nsFixedCString s(buf, sizeof(buf));
+
+  EXPECT_EQ(s.Length(), strlen(buf));
+
+  EXPECT_STREQ(s.get(), buf);
+
+  s.Assign("foopy doopy doo");
+  EXPECT_EQ(s.get(), buf);
+}
+
+TEST(Strings, concat)
+{
+  nsCString bar("bar");
+  const nsACString& barRef = bar;
+
+  const nsPromiseFlatCString& result =
+      PromiseFlatCString(NS_LITERAL_CSTRING("foo") +
+                         NS_LITERAL_CSTRING(",") +
+                         barRef);
+  EXPECT_STREQ(result.get(), "foo,bar");
+}
+
+TEST(Strings, concat_2)
+{
+  nsCString fieldTextStr("xyz");
+  nsCString text("text");
+  const nsACString& aText = text;
+
+  nsAutoCString result( fieldTextStr + aText );
+
+  EXPECT_STREQ(result.get(), "xyztext");
+}
+
+TEST(Strings, concat_3)
+{
+  nsCString result;
+  nsCString ab("ab"), c("c");
+
+  result = ab + result + c;
+  EXPECT_STREQ(result.get(), "abc");
+}
+
+TEST(Strings, xpidl_string)
+{
+  nsXPIDLCString a, b;
+  a = b;
+  EXPECT_TRUE(a == b);
+
+  a.Adopt(0);
+  EXPECT_TRUE(a == b);
+
+  a.Append("foopy");
+  a.Assign(b);
+  EXPECT_TRUE(a == b);
+
+  a.Insert("", 0);
+  a.Assign(b);
+  EXPECT_TRUE(a == b);
+
+  const char text[] = "hello world";
+  *getter_Copies(a) = NS_strdup(text);
+  EXPECT_STREQ(a, text);
+
+  b = a;
+  EXPECT_STREQ(a, b);
+
+  a.Adopt(0);
+  nsACString::const_iterator begin, end;
+  a.BeginReading(begin);
+  a.EndReading(end);
+  char *r = ToNewCString(Substring(begin, end));
+  EXPECT_STREQ(r, "");
+  nsMemory::Free(r);
+
+  a.Adopt(0);
+  EXPECT_TRUE(a.IsVoid());
+
+  int32_t index = a.FindCharInSet("xyz");
+  EXPECT_EQ(index, kNotFound);
+}
+
+TEST(Strings, empty_assign)
+{
+  nsCString a;
+  a.AssignLiteral("");
+
+  a.AppendLiteral("");
+
+  nsCString b;
+  b.SetCapacity(0);
+}
+
+TEST(Strings, set_length)
+{
+  const char kText[] = "Default Plugin";
+  nsCString buf;
+  buf.SetCapacity(sizeof(kText)-1);
+  buf.Assign(kText);
+  buf.SetLength(sizeof(kText)-1);
+  EXPECT_STREQ(buf.get(), kText);
+}
+
+TEST(Strings, substring)
+{
+  nsCString super("hello world"), sub("hello");
+
+  // this tests that |super| starts with |sub|,
+  
+  EXPECT_TRUE(sub.Equals(StringHead(super, sub.Length())));
+
+  // and verifies that |sub| does not start with |super|.
+
+  EXPECT_FALSE(super.Equals(StringHead(sub, super.Length())));
+}
+
+#define test_append_expect(str, int, suffix, expect) \
+  str.Truncate(); \
+  str.AppendInt(suffix = int); \
+  EXPECT_TRUE(str.EqualsLiteral(expect));
+
+#define test_appends_expect(int, suffix, expect) \
+  test_append_expect(str, int, suffix, expect) \
+  test_append_expect(cstr, int, suffix, expect)
+
+#define test_appendbase(str, prefix, int, suffix, base) \
+  str.Truncate(); \
+  str.AppendInt(suffix = prefix ## int ## suffix, base); \
+  EXPECT_TRUE(str.EqualsLiteral(#int));
+
+#define test_appendbases(prefix, int, suffix, base) \
+  test_appendbase(str, prefix, int, suffix, base) \
+  test_appendbase(cstr, prefix, int, suffix, base)
+
+TEST(Strings, appendint)
+{
+  nsString str;
+  nsCString cstr;
+  int32_t L;
+  uint32_t UL;
+  int64_t LL;
+  uint64_t ULL;
+  test_appends_expect(INT32_MAX, L, "2147483647")
+  test_appends_expect(INT32_MIN, L, "-2147483648")
+  test_appends_expect(UINT32_MAX, UL, "4294967295")
+  test_appends_expect(INT64_MAX, LL, "9223372036854775807")
+  test_appends_expect(INT64_MIN, LL, "-9223372036854775808")
+  test_appends_expect(UINT64_MAX, ULL, "18446744073709551615")
+  test_appendbases(0, 17777777777, L, 8)
+  test_appendbases(0, 20000000000, L, 8)
+  test_appendbases(0, 37777777777, UL, 8)
+  test_appendbases(0, 777777777777777777777, LL, 8)
+  test_appendbases(0, 1000000000000000000000, LL, 8)
+  test_appendbases(0, 1777777777777777777777, ULL, 8)
+  test_appendbases(0x, 7fffffff, L, 16)
+  test_appendbases(0x, 80000000, L, 16)
+  test_appendbases(0x, ffffffff, UL, 16)
+  test_appendbases(0x, 7fffffffffffffff, LL, 16)
+  test_appendbases(0x, 8000000000000000, LL, 16)
+  test_appendbases(0x, ffffffffffffffff, ULL, 16)
+}
+
+TEST(Strings, appendint64)
+{
+  nsCString str;
+
+  int64_t max = INT64_MAX;
+  static const char max_expected[] = "9223372036854775807";
+  int64_t min = INT64_MIN;
+  static const char min_expected[] = "-9223372036854775808";
+  static const char min_expected_oct[] = "1000000000000000000000";
+  int64_t maxint_plus1 = 1LL << 32;
+  static const char maxint_plus1_expected[] = "4294967296";
+  static const char maxint_plus1_expected_x[] = "100000000";
+
+  str.AppendInt(max);
+
+  EXPECT_TRUE(str.Equals(max_expected));
+
+  str.Truncate();
+  str.AppendInt(min);
+  EXPECT_TRUE(str.Equals(min_expected));
+  str.Truncate();
+  str.AppendInt(min, 8);
+  EXPECT_TRUE(str.Equals(min_expected_oct));
+
+
+  str.Truncate();
+  str.AppendInt(maxint_plus1);
+  EXPECT_TRUE(str.Equals(maxint_plus1_expected));
+  str.Truncate();
+  str.AppendInt(maxint_plus1, 16);
+  EXPECT_TRUE(str.Equals(maxint_plus1_expected_x));
+}
+
+TEST(Strings, appendfloat)
+{
+  nsCString str;
+  double bigdouble = 11223344556.66;
+  static const char double_expected[] = "11223344556.66";
+  static const char float_expected[] = "0.01";
+
+  // AppendFloat is used to append doubles, therefore the precision must be
+  // large enough (see bug 327719)
+  str.AppendFloat( bigdouble );
+  EXPECT_TRUE(str.Equals(double_expected));
+
+  str.Truncate();
+  // AppendFloat is used to append floats (bug 327719 #27)
+  str.AppendFloat( 0.1f * 0.1f );
+  EXPECT_TRUE(str.Equals(float_expected));
+}
+
+TEST(Strings, findcharinset)
+{
+  nsCString buf("hello, how are you?");
+
+  int32_t index = buf.FindCharInSet(",?", 5);
+  EXPECT_EQ(index, 5);
+
+  index = buf.FindCharInSet("helo", 0);
+  EXPECT_EQ(index, 0);
+
+  index = buf.FindCharInSet("z?", 6);
+  EXPECT_EQ(index, (int32_t) buf.Length() - 1);
+}
+
+TEST(Strings, rfindcharinset)
+{
+  nsCString buf("hello, how are you?");
+
+  int32_t index = buf.RFindCharInSet(",?", 5);
+  EXPECT_EQ(index, 5);
+
+  index = buf.RFindCharInSet("helo", 0);
+  EXPECT_EQ(index, 0);
+
+  index = buf.RFindCharInSet("z?", 6);
+  EXPECT_EQ(index, kNotFound);
+
+  index = buf.RFindCharInSet("l", 5);
+  EXPECT_EQ(index, 3);
+
+  buf.Assign("abcdefghijkabc");
+
+  index = buf.RFindCharInSet("ab");
+  EXPECT_EQ(index, 12);
+
+  index = buf.RFindCharInSet("ab", 11);
+  EXPECT_EQ(index, 11);
+
+  index = buf.RFindCharInSet("ab", 10);
+  EXPECT_EQ(index, 1);
+
+  index = buf.RFindCharInSet("ab", 0);
+  EXPECT_EQ(index, 0);
+
+  index = buf.RFindCharInSet("cd", 1);
+  EXPECT_EQ(index, kNotFound);
+
+  index = buf.RFindCharInSet("h");
+  EXPECT_EQ(index, 7);
+}
+
+TEST(Strings, stringbuffer)
+{
+  const char kData[] = "hello world";
+
+  nsRefPtr<nsStringBuffer> buf;
+
+  buf = nsStringBuffer::Alloc(sizeof(kData));
+  EXPECT_TRUE(!!buf);
+
+  buf = nsStringBuffer::Alloc(sizeof(kData));
+  EXPECT_TRUE(!!buf);
+  char *data = (char *) buf->Data();
+  memcpy(data, kData, sizeof(kData));
+
+  nsCString str;
+  buf->ToString(sizeof(kData)-1, str);
+
+  nsStringBuffer *buf2;
+  buf2 = nsStringBuffer::FromString(str);
+
+  EXPECT_EQ(buf, buf2);
+}
+
+TEST(Strings, voided)
+{
+  const char kData[] = "hello world";
+
+  nsXPIDLCString str;
+  EXPECT_FALSE(str);
+  EXPECT_TRUE(str.IsVoid());
+  EXPECT_TRUE(str.IsEmpty());
+
+  str.Assign(kData);
+  EXPECT_STREQ(str, kData);
+
+  str.SetIsVoid(true);
+  EXPECT_FALSE(str);
+  EXPECT_TRUE(str.IsVoid());
+  EXPECT_TRUE(str.IsEmpty());
+
+  str.SetIsVoid(false);
+  EXPECT_STREQ(str, "");
+}
+
+TEST(Strings, voided_autostr)
+{
+  const char kData[] = "hello world";
+
+  nsAutoCString str;
+  EXPECT_FALSE(str.IsVoid());
+  EXPECT_TRUE(str.IsEmpty());
+
+  str.Assign(kData);
+  EXPECT_STREQ(str.get(), kData);
+
+  str.SetIsVoid(true);
+  EXPECT_TRUE(str.IsVoid());
+  EXPECT_TRUE(str.IsEmpty());
+
+  str.Assign(kData);
+  EXPECT_FALSE(str.IsVoid());
+  EXPECT_FALSE(str.IsEmpty());
+  EXPECT_STREQ(str.get(), kData);
+}
+
+TEST(Strings, voided_assignment)
+{
+  nsCString a, b;
+  b.SetIsVoid(true);
+  a = b;
+  EXPECT_TRUE(a.IsVoid());
+  EXPECT_EQ(a.get(), b.get());
+}
+
+TEST(Strings, empty_assignment)
+{
+  nsCString a, b;
+  a = b;
+  EXPECT_EQ(a.get(), b.get());
+}
+
+struct ToIntegerTest
+{
+  const char *str;
+  uint32_t radix;
+  int32_t result;
+  nsresult rv;
+};
+
+static const ToIntegerTest kToIntegerTests[] = {
+  { "123", 10, 123, NS_OK },
+  { "7b", 16, 123, NS_OK },
+  { "90194313659", 10, 0, NS_ERROR_ILLEGAL_VALUE },
+  { nullptr, 0, 0, NS_OK }
+};
+
+TEST(Strings, string_tointeger)
+{
+  nsresult rv;
+  for (const ToIntegerTest* t = kToIntegerTests; t->str; ++t) {
+    int32_t result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
+    EXPECT_EQ(rv, t->rv);
+    EXPECT_EQ(result, t->result);
+    result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
+    EXPECT_EQ(rv, t->rv);
+    EXPECT_EQ(result, t->result);
+  }
+}
+
+static void test_parse_string_helper(const char* str, char separator, int len,
+                                       const char* s1, const char* s2)
+{
+  nsCString data(str);
+  nsTArray<nsCString> results;
+  EXPECT_TRUE(ParseString(data, separator, results));
+  EXPECT_EQ(int(results.Length()), len);
+  const char* strings[] = { s1, s2 };
+  for (int i = 0; i < len; ++i) {
+    EXPECT_TRUE(results[i].Equals(strings[i]));
+  }
+}
+
+static void test_parse_string_helper0(const char* str, char separator)
+{
+  test_parse_string_helper(str, separator, 0, nullptr, nullptr);
+}
+
+static void test_parse_string_helper1(const char* str, char separator, const char* s1)
+{
+  test_parse_string_helper(str, separator, 1, s1, nullptr);
+}
+
+static void test_parse_string_helper2(const char* str, char separator, const char* s1, const char* s2)
+{
+  test_parse_string_helper(str, separator, 2, s1, s2);
+}
+
+TEST(String, parse_string)
+{
+  test_parse_string_helper1("foo, bar", '_', "foo, bar");
+  test_parse_string_helper2("foo, bar", ',', "foo", " bar");
+  test_parse_string_helper2("foo, bar ", ' ', "foo,", "bar");
+  test_parse_string_helper2("foo,bar", 'o', "f", ",bar");
+  test_parse_string_helper0("", '_');
+  test_parse_string_helper0("  ", ' ');
+  test_parse_string_helper1(" foo", ' ', "foo");
+  test_parse_string_helper1("  foo", ' ', "foo");
+}
+
+static void test_strip_chars_helper(const char16_t* str, const char16_t* strip, const nsAString& result, uint32_t offset=0)
+{
+  nsAutoString tmp(str);
+  nsAString& data = tmp;
+  data.StripChars(strip, offset);
+  EXPECT_TRUE(data.Equals(result));
+}
+
+TEST(String, strip_chars)
+{
+  test_strip_chars_helper(MOZ_UTF16("foo \r \nbar"),
+                          MOZ_UTF16(" \n\r"),
+                          NS_LITERAL_STRING("foobar"));
+  test_strip_chars_helper(MOZ_UTF16("\r\nfoo\r\n"),
+                          MOZ_UTF16(" \n\r"),
+                          NS_LITERAL_STRING("foo"));
+  test_strip_chars_helper(MOZ_UTF16("foo"),
+                          MOZ_UTF16(" \n\r"),
+                          NS_LITERAL_STRING("foo"));
+  test_strip_chars_helper(MOZ_UTF16("foo"),
+                          MOZ_UTF16("fo"),
+                          NS_LITERAL_STRING(""));
+  test_strip_chars_helper(MOZ_UTF16("foo"),
+                          MOZ_UTF16("foo"),
+