merge mozilla-central to autoland. r=merge a=merge
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 20 Jul 2017 10:57:40 +0200
changeset 418549 5c970c6e9a2fc4a06b2fef139877b6846e7f2189
parent 418548 134ac1090b4a058d61a72dd2e680c30cb5db3af4 (current diff)
parent 418525 0985725c848ec0cfc6f2f3c3a5aa3d71321e7620 (diff)
child 418550 9081664a8b86cd6bb3f188a78d3c70f076ef9ccd
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge, merge
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
merge mozilla-central to autoland. r=merge a=merge
--- a/browser/components/extensions/ext-history.js
+++ b/browser/components/extensions/ext-history.js
@@ -1,19 +1,19 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 // The ext-* files are imported into the same scopes.
 /* import-globals-from ext-browserAction.js */
 
-XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
-                                  "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
                                   "resource://gre/modules/PlacesUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+                                  "resource://gre/modules/Services.jsm");
 
 var {
   normalizeTime,
 } = ExtensionUtils;
 
 let nsINavHistoryService = Ci.nsINavHistoryService;
 const TRANSITION_TO_TRANSITION_TYPES_MAP = new Map([
   ["link", nsINavHistoryService.TRANSITION_LINK],
@@ -208,17 +208,17 @@ this.history = class extends ExtensionAP
             return Promise.reject({message: "A URL must be provided for getVisits"});
           }
 
           let options = PlacesUtils.history.getNewQueryOptions();
           options.sortingMode = options.SORT_BY_DATE_DESCENDING;
           options.resultType = options.RESULTS_AS_VISIT;
 
           let historyQuery = PlacesUtils.history.getNewQuery();
-          historyQuery.uri = NetUtil.newURI(url);
+          historyQuery.uri = Services.io.newURI(url);
           let queryResult = PlacesUtils.history.executeQuery(historyQuery, options).root;
           let results = convertNavHistoryContainerResultNode(queryResult, convertNodeToVisitItem);
           return Promise.resolve(results);
         },
 
         onVisited: new EventManager(context, "history.onVisited", fire => {
           let listener = (event, data) => {
             fire.sync(data);
--- a/browser/components/extensions/ext-menus.js
+++ b/browser/components/extensions/ext-menus.js
@@ -2,19 +2,16 @@
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 // The ext-* files are imported into the same scopes.
 /* import-globals-from ext-utils.js */
 
 Cu.import("resource://gre/modules/Services.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
-                                  "resource://gre/modules/NetUtil.jsm");
-
 var {
   ExtensionError,
 } = ExtensionUtils;
 
 Cu.import("resource://gre/modules/ExtensionParent.jsm");
 
 var {
   IconDetails,
@@ -570,17 +567,17 @@ MenuItem.prototype = {
       let targetUrls = [];
       if (contextData.onImage || contextData.onAudio || contextData.onVideo) {
         // TODO: double check if srcUrl is always set when we need it
         targetUrls.push(contextData.srcUrl);
       }
       if (contextData.onLink) {
         targetUrls.push(contextData.linkUrl);
       }
-      if (!targetUrls.some(targetUrl => targetPattern.matches(NetUtil.newURI(targetUrl)))) {
+      if (!targetUrls.some(targetUrl => targetPattern.matches(Services.io.newURI(targetUrl)))) {
         return false;
       }
     }
 
     return true;
   },
 };
 
--- a/devtools/shared/heapsnapshot/DeserializedNode.h
+++ b/devtools/shared/heapsnapshot/DeserializedNode.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_devtools_DeserializedNode__
 #define mozilla_devtools_DeserializedNode__
 
 #include "js/UbiNode.h"
 #include "js/UniquePtr.h"
 #include "mozilla/devtools/CoreDump.pb.h"
+#include "mozilla/HashFunctions.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/Move.h"
 #include "mozilla/Vector.h"
 
 // `Deserialized{Node,Edge}` translate protobuf messages from our core dump
 // format into structures we can rely upon for implementing `JS::ubi::Node`
 // specializations on top of. All of the properties of the protobuf messages are
 // optional for future compatibility, and this is the layer where we validate
@@ -137,23 +138,17 @@ protected:
 private:
   DeserializedNode(const DeserializedNode&) = delete;
   DeserializedNode& operator=(const DeserializedNode&) = delete;
 };
 
 static inline js::HashNumber
 hashIdDerivedFromPtr(uint64_t id)
 {
-    // NodeIds and StackFrameIds are always 64 bits, but they are derived from
-    // the original referents' addresses, which could have been either 32 or 64
-    // bits long. As such, NodeId and StackFrameId have little entropy in their
-    // bottom three bits, and may or may not have entropy in their upper 32
-    // bits. This hash should manage both cases well.
-    id >>= 3;
-    return js::HashNumber((id >> 32) ^ id);
+    return mozilla::HashGeneric(id);
 }
 
 struct DeserializedNode::HashPolicy
 {
   using Lookup = NodeId;
 
   static js::HashNumber hash(const Lookup& lookup) {
     return hashIdDerivedFromPtr(lookup);
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -114,17 +114,17 @@ ShaderOutput(gl::GLContext* gl)
         case 330: return SH_GLSL_330_CORE_OUTPUT;
         case 400: return SH_GLSL_400_CORE_OUTPUT;
         case 410: return SH_GLSL_410_CORE_OUTPUT;
         case 420: return SH_GLSL_420_CORE_OUTPUT;
         case 430: return SH_GLSL_430_CORE_OUTPUT;
         case 440: return SH_GLSL_440_CORE_OUTPUT;
         case 450: return SH_GLSL_450_CORE_OUTPUT;
         default:
-            MOZ_CRASH("GFX: Unexpected GLSL version.");
+            MOZ_ASSERT(false, "GFX: Unexpected GLSL version.");
         }
     }
 
     return SH_GLSL_COMPATIBILITY_OUTPUT;
 }
 
 webgl::ShaderValidator*
 WebGLContext::CreateShaderValidator(GLenum shaderType) const
--- a/dom/html/HTMLFormSubmission.cpp
+++ b/dom/html/HTMLFormSubmission.cpp
@@ -30,17 +30,16 @@
 #include "nsIMIMEInputStream.h"
 #include "nsIMIMEService.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIFileStreams.h"
 #include "nsContentUtils.h"
-#include "mozilla/Telemetry.h"
 
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/File.h"
 
 namespace mozilla {
 namespace dom {
 
 namespace {
--- a/gfx/layers/wr/WebRenderBridgeChild.cpp
+++ b/gfx/layers/wr/WebRenderBridgeChild.cpp
@@ -460,20 +460,20 @@ WebRenderBridgeChild::RecvWrUpdated(cons
   GetCompositorBridgeChild()->RecvInvalidateLayers(wr::AsUint64(mPipelineId));
   return IPC_OK();
 }
 
 void
 WebRenderBridgeChild::BeginClearCachedResources()
 {
   mIsInClearCachedResources = true;
-  SendClearCachedResources();
 }
 
 void
 WebRenderBridgeChild::EndClearCachedResources()
 {
   ProcessWebRenderParentCommands();
+  SendClearCachedResources();
   mIsInClearCachedResources = false;
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -841,21 +841,21 @@ mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvClearCachedResources()
 {
   if (mDestroyed) {
     return IPC_OK();
   }
   mCompositorBridge->ObserveLayerUpdate(GetLayersId(), GetChildLayerObserverEpoch(), false);
 
   // Clear resources
-  // XXX Can we clear more resources?
   ++mWrEpoch; // Update webrender epoch
   mApi->ClearRootDisplayList(wr::NewEpoch(mWrEpoch), mPipelineId);
   // Schedule composition to clean up Pipeline
   mCompositorScheduler->ScheduleComposition();
+  DeleteOldImages();
   // Remove animations.
   for (std::unordered_set<uint64_t>::iterator iter = mActiveAnimations.begin(); iter != mActiveAnimations.end(); iter++) {
     mAnimStorage->ClearById(*iter);
   }
   mActiveAnimations.clear();
   return IPC_OK();
 }
 
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -625,28 +625,28 @@ WebRenderLayerManager::MakeSnapshotIfReq
   dt->FillRect(dst, pattern);
 
   mTarget = nullptr;
 }
 
 void
 WebRenderLayerManager::AddImageKeyForDiscard(wr::ImageKey key)
 {
-  mImageKeys.push_back(key);
+  mImageKeysToDelete.push_back(key);
 }
 
 void
 WebRenderLayerManager::DiscardImages()
 {
   if (WrBridge()->IPCOpen()) {
-    for (auto key : mImageKeys) {
+    for (auto key : mImageKeysToDelete) {
       WrBridge()->SendDeleteImage(key);
     }
   }
-  mImageKeys.clear();
+  mImageKeysToDelete.clear();
 }
 
 void
 WebRenderLayerManager::AddCompositorAnimationsIdForDiscard(uint64_t aId)
 {
   mDiscardedCompositorAnimationsIds.AppendElement(aId);
 }
 
@@ -661,17 +661,17 @@ WebRenderLayerManager::DiscardCompositor
 }
 
 void
 WebRenderLayerManager::DiscardLocalImages()
 {
   // Removes images but doesn't tell the parent side about them
   // This is useful in empty / failed transactions where we created
   // image keys but didn't tell the parent about them yet.
-  mImageKeys.clear();
+  mImageKeysToDelete.clear();
 }
 
 void
 WebRenderLayerManager::Mutated(Layer* aLayer)
 {
   LayerManager::Mutated(aLayer);
   AddMutatedLayer(aLayer);
 }
@@ -759,16 +759,17 @@ void
 WebRenderLayerManager::ClearCachedResources(Layer* aSubtree)
 {
   WrBridge()->BeginClearCachedResources();
   if (aSubtree) {
     ClearLayer(aSubtree);
   } else if (mRoot) {
     ClearLayer(mRoot);
   }
+  DiscardImages();
   WrBridge()->EndClearCachedResources();
 }
 
 void
 WebRenderLayerManager::UpdateTextureFactoryIdentifier(const TextureFactoryIdentifier& aNewIdentifier,
                                                       uint64_t aDeviceResetSeqNo)
 {
   WrBridge()->IdentifyTextureHost(aNewIdentifier);
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -209,17 +209,17 @@ private:
   bool EndTransactionInternal(DrawPaintedLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags,
                               nsDisplayList* aDisplayList = nullptr,
                               nsDisplayListBuilder* aDisplayListBuilder = nullptr);
 
 private:
   nsIWidget* MOZ_NON_OWNING_REF mWidget;
-  std::vector<wr::ImageKey> mImageKeys;
+  std::vector<wr::ImageKey> mImageKeysToDelete;
   nsTArray<uint64_t> mDiscardedCompositorAnimationsIds;
 
   /* PaintedLayer callbacks; valid at the end of a transaciton,
    * while rendering */
   DrawPaintedLayerCallback mPaintedLayerCallback;
   void *mPaintedLayerCallbackData;
 
   RefPtr<WebRenderBridgeChild> mWrChild;
--- a/memory/build/mozmemory_wrap.h
+++ b/memory/build/mozmemory_wrap.h
@@ -136,17 +136,17 @@
 #    if defined(XP_WIN)
 #      if defined(MOZ_REPLACE_MALLOC)
 #        define mozmem_malloc_impl(a)   a ## _impl
 #      else
 #        define mozmem_malloc_impl(a)   je_ ## a
 #      endif
 #    else
 #      define MOZ_MEMORY_API MOZ_EXTERN_C MFBT_API
-#      if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
+#      if defined(MOZ_WIDGET_ANDROID)
 #        define MOZ_WRAP_NEW_DELETE
 #      endif
 #    endif
 #  endif
 #  ifdef XP_WIN
 #    define mozmem_dup_impl(a)      wrap_ ## a
 #  endif
 #endif
--- a/memory/volatile/tests/TestVolatileBuffer.cpp
+++ b/memory/volatile/tests/TestVolatileBuffer.cpp
@@ -63,24 +63,17 @@ TEST(VolatileBufferTest, RealVolatileBuf
     VolatileBufferPtr<char> ptr(buf);
 
     EXPECT_FALSE(ptr.WasBufferPurged())
       << "Buffer was immediately purged after unlock";
     EXPECT_STREQ(ptr, teststr) << "Buffer failed to retain data after unlock";
   }
 
   // Test purging if we know how to
-#if defined(MOZ_WIDGET_GONK)
-  // This also works on Android, but we need root.
-  int fd = open("/" ASHMEM_NAME_DEF, O_RDWR);
-
-  ASSERT_GE(fd, 0) << "Failed to open ashmem device";
-  ASSERT_GE(ioctl(fd, ASHMEM_PURGE_ALL_CACHES, NULL), 0)
-    << "Failed to purge ashmem caches";
-#elif defined(XP_DARWIN)
+#if defined(XP_DARWIN)
   int state;
   vm_purgable_control(mach_task_self(), (vm_address_t)NULL,
                       VM_PURGABLE_PURGE_ALL, &state);
 #else
   return;
 #endif
 
   EXPECT_GT(buf->NonHeapSizeOfExcludingThis(), 0ul)
--- a/mobile/android/base/AppConstants.java.in
+++ b/mobile/android/base/AppConstants.java.in
@@ -56,16 +56,17 @@ public class AppConstants {
         public static final boolean feature26Plus = MIN_SDK_VERSION >= 26 || (MAX_SDK_VERSION >= 26 && Build.VERSION.SDK_INT >= 26);
 
         /*
          * If our MIN_SDK_VERSION is 14 or higher, we must be an ICS device.
          * If our MAX_SDK_VERSION is lower than ICS, we must not be an ICS device.
          * Otherwise, we need a range check.
          */
         public static final boolean preMarshmallow = MAX_SDK_VERSION < 23 || (MIN_SDK_VERSION < 23 && Build.VERSION.SDK_INT < 23);
+        public static final boolean preLollipopMR1 = MAX_SDK_VERSION < 22 || (MIN_SDK_VERSION < 22 && Build.VERSION.SDK_INT < 22);
         public static final boolean preLollipop = MAX_SDK_VERSION < 21 || (MIN_SDK_VERSION < 21 && Build.VERSION.SDK_INT < 21);
         public static final boolean preJBMR2 = MAX_SDK_VERSION < 18 || (MIN_SDK_VERSION < 18 && Build.VERSION.SDK_INT < 18);
         public static final boolean preJBMR1 = MAX_SDK_VERSION < 17 || (MIN_SDK_VERSION < 17 && Build.VERSION.SDK_INT < 17);
         public static final boolean preJB = MAX_SDK_VERSION < 16 || (MIN_SDK_VERSION < 16 && Build.VERSION.SDK_INT < 16);
         public static final boolean preN = MAX_SDK_VERSION < 24 || (MIN_SDK_VERSION < 24 && Build.VERSION.SDK_INT < 24);
     }
 
     /**
--- a/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/DateTimePicker.java
@@ -309,18 +309,18 @@ public class DateTimePicker extends Fram
                     CalendarView view, int year, int month, int monthDay) {
                     mTempDate.set(year, month, monthDay);
                     setDate(mTempDate);
                     notifyDateChanged();
                 }
             });
 
             final int height;
-            if (Versions.preLollipop) {
-                // The 4.X version of CalendarView doesn't request any height, resulting in
+            if (Versions.preLollipopMR1) {
+                // Older versions of CalendarView don't request any height, resulting in
                 // the whole dialog not appearing unless we manually request height.
                 height =  (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics());;
             } else {
                 height = LayoutParams.WRAP_CONTENT;
             }
 
             mPickers.addView(mCalendar, LayoutParams.MATCH_PARENT, height);
 
--- a/mozglue/build/BionicGlue.cpp
+++ b/mozglue/build/BionicGlue.cpp
@@ -59,33 +59,16 @@ struct SpecialAllocator: public std::all
 private:
   mozilla::AlignedStorage2<T> buf;
   bool bufUsed;
 };
 
 static std::vector<AtForkFuncs, SpecialAllocator<AtForkFuncs> > atfork;
 #endif
 
-#ifdef MOZ_WIDGET_GONK
-#include "cpuacct.h"
-
-#if ANDROID_VERSION < 17 || defined(MOZ_WIDGET_ANDROID)
-extern "C" NS_EXPORT int
-timer_create(clockid_t, struct sigevent*, timer_t*)
-{
-  __android_log_print(ANDROID_LOG_ERROR, "BionicGlue", "timer_create not supported!");
-  abort();
-  return -1;
-}
-#endif
-
-#else
-#define cpuacct_add(x)
-#endif
-
 #if ANDROID_VERSION < 17 || defined(MOZ_WIDGET_ANDROID)
 extern "C" NS_EXPORT int
 pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
 {
   AtForkFuncs funcs;
   funcs.prepare = prepare;
   funcs.parent = parent;
   funcs.child = child;
@@ -103,17 +86,16 @@ fork(void)
   pid_t pid;
   for (auto it = atfork.rbegin();
        it < atfork.rend(); ++it)
     if (it->prepare)
       it->prepare();
 
   switch ((pid = syscall(__NR_clone, SIGCHLD, NULL, NULL, NULL, NULL))) {
   case 0:
-    cpuacct_add(getuid());
     for (auto it = atfork.begin();
          it < atfork.end(); ++it)
       if (it->child)
         it->child();
     break;
   default:
     for (auto it = atfork.begin();
          it < atfork.end(); ++it)
@@ -135,23 +117,21 @@ raise(int sig)
   // equivalent to raise(sig), but Bionic also has a bug with these
   // functions, where a forked child will kill its parent instead.
 
   extern pid_t gettid(void);
   return syscall(__NR_tgkill, getpid(), gettid(), sig);
 }
 
 /* Flash plugin uses symbols that are not present in Android >= 4.4 */
-#ifndef MOZ_WIDGET_GONK
 namespace android {
   namespace VectorImpl {
     NS_EXPORT void reservedVectorImpl1(void) { }
     NS_EXPORT void reservedVectorImpl2(void) { }
     NS_EXPORT void reservedVectorImpl3(void) { }
     NS_EXPORT void reservedVectorImpl4(void) { }
     NS_EXPORT void reservedVectorImpl5(void) { }
     NS_EXPORT void reservedVectorImpl6(void) { }
     NS_EXPORT void reservedVectorImpl7(void) { }
     NS_EXPORT void reservedVectorImpl8(void) { }
   }
 }
-#endif
 
--- a/mozglue/misc/TimeStamp.h
+++ b/mozglue/misc/TimeStamp.h
@@ -422,18 +422,17 @@ public:
    * vsync timestamps, we enable the creation of mozilla::TimeStamps
    * on platforms that support vsync aligned refresh drivers / compositors
    * Verified true as of Jan 31, 2015: B2G and OS X
    * False on Windows 7
    * Android's event time uses CLOCK_MONOTONIC via SystemClock.uptimeMilles.
    * So it is same value of TimeStamp posix implementation.
    * UNTESTED ON OTHER PLATFORMS
    */
-#if defined(MOZ_WIDGET_GONK) || defined(XP_DARWIN) || \
-    defined(MOZ_WIDGET_ANDROID)
+#if defined(XP_DARWIN) || defined(MOZ_WIDGET_ANDROID)
   static TimeStamp FromSystemTime(int64_t aSystemTime)
   {
     static_assert(sizeof(aSystemTime) == sizeof(TimeStampValue),
                   "System timestamp should be same units as TimeStampValue");
     return TimeStamp(aSystemTime);
   }
 #endif
 
--- a/netwerk/base/nsStreamListenerWrapper.h
+++ b/netwerk/base/nsStreamListenerWrapper.h
@@ -21,17 +21,17 @@ class nsStreamListenerWrapper final : pu
 {
 public:
   explicit nsStreamListenerWrapper(nsIStreamListener *listener)
     : mListener(listener)
   {
     MOZ_ASSERT(mListener, "no stream listener specified");
   }
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_FORWARD_SAFE_NSIREQUESTOBSERVER(mListener)
   NS_FORWARD_SAFE_NSISTREAMLISTENER(mListener)
   NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
 
 private:
   ~nsStreamListenerWrapper() {}
   nsCOMPtr<nsIStreamListener> mListener;
 };
--- a/toolkit/components/build/nsToolkitCompsModule.cpp
+++ b/toolkit/components/build/nsToolkitCompsModule.cpp
@@ -42,17 +42,17 @@
 #if defined(XP_WIN)
 #include "NativeFileWatcherWin.h"
 #else
 #include "NativeFileWatcherNotSupported.h"
 #endif // (XP_WIN)
 
 #include "nsWebRequestListener.h"
 
-#if !defined(MOZ_WIDGET_GONK) && !defined(MOZ_WIDGET_ANDROID)
+#if !defined(MOZ_WIDGET_ANDROID)
 #define MOZ_HAS_TERMINATOR
 #endif
 
 #if defined(MOZ_HAS_TERMINATOR)
 #include "nsTerminator.h"
 #endif
 
 #define MOZ_HAS_PERFSTATS
--- a/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp
+++ b/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp
@@ -140,19 +140,16 @@ static const mozilla::Module::CIDEntry k
 };
 
 static const mozilla::Module::ContractIDEntry kDiskSpaceWatcherContracts[] = {
   { "@mozilla.org/toolkit/disk-space-watcher;1", &kNS_DISKSPACEWATCHER_CID },
   { nullptr }
 };
 
 static const mozilla::Module::CategoryEntry kDiskSpaceWatcherCategories[] = {
-#ifdef MOZ_WIDGET_GONK
-  { "profile-after-change", "Disk Space Watcher Service", DISKSPACEWATCHER_CONTRACTID },
-#endif
   { nullptr }
 };
 
 static const mozilla::Module kDiskSpaceWatcherModule = {
   mozilla::Module::kVersion,
   kDiskSpaceWatcherCIDs,
   kDiskSpaceWatcherContracts,
   kDiskSpaceWatcherCategories
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -274,17 +274,17 @@ var UninstallObserver = {
 
     if (!this.leaveStorage) {
       // Clear browser.local.storage
       AsyncShutdown.profileChangeTeardown.addBlocker(
         `Clear Extension Storage ${addon.id}`,
         ExtensionStorage.clear(addon.id));
 
       // Clear any IndexedDB storage created by the extension
-      let baseURI = NetUtil.newURI(`moz-extension://${uuid}/`);
+      let baseURI = Services.io.newURI(`moz-extension://${uuid}/`);
       let principal = Services.scriptSecurityManager.createCodebasePrincipal(
         baseURI, {});
       Services.qms.clearStoragesForPrincipal(principal);
 
       // Clear localStorage created by the extension
       let storage = Services.domStorageManager.getStorage(null, principal);
       if (storage) {
         storage.clear();
@@ -390,17 +390,17 @@ this.ExtensionData = class {
     if (!this.uuid) {
       this.uuid = UUIDMap.get(this.id);
     }
     return `moz-extension://${this.uuid}/${path}`;
   }
 
   async readDirectory(path) {
     if (this.rootURI instanceof Ci.nsIFileURL) {
-      let uri = NetUtil.newURI(this.rootURI.resolve("./" + path));
+      let uri = Services.io.newURI(this.rootURI.resolve("./" + path));
       let fullPath = uri.QueryInterface(Ci.nsIFileURL).file.path;
 
       let iter = new OS.File.DirectoryIterator(fullPath);
       let results = [];
 
       try {
         await iter.forEach(entry => {
           results.push(entry);
@@ -787,17 +787,17 @@ this.Extension = class extends Extension
       throw new Error("Out-of-process WebExtensions are not supported with multiple child processes");
     }
 
     // This is filled in the first time an extension child is created.
     this.parentMessageManager = null;
 
     this.id = addonData.id;
     this.version = addonData.version;
-    this.baseURI = NetUtil.newURI(this.getURL("")).QueryInterface(Ci.nsIURL);
+    this.baseURI = Services.io.newURI(this.getURL("")).QueryInterface(Ci.nsIURL);
     this.principal = this.createPrincipal();
     this.views = new Set();
     this._backgroundPageFrameLoader = null;
 
     this.onStartup = null;
 
     this.hasShutdown = false;
     this.onShutdown = new Set();
--- a/toolkit/components/extensions/ExtensionParent.jsm
+++ b/toolkit/components/extensions/ExtensionParent.jsm
@@ -29,18 +29,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "IndexedDB",
                                   "resource://gre/modules/IndexedDB.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MessageChannel",
                                   "resource://gre/modules/MessageChannel.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "NativeApp",
                                   "resource://gre/modules/NativeMessaging.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
-                                  "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
                                   "resource://gre/modules/PrivateBrowsingUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Schemas",
                                   "resource://gre/modules/Schemas.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gAddonPolicyService",
                                    "@mozilla.org/addons/policy-service;1",
                                    "nsIAddonPolicyService");
@@ -362,17 +360,17 @@ GlobalManager = {
 /**
  * The proxied parent side of a context in ExtensionChild.jsm, for the
  * parent side of a proxied API.
  */
 class ProxyContextParent extends BaseContext {
   constructor(envType, extension, params, xulBrowser, principal) {
     super(envType, extension);
 
-    this.uri = NetUtil.newURI(params.url);
+    this.uri = Services.io.newURI(params.url);
 
     this.incognito = params.incognito;
 
     this.listenerPromises = new Set();
 
     // This message manager is used by ParentAPIManager to send messages and to
     // close the ProxyContext if the underlying message manager closes. This
     // message manager object may change when `xulBrowser` swaps docshells, e.g.
--- a/toolkit/components/extensions/ext-cookies.js
+++ b/toolkit/components/extensions/ext-cookies.js
@@ -1,17 +1,17 @@
 "use strict";
 
 // The ext-* files are imported into the same scopes.
 /* import-globals-from ext-toolkit.js */
 
 XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
                                   "resource://gre/modules/ContextualIdentityService.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
-                                  "resource://gre/modules/NetUtil.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+                                  "resource://gre/modules/Services.jsm");
 
 /* globals DEFAULT_STORE, PRIVATE_STORE */
 
 const convertCookie = ({cookie, isPrivate}) => {
   let result = {
     name: cookie.name,
     value: cookie.value,
     domain: cookie.host,
@@ -176,17 +176,17 @@ const query = function* (detailsIn, prop
   let enumerator;
   let uri;
   let originAttributes = {
     userContextId,
     privateBrowsingId: isPrivate ? 1 : 0,
   };
   if ("url" in details) {
     try {
-      uri = NetUtil.newURI(details.url).QueryInterface(Ci.nsIURL);
+      uri = Services.io.newURI(details.url).QueryInterface(Ci.nsIURL);
       enumerator = Services.cookies.getCookiesFromHost(uri.host, originAttributes);
     } catch (ex) {
       // This often happens for about: URLs
       return;
     }
   } else if ("domain" in details) {
     enumerator = Services.cookies.getCookiesFromHost(details.domain, originAttributes);
   } else {
@@ -288,17 +288,17 @@ this.cookies = class extends ExtensionAP
         getAll: function(details) {
           let allowed = ["url", "name", "domain", "path", "secure", "session", "storeId"];
           let result = Array.from(query(details, allowed, context), convertCookie);
 
           return Promise.resolve(result);
         },
 
         set: function(details) {
-          let uri = NetUtil.newURI(details.url).QueryInterface(Ci.nsIURL);
+          let uri = Services.io.newURI(details.url).QueryInterface(Ci.nsIURL);
 
           let path;
           if (details.path !== null) {
             path = details.path;
           } else {
             // This interface essentially emulates the behavior of the
             // Set-Cookie header. In the case of an omitted path, the cookie
             // service uses the directory path of the requesting URL, ignoring
--- a/toolkit/components/extensions/webrequest/nsWebRequestListener.cpp
+++ b/toolkit/components/extensions/webrequest/nsWebRequestListener.cpp
@@ -27,31 +27,29 @@ nsWebRequestListener::Init(nsIStreamList
 }
 
 NS_IMETHODIMP
 nsWebRequestListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt)
 {
   MOZ_ASSERT(mTargetStreamListener, "Should have mTargetStreamListener");
   MOZ_ASSERT(mOrigStreamListener, "Should have mOrigStreamListener");
 
-  nsresult rv = mTargetStreamListener->OnStartRequest(request, aCtxt);
-  NS_ENSURE_SUCCESS(rv, rv);
+  mTargetStreamListener->OnStartRequest(request, aCtxt);
 
   return mOrigStreamListener->OnStartRequest(request, aCtxt);
 }
 
 NS_IMETHODIMP
 nsWebRequestListener::OnStopRequest(nsIRequest *request, nsISupports *aCtxt,
                                            nsresult aStatus)
 {
   MOZ_ASSERT(mOrigStreamListener, "Should have mOrigStreamListener");
   MOZ_ASSERT(mTargetStreamListener, "Should have mTargetStreamListener");
 
-  nsresult rv = mOrigStreamListener->OnStopRequest(request, aCtxt, aStatus);
-  NS_ENSURE_SUCCESS(rv, rv);
+  mOrigStreamListener->OnStopRequest(request, aCtxt, aStatus);
 
   return mTargetStreamListener->OnStopRequest(request, aCtxt, aStatus);
 }
 
 NS_IMETHODIMP
 nsWebRequestListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt,
                                              nsIInputStream * inStr,
                                              uint64_t sourceOffset, uint32_t count)
--- a/toolkit/components/extensions/webrequest/nsWebRequestListener.h
+++ b/toolkit/components/extensions/webrequest/nsWebRequestListener.h
@@ -6,31 +6,35 @@
 #define nsWebRequestListener_h__
 
 #include "nsCOMPtr.h"
 #include "nsIWebRequestListener.h"
 #include "nsIRequestObserver.h"
 #include "nsIStreamListener.h"
 #include "nsITraceableChannel.h"
 #include "nsIThreadRetargetableStreamListener.h"
+#include "nsProxyRelease.h"
 #include "mozilla/Attributes.h"
 
 class nsWebRequestListener final : public nsIWebRequestListener
                                  , public nsIStreamListener
                                  , public nsIThreadRetargetableStreamListener
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIWEBREQUESTLISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
 
   nsWebRequestListener() {}
 
 private:
-  ~nsWebRequestListener() {}
+  ~nsWebRequestListener() {
+    NS_ReleaseOnMainThreadSystemGroup("nsWebRequestListener::mTargetStreamListener",
+                                      mTargetStreamListener.forget());
+  }
   nsCOMPtr<nsIStreamListener> mOrigStreamListener;
   nsCOMPtr<nsIStreamListener> mTargetStreamListener;
 };
 
 #endif // nsWebRequestListener_h__
 
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -368,18 +368,16 @@ this.DownloadIntegration = {
    * @resolves The downloads directory string path.
    */
   async getTemporaryDownloadsDirectory() {
     let directoryPath = null;
 #ifdef XP_MACOSX
     directoryPath = await this.getPreferredDownloadsDirectory();
 #elifdef MOZ_WIDGET_ANDROID
     directoryPath = await this.getSystemDownloadsDirectory();
-#elifdef MOZ_WIDGET_GONK
-    directoryPath = await this.getSystemDownloadsDirectory();
 #else
     directoryPath = this._getDirectory("TmpD");
 #endif
     return directoryPath;
   },
 
   /**
    * Checks to determine whether to block downloads for parental controls.
--- a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp
+++ b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp
@@ -97,17 +97,17 @@ CFURLRef CreateCFURLFromNSIURI(nsIURI *a
   return url;
 }
 #endif
 
 nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIURI* aReferrer, nsIFile* aTarget,
                                         const nsACString& aContentType, bool aIsPrivate)
 {
 #if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) \
- || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GONK)
+ || defined(MOZ_WIDGET_GTK)
 
   nsAutoString path;
   if (aTarget && NS_SUCCEEDED(aTarget->GetPath(path))) {
 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_ANDROID)
     // On Windows and Gtk, add the download to the system's "recent documents"
     // list, with a pref to disable.
     {
       bool addToRecentDocs = Preferences::GetBool(PREF_BDM_ADDTORECENTDOCS);
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -236,32 +236,32 @@ NS_IMPL_ISUPPORTS(nsAppStartup,
 
 //
 // nsAppStartup->nsIAppStartup
 //
 
 NS_IMETHODIMP
 nsAppStartup::CreateHiddenWindow()
 {
-#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_UIKIT)
+#if defined(MOZ_WIDGET_UIKIT)
   return NS_OK;
 #else
   nsCOMPtr<nsIAppShellService> appShellService
     (do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
   NS_ENSURE_TRUE(appShellService, NS_ERROR_FAILURE);
 
   return appShellService->CreateHiddenWindow();
 #endif
 }
 
 
 NS_IMETHODIMP
 nsAppStartup::DestroyHiddenWindow()
 {
-#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_UIKIT)
+#if defined(MOZ_WIDGET_UIKIT)
   return NS_OK;
 #else
   nsCOMPtr<nsIAppShellService> appShellService
     (do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
   NS_ENSURE_TRUE(appShellService, NS_ERROR_FAILURE);
 
   return appShellService->DestroyHiddenWindow();
 #endif
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -6790,24 +6790,16 @@
     "description": "The input method the user used to select a result in the searchbar. 'enter' => The user hit the Enter key without choosing a result in the popup. 'enterSelection' => The user chose a result and then hit the Enter key. 'click' => The user clicked a result with the mouse."
   },
   "INNERWINDOWS_WITH_MUTATION_LISTENERS": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "Deleted or to-be-reused innerwindow which has had mutation event listeners."
   },
-  "FORM_ISINDEX_USED": {
-    "record_in_processes": ["main", "content"],
-    "alert_emails": ["hsivonen@mozilla.com"],
-    "expires_in_version": "56",
-    "kind": "flag",
-    "bug_numbers": [1356181],
-    "description": "Whether there has been an isindex form submission in this session."
-  },
   "CHARSET_OVERRIDE_SITUATION": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 8,
     "description": "Labeling status of top-level page when overriding charset (0: unlabeled file URL without detection, 1: unlabeled non-TLD-guessed non-file URL without detection, 2: unlabeled file URL with detection, 3: unlabeled non-file URL with detection, 4: labeled, 5: already overridden, 6: bug, 7: unlabeled with TLD guessing)"
   },
   "CHARSET_OVERRIDE_USED": {
--- a/toolkit/components/telemetry/histogram-whitelists.json
+++ b/toolkit/components/telemetry/histogram-whitelists.json
@@ -1910,17 +1910,16 @@
     "FX_BROWSER_FULLSCREEN_USED",
     "FX_CONTENT_CRASH_DUMP_UNAVAILABLE",
     "FX_CONTENT_CRASH_NOT_SUBMITTED",
     "FX_CONTENT_CRASH_PRESENTED",
     "FX_SESSION_RESTORE_SEND_UPDATE_CAUSED_OOM",
     "FX_TOUCH_USED",
     "GEOLOCATION_ERROR",
     "JS_TELEMETRY_ADDON_EXCEPTIONS",
-    "FORM_ISINDEX_USED",
     "MASTER_PASSWORD_ENABLED",
     "MEDIA_CODEC_USED",
     "MEDIA_DECODING_PROCESS_CRASH",
     "NETWORK_CONNECTION_COUNT",
     "NUMBER_OF_PROFILES",
     "ONBEFOREUNLOAD_PROMPT_COUNT",
     "OPENGL_COMPOSITING_FAILURE_ID",
     "PERMISSIONS_SQL_CORRUPTED",
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -485,23 +485,16 @@ nsWindowWatcher::CreateChromeWindow(cons
                                     uint64_t aNextTabParentId,
                                     nsIWebBrowserChrome** aResult)
 {
   nsCOMPtr<nsIWindowCreator2> windowCreator2(do_QueryInterface(mWindowCreator));
   if (NS_WARN_IF(!windowCreator2)) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  // B2G multi-screen support. mozDisplayId is returned from the
-  // "display-changed" event, it is also platform-dependent.
-#ifdef MOZ_WIDGET_GONK
-  int retval = WinHasOption(aFeatures, "mozDisplayId", 0, nullptr);
-  windowCreator2->SetScreenId(retval);
-#endif
-
   bool cancel = false;
   nsCOMPtr<nsIWebBrowserChrome> newWindowChrome;
   nsresult rv =
     windowCreator2->CreateChromeWindow2(aParentChrome, aChromeFlags,
                                         aOpeningTabParent, aOpener,
                                         aNextTabParentId, &cancel,
                                         getter_AddRefs(newWindowChrome));
 
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -1596,36 +1596,31 @@ LocateExecutable(nsIFile* aXREDirectory,
 #endif // !defined(MOZ_WIDGET_ANDROID)
 
 nsresult SetExceptionHandler(nsIFile* aXREDirectory,
                              bool force/*=false*/)
 {
   if (gExceptionHandler)
     return NS_ERROR_ALREADY_INITIALIZED;
 
-#if !defined(DEBUG) || defined(MOZ_WIDGET_GONK)
+#if !defined(DEBUG)
   // In non-debug builds, enable the crash reporter by default, and allow
   // disabling it with the MOZ_CRASHREPORTER_DISABLE environment variable.
-  // Also enable it by default in debug gonk builds as it is difficult to
-  // set environment on startup.
   const char *envvar = PR_GetEnv("MOZ_CRASHREPORTER_DISABLE");
   if (envvar && *envvar && !force)
     return NS_OK;
 #else
   // In debug builds, disable the crash reporter by default, and allow to
   // enable it with the MOZ_CRASHREPORTER environment variable.
   const char *envvar = PR_GetEnv("MOZ_CRASHREPORTER");
   if ((!envvar || !*envvar) && !force)
     return NS_OK;
 #endif
 
-#if defined(MOZ_WIDGET_GONK)
-  doReport = false;
-  headlessClient = true;
-#elif defined(XP_WIN)
+#if defined(XP_WIN)
   doReport = ShouldReport();
 #else
   // this environment variable prevents us from launching
   // the crash reporter client
   doReport = ShouldReport();
 #endif
 
   // allocate our strings
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -151,18 +151,16 @@ this.AppConstants = Object.freeze({
 #ifdef MOZ_WIDGET_GTK
   "linux",
 #elif XP_WIN
   "win",
 #elif XP_MACOSX
   "macosx",
 #elif MOZ_WIDGET_ANDROID
   "android",
-#elif MOZ_WIDGET_GONK
-  "gonk",
 #elif XP_LINUX
   "linux",
 #else
   "other",
 #endif
 
   isPlatformAndVersionAtLeast(platform, version) {
     let platformVersion = Services.sysinfo.getProperty("version");
--- a/toolkit/profile/nsProfileLock.cpp
+++ b/toolkit/profile/nsProfileLock.cpp
@@ -25,20 +25,16 @@
 #include <signal.h>
 #include <stdlib.h>
 #include "prnetdb.h"
 #include "prsystem.h"
 #include "prenv.h"
 #include "mozilla/Printf.h"
 #endif
 
-#if defined(MOZ_WIDGET_GONK) && !defined(MOZ_CRASHREPORTER)
-#include <sys/syscall.h>
-#endif
-
 // **********************************************************************
 // class nsProfileLock
 //
 // This code was moved from profile/src/nsProfileAccess.
 // **********************************************************************
 
 #if defined (XP_UNIX)
 static bool sDisableSignalHandling = false;
@@ -187,37 +183,16 @@ void nsProfileLock::FatalSignalHandler(i
         }
 #endif
         else if (oldact->sa_handler && oldact->sa_handler != SIG_IGN)
         {
             oldact->sa_handler(signo);
         }
     }
 
-#ifdef MOZ_WIDGET_GONK
-    switch (signo) {
-        case SIGQUIT:
-        case SIGILL:
-        case SIGABRT:
-        case SIGSEGV:
-#ifndef MOZ_CRASHREPORTER
-            // Retrigger the signal for those that can generate a core dump
-            signal(signo, SIG_DFL);
-            if (info->si_code <= 0) {
-                if (syscall(__NR_tgkill, getpid(), syscall(__NR_gettid), signo) < 0) {
-                    break;
-                }
-            }
-#endif
-            return;
-        default:
-            break;
-    }
-#endif
-
     // Backstop exit call, just in case.
     _exit(signo);
 }
 
 nsresult nsProfileLock::LockWithFcntl(nsIFile *aLockFile)
 {
     nsresult rv = NS_OK;
 
--- a/toolkit/xre/EventTracer.cpp
+++ b/toolkit/xre/EventTracer.cpp
@@ -61,60 +61,31 @@
 #include "nsDebug.h"
 #include <limits.h>
 #include <prenv.h>
 #include <prinrval.h>
 #include <prthread.h>
 #include <prtime.h>
 
 #include "nsThreadUtils.h"
-#ifdef MOZ_WIDGET_GONK
-#include "nsIObserverService.h"
-#include "mozilla/Services.h"
-#endif
 
 using mozilla::TimeDuration;
 using mozilla::TimeStamp;
 using mozilla::FireAndWaitForTracerEvent;
 
 namespace {
 
 PRThread* sTracerThread = nullptr;
 bool sExit = false;
 
 struct TracerStartClosure {
   bool mLogTracing;
   int32_t mThresholdInterval;
 };
 
-#ifdef MOZ_WIDGET_GONK
-class EventLoopLagDispatcher : public Runnable
-{
-  public:
-    explicit EventLoopLagDispatcher(int aLag)
-      : mLag(aLag) {}
-
-    NS_IMETHOD Run() override
-    {
-      nsCOMPtr<nsIObserverService> obsService =
-        mozilla::services::GetObserverService();
-      if (!obsService) {
-        return NS_ERROR_FAILURE;
-      }
-
-      nsAutoString value;
-      value.AppendInt(mLag);
-      return obsService->NotifyObservers(nullptr, "event-loop-lag", value.get());
-    }
-
-  private:
-    int mLag;
-};
-#endif
-
 /*
  * The tracer thread fires events at the native event loop roughly
  * every kMeasureInterval. It will sleep to attempt not to send them
  * more quickly, but if the response time is longer than kMeasureInterval
  * it will not send another event until the previous response is received.
  *
  * The output defaults to stdout, but can be redirected to a file by
  * settting the environment variable MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT
@@ -175,20 +146,16 @@ void TracerThread(void *arg)
     if (FireAndWaitForTracerEvent()) {
       TimeDuration duration = TimeStamp::Now() - start;
       // Only report samples that exceed our measurement threshold.
       long long now = PR_Now() / PR_USEC_PER_MSEC;
       if (threadArgs->mLogTracing && duration.ToMilliseconds() > threshold) {
         fprintf(log, "MOZ_EVENT_TRACE sample %llu %lf\n",
                 now,
                 duration.ToMilliseconds());
-#ifdef MOZ_WIDGET_GONK
-        NS_DispatchToMainThread(
-         new EventLoopLagDispatcher(int(duration.ToSecondsSigDigits() * 1000)));
-#endif
       }
 
       if (next_sleep > duration.ToMilliseconds()) {
         next_sleep -= int(duration.ToMilliseconds());
       }
       else {
         // Don't sleep at all if this event took longer than the measure
         // interval to deliver.
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4013,17 +4013,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
 #endif
 
   // Support exiting early for testing startup sequence. Bug 1360493
   if (CheckArg("test-launch-without-hang")) {
     *aExitFlag = true;
     return 0;
   }
 
-#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID)
   // Check for and process any available updates
   nsCOMPtr<nsIFile> updRoot;
   bool persistent;
   rv = mDirProvider.GetFile(XRE_UPDATE_ROOT_DIR, &persistent,
                             getter_AddRefs(updRoot));
   // XRE_UPDATE_ROOT_DIR may fail. Fallback to appDir if failed
   if (NS_FAILED(rv))
     updRoot = mDirProvider.GetAppDir();
@@ -4206,17 +4206,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
   if (flagFile) {
     flagFile->Remove(true);
   }
 
   return 0;
 }
 
 #if defined(MOZ_CRASHREPORTER)
-#if defined(MOZ_CONTENT_SANDBOX) && !defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_CONTENT_SANDBOX)
 void AddSandboxAnnotations()
 {
   // Include the sandbox content level, regardless of platform
   int level = GetEffectiveContentSandboxLevel();
 
   nsAutoCString levelString;
   levelString.AppendInt(level);
 
@@ -4235,17 +4235,17 @@ void AddSandboxAnnotations()
 #elif defined(XP_LINUX)
   sandboxCapable = SandboxInfo::Get().CanSandboxContent();
 #endif
 
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("ContentSandboxCapable"),
     sandboxCapable ? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
 }
-#endif /* MOZ_CONTENT_SANDBOX && !MOZ_WIDGET_GONK */
+#endif /* MOZ_CONTENT_SANDBOX */
 #endif /* MOZ_CRASHREPORTER */
 
 /*
  * XRE_mainRun - Command line startup, profile migration, and
  * the calling of appStartup->Run().
  */
 nsresult
 XREMain::XRE_mainRun()
@@ -4556,17 +4556,17 @@ XREMain::XRE_mainRun()
 
 #ifdef MOZ_INSTRUMENT_EVENT_LOOP
   if (PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP")) {
     bool logToConsole = true;
     mozilla::InitEventTracing(logToConsole);
   }
 #endif /* MOZ_INSTRUMENT_EVENT_LOOP */
 
-#if defined(MOZ_SANDBOX) && defined(XP_LINUX) && !defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_SANDBOX) && defined(XP_LINUX)
   // If we're on Linux, we now have information about the OS capabilities
   // available to us.
   SandboxInfo sandboxInfo = SandboxInfo::Get();
   Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_BPF,
                         sandboxInfo.Test(SandboxInfo::kHasSeccompBPF));
   Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_TSYNC,
                         sandboxInfo.Test(SandboxInfo::kHasSeccompTSync));
   Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES_PRIVILEGED,
@@ -4579,22 +4579,22 @@ XREMain::XRE_mainRun()
                         sandboxInfo.Test(SandboxInfo::kEnabledForMedia));
 #if defined(MOZ_CRASHREPORTER)
   nsAutoCString flagsString;
   flagsString.AppendInt(sandboxInfo.AsInteger());
 
   CrashReporter::AnnotateCrashReport(
     NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
 #endif /* MOZ_CRASHREPORTER */
-#endif /* MOZ_SANDBOX && XP_LINUX && !MOZ_WIDGET_GONK */
+#endif /* MOZ_SANDBOX && XP_LINUX */
 
 #if defined(MOZ_CRASHREPORTER)
-#if defined(MOZ_CONTENT_SANDBOX) && !defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_CONTENT_SANDBOX)
   AddSandboxAnnotations();
-#endif /* MOZ_CONTENT_SANDBOX && !MOZ_WIDGET_GONK */
+#endif /* MOZ_CONTENT_SANDBOX */
 #endif /* MOZ_CRASHREPORTER */
 
   {
     rv = appStartup->Run();
     if (NS_FAILED(rv)) {
       NS_ERROR("failed to run appstartup");
       gLogConsoleErrors = true;
     }
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -84,20 +84,18 @@
 
 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
 #include "mozilla/sandboxTarget.h"
 #include "mozilla/sandboxing/loggingCallbacks.h"
 #endif
 
 #if defined(MOZ_CONTENT_SANDBOX)
 #include "mozilla/SandboxSettings.h"
-#if !defined(MOZ_WIDGET_GONK)
 #include "mozilla/Preferences.h"
 #endif
-#endif
 
 #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
 #include "mozilla/Sandbox.h"
 #include "mozilla/SandboxInfo.h"
 #endif
 
 #if defined(XP_LINUX)
 #include <sys/prctl.h>
@@ -304,29 +302,29 @@ SetTaskbarGroupId(const nsString& aId)
 {
     if (FAILED(SetCurrentProcessExplicitAppUserModelID(aId.get()))) {
         NS_WARNING("SetCurrentProcessExplicitAppUserModelID failed for child process.");
     }
 }
 #endif
 
 #if defined(MOZ_CRASHREPORTER)
-#if defined(MOZ_CONTENT_SANDBOX) && !defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_CONTENT_SANDBOX)
 void
 AddContentSandboxLevelAnnotation()
 {
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     int level = GetEffectiveContentSandboxLevel();
     nsAutoCString levelString;
     levelString.AppendInt(level);
     CrashReporter::AnnotateCrashReport(
       NS_LITERAL_CSTRING("ContentSandboxLevel"), levelString);
   }
 }
-#endif /* MOZ_CONTENT_SANDBOX && !MOZ_WIDGET_GONK */
+#endif /* MOZ_CONTENT_SANDBOX */
 #endif /* MOZ_CRASHREPORTER */
 
 namespace {
 
 int GetDebugChildPauseTime() {
   auto pauseStr = PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE");
   if (pauseStr && *pauseStr) {
     int pause = atoi(pauseStr);
@@ -697,17 +695,17 @@ XRE_InitChildProcess(int aArgc,
       // We need to do this after the process has been initialised, as
       // InitLoggingIfRequired may need access to prefs.
       mozilla::sandboxing::InitLoggingIfRequired(aChildData->ProvideLogFunction);
 #endif
 
       OverrideDefaultLocaleIfNeeded();
 
 #if defined(MOZ_CRASHREPORTER)
-#if defined(MOZ_CONTENT_SANDBOX) && !defined(MOZ_WIDGET_GONK)
+#if defined(MOZ_CONTENT_SANDBOX)
       AddContentSandboxLevelAnnotation();
 #endif
 #endif
 
       // Run the UI event loop on the main thread.
       uiMessageLoop.MessageLoop::Run();
 
       // Allow ProcessChild to clean up after itself before going out of
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -1244,24 +1244,16 @@ GetCachedHash(HKEY rootKey, const nsAStr
 }
 
 #endif
 
 nsresult
 nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
 {
   nsCOMPtr<nsIFile> updRoot;
-#if defined(MOZ_WIDGET_GONK)
-
-  nsresult rv = NS_NewNativeLocalFile(nsDependentCString("/data/local"),
-                                      true,
-                                      getter_AddRefs(updRoot));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-#else
   nsCOMPtr<nsIFile> appFile;
   bool per = false;
   nsresult rv = GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(appFile));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = appFile->GetParent(getter_AddRefs(updRoot));
   NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef XP_MACOSX
@@ -1397,17 +1389,16 @@ nsXREDirProvider::GetUpdateRootDir(nsIFi
 
   rv = GetUserLocalDataDirectory(getter_AddRefs(updRoot));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = updRoot->AppendRelativePath(programName);
   NS_ENSURE_SUCCESS(rv, rv);
 
 #endif // XP_WIN
-#endif
   updRoot.forget(aResult);
   return NS_OK;
 }
 
 nsresult
 nsXREDirProvider::GetProfileStartupDir(nsIFile* *aResult)
 {
   if (mProfileDir)
@@ -1501,19 +1492,16 @@ nsXREDirProvider::GetUserDataDirectoryHo
     if (NS_FAILED(rv)) {
       if (!aLocal)
         rv = GetRegWindowsAppDataFolder(aLocal, path);
     }
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = NS_NewLocalFile(path, true, getter_AddRefs(localDir));
-#elif defined(MOZ_WIDGET_GONK)
-  rv = NS_NewNativeLocalFile(NS_LITERAL_CSTRING("/data/b2g"), true,
-                             getter_AddRefs(localDir));
 #elif defined(XP_UNIX)
   const char* homeDir = getenv("HOME");
   if (!homeDir || !*homeDir)
     return NS_ERROR_FAILURE;
 
 #ifdef ANDROID /* We want (ProfD == ProfLD) on Android. */
   aLocal = false;
 #endif