[tor-commits] [tor-messenger-build/master] Remove all unnecessary mozpatches and switch to tb

arlo at torproject.org arlo at torproject.org
Mon Oct 10 19:41:22 UTC 2016


commit bad6b5ab6859c8f06ea5421e790865b9cda2fdbf
Author: Arlo Breault <arlolra at gmail.com>
Date:   Thu Oct 6 20:22:28 2016 -0700

    Remove all unnecessary mozpatches and switch to tb
---
 ...d-mozilla-ViewRegion-which-assembles-a.mozpatch |  192 --
 ...e-ViewRegion-for-vibrant-areas-in-Vibr.mozpatch |  180 --
 ...e-ViewRegion-for-window-dragging.-r-sp.mozpatch |  199 --
 ...ault-Firefox-profile-director-bug-9173.mozpatch |  451 ----
 .../Firefox-update-process-bug-4234.mozpatch       | 2156 --------------------
 ...Improve-profile-access-bug-14631-first.mozpatch |  246 ---
 ...mprove-profile-access-bug-14631-second.mozpatch |  182 --
 .../Mac-outside-app-data-bug-13252.mozpatch        | 1124 ----------
 .../instantbird/Sign-MAR-files-bug-13379.mozpatch  |  616 ------
 ...ate-load-local-changes-bug-14392-first.mozpatch |   18 -
 ...te-load-local-changes-bug-16940-second.mozpatch |  368 ----
 .../Updater-Linux-search-path-bug-18900.mozpatch   |   42 -
 projects/instantbird/bug-1167248.mozpatch          |   22 -
 projects/instantbird/bug-1240589.mozpatch          |   22 -
 projects/instantbird/config                        |   20 +-
 projects/instantbird/trac-16475.mozpatch           |   73 +-
 projects/instantbird/trac-18290.mozpatch           |   47 -
 projects/instantbird/trac-20206.mozpatch           |   73 -
 projects/instantbird/trac-20309.mozpatch           |   25 +
 projects/mozilla/config                            |    2 +-
 20 files changed, 53 insertions(+), 6005 deletions(-)

diff --git a/projects/instantbird/0001-Bug-1070710-Add-mozilla-ViewRegion-which-assembles-a.mozpatch b/projects/instantbird/0001-Bug-1070710-Add-mozilla-ViewRegion-which-assembles-a.mozpatch
deleted file mode 100644
index c5280e8..0000000
--- a/projects/instantbird/0001-Bug-1070710-Add-mozilla-ViewRegion-which-assembles-a.mozpatch
+++ /dev/null
@@ -1,192 +0,0 @@
-From 20344dc64a7177eb6d894df3ee6a77419c67284b Mon Sep 17 00:00:00 2001
-From: Markus Stange <mstange at themasta.com>
-Date: Sat, 16 Jul 2016 17:07:45 -0400
-Subject: [PATCH 1/3] Bug 1070710 - Add mozilla::ViewRegion which assembles a
- LayoutDeviceIntRegion as NSViews. r=spohl
-
-MozReview-Commit-ID: RrVzLcv27T
-
---HG--
-extra : amend_source : d14dc262bf300a81feaf03954d5783ea1c7451cb
-extra : histedit_source : aa39b53c122a719a5181b5a41d5351bbdf04cbd8
----
- widget/cocoa/ViewRegion.h     | 53 ++++++++++++++++++++++++++++++++
- widget/cocoa/ViewRegion.mm    | 70 +++++++++++++++++++++++++++++++++++++++++++
- widget/cocoa/moz.build        |  1 +
- widget/cocoa/nsScreenCocoa.mm |  4 +--
- 4 files changed, 126 insertions(+), 2 deletions(-)
- create mode 100644 widget/cocoa/ViewRegion.h
- create mode 100644 widget/cocoa/ViewRegion.mm
-
-diff --git a/widget/cocoa/ViewRegion.h b/widget/cocoa/ViewRegion.h
-new file mode 100644
-index 0000000..a8efcca
---- /dev/null
-+++ b/widget/cocoa/ViewRegion.h
-@@ -0,0 +1,53 @@
-+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-+/* This Source Code Form is subject to the terms of the Mozilla Public
-+ * License, v. 2.0. If a copy of the MPL was not distributed with this
-+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-+
-+#ifndef ViewRegion_h
-+#define ViewRegion_h
-+
-+#include "Units.h"
-+#include "nsTArray.h"
-+
-+ at class NSView;
-+
-+namespace mozilla {
-+
-+/**
-+ * Manages a set of NSViews to cover a LayoutDeviceIntRegion.
-+ */
-+class ViewRegion {
-+public:
-+  ~ViewRegion();
-+
-+  mozilla::LayoutDeviceIntRegion Region() { return mRegion; }
-+
-+  /**
-+   * Update the region.
-+   * @param aRegion  The new region.
-+   * @param aCoordinateConverter  The nsChildView to use for converting
-+   *   LayoutDeviceIntRect device pixel coordinates into Cocoa NSRect coordinates.
-+   * @param aContainerView  The view that's going to be the superview of the
-+   *   NSViews which will be created for this region.
-+   * @param aViewCreationCallback  A block that instantiates new NSViews.
-+   * @return  Whether or not the region changed.
-+   */
-+  bool UpdateRegion(const mozilla::LayoutDeviceIntRegion& aRegion,
-+                    const nsChildView& aCoordinateConverter,
-+                    NSView* aContainerView,
-+                    NSView* (^aViewCreationCallback)());
-+
-+  /**
-+   * Return an NSView from the region, if there is any.
-+   */
-+  NSView* GetAnyView() { return mViews.Length() > 0 ? mViews[0] : nil; }
-+
-+private:
-+  mozilla::LayoutDeviceIntRegion mRegion;
-+  nsTArray<NSView*> mViews;
-+};
-+
-+} // namespace mozilla
-+
-+#endif // ViewRegion_h
-diff --git a/widget/cocoa/ViewRegion.mm b/widget/cocoa/ViewRegion.mm
-new file mode 100644
-index 0000000..3459849
---- /dev/null
-+++ b/widget/cocoa/ViewRegion.mm
-@@ -0,0 +1,70 @@
-+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-+/* This Source Code Form is subject to the terms of the Mozilla Public
-+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
-+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
-+
-+#include "ViewRegion.h"
-+#import <Cocoa/Cocoa.h>
-+
-+using namespace mozilla;
-+
-+ViewRegion::~ViewRegion()
-+{
-+  for (size_t i = 0; i < mViews.Length(); i++) {
-+    [mViews[i] removeFromSuperview];
-+  }
-+}
-+
-+bool
-+ViewRegion::UpdateRegion(const LayoutDeviceIntRegion& aRegion,
-+                         const nsChildView& aCoordinateConverter,
-+                         NSView* aContainerView,
-+                         NSView* (^aViewCreationCallback)())
-+{
-+  if (mRegion == aRegion) {
-+    return false;
-+  }
-+
-+  // We need to construct the required region using as many EffectViews
-+  // as necessary. We try to update the geometry of existing views if
-+  // possible, or create new ones or remove old ones if the number of
-+  // rects in the region has changed.
-+
-+  nsTArray<NSView*> viewsToRecycle;
-+  mViews.SwapElements(viewsToRecycle);
-+  // The mViews array is now empty.
-+
-+  LayoutDeviceIntRegion::RectIterator iter(aRegion);
-+  const LayoutDeviceIntRect* iterRect = nullptr;
-+  for (size_t i = 0; (iterRect = iter.Next()) || i < viewsToRecycle.Length(); ++i) {
-+    if (iterRect) {
-+      NSView* view = nil;
-+      NSRect rect = aCoordinateConverter.DevPixelsToCocoaPoints(*iterRect);
-+      if (i < viewsToRecycle.Length()) {
-+        view = viewsToRecycle[i];
-+      } else {
-+        view = aViewCreationCallback();
-+        [aContainerView addSubview:view];
-+
-+        // Now that the view is in the view hierarchy, it'll be kept alive by
-+        // its superview, so we can drop our reference.
-+        [view release];
-+      }
-+      if (!NSEqualRects(rect, [view frame])) {
-+        [view setFrame:rect];
-+      }
-+      [view setNeedsDisplay:YES];
-+      mViews.AppendElement(view);
-+      iter.Next();
-+    } else {
-+      // Our new region is made of fewer rects than the old region, so we can
-+      // remove this view. We only have a weak reference to it, so removing it
-+      // from the view hierarchy will release it.
-+      [viewsToRecycle[i] removeFromSuperview];
-+    }
-+  }
-+
-+  mRegion = aRegion;
-+  return true;
-+}
-diff --git a/widget/cocoa/moz.build b/widget/cocoa/moz.build
-index aa8bfac..21b9369 100644
---- a/widget/cocoa/moz.build
-+++ b/widget/cocoa/moz.build
-@@ -58,6 +58,7 @@ UNIFIED_SOURCES += [
-     'SwipeTracker.mm',
-     'TextInputHandler.mm',
-     'VibrancyManager.mm',
-+    'ViewRegion.mm',
-     'WidgetTraceEvent.mm',
- ]
- 
-diff --git a/widget/cocoa/nsScreenCocoa.mm b/widget/cocoa/nsScreenCocoa.mm
-index 1b72bbf..bd3eef3 100644
---- a/widget/cocoa/nsScreenCocoa.mm
-+++ b/widget/cocoa/nsScreenCocoa.mm
-@@ -44,7 +44,7 @@ nsScreenCocoa::GetRect(int32_t *outX, int32_t *outY, int32_t *outWidth, int32_t
- {
-   NSRect frame = [mScreen frame];
- 
--  LayoutDeviceIntRect r =
-+  mozilla::LayoutDeviceIntRect r =
-     nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
- 
-   *outX = r.x;
-@@ -60,7 +60,7 @@ nsScreenCocoa::GetAvailRect(int32_t *outX, int32_t *outY, int32_t *outWidth, int
- {
-   NSRect frame = [mScreen visibleFrame];
- 
--  LayoutDeviceIntRect r =
-+  mozilla::LayoutDeviceIntRect r =
-     nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
- 
-   *outX = r.x;
--- 
-2.10.0
-
diff --git a/projects/instantbird/0002-Bug-1070710-Use-ViewRegion-for-vibrant-areas-in-Vibr.mozpatch b/projects/instantbird/0002-Bug-1070710-Use-ViewRegion-for-vibrant-areas-in-Vibr.mozpatch
deleted file mode 100644
index c54ae43..0000000
--- a/projects/instantbird/0002-Bug-1070710-Use-ViewRegion-for-vibrant-areas-in-Vibr.mozpatch
+++ /dev/null
@@ -1,180 +0,0 @@
-From 6222ca8ecd339b8fa7ffb1987558ee23970bf071 Mon Sep 17 00:00:00 2001
-From: Markus Stange <mstange at themasta.com>
-Date: Mon, 11 Jul 2016 14:47:05 -0400
-Subject: [PATCH 2/3] Bug 1070710 - Use ViewRegion for vibrant areas in
- VibrancyManager. r=spohl
-
-MozReview-Commit-ID: 5qVo59SV7QG
-
---HG--
-extra : histedit_source : 12980052172b2a858a52978fdd98dea28a9ea854
----
- widget/cocoa/VibrancyManager.h  | 14 +++------
- widget/cocoa/VibrancyManager.mm | 70 +++++++++--------------------------------
- 2 files changed, 18 insertions(+), 66 deletions(-)
-
-diff --git a/widget/cocoa/VibrancyManager.h b/widget/cocoa/VibrancyManager.h
-index 464a106..737fdc2 100644
---- a/widget/cocoa/VibrancyManager.h
-+++ b/widget/cocoa/VibrancyManager.h
-@@ -11,6 +11,7 @@
- #include "nsClassHashtable.h"
- #include "nsRegion.h"
- #include "nsTArray.h"
-+#include "ViewRegion.h"
- 
- #import <Foundation/NSGeometry.h>
- 
-@@ -100,20 +101,13 @@ public:
-    */
-   static bool SystemSupportsVibrancy();
- 
--  // The following are only public because otherwise ClearVibrantRegionFunc
--  // can't see them.
--  struct VibrantRegion {
--    LayoutDeviceIntRegion region;
--    nsTArray<NSView*> effectViews;
--  };
--  void ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const;
--
- protected:
--  NSView* CreateEffectView(VibrancyType aType, NSRect aRect);
-+  void ClearVibrantRegion(const LayoutDeviceIntRegion& aVibrantRegion) const;
-+  NSView* CreateEffectView(VibrancyType aType);
- 
-   const nsChildView& mCoordinateConverter;
-   NSView* mContainerView;
--  nsClassHashtable<nsUint32HashKey, VibrantRegion> mVibrantRegions;
-+  nsClassHashtable<nsUint32HashKey, ViewRegion> mVibrantRegions;
- };
- 
- } // namespace mozilla
-diff --git a/widget/cocoa/VibrancyManager.mm b/widget/cocoa/VibrancyManager.mm
-index 26f9670..f12cac6 100644
---- a/widget/cocoa/VibrancyManager.mm
-+++ b/widget/cocoa/VibrancyManager.mm
-@@ -15,63 +15,25 @@ VibrancyManager::UpdateVibrantRegion(VibrancyType aType,
-                                      const LayoutDeviceIntRegion& aRegion)
- {
-   auto& vr = *mVibrantRegions.LookupOrAdd(uint32_t(aType));
--  if (vr.region == aRegion) {
--    return;
--  }
--
--  // We need to construct the required region using as many EffectViews
--  // as necessary. We try to update the geometry of existing views if
--  // possible, or create new ones or remove old ones if the number of
--  // rects in the region has changed.
--
--  nsTArray<NSView*> viewsToRecycle;
--  vr.effectViews.SwapElements(viewsToRecycle);
--  // vr.effectViews is now empty.
--
--  LayoutDeviceIntRegion::RectIterator iter(aRegion);
--  const LayoutDeviceIntRect* iterRect = nullptr;
--  for (size_t i = 0; (iterRect = iter.Next()) || i < viewsToRecycle.Length(); ++i) {
--    if (iterRect) {
--      NSView* view = nil;
--      NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(*iterRect);
--      if (i < viewsToRecycle.Length()) {
--        view = viewsToRecycle[i];
--        [view setFrame:rect];
--        [view setNeedsDisplay:YES];
--      } else {
--        view = CreateEffectView(aType, rect);
--        [mContainerView addSubview:view];
--
--        // Now that the view is in the view hierarchy, it'll be kept alive by
--        // its superview, so we can drop our reference.
--        [view release];
--      }
--      vr.effectViews.AppendElement(view);
--    } else {
--      // Our new region is made of less rects than the old region, so we can
--      // remove this view. We only have a weak reference to it, so removing it
--      // from the view hierarchy will release it.
--      [viewsToRecycle[i] removeFromSuperview];
--    }
--  }
--
--  vr.region = aRegion;
-+  vr.UpdateRegion(aRegion, mCoordinateConverter, mContainerView, ^() {
-+    return this->CreateEffectView(aType);
-+  });
- }
- 
- void
- VibrancyManager::ClearVibrantAreas() const
- {
-   for (auto iter = mVibrantRegions.ConstIter(); !iter.Done(); iter.Next()) {
--    ClearVibrantRegion(*iter.UserData());
-+    ClearVibrantRegion(iter.UserData()->Region());
-   }
- }
- 
- void
--VibrancyManager::ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const
-+VibrancyManager::ClearVibrantRegion(const LayoutDeviceIntRegion& aVibrantRegion) const
- {
-   [[NSColor clearColor] set];
- 
--  LayoutDeviceIntRegion::RectIterator iter(aVibrantRegion.region);
-+  LayoutDeviceIntRegion::RectIterator iter(aVibrantRegion);
-   while (const LayoutDeviceIntRect* rect = iter.Next()) {
-     NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(*rect));
-   }
-@@ -97,15 +59,13 @@ AdjustedColor(NSColor* aFillColor, VibrancyType aType)
- NSColor*
- VibrancyManager::VibrancyFillColorForType(VibrancyType aType)
- {
--  const nsTArray<NSView*>& views =
--    mVibrantRegions.LookupOrAdd(uint32_t(aType))->effectViews;
-+  NSView* view = mVibrantRegions.LookupOrAdd(uint32_t(aType))->GetAnyView();
- 
--  if (!views.IsEmpty() &&
--      [views[0] respondsToSelector:@selector(_currentFillColor)]) {
-+  if (view && [view respondsToSelector:@selector(_currentFillColor)]) {
-     // -[NSVisualEffectView _currentFillColor] is the color that our view
-     // would draw during its drawRect implementation, if we hadn't
-     // disabled that.
--    return AdjustedColor([views[0] _currentFillColor], aType);
-+    return AdjustedColor([view _currentFillColor], aType);
-   }
-   return [NSColor whiteColor];
- }
-@@ -117,12 +77,10 @@ VibrancyManager::VibrancyFillColorForType(VibrancyType aType)
- NSColor*
- VibrancyManager::VibrancyFontSmoothingBackgroundColorForType(VibrancyType aType)
- {
--  const nsTArray<NSView*>& views =
--    mVibrantRegions.LookupOrAdd(uint32_t(aType))->effectViews;
-+  NSView* view = mVibrantRegions.LookupOrAdd(uint32_t(aType))->GetAnyView();
- 
--  if (!views.IsEmpty() &&
--      [views[0] respondsToSelector:@selector(fontSmoothingBackgroundColor)]) {
--    return [views[0] fontSmoothingBackgroundColor];
-+  if (view && [view respondsToSelector:@selector(fontSmoothingBackgroundColor)]) {
-+    return [view fontSmoothingBackgroundColor];
-   }
-   return [NSColor clearColor];
- }
-@@ -250,14 +208,14 @@ enum {
- @end
- 
- NSView*
--VibrancyManager::CreateEffectView(VibrancyType aType, NSRect aRect)
-+VibrancyManager::CreateEffectView(VibrancyType aType)
- {
-   static Class EffectViewClassWithoutForegroundVibrancy = CreateEffectViewClass(NO);
-   static Class EffectViewClassWithForegroundVibrancy = CreateEffectViewClass(YES);
- 
-   Class EffectViewClass = HasVibrantForeground(aType)
-     ? EffectViewClassWithForegroundVibrancy : EffectViewClassWithoutForegroundVibrancy;
--  NSView* effectView = [[EffectViewClass alloc] initWithFrame:aRect];
-+  NSView* effectView = [[EffectViewClass alloc] initWithFrame:NSZeroRect];
-   [effectView performSelector:@selector(setAppearance:)
-                    withObject:AppearanceForVibrancyType(aType)];
-   [effectView setState:VisualEffectStateForVibrancyType(aType)];
--- 
-2.10.0
-
diff --git a/projects/instantbird/0003-Bug-1070710-Use-ViewRegion-for-window-dragging.-r-sp.mozpatch b/projects/instantbird/0003-Bug-1070710-Use-ViewRegion-for-window-dragging.-r-sp.mozpatch
deleted file mode 100644
index 94a92fd..0000000
--- a/projects/instantbird/0003-Bug-1070710-Use-ViewRegion-for-window-dragging.-r-sp.mozpatch
+++ /dev/null
@@ -1,199 +0,0 @@
-From d378445257ad07190569b98bc1ad3ee93729cc38 Mon Sep 17 00:00:00 2001
-From: Markus Stange <mstange at themasta.com>
-Date: Mon, 11 Jul 2016 16:15:07 -0400
-Subject: [PATCH 3/3] Bug 1070710 - Use ViewRegion for window dragging. r=spohl
-
-MozReview-Commit-ID: 5x2XHl20P6a
-
---HG--
-extra : histedit_source : 56b671bffe9e6cd497ade61ff9beed2e3bf98e14
----
- widget/cocoa/nsChildView.h  |   5 +-
- widget/cocoa/nsChildView.mm | 117 ++++++++++++++------------------------------
- 2 files changed, 40 insertions(+), 82 deletions(-)
-
-diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h
-index 8f07c70..e7bd6b0 100644
---- a/widget/cocoa/nsChildView.h
-+++ b/widget/cocoa/nsChildView.h
-@@ -28,6 +28,7 @@
- 
- #include "nsString.h"
- #include "nsIDragService.h"
-+#include "ViewRegion.h"
- 
- #import <Carbon/Carbon.h>
- #import <Cocoa/Cocoa.h>
-@@ -493,7 +494,7 @@ public:
-   virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
- 
-   virtual void UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegion) override;
--  const LayoutDeviceIntRegion& GetDraggableRegion() { return mDraggableRegion; }
-+  LayoutDeviceIntRegion GetNonDraggableRegion() { return mNonDraggableRegion.Region(); }
- 
-   virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) override;
- 
-@@ -659,7 +660,7 @@ protected:
-   // uploaded to to mTitlebarImage. Main thread only.
-   nsIntRegion           mDirtyTitlebarRegion;
- 
--  LayoutDeviceIntRegion mDraggableRegion;
-+  mozilla::ViewRegion   mNonDraggableRegion;
- 
-   // Cached value of [mView backingScaleFactor], to avoid sending two obj-c
-   // messages (respondsToSelector, backingScaleFactor) every time we need to
-diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm
-index 8dbeacc..1415664 100644
---- a/widget/cocoa/nsChildView.mm
-+++ b/widget/cocoa/nsChildView.mm
-@@ -2720,12 +2720,41 @@ nsChildView::DoRemoteComposition(const LayoutDeviceIntRect& aRenderRect)
-   [(ChildView*)mView postRender:mGLPresenter->GetNSOpenGLContext()];
- }
- 
-+ at interface NonDraggableView : NSView
-+ at end
-+
-+ at implementation NonDraggableView
-+- (BOOL)mouseDownCanMoveWindow { return NO; }
-+- (NSView*)hitTest:(NSPoint)aPoint { return nil; }
-+ at end
-+
- void
- nsChildView::UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegion)
- {
--  if (mDraggableRegion != aRegion) {
--    mDraggableRegion = aRegion;
--    [(ChildView*)mView updateWindowDraggableState];
-+  // mView returns YES from mouseDownCanMoveWindow, so we need to put NSViews
-+  // that return NO from mouseDownCanMoveWindow in the places that shouldn't
-+  // be draggable. We can't do it the other way round because returning
-+  // YES from mouseDownCanMoveWindow doesn't have any effect if there's a
-+  // superview that returns NO.
-+  LayoutDeviceIntRegion nonDraggable;
-+  nonDraggable.Sub(LayoutDeviceIntRect(0, 0, mBounds.width, mBounds.height), aRegion);
-+
-+  __block bool changed = false;
-+
-+  // Suppress calls to setNeedsDisplay during NSView geometry changes.
-+  ManipulateViewWithoutNeedingDisplay(mView, ^() {
-+    changed = mNonDraggableRegion.UpdateRegion(nonDraggable, *this, mView, ^() {
-+      return [[NonDraggableView alloc] initWithFrame:NSZeroRect];
-+    });
-+  });
-+
-+  if (changed) {
-+    // Trigger an update to the window server. This will call
-+    // mouseDownCanMoveWindow.
-+    // Doing this manually is only necessary because we're suppressing
-+    // setNeedsDisplay calls above.
-+    [[mView window] setMovableByWindowBackground:NO];
-+    [[mView window] setMovableByWindowBackground:YES];
-   }
- }
- 
-@@ -3566,8 +3595,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
- 
- - (BOOL)mouseDownCanMoveWindow
- {
--  // Return YES so that _regionForOpaqueDescendants gets called, where the
--  // actual draggable region will be assembled.
-+  // Return YES so that parts of this view can be draggable. The non-draggable
-+  // parts will be covered by NSViews that return NO from
-+  // mouseDownCanMoveWindow and thus override draggability from the inside.
-+  // These views are assembled in nsChildView::UpdateWindowDraggingRegion.
-   return YES;
- }
- 
-@@ -4572,7 +4603,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
-   CGFloat locationInTitlebar = [[self window] frame].size.height - [theEvent locationInWindow].y;
-   LayoutDeviceIntPoint pos = geckoEvent.refPoint;
-   if (!defaultPrevented && [theEvent clickCount] == 2 &&
--      mGeckoChild->GetDraggableRegion().Contains(pos.x, pos.y) &&
-+      !mGeckoChild->GetNonDraggableRegion().Contains(pos.x, pos.y) &&
-       [[self window] isKindOfClass:[ToolbarWindow class]] &&
-       (locationInTitlebar < [(ToolbarWindow*)[self window] titlebarHeight] ||
-        locationInTitlebar < [(ToolbarWindow*)[self window] unifiedToolbarHeight])) {
-@@ -4607,80 +4638,6 @@ NSEvent* gLastDragMouseDownEvent = nil;
-   mGeckoChild->DispatchEvent(&event, status);
- }
- 
--- (void)updateWindowDraggableState
--{
--  // Trigger update to the window server.
--  [[self window] setMovableByWindowBackground:NO];
--  [[self window] setMovableByWindowBackground:YES];
--}
--
--// aRect is in view coordinates relative to this NSView.
--- (CGRect)convertToFlippedWindowCoordinates:(NSRect)aRect
--{
--  // First, convert the rect to regular window coordinates...
--  NSRect inWindowCoords = [self convertRect:aRect toView:nil];
--  // ... and then flip it again because window coordinates have their origin
--  // in the bottom left corner, and we need it to be in the top left corner.
--  inWindowCoords.origin.y = [[self window] frame].size.height - NSMaxY(inWindowCoords);
--  return NSRectToCGRect(inWindowCoords);
--}
--
--static CGSRegionObj
--NewCGSRegionFromRegion(const LayoutDeviceIntRegion& aRegion,
--                       CGRect (^aRectConverter)(const LayoutDeviceIntRect&))
--{
--  nsTArray<CGRect> rects;
--  LayoutDeviceIntRegion::RectIterator iter(aRegion);
--  for (;;) {
--    const LayoutDeviceIntRect* r = iter.Next();
--    if (!r) {
--      break;
--    }
--    rects.AppendElement(aRectConverter(*r));
--  }
--
--  CGSRegionObj region;
--  CGSNewRegionWithRectList(rects.Elements(), rects.Length(), &region);
--  return region;
--}
--
--// This function is called with forMove:YES to calculate the draggable region
--// of the window which will be submitted to the window server. Window dragging
--// is handled on the window server without calling back into our process, so it
--// also works while our app is unresponsive.
--- (CGSRegionObj)_regionForOpaqueDescendants:(NSRect)aRect forMove:(BOOL)aForMove
--{
--  if (!aForMove || !mGeckoChild) {
--    return [super _regionForOpaqueDescendants:aRect forMove:aForMove];
--  }
--
--  LayoutDeviceIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
--
--  LayoutDeviceIntRegion opaqueRegion;
--  opaqueRegion.Sub(boundingRect, mGeckoChild->GetDraggableRegion());
--
--  return NewCGSRegionFromRegion(opaqueRegion, ^(const LayoutDeviceIntRect& r) {
--    return [self convertToFlippedWindowCoordinates:mGeckoChild->DevPixelsToCocoaPoints(r)];
--  });
--}
--
--// Starting with 10.10, in addition to the traditional
--// -[NSView _regionForOpaqueDescendants:forMove:] method, there's a new form with
--// an additional forUnderTitlebar argument, which is sometimes called instead of
--// the old form. We need to override the new variant as well.
--- (CGSRegionObj)_regionForOpaqueDescendants:(NSRect)aRect
--                                    forMove:(BOOL)aForMove
--                           forUnderTitlebar:(BOOL)aForUnderTitlebar
--{
--  if (!aForMove || !mGeckoChild) {
--    return [super _regionForOpaqueDescendants:aRect
--                                      forMove:aForMove
--                             forUnderTitlebar:aForUnderTitlebar];
--  }
--
--  return [self _regionForOpaqueDescendants:aRect forMove:aForMove];
--}
--
- - (void)handleMouseMoved:(NSEvent*)theEvent
- {
-   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
--- 
-2.10.0
-
diff --git a/projects/instantbird/Change-the-default-Firefox-profile-director-bug-9173.mozpatch b/projects/instantbird/Change-the-default-Firefox-profile-director-bug-9173.mozpatch
deleted file mode 100644
index 4447c70..0000000
--- a/projects/instantbird/Change-the-default-Firefox-profile-director-bug-9173.mozpatch
+++ /dev/null
@@ -1,451 +0,0 @@
-From 48068e88b66ba37c725850331d099f10f9d34c90 Mon Sep 17 00:00:00 2001
-From: Kathy Brade <brade at pearlcrescent.com>
-Date: Fri, 18 Oct 2013 15:20:06 -0400
-Subject: Bug #9173: Change the default Firefox profile directory to be
- TBB-relative.
-
-This should eliminate our need to rely on a wrapper script that
-sets $HOME and launches Firefox with -profile.
-
-diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
-index a828d33..831a373 100644
---- a/toolkit/xre/nsXREDirProvider.cpp
-+++ b/toolkit/xre/nsXREDirProvider.cpp
-@@ -32,6 +32,7 @@
- #include "nsArrayEnumerator.h"
- #include "nsEnumeratorUtils.h"
- #include "nsReadableUtils.h"
-+#include "nsXPCOMPrivate.h"  // for XPCOM_FILE_PATH_SEPARATOR
- #include "mozilla/Services.h"
- #include "mozilla/Omnijar.h"
- #include "mozilla/Preferences.h"
-@@ -200,9 +201,6 @@ nsXREDirProvider::GetUserProfilesRootDir(nsIFile** aResult,
-                                      aProfileName, aAppName, aVendorName);
- 
-   if (NS_SUCCEEDED(rv)) {
--#if !defined(XP_UNIX) || defined(XP_MACOSX)
--    rv = file->AppendNative(NS_LITERAL_CSTRING("Profiles"));
--#endif
-     // We must create the profile directory here if it does not exist.
-     nsresult tmp = EnsureDirectoryExists(file);
-     if (NS_FAILED(tmp)) {
-@@ -225,9 +223,6 @@ nsXREDirProvider::GetUserProfilesLocalDir(nsIFile** aResult,
-                                      aProfileName, aAppName, aVendorName);
- 
-   if (NS_SUCCEEDED(rv)) {
--#if !defined(XP_UNIX) || defined(XP_MACOSX)
--    rv = file->AppendNative(NS_LITERAL_CSTRING("Profiles"));
--#endif
-     // We must create the profile directory here if it does not exist.
-     nsresult tmp = EnsureDirectoryExists(file);
-     if (NS_FAILED(tmp)) {
-@@ -1245,90 +1240,45 @@ nsresult
- nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
- {
-   // Copied from nsAppFileLocationProvider (more or less)
--  nsresult rv;
-+  NS_ENSURE_ARG_POINTER(aFile);
-   nsCOMPtr<nsIFile> localDir;
- 
--#if defined(XP_MACOSX)
--  FSRef fsRef;
--  OSType folderType;
--  if (aLocal) {
--    folderType = kCachedDataFolderType;
--  } else {
--#ifdef MOZ_THUNDERBIRD
--    folderType = kDomainLibraryFolderType;
--#else
--    folderType = kApplicationSupportFolderType;
--#endif
--  }
--  OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
--  NS_ENSURE_FALSE(err, NS_ERROR_FAILURE);
--
--  rv = NS_NewNativeLocalFile(EmptyCString(), true, getter_AddRefs(localDir));
-+  nsresult rv = GetAppDir()->Clone(getter_AddRefs(localDir));
-   NS_ENSURE_SUCCESS(rv, rv);
- 
--  nsCOMPtr<nsILocalFileMac> dirFileMac = do_QueryInterface(localDir);
--  NS_ENSURE_TRUE(dirFileMac, NS_ERROR_UNEXPECTED);
-+  int levelsToRemove = 0; // In FF21+, appDir points to browser subdirectory.
-+#if defined(XP_MACOSX)
-+  levelsToRemove += 1;
-+#endif
-+  while (localDir && (levelsToRemove > 0)) {
-+    // When crawling up the hierarchy, components named "." do not count.
-+    nsAutoCString removedName;
-+    rv = localDir->GetNativeLeafName(removedName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    bool didRemove = !removedName.Equals(".");
- 
--  rv = dirFileMac->InitWithFSRef(&fsRef);
--  NS_ENSURE_SUCCESS(rv, rv);
-+    // Remove a directory component.
-+    nsCOMPtr<nsIFile> parentDir;
-+    rv = localDir->GetParent(getter_AddRefs(parentDir));
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    localDir = parentDir;
- 
--  localDir = do_QueryInterface(dirFileMac, &rv);
--#elif defined(XP_IOS)
--  nsAutoCString userDir;
--  if (GetUIKitDirectory(aLocal, userDir)) {
--    rv = NS_NewNativeLocalFile(userDir, true, getter_AddRefs(localDir));
--  } else {
--    rv = NS_ERROR_FAILURE;
--  }
--  NS_ENSURE_SUCCESS(rv, rv);
--#elif defined(XP_WIN)
--  nsString path;
--  if (aLocal) {
--    rv = GetShellFolderPath(CSIDL_LOCAL_APPDATA, path);
--    if (NS_FAILED(rv))
--      rv = GetRegWindowsAppDataFolder(aLocal, path);
--  }
--  if (!aLocal || NS_FAILED(rv)) {
--    rv = GetShellFolderPath(CSIDL_APPDATA, path);
--    if (NS_FAILED(rv)) {
--      if (!aLocal)
--        rv = GetRegWindowsAppDataFolder(aLocal, path);
--    }
-+    if (didRemove)
-+      --levelsToRemove;
-   }
--  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)
-+  if (!localDir)
-     return NS_ERROR_FAILURE;
- 
--#ifdef ANDROID /* We want (ProfD == ProfLD) on Android. */
--  aLocal = false;
--#endif
-+  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("TorBrowser"
-+                                     XPCOM_FILE_PATH_SEPARATOR "Data"
-+                                     XPCOM_FILE_PATH_SEPARATOR "Browser"));
-+  NS_ENSURE_SUCCESS(rv, rv);
- 
-   if (aLocal) {
--    // If $XDG_CACHE_HOME is defined use it, otherwise use $HOME/.cache.
--    const char* cacheHome = getenv("XDG_CACHE_HOME");
--    if (cacheHome && *cacheHome) {
--      rv = NS_NewNativeLocalFile(nsDependentCString(cacheHome), true,
--                                 getter_AddRefs(localDir));
--    } else {
--      rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
--                                 getter_AddRefs(localDir));
--      if (NS_SUCCEEDED(rv))
--        rv = localDir->AppendNative(NS_LITERAL_CSTRING(".cache"));
--    }
--  } else {
--    rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true,
--                               getter_AddRefs(localDir));
-+    rv = localDir->AppendNative(NS_LITERAL_CSTRING("Caches"));
-+    NS_ENSURE_SUCCESS(rv, rv);
-   }
--#else
--#error "Don't know how to get product dir on your platform"
--#endif
- 
-   NS_IF_ADDREF(*aFile = localDir);
-   return rv;
-@@ -1541,48 +1491,25 @@ nsXREDirProvider::AppendProfilePath(nsIFile* aFile,
-   }
- 
-   nsAutoCString profile;
--  nsAutoCString appName;
--  nsAutoCString vendor;
-   if (aProfileName && !aProfileName->IsEmpty()) {
-     profile = *aProfileName;
--  } else if (aAppName) {
--    appName = *aAppName;
--    if (aVendorName) {
--      vendor = *aVendorName;
--    }
-   } else if (gAppData->profile) {
-     profile = gAppData->profile;
--  } else {
--    appName = gAppData->name;
--    vendor = gAppData->vendor;
-   }
- 
--  nsresult rv;
-+  nsresult rv = NS_ERROR_FAILURE;
- 
- #if defined (XP_MACOSX)
-   if (!profile.IsEmpty()) {
-     rv = AppendProfileString(aFile, profile.get());
-+    NS_ENSURE_SUCCESS(rv, rv);
-   }
--  else {
--    // Note that MacOS ignores the vendor when creating the profile hierarchy -
--    // all application preferences directories live alongside one another in
--    // ~/Library/Application Support/
--    rv = aFile->AppendNative(appName);
--  }
--  NS_ENSURE_SUCCESS(rv, rv);
- 
- #elif defined(XP_WIN)
-   if (!profile.IsEmpty()) {
-     rv = AppendProfileString(aFile, profile.get());
-+    NS_ENSURE_SUCCESS(rv, rv);
-   }
--  else {
--    if (!vendor.IsEmpty()) {
--      rv = aFile->AppendNative(vendor);
--      NS_ENSURE_SUCCESS(rv, rv);
--    }
--    rv = aFile->AppendNative(appName);
--  }
--  NS_ENSURE_SUCCESS(rv, rv);
- 
- #elif defined(ANDROID)
-   // The directory used for storing profiles
-@@ -1594,12 +1521,6 @@ nsXREDirProvider::AppendProfilePath(nsIFile* aFile,
-   rv = aFile->AppendNative(nsDependentCString("mozilla"));
-   NS_ENSURE_SUCCESS(rv, rv);
- #elif defined(XP_UNIX)
--  nsAutoCString folder;
--  // Make it hidden (by starting with "."), except when local (the
--  // profile is already under ~/.cache or XDG_CACHE_HOME).
--  if (!aLocal)
--    folder.Assign('.');
--
-   if (!profile.IsEmpty()) {
-     // Skip any leading path characters
-     const char* profileStart = profile.get();
-@@ -1608,31 +1529,17 @@ nsXREDirProvider::AppendProfilePath(nsIFile* aFile,
- 
-     // On the off chance that someone wanted their folder to be hidden don't
-     // let it become ".."
--    if (*profileStart == '.' && !aLocal)
-+    if (*profileStart == '.')
-       profileStart++;
- 
-+    // Make it hidden (by starting with ".").
-+    nsAutoCString folder(".");
-     folder.Append(profileStart);
-     ToLowerCase(folder);
- 
-     rv = AppendProfileString(aFile, folder.BeginReading());
-+    NS_ENSURE_SUCCESS(rv, rv);
-   }
--  else {
--    if (!vendor.IsEmpty()) {
--      folder.Append(vendor);
--      ToLowerCase(folder);
--
--      rv = aFile->AppendNative(folder);
--      NS_ENSURE_SUCCESS(rv, rv);
--
--      folder.Truncate();
--    }
--
--    folder.Append(appName);
--    ToLowerCase(folder);
--
--    rv = aFile->AppendNative(folder);
--  }
--  NS_ENSURE_SUCCESS(rv, rv);
- 
- #else
- #error "Don't know how to get profile path on your platform"
-diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h
-index eb27ed2..1985f66 100644
---- a/toolkit/xre/nsXREDirProvider.h
-+++ b/toolkit/xre/nsXREDirProvider.h
-@@ -56,16 +56,16 @@ public:
- 
-   nsresult GetProfileDefaultsDir(nsIFile* *aResult);
- 
--  static nsresult GetUserAppDataDirectory(nsIFile* *aFile) {
-+  nsresult GetUserAppDataDirectory(nsIFile* *aFile) {
-     return GetUserDataDirectory(aFile, false, nullptr, nullptr, nullptr);
-   }
--  static nsresult GetUserLocalDataDirectory(nsIFile* *aFile) {
-+  nsresult GetUserLocalDataDirectory(nsIFile* *aFile) {
-     return GetUserDataDirectory(aFile, true, nullptr, nullptr, nullptr);
-   }
- 
-   // By default GetUserDataDirectory gets profile path from gAppData,
-   // but that can be overridden by using aProfileName/aAppName/aVendorName.
--  static nsresult GetUserDataDirectory(nsIFile** aFile, bool aLocal,
-+  nsresult GetUserDataDirectory(nsIFile** aFile, bool aLocal,
-                                        const nsACString* aProfileName,
-                                        const nsACString* aAppName,
-                                        const nsACString* aVendorName);
-@@ -102,8 +102,8 @@ public:
- 
- protected:
-   nsresult GetFilesInternal(const char* aProperty, nsISimpleEnumerator** aResult);
--  static nsresult GetUserDataDirectoryHome(nsIFile* *aFile, bool aLocal);
--  static nsresult GetSysUserExtensionsDirectory(nsIFile* *aFile);
-+  nsresult GetUserDataDirectoryHome(nsIFile* *aFile, bool aLocal);
-+  nsresult GetSysUserExtensionsDirectory(nsIFile* *aFile);
- #if defined(XP_UNIX) || defined(XP_MACOSX)
-   static nsresult GetSystemExtensionsDirectory(nsIFile** aFile);
- #endif
-diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build
-index 45732e4..bc62f71 100644
---- a/xpcom/io/moz.build
-+++ b/xpcom/io/moz.build
-@@ -134,4 +134,7 @@ FINAL_LIBRARY = 'xul'
- if CONFIG['OS_ARCH'] == 'Linux' and 'lib64' in CONFIG['libdir']:
-     DEFINES['HAVE_USR_LIB64_DIR'] = True
- 
--LOCAL_INCLUDES += ['!..']
-+LOCAL_INCLUDES += [
-+    '!..',
-+    '../build',
-+]
-diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp
-index 1211c39..039a89e 100644
---- a/xpcom/io/nsAppFileLocationProvider.cpp
-+++ b/xpcom/io/nsAppFileLocationProvider.cpp
-@@ -15,6 +15,7 @@
- #include "nsISimpleEnumerator.h"
- #include "prenv.h"
- #include "nsCRT.h"
-+#include "nsXPCOMPrivate.h"  // for XPCOM_FILE_PATH_SEPARATOR
- 
- #if defined(MOZ_WIDGET_COCOA)
- #include <Carbon/Carbon.h>
-@@ -281,9 +282,8 @@ nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile** aLocalFile)
- //----------------------------------------------------------------------------------------
- // GetProductDirectory - Gets the directory which contains the application data folder
- //
--// UNIX   : ~/.mozilla/
--// WIN    : <Application Data folder on user's machine>\Mozilla
--// Mac    : :Documents:Mozilla:
-+// UNIX and WIN   : <App Folder>/TorBrowser/Data/Browser
-+// Mac            : <App Folder>/../../TorBrowser/Data/Browser
- //----------------------------------------------------------------------------------------
- NS_METHOD
- nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
-@@ -297,48 +297,45 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
-   bool exists;
-   nsCOMPtr<nsIFile> localDir;
- 
--#if defined(MOZ_WIDGET_COCOA)
--  FSRef fsRef;
--  OSType folderType = aLocal ? (OSType)kCachedDataFolderType :
--                               (OSType)kDomainLibraryFolderType;
--  OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
--  if (err) {
--    return NS_ERROR_FAILURE;
-+  rv = CloneMozBinDirectory(getter_AddRefs(localDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  int levelsToRemove = 0; // In FF21+, bin dir points to browser subdirectory.
-+#if defined(XP_MACOSX)
-+  levelsToRemove += 1;
-+#endif
-+  while (localDir && (levelsToRemove > 0)) {
-+    // When crawling up the hierarchy, components named "." do not count.
-+    nsAutoCString removedName;
-+    rv = localDir->GetNativeLeafName(removedName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    bool didRemove = !removedName.Equals(".");
-+
-+    // Remove a directory component.
-+    nsCOMPtr<nsIFile> parentDir;
-+    rv = localDir->GetParent(getter_AddRefs(parentDir));
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    localDir = parentDir;
-+
-+    if (didRemove) {
-+      --levelsToRemove;
-+    }
-   }
--  NS_NewLocalFile(EmptyString(), true, getter_AddRefs(localDir));
-+
-   if (!localDir) {
-     return NS_ERROR_FAILURE;
-   }
--  nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
--  rv = localDirMac->InitWithFSRef(&fsRef);
--  if (NS_FAILED(rv)) {
--    return rv;
--  }
--#elif defined(XP_WIN)
--  nsCOMPtr<nsIProperties> directoryService =
--    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
--  if (NS_FAILED(rv)) {
--    return rv;
--  }
--  const char* prop = aLocal ? NS_WIN_LOCAL_APPDATA_DIR : NS_WIN_APPDATA_DIR;
--  rv = directoryService->Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(localDir));
--  if (NS_FAILED(rv)) {
--    return rv;
--  }
--#elif defined(XP_UNIX)
--  rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true,
--                             getter_AddRefs(localDir));
--  if (NS_FAILED(rv)) {
--    return rv;
--  }
--#else
--#error dont_know_how_to_get_product_dir_on_your_platform
--#endif
- 
--  rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
--  if (NS_FAILED(rv)) {
--    return rv;
-+  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("TorBrowser"
-+                                        XPCOM_FILE_PATH_SEPARATOR "Data"
-+                                        XPCOM_FILE_PATH_SEPARATOR "Browser"));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  if (aLocal) {
-+    rv = localDir->AppendNative(NS_LITERAL_CSTRING("Caches"));
-+    NS_ENSURE_SUCCESS(rv, rv);
-   }
-+
-   rv = localDir->Exists(&exists);
- 
-   if (NS_SUCCEEDED(rv) && !exists) {
-@@ -357,10 +354,6 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
- 
- //----------------------------------------------------------------------------------------
- // GetDefaultUserProfileRoot - Gets the directory which contains each user profile dir
--//
--// UNIX   : ~/.mozilla/
--// WIN    : <Application Data folder on user's machine>\Mozilla\Profiles
--// Mac    : :Documents:Mozilla:Profiles:
- //----------------------------------------------------------------------------------------
- NS_METHOD
- nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsIFile** aLocalFile,
-@@ -378,23 +371,6 @@ nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsIFile** aLocalFile,
-     return rv;
-   }
- 
--#if defined(MOZ_WIDGET_COCOA) || defined(XP_WIN)
--  // These 3 platforms share this part of the path - do them as one
--  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
--  if (NS_FAILED(rv)) {
--    return rv;
--  }
--
--  bool exists;
--  rv = localDir->Exists(&exists);
--  if (NS_SUCCEEDED(rv) && !exists) {
--    rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
--  }
--  if (NS_FAILED(rv)) {
--    return rv;
--  }
--#endif
--
-   localDir.forget(aLocalFile);
- 
-   return rv;
--- 
-cgit v0.10.2
-
diff --git a/projects/instantbird/Firefox-update-process-bug-4234.mozpatch b/projects/instantbird/Firefox-update-process-bug-4234.mozpatch
deleted file mode 100644
index 86e527d..0000000
--- a/projects/instantbird/Firefox-update-process-bug-4234.mozpatch
+++ /dev/null
@@ -1,2156 +0,0 @@
-From 3f8110f69e1ddfc762a7c7dba4d06b537a785a9c Mon Sep 17 00:00:00 2001
-From: Kathy Brade <brade at pearlcrescent.com>
-Date: Thu, 4 Sep 2014 15:45:23 +0000
-Subject: Bug #4234: Use the Firefox Update Process for Tor Browser.
-
-New configure options:
-  --with-tor-browser-version=VERSION # Pass TB version throughout build.
-  --enable-tor-browser-update        # Enable bundle update behavior.
-The following files are never updated:
-  TorBrowser/Data/Browser/profiles.ini
-  TorBrowser/Data/Browser/profile.default/bookmarks.html
-  TorBrowser/Data/Tor/torrc
-Mac OS: Store update metadata under TorBrowser/UpdateInfo.
-Removed the %OS_VERSION% component from the update URL (13047) and
-  added support for minSupportedOSVersion, an attribute of the
-  <update> element that may be used to trigger Firefox's
-  "unsupported platform" behavior.
-Windows: disable "runas" code path in updater (15201).
-Windows: avoid writing to the registry (16236).
-Also includes fixes for tickets 13047, 13301, 13356, 13594, 15406,
-  16014, and 16909.
-
-diff --git a/browser/components/moz.build b/browser/components/moz.build
-index 431d505..bf7a40c 100644
---- a/browser/components/moz.build
-+++ b/browser/components/moz.build
-@@ -38,11 +38,8 @@ XPIDL_MODULE = 'browsercompsbase'
- 
- EXTRA_PP_COMPONENTS += [
-     'BrowserComponents.manifest',
--    'nsBrowserGlue.js',
--]
--
--EXTRA_COMPONENTS += [
-     'nsBrowserContentHandler.js',
-+    'nsBrowserGlue.js',
- ]
- 
- EXTRA_JS_MODULES += [
-diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js
-index e89004d..b892eaf 100644
---- a/browser/components/nsBrowserContentHandler.js
-+++ b/browser/components/nsBrowserContentHandler.js
-@@ -45,6 +45,10 @@ const NS_BINDING_ABORTED = Components.results.NS_BINDING_ABORTED;
- const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
- const NS_ERROR_ABORT = Components.results.NS_ERROR_ABORT;
- 
-+#ifdef TOR_BROWSER_VERSION
-+const kTBSavedVersionPref = "browser.startup.homepage_override.torbrowser.version";
-+#endif
-+
- function shouldLoadURI(aURI) {
-   if (aURI && !aURI.schemeIs("chrome"))
-     return true;
-@@ -96,7 +100,8 @@ const OVERRIDE_NEW_BUILD_ID = 3;
-  * Returns:
-  *  OVERRIDE_NEW_PROFILE if this is the first run with a new profile.
-  *  OVERRIDE_NEW_MSTONE if this is the first run with a build with a different
-- *                      Gecko milestone (i.e. right after an upgrade).
-+ *                      Gecko milestone or Tor Browser version (i.e. right
-+ *                      after an upgrade).
-  *  OVERRIDE_NEW_BUILD_ID if this is the first run with a new build ID of the
-  *                        same Gecko milestone (i.e. after a nightly upgrade).
-  *  OVERRIDE_NONE otherwise.
-@@ -112,6 +117,15 @@ function needHomepageOverride(prefb) {
- 
-   var mstone = Services.appinfo.platformVersion;
- 
-+#ifdef TOR_BROWSER_VERSION
-+#expand const TOR_BROWSER_VERSION = __TOR_BROWSER_VERSION__;
-+
-+  var savedTBVersion = null;
-+  try {
-+    savedTBVersion = prefb.getCharPref(kTBSavedVersionPref);
-+  } catch (e) {}
-+#endif
-+
-   var savedBuildID = null;
-   try {
-     savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID");
-@@ -129,9 +143,30 @@ function needHomepageOverride(prefb) {
-     
-     prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
-     prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
-+#ifdef TOR_BROWSER_VERSION
-+    prefb.setCharPref(kTBSavedVersionPref, TOR_BROWSER_VERSION);
-+
-+    // After an upgrade from an older release of Tor Browser (<= 5.5a1), the
-+    // savedmstone will be undefined because those releases included the
-+    // value "ignore" for the browser.startup.homepage_override.mstone pref.
-+    // To correctly detect an upgrade vs. a new profile, we check for the
-+    // presence of the "app.update.postupdate" pref.
-+    var updated = prefb.prefHasUserValue("app.update.postupdate");
-+    return (savedmstone || updated) ? OVERRIDE_NEW_MSTONE
-+                                    : OVERRIDE_NEW_PROFILE;
-+#else
-     return (savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE);
-+#endif
-   }
- 
-+#ifdef TOR_BROWSER_VERSION
-+  if (TOR_BROWSER_VERSION != savedTBVersion) {
-+    prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
-+    prefb.setCharPref(kTBSavedVersionPref, TOR_BROWSER_VERSION);
-+    return OVERRIDE_NEW_MSTONE;
-+  }
-+#endif
-+
-   if (buildID != savedBuildID) {
-     prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
-     return OVERRIDE_NEW_BUILD_ID;
-@@ -515,6 +550,15 @@ nsBrowserContentHandler.prototype = {
-       try {
-         old_mstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone");
-       } catch (ex) {}
-+
-+#ifdef TOR_BROWSER_VERSION
-+      // We do the same for the Tor Browser version.
-+      var old_tbversion = null;
-+      try {
-+        old_tbversion = prefb.getCharPref(kTBSavedVersionPref);
-+      } catch (e) {}
-+#endif
-+
-       override = needHomepageOverride(prefb);
-       if (override != OVERRIDE_NONE) {
-         switch (override) {
-@@ -538,6 +582,10 @@ nsBrowserContentHandler.prototype = {
-               overridePage = getPostUpdateOverridePage(overridePage);
- 
-             overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
-+#ifdef TOR_BROWSER_VERSION
-+            overridePage = overridePage.replace("%OLD_TOR_BROWSER_VERSION%",
-+                                                old_tbversion);
-+#endif
-             break;
-         }
-       }
-diff --git a/browser/confvars.sh b/browser/confvars.sh
-index 6935e05..ed93deb 100755
---- a/browser/confvars.sh
-+++ b/browser/confvars.sh
-@@ -8,22 +8,6 @@ MOZ_APP_VENDOR=Mozilla
- MOZ_UPDATER=1
- MOZ_PHOENIX=1
- 
--if test "$OS_ARCH" = "WINNT"; then
--  MOZ_MAINTENANCE_SERVICE=1
--  if ! test "$HAVE_64BIT_BUILD"; then
--    if test "$MOZ_UPDATE_CHANNEL" = "nightly" -o \
--            "$MOZ_UPDATE_CHANNEL" = "aurora" -o \
--            "$MOZ_UPDATE_CHANNEL" = "beta" -o \
--            "$MOZ_UPDATE_CHANNEL" = "beta-dev" -o \
--            "$MOZ_UPDATE_CHANNEL" = "release" -o \
--            "$MOZ_UPDATE_CHANNEL" = "release-dev"; then
--      if ! test "$MOZ_DEBUG"; then
--        MOZ_STUB_INSTALLER=1
--      fi
--    fi
--  fi
--fi
--
- # Enable building ./signmar and running libmar signature tests
- MOZ_ENABLE_SIGNMAR=1
- 
-@@ -51,9 +35,9 @@ MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
- # This should usually be the same as the value MAR_CHANNEL_ID.
- # If more than one ID is needed, then you should use a comma separated list
- # of values.
--ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-esr
-+ACCEPTED_MAR_CHANNEL_IDS=torbrowser-torproject-release
- # The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
--MAR_CHANNEL_ID=firefox-mozilla-esr
-+MAR_CHANNEL_ID=torbrowser-torproject-release
- MOZ_PROFILE_MIGRATOR=1
- MOZ_APP_STATIC_INI=1
- MOZ_WEBAPP_RUNTIME=1
-diff --git a/browser/installer/Makefile.in b/browser/installer/Makefile.in
-index bb91b4a..ecab9ad 100644
---- a/browser/installer/Makefile.in
-+++ b/browser/installer/Makefile.in
-@@ -72,6 +72,10 @@ endif
- endif
- endif
- 
-+ifdef TOR_BROWSER_UPDATE
-+DEFINES += -DTOR_BROWSER_UPDATE
-+endif
-+
- ifneq (,$(filter WINNT Darwin Android,$(OS_TARGET)))
- DEFINES += -DMOZ_SHARED_MOZGLUE=1
- endif
-diff --git a/config/createprecomplete.py b/config/createprecomplete.py
-index 3241d52..be571be 100644
---- a/config/createprecomplete.py
-+++ b/config/createprecomplete.py
-@@ -5,13 +5,22 @@
- # update instructions which is used to remove files and directories that are no
- # longer present in a complete update. The current working directory is used for
- # the location to enumerate and to create the precomplete file.
-+# For symlinks, remove instructions are always generated.
- 
- import sys
- import os
- 
-+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
-+# we should remove all lines in this file that contain:
-+#      TorBrowser/Data
-+
- def get_build_entries(root_path):
-     """ Iterates through the root_path, creating a list for each file and
-         directory. Excludes any file paths ending with channel-prefs.js.
-+        To support Tor Browser updates, excludes:
-+          TorBrowser/Data/Browser/profiles.ini
-+          TorBrowser/Data/Browser/profile.default/bookmarks.html
-+          TorBrowser/Data/Tor/torrc
-     """
-     rel_file_path_set = set()
-     rel_dir_path_set = set()
-@@ -22,6 +31,9 @@ def get_build_entries(root_path):
-             rel_path_file = rel_path_file.replace("\\", "/")
-             if not (rel_path_file.endswith("channel-prefs.js") or
-                     rel_path_file.endswith("update-settings.ini") or
-+                    rel_path_file == "TorBrowser/Data/Browser/profiles.ini" or
-+                    rel_path_file == "TorBrowser/Data/Browser/profile.default/bookmarks.html" or
-+                    rel_path_file == "TorBrowser/Data/Tor/torrc" or
-                     rel_path_file.find("distribution/") != -1):
-                 rel_file_path_set.add(rel_path_file)
- 
-@@ -30,7 +42,10 @@ def get_build_entries(root_path):
-             rel_path_dir = os.path.join(parent_dir_rel_path, dir_name)
-             rel_path_dir = rel_path_dir.replace("\\", "/")+"/"
-             if rel_path_dir.find("distribution/") == -1:
--                rel_dir_path_set.add(rel_path_dir)
-+                if (os.path.islink(rel_path_dir[:-1])):
-+                    rel_file_path_set.add(rel_path_dir[:-1])
-+                else:
-+                    rel_dir_path_set.add(rel_path_dir)
- 
-     rel_file_path_list = list(rel_file_path_set)
-     rel_file_path_list.sort(reverse=True)
-diff --git a/configure.in b/configure.in
-index 38df30e..e9fb038 100644
---- a/configure.in
-+++ b/configure.in
-@@ -3369,15 +3369,12 @@ AC_SUBST(GRE_MILESTONE)
- # set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
- # The logic works like this:
- # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
--# - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
- # - otherwise, we're building Release/Beta (define RELEASE_BUILD)
- case "$GRE_MILESTONE" in
-   *a1*)
-       NIGHTLY_BUILD=1
-       AC_DEFINE(NIGHTLY_BUILD)
-       ;;
--  *a*)
--      ;;
-   *)
-       RELEASE_BUILD=1
-       AC_DEFINE(RELEASE_BUILD)
-@@ -6521,6 +6518,31 @@ MOZ_ARG_ENABLE_BOOL(update-packaging,
- AC_SUBST(MOZ_UPDATE_PACKAGING)
- 
- dnl ========================================================
-+dnl Tor Additions
-+dnl ========================================================
-+MOZ_ARG_WITH_STRING(tor-browser-version,
-+[  --with-tor-browser-version=VERSION
-+                          Set Tor Browser version, e.g., 4.0b1],
-+    TOR_BROWSER_VERSION="$withval")
-+
-+MOZ_ARG_ENABLE_BOOL(tor-browser-update,
-+[  --enable-tor-browser-update
-+                          Enable Tor Browser update],
-+    TOR_BROWSER_UPDATE=1,
-+    TOR_BROWSER_UPDATE= )
-+
-+if test -n "$TOR_BROWSER_UPDATE"; then
-+    if test -z "$TOR_BROWSER_VERSION"; then
-+        AC_MSG_ERROR([--enable-tor-browser-update requires --with-tor-browser-version.])
-+    fi
-+    AC_DEFINE(TOR_BROWSER_UPDATE)
-+fi
-+
-+AC_DEFINE_UNQUOTED(TOR_BROWSER_VERSION,"$TOR_BROWSER_VERSION")
-+AC_SUBST(TOR_BROWSER_VERSION)
-+AC_SUBST(TOR_BROWSER_UPDATE)
-+
-+dnl ========================================================
- dnl build the tests by default
- dnl ========================================================
- MOZ_ARG_DISABLE_BOOL(tests,
-@@ -9068,7 +9090,7 @@ if test "$MOZ_DEBUG"; then
-     A11Y_LOG=1
- fi
- case "$MOZ_UPDATE_CHANNEL" in
--aurora|beta|release|esr)
-+aurora|alpha|beta|hardened|release|esr)
-     ;;
- *)
-     A11Y_LOG=1
-diff --git a/js/src/configure.in b/js/src/configure.in
-index 25b4ae8..7fae8a4 100644
---- a/js/src/configure.in
-+++ b/js/src/configure.in
-@@ -2691,15 +2691,12 @@ AC_SUBST(GRE_MILESTONE)
- dnl set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
- dnl The logic works like this:
- dnl - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
--dnl - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
- dnl - otherwise, we're building Release/Beta (define RELEASE_BUILD)
- case "$GRE_MILESTONE" in
-   *a1*)
-       NIGHTLY_BUILD=1
-       AC_DEFINE(NIGHTLY_BUILD)
-       ;;
--  *a*)
--      ;;
-   *)
-       RELEASE_BUILD=1
-       AC_DEFINE(RELEASE_BUILD)
-diff --git a/toolkit/modules/UpdateUtils.jsm b/toolkit/modules/UpdateUtils.jsm
-index b943467..4638c8e 100644
---- a/toolkit/modules/UpdateUtils.jsm
-+++ b/toolkit/modules/UpdateUtils.jsm
-@@ -20,6 +20,9 @@ const PREF_APP_B2G_VERSION                = "b2g.version";
- const PREF_APP_UPDATE_CUSTOM              = "app.update.custom";
- const PREF_APP_UPDATE_IMEI_HASH           = "app.update.imei_hash";
- 
-+#ifdef TOR_BROWSER_VERSION
-+#expand const TOR_BROWSER_VERSION = __TOR_BROWSER_VERSION__;
-+#endif
- 
- this.UpdateUtils = {
-   /**
-@@ -70,7 +73,11 @@ this.UpdateUtils = {
-    */
-   formatUpdateURL(url) {
-     url = url.replace(/%PRODUCT%/g, Services.appinfo.name);
-+#ifdef TOR_BROWSER_UPDATE
-+    url = url.replace(/%VERSION%/g, TOR_BROWSER_VERSION);
-+#else
-     url = url.replace(/%VERSION%/g, Services.appinfo.version);
-+#endif
-     url = url.replace(/%BUILD_ID%/g, Services.appinfo.appBuildID);
-     url = url.replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + this.ABI);
-     url = url.replace(/%OS_VERSION%/g, this.OSVersion);
-diff --git a/toolkit/modules/debug.js b/toolkit/modules/debug.js
-index ba59c65..486105e 100644
---- a/toolkit/modules/debug.js
-+++ b/toolkit/modules/debug.js
-@@ -41,6 +41,8 @@ this.NS_ASSERT = function NS_ASSERT(condition, message) {
-     switch (defB.getCharPref("app.update.channel")) {
-       case "nightly":
-       case "aurora":
-+      case "alpha":
-+      case "hardened":
-       case "beta":
-       case "default":
-         releaseBuild = false;
-diff --git a/toolkit/modules/moz.build b/toolkit/modules/moz.build
-index 0600b82..81125d1 100644
---- a/toolkit/modules/moz.build
-+++ b/toolkit/modules/moz.build
-@@ -72,7 +72,6 @@ EXTRA_JS_MODULES += [
-     'Task.jsm',
-     'Timer.jsm',
-     'Troubleshoot.jsm',
--    'UpdateUtils.jsm',
-     'WebChannel.jsm',
-     'WindowDraggingUtils.jsm',
-     'ZipUtils.jsm',
-@@ -87,6 +86,7 @@ if not CONFIG['TOR_BROWSER_VERSION']:
- EXTRA_PP_JS_MODULES += [
-     'AppConstants.jsm',
-     'SessionRecorder.jsm',
-+    'UpdateUtils.jsm',
- ]
- 
- if 'Android' != CONFIG['OS_TARGET']:
-diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
-index ab63c3d..a453062 100644
---- a/toolkit/mozapps/extensions/AddonManager.jsm
-+++ b/toolkit/mozapps/extensions/AddonManager.jsm
-@@ -23,7 +23,7 @@ if ("@mozilla.org/xre/app-info;1" in Cc) {
- 
- Cu.import("resource://gre/modules/AppConstants.jsm");
- 
--const MOZ_COMPATIBILITY_NIGHTLY = !['aurora', 'beta', 'release', 'esr'].includes(AppConstants.MOZ_UPDATE_CHANNEL);
-+const MOZ_COMPATIBILITY_NIGHTLY = !['aurora', 'alpha', 'beta', 'hardened', 'release', 'esr'].includes(AppConstants.MOZ_UPDATE_CHANNEL);
- 
- const PREF_BLOCKLIST_PINGCOUNTVERSION = "extensions.blocklist.pingCountVersion";
- const PREF_DEFAULT_PROVIDERS_ENABLED  = "extensions.defaultProviders.enabled";
-diff --git a/toolkit/mozapps/update/content/updates.js b/toolkit/mozapps/update/content/updates.js
-index 48f8bad..40e76c8 100644
---- a/toolkit/mozapps/update/content/updates.js
-+++ b/toolkit/mozapps/update/content/updates.js
-@@ -3,6 +3,8 @@
-  * 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/. */
- 
-+#filter substitution
-+
- 'use strict';
- 
- // Firefox's macBrowserOverlay.xul includes scripts that define Cc, Ci, and Cr
-@@ -51,6 +53,11 @@ const CERT_ATTR_CHECK_FAILED_NO_UPDATE  = 100;
- const CERT_ATTR_CHECK_FAILED_HAS_UPDATE = 101;
- const BACKGROUNDCHECK_MULTIPLE_FAILURES = 110;
- 
-+#ifdef TOR_BROWSER_VERSION
-+# Add double-quotes back on (stripped by JarMaker.py).
-+#expand const TOR_BROWSER_VERSION = "__TOR_BROWSER_VERSION__";
-+#endif
-+
- var gLogEnabled = false;
- var gUpdatesFoundPageId;
- 
-@@ -510,8 +517,13 @@ var gUpdates = {
-       return;
-     }
- 
-+#ifdef TOR_BROWSER_UPDATE
-+    var appVersion = TOR_BROWSER_VERSION;
-+#else
-+    var appVersion = Services.appinfo.version;
-+#endif
-     if (!this.update.appVersion ||
--        Services.vc.compare(this.update.appVersion, Services.appinfo.version) == 0) {
-+        Services.vc.compare(this.update.appVersion, appVersion) == 0) {
-       aCallback(false);
-       return;
-     }
-@@ -523,6 +535,11 @@ var gUpdates = {
- 
-     var self = this;
-     AddonManager.getAllAddons(function(addons) {
-+#ifdef TOR_BROWSER_UPDATE
-+      let compatVersion = self.update.platformVersion;
-+#else
-+      let compatVersion = self.update.appVersion;
-+#endif
-       self.addons = [];
-       addons.forEach(function(addon) {
-         // Protect against code that overrides the add-ons manager and doesn't
-@@ -551,7 +568,7 @@ var gUpdates = {
-               !addon.appDisabled && !addon.userDisabled &&
-               addon.scope != AddonManager.SCOPE_APPLICATION &&
-               addon.isCompatible &&
--              !addon.isCompatibleWith(self.update.appVersion,
-+              !addon.isCompatibleWith(compatVersion,
-                                       self.update.platformVersion))
-             self.addons.push(addon);
-         }
-@@ -821,9 +838,14 @@ var gIncompatibleCheckPage = {
-     this._totalCount = gUpdates.addons.length;
- 
-     this._pBar.mode = "normal";
-+#ifdef TOR_BROWSER_UPDATE
-+    let compatVersion = gUpdates.update.platformVersion;
-+#else
-+    let compatVersion = gUpdates.update.appVersion;
-+#endif
-     gUpdates.addons.forEach(function(addon) {
-       addon.findUpdates(this, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED,
--                        gUpdates.update.appVersion,
-+                        compatVersion,
-                         gUpdates.update.platformVersion);
-     }, this);
-   },
-@@ -848,8 +870,13 @@ var gIncompatibleCheckPage = {
-     // the add-on will become incompatible.
-     let bs = CoC["@mozilla.org/extensions/blocklist;1"].
-              getService(CoI.nsIBlocklistService);
-+#ifdef TOR_BROWSER_UPDATE
-+    let compatVersion = gUpdates.update.platformVersion;
-+#else
-+    let compatVersion = gUpdates.update.appVersion;
-+#endif
-     if (bs.isAddonBlocklisted(addon,
--                              gUpdates.update.appVersion,
-+                              compatVersion,
-                               gUpdates.update.platformVersion))
-       return;
- 
-diff --git a/toolkit/mozapps/update/jar.mn b/toolkit/mozapps/update/jar.mn
-index 9bb5d2d..5347123 100644
---- a/toolkit/mozapps/update/jar.mn
-+++ b/toolkit/mozapps/update/jar.mn
-@@ -7,6 +7,6 @@ toolkit.jar:
-   content/mozapps/update/history.xul                            (content/history.xul)
-   content/mozapps/update/history.js                             (content/history.js)
-   content/mozapps/update/updates.css                            (content/updates.css)
--  content/mozapps/update/updates.js                             (content/updates.js)
-+* content/mozapps/update/updates.js                             (content/updates.js)
-   content/mozapps/update/updates.xml                            (content/updates.xml)
-   content/mozapps/update/updates.xul                            (content/updates.xul)
-diff --git a/toolkit/mozapps/update/moz.build b/toolkit/mozapps/update/moz.build
-index 3824b88..c93100a 100644
---- a/toolkit/mozapps/update/moz.build
-+++ b/toolkit/mozapps/update/moz.build
-@@ -18,11 +18,14 @@ XPIDL_SOURCES += [
- TEST_DIRS += ['tests']
- 
- EXTRA_COMPONENTS += [
--    'nsUpdateService.js',
-     'nsUpdateService.manifest',
-     'nsUpdateServiceStub.js',
- ]
- 
-+EXTRA_PP_COMPONENTS += [
-+    'nsUpdateService.js',
-+]
-+
- EXTRA_JS_MODULES += [
-     'UpdateTelemetry.jsm',
- ]
-diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js
-index 489d085..e12636d 100644
---- a/toolkit/mozapps/update/nsUpdateService.js
-+++ b/toolkit/mozapps/update/nsUpdateService.js
-@@ -12,7 +12,9 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
- Cu.import("resource://gre/modules/FileUtils.jsm", this);
- Cu.import("resource://gre/modules/AddonManager.jsm", this);
- Cu.import("resource://gre/modules/Services.jsm", this);
-+#ifdef XP_WIN
- Cu.import("resource://gre/modules/ctypes.jsm", this);
-+#endif
- Cu.import("resource://gre/modules/UpdateTelemetry.jsm", this);
- Cu.import("resource://gre/modules/AppConstants.jsm", this);
- 
-@@ -66,6 +68,10 @@ const KEY_EXECUTABLE      = "XREExeF";
- // Gonk only
- const KEY_UPDATE_ARCHIVE_DIR = "UpdArchD";
- 
-+#ifdef TOR_BROWSER_VERSION
-+#expand const TOR_BROWSER_VERSION = __TOR_BROWSER_VERSION__;
-+#endif
-+
- const DIR_UPDATED         = "updated";
- const DIR_UPDATED_APP     = "Updated.app";
- const DIR_UPDATES         = "updates";
-@@ -701,8 +707,13 @@ function getUpdatesDirInApplyToDir() {
-   if (AppConstants.platform == "macosx") {
-     dir = dir.parent.parent; // the bundle directory
-     dir.append(DIR_UPDATED_APP);
-+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+    dir.append("TorBrowser");
-+    dir.append("UpdateInfo");
-+#else
-     dir.append("Contents");
-     dir.append("MacOS");
-+#endif
-   } else {
-     dir.append(DIR_UPDATED);
-   }
-@@ -1521,7 +1532,17 @@ function Update(update) {
-     this._patches.push(patch);
-   }
- 
--  if (this._patches.length == 0 && !update.hasAttribute("unsupported")) {
-+  if (update.hasAttribute("unsupported")) {
-+    this.unsupported = ("true" == update.getAttribute("unsupported"));
-+  } else if (update.hasAttribute("minSupportedOSVersion")) {
-+    let minOSVersion = update.getAttribute("minSupportedOSVersion");
-+    try {
-+      let osVersion = Services.sysinfo.getProperty("version");
-+      this.unsupported = (Services.vc.compare(osVersion, minOSVersion) < 0);
-+    } catch (e) {}
-+  }
-+
-+  if (this._patches.length == 0 && !this.unsupported) {
-     throw Cr.NS_ERROR_ILLEGAL_VALUE;
-   }
- 
-@@ -1574,15 +1595,13 @@ function Update(update) {
-       if(!isNaN(attr.value)) {
-         this.promptWaitTime = parseInt(attr.value);
-       }
--    } else if (attr.name == "unsupported") {
--      this.unsupported = attr.value == "true";
-     } else if (attr.name == "version") {
-       // Prevent version from replacing displayVersion if displayVersion is
-       // present in the update xml.
-       if (!this.displayVersion) {
-         this.displayVersion = attr.value;
-       }
--    } else {
-+    } else if (attr.name != "unsupported") {
-       this[attr.name] = attr.value;
- 
-       switch (attr.name) {
-@@ -2408,9 +2427,14 @@ UpdateService.prototype = {
-     updates.forEach(function(aUpdate) {
-       // Ignore updates for older versions of the application and updates for
-       // the same version of the application with the same build ID.
--      if (vc.compare(aUpdate.appVersion, Services.appinfo.version) < 0 ||
--          vc.compare(aUpdate.appVersion, Services.appinfo.version) == 0 &&
--          aUpdate.buildID == Services.appinfo.appBuildID) {
-+#ifdef TOR_BROWSER_UPDATE
-+      var compatVersion = TOR_BROWSER_VERSION;
-+#else
-+      var compatVersion = Services.appinfo.version;
-+#endif
-+      var rc = vc.compare(aUpdate.appVersion, compatVersion);
-+      if (rc < 0 || ((rc == 0) &&
-+                     (aUpdate.buildID == Services.appinfo.appBuildID))) {
-         LOG("UpdateService:selectUpdate - skipping update because the " +
-             "update's application version is less than the current " +
-             "application version");
-@@ -2574,8 +2598,13 @@ UpdateService.prototype = {
-     }
- 
-     // Only check add-on compatibility when the version changes.
-+#ifdef TOR_BROWSER_UPDATE
-+    var compatVersion = TOR_BROWSER_VERSION;
-+#else
-+    var compatVersion = Services.appinfo.version;
-+#endif
-     if (update.appVersion &&
--        Services.vc.compare(update.appVersion, Services.appinfo.version) != 0) {
-+        Services.vc.compare(update.appVersion, compatVersion) != 0) {
-       this._update = update;
-       this._checkAddonCompatibility();
-     }
-@@ -2606,6 +2635,11 @@ UpdateService.prototype = {
-     // Get all the installed add-ons
-     var self = this;
-     AddonManager.getAllAddons(function(addons) {
-+#ifdef TOR_BROWSER_UPDATE
-+      let compatVersion = self._update.platformVersion;
-+#else
-+      let compatVersion = self._update.appVersion;
-+#endif
-       self._incompatibleAddons = [];
-       addons.forEach(function(addon) {
-         // Protect against code that overrides the add-ons manager and doesn't
-@@ -2635,7 +2669,7 @@ UpdateService.prototype = {
-               !addon.appDisabled && !addon.userDisabled &&
-               addon.scope != AddonManager.SCOPE_APPLICATION &&
-               addon.isCompatible &&
--              !addon.isCompatibleWith(self._update.appVersion,
-+              !addon.isCompatibleWith(compatVersion,
-                                       self._update.platformVersion)) {
-             self._incompatibleAddons.push(addon);
-           }
-@@ -2671,7 +2705,7 @@ UpdateService.prototype = {
- 
-         self._incompatibleAddons.forEach(function(addon) {
-           addon.findUpdates(this, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED,
--                            this._update.appVersion, this._update.platformVersion);
-+                            compatVersion, this._update.platformVersion);
-         }, self);
-       }
-       else {
-@@ -2707,7 +2741,12 @@ UpdateService.prototype = {
-     // If the new version of this add-on is blocklisted for the new application
-     // then it isn't a valid update and the user should still be warned that
-     // the add-on will become incompatible.
--    if (Services.blocklist.isAddonBlocklisted(addon, this._update.appVersion,
-+#ifdef TOR_BROWSER_UPDATE
-+    let compatVersion = this._update.platformVersion;
-+#else
-+    let compatVersion = this._update.appVersion;
-+#endif
-+    if (Services.blocklist.isAddonBlocklisted(addon, compatVersion,
-                                               this._update.platformVersion)) {
-       return;
-     }
-@@ -2819,14 +2858,24 @@ UpdateService.prototype = {
-     // current application's version or the update's version is the same as the
-     // application's version and the build ID is the same as the application's
-     // build ID.
-+#ifdef TOR_BROWSER_UPDATE
-+    var compatVersion = TOR_BROWSER_VERSION;
-+#else
-+    var compatVersion = Services.appinfo.version;
-+#endif
-     if (update.appVersion &&
--        (Services.vc.compare(update.appVersion, Services.appinfo.version) < 0 ||
-+        (Services.vc.compare(update.appVersion, compatVersion) < 0 ||
-          update.buildID && update.buildID == Services.appinfo.appBuildID &&
--         update.appVersion == Services.appinfo.version)) {
-+         update.appVersion == compatVersion)) {
-       LOG("UpdateService:downloadUpdate - canceling download of update since " +
-           "it is for an earlier or same application version and build ID.\n" +
--          "current application version: " + Services.appinfo.version + "\n" +
-+#ifdef TOR_BROWSER_UPDATE
-+          "current Tor Browser version: " + compatVersion + "\n" +
-+          "update Tor Browser version : " + update.appVersion + "\n" +
-+#else
-+          "current application version: " + compatVersion + "\n" +
-           "update application version : " + update.appVersion + "\n" +
-+#endif
-           "current build ID: " + Services.appinfo.appBuildID + "\n" +
-           "update build ID : " + update.buildID);
-       cleanupActiveUpdate();
-@@ -2859,7 +2908,7 @@ UpdateService.prototype = {
-       }
-     }
-     // Set the previous application version prior to downloading the update.
--    update.previousAppVersion = Services.appinfo.version;
-+    update.previousAppVersion = compatVersion;
-     this._downloader = new Downloader(background, this);
-     return this._downloader.downloadUpdate(update);
-   },
-diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
-index 6ef82a1..f362292 100644
---- a/toolkit/mozapps/update/updater/updater.cpp
-+++ b/toolkit/mozapps/update/updater/updater.cpp
-@@ -25,7 +25,7 @@
-  *  updatev3.manifest
-  *  -----------------
-  *  method   = "add" | "add-if" | "add-if-not" | "patch" | "patch-if" |
-- *             "remove" | "rmdir" | "rmrfdir" | type
-+ *             "remove" | "rmdir" | "rmrfdir" | "addsymlink" | type
-  *
-  *  'add-if-not' adds a file if it doesn't exist.
-  *
-@@ -403,10 +403,12 @@ get_full_path(const NS_tchar *relpath)
-  *         The line from the manifest that contains the path.
-  * @param  isdir
-  *         Whether the path is a directory path. Defaults to false.
-+ * @param  islinktarget
-+ *         Whether the path is a symbolic link target. Defaults to false.
-  * @return valid filesystem path or nullptr if the path checks fail.
-  */
- static NS_tchar*
--get_valid_path(NS_tchar **line, bool isdir = false)
-+get_valid_path(NS_tchar **line, bool isdir = false, bool islinktarget = false)
- {
-   NS_tchar *path = mstrtok(kQuote, line);
-   if (!path) {
-@@ -441,10 +443,12 @@ get_valid_path(NS_tchar **line, bool isdir = false)
-     path[NS_tstrlen(path) - 1] = NS_T('\0');
-   }
- 
--  // Don't allow relative paths that resolve to a parent directory.
--  if (NS_tstrstr(path, NS_T("..")) != nullptr) {
--    LOG(("get_valid_path: paths must not contain '..': " LOG_S, path));
--    return nullptr;
-+  if (!islinktarget) {
-+    // Don't allow relative paths that resolve to a parent directory.
-+    if (NS_tstrstr(path, NS_T("..")) != nullptr) {
-+      LOG(("get_valid_path: paths must not contain '..': " LOG_S, path));
-+      return nullptr;
-+    }
-   }
- 
-   return path;
-@@ -479,7 +483,8 @@ static void ensure_write_permissions(const NS_tchar *path)
-   (void) _wchmod(path, _S_IREAD | _S_IWRITE);
- #else
-   struct stat fs;
--  if (!stat(path, &fs) && !(fs.st_mode & S_IWUSR)) {
-+  if (!lstat(path, &fs) && !S_ISLNK(fs.st_mode)
-+      && !(fs.st_mode & S_IWUSR)) {
-     (void)chmod(path, fs.st_mode | S_IWUSR);
-   }
- #endif
-@@ -680,11 +685,9 @@ static int ensure_copy(const NS_tchar *path, const NS_tchar *dest)
-     return READ_ERROR;
-   }
- 
--#ifdef XP_UNIX
-   if (S_ISLNK(ss.st_mode)) {
-     return ensure_copy_symlink(path, dest);
-   }
--#endif
- 
- #if MAYBE_USE_HARD_LINKS
-   if (sUseHardLinks) {
-@@ -780,7 +783,7 @@ static int ensure_copy_recursive(const NS_tchar *path, const NS_tchar *dest,
-     return READ_ERROR;
-   }
- 
--#ifdef XP_UNIX
-+#ifndef XP_WIN
-   if (S_ISLNK(sInfo.st_mode)) {
-     return ensure_copy_symlink(path, dest);
-   }
-@@ -839,14 +842,19 @@ static int rename_file(const NS_tchar *spath, const NS_tchar *dpath,
-     return rv;
- 
-   struct NS_tstat_t spathInfo;
--  rv = NS_tstat(spath, &spathInfo);
-+  rv = NS_tlstat(spath, &spathInfo); // Get info about file or symlink.
-   if (rv) {
-     LOG(("rename_file: failed to read file status info: " LOG_S ", " \
-          "err: %d", spath, errno));
-     return READ_ERROR;
-   }
- 
--  if (!S_ISREG(spathInfo.st_mode)) {
-+#ifdef XP_WIN
-+  if (!S_ISREG(spathInfo.st_mode))
-+#else
-+  if (!S_ISREG(spathInfo.st_mode) && !S_ISLNK(spathInfo.st_mode))
-+#endif
-+  {
-     if (allowDirs && !S_ISDIR(spathInfo.st_mode)) {
-       LOG(("rename_file: path present, but not a file: " LOG_S ", err: %d",
-            spath, errno));
-@@ -856,7 +864,12 @@ static int rename_file(const NS_tchar *spath, const NS_tchar *dpath,
-     }
-   }
- 
--  if (!NS_taccess(dpath, F_OK)) {
-+#ifdef XP_WIN
-+  if (!NS_taccess(dpath, F_OK))
-+#else
-+  if (!S_ISLNK(spathInfo.st_mode) && !NS_taccess(dpath, F_OK))
-+#endif
-+  {
-     if (ensure_remove(dpath)) {
-       LOG(("rename_file: destination file exists and could not be " \
-            "removed: " LOG_S, dpath));
-@@ -873,7 +886,7 @@ static int rename_file(const NS_tchar *spath, const NS_tchar *dpath,
-   return OK;
- }
- 
--#ifdef XP_WIN
-+#if defined(XP_WIN) && !defined(TOR_BROWSER_UPDATE)
- // Remove the directory pointed to by path and all of its files and
- // sub-directories. If a file is in use move it to the tobedeleted directory
- // and attempt to schedule removal of the file on reboot
-@@ -960,7 +973,18 @@ static int backup_restore(const NS_tchar *path)
-   NS_tsnprintf(backup, sizeof(backup)/sizeof(backup[0]),
-                NS_T("%s") BACKUP_EXT, path);
- 
--  if (NS_taccess(backup, F_OK)) {
-+  bool isLink = false;
-+#ifndef XP_WIN
-+  struct stat linkInfo;
-+  int rv = lstat(path, &linkInfo);
-+  if (!rv) {
-+    LOG(("backup_restore: cannot get info for backup file: " LOG_S, backup));
-+    return OK;
-+  }
-+  isLink = S_ISLNK(linkInfo.st_mode);
-+#endif
-+
-+  if (!isLink && NS_taccess(backup, F_OK)) {
-     LOG(("backup_restore: backup file doesn't exist: " LOG_S, backup));
-     return OK;
-   }
-@@ -975,8 +999,18 @@ static int backup_discard(const NS_tchar *path)
-   NS_tsnprintf(backup, sizeof(backup)/sizeof(backup[0]),
-                NS_T("%s") BACKUP_EXT, path);
- 
-+  bool isLink = false;
-+#ifndef XP_WIN
-+  struct stat linkInfo;
-+  int rv2 = lstat(backup, &linkInfo);
-+  if (rv2) {
-+    return OK;  // File does not exist; nothing to do.
-+  }
-+  isLink = S_ISLNK(linkInfo.st_mode);
-+#endif
-+
-   // Nothing to discard
--  if (NS_taccess(backup, F_OK)) {
-+  if (!isLink && NS_taccess(backup, F_OK)) {
-     return OK;
-   }
- 
-@@ -991,6 +1025,8 @@ static int backup_discard(const NS_tchar *path)
-            backup, path));
-       return WRITE_ERROR_DELETE_BACKUP;
-     }
-+
-+#if !defined(TOR_BROWSER_UPDATE)
-     // The MoveFileEx call to remove the file on OS reboot will fail if the
-     // process doesn't have write access to the HKEY_LOCAL_MACHINE registry key
-     // but this is ok since the installer / uninstaller will delete the
-@@ -1003,6 +1039,7 @@ static int backup_discard(const NS_tchar *path)
-       LOG(("backup_discard: failed to schedule OS reboot removal of " \
-            "file: " LOG_S, path));
-     }
-+#endif
-   }
- #else
-   if (rv)
-@@ -1056,7 +1093,7 @@ private:
- class RemoveFile : public Action
- {
- public:
--  RemoveFile() : mFile(nullptr), mSkip(0) { }
-+  RemoveFile() : mFile(nullptr), mSkip(0), mIsLink(0) { }
- 
-   int Parse(NS_tchar *line);
-   int Prepare();
-@@ -1066,6 +1103,7 @@ public:
- private:
-   const NS_tchar *mFile;
-   int mSkip;
-+  int mIsLink;
- };
- 
- int
-@@ -1083,28 +1121,39 @@ RemoveFile::Parse(NS_tchar *line)
- int
- RemoveFile::Prepare()
- {
--  // Skip the file if it already doesn't exist.
--  int rv = NS_taccess(mFile, F_OK);
--  if (rv) {
--    mSkip = 1;
--    mProgressCost = 0;
--    return OK;
-+  int rv;
-+#ifndef XP_WIN
-+  struct stat linkInfo;
-+  rv = lstat(mFile, &linkInfo);
-+  mIsLink = ((0 == rv) && S_ISLNK(linkInfo.st_mode));
-+#endif
-+
-+  if (!mIsLink) {
-+    // Skip the file if it already doesn't exist.
-+    rv = NS_taccess(mFile, F_OK);
-+    if (rv) {
-+      mSkip = 1;
-+      mProgressCost = 0;
-+      return OK;
-+    }
-   }
- 
-   LOG(("PREPARE REMOVEFILE " LOG_S, mFile));
- 
--  // Make sure that we're actually a file...
--  struct NS_tstat_t fileInfo;
--  rv = NS_tstat(mFile, &fileInfo);
--  if (rv) {
--    LOG(("failed to read file status info: " LOG_S ", err: %d", mFile,
--         errno));
--    return READ_ERROR;
--  }
-+  if (!mIsLink) {
-+    // Make sure that we're actually a file...
-+    struct NS_tstat_t fileInfo;
-+    rv = NS_tstat(mFile, &fileInfo);
-+    if (rv) {
-+      LOG(("failed to read file status info: " LOG_S ", err: %d", mFile,
-+           errno));
-+      return READ_ERROR;
-+    }
- 
--  if (!S_ISREG(fileInfo.st_mode)) {
--    LOG(("path present, but not a file: " LOG_S, mFile));
--    return DELETE_ERROR_EXPECTED_FILE;
-+    if (!S_ISREG(fileInfo.st_mode)) {
-+      LOG(("path present, but not a file: " LOG_S, mFile));
-+      return DELETE_ERROR_EXPECTED_FILE;
-+    }
-   }
- 
-   NS_tchar *slash = (NS_tchar *) NS_tstrrchr(mFile, NS_T('/'));
-@@ -1134,7 +1183,13 @@ RemoveFile::Execute()
- 
-   // The file is checked for existence here and in Prepare since it might have
-   // been removed by a separate instruction: bug 311099.
--  int rv = NS_taccess(mFile, F_OK);
-+  int rv = 0;
-+  if (mIsLink) {
-+    struct NS_tstat_t linkInfo;
-+    rv = NS_tlstat(mFile, &linkInfo);
-+  } else {
-+    rv = NS_taccess(mFile, F_OK);
-+  }
-   if (rv) {
-     LOG(("file cannot be removed because it does not exist; skipping"));
-     mSkip = 1;
-@@ -1814,6 +1869,97 @@ PatchIfFile::Finish(int status)
-   PatchFile::Finish(status);
- }
- 
-+#ifndef XP_WIN
-+class AddSymlink : public Action
-+{
-+public:
-+  AddSymlink() : mLinkName(NULL)
-+               , mTarget(NULL)
-+               , mAdded(false)
-+            { }
-+
-+  virtual int Parse(NS_tchar *line);
-+  virtual int Prepare();
-+  virtual int Execute();
-+  virtual void Finish(int status);
-+
-+private:
-+  const NS_tchar *mLinkName;
-+  const NS_tchar *mTarget;
-+  bool mAdded;
-+};
-+
-+int
-+AddSymlink::Parse(NS_tchar *line)
-+{
-+  // format "<linkname>" "target"
-+
-+  mLinkName = get_valid_path(&line);
-+  if (!mLinkName)
-+    return PARSE_ERROR;
-+
-+  // consume whitespace between args
-+  NS_tchar *q = mstrtok(kQuote, &line);
-+  if (!q)
-+    return PARSE_ERROR;
-+
-+  mTarget = get_valid_path(&line, false, true);
-+  if (!mTarget)
-+    return PARSE_ERROR;
-+
-+  return OK;
-+}
-+
-+int
-+AddSymlink::Prepare()
-+{
-+  LOG(("PREPARE ADDSYMLINK " LOG_S " -> " LOG_S, mLinkName, mTarget));
-+
-+  return OK;
-+}
-+
-+int
-+AddSymlink::Execute()
-+{
-+  LOG(("EXECUTE ADDSYMLINK " LOG_S " -> " LOG_S, mLinkName, mTarget));
-+
-+  // First make sure that we can actually get rid of any existing file or link.
-+  struct stat linkInfo;
-+  int rv = lstat(mLinkName, &linkInfo);
-+  if ((0 == rv) && !S_ISLNK(linkInfo.st_mode)) {
-+    rv = NS_taccess(mLinkName, F_OK);
-+  }
-+  if (rv == 0) {
-+    rv = backup_create(mLinkName);
-+    if (rv)
-+      return rv;
-+  } else {
-+    rv = ensure_parent_dir(mLinkName);
-+    if (rv)
-+      return rv;
-+  }
-+
-+  // Create the link.
-+  rv = symlink(mTarget, mLinkName);
-+  if (!rv) {
-+    mAdded = true;
-+  }
-+
-+  return rv;
-+}
-+
-+void
-+AddSymlink::Finish(int status)
-+{
-+  LOG(("FINISH ADDSYMLINK " LOG_S " -> " LOG_S, mLinkName, mTarget));
-+  // When there is an update failure and a link has been added it is removed
-+  // here since there might not be a backup to replace it.
-+  if (status && mAdded)
-+    NS_tremove(mLinkName);
-+  backup_finish(mLinkName, status);
-+}
-+#endif
-+
- //-----------------------------------------------------------------------------
- 
- #ifdef XP_WIN
-@@ -2115,14 +2261,29 @@ static int
- CopyInstallDirToDestDir()
- {
-   // These files should not be copied over to the updated app
--#ifdef XP_WIN
--#define SKIPLIST_COUNT 3
--#elif XP_MACOSX
--#define SKIPLIST_COUNT 0
-+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+  #ifdef XP_WIN
-+  #define SKIPLIST_COUNT 6
-+  #else
-+  #define SKIPLIST_COUNT 5
-+  #endif
- #else
--#define SKIPLIST_COUNT 2
-+  #ifdef XP_WIN
-+  #define SKIPLIST_COUNT 3
-+  #elif XP_MACOSX
-+  #define SKIPLIST_COUNT 0
-+  #else
-+  #define SKIPLIST_COUNT 2
-+  #endif
- #endif
-   copy_recursive_skiplist<SKIPLIST_COUNT> skiplist;
-+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+#ifdef XP_MACOSX
-+  skiplist.append(0, gInstallDirPath, NS_T("Updated.app"));
-+  skiplist.append(1, gInstallDirPath, NS_T("TorBrowser/UpdateInfo/updates/0"));
-+#endif
-+#endif
-+
- #ifndef XP_MACOSX
-   skiplist.append(0, gInstallDirPath, NS_T("updated"));
-   skiplist.append(1, gInstallDirPath, NS_T("updates/0"));
-@@ -2131,6 +2292,23 @@ CopyInstallDirToDestDir()
- #endif
- #endif
- 
-+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+#ifdef XP_WIN
-+  skiplist.append(SKIPLIST_COUNT - 3, gInstallDirPath,
-+                  NS_T("TorBrowser/Data/Browser/profile.default/parent.lock"));
-+  skiplist.append(SKIPLIST_COUNT - 2, gInstallDirPath,
-+         NS_T("TorBrowser/Data/Browser/profile.meek-http-helper/parent.lock"));
-+#else
-+  skiplist.append(SKIPLIST_COUNT - 3, gInstallDirPath,
-+                  NS_T("TorBrowser/Data/Browser/profile.default/.parentlock"));
-+  skiplist.append(SKIPLIST_COUNT - 2, gInstallDirPath,
-+         NS_T("TorBrowser/Data/Browser/profile.meek-http-helper/.parentlock"));
-+#endif
-+
-+skiplist.append(SKIPLIST_COUNT - 1, gInstallDirPath,
-+                NS_T("TorBrowser/Data/Tor/lock"));
-+#endif
-+
-   return ensure_copy_recursive(gInstallDirPath, gWorkingDirPath, skiplist);
- }
- 
-@@ -2251,16 +2429,52 @@ ProcessReplaceRequest()
-     if (NS_taccess(deleteDir, F_OK)) {
-       NS_tmkdir(deleteDir, 0755);
-     }
-+#if !defined(TOR_BROWSER_UPDATE)
-     remove_recursive_on_reboot(tmpDir, deleteDir);
- #endif
-+#endif
-   }
- 
- #ifdef XP_MACOSX
-   // On OS X, we we need to remove the staging directory after its Contents
-   // directory has been moved.
-   NS_tchar updatedAppDir[MAXPATHLEN];
-+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+  NS_tsnprintf(updatedAppDir, sizeof(updatedAppDir)/sizeof(updatedAppDir[0]),
-+               NS_T("%s/Updated.app"), gInstallDirPath);
-+  // For Tor Browser on OS X, we also need to copy everything else that is inside Updated.app.
-+  NS_tDIR *dir = NS_topendir(updatedAppDir);
-+  if (dir) {
-+    NS_tdirent *entry;
-+    while ((entry = NS_treaddir(dir)) != 0) {
-+      if (NS_tstrcmp(entry->d_name, NS_T(".")) &&
-+          NS_tstrcmp(entry->d_name, NS_T(".."))) {
-+        NS_tchar childSrcPath[MAXPATHLEN];
-+        NS_tsnprintf(childSrcPath, sizeof(childSrcPath)/sizeof(childSrcPath[0]),
-+                     NS_T("%s/%s"), updatedAppDir, entry->d_name);
-+        NS_tchar childDstPath[MAXPATHLEN];
-+        NS_tsnprintf(childDstPath, sizeof(childDstPath)/sizeof(childDstPath[0]),
-+                     NS_T("%s/%s"), gInstallDirPath, entry->d_name);
-+        ensure_remove_recursive(childDstPath);
-+        rv = rename_file(childSrcPath, childDstPath, true);
-+        if (rv) {
-+          LOG(("Moving " LOG_S " to " LOG_S " failed, err: %d",
-+              childSrcPath, childDstPath, errno));
-+        }
-+      }
-+    }
-+
-+    NS_tclosedir(dir);
-+  } else {
-+    LOG(("Updated.app dir can't be found: " LOG_S ", err: %d",
-+         updatedAppDir, errno));
-+  }
-+#else
-   NS_tsnprintf(updatedAppDir, sizeof(updatedAppDir)/sizeof(updatedAppDir[0]),
-                NS_T("%s/Updated.app"), gPatchDirPath);
-+#endif
-+
-+  // Remove the Updated.app directory.
-   ensure_remove_recursive(updatedAppDir);
- #endif
- 
-@@ -2998,6 +3212,26 @@ int NS_main(int argc, NS_tchar **argv)
-       // using the service is because we are testing.
-       if (!useService && !noServiceFallback &&
-           updateLockFileHandle == INVALID_HANDLE_VALUE) {
-+#ifdef TOR_BROWSER_UPDATE
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+        // Because the TorBrowser-Data directory that contains the user's
-+        // profile is a sibling of the Tor Browser installation directory,
-+        // the user probably has permission to apply updates. Therefore, to
-+        // avoid potential security issues such as CVE-2015-0833, do not
-+        // attempt to elevate privileges. Instead, write a "failed" message
-+        // to the update status file (this function will return immediately
-+        // after the CloseHandle(elevatedFileHandle) call below).
-+#else
-+        // Because the user profile is contained within the Tor Browser
-+        // installation directory, the user almost certainly has permission to
-+        // apply updates. Therefore, to avoid potential security issues such
-+        // as CVE-2015-0833, do not attempt to elevate privileges. Instead,
-+        // write a "failed" message to the update status file (this function
-+        // will return immediately after the CloseHandle(elevatedFileHandle)
-+        // call below).
-+#endif
-+        WriteStatusFile(WRITE_ERROR_ACCESS_DENIED);
-+#else
-         SHELLEXECUTEINFO sinfo;
-         memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO));
-         sinfo.cbSize       = sizeof(SHELLEXECUTEINFO);
-@@ -3019,6 +3253,7 @@ int NS_main(int argc, NS_tchar **argv)
-         } else {
-           WriteStatusFile(ELEVATION_CANCELED);
-         }
-+#endif
-       }
- 
-       if (argc > callbackIndex) {
-@@ -3310,6 +3545,7 @@ int NS_main(int argc, NS_tchar **argv)
-   if (!sStagedUpdate && !sReplaceRequest && _wrmdir(DELETE_DIR)) {
-     LOG(("NS_main: unable to remove directory: " LOG_S ", err: %d",
-          DELETE_DIR, errno));
-+#if !defined(TOR_BROWSER_UPDATE)
-     // The directory probably couldn't be removed due to it containing files
-     // that are in use and will be removed on OS reboot. The call to remove the
-     // directory on OS reboot is done after the calls to remove the files so the
-@@ -3326,6 +3562,7 @@ int NS_main(int argc, NS_tchar **argv)
-       LOG(("NS_main: failed to schedule OS reboot removal of " \
-            "directory: " LOG_S, DELETE_DIR));
-     }
-+#endif
-   }
- #endif /* XP_WIN */
- 
-@@ -3376,7 +3613,7 @@ int NS_main(int argc, NS_tchar **argv)
-   LogFinish();
- 
-   if (argc > callbackIndex) {
--#if defined(XP_WIN)
-+#if defined(XP_WIN) && !defined(TOR_BROWSER_UPDATE)
-     if (gSucceeded) {
-       if (!LaunchWinPostProcess(gInstallDirPath, gPatchDirPath)) {
-         fprintf(stderr, "The post update process was not launched");
-@@ -4005,6 +4242,11 @@ int DoUpdate()
-     else if (NS_tstrcmp(token, NS_T("patch-if")) == 0) { // Patch if exists
-       action = new PatchIfFile();
-     }
-+#ifndef XP_WIN
-+    else if (NS_tstrcmp(token, NS_T("addsymlink")) == 0) {
-+      action = new AddSymlink();
-+    }
-+#endif
-     else {
-       LOG(("DoUpdate: unknown token: " LOG_S, token));
-       return PARSE_ERROR;
-diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
-index 6d04d46..a3a2857 100644
---- a/toolkit/xre/nsAppRunner.cpp
-+++ b/toolkit/xre/nsAppRunner.cpp
-@@ -4051,12 +4051,20 @@ XREMain::XRE_mainStartup(bool* aExitFlag)
-   NS_ENSURE_SUCCESS(rv, 1);
-   rv = exeFile->GetParent(getter_AddRefs(exeDir));
-   NS_ENSURE_SUCCESS(rv, 1);
-+#ifdef TOR_BROWSER_UPDATE
-+  nsAutoCString compatVersion(TOR_BROWSER_VERSION);
-+#endif
-   ProcessUpdates(mDirProvider.GetGREDir(),
-                  exeDir,
-                  updRoot,
-                  gRestartArgc,
-                  gRestartArgv,
--                 mAppData->version);
-+#ifdef TOR_BROWSER_UPDATE
-+                 compatVersion.get()
-+#else
-+                 mAppData->version
-+#endif
-+                 );
-   if (EnvHasValue("MOZ_TEST_PROCESS_UPDATES")) {
-     SaveToEnv("MOZ_TEST_PROCESS_UPDATES=");
-     *aExitFlag = true;
-diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp
-index 83002ca..ee60aee 100644
---- a/toolkit/xre/nsUpdateDriver.cpp
-+++ b/toolkit/xre/nsUpdateDriver.cpp
-@@ -39,6 +39,7 @@
- # include <windows.h>
- # include <shlwapi.h>
- # include "nsWindowsHelpers.h"
-+# include "prprf.h"
- # define getcwd(path, size) _getcwd(path, size)
- # define getpid() GetCurrentProcessId()
- #elif defined(XP_UNIX)
-@@ -168,6 +169,46 @@ GetInstallDirPath(nsIFile *appDir, nsACString& installDirPath)
-   return NS_OK;
- }
- 
-+#if defined(TOR_BROWSER_UPDATE) && defined(XP_WIN)
-+#define PATH_SEPARATOR ";"
-+
-+// In Tor Browser, updater.exe depends on some DLLs that are located in the
-+// app directory.  To allow the updater to run when it has been copied into
-+// the update directory, we append the app directory to the PATH.
-+static nsresult
-+AdjustPathForUpdater(nsIFile *appDir)
-+{
-+  nsAutoCString appPath;
-+  nsresult rv = appDir->GetNativePath(appPath);
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  char *s = nullptr;
-+  char *pathValue = PR_GetEnv("PATH");
-+  if ((nullptr == pathValue) || ('\0' == *pathValue)) {
-+    s = PR_smprintf("PATH=%s", appPath.get());
-+  } else {
-+    s = PR_smprintf("PATH=%s" PATH_SEPARATOR "%s", pathValue, appPath.get());
-+  }
-+
-+  // We intentionally leak the value that is passed into PR_SetEnv() because
-+  // the environment will hold a pointer to it.
-+  if ((nullptr == s) || (PR_SUCCESS != PR_SetEnv(s)))
-+    return NS_ERROR_FAILURE;
-+
-+  return NS_OK;
-+}
-+#endif
-+
-+#ifdef DEBUG
-+static void
-+dump_argv(const char *aPrefix, char **argv, int argc)
-+{
-+  printf("%s - %d args\n", aPrefix, argc);
-+  for (int i = 0; i < argc; ++i)
-+    printf("  %d: %s\n", i, argv[i]);
-+}
-+#endif
-+
- #if defined(XP_MACOSX)
- // This is a copy of OS X's XRE_GetBinaryPath from nsAppRunner.cpp with the
- // gBinaryPath check removed so that the updater can reload the stub executable
-@@ -255,6 +296,33 @@ typedef enum {
-   eAppliedService
- } UpdateStatus;
- 
-+#ifdef DEBUG
-+static const char *
-+UpdateStatusToString(UpdateStatus aStatus)
-+{
-+  const char *rv = "unknown";
-+  switch (aStatus) {
-+    case eNoUpdateAction:
-+      rv = "NoUpdateAction";
-+      break;
-+    case ePendingUpdate:
-+      rv = "PendingUpdate";
-+      break;
-+    case ePendingService:
-+      rv = "PendingService";
-+      break;
-+    case eAppliedUpdate:
-+      rv = "AppliedUpdate";
-+      break;
-+    case eAppliedService:
-+      rv = "AppliedService";
-+      break;
-+  }
-+
-+  return rv;
-+}
-+#endif
-+
- /**
-  * Returns a value indicating what needs to be done in order to handle an update.
-  *
-@@ -323,12 +391,44 @@ IsOlderVersion(nsIFile *versionFile, const char *appVersion)
-   if (strncmp(buf, kNull, sizeof(kNull) - 1) == 0)
-     return false;
- 
-+#ifdef DEBUG
-+  printf("IsOlderVersion checking appVersion %s against updateVersion %s\n",
-+         appVersion, buf);
-+#endif
-+
-   if (mozilla::Version(appVersion) > buf)
-     return true;
- 
-   return false;
- }
- 
-+#ifndef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+#if defined(TOR_BROWSER_UPDATE) && defined(XP_MACOSX)
-+static nsresult
-+GetUpdateDirFromAppDir(nsIFile *aAppDir, nsIFile* *aResult)
-+{
-+  // On Mac OSX, we stage the update to an Updated.app directory that is
-+  // directly below the main Tor Browser.app directory (two levels up from
-+  // the appDir).
-+  NS_ENSURE_ARG_POINTER(aAppDir);
-+  NS_ENSURE_ARG_POINTER(aResult);
-+  nsCOMPtr<nsIFile> parentDir1, parentDir2;
-+  nsresult rv = aAppDir->GetParent(getter_AddRefs(parentDir1));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = parentDir1->GetParent(getter_AddRefs(parentDir2));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  nsCOMPtr<nsIFile> updatedDir;
-+  if (!GetFile(parentDir2, NS_LITERAL_CSTRING("Updated.app"), updatedDir)) {
-+    return NS_ERROR_FAILURE;
-+  }
-+
-+  updatedDir.forget(aResult);
-+  return NS_OK;
-+}
-+#endif
-+#endif
-+
- static bool
- CopyFileIntoUpdateDir(nsIFile *parentDir, const nsACString& leaf, nsIFile *updateDir)
- {
-@@ -541,7 +641,12 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir,
-   nsAutoCString applyToDir;
-   nsCOMPtr<nsIFile> updatedDir;
- #ifdef XP_MACOSX
-+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+  rv = GetUpdateDirFromAppDir(appDir, getter_AddRefs(updatedDir));
-+  if (NS_FAILED(rv)) {
-+#else
-   if (!GetFile(updateDir, NS_LITERAL_CSTRING("Updated.app"), updatedDir)) {
-+#endif
- #else
-   if (!GetFile(appDir, NS_LITERAL_CSTRING("updated"), updatedDir)) {
- #endif
-@@ -632,6 +737,13 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir,
-   AppendToLibPath(installDirPath.get());
- #endif
- 
-+#if defined(TOR_BROWSER_UPDATE) && defined(XP_WIN)
-+  nsresult rv2 = AdjustPathForUpdater(appDir);
-+  if (NS_FAILED(rv2)) {
-+    LOG(("SwitchToUpdatedApp -- AdjustPathForUpdater failed (0x%x)\n", rv2));
-+  }
-+#endif
-+
-   LOG(("spawning updater process for replacing [%s]\n", updaterPath.get()));
- 
- #if defined(USE_EXECV)
-@@ -807,7 +919,12 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
-     applyToDir.Assign(installDirPath);
-   } else {
- #ifdef XP_MACOSX
-+#if defined(TOR_BROWSER_UPDATE) && !defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+    rv = GetUpdateDirFromAppDir(appDir, getter_AddRefs(updatedDir));
-+    if (NS_FAILED(rv)) {
-+#else
-     if (!GetFile(updateDir, NS_LITERAL_CSTRING("Updated.app"), updatedDir)) {
-+#endif
- #else
-     if (!GetFile(appDir, NS_LITERAL_CSTRING("updated"), updatedDir)) {
- #endif
-@@ -911,6 +1028,14 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
-   if (isOSUpdate) {
-     PR_SetEnv("MOZ_OS_UPDATE=1");
-   }
-+
-+#if defined(TOR_BROWSER_UPDATE) && defined(XP_WIN)
-+  nsresult rv2 = AdjustPathForUpdater(appDir);
-+  if (NS_FAILED(rv2)) {
-+    LOG(("ApplyUpdate -- AdjustPathForUpdater failed (0x%x)\n", rv2));
-+  }
-+#endif
-+
- #if defined(MOZ_WIDGET_GONK)
-   // We want the updater to be CPU friendly and not subject to being killed by
-   // the low memory killer, so we pass in some preferences to allow it to
-@@ -933,6 +1058,9 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
- #endif
- 
-   LOG(("spawning updater process [%s]\n", updaterPath.get()));
-+#ifdef DEBUG
-+  dump_argv("ApplyUpdate updater", argv, argc);
-+#endif
- 
- #if defined(USE_EXECV)
-   // Don't use execv when staging updates.
-@@ -956,6 +1084,9 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
-   // LaunchChildMac uses posix_spawnp and prefers the current
-   // architecture when launching. It doesn't require a
-   // null-terminated string but it doesn't matter if we pass one.
-+#ifdef DEBUG
-+  dump_argv("ApplyUpdate after SetupMacCommandLine", argv, argc);
-+#endif
-   LaunchChildMac(argc, argv, 0, outpid);
-   if (restart) {
-     exit(0);
-@@ -994,9 +1125,29 @@ ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir,
-                bool restart, bool isOSUpdate, nsIFile *osApplyToDir,
-                ProcessType *pid)
- {
-+#if defined(XP_WIN) && defined(TOR_BROWSER_UPDATE)
-+  // Try to remove the "tobedeleted" directory which, if present, contains
-+  // files that could not be removed during a previous update (e.g., DLLs
-+  // that were in use and therefore locked by Windows).
-+  nsCOMPtr<nsIFile> deleteDir;
-+  nsresult winrv = appDir->Clone(getter_AddRefs(deleteDir));
-+  if (NS_SUCCEEDED(winrv)) {
-+    winrv = deleteDir->AppendNative(NS_LITERAL_CSTRING("tobedeleted"));
-+    if (NS_SUCCEEDED(winrv)) {
-+      winrv = deleteDir->Remove(true);
-+    }
-+  }
-+#endif
-+
-   nsresult rv;
- 
-   nsCOMPtr<nsIFile> updatesDir;
-+#ifdef DEBUG
-+  nsAutoCString path;
-+  updRootDir->GetNativePath(path);
-+  printf("ProcessUpdates updateRootDir: %s appVersion: %s\n",
-+         path.get(), appVersion);
-+#endif
-   rv = updRootDir->Clone(getter_AddRefs(updatesDir));
-   if (NS_FAILED(rv))
-     return rv;
-@@ -1022,6 +1173,12 @@ ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir,
- 
-   nsCOMPtr<nsIFile> statusFile;
-   UpdateStatus status = GetUpdateStatus(updatesDir, statusFile);
-+#ifdef DEBUG
-+  printf("ProcessUpdates status: %s (%d)\n",
-+         UpdateStatusToString(status), status);
-+  updatesDir->GetNativePath(path);
-+  printf("ProcessUpdates updatesDir: %s\n", path.get());
-+#endif
-   switch (status) {
-   case ePendingUpdate:
-   case ePendingService: {
-@@ -1104,7 +1261,11 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate)
-     if (NS_FAILED(rv))
-       appDir = dirProvider->GetAppDir();
- 
-+#ifdef TOR_BROWSER_UPDATE
-+    appVersion = TOR_BROWSER_VERSION;
-+#else
-     appVersion = gAppData->version;
-+#endif
-     argc = gRestartArgc;
-     argv = gRestartArgv;
-   } else {
-@@ -1134,6 +1295,8 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate)
-                  getter_AddRefs(updRoot));
-     NS_ASSERTION(NS_SUCCEEDED(rv), "Can't get the UpdRootD dir");
- 
-+    // To support Tor Browser updates from xpcshell, modify the following
-+    // code to use TOR_BROWSER_VERSION from the configure process.
-     nsCOMPtr<nsIXULAppInfo> appInfo =
-       do_GetService("@mozilla.org/xre/app-info;1");
-     if (appInfo) {
-diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
-index 831a373..403e820 100644
---- a/toolkit/xre/nsXREDirProvider.cpp
-+++ b/toolkit/xre/nsXREDirProvider.cpp
-@@ -1066,6 +1066,31 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
-   NS_ENSURE_SUCCESS(rv, rv);
- 
- #ifdef XP_MACOSX
-+#ifdef TOR_BROWSER_UPDATE
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+  // For Tor Browser, we cannot store update history, etc. under the user's
-+  // home directory. Instead, we place it under
-+  // Tor Browser.app/../TorBrowser-Data/UpdateInfo/
-+  nsCOMPtr<nsIFile> appRootDir;
-+  rv = GetAppRootDir(getter_AddRefs(appRootDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  nsCOMPtr<nsIFile> localDir;
-+  rv = appRootDir->GetParent(getter_AddRefs(localDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("TorMessenger-Data"
-+                                     XPCOM_FILE_PATH_SEPARATOR "UpdateInfo"));
-+#else
-+  // For Tor Browser, we cannot store update history, etc. under the user's home directory.
-+  // Instead, we place it under Tor Browser.app/TorBrowser/UpdateInfo/
-+  nsCOMPtr<nsIFile> localDir;
-+  rv = GetAppRootDir(getter_AddRefs(localDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = localDir->AppendNative(NS_LITERAL_CSTRING("TorBrowser"));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = localDir->AppendNative(NS_LITERAL_CSTRING("UpdateInfo"));
-+#endif
-+  NS_ENSURE_SUCCESS(rv, rv);
-+#else
-   nsCOMPtr<nsIFile> appRootDirFile;
-   nsCOMPtr<nsIFile> localDir;
-   nsAutoString appDirPath;
-@@ -1096,6 +1121,7 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
-       NS_FAILED(localDir->AppendRelativePath(appDirPath))) {
-     return NS_ERROR_FAILURE;
-   }
-+#endif
- 
-   localDir.forget(aResult);
-   return NS_OK;
-@@ -1243,33 +1269,8 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
-   NS_ENSURE_ARG_POINTER(aFile);
-   nsCOMPtr<nsIFile> localDir;
- 
--  nsresult rv = GetAppDir()->Clone(getter_AddRefs(localDir));
-+  nsresult rv = GetAppRootDir(getter_AddRefs(localDir));
-   NS_ENSURE_SUCCESS(rv, rv);
--
--  int levelsToRemove = 0; // In FF21+, appDir points to browser subdirectory.
--#if defined(XP_MACOSX)
--  levelsToRemove += 1;
--#endif
--  while (localDir && (levelsToRemove > 0)) {
--    // When crawling up the hierarchy, components named "." do not count.
--    nsAutoCString removedName;
--    rv = localDir->GetNativeLeafName(removedName);
--    NS_ENSURE_SUCCESS(rv, rv);
--    bool didRemove = !removedName.Equals(".");
--
--    // Remove a directory component.
--    nsCOMPtr<nsIFile> parentDir;
--    rv = localDir->GetParent(getter_AddRefs(parentDir));
--    NS_ENSURE_SUCCESS(rv, rv);
--    localDir = parentDir;
--
--    if (didRemove)
--      --levelsToRemove;
--  }
--
--  if (!localDir)
--    return NS_ERROR_FAILURE;
--
-   rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("TorBrowser"
-                                      XPCOM_FILE_PATH_SEPARATOR "Data"
-                                      XPCOM_FILE_PATH_SEPARATOR "Browser"));
-@@ -1376,6 +1377,44 @@ nsXREDirProvider::GetUserDataDirectory(nsIFile** aFile, bool aLocal,
- }
- 
- nsresult
-+nsXREDirProvider::GetAppRootDir(nsIFile* *aFile)
-+{
-+  NS_ENSURE_ARG_POINTER(aFile);
-+  nsCOMPtr<nsIFile> appRootDir;
-+
-+  nsresult rv = GetAppDir()->Clone(getter_AddRefs(appRootDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  int levelsToRemove = 0; // In FF21+, appDir points to browser subdirectory.
-+#if defined(XP_MACOSX)
-+  levelsToRemove += 1;
-+#endif
-+  while (appRootDir && (levelsToRemove > 0)) {
-+    // When crawling up the hierarchy, components named "." do not count.
-+    nsAutoCString removedName;
-+    rv = appRootDir->GetNativeLeafName(removedName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    bool didRemove = !removedName.Equals(".");
-+
-+    // Remove a directory component.
-+    nsCOMPtr<nsIFile> parentDir;
-+    rv = appRootDir->GetParent(getter_AddRefs(parentDir));
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    appRootDir = parentDir;
-+
-+    if (didRemove)
-+      --levelsToRemove;
-+  }
-+
-+  if (!appRootDir)
-+    return NS_ERROR_FAILURE;
-+
-+  appRootDir.forget(aFile);
-+  return NS_OK;
-+}
-+
-+
-+nsresult
- nsXREDirProvider::EnsureDirectoryExists(nsIFile* aDirectory)
- {
-   bool exists;
-diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h
-index 1985f66..b86cc68 100644
---- a/toolkit/xre/nsXREDirProvider.h
-+++ b/toolkit/xre/nsXREDirProvider.h
-@@ -107,6 +107,7 @@ protected:
- #if defined(XP_UNIX) || defined(XP_MACOSX)
-   static nsresult GetSystemExtensionsDirectory(nsIFile** aFile);
- #endif
-+  nsresult GetAppRootDir(nsIFile* *aFile);
-   static nsresult EnsureDirectoryExists(nsIFile* aDirectory);
-   void EnsureProfileFileExists(nsIFile* aFile);
- 
-diff --git a/tools/update-packaging/common.sh b/tools/update-packaging/common.sh
-index eb35880..96bfa43 100755
---- a/tools/update-packaging/common.sh
-+++ b/tools/update-packaging/common.sh
-@@ -8,7 +8,13 @@
- # Author: Darin Fisher
- #
- 
-+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
-+# we should remove all lines in this file that contain:
-+#      TorBrowser/Data
-+
- # -----------------------------------------------------------------------------
-+QUIET=0
-+
- # By default just assume that these tools exist on our path
- MAR=${MAR:-mar}
- BZIP2=${BZIP2:-bzip2}
-@@ -21,6 +27,12 @@ notice() {
-   echo "$*" 1>&2
- }
- 
-+verbose_notice() {
-+  if [ $QUIET -eq 0 ]; then
-+    notice "$*"
-+  fi
-+}
-+
- get_file_size() {
-   info=($(ls -ln "$1"))
-   echo ${info[4]}
-@@ -54,22 +66,10 @@ make_add_instruction() {
-     forced=
-   fi
- 
--  is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
--  if [ $is_extension = "1" ]; then
--    # Use the subdirectory of the extensions folder as the file to test
--    # before performing this add instruction.
--    testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
--    notice "     add-if \"$testdir\" \"$f\""
--    echo "add-if \"$testdir\" \"$f\"" >> $filev2
--    if [ ! $filev3 = "" ]; then
--      echo "add-if \"$testdir\" \"$f\"" >> $filev3
--    fi
--  else
--    notice "        add \"$f\"$forced"
--    echo "add \"$f\"" >> $filev2
--    if [ ! $filev3 = "" ]; then
--      echo "add \"$f\"" >> $filev3
--    fi
-+  verbose_notice "        add \"$f\"$forced"
-+  echo "add \"$f\"" >> "$filev2"
-+  if [ ! "$filev3" = "" ]; then
-+    echo "add \"$f\"" >> "$filev3"
-   fi
- }
- 
-@@ -100,8 +100,19 @@ make_add_if_not_instruction() {
-   f="$1"
-   filev3="$2"
- 
--  notice " add-if-not \"$f\" \"$f\""
--  echo "add-if-not \"$f\" \"$f\"" >> $filev3
-+  verbose_notice " add-if-not \"$f\" \"$f\""
-+  echo "add-if-not \"$f\" \"$f\"" >> "$filev3"
-+}
-+
-+make_addsymlink_instruction() {
-+  link="$1"
-+  target="$2"
-+  filev2="$3"
-+  filev3="$4"
-+
-+  verbose_notice "        addsymlink: $link -> $target"
-+  echo "addsymlink \"$link\" \"$target\"" >> "$filev2"
-+  echo "addsymlink \"$link\" \"$target\"" >> "$filev3"
- }
- 
- make_patch_instruction() {
-@@ -109,19 +120,9 @@ make_patch_instruction() {
-   filev2="$2"
-   filev3="$3"
- 
--  is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
--  if [ $is_extension = "1" ]; then
--    # Use the subdirectory of the extensions folder as the file to test
--    # before performing this add instruction.
--    testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
--    notice "   patch-if \"$testdir\" \"$f.patch\" \"$f\""
--    echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev2
--    echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev3
--  else
--    notice "      patch \"$f.patch\" \"$f\""
--    echo "patch \"$f.patch\" \"$f\"" >> $filev2
--    echo "patch \"$f.patch\" \"$f\"" >> $filev3
--  fi
-+  verbose_notice "      patch \"$f.patch\" \"$f\""
-+  echo "patch \"$f.patch\" \"$f\"" >> "$filev2"
-+  echo "patch \"$f.patch\" \"$f\"" >> "$filev3"
- }
- 
- append_remove_instructions() {
-@@ -148,19 +149,19 @@ append_remove_instructions() {
-         # Exclude comments
-         if [ ! $(echo "$f" | grep -c '^#') = 1 ]; then
-           if [ $(echo "$f" | grep -c '\/$') = 1 ]; then
--            notice "      rmdir \"$f\""
--            echo "rmdir \"$f\"" >> $filev2
--            echo "rmdir \"$f\"" >> $filev3
-+            verbose_notice "      rmdir \"$f\""
-+            echo "rmdir \"$f\"" >> "$filev2"
-+            echo "rmdir \"$f\"" >> "$filev3"
-           elif [ $(echo "$f" | grep -c '\/\*$') = 1 ]; then
-             # Remove the *
-             f=$(echo "$f" | sed -e 's:\*$::')
--            notice "    rmrfdir \"$f\""
--            echo "rmrfdir \"$f\"" >> $filev2
--            echo "rmrfdir \"$f\"" >> $filev3
-+            verbose_notice "    rmrfdir \"$f\""
-+            echo "rmrfdir \"$f\"" >> "$filev2"
-+            echo "rmrfdir \"$f\"" >> "$filev3"
-           else
--            notice "     remove \"$f\""
--            echo "remove \"$f\"" >> $filev2
--            echo "remove \"$f\"" >> $filev3
-+            verbose_notice "     remove \"$f\""
-+            echo "remove \"$f\"" >> "$filev2"
-+            echo "remove \"$f\"" >> "$filev3"
-           fi
-         fi
-       fi
-@@ -170,6 +171,10 @@ append_remove_instructions() {
- 
- # List all files in the current directory, stripping leading "./"
- # Pass a variable name and it will be filled as an array.
-+# To support Tor Browser updates, skip the following files:
-+#    TorBrowser/Data/Browser/profiles.ini
-+#    TorBrowser/Data/Browser/profile.default/bookmarks.html
-+#    TorBrowser/Data/Tor/torrc
- list_files() {
-   count=0
- 
-@@ -182,6 +187,11 @@ list_files() {
-     | sed 's/\.\/\(.*\)/\1/' \
-     | sort -r > "temp-filelist"
-   while read file; do
-+    if [ "$file" = "TorBrowser/Data/Browser/profiles.ini" -o                   \
-+         "$file" = "TorBrowser/Data/Browser/profile.default/bookmarks.html" -o \
-+         "$file" = "TorBrowser/Data/Tor/torrc" ]; then
-+      continue;
-+    fi
-     eval "${1}[$count]=\"$file\""
-     (( count++ ))
-   done < "temp-filelist"
-@@ -203,3 +213,19 @@ list_dirs() {
-   done < "temp-dirlist"
-   rm "temp-dirlist"
- }
-+
-+# List all symbolic links in the current directory, stripping leading "./"
-+list_symlinks() {
-+  count=0
-+
-+  find . -type l \
-+    | sed 's/\.\/\(.*\)/\1/' \
-+    | sort -r > "temp-symlinklist"
-+  while read symlink; do
-+    target=$(readlink "$symlink")
-+    eval "${1}[$count]=\"$symlink\""
-+    eval "${2}[$count]=\"$target\""
-+    (( count++ ))
-+  done < "temp-symlinklist"
-+  rm "temp-symlinklist"
-+}
-diff --git a/tools/update-packaging/make_full_update.sh b/tools/update-packaging/make_full_update.sh
-index f046614..f0bd7f6 100755
---- a/tools/update-packaging/make_full_update.sh
-+++ b/tools/update-packaging/make_full_update.sh
-@@ -28,10 +28,16 @@ if [ $1 = -h ]; then
-   notice ""
-   notice "Options:"
-   notice "  -h  show this help text"
-+  notice "  -q  be less verbose"
-   notice ""
-   exit 1
- fi
- 
-+if [ $1 = -q ]; then
-+  QUIET=1
-+  shift
-+fi
-+
- # -----------------------------------------------------------------------------
- 
- archive="$1"
-@@ -63,17 +69,46 @@ if [ ! -f "precomplete" ]; then
- fi
- 
- list_files files
-+list_symlinks symlinks symlink_targets
-+
-+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
-+# we should remove the following lines:
-+# Make sure we delete the pre 5.1.0 HTTPS Everywhere as well in case it
-+# exists. The extension ID got changed with the version bump to 5.1.0.
-+ext_path='TorBrowser/Data/Browser/profile.default/extensions'
-+if [ -d "$ext_dir" ]; then
-+  directories_to_remove="$ext_path/https-everywhere at eff.org $ext_path/https-everywhere-eff at eff.org"
-+else
-+  directories_to_remove=""
-+fi
-+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
- 
- popd
- 
- # Add the type of update to the beginning of the update manifests.
--> $updatemanifestv2
--> $updatemanifestv3
-+> "$updatemanifestv2"
-+> "$updatemanifestv3"
- notice ""
- notice "Adding type instruction to update manifests"
- notice "       type complete"
--echo "type \"complete\"" >> $updatemanifestv2
--echo "type \"complete\"" >> $updatemanifestv3
-+echo "type \"complete\"" >> "$updatemanifestv2"
-+echo "type \"complete\"" >> "$updatemanifestv3"
-+
-+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
-+# we should remove the following lines:
-+# If removal of any old, existing directories is desired, emit the appropriate
-+# rmrfdir commands.
-+notice ""
-+notice "Adding directory removal instructions to update manifests"
-+for dir_to_remove in $directories_to_remove; do
-+  # rmrfdir requires a trailing slash; if slash is missing, add one.
-+  if ! [[ "$dir_to_remove" =~ /$ ]]; then
-+   dir_to_remove="${dir_to_remove}/"
-+  fi
-+  echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv2"
-+  echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv3"
-+done
-+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
- 
- notice ""
- notice "Adding file add instructions to update manifests"
-@@ -99,6 +134,15 @@ for ((i=0; $i<$num_files; i=$i+1)); do
-   targetfiles="$targetfiles \"$f\""
- done
- 
-+notice ""
-+notice "Adding symlink add instructions to update manifests"
-+num_symlinks=${#symlinks[*]}
-+for ((i=0; $i<$num_symlinks; i=$i+1)); do
-+  link="${symlinks[$i]}"
-+  target="${symlink_targets[$i]}"
-+  make_addsymlink_instruction "$link" "$target" "$updatemanifestv2" "$updatemanifestv3"
-+done
-+
- # Append remove instructions for any dead files.
- notice ""
- notice "Adding file and directory remove instructions from file 'removed-files'"
-diff --git a/tools/update-packaging/make_incremental_update.sh b/tools/update-packaging/make_incremental_update.sh
-index 592b7ab..15af172 100755
---- a/tools/update-packaging/make_incremental_update.sh
-+++ b/tools/update-packaging/make_incremental_update.sh
-@@ -21,6 +21,7 @@ print_usage() {
-   notice "  -h  show this help text"
-   notice "  -f  clobber this file in the installation"
-   notice "      Must be a path to a file to clobber in the partial update."
-+  notice "  -q  be less verbose"
-   notice ""
- }
- 
-@@ -61,6 +62,21 @@ check_for_forced_update() {
-       ## "true" *giggle*
-       return 0;
-     fi
-+
-+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
-+# we should remove the following lines:
-+    # If the file in the skip list ends with /*, do a prefix match.
-+    # This allows TorBrowser/Data/Browser/profile.default/extensions/https-everywhere-eff at eff.org/*
-+    # to be used to force all HTTPS Everywhere files to be updated.
-+    f_suffix=${f##*/}
-+    if [[ $f_suffix = "*" ]]; then
-+      f_prefix="${f%\/\*}";
-+      if [[ $forced_file_chk == $f_prefix* ]]; then
-+        ## 0 means "true"
-+        return 0;
-+      fi
-+    fi
-+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
-   done
-   ## 'false'... because this is bash. Oh yay!
-   return 1;
-@@ -71,13 +87,18 @@ if [ $# = 0 ]; then
-   exit 1
- fi
- 
--requested_forced_updates='Contents/MacOS/firefox'
-+# Firefox uses requested_forced_updates='Contents/MacOS/firefox' due to
-+# 770996 but in Tor Browser we do not need that fix.
-+requested_forced_updates=""
-+directories_to_remove=""
- 
--while getopts "hf:" flag
-+while getopts "hqf:" flag
- do
-    case "$flag" in
-       h) print_usage; exit 0
-       ;;
-+      q) QUIET=1
-+      ;;
-       f) requested_forced_updates="$requested_forced_updates $OPTARG"
-       ;;
-       ?) print_usage; exit 1
-@@ -104,6 +125,46 @@ updatemanifestv2="$workdir/updatev2.manifest"
- updatemanifestv3="$workdir/updatev3.manifest"
- archivefiles="updatev2.manifest updatev3.manifest"
- 
-+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
-+# we should remove the following lines:
-+# If the NoScript or HTTPS Everywhere extensions have changed between
-+# releases, add them to the "force updates" list.
-+ext_path='TorBrowser/Data/Browser/profile.default/extensions'
-+if [ -d "$newdir/$ext_path" ]; then
-+  https_everywhere='https-everywhere-eff at eff.org'
-+  noscript='{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi'
-+
-+  # NoScript is a packed extension, so we simply compare the old and the new
-+  # .xpi files.
-+  noscript_path="$ext_path/$noscript"
-+  diff -a "$olddir/$noscript_path" "$newdir/$noscript_path" > /dev/null
-+  rc=$?
-+  if [ $rc -gt 1 ]; then
-+    notice "Unexpected exit $rc from $noscript_path diff command"
-+    exit 2
-+  elif [ $rc -eq 1 ]; then
-+    requested_forced_updates="$requested_forced_updates $noscript_path"
-+  fi
-+
-+  # HTTPS Everywhere is an unpacked extension, so we need to determine if any of
-+  # the unpacked files have changed. Since that is messy, we simply compare the
-+  # old extension's install.rdf file to the new one.
-+  https_everywhere_install_rdf="$ext_path/$https_everywhere/install.rdf"
-+  diff "$olddir/$https_everywhere_install_rdf"     \
-+        "$newdir/$https_everywhere_install_rdf" > /dev/null
-+  rc=$?
-+  if [ $rc -gt 1 -a -e "$olddir/$https_everywhere_install_rdf" ]; then
-+    notice "Unexpected exit $rc from $https_everywhere_install_rdf diff command"
-+    exit 2
-+  elif [ $rc -ge 1 ]; then
-+    requested_forced_updates="$requested_forced_updates $ext_path/$https_everywhere/*"
-+    # Make sure we delete the pre 5.1.0 HTTPS Everywhere as well in case it
-+    # exists. The extension ID got changed with the version bump to 5.1.0.
-+    directories_to_remove="$directories_to_remove $ext_path/https-everywhere at eff.org $ext_path/$https_everywhere"
-+  fi
-+fi
-+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
-+
- mkdir -p "$workdir"
- 
- # Generate a list of all files in the target directory.
-@@ -113,6 +174,7 @@ if test $? -ne 0 ; then
- fi
- 
- list_files oldfiles
-+list_symlinks oldsymlinks oldsymlink_targets
- list_dirs olddirs
- 
- popd
-@@ -131,17 +193,34 @@ fi
- 
- list_dirs newdirs
- list_files newfiles
-+list_symlinks newsymlinks newsymlink_targets
- 
- popd
- 
- # Add the type of update to the beginning of the update manifests.
- notice ""
- notice "Adding type instruction to update manifests"
--> $updatemanifestv2
--> $updatemanifestv3
-+> "$updatemanifestv2"
-+> "$updatemanifestv3"
- notice "       type partial"
--echo "type \"partial\"" >> $updatemanifestv2
--echo "type \"partial\"" >> $updatemanifestv3
-+echo "type \"partial\"" >> "$updatemanifestv2"
-+echo "type \"partial\"" >> "$updatemanifestv3"
-+
-+# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
-+# we should remove the following lines:
-+# If removal of any old, existing directories is desired, emit the appropriate
-+# rmrfdir commands.
-+notice ""
-+notice "Adding directory removal instructions to update manifests"
-+for dir_to_remove in $directories_to_remove; do
-+  # rmrfdir requires a trailing slash, so add one if missing.
-+  if ! [[ "$dir_to_remove" =~ /$ ]]; then
-+    dir_to_remove="${dir_to_remove}/"
-+  fi
-+  echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv2"
-+  echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv3"
-+done
-+# END TOR_BROWSER_DATA_OUTSIDE_APP_DIR removal
- 
- notice ""
- notice "Adding file patch and add instructions to update manifests"
-@@ -234,6 +313,24 @@ for ((i=0; $i<$num_oldfiles; i=$i+1)); do
-   fi
- done
- 
-+# Remove and re-add symlinks
-+notice ""
-+notice "Adding symlink remove/add instructions to update manifests"
-+num_oldsymlinks=${#oldsymlinks[*]}
-+for ((i=0; $i<$num_oldsymlinks; i=$i+1)); do
-+  link="${oldsymlinks[$i]}"
-+  verbose_notice "        remove: $link"
-+  echo "remove \"$link\"" >> "$updatemanifestv2"
-+  echo "remove \"$link\"" >> "$updatemanifestv3"
-+done
-+
-+num_newsymlinks=${#newsymlinks[*]}
-+for ((i=0; $i<$num_newsymlinks; i=$i+1)); do
-+  link="${newsymlinks[$i]}"
-+  target="${newsymlink_targets[$i]}"
-+  make_addsymlink_instruction "$link" "$target" "$updatemanifestv2" "$updatemanifestv3"
-+done
-+
- # Newly added files
- notice ""
- notice "Adding file add instructions to update manifests"
-@@ -270,8 +367,8 @@ notice "Adding file remove instructions to update manifests"
- for ((i=0; $i<$num_removes; i=$i+1)); do
-   f="${remove_array[$i]}"
-   notice "     remove \"$f\""
--  echo "remove \"$f\"" >> $updatemanifestv2
--  echo "remove \"$f\"" >> $updatemanifestv3
-+  echo "remove \"$f\"" >> "$updatemanifestv2"
-+  echo "remove \"$f\"" >> "$updatemanifestv3"
- done
- 
- # Add remove instructions for any dead files.
-@@ -288,8 +385,8 @@ for ((i=0; $i<$num_olddirs; i=$i+1)); do
-   # If this dir doesn't exist in the new directory remove it.
-   if [ ! -d "$newdir/$f" ]; then
-     notice "      rmdir $f/"
--    echo "rmdir \"$f/\"" >> $updatemanifestv2
--    echo "rmdir \"$f/\"" >> $updatemanifestv3
-+    echo "rmdir \"$f/\"" >> "$updatemanifestv2"
-+    echo "rmdir \"$f/\"" >> "$updatemanifestv3"
-   fi
- done
- 
--- 
-cgit v0.10.2
-
diff --git a/projects/instantbird/Improve-profile-access-bug-14631-first.mozpatch b/projects/instantbird/Improve-profile-access-bug-14631-first.mozpatch
deleted file mode 100644
index 7a9ad68..0000000
--- a/projects/instantbird/Improve-profile-access-bug-14631-first.mozpatch
+++ /dev/null
@@ -1,246 +0,0 @@
-commit 5aae044b37579dc1c95b195084bcfcdaed352545
-Author: Kathy Brade <brade at pearlcrescent.com>
-Date:   Tue Feb 24 13:50:23 2015 -0500
-
-    Bug 14631: Improve profile access error messages.
-    
-    Instead of always reporting that the profile is locked, display specific
-    messages for "access denied" and "read-only file system".
-
-diff --git a/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties b/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties
-index adac95a..3cf48ff 100644
---- a/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties
-+++ b/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties
-@@ -12,6 +12,11 @@ restartMessageUnlocker=%S is already running, but is not responding. The old %S
- restartMessageNoUnlockerMac=A copy of %S is already open. Only one copy of %S can be open at a time.
- restartMessageUnlockerMac=A copy of %S is already open. The running copy of %S will quit in order to open this one.
- 
-+# LOCALIZATION NOTE (profileProblemTitle, profileReadOnly, profileReadOnlyMac, profileAccessDenied):  Messages displayed when the browser profile cannot be accessed or written to. %S is the application name.
-+profileProblemTitle=%S Profile Problem
-+profileReadOnly=You cannot run %S from a read-only file system.  Please copy %S to another location before trying to use it.
-+profileReadOnlyMac=You cannot run %S from a read-only file system.  Please copy %S to your Desktop or Applications folder before trying to use it.
-+profileAccessDenied=%S does not have permission to access the profile. Please adjust your file system permissions and try again.
- # Profile manager
- # LOCALIZATION NOTE (profileTooltip): First %S is the profile name, second %S is the path to the profile folder.
- profileTooltip=Profile: '%S' - Path: '%S'
-diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
-index da73cd5..d82f303 100644
---- a/toolkit/xre/nsAppRunner.cpp
-+++ b/toolkit/xre/nsAppRunner.cpp
-@@ -1913,6 +1913,14 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
-   return NS_ERROR_LAUNCHED_CHILD_PROCESS;
- }
- 
-+enum ProfileStatus {
-+  PROFILE_STATUS_OK,
-+  PROFILE_STATUS_ACCESS_DENIED,
-+  PROFILE_STATUS_READ_ONLY,
-+  PROFILE_STATUS_IS_LOCKED,
-+  PROFILE_STATUS_OTHER_ERROR
-+};
-+
- static const char kProfileProperties[] =
-   "chrome://mozapps/locale/profile/profileSelection.properties";
- 
-@@ -1951,9 +1959,9 @@ private:
- } // namespace
- 
- static ReturnAbortOnError
--ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
--                    nsIProfileUnlocker* aUnlocker,
--                    nsINativeAppSupport* aNative, nsIProfileLock* *aResult)
-+ProfileErrorDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
-+                   ProfileStatus aStatus, nsIProfileUnlocker* aUnlocker,
-+                   nsINativeAppSupport* aNative, nsIProfileLock* *aResult)
- {
-   nsresult rv;
- 
-@@ -1980,18 +1988,31 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
- 
-     nsXPIDLString killMessage;
- #ifndef XP_MACOSX
--    sb->FormatStringFromName(aUnlocker ? MOZ_UTF16("restartMessageUnlocker")
--                                       : MOZ_UTF16("restartMessageNoUnlocker"),
--                             params, 2, getter_Copies(killMessage));
-+    static const char16_t kRestartUnlocker[] = MOZ_UTF16("restartMessageUnlocker");
-+    static const char16_t kRestartNoUnlocker[] = MOZ_UTF16("restartMessageNoUnlocker");
-+    static const char16_t kReadOnly[] = MOZ_UTF16("profileReadOnly");
- #else
--    sb->FormatStringFromName(aUnlocker ? MOZ_UTF16("restartMessageUnlockerMac")
--                                       : MOZ_UTF16("restartMessageNoUnlockerMac"),
--                             params, 2, getter_Copies(killMessage));
-+    static const char16_t kRestartUnlocker[] = MOZ_UTF16("restartMessageUnlockerMac");
-+    static const char16_t kRestartNoUnlocker[] = MOZ_UTF16("restartMessageNoUnlockerMac");
-+    static const char16_t kReadOnly[] = MOZ_UTF16("profileReadOnlyMac");
- #endif
-+    static const char16_t kAccessDenied[] = MOZ_UTF16("profileAccessDenied");
-+ 
-+    const char16_t *errorKey = aUnlocker ? kRestartUnlocker
-+                                         : kRestartNoUnlocker;
-+    if (PROFILE_STATUS_READ_ONLY == aStatus)
-+      errorKey = kReadOnly;
-+    else if (PROFILE_STATUS_ACCESS_DENIED == aStatus)
-+      errorKey = kAccessDenied;
-+    sb->FormatStringFromName(errorKey, params, 2, getter_Copies(killMessage));
-+
-+    const char16_t *titleKey = ((PROFILE_STATUS_READ_ONLY == aStatus) ||
-+                                (PROFILE_STATUS_ACCESS_DENIED == aStatus))
-+                                   ? MOZ_UTF16("profileProblemTitle")
-+                                   : MOZ_UTF16("restartTitle");
- 
-     nsXPIDLString killTitle;
--    sb->FormatStringFromName(MOZ_UTF16("restartTitle"),
--                             params, 1, getter_Copies(killTitle));
-+    sb->FormatStringFromName(titleKey, params, 1, getter_Copies(killTitle));
- 
-     if (!killMessage || !killTitle)
-       return NS_ERROR_FAILURE;
-@@ -2092,8 +2113,9 @@ ProfileMissingDialog(nsINativeAppSupport* aNative)
- }
- 
- static nsresult
--ProfileLockedDialog(nsIToolkitProfile* aProfile, nsIProfileUnlocker* aUnlocker,
--                    nsINativeAppSupport* aNative, nsIProfileLock* *aResult)
-+ProfileErrorDialog(nsIToolkitProfile* aProfile, ProfileStatus aStatus,
-+                   nsIProfileUnlocker* aUnlocker, nsINativeAppSupport* aNative,
-+                   nsIProfileLock* *aResult)
- {
-   nsCOMPtr<nsIFile> profileDir;
-   nsresult rv = aProfile->GetRootDir(getter_AddRefs(profileDir));
-@@ -2109,8 +2131,8 @@ ProfileLockedDialog(nsIToolkitProfile* aProfile, nsIProfileUnlocker* aUnlocker,
-   rv = aProfile->GetLocalDir(getter_AddRefs(profileLocalDir));
-   if (NS_FAILED(rv)) return rv;
- 
--  return ProfileLockedDialog(profileDir, profileLocalDir, aUnlocker, aNative,
--                             aResult);
-+  return ProfileErrorDialog(profileDir, profileLocalDir, aStatus, aUnlocker,
-+                            aNative, aResult);
- }
- 
- static const char kProfileManagerURL[] =
-@@ -2275,6 +2297,53 @@ SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
-   return rv;
- }
- 
-+// Check for write permission to the profile directory by trying to create a
-+// new file (after ensuring that no file with the same name exists).
-+static ProfileStatus CheckProfileWriteAccess(nsIFile* aProfileDir)
-+{
-+#if defined(XP_UNIX)
-+  NS_NAMED_LITERAL_STRING(writeTestFileName, ".parentwritetest");
-+#else
-+  NS_NAMED_LITERAL_STRING(writeTestFileName, "parent.writetest");
-+#endif
-+
-+  nsCOMPtr<nsIFile> writeTestFile;
-+  nsresult rv = aProfileDir->Clone(getter_AddRefs(writeTestFile));
-+  if (NS_SUCCEEDED(rv))
-+    rv = writeTestFile->Append(writeTestFileName);
-+
-+  if (NS_SUCCEEDED(rv)) {
-+    bool doesExist = false;
-+    rv = writeTestFile->Exists(&doesExist);
-+    if (NS_SUCCEEDED(rv) && doesExist)
-+      rv = writeTestFile->Remove(true);
-+  }
-+
-+  if (NS_SUCCEEDED(rv)) {
-+    rv = writeTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0666);
-+    (void)writeTestFile->Remove(true);
-+  }
-+
-+  ProfileStatus status = NS_SUCCEEDED(rv) ? PROFILE_STATUS_OK
-+                                          : PROFILE_STATUS_OTHER_ERROR;
-+  if (NS_ERROR_FILE_ACCESS_DENIED == rv)
-+    status = PROFILE_STATUS_ACCESS_DENIED;
-+  else if (NS_ERROR_FILE_READ_ONLY == rv)
-+    status = PROFILE_STATUS_READ_ONLY;
-+
-+  return status;
-+}
-+
-+static ProfileStatus CheckProfileWriteAccess(nsIToolkitProfile* aProfile)
-+{
-+  nsCOMPtr<nsIFile> profileDir;
-+  nsresult rv = aProfile->GetRootDir(getter_AddRefs(profileDir));
-+  if (NS_FAILED(rv))
-+    return PROFILE_STATUS_OTHER_ERROR;
-+
-+  return CheckProfileWriteAccess(profileDir);
-+}
-+
- static bool gDoMigration = false;
- static bool gDoProfileReset = false;
- 
-@@ -2410,13 +2479,18 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
-         NS_ENSURE_SUCCESS(rv, rv);
-     }
- 
-+    ProfileStatus status = CheckProfileWriteAccess(lf);
-+    if (PROFILE_STATUS_OK != status)
-+      return ProfileErrorDialog(lf, lf, status, nullptr, aNative, aResult);
-+
-     // If a profile path is specified directory on the command line, then
-     // assume that the temp directory is the same as the given directory.
-     rv = NS_LockProfilePath(lf, lf, getter_AddRefs(unlocker), aResult);
-     if (NS_SUCCEEDED(rv))
-       return rv;
- 
--    return ProfileLockedDialog(lf, lf, unlocker, aNative, aResult);
-+    return ProfileErrorDialog(lf, lf, PROFILE_STATUS_IS_LOCKED, unlocker,
-+                              aNative, aResult);
-   }
- 
-   ar = CheckArg("createprofile", true, &arg);
-@@ -2501,6 +2575,10 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
-         gDoProfileReset = false;
-       }
- 
-+      ProfileStatus status = CheckProfileWriteAccess(profile);
-+      if (PROFILE_STATUS_OK != status)
-+        return ProfileErrorDialog(profile, status, nullptr, aNative, aResult);
-+
-       nsCOMPtr<nsIProfileUnlocker> unlocker;
-       rv = profile->Lock(getter_AddRefs(unlocker), aResult);
-       if (NS_SUCCEEDED(rv)) {
-@@ -2509,7 +2587,8 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
-         return NS_OK;
-       }
- 
--      return ProfileLockedDialog(profile, unlocker, aNative, aResult);
-+      return ProfileErrorDialog(profile, PROFILE_STATUS_IS_LOCKED, unlocker,
-+                                aNative, aResult);
-     }
- 
-     if (CanShowProfileManager()) {
-@@ -2589,7 +2668,8 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
-           nsCOMPtr<nsIProfileUnlocker> unlocker;
-           rv = profile->Lock(getter_AddRefs(unlocker), &tempProfileLock);
-           if (NS_FAILED(rv))
--            return ProfileLockedDialog(profile, unlocker, aNative, &tempProfileLock);
-+            return ProfileErrorDialog(profile, PROFILE_STATUS_IS_LOCKED,
-+                                      unlocker, aNative, &tempProfileLock);
-         }
- 
-         nsCOMPtr<nsIToolkitProfile> newProfile;
-@@ -2600,6 +2680,10 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
-           gDoProfileReset = false;
-       }
- 
-+      ProfileStatus status = CheckProfileWriteAccess(profile);
-+      if (PROFILE_STATUS_OK != status)
-+        return ProfileErrorDialog(profile, status, nullptr, aNative, aResult);
-+
-       // If you close Firefox and very quickly reopen it, the old Firefox may
-       // still be closing down. Rather than immediately showing the
-       // "Firefox is running but is not responding" message, we spend a few
-@@ -2625,7 +2709,8 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
-         PR_Sleep(kLockRetrySleepMS);
-       } while (TimeStamp::Now() - start < TimeDuration::FromSeconds(kLockRetrySeconds));
- 
--      return ProfileLockedDialog(profile, unlocker, aNative, aResult);
-+      return ProfileErrorDialog(profile, PROFILE_STATUS_IS_LOCKED, unlocker,
-+                                aNative, aResult);
-     }
-   }
- 
diff --git a/projects/instantbird/Improve-profile-access-bug-14631-second.mozpatch b/projects/instantbird/Improve-profile-access-bug-14631-second.mozpatch
deleted file mode 100644
index 3e59cd5..0000000
--- a/projects/instantbird/Improve-profile-access-bug-14631-second.mozpatch
+++ /dev/null
@@ -1,182 +0,0 @@
-commit 303992b0684036f6f23d1ca7f76b360930f510db
-Author: Kathy Brade <brade at pearlcrescent.com>
-Date:   Fri Feb 27 10:38:40 2015 -0500
-
-    Bug 14631: Improve profile access error msgs (strings).
-    
-    To allow for localization, get profile-related error strings from Torbutton.
-    Use app display name ("Tor Browser") in profile-related error alerts.
-
-diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build
-index d8127a6..3e6a3b6 100644
---- a/toolkit/xre/moz.build
-+++ b/toolkit/xre/moz.build
-@@ -116,8 +116,8 @@ FINAL_LIBRARY = 'xul'
- if CONFIG['MOZ_GL_DEFAULT_PROVIDER'] == 'GLX':
-     DEFINES['USE_GLX_TEST'] = True
- 
--for var in ('MOZ_APP_NAME', 'MOZ_APP_BASENAME', 'MOZ_APP_VERSION', 'OS_TARGET',
--            'MOZ_WIDGET_TOOLKIT'):
-+for var in ('MOZ_APP_NAME', 'MOZ_APP_BASENAME', 'MOZ_APP_DISPLAYNAME',
-+            'MOZ_APP_VERSION', 'OS_TARGET', 'MOZ_WIDGET_TOOLKIT'):
-     DEFINES[var] = '"%s"' % CONFIG[var]
- 
- if CONFIG['MOZ_UPDATER'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
-diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
-index d82f303..a7c7d75 100644
---- a/toolkit/xre/nsAppRunner.cpp
-+++ b/toolkit/xre/nsAppRunner.cpp
-@@ -1913,6 +1913,104 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
-   return NS_ERROR_LAUNCHED_CHILD_PROCESS;
- }
- 
-+static nsresult
-+GetOverrideStringBundleForLocale(nsIStringBundleService* aSBS,
-+                                 const char* aTorbuttonURI, const char* aLocale,
-+                                 nsIStringBundle* *aResult)
-+{
-+  NS_ENSURE_ARG(aSBS);
-+  NS_ENSURE_ARG(aTorbuttonURI);
-+  NS_ENSURE_ARG(aLocale);
-+  NS_ENSURE_ARG(aResult);
-+
-+  const char* kFormatStr = "jar:%s!/chrome/locale/%s/torbutton.properties";
-+  nsPrintfCString strBundleURL(kFormatStr, aTorbuttonURI, aLocale);
-+  nsresult rv = aSBS->CreateBundle(strBundleURL.get(), aResult);
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  // To ensure that we have a valid string bundle, try to retrieve a string
-+  // that we know exists.
-+  nsXPIDLString val;
-+  rv = (*aResult)->GetStringFromName(MOZ_UTF16("profileProblemTitle"),
-+                                     getter_Copies(val));
-+  if (!NS_SUCCEEDED(rv))
-+    *aResult = nullptr;  // No good.  Discard it.
-+
-+  return rv;
-+}
-+
-+static void
-+GetOverrideStringBundle(nsIStringBundleService* aSBS, nsIStringBundle* *aResult)
-+{
-+  if (!aSBS || !aResult)
-+    return;
-+
-+  *aResult = nullptr;
-+
-+  // Build Torbutton file URI string by starting from the profiles directory.
-+  nsXREDirProvider* dirProvider = nsXREDirProvider::GetSingleton();
-+  if (!dirProvider)
-+    return;
-+
-+  bool persistent = false; // ignored
-+  nsCOMPtr<nsIFile> profilesDir;
-+  nsresult rv = dirProvider->GetFile(NS_APP_USER_PROFILES_ROOT_DIR, &persistent,
-+                                     getter_AddRefs(profilesDir));
-+  if (NS_FAILED(rv))
-+    return;
-+
-+  // Create file URI, extract as string, and append Torbutton xpi relative path.
-+  nsCOMPtr<nsIURI> uri;
-+  nsAutoCString uriString;
-+  if (NS_FAILED(NS_NewFileURI(getter_AddRefs(uri), profilesDir)) ||
-+      NS_FAILED(uri->GetSpec(uriString))) {
-+    return;
-+  }
-+
-+  uriString.Append("profile.default/extensions/torbutton at torproject.org.xpi");
-+
-+  nsCString userAgentLocale;
-+  if (!NS_SUCCEEDED(Preferences::GetCString("general.useragent.locale",
-+                                            &userAgentLocale))) {
-+    return;
-+  }
-+
-+  rv = GetOverrideStringBundleForLocale(aSBS, uriString.get(),
-+                                   userAgentLocale.get(), aResult);
-+  if (NS_FAILED(rv)) {
-+    // Try again using base locale, e.g., "en" vs. "en-US".
-+    int16_t offset = userAgentLocale.FindChar('-', 1);
-+    if (offset > 0) {
-+      nsAutoCString shortLocale(Substring(userAgentLocale, 0, offset));
-+      rv = GetOverrideStringBundleForLocale(aSBS, uriString.get(),
-+                                       shortLocale.get(), aResult);
-+    }
-+  }
-+}
-+
-+static nsresult
-+GetFormattedString(nsIStringBundle* aOverrideBundle,
-+                   nsIStringBundle* aMainBundle,
-+                   const char16_t* aName,
-+                   const char16_t** aParams, uint32_t aLength,
-+                   char16_t* *aResult)
-+{
-+  NS_ENSURE_ARG(aName);
-+  NS_ENSURE_ARG(aResult);
-+
-+  nsresult rv = NS_ERROR_FAILURE;
-+  if (aOverrideBundle) {
-+    rv = aOverrideBundle->FormatStringFromName(aName, aParams, aLength,
-+                                               aResult);
-+  }
-+
-+  // If string was not found in override bundle, use main (browser) bundle.
-+  if (NS_FAILED(rv) && aMainBundle)
-+    rv = aMainBundle->FormatStringFromName(aName, aParams, aLength, aResult);
-+
-+  return rv;
-+}
-+
- enum ProfileStatus {
-   PROFILE_STATUS_OK,
-   PROFILE_STATUS_ACCESS_DENIED,
-@@ -1983,7 +2081,10 @@ ProfileErrorDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
-     sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
-     NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
- 
--    NS_ConvertUTF8toUTF16 appName(gAppData->name);
-+    nsCOMPtr<nsIStringBundle> overrideSB;
-+    GetOverrideStringBundle(sbs, getter_AddRefs(overrideSB));
-+
-+    NS_ConvertUTF8toUTF16 appName(MOZ_APP_DISPLAYNAME);
-     const char16_t* params[] = {appName.get(), appName.get()};
- 
-     nsXPIDLString killMessage;
-@@ -1998,21 +2099,23 @@ ProfileErrorDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
- #endif
-     static const char16_t kAccessDenied[] = MOZ_UTF16("profileAccessDenied");
-  
--    const char16_t *errorKey = aUnlocker ? kRestartUnlocker
-+    const char16_t* errorKey = aUnlocker ? kRestartUnlocker
-                                          : kRestartNoUnlocker;
-     if (PROFILE_STATUS_READ_ONLY == aStatus)
-       errorKey = kReadOnly;
-     else if (PROFILE_STATUS_ACCESS_DENIED == aStatus)
-       errorKey = kAccessDenied;
--    sb->FormatStringFromName(errorKey, params, 2, getter_Copies(killMessage));
-+    GetFormattedString(overrideSB, sb, errorKey, params, 2,
-+                       getter_Copies(killMessage));
- 
--    const char16_t *titleKey = ((PROFILE_STATUS_READ_ONLY == aStatus) ||
-+    const char16_t* titleKey = ((PROFILE_STATUS_READ_ONLY == aStatus) ||
-                                 (PROFILE_STATUS_ACCESS_DENIED == aStatus))
-                                    ? MOZ_UTF16("profileProblemTitle")
-                                    : MOZ_UTF16("restartTitle");
- 
-     nsXPIDLString killTitle;
--    sb->FormatStringFromName(titleKey, params, 1, getter_Copies(killTitle));
-+    GetFormattedString(overrideSB, sb, titleKey, params, 1,
-+                       getter_Copies(killTitle));
- 
-     if (!killMessage || !killTitle)
-       return NS_ERROR_FAILURE;
-@@ -2088,7 +2191,7 @@ ProfileMissingDialog(nsINativeAppSupport* aNative)
-     sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
-     NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
-   
--    NS_ConvertUTF8toUTF16 appName(gAppData->name);
-+    NS_ConvertUTF8toUTF16 appName(MOZ_APP_DISPLAYNAME);
-     const char16_t* params[] = {appName.get(), appName.get()};
-   
-     nsXPIDLString missingMessage;
diff --git a/projects/instantbird/Mac-outside-app-data-bug-13252.mozpatch b/projects/instantbird/Mac-outside-app-data-bug-13252.mozpatch
deleted file mode 100644
index 4501ee7..0000000
--- a/projects/instantbird/Mac-outside-app-data-bug-13252.mozpatch
+++ /dev/null
@@ -1,1124 +0,0 @@
-From 4f8084edd80a3726e9a995ff3407331807401558 Mon Sep 17 00:00:00 2001
-From: Kathy Brade <brade at pearlcrescent.com>
-Date: Fri, 18 Mar 2016 14:20:02 -0400
-Subject: Bug 13252 - Do not store data in the app bundle
-
-Add an --enable-tor-browser-data-outside-app-dir configure option.
-When this is enabled, all user data is stored in a directory named
-TorBrowser-Data which is located next to the application directory.
-
-The first time an updated browser is opened, migrate the existing
-browser profile, Tor data directory contents, and UpdateInfo to the
-TorBrowser-Data directory. If migration of the browser profile
-fails, an error alert is displayed and the browser is started
-using a new profile.
-
-Display an informative error messages if the TorBrowser-Data
-directory cannot be created due to an "access denied" or a
-"read only volume" error.
-
-Add support for installing "override" preferences within the user's
-browser profile. All .js files in distribution/preferences (on
-Mac OS, Contents/Resources/distribution/preferences) will be copied
-to the preferences directory within the user's browser profile when
-the profile is created and each time Tor Browser is updated. This
-mechanism will be used to install the extension-overrides.js file
-into the profile.
-
-On Mac OS, add support for the --invisible command line option which
-is used by the meek-http-helper to avoid showing an icon for the
-helper browser on the dock.
-
-diff --git a/configure.in b/configure.in
-index e9fb038..885ee84 100644
---- a/configure.in
-+++ b/configure.in
-@@ -6538,9 +6538,20 @@ if test -n "$TOR_BROWSER_UPDATE"; then
-     AC_DEFINE(TOR_BROWSER_UPDATE)
- fi
- 
-+MOZ_ARG_ENABLE_BOOL(tor-browser-data-outside-app-dir,
-+[  --enable-tor-browser-data-outside-app-dir
-+                          Enable Tor Browser data outside of app directory],
-+    TOR_BROWSER_DATA_OUTSIDE_APP_DIR=1,
-+    TOR_BROWSER_DATA_OUTSIDE_APP_DIR= )
-+
-+if test -n "$TOR_BROWSER_DATA_OUTSIDE_APP_DIR"; then
-+    AC_DEFINE(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+fi
-+
- AC_DEFINE_UNQUOTED(TOR_BROWSER_VERSION,"$TOR_BROWSER_VERSION")
- AC_SUBST(TOR_BROWSER_VERSION)
- AC_SUBST(TOR_BROWSER_UPDATE)
-+AC_SUBST(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
- 
- dnl ========================================================
- dnl build the tests by default
-diff --git a/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties b/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties
-index 3cf48ff..f5cb77a 100644
---- a/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties
-+++ b/toolkit/locales/en-US/chrome/mozapps/profile/profileSelection.properties
-@@ -17,6 +17,7 @@ profileProblemTitle=%S Profile Problem
- profileReadOnly=You cannot run %S from a read-only file system.  Please copy %S to another location before trying to use it.
- profileReadOnlyMac=You cannot run %S from a read-only file system.  Please copy %S to your Desktop or Applications folder before trying to use it.
- profileAccessDenied=%S does not have permission to access the profile. Please adjust your file system permissions and try again.
-+profileMigrationFailed=Migration of your existing %S profile failed.\nNew settings will be used.
- # Profile manager
- # LOCALIZATION NOTE (profileTooltip): First %S is the profile name, second %S is the path to the profile folder.
- profileTooltip=Profile: '%S' - Path: '%S'
-diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
-index a453062..e2d4e44 100644
---- a/toolkit/mozapps/extensions/AddonManager.jsm
-+++ b/toolkit/mozapps/extensions/AddonManager.jsm
-@@ -45,6 +45,11 @@ const PREF_MATCH_OS_LOCALE            = "intl.locale.matchOS";
- const PREF_SELECTED_LOCALE            = "general.useragent.locale";
- const UNKNOWN_XPCOM_ABI               = "unknownABI";
- 
-+#ifdef TOR_BROWSER_VERSION
-+#expand const TOR_BROWSER_VERSION = __TOR_BROWSER_VERSION__;
-+const PREF_EM_LAST_TORBROWSER_VERSION = "extensions.lastTorBrowserVersion";
-+#endif
-+
- const PREF_MIN_WEBEXT_PLATFORM_VERSION = "extensions.webExtensionsMinPlatformVersion";
- 
- const UPDATE_REQUEST_VERSION          = 2;
-@@ -910,6 +915,30 @@ var AddonManagerInternal = {
-         this.validateBlocklist();
-       }
- 
-+#ifdef TOR_BROWSER_VERSION
-+      // To ensure that extension override prefs are reinstalled into the
-+      // user's profile after each update, set appChanged = true if the
-+      // Mozilla app version has not changed but the Tor Browser version
-+      // has changed.
-+      let tbChanged = undefined;
-+      try {
-+        tbChanged = TOR_BROWSER_VERSION !=
-+                   Services.prefs.getCharPref(PREF_EM_LAST_TORBROWSER_VERSION);
-+      }
-+      catch (e) { }
-+      if (tbChanged !== false) {
-+        // Because PREF_EM_LAST_TORBROWSER_VERSION was not present in older
-+        // versions of Tor Browser, an app change is indicated when tbChanged
-+        // is undefined or true.
-+        if (appChanged === false) {
-+          appChanged = true;
-+        }
-+
-+        Services.prefs.setCharPref(PREF_EM_LAST_TORBROWSER_VERSION,
-+                                   TOR_BROWSER_VERSION);
-+      }
-+#endif
-+
-       if (!MOZ_COMPATIBILITY_NIGHTLY) {
-         PREF_EM_CHECK_COMPATIBILITY = PREF_EM_CHECK_COMPATIBILITY_BASE + "." +
-                                       Services.appinfo.version.replace(BRANCH_REGEXP, "$1");
-diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
-index 7a58a7d..51c51b8 100644
---- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
-+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
-@@ -130,6 +130,7 @@ const URI_EXTENSION_STRINGS           = "chrome://mozapps/locale/extensions/exte
- const STRING_TYPE_NAME                = "type.%ID%.name";
- 
- const DIR_EXTENSIONS                  = "extensions";
-+const DIR_PREFERENCES                 = "preferences";
- const DIR_SYSTEM_ADDONS               = "features";
- const DIR_STAGE                       = "staged";
- const DIR_TRASH                       = "trash";
-@@ -3510,6 +3511,58 @@ this.XPIProvider = {
-     return changed;
-   },
- 
-+   /**
-+   * Installs any preference files located in the preferences directory of the
-+   * application's distribution specific directory into the profile.
-+   *
-+   * @return true if any preference files were installed
-+   */
-+  installDistributionPreferences: function XPI_installDistributionPreferences() {
-+    let distroDir;
-+    try {
-+      distroDir = FileUtils.getDir(KEY_APP_DISTRIBUTION, [DIR_PREFERENCES]);
-+    }
-+    catch (e) {
-+      return false;
-+    }
-+
-+    if (!distroDir.exists() || !distroDir.isDirectory())
-+      return false;
-+
-+    let changed = false;
-+    let prefOverrideDir = Services.dirsvc.get("PrefDOverride", Ci.nsIFile);
-+
-+    let entries = distroDir.directoryEntries
-+                           .QueryInterface(Ci.nsIDirectoryEnumerator);
-+    let entry;
-+    while ((entry = entries.nextFile)) {
-+      let fileName = entry.leafName;
-+      if (!entry.isFile() ||
-+          fileName.substring(fileName.length - 3).toLowerCase() != ".js") {
-+        logger.debug("Ignoring distribution preference that isn't a JS file: "
-+                     + entry.path);
-+        continue;
-+      }
-+
-+      try {
-+        if (!prefOverrideDir.exists()) {
-+          prefOverrideDir.create(Ci.nsIFile.DIRECTORY_TYPE,
-+                                 FileUtils.PERMS_DIRECTORY);
-+        }
-+
-+        entry.copyTo(prefOverrideDir, null);
-+        changed = true;
-+      } catch (e) {
-+        logger.debug("Unable to copy " + entry.path + " to " +
-+                     prefOverrideDir.path);
-+      }
-+    }
-+
-+    entries.close();
-+
-+    return changed;
-+  },
-+
-   /**
-    * Imports the xpinstall permissions from preferences into the permissions
-    * manager for the user to change later.
-@@ -3583,6 +3636,12 @@ this.XPIProvider = {
-       if (updated) {
-         updateReasons.push("installDistributionAddons");
-       }
-+
-+      // Also copy distribution preferences to the user's profile.
-+      updated = this.installDistributionPreferences();
-+      if (updated) {
-+        updateReasons.push("installDistributionPreferences");
-+      }
-     }
- 
-     // Telemetry probe added around getInstallState() to check perf
-diff --git a/toolkit/mozapps/extensions/moz.build b/toolkit/mozapps/extensions/moz.build
-index 8fbd96d..06091a5 100644
---- a/toolkit/mozapps/extensions/moz.build
-+++ b/toolkit/mozapps/extensions/moz.build
-@@ -30,12 +30,15 @@ EXTRA_PP_COMPONENTS += [
- ]
- 
- EXTRA_JS_MODULES += [
--    'AddonManager.jsm',
-     'ChromeManifestParser.jsm',
-     'DeferredSave.jsm',
-     'LightweightThemeManager.jsm',
- ]
- 
-+EXTRA_PP_JS_MODULES += [
-+    'AddonManager.jsm',
-+]
-+
- JAR_MANIFESTS += ['jar.mn']
- 
- EXPORTS.mozilla += [
-diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
-index a3a2857..20be296 100644
---- a/toolkit/xre/nsAppRunner.cpp
-+++ b/toolkit/xre/nsAppRunner.cpp
-@@ -1949,11 +1949,30 @@ GetOverrideStringBundle(nsIStringBundleService* aSBS, nsIStringBundle* *aResult)
- 
-   *aResult = nullptr;
- 
--  // Build Torbutton file URI string by starting from the profiles directory.
-   nsXREDirProvider* dirProvider = nsXREDirProvider::GetSingleton();
-   if (!dirProvider)
-     return;
- 
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+  // Build Torbutton file URI by starting from the distribution directory.
-+  bool persistent = false; // ignored
-+  nsCOMPtr<nsIFile> distribDir;
-+  nsresult rv = dirProvider->GetFile(XRE_APP_DISTRIBUTION_DIR, &persistent,
-+                                     getter_AddRefs(distribDir));
-+  if (NS_FAILED(rv))
-+    return;
-+
-+  // Create file URI, extract as string, and append Torbutton xpi relative path.
-+  nsCOMPtr<nsIURI> uri;
-+  nsAutoCString uriString;
-+  if (NS_FAILED(NS_NewFileURI(getter_AddRefs(uri), distribDir)) ||
-+      NS_FAILED(uri->GetSpec(uriString))) {
-+    return;
-+  }
-+
-+  uriString.Append("extensions/torbutton at torproject.org.xpi");
-+#else
-+  // Build Torbutton file URI string by starting from the profiles directory.
-   bool persistent = false; // ignored
-   nsCOMPtr<nsIFile> profilesDir;
-   nsresult rv = dirProvider->GetFile(NS_APP_USER_PROFILES_ROOT_DIR, &persistent,
-@@ -1970,6 +1989,7 @@ GetOverrideStringBundle(nsIStringBundleService* aSBS, nsIStringBundle* *aResult)
-   }
- 
-   uriString.Append("profile.default/extensions/torbutton at torproject.org.xpi");
-+#endif
- 
-   nsCString userAgentLocale;
-   if (!NS_SUCCEEDED(Preferences::GetCString("general.useragent.locale",
-@@ -2019,6 +2039,9 @@ enum ProfileStatus {
-   PROFILE_STATUS_READ_ONLY,
-   PROFILE_STATUS_IS_LOCKED,
-   PROFILE_STATUS_OTHER_ERROR
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+  , PROFILE_STATUS_MIGRATION_FAILED
-+#endif
- };
- 
- static const char kProfileProperties[] =
-@@ -2058,6 +2081,8 @@ private:
- 
- } // namespace
- 
-+// If aUnlocker is NULL, it is also OK for the following arguments to be NULL:
-+//   aProfileDir, aProfileLocalDir, aResult.
- static ReturnAbortOnError
- ProfileErrorDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
-                    ProfileStatus aStatus, nsIProfileUnlocker* aUnlocker,
-@@ -2069,7 +2094,8 @@ ProfileErrorDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
-   rv = xpcom.Initialize();
-   NS_ENSURE_SUCCESS(rv, rv);
- 
--  mozilla::Telemetry::WriteFailedProfileLock(aProfileDir);
-+  if (aProfileDir)
-+    mozilla::Telemetry::WriteFailedProfileLock(aProfileDir);
- 
-   rv = xpcom.SetWindowCreator(aNative);
-   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
-@@ -2100,21 +2126,27 @@ ProfileErrorDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
-     static const char16_t kReadOnly[] = MOZ_UTF16("profileReadOnlyMac");
- #endif
-     static const char16_t kAccessDenied[] = MOZ_UTF16("profileAccessDenied");
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+    static const char16_t kMigrationFailed[] = MOZ_UTF16("profileMigrationFailed");
-+#endif
-  
-     const char16_t* errorKey = aUnlocker ? kRestartUnlocker
-                                          : kRestartNoUnlocker;
-+    const char16_t* titleKey = MOZ_UTF16("profileProblemTitle");
-     if (PROFILE_STATUS_READ_ONLY == aStatus)
-       errorKey = kReadOnly;
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+    else if (PROFILE_STATUS_MIGRATION_FAILED == aStatus)
-+      errorKey = kMigrationFailed;
-+#endif
-     else if (PROFILE_STATUS_ACCESS_DENIED == aStatus)
-       errorKey = kAccessDenied;
-+    else
-+      titleKey = MOZ_UTF16("restartTitle");
-+
-     GetFormattedString(overrideSB, sb, errorKey, params, 2,
-                        getter_Copies(killMessage));
- 
--    const char16_t* titleKey = ((PROFILE_STATUS_READ_ONLY == aStatus) ||
--                                (PROFILE_STATUS_ACCESS_DENIED == aStatus))
--                                   ? MOZ_UTF16("profileProblemTitle")
--                                   : MOZ_UTF16("restartTitle");
--
-     nsXPIDLString killTitle;
-     GetFormattedString(overrideSB, sb, titleKey, params, 1,
-                        getter_Copies(killTitle));
-@@ -2158,7 +2190,8 @@ ProfileErrorDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
-       }
-     } else {
- #ifdef MOZ_WIDGET_ANDROID
--      if (mozilla::widget::GeckoAppShell::UnlockProfile()) {
-+      if (aProfileDir && aProfileLocalDir && aResult &&
-+          mozilla::widget::GeckoAppShell::UnlockProfile()) {
-         return NS_LockProfilePath(aProfileDir, aProfileLocalDir, 
-                                   nullptr, aResult);
-       }
-@@ -2449,6 +2482,223 @@ static ProfileStatus CheckProfileWriteAccess(nsIToolkitProfile* aProfile)
-   return CheckProfileWriteAccess(profileDir);
- }
- 
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+// Obtain an nsIFile for the app root directory, e.g., TorBrowser.app on
-+// Mac OS and the directory that contains Browser/ on Linux and Windows.
-+static nsresult GetAppRootDir(nsIFile *aAppDir, nsIFile **aAppRootDir)
-+{
-+  NS_ENSURE_ARG_POINTER(aAppDir);
-+
-+#ifdef XP_MACOSX
-+  nsCOMPtr<nsIFile> tmpDir;
-+  nsresult rv = aAppDir->GetParent(getter_AddRefs(tmpDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  return tmpDir->GetParent(aAppRootDir);
-+#else
-+  return aAppDir->Clone(aAppRootDir);
-+#endif
-+}
-+
-+static ProfileStatus CheckTorBrowserDataWriteAccess(nsIFile *aAppDir)
-+{
-+  // Check whether we can write to the directory that will contain
-+  // TorBrowser-Data.
-+  nsCOMPtr<nsIFile> tbDataDir;
-+  nsXREDirProvider* dirProvider = nsXREDirProvider::GetSingleton();
-+  if (!dirProvider)
-+    return PROFILE_STATUS_OTHER_ERROR;
-+  nsresult rv =
-+              dirProvider->GetTorBrowserUserDataDir(getter_AddRefs(tbDataDir));
-+  NS_ENSURE_SUCCESS(rv, PROFILE_STATUS_OTHER_ERROR);
-+  nsCOMPtr<nsIFile> tbDataDirParent;
-+  rv = tbDataDir->GetParent(getter_AddRefs(tbDataDirParent));
-+  NS_ENSURE_SUCCESS(rv, PROFILE_STATUS_OTHER_ERROR);
-+  return CheckProfileWriteAccess(tbDataDirParent);
-+}
-+
-+// Move the directory defined by combining aSrcParentDir and aSrcRelativePath
-+// to the location defined by combining aDestParentDir and aDestRelativePath.
-+// If the source directory does not exist, no changes are made and NS_OK is
-+// returned.
-+// If the destination directory exists, its contents are removed after the
-+// source directory has been moved (if the move fails for some reason, the
-+// original contents of the destination directory are restored).
-+static nsresult
-+migrateOneTorBrowserDataDir(nsIFile *aSrcParentDir,
-+                            const nsACString &aSrcRelativePath,
-+                            nsIFile *aDestParentDir,
-+                            const nsACString &aDestRelativePath)
-+{
-+  NS_ENSURE_ARG_POINTER(aSrcParentDir);
-+  NS_ENSURE_ARG_POINTER(aDestParentDir);
-+
-+  nsCOMPtr<nsIFile> srcDir;
-+  nsresult rv = aSrcParentDir->Clone(getter_AddRefs(srcDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  if (!aSrcRelativePath.IsEmpty()) {
-+    rv = srcDir->AppendRelativeNativePath(aSrcRelativePath);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+  }
-+
-+  bool srcDirExists = false;
-+  srcDir->Exists(&srcDirExists);
-+  if (!srcDirExists)
-+    return NS_OK;   // Old data does not exist; skip migration.
-+
-+  nsCOMPtr<nsIFile> destDir;
-+  rv = aDestParentDir->Clone(getter_AddRefs(destDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  if (!aDestRelativePath.IsEmpty()) {
-+    rv = destDir->AppendRelativeNativePath(aDestRelativePath);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+  }
-+
-+  nsCOMPtr<nsIFile> destParentDir;
-+  rv = destDir->GetParent(getter_AddRefs(destParentDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  nsAutoString destLeafName;
-+  rv = destDir->GetLeafName(destLeafName);
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  bool destDirExists = false;
-+  destDir->Exists(&destDirExists);
-+  nsCOMPtr<nsIFile> tmpDir;
-+  if (destDirExists) {
-+    // The destination directory exists. When we are migrating an old
-+    // Tor Browser profile, we expect this to be the case because we first
-+    // allow the standard Mozilla startup code to create a new profile as
-+    // usual, and then later (here) we set aside that profile directory and
-+    // replace it with the old Tor Browser profile that we need to migrate.
-+    // For now, move the Mozilla profile directory aside and set tmpDir to
-+    // point to its new, temporary location in case migration fails and we
-+    // need to restore the profile that was created by the Mozilla code.
-+    nsAutoString tmpName(NS_LITERAL_STRING("tmp"));
-+    rv = destDir->RenameTo(nullptr, tmpName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    nsCOMPtr<nsIFile> dir;
-+    rv = destParentDir->Clone(getter_AddRefs(dir));
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    rv = dir->Append(tmpName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    tmpDir = dir;
-+  }
-+
-+  // Move the old directory to the new location using MoveTo() so that
-+  // timestamps are preserved (MoveTo() is atomic as long as the source and
-+  // destination are on the same volume).
-+  rv = srcDir->MoveTo(destParentDir, destLeafName);
-+  if (NS_FAILED(rv)) {
-+    // The move failed. Restore the directory that we were trying to replace.
-+    if (tmpDir)
-+      tmpDir->RenameTo(nullptr, destLeafName);
-+    return rv;
-+  }
-+
-+  // Success. If we set aside a directory earlier by renaming it, remove it.
-+  if (tmpDir)
-+    tmpDir->Remove(true);
-+
-+  return NS_OK;
-+}
-+
-+static nsresult
-+deleteFile(nsIFile *aParentDir, const nsACString &aRelativePath)
-+{
-+  NS_ENSURE_ARG_POINTER(aParentDir);
-+
-+  nsCOMPtr<nsIFile> file;
-+  nsresult rv = aParentDir->Clone(getter_AddRefs(file));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  if (!aRelativePath.IsEmpty()) {
-+    rv = file->AppendRelativeNativePath(aRelativePath);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+  }
-+
-+  return file->Remove(false);
-+}
-+
-+// When this function is called, aProfile is a brand new profile and
-+// aAppDir is the directory that contains the firefox executable.
-+// Our strategy is to check if an old "in application" profile exists at
-+// <AppRootDir>/TorBrowser/Data/Browser/profile.default. If so, we set
-+// aside the new profile directory and replace it with the old one.
-+// We use a similar approach for the Tor data and UpdateInfo directories.
-+static nsresult
-+migrateInAppTorBrowserProfile(nsIToolkitProfile *aProfile, nsIFile *aAppDir)
-+{
-+  NS_ENSURE_ARG_POINTER(aProfile);
-+  NS_ENSURE_ARG_POINTER(aAppDir);
-+
-+  nsCOMPtr<nsIFile> appRootDir;
-+  nsresult rv = GetAppRootDir(aAppDir, getter_AddRefs(appRootDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  // Create an nsIFile for the old <AppRootDir>/TorBrowser directory.
-+  nsCOMPtr<nsIFile> oldTorBrowserDir;
-+  rv = appRootDir->Clone(getter_AddRefs(oldTorBrowserDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = oldTorBrowserDir->AppendRelativeNativePath(
-+                                        NS_LITERAL_CSTRING("TorBrowser"));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  // Get an nsIFile for the TorBrowser-Data directory.
-+  nsCOMPtr<nsIFile> newTBDataDir;
-+  nsXREDirProvider* dirProvider = nsXREDirProvider::GetSingleton();
-+  if (!dirProvider)
-+    return NS_ERROR_UNEXPECTED;
-+  rv = dirProvider->GetTorBrowserUserDataDir(getter_AddRefs(newTBDataDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+
-+  // Try to migrate the browser profile. If this fails, we return an error
-+  // code and we do not try to migrate any other data.
-+  nsCOMPtr<nsIFile> newProfileDir;
-+  rv = aProfile->GetRootDir(getter_AddRefs(newProfileDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  nsAutoCString path(NS_LITERAL_CSTRING("Data" XPCOM_FILE_PATH_SEPARATOR
-+                    "Browser" XPCOM_FILE_PATH_SEPARATOR "profile.default"));
-+  rv = migrateOneTorBrowserDataDir(oldTorBrowserDir, path,
-+                                   newProfileDir, NS_LITERAL_CSTRING(""));
-+  NS_ENSURE_SUCCESS(rv, rv);  // Return immediately upon failure.
-+
-+  // Try to migrate the Tor data directory but do not return upon failure.
-+  nsAutoCString torDataDirPath(NS_LITERAL_CSTRING("Data"
-+                                        XPCOM_FILE_PATH_SEPARATOR "Tor"));
-+  rv = migrateOneTorBrowserDataDir(oldTorBrowserDir, torDataDirPath,
-+                                   newTBDataDir, NS_LITERAL_CSTRING("Tor"));
-+  if (NS_SUCCEEDED(rv)) {
-+    // Make a "best effort" attempt to remove the Tor data files that should
-+    // no longer be stored in the Tor user data directory (they have been
-+    // relocated to a read-only Tor directory, e.g.,
-+    // TorBrowser.app/Contents/Resources/TorBrowser/Tor.
-+    deleteFile(newTBDataDir,
-+         NS_LITERAL_CSTRING("Tor" XPCOM_FILE_PATH_SEPARATOR "geoip"));
-+    deleteFile(newTBDataDir,
-+         NS_LITERAL_CSTRING("Tor" XPCOM_FILE_PATH_SEPARATOR "geoip6"));
-+    deleteFile(newTBDataDir,
-+         NS_LITERAL_CSTRING("Tor" XPCOM_FILE_PATH_SEPARATOR "torrc-defaults"));
-+  }
-+
-+  // Try to migrate the UpdateInfo directory.
-+  nsCOMPtr<nsIFile> newUpdateInfoDir;
-+  nsresult rv2 = dirProvider->GetUpdateRootDir(
-+                                            getter_AddRefs(newUpdateInfoDir));
-+  if (NS_SUCCEEDED(rv2)) {
-+    nsAutoCString updateInfoPath(NS_LITERAL_CSTRING("UpdateInfo"));
-+    rv2 = migrateOneTorBrowserDataDir(oldTorBrowserDir, updateInfoPath,
-+                                      newUpdateInfoDir, NS_LITERAL_CSTRING(""));
-+  }
-+
-+  // If all pieces of the migration succeeded, remove the old TorBrowser
-+  // directory.
-+  if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2)) {
-+    oldTorBrowserDir->Remove(true);
-+  }
-+
-+  return NS_OK;
-+}
-+#endif
-+
- static bool gDoMigration = false;
- static bool gDoProfileReset = false;
- 
-@@ -2461,7 +2711,8 @@ static bool gDoProfileReset = false;
- // 5) if there are *no* profiles, set up profile-migration
- // 6) display the profile-manager UI
- static nsresult
--SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, nsINativeAppSupport* aNative,
-+SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc,
-+              nsIFile *aAppDir, nsINativeAppSupport* aNative,
-               bool* aStartOffline, nsACString* aProfileName)
- {
-   StartupTimeline::Record(StartupTimeline::SELECT_PROFILE);
-@@ -2742,6 +2993,20 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
-       aProfileSvc->SetDefaultProfile(profile);
- #endif
-       aProfileSvc->Flush();
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+      // Handle migration from an older version of Tor Browser in which the
-+      // user data was stored inside the application directory.
-+      rv = migrateInAppTorBrowserProfile(profile, aAppDir);
-+      if (!NS_SUCCEEDED(rv)) {
-+        // Display an error alert and continue startup. Since XPCOM was
-+        // initialized in a limited way inside ProfileErrorDialog() and
-+        // because it cannot be reinitialized, use LaunchChild() to start
-+        // the browser.
-+        ProfileErrorDialog(profile, PROFILE_STATUS_MIGRATION_FAILED, nullptr,
-+                           aNative, aResult);
-+        return LaunchChild(aNative);
-+      }
-+#endif
-       rv = profile->Lock(nullptr, aResult);
-       if (NS_SUCCEEDED(rv)) {
-         if (aProfileName)
-@@ -3313,6 +3578,14 @@ XREMain::XRE_mainInit(bool* aExitFlag)
-     NS_BREAK();
- #endif
- 
-+#if defined(XP_MACOSX) && defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+  bool hideDockIcon = (CheckArg("invisible") == ARG_FOUND);
-+  if (hideDockIcon) {
-+    ProcessSerialNumber psn = { 0, kCurrentProcess };
-+    TransformProcessType(&psn, kProcessTransformToBackgroundApplication);
-+  }
-+#endif
-+
- #ifdef USE_GLX_TEST
-   // bug 639842 - it's very important to fire this process BEFORE we set up
-   // error handling. indeed, this process is expected to be crashy, and we
-@@ -4073,6 +4346,22 @@ XREMain::XRE_mainStartup(bool* aExitFlag)
- #endif
- 
-   rv = NS_NewToolkitProfileService(getter_AddRefs(mProfileSvc));
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+  if (NS_FAILED(rv)) {
-+    // NS_NewToolkitProfileService() returns a generic NS_ERROR_FAILURE error
-+    // if creation of the TorBrowser-Data directory fails due to access denied
-+    // or because of a read-only disk volume. Do an extra check here to detect
-+    // these errors so we can display an informative error message.
-+    ProfileStatus status = CheckTorBrowserDataWriteAccess(exeDir);
-+    if ((PROFILE_STATUS_ACCESS_DENIED == status) ||
-+        (PROFILE_STATUS_READ_ONLY == status)) {
-+      ProfileErrorDialog(nullptr, nullptr, status, nullptr, mNativeApp,
-+                        nullptr);
-+      return 1;
-+    }
-+  }
-+#endif
-+
-   if (rv == NS_ERROR_FILE_ACCESS_DENIED) {
-     PR_fprintf(PR_STDERR, "Error: Access was denied while trying to open files in " \
-                 "your profile directory.\n");
-@@ -4083,8 +4372,8 @@ XREMain::XRE_mainStartup(bool* aExitFlag)
-     return 1;
-   }
- 
--  rv = SelectProfile(getter_AddRefs(mProfileLock), mProfileSvc, mNativeApp, &mStartOffline,
--                      &mProfileName);
-+  rv = SelectProfile(getter_AddRefs(mProfileLock), mProfileSvc, exeDir,
-+                     mNativeApp, &mStartOffline, &mProfileName);
-   if (rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ||
-       rv == NS_ERROR_ABORT) {
-     *aExitFlag = true;
-diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp
-index 403e820..e3c1449 100644
---- a/toolkit/xre/nsXREDirProvider.cpp
-+++ b/toolkit/xre/nsXREDirProvider.cpp
-@@ -38,6 +38,8 @@
- #include "mozilla/Preferences.h"
- #include "mozilla/Telemetry.h"
- 
-+#include "TorFileUtils.h"
-+
- #include <stdlib.h>
- 
- #ifdef XP_WIN
-@@ -1057,40 +1059,48 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
-                                       getter_AddRefs(updRoot));
-   NS_ENSURE_SUCCESS(rv, rv);
- 
--#else
-+#elif defined(TOR_BROWSER_UPDATE)
-+  // For Tor Browser, we store update history, etc. within the UpdateInfo
-+  // directory under the user data directory.
-+  nsresult rv = GetTorBrowserUserDataDir(getter_AddRefs(updRoot));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = updRoot->AppendNative(NS_LITERAL_CSTRING("UpdateInfo"));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+#if defined(XP_MACOSX) && defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-+  // Since the TorBrowser-Data directory may be shared among different
-+  // installations of the application, embed the app path in the update dir
-+  // so that the update history is partitioned. This is much less likely to
-+  // be an issue on Linux or Windows because the Tor Browser packages for
-+  // those platforms include a "container" folder that provides partitioning
-+  // by default, and we do not support use of a shared, OS-recommended area
-+  // for user data on those platforms.
-   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));
-+  rv = GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(appFile));
-   NS_ENSURE_SUCCESS(rv, rv);
-+  nsCOMPtr<nsIFile> appRootDirFile;
-+  nsAutoString appDirPath;
-+  if (NS_FAILED(appFile->GetParent(getter_AddRefs(appRootDirFile))) ||
-+      NS_FAILED(appRootDirFile->GetPath(appDirPath))) {
-+    return NS_ERROR_FAILURE;
-+  }
- 
--#ifdef XP_MACOSX
--#ifdef TOR_BROWSER_UPDATE
--#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
--  // For Tor Browser, we cannot store update history, etc. under the user's
--  // home directory. Instead, we place it under
--  // Tor Browser.app/../TorBrowser-Data/UpdateInfo/
--  nsCOMPtr<nsIFile> appRootDir;
--  rv = GetAppRootDir(getter_AddRefs(appRootDir));
--  NS_ENSURE_SUCCESS(rv, rv);
--  nsCOMPtr<nsIFile> localDir;
--  rv = appRootDir->GetParent(getter_AddRefs(localDir));
--  NS_ENSURE_SUCCESS(rv, rv);
--  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("TorMessenger-Data"
--                                     XPCOM_FILE_PATH_SEPARATOR "UpdateInfo"));
--#else
--  // For Tor Browser, we cannot store update history, etc. under the user's home directory.
--  // Instead, we place it under Tor Browser.app/TorBrowser/UpdateInfo/
--  nsCOMPtr<nsIFile> localDir;
--  rv = GetAppRootDir(getter_AddRefs(localDir));
--  NS_ENSURE_SUCCESS(rv, rv);
--  rv = localDir->AppendNative(NS_LITERAL_CSTRING("TorBrowser"));
-+  int32_t dotIndex = appDirPath.RFind(".app");
-+  if (dotIndex == kNotFound) {
-+    dotIndex = appDirPath.Length();
-+  }
-+  appDirPath = Substring(appDirPath, 1, dotIndex - 1);
-+  rv = updRoot->AppendRelativePath(appDirPath);
-   NS_ENSURE_SUCCESS(rv, rv);
--  rv = localDir->AppendNative(NS_LITERAL_CSTRING("UpdateInfo"));
- #endif
-+#else // ! TOR_BROWSER_UPDATE
-+  nsCOMPtr<nsIFile> appFile;
-+  bool per = false;
-+  nsresult rv = GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(appFile));
-   NS_ENSURE_SUCCESS(rv, rv);
--#else
-+  rv = appFile->GetParent(getter_AddRefs(updRoot));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+#ifdef XP_MACOSX
-   nsCOMPtr<nsIFile> appRootDirFile;
-   nsCOMPtr<nsIFile> localDir;
-   nsAutoString appDirPath;
-@@ -1121,7 +1131,6 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
-       NS_FAILED(localDir->AppendRelativePath(appDirPath))) {
-     return NS_ERROR_FAILURE;
-   }
--#endif
- 
-   localDir.forget(aResult);
-   return NS_OK;
-@@ -1215,7 +1224,7 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
-   NS_ENSURE_SUCCESS(rv, rv);
- 
- #endif // XP_WIN
--#endif
-+#endif // ! TOR_BROWSER_UPDATE
-   updRoot.forget(aResult);
-   return NS_OK;
- }
-@@ -1268,12 +1277,15 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
-   // Copied from nsAppFileLocationProvider (more or less)
-   NS_ENSURE_ARG_POINTER(aFile);
-   nsCOMPtr<nsIFile> localDir;
--
--  nsresult rv = GetAppRootDir(getter_AddRefs(localDir));
-+  nsresult rv = GetTorBrowserUserDataDir(getter_AddRefs(localDir));
-   NS_ENSURE_SUCCESS(rv, rv);
--  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("TorBrowser"
--                                     XPCOM_FILE_PATH_SEPARATOR "Data"
-+
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+  rv = localDir->AppendNative(NS_LITERAL_CSTRING("Browser"));
-+#else
-+  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Data"
-                                      XPCOM_FILE_PATH_SEPARATOR "Browser"));
-+#endif
-   NS_ENSURE_SUCCESS(rv, rv);
- 
-   if (aLocal) {
-@@ -1377,43 +1389,16 @@ nsXREDirProvider::GetUserDataDirectory(nsIFile** aFile, bool aLocal,
- }
- 
- nsresult
--nsXREDirProvider::GetAppRootDir(nsIFile* *aFile)
-+nsXREDirProvider::GetTorBrowserUserDataDir(nsIFile* *aFile)
- {
-   NS_ENSURE_ARG_POINTER(aFile);
--  nsCOMPtr<nsIFile> appRootDir;
--
--  nsresult rv = GetAppDir()->Clone(getter_AddRefs(appRootDir));
-+  nsCOMPtr<nsIFile> exeFile;
-+  bool per = false;
-+  nsresult rv = GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(exeFile));
-   NS_ENSURE_SUCCESS(rv, rv);
--
--  int levelsToRemove = 0; // In FF21+, appDir points to browser subdirectory.
--#if defined(XP_MACOSX)
--  levelsToRemove += 1;
--#endif
--  while (appRootDir && (levelsToRemove > 0)) {
--    // When crawling up the hierarchy, components named "." do not count.
--    nsAutoCString removedName;
--    rv = appRootDir->GetNativeLeafName(removedName);
--    NS_ENSURE_SUCCESS(rv, rv);
--    bool didRemove = !removedName.Equals(".");
--
--    // Remove a directory component.
--    nsCOMPtr<nsIFile> parentDir;
--    rv = appRootDir->GetParent(getter_AddRefs(parentDir));
--    NS_ENSURE_SUCCESS(rv, rv);
--    appRootDir = parentDir;
--
--    if (didRemove)
--      --levelsToRemove;
--  }
--
--  if (!appRootDir)
--    return NS_ERROR_FAILURE;
--
--  appRootDir.forget(aFile);
--  return NS_OK;
-+  return TorBrowser_GetUserDataDir(exeFile, aFile);
- }
- 
--
- nsresult
- nsXREDirProvider::EnsureDirectoryExists(nsIFile* aDirectory)
- {
-diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h
-index b86cc68..e8190e3 100644
---- a/toolkit/xre/nsXREDirProvider.h
-+++ b/toolkit/xre/nsXREDirProvider.h
-@@ -100,6 +100,12 @@ public:
-    */
-   nsresult GetProfileDir(nsIFile* *aResult);
- 
-+  /**
-+   * Get the TorBrowser user data directory by calling the
-+   * TorBrowser_GetUserDataDir() utility function.
-+   */
-+  nsresult GetTorBrowserUserDataDir(nsIFile* *aFile);
-+
- protected:
-   nsresult GetFilesInternal(const char* aProperty, nsISimpleEnumerator** aResult);
-   nsresult GetUserDataDirectoryHome(nsIFile* *aFile, bool aLocal);
-@@ -107,7 +113,6 @@ protected:
- #if defined(XP_UNIX) || defined(XP_MACOSX)
-   static nsresult GetSystemExtensionsDirectory(nsIFile** aFile);
- #endif
--  nsresult GetAppRootDir(nsIFile* *aFile);
-   static nsresult EnsureDirectoryExists(nsIFile* aDirectory);
-   void EnsureProfileFileExists(nsIFile* aFile);
- 
-diff --git a/xpcom/io/TorFileUtils.cpp b/xpcom/io/TorFileUtils.cpp
-new file mode 100644
-index 0000000..2b0b100
---- /dev/null
-+++ b/xpcom/io/TorFileUtils.cpp
-@@ -0,0 +1,130 @@
-+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-+/* This Source Code Form is subject to the terms of the Mozilla Public
-+ * License, v. 2.0. If a copy of the MPL was not distributed with this
-+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-+
-+#include "TorFileUtils.h"
-+
-+static nsresult GetAppRootDir(nsIFile *aExeFile, nsIFile** aFile);
-+
-+//-----------------------------------------------------------------------------
-+NS_METHOD
-+TorBrowser_GetUserDataDir(nsIFile *aExeFile, nsIFile** aFile)
-+{
-+  NS_ENSURE_ARG_POINTER(aFile);
-+  nsCOMPtr<nsIFile> tbDataDir;
-+
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+  nsAutoCString tbDataLeafName(NS_LITERAL_CSTRING("TorMessenger-Data"));
-+  nsCOMPtr<nsIFile> appRootDir;
-+  nsresult rv = GetAppRootDir(aExeFile, getter_AddRefs(appRootDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+#ifndef XP_MACOSX
-+  // On all platforms except Mac OS, we always operate in a "portable" mode
-+  // where the TorBrowser-Data directory is located next to the application.
-+  rv = appRootDir->GetParent(getter_AddRefs(tbDataDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = tbDataDir->AppendNative(tbDataLeafName);
-+  NS_ENSURE_SUCCESS(rv, rv);
-+#else
-+  // For Mac OS, determine whether we should store user data in the OS's
-+  // standard location (i.e., under ~/Library/Application Support). We use
-+  // the OS location if (1) the application is installed in a directory whose
-+  // path contains "/Applications" or (2) the TorBrowser-Data directory does
-+  // not exist and cannot be created (which probably means we lack write
-+  // permission to the directory that contains the application).
-+  nsAutoString appRootPath;
-+  rv = appRootDir->GetPath(appRootPath);
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  bool useOSLocation = (appRootPath.Find("/Applications",
-+                                         true /* ignore case */) >= 0);
-+  if (!useOSLocation) {
-+    // We hope to use the portable (aka side-by-side) approach, but before we
-+    // commit to that, let's ensure that we can create the TorBrowser-Data
-+    // directory. If it already exists, we will try to use it; if not and we
-+    // fail to create it, we will switch to ~/Library/Application Support.
-+    rv = appRootDir->GetParent(getter_AddRefs(tbDataDir));
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    rv = tbDataDir->AppendNative(tbDataLeafName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    bool exists = false;
-+    rv = tbDataDir->Exists(&exists);
-+    if (NS_SUCCEEDED(rv) && !exists)
-+      rv = tbDataDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
-+    useOSLocation = NS_FAILED(rv);
-+  }
-+
-+  if (useOSLocation) {
-+    // We are using ~/Library/Application Support/TorBrowser-Data. We do not
-+    // need to create that directory here because the code in nsXREDirProvider
-+    // will do so (and the user should always have write permission for
-+    // ~/Library/Application Support; if they do not we have no more options).
-+    FSRef fsRef;
-+    OSErr err = ::FSFindFolder(kUserDomain, kApplicationSupportFolderType,
-+                               kCreateFolder, &fsRef);
-+    NS_ENSURE_FALSE(err, NS_ERROR_FAILURE);
-+    // To convert the FSRef returned by FSFindFolder() into an nsIFile that
-+    // points to ~/Library/Application Support, we first create an empty
-+    // nsIFile object (no path) and then use InitWithFSRef() to set the
-+    // path.
-+    rv = NS_NewNativeLocalFile(EmptyCString(), true,
-+                               getter_AddRefs(tbDataDir));
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    nsCOMPtr<nsILocalFileMac> dirFileMac = do_QueryInterface(tbDataDir);
-+    if (!dirFileMac)
-+      return NS_ERROR_UNEXPECTED;
-+    rv = dirFileMac->InitWithFSRef(&fsRef);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    rv = tbDataDir->AppendNative(tbDataLeafName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+  }
-+#endif
-+
-+#else
-+  // User data is embedded within the application directory (i.e.,
-+  // TOR_BROWSER_DATA_OUTSIDE_APP_DIR is not defined).
-+  nsresult rv = GetAppRootDir(aExeFile, getter_AddRefs(tbDataDir));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = tbDataDir->AppendNative(NS_LITERAL_CSTRING("TorBrowser"));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+#endif
-+
-+  tbDataDir.forget(aFile);
-+  return NS_OK;
-+}
-+
-+static nsresult
-+GetAppRootDir(nsIFile *aExeFile, nsIFile** aFile)
-+{
-+  NS_ENSURE_ARG_POINTER(aExeFile);
-+  NS_ENSURE_ARG_POINTER(aFile);
-+  nsCOMPtr<nsIFile> appRootDir = aExeFile;
-+
-+  int levelsToRemove = 1; // Remove firefox (the executable file).
-+#if defined(XP_MACOSX)
-+  levelsToRemove += 2;   // On Mac OS, we must also remove Contents/MacOS.
-+#endif
-+  while (appRootDir && (levelsToRemove > 0)) {
-+    // When crawling up the hierarchy, components named "." do not count.
-+    nsAutoCString removedName;
-+    nsresult rv = appRootDir->GetNativeLeafName(removedName);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    bool didRemove = !removedName.Equals(".");
-+
-+    // Remove a directory component.
-+    nsCOMPtr<nsIFile> parentDir;
-+    rv = appRootDir->GetParent(getter_AddRefs(parentDir));
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    appRootDir = parentDir;
-+
-+    if (didRemove)
-+      --levelsToRemove;
-+  }
-+
-+  if (!appRootDir)
-+    return NS_ERROR_FAILURE;
-+
-+  appRootDir.forget(aFile);
-+  return NS_OK;
-+}
-diff --git a/xpcom/io/TorFileUtils.h b/xpcom/io/TorFileUtils.h
-new file mode 100644
-index 0000000..293ed04
---- /dev/null
-+++ b/xpcom/io/TorFileUtils.h
-@@ -0,0 +1,35 @@
-+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-+/* This Source Code Form is subject to the terms of the Mozilla Public
-+ * License, v. 2.0. If a copy of the MPL was not distributed with this
-+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-+
-+#ifndef TorFileUtils_h__
-+#define TorFileUtils_h__
-+
-+#include "nsIFile.h"
-+
-+class nsIFile;
-+
-+/**
-+ * TorBrowser_GetUserDataDir
-+ *
-+ * Retrieve the Tor Browser user data directory.
-+ * When built with --enable-tor-browser-data-outside-app-dir, the directory
-+ * is next to the application directory, except on Mac OS where it may be
-+ * there or it may be at ~/Library/Application Support/TorBrowser-Data (the
-+ * latter location is used if the .app bundle is in a directory whose path
-+ * contains /Applications or if we lack write access to the directory that
-+ * contains the .app).
-+ * When built without --enable-tor-browser-data-outside-app-dir, this
-+ * directory is TorBrowser.app/TorBrowser.
-+ *
-+ * @param aExeFile  The firefox executable.
-+ * @param aFile     Out parameter that is set to the Tor Browser user data
-+ *                  directory.
-+ * @return NS_OK on success.  Error otherwise.
-+ */
-+extern NS_METHOD
-+TorBrowser_GetUserDataDir(nsIFile *aExeFile, nsIFile** aFile);
-+
-+#endif // !TorFileUtils_h__
-diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build
-index bc62f71..c90f33c 100644
---- a/xpcom/io/moz.build
-+++ b/xpcom/io/moz.build
-@@ -80,6 +80,7 @@ EXPORTS += [
-     'nsUnicharInputStream.h',
-     'nsWildCard.h',
-     'SpecialSystemDirectory.h',
-+    'TorFileUtils.h',
- ]
- 
- EXPORTS.mozilla += [
-@@ -116,6 +117,7 @@ UNIFIED_SOURCES += [
-     'SnappyFrameUtils.cpp',
-     'SnappyUncompressInputStream.cpp',
-     'SpecialSystemDirectory.cpp',
-+    'TorFileUtils.cpp',
- ]
- 
- if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp
-index 039a89e..da66b90 100644
---- a/xpcom/io/nsAppFileLocationProvider.cpp
-+++ b/xpcom/io/nsAppFileLocationProvider.cpp
-@@ -29,6 +29,7 @@
- #include <sys/param.h>
- #endif
- 
-+#include "TorFileUtils.h"
- 
- // WARNING: These hard coded names need to go away. They need to
- // come from localizable resources
-@@ -282,8 +283,14 @@ nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile** aLocalFile)
- //----------------------------------------------------------------------------------------
- // GetProductDirectory - Gets the directory which contains the application data folder
- //
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+// UNIX and WIN   : <App Folder>/../TorBrowser-Data/Browser
-+// Mac            : <App Folder>/../../../TorBrowser-Data/Browser OR
-+//                  ~/Library/Application Support/TorBrowser-Data/Browser
-+#else
- // UNIX and WIN   : <App Folder>/TorBrowser/Data/Browser
- // Mac            : <App Folder>/../../TorBrowser/Data/Browser
-+#endif
- //----------------------------------------------------------------------------------------
- NS_METHOD
- nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
-@@ -293,42 +300,25 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
-     return NS_ERROR_INVALID_ARG;
-   }
- 
--  nsresult rv;
-+  nsresult rv = NS_ERROR_UNEXPECTED;
-   bool exists;
--  nsCOMPtr<nsIFile> localDir;
-+  nsCOMPtr<nsIFile> localDir, exeFile;
- 
--  rv = CloneMozBinDirectory(getter_AddRefs(localDir));
-+  nsCOMPtr<nsIProperties> directoryService(
-+                         do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = directoryService->Get(XRE_EXECUTABLE_FILE, NS_GET_IID(nsIFile),
-+                             getter_AddRefs(exeFile));
-+  NS_ENSURE_SUCCESS(rv, rv);
-+  rv = TorBrowser_GetUserDataDir(exeFile, getter_AddRefs(localDir));
-   NS_ENSURE_SUCCESS(rv, rv);
- 
--  int levelsToRemove = 0; // In FF21+, bin dir points to browser subdirectory.
--#if defined(XP_MACOSX)
--  levelsToRemove += 1;
--#endif
--  while (localDir && (levelsToRemove > 0)) {
--    // When crawling up the hierarchy, components named "." do not count.
--    nsAutoCString removedName;
--    rv = localDir->GetNativeLeafName(removedName);
--    NS_ENSURE_SUCCESS(rv, rv);
--    bool didRemove = !removedName.Equals(".");
--
--    // Remove a directory component.
--    nsCOMPtr<nsIFile> parentDir;
--    rv = localDir->GetParent(getter_AddRefs(parentDir));
--    NS_ENSURE_SUCCESS(rv, rv);
--    localDir = parentDir;
--
--    if (didRemove) {
--      --levelsToRemove;
--    }
--  }
--
--  if (!localDir) {
--    return NS_ERROR_FAILURE;
--  }
--
--  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("TorBrowser"
--                                        XPCOM_FILE_PATH_SEPARATOR "Data"
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+  rv = localDir->AppendNative(NS_LITERAL_CSTRING("Browser"));
-+#else
-+  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Data"
-                                         XPCOM_FILE_PATH_SEPARATOR "Browser"));
-+#endif
-   NS_ENSURE_SUCCESS(rv, rv);
- 
-   if (aLocal) {
--- 
-cgit v0.10.2
-
diff --git a/projects/instantbird/Sign-MAR-files-bug-13379.mozpatch b/projects/instantbird/Sign-MAR-files-bug-13379.mozpatch
deleted file mode 100644
index bfc1e64..0000000
--- a/projects/instantbird/Sign-MAR-files-bug-13379.mozpatch
+++ /dev/null
@@ -1,616 +0,0 @@
-From 94882047c2de9160fd08f33ee2d5541df7baff4d Mon Sep 17 00:00:00 2001
-From: Kathy Brade <brade at pearlcrescent.com>
-Date: Wed, 17 Dec 2014 16:37:11 -0500
-Subject: Bug 13379: Sign our MAR files.
-
-Replace Mozilla's MAR signing certificates with our own.
-Configure with --enable-signmar (build the signmar tool).
-Configure with --enable-verify-mar (when updating, require a valid signature
-  on the MAR file before it is applied).
-Use the Tor Browser version instead of the Firefox version inside the
-  MAR file info block (necessary to prevent downgrade attacks).
-Use NSS on all platforms for checking MAR signatures (Mozilla plans to use
-  OS-native APIs on Mac OS and they already do so on Windows). So that the
-  NSS and NSPR libraries the updater depends on can be found at runtime, we
-  add the firefox directory to the shared library search path on all platforms.
-Use SHA512-based MAR signatures instead of the SHA1-based ones that Mozilla
-  uses. This is implemented inside MAR_USE_SHA512_RSA_SIG #ifdef's and with
-  a signature algorithm ID of 512 to help avoid collisions with future work
-  Mozilla might do in this area.
-  See: https://bugzilla.mozilla.org/show_bug.cgi?id=1105689
-
-diff --git a/config/external/nss/Makefile.in b/config/external/nss/Makefile.in
-index c91bf5b..e636fa0 100644
---- a/config/external/nss/Makefile.in
-+++ b/config/external/nss/Makefile.in
-@@ -283,11 +283,11 @@ endif
- NSS_DIRS += \
-   nss/cmd/lib \
-   nss/cmd/shlibsign \
-+  nss/cmd/certutil \
-   $(NULL)
- 
- ifdef ENABLE_TESTS
- NSS_DIRS += \
--  nss/cmd/certutil \
-   nss/cmd/pk12util \
-   nss/cmd/modutil \
-   $(NULL)
-diff --git a/modules/libmar/sign/mar_sign.c b/modules/libmar/sign/mar_sign.c
-index 2a08abf..902c6f2 100644
---- a/modules/libmar/sign/mar_sign.c
-+++ b/modules/libmar/sign/mar_sign.c
-@@ -95,7 +95,12 @@ NSSSignBegin(const char *certName,
-     return -1;
-   }
- 
--  *ctx = SGN_NewContext (SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE, *privKey);
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+  SECOidTag sigAlg = SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION;
-+#else
-+  SECOidTag sigAlg = SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE;
-+#endif
-+  *ctx = SGN_NewContext(sigAlg, *privKey);
-   if (!*ctx) {
-     fprintf(stderr, "ERROR: Could not create signature context\n");
-     return -1;
-@@ -994,8 +999,12 @@ mar_repackage_and_sign(const char *NSSConfigDir,
-   signaturePlaceholderOffset = ftello(fpDest);
- 
-   for (k = 0; k < certCount; k++) {
--    /* Write out the signature algorithm ID, Only an ID of 1 is supported */
--    signatureAlgorithmID = htonl(1);
-+    /* Write out the signature algorithm ID. */
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+    signatureAlgorithmID = htonl(SIGNATURE_ALGORITHM_ID_SHA512_RSA);
-+#else
-+    signatureAlgorithmID = htonl(SIGNATURE_ALGORITHM_ID_SHA1_RSA);
-+#endif
-     if (WriteAndUpdateSignatures(fpDest, &signatureAlgorithmID,
-                                  sizeof(signatureAlgorithmID),
-                                  ctxs, certCount, "num signatures")) {
-diff --git a/modules/libmar/sign/moz.build b/modules/libmar/sign/moz.build
-index d7b8d1f..849deff 100644
---- a/modules/libmar/sign/moz.build
-+++ b/modules/libmar/sign/moz.build
-@@ -19,6 +19,7 @@ LOCAL_INCLUDES += [
- ]
- 
- DEFINES['MAR_NSS'] = True
-+DEFINES['MAR_USE_SHA512_RSA_SIG'] = True
- 
- if CONFIG['OS_ARCH'] == 'WINNT':
-     USE_STATIC_LIBS = True
-diff --git a/modules/libmar/src/mar_private.h b/modules/libmar/src/mar_private.h
-index e0c2632..add03f5 100644
---- a/modules/libmar/src/mar_private.h
-+++ b/modules/libmar/src/mar_private.h
-@@ -21,6 +21,14 @@
-    which is 16 bytes */
- #define SIGNATURE_BLOCK_OFFSET 16
- 
-+/* Signature algorithm IDs. */
-+#define SIGNATURE_ALGORITHM_ID_SHA1_RSA 1
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+/* Use 512 as the algorithm ID so it is less likely that we will conflict with
-+   whatever Mozilla chooses when they add support for a stronger signature. */
-+#define SIGNATURE_ALGORITHM_ID_SHA512_RSA 512
-+#endif
-+
- /* Make sure the file is less than 500MB.  We do this to protect against
-    invalid MAR files. */
- #define MAX_SIZE_OF_MAR_FILE ((int64_t)524288000)
-diff --git a/modules/libmar/tool/mar.c b/modules/libmar/tool/mar.c
-index 5011c88..ef0a3eb 100644
---- a/modules/libmar/tool/mar.c
-+++ b/modules/libmar/tool/mar.c
-@@ -31,7 +31,11 @@ int mar_repackage_and_sign(const char *NSSConfigDir,
-                            const char * dest);
- 
- static void print_version() {
-+#ifdef TOR_BROWSER_UPDATE
-+  printf("Version: %s\n", TOR_BROWSER_VERSION);
-+#else
-   printf("Version: %s\n", MOZ_APP_VERSION);
-+#endif
-   printf("Default Channel ID: %s\n", MAR_CHANNEL_ID);
- }
- 
-@@ -61,7 +65,7 @@ static void print_usage() {
-          "signed_input_archive.mar base_64_encoded_signature_file "
-          "changed_signed_output.mar\n");
-   printf("(i) is the index of the certificate to extract\n");
--#if defined(XP_MACOSX) || (defined(XP_WIN) && !defined(MAR_NSS))
-+#if (defined(XP_MACOSX) || defined(XP_WIN)) && !defined(MAR_NSS)
-   printf("Verify a MAR file:\n");
-   printf("  mar [-C workingDir] -D DERFilePath -v signed_archive.mar\n");
-   printf("At most %d signature certificate DER files are specified by "
-@@ -116,7 +120,11 @@ int main(int argc, char **argv) {
-   char *NSSConfigDir = NULL;
-   const char *certNames[MAX_SIGNATURES];
-   char *MARChannelID = MAR_CHANNEL_ID;
-+#ifdef TOR_BROWSER_UPDATE
-+  char *productVersion = TOR_BROWSER_VERSION;
-+#else
-   char *productVersion = MOZ_APP_VERSION;
-+#endif
-   uint32_t k;
-   int rv = -1;
-   uint32_t certCount = 0;
-@@ -135,8 +143,8 @@ int main(int argc, char **argv) {
- #if defined(XP_WIN) && !defined(MAR_NSS) && !defined(NO_SIGN_VERIFY)
-   memset((void*)certBuffers, 0, sizeof(certBuffers));
- #endif
--#if !defined(NO_SIGN_VERIFY) && ((!defined(MAR_NSS) && defined(XP_WIN)) || \
--                                 defined(XP_MACOSX))
-+#if !defined(NO_SIGN_VERIFY) && (!defined(MAR_NSS) && (defined(XP_WIN) || \
-+                                 defined(XP_MACOSX)))
-   memset(DERFilePaths, 0, sizeof(DERFilePaths));
-   memset(fileSizes, 0, sizeof(fileSizes));
- #endif
-@@ -167,8 +175,8 @@ int main(int argc, char **argv) {
-       argv += 2;
-       argc -= 2;
-     } 
--#if !defined(NO_SIGN_VERIFY) && ((!defined(MAR_NSS) && defined(XP_WIN)) || \
--                                 defined(XP_MACOSX))
-+#if !defined(NO_SIGN_VERIFY) && (!defined(MAR_NSS) && (defined(XP_WIN) || \
-+                                 defined(XP_MACOSX)))
-     /* -D DERFilePath, also matches -D[index] DERFilePath
-        We allow an index for verifying to be symmetric
-        with the import and export command line arguments. */
-@@ -343,6 +351,10 @@ int main(int argc, char **argv) {
- #if (defined(XP_WIN) || defined(XP_MACOSX)) && !defined(MAR_NSS)
-       rv = mar_read_entire_file(DERFilePaths[k], MAR_MAX_CERT_SIZE,
-                                 &certBuffers[k], &fileSizes[k]);
-+      if (rv) {
-+        fprintf(stderr, "ERROR: could not read file %s", DERFilePaths[k]);
-+        break;
-+      }
- #else
-       /* It is somewhat circuitous to look up a CERTCertificate and then pass
-        * in its DER encoding just so we can later re-create that
-@@ -359,11 +371,11 @@ int main(int argc, char **argv) {
-       } else {
-         rv = -1;
-       }
--#endif
-       if (rv) {
--        fprintf(stderr, "ERROR: could not read file %s", DERFilePaths[k]);
-+        fprintf(stderr, "ERROR: no certificate named %s", certNames[k]);
-         break;
-       }
-+#endif
-     }
- 
-     if (!rv) {
-diff --git a/modules/libmar/tool/moz.build b/modules/libmar/tool/moz.build
-index 5b52124..9fa982e 100644
---- a/modules/libmar/tool/moz.build
-+++ b/modules/libmar/tool/moz.build
-@@ -29,7 +29,13 @@ for var in ('MAR_CHANNEL_ID', 'MOZ_APP_VERSION'):
-     DEFINES[var] = '"%s"' % CONFIG[var]
-     HOST_DEFINES[var] = DEFINES[var]
- 
-+if CONFIG['TOR_BROWSER_UPDATE']:
-+    DEFINES['TOR_BROWSER_UPDATE'] = '%s' % CONFIG['TOR_BROWSER_UPDATE']
-+if CONFIG['TOR_BROWSER_VERSION']:
-+    DEFINES['TOR_BROWSER_VERSION'] = '"%s"' % CONFIG['TOR_BROWSER_VERSION']
-+
- if CONFIG['MOZ_ENABLE_SIGNMAR']:
-+    DEFINES['MAR_NSS'] = True
-     USE_LIBS += [
-         'nspr',
-         'nss',
-@@ -43,12 +49,12 @@ if CONFIG['OS_ARCH'] == 'WINNT':
-     OS_LIBS += [
-         'ws2_32',
-     ]
--    if CONFIG['MOZ_ENABLE_SIGNMAR']:
-+    if CONFIG['MOZ_ENABLE_SIGNMAR'] and not DEFINES['MAR_NSS']:
-         OS_LIBS += [
-             'crypt32',
-             'advapi32',
-         ]
--elif CONFIG['OS_ARCH'] == 'Darwin':
-+elif CONFIG['OS_ARCH'] == 'Darwin' and not DEFINES['MAR_NSS']:
-     OS_LIBS += [
-       '-framework Security',
-     ]
-diff --git a/modules/libmar/verify/cryptox.c b/modules/libmar/verify/cryptox.c
-index af34210..f39669b 100644
---- a/modules/libmar/verify/cryptox.c
-+++ b/modules/libmar/verify/cryptox.c
-@@ -64,8 +64,12 @@ NSS_VerifyBegin(VFYContext **ctx,
-     return CryptoX_Error;
-   }
- 
--  *ctx = VFY_CreateContext(*publicKey, NULL, 
--                           SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE, NULL);
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+  SECOidTag sigAlg = SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION;
-+#else
-+  SECOidTag sigAlg = SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE;
-+#endif
-+  *ctx = VFY_CreateContext(*publicKey, NULL, sigAlg, NULL);
-   if (*ctx == NULL) {
-     return CryptoX_Error;
-   }
-diff --git a/modules/libmar/verify/cryptox.h b/modules/libmar/verify/cryptox.h
-index 2296b81..ab9b5a3 100644
---- a/modules/libmar/verify/cryptox.h
-+++ b/modules/libmar/verify/cryptox.h
-@@ -59,6 +59,10 @@ CryptoX_Result NSS_VerifySignature(VFYContext * const *ctx ,
- 
- #elif XP_MACOSX
- 
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+#error MAR_USE_SHA512_RSA_SIG is not implemented.
-+#endif
-+
- #define CryptoX_InvalidHandleValue NULL
- #define CryptoX_ProviderHandle void*
- #define CryptoX_SignatureHandle void*
-@@ -106,6 +110,11 @@ void CryptoMac_FreePublicKey(CryptoX_PublicKey* aPublicKey);
- 
- #elif defined(XP_WIN) 
- 
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+#error MAR_USE_SHA512_RSA_SIG is not implemented.
-+#endif
-+
-+
- #include <windows.h>
- #include <wincrypt.h>
- 
-diff --git a/modules/libmar/verify/mar_verify.c b/modules/libmar/verify/mar_verify.c
-index 07e4354..a9ecaa8 100644
---- a/modules/libmar/verify/mar_verify.c
-+++ b/modules/libmar/verify/mar_verify.c
-@@ -277,8 +277,25 @@ mar_extract_and_verify_signatures_fp(FILE *fp,
-     }
- 
-     /* We don't try to verify signatures we don't know about */
--    if (signatureAlgorithmIDs[i] != 1) {
--      fprintf(stderr, "ERROR: Unknown signature algorithm ID.\n");
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+    const uint32_t kSupportedAlgID = SIGNATURE_ALGORITHM_ID_SHA512_RSA;
-+#else
-+    const uint32_t kSupportedAlgID = SIGNATURE_ALGORITHM_ID_SHA1_RSA;
-+#endif
-+
-+    if (signatureAlgorithmIDs[i] != kSupportedAlgID) {
-+#ifdef MAR_USE_SHA512_RSA_SIG
-+      if (signatureAlgorithmIDs[i] == SIGNATURE_ALGORITHM_ID_SHA1_RSA) {
-+        fprintf(stderr,
-+                "ERROR: Unsupported signature algorithm (SHA1 with RSA).\n");
-+      } else {
-+        fprintf(stderr, "ERROR: Unknown signature algorithm ID %u.\n",
-+                        signatureAlgorithmIDs[i]);
-+      }
-+#else
-+      fprintf(stderr, "ERROR: Unknown signature algorithm ID %u.\n",
-+                      signatureAlgorithmIDs[i]);
-+#endif
-       for (i = 0; i < signatureCount; ++i) {
-         free(extractedSignatures[i]);
-       }
-diff --git a/modules/libmar/verify/moz.build b/modules/libmar/verify/moz.build
-index 89f7323..735cf7c 100644
---- a/modules/libmar/verify/moz.build
-+++ b/modules/libmar/verify/moz.build
-@@ -15,16 +15,10 @@ FORCE_STATIC_LIB = True
- 
- if CONFIG['OS_ARCH'] == 'WINNT':
-     USE_STATIC_LIBS = True
--elif CONFIG['OS_ARCH'] == 'Darwin':
--    UNIFIED_SOURCES += [
--      'MacVerifyCrypto.cpp',
--    ]
--    OS_LIBS += [
--      '-framework Security',
--    ]
--else:
--    DEFINES['MAR_NSS'] = True
--    LOCAL_INCLUDES += ['../sign']
-+
-+DEFINES['MAR_NSS'] = True
-+DEFINES['MAR_USE_SHA512_RSA_SIG'] = True
-+LOCAL_INCLUDES += ['../sign']
- 
- LOCAL_INCLUDES += [
-     '../src',
-diff --git a/toolkit/mozapps/update/updater/Makefile.in b/toolkit/mozapps/update/updater/Makefile.in
-index d216298..f2c7540 100644
---- a/toolkit/mozapps/update/updater/Makefile.in
-+++ b/toolkit/mozapps/update/updater/Makefile.in
-@@ -15,7 +15,7 @@ endif
- 
- include $(topsrcdir)/config/rules.mk
- 
--ifneq (,$(filter beta release esr,$(MOZ_UPDATE_CHANNEL)))
-+ifneq (,$(filter alpha beta hardened release esr,$(MOZ_UPDATE_CHANNEL)))
- 	PRIMARY_CERT = release_primary.der
- 	SECONDARY_CERT = release_secondary.der
- else ifneq (,$(filter nightly aurora nightly-elm nightly-profiling nightly-oak nightly-ux,$(MOZ_UPDATE_CHANNEL)))
-diff --git a/toolkit/mozapps/update/updater/release_primary.der b/toolkit/mozapps/update/updater/release_primary.der
-index 11417c3..542fb24 100644
-Binary files a/toolkit/mozapps/update/updater/release_primary.der and b/toolkit/mozapps/update/updater/release_primary.der differ
-diff --git a/toolkit/mozapps/update/updater/updater-common.build b/toolkit/mozapps/update/updater/updater-common.build
-index a39d47d88..a9699c23 100644
---- a/toolkit/mozapps/update/updater/updater-common.build
-+++ b/toolkit/mozapps/update/updater/updater-common.build
-@@ -4,6 +4,10 @@
- # 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/.
- 
-+DEFINES['MAR_NSS'] = True
-+
-+link_with_nss = DEFINES['MAR_NSS'] or (CONFIG['OS_ARCH'] == 'Linux' and CONFIG['MOZ_VERIFY_MAR_SIGNATURE'])
-+
- srcs = [
-     'archivereader.cpp',
-     'bspatch.cpp',
-@@ -41,19 +45,23 @@ if CONFIG['OS_ARCH'] == 'WINNT':
-         'ws2_32',
-         'shell32',
-         'shlwapi',
--        'crypt32',
--        'advapi32',
-     ]
--elif CONFIG['OS_ARCH'] == 'Linux' and CONFIG['MOZ_VERIFY_MAR_SIGNATURE']:
-+
-+    if not link_with_nss:
-+        OS_LIBS += [
-+            'crypt32',
-+            'advapi32',
-+        ]
-+else:
-     USE_LIBS += [
--        'nss',
--        'signmar',
-         'updatecommon',
-     ]
--    OS_LIBS += CONFIG['NSPR_LIBS']
--else:
-+
-+if link_with_nss:
-     USE_LIBS += [
--        'updatecommon',
-+        'nspr',
-+        'nss',
-+        'signmar',
-     ]
- 
- USE_LIBS += [
-@@ -81,8 +89,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-     ]
-     OS_LIBS += [
-         '-framework Cocoa',
--        '-framework Security',
-     ]
-+
-+    if not link_with_nss:
-+        OS_LIBS += [
-+            '-framework Security',
-+        ]
- elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-     have_progressui = 1
-     srcs += [
-diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
-index f362292..2d205a8 100644
---- a/toolkit/mozapps/update/updater/updater.cpp
-+++ b/toolkit/mozapps/update/updater/updater.cpp
-@@ -120,11 +120,13 @@ static bool sUseHardLinks = true;
- # define MAYBE_USE_HARD_LINKS 0
- #endif
- 
--#if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \
--    !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
-+#if defined(MOZ_VERIFY_MAR_SIGNATURE)
-+#if defined(MAR_NSS) || (!defined(XP_WIN) && !defined(XP_MACOSX) && \
-+    !defined(MOZ_WIDGET_GONK))
- #include "nss.h"
- #include "prerror.h"
- #endif
-+#endif
- 
- #ifdef XP_WIN
- #ifdef MOZ_MAINTENANCE_SERVICE
-@@ -2635,8 +2637,13 @@ UpdateThreadFunc(void *param)
-           MARStrings.MARChannelID[0] = '\0';
-         }
- 
-+#ifdef TOR_BROWSER_UPDATE
-+        const char *appVersion = TOR_BROWSER_VERSION;
-+#else
-+        const char *appVersion = MOZ_APP_VERSION;
-+#endif
-         rv = gArchiveReader.VerifyProductInformation(MARStrings.MARChannelID,
--                                                     MOZ_APP_VERSION);
-+                                                     appVersion);
-       }
-     }
- #endif
-@@ -2722,12 +2729,11 @@ int NS_main(int argc, NS_tchar **argv)
-   }
- #endif
- 
--#if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \
--    !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
--  // On Windows and Mac we rely on native APIs to do verifications so we don't
--  // need to initialize NSS at all there.
--  // Otherwise, minimize the amount of NSS we depend on by avoiding all the NSS
--  // databases.
-+#if defined(MOZ_VERIFY_MAR_SIGNATURE)
-+#if defined(MAR_NSS) || (!defined(XP_WIN) && !defined(XP_MACOSX) && \
-+    !defined(MOZ_WIDGET_GONK))
-+  // If using NSS for signature verification, initialize NSS but minimize
-+  // the portion we depend on by avoiding all of the NSS databases.
-   if (NSS_NoDB_Init(NULL) != SECSuccess) {
-    PRErrorCode error = PR_GetError();
-    fprintf(stderr, "Could not initialize NSS: %s (%d)",
-@@ -2735,6 +2741,7 @@ int NS_main(int argc, NS_tchar **argv)
-     _exit(1);
-   }
- #endif
-+#endif
- 
-   InitProgressUI(&argc, &argv);
- 
-diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build
-index 3e6a3b6..7d46dfd 100644
---- a/toolkit/xre/moz.build
-+++ b/toolkit/xre/moz.build
-@@ -149,6 +149,9 @@ for var in ('APP_VERSION', 'APP_ID'):
- if CONFIG['MOZ_BUILD_APP'] == 'browser':
-     DEFINES['MOZ_BUILD_APP_IS_BROWSER'] = True
- 
-+if CONFIG['MOZ_ENABLE_SIGNMAR'] and CONFIG['TOR_BROWSER_UPDATE']:
-+     DEFINES['MAR_NSS'] = True
-+
- LOCAL_INCLUDES += [
-     '../profile',
-     '/config',
-diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp
-index ee60aee..0c7b6b0 100644
---- a/toolkit/xre/nsUpdateDriver.cpp
-+++ b/toolkit/xre/nsUpdateDriver.cpp
-@@ -39,7 +39,6 @@
- # include <windows.h>
- # include <shlwapi.h>
- # include "nsWindowsHelpers.h"
--# include "prprf.h"
- # define getcwd(path, size) _getcwd(path, size)
- # define getpid() GetCurrentProcessId()
- #elif defined(XP_UNIX)
-@@ -169,36 +168,6 @@ GetInstallDirPath(nsIFile *appDir, nsACString& installDirPath)
-   return NS_OK;
- }
- 
--#if defined(TOR_BROWSER_UPDATE) && defined(XP_WIN)
--#define PATH_SEPARATOR ";"
--
--// In Tor Browser, updater.exe depends on some DLLs that are located in the
--// app directory.  To allow the updater to run when it has been copied into
--// the update directory, we append the app directory to the PATH.
--static nsresult
--AdjustPathForUpdater(nsIFile *appDir)
--{
--  nsAutoCString appPath;
--  nsresult rv = appDir->GetNativePath(appPath);
--  NS_ENSURE_SUCCESS(rv, rv);
--
--  char *s = nullptr;
--  char *pathValue = PR_GetEnv("PATH");
--  if ((nullptr == pathValue) || ('\0' == *pathValue)) {
--    s = PR_smprintf("PATH=%s", appPath.get());
--  } else {
--    s = PR_smprintf("PATH=%s" PATH_SEPARATOR "%s", pathValue, appPath.get());
--  }
--
--  // We intentionally leak the value that is passed into PR_SetEnv() because
--  // the environment will hold a pointer to it.
--  if ((nullptr == s) || (PR_SUCCESS != PR_SetEnv(s)))
--    return NS_ERROR_FAILURE;
--
--  return NS_OK;
--}
--#endif
--
- #ifdef DEBUG
- static void
- dump_argv(const char *aPrefix, char **argv, int argc)
-@@ -500,13 +469,22 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir,
-  * Appends the specified path to the library path.
-  * This is used so that updater can find libmozsqlite3.so and other shared libs.
-  *
-- * @param pathToAppend A new library path to prepend to LD_LIBRARY_PATH
-+ * @param pathToAppend A new library path to prepend to the dynamic linker's search path.
-  */
--#if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \
--    !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
-+#if defined(MOZ_VERIFY_MAR_SIGNATURE) && (defined(MAR_NSS) || \
-+    (!defined(XP_WIN) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)))
- #include "prprf.h"
-+#if defined(XP_WIN)
-+#define PATH_SEPARATOR ";"
-+#define LD_LIBRARY_PATH_ENVVAR_NAME "PATH"
-+#else
- #define PATH_SEPARATOR ":"
-+#if defined(XP_MACOSX)
-+#define LD_LIBRARY_PATH_ENVVAR_NAME "DYLD_LIBRARY_PATH"
-+#else
- #define LD_LIBRARY_PATH_ENVVAR_NAME "LD_LIBRARY_PATH"
-+#endif
-+#endif
- static void
- AppendToLibPath(const char *pathToAppend)
- {
-@@ -732,16 +710,20 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir,
-   if (gSafeMode) {
-     PR_SetEnv("MOZ_SAFE_MODE_RESTART=1");
-   }
--#if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \
--    !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
--  AppendToLibPath(installDirPath.get());
--#endif
- 
--#if defined(TOR_BROWSER_UPDATE) && defined(XP_WIN)
--  nsresult rv2 = AdjustPathForUpdater(appDir);
--  if (NS_FAILED(rv2)) {
--    LOG(("SwitchToUpdatedApp -- AdjustPathForUpdater failed (0x%x)\n", rv2));
-+#if defined(MOZ_VERIFY_MAR_SIGNATURE) && (defined(MAR_NSS) || \
-+    (!defined(XP_WIN) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)))
-+#ifdef TOR_BROWSER_UPDATE
-+  nsAutoCString appPath;
-+  nsresult rv2 = appDir->GetNativePath(appPath);
-+  if (NS_SUCCEEDED(rv2)) {
-+    AppendToLibPath(appPath.get());
-+  } else {
-+    LOG(("SwitchToUpdatedApp -- appDir->GetNativePath() failed (0x%x)\n", rv2));
-   }
-+#else
-+  AppendToLibPath(installDirPath.get());
-+#endif
- #endif
- 
-   LOG(("spawning updater process for replacing [%s]\n", updaterPath.get()));
-@@ -1020,22 +1002,25 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
-   if (gSafeMode) {
-     PR_SetEnv("MOZ_SAFE_MODE_RESTART=1");
-   }
--#if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \
--    !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
-+#if defined(MOZ_VERIFY_MAR_SIGNATURE) && (defined(MAR_NSS) || \
-+    (!defined(XP_WIN) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)))
-+#ifdef TOR_BROWSER_UPDATE
-+  nsAutoCString appPath;
-+  nsresult rv2 = appDir->GetNativePath(appPath);
-+  if (NS_SUCCEEDED(rv2)) {
-+    AppendToLibPath(appPath.get());
-+  } else {
-+    LOG(("ApplyUpdate -- appDir->GetNativePath() failed (0x%x)\n", rv2));
-+  }
-+#else
-   AppendToLibPath(installDirPath.get());
- #endif
-+#endif
- 
-   if (isOSUpdate) {
-     PR_SetEnv("MOZ_OS_UPDATE=1");
-   }
- 
--#if defined(TOR_BROWSER_UPDATE) && defined(XP_WIN)
--  nsresult rv2 = AdjustPathForUpdater(appDir);
--  if (NS_FAILED(rv2)) {
--    LOG(("ApplyUpdate -- AdjustPathForUpdater failed (0x%x)\n", rv2));
--  }
--#endif
--
- #if defined(MOZ_WIDGET_GONK)
-   // We want the updater to be CPU friendly and not subject to being killed by
-   // the low memory killer, so we pass in some preferences to allow it to
--- 
-cgit v0.10.2
-
diff --git a/projects/instantbird/Update-load-local-changes-bug-14392-first.mozpatch b/projects/instantbird/Update-load-local-changes-bug-14392-first.mozpatch
deleted file mode 100644
index e1bc5bf..0000000
--- a/projects/instantbird/Update-load-local-changes-bug-14392-first.mozpatch
+++ /dev/null
@@ -1,18 +0,0 @@
-commit bb781597694015aed8ea4d121eac503542fd52f2
-Author: Mike Perry <mikeperry-git at torproject.org>
-Date:   Wed Feb 11 16:45:24 2015 -0800
-
-    Bug 14392: Make about:tor behave like other initial pages.
-
-diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
-index 4f2642a..934a223 100644
---- a/browser/base/content/browser.js
-+++ b/browser/base/content/browser.js
-@@ -258,6 +258,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerParent",
-   "resource://gre/modules/LoginManagerParent.jsm");
- 
- var gInitialPages = [
-+  "about:tor",
-   "about:blank",
-   "about:newtab",
-   "about:home",
diff --git a/projects/instantbird/Update-load-local-changes-bug-16940-second.mozpatch b/projects/instantbird/Update-load-local-changes-bug-16940-second.mozpatch
deleted file mode 100644
index 25aac2a..0000000
--- a/projects/instantbird/Update-load-local-changes-bug-16940-second.mozpatch
+++ /dev/null
@@ -1,368 +0,0 @@
-From 3815bb323160cf9163a07e36859c2ea83c905ace Mon Sep 17 00:00:00 2001
-From: Kathy Brade <brade at pearlcrescent.com>
-Date: Wed, 25 Nov 2015 11:36:20 -0500
-Subject: Bug 16940: After update, load local change notes.
-
-Add an about:tbupdate page that displays the first section from
-TorBrowser/Docs/ChangeLog.txt and includes a link to the remote
-post-update page (typically our blog entry for the release).
-
-diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.css b/browser/base/content/abouttbupdate/aboutTBUpdate.css
-new file mode 100644
-index 0000000..489c9d2
---- /dev/null
-+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.css
-@@ -0,0 +1,34 @@
-+body {
-+  font-family: sans-serif;
-+  font-size: 110%;
-+  background-image: -moz-linear-gradient(top, #ffffff, #ffffff 10%, #d5ffd5 50%, #d5ffd5);
-+  background-attachment: fixed;
-+  background-size: 100% 100%;
-+}
-+
-+#logo {
-+  background-image: url("chrome://browser/content/abouttbupdate/aboutTBUpdateLogo.png");
-+  height: 128px;
-+  width: 128px;
-+  margin: 20px;
-+  float: left;
-+}
-+
-+#msg {
-+  margin-top: 50px;
-+  float: left;
-+}
-+
-+#msg-updated {
-+  font-size: 120%;
-+  margin-bottom: 20px;
-+}
-+
-+#changelog-container {
-+  margin: 0px 20px 20px 20px;
-+}
-+
-+#changelog {
-+  margin-left: 20px;
-+  white-space: pre;
-+}
-diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.js b/browser/base/content/abouttbupdate/aboutTBUpdate.js
-new file mode 100644
-index 0000000..8243647
---- /dev/null
-+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.js
-@@ -0,0 +1,10 @@
-+// Copyright (c) 2015, The Tor Project, Inc.
-+// See LICENSE for licensing information.
-+//
-+// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
-+
-+function init()
-+{
-+  let event = new CustomEvent("AboutTBUpdateLoad", { bubbles: true });
-+  document.dispatchEvent(event);
-+}
-diff --git a/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml
-new file mode 100644
-index 0000000..3a29e0c
---- /dev/null
-+++ b/browser/base/content/abouttbupdate/aboutTBUpdate.xhtml
-@@ -0,0 +1,34 @@
-+<?xml version="1.0" encoding="UTF-8"?>
-+
-+<!DOCTYPE html [
-+  <!ENTITY % htmlDTD
-+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-+    "DTD/xhtml1-strict.dtd">
-+  %htmlDTD;
-+  <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
-+  %globalDTD;
-+  <!ENTITY % tbUpdateDTD SYSTEM "chrome://browser/locale/aboutTBUpdate.dtd">
-+  %tbUpdateDTD;
-+]>
-+
-+<html xmlns="http://www.w3.org/1999/xhtml">
-+<head>
-+  <title>&aboutTBUpdate.title;</title>
-+  <link rel="stylesheet" type="text/css"
-+        href="chrome://browser/content/abouttbupdate/aboutTBUpdate.css"/>
-+  <script src="chrome://browser/content/abouttbupdate/aboutTBUpdate.js"
-+          type="text/javascript;version=1.7"/>
-+</head>
-+<body dir="&locale.dir;" onload="init()">
-+<div id="logo"/>
-+<div id="msg">
-+<div id="msg-updated">&aboutTBUpdate.updated;</div>
-+<div>&aboutTBUpdate.linkPrefix;<a id="infolink">&aboutTBUpdate.linkLabel;</a>&aboutTBUpdate.linkSuffix;
-+</div>
-+</div>
-+<br clear="all"/>
-+<div id="changelog-container">&aboutTBUpdate.changeLogHeading;
-+<div id="changelog"></div>
-+</div>
-+</body>
-+</html>
-diff --git a/browser/base/content/abouttbupdate/aboutTBUpdateLogo.png b/browser/base/content/abouttbupdate/aboutTBUpdateLogo.png
-new file mode 100644
-index 0000000..be5cae9
-Binary files /dev/null and b/browser/base/content/abouttbupdate/aboutTBUpdateLogo.png differ
-diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
-index 6e78084..0adbe61 100644
---- a/browser/base/content/browser.js
-+++ b/browser/base/content/browser.js
-@@ -259,6 +259,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerParent",
- 
- var gInitialPages = [
-   "about:tor",
-+#ifdef TOR_BROWSER_UPDATE
-+  "about:tbupdate",
-+#endif
-   "about:blank",
-   "about:newtab",
-   "about:home",
-@@ -2425,8 +2428,14 @@ function URLBarSetURI(aURI) {
- 
-     // Replace initial page URIs with an empty string
-     // only if there's no opener (bug 370555).
-+#ifdef TOR_BROWSER_UPDATE
-+    if (gInitialPages.indexOf(uri.spec.split('?')[0]) != -1 &&
-+        checkEmptyPageOrigin(gBrowser.selectedBrowser, uri))
-+#else
-     if (gInitialPages.indexOf(uri.spec) != -1 &&
--        checkEmptyPageOrigin(gBrowser.selectedBrowser, uri)) {
-+        checkEmptyPageOrigin(gBrowser.selectedBrowser, uri))
-+#endif
-+    {
-       value = "";
-     } else {
-       value = losslessDecodeURI(uri);
-@@ -7043,7 +7052,11 @@ var gIdentityHandler = {
-       this._uriHasHost = false;
-     }
- 
--    let whitelist = /^(?:accounts|addons|cache|config|crashes|customizing|downloads|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback)(?:[?#]|$)/i;
-+#ifdef TOR_BROWSER_UPDATE
-+    let whitelist = /^(?:accounts|addons|cache|config|crashes|customizing|downloads|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback|tor|tbupdate)(?:[?#]|$)/i;
-+#else
-+    let whitelist = /^(?:accounts|addons|cache|config|crashes|customizing|downloads|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback|tor)(?:[?#]|$)/i;
-+#endif
-     this._isSecureInternalUI = uri.schemeIs("about") && whitelist.test(uri.path);
- 
-     this._sslStatus = gBrowser.securityUI
-diff --git a/browser/base/content/tab-content.js b/browser/base/content/tab-content.js
-index c8f39ee..44489a2 100644
---- a/browser/base/content/tab-content.js
-+++ b/browser/base/content/tab-content.js
-@@ -10,6 +10,9 @@ var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
- Cu.import("resource://gre/modules/XPCOMUtils.jsm");
- Cu.import("resource://gre/modules/Services.jsm");
- Cu.import("resource://gre/modules/ExtensionContent.jsm");
-+#ifdef TOR_BROWSER_UPDATE
-+Cu.import("resource://gre/modules/NetUtil.jsm");
-+#endif
- 
- XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
-   "resource:///modules/E10SUtils.jsm");
-@@ -368,6 +371,82 @@ var AboutReaderListener = {
- };
- AboutReaderListener.init();
- 
-+#ifdef TOR_BROWSER_UPDATE
-+let AboutTBUpdateListener = {
-+  init: function(chromeGlobal) {
-+    chromeGlobal.addEventListener('AboutTBUpdateLoad', this, false, true);
-+  },
-+
-+  get isAboutTBUpdate() {
-+    return content.document.documentURI.split('?')[0].toLowerCase()
-+           == "about:tbupdate";
-+  },
-+
-+  handleEvent: function(aEvent) {
-+    if (this.isAboutTBUpdate && (aEvent.type == "AboutTBUpdateLoad"))
-+      this.onPageLoad();
-+  },
-+
-+  onPageLoad: function() {
-+    let doc = content.document;
-+    doc.getElementById("infolink").setAttribute("href", this.getPostUpdateURL());
-+    doc.getElementById("changelog").textContent = this.getChangeLogText();
-+  },
-+
-+  // Extract the post update URL from this page's query string.
-+  getPostUpdateURL: function() {
-+    let idx = content.document.documentURI.indexOf('?');
-+    if (idx > 0)
-+      return decodeURIComponent(content.document.documentURI.substring(idx+1));
-+
-+    // No query string: use the default URL.
-+    return Services.urlFormatter.formatURLPref("startup.homepage_override_url");
-+  },
-+
-+  // Read and return the text from the beginning of the changelog file that is
-+  // located at TorBrowser/Docs/ChangeLog.txt.
-+  // On Mac OS, when building with --enable-tor-browser-data-outside-app-dir
-+  // to support Gatekeeper signing, the file is located in
-+  // TorBrowser.app/Contents/Resources/TorBrowser/Docs/.
-+  //
-+  // When electrolysis is enabled we will need to adopt an architecture that is
-+  // more similar to the one that is used for about:home (see AboutHomeListener
-+  // in this file and browser/modules/AboutHome.jsm).
-+  getChangeLogText: function() {
-+    try {
-+#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
-+      // "XREExeF".parent is the directory that contains firefox, i.e.,
-+      // Browser/ or, on Mac OS, TorBrowser.app/Contents/MacOS/.
-+      let f = Services.dirsvc.get("XREExeF", Ci.nsIFile).parent;
-+#ifdef XP_MACOSX
-+      f = f.parent;
-+      f.append("Resources");
-+#endif
-+      f.append("TorBrowser");
-+#else
-+      // "DefProfRt" is .../TorBrowser/Data/Browser
-+      let f = Cc["@mozilla.org/file/directory_service;1"]
-+                .getService(Ci.nsIProperties).get("DefProfRt", Ci.nsIFile);
-+      f = f.parent.parent;  // Remove "Data/Browser"
-+#endif
-+      f.append("Docs");
-+      f.append("ChangeLog.txt");
-+
-+      let fs = Cc["@mozilla.org/network/file-input-stream;1"]
-+                 .createInstance(Ci.nsIFileInputStream);
-+      fs.init(f, -1, 0, 0);
-+      let s = NetUtil.readInputStreamToString(fs, fs.available());
-+      fs.close();
-+
-+      // Truncate at the first empty line.
-+      return s.replace(/[\r\n][\r\n][\s\S]*$/m, "");
-+    } catch (e) {}
-+
-+    return "";
-+  },
-+};
-+AboutTBUpdateListener.init(this);
-+#endif
- 
- var ContentSearchMediator = {
- 
-diff --git a/browser/base/jar.mn b/browser/base/jar.mn
-index a39f8fa..45f6e09 100644
---- a/browser/base/jar.mn
-+++ b/browser/base/jar.mn
-@@ -73,8 +73,14 @@ browser.jar:
-         content/browser/aboutTabCrashed.xhtml         (content/aboutTabCrashed.xhtml)
- *       content/browser/aboutTabGroupsMigration.xhtml (content/aboutTabGroupsMigration.xhtml)
-         content/browser/aboutTabGroupsMigration.js    (content/aboutTabGroupsMigration.js)
-+#ifdef TOR_BROWSER_UPDATE
-+        content/browser/abouttbupdate/aboutTBUpdate.xhtml    (content/abouttbupdate/aboutTBUpdate.xhtml)
-+        content/browser/abouttbupdate/aboutTBUpdate.js       (content/abouttbupdate/aboutTBUpdate.js)
-+        content/browser/abouttbupdate/aboutTBUpdate.css      (content/abouttbupdate/aboutTBUpdate.css)
-+        content/browser/abouttbupdate/aboutTBUpdateLogo.png  (content/abouttbupdate/aboutTBUpdateLogo.png)
-+#endif
- *       content/browser/browser.css                   (content/browser.css)
--        content/browser/browser.js                    (content/browser.js)
-+*       content/browser/browser.js                    (content/browser.js)
- *       content/browser/browser.xul                   (content/browser.xul)
-         content/browser/browser-addons.js             (content/browser-addons.js)
-         content/browser/browser-ctrlTab.js            (content/browser-ctrlTab.js)
-@@ -104,7 +110,7 @@ browser.jar:
-         content/browser/browser-thumbnails.js         (content/browser-thumbnails.js)
-         content/browser/browser-trackingprotection.js (content/browser-trackingprotection.js)
- *       content/browser/chatWindow.xul                (content/chatWindow.xul)
--        content/browser/tab-content.js                (content/tab-content.js)
-+*       content/browser/tab-content.js                (content/tab-content.js)
-         content/browser/content.js                    (content/content.js)
-         content/browser/social-content.js             (content/social-content.js)
-         content/browser/defaultthemes/1.footer.jpg    (content/defaultthemes/1.footer.jpg)
-diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp
-index 78f55c9..ab069e5 100644
---- a/browser/components/about/AboutRedirector.cpp
-+++ b/browser/components/about/AboutRedirector.cpp
-@@ -138,6 +138,13 @@ static RedirEntry kRedirMap[] = {
-     nsIAboutModule::ALLOW_SCRIPT |
-     nsIAboutModule::HIDE_FROM_ABOUTABOUT |
-     nsIAboutModule::MAKE_UNLINKABLE },
-+#ifdef TOR_BROWSER_UPDATE
-+  { "tbupdate", "chrome://browser/content/abouttbupdate/aboutTBUpdate.xhtml",
-+    nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
-+    nsIAboutModule::ALLOW_SCRIPT |
-+    nsIAboutModule::MAKE_UNLINKABLE |
-+    nsIAboutModule::HIDE_FROM_ABOUTABOUT },
-+#endif
- };
- static const int kRedirTotal = ArrayLength(kRedirMap);
- 
-diff --git a/browser/components/build/nsModule.cpp b/browser/components/build/nsModule.cpp
-index 7950d7c..a316cb3 100644
---- a/browser/components/build/nsModule.cpp
-+++ b/browser/components/build/nsModule.cpp
-@@ -115,6 +115,9 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
-     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "reader", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-saved", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-signup", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-+#ifdef TOR_BROWSER_UPDATE
-+    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "tbupdate", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-+#endif
- #if defined(XP_WIN)
-     { NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
- #elif defined(XP_MACOSX)
-diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js
-index b892eaf..8cc5cc5 100644
---- a/browser/components/nsBrowserContentHandler.js
-+++ b/browser/components/nsBrowserContentHandler.js
-@@ -573,6 +573,13 @@ nsBrowserContentHandler.prototype = {
-             // into account because that requires waiting for the session file
-             // to be read. If a crash occurs after updating, before restarting,
-             // we may open the startPage in addition to restoring the session.
-+            //
-+            // Tor Browser: Instead of opening the post-update "override page"
-+            // directly, an about:tbupdate page is opened that includes a link
-+            // to the override page as well as text from the first part of the
-+            // local ChangeLog.txt file. The override page URL comes from the
-+            // openURL attribute within the updates.xml file or, if no showURL
-+            // action is present, from the startup.homepage_override_url pref.
-             var ss = Components.classes["@mozilla.org/browser/sessionstartup;1"]
-                                .getService(Components.interfaces.nsISessionStartup);
-             willRestoreSession = ss.isAutomaticRestoreEnabled();
-@@ -586,6 +593,11 @@ nsBrowserContentHandler.prototype = {
-             overridePage = overridePage.replace("%OLD_TOR_BROWSER_VERSION%",
-                                                 old_tbversion);
- #endif
-+
-+#ifdef TOR_BROWSER_UPDATE
-+            if (overridePage)
-+              overridePage = "about:tbupdate?" + encodeURIComponent(overridePage);
-+#endif
-             break;
-         }
-       }
-diff --git a/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd b/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd
-new file mode 100644
-index 0000000..37567bd
---- /dev/null
-+++ b/browser/locales/en-US/chrome/browser/aboutTBUpdate.dtd
-@@ -0,0 +1,6 @@
-+<!ENTITY aboutTBUpdate.title "Tor Messenger Update">
-+<!ENTITY aboutTBUpdate.updated "Tor Messenger has been updated.">
-+<!ENTITY aboutTBUpdate.linkPrefix "For the most up-to-date information about this release, ">
-+<!ENTITY aboutTBUpdate.linkLabel  "visit our website">
-+<!ENTITY aboutTBUpdate.linkSuffix ".">
-+<!ENTITY aboutTBUpdate.changeLogHeading "Changelog:">
-diff --git a/browser/locales/jar.mn b/browser/locales/jar.mn
-index 44c5e6a..0f18e06 100644
---- a/browser/locales/jar.mn
-+++ b/browser/locales/jar.mn
-@@ -21,6 +21,9 @@
-     locale/browser/aboutTabCrashed.dtd             (%chrome/browser/aboutTabCrashed.dtd)
-     locale/browser/syncCustomize.dtd               (%chrome/browser/syncCustomize.dtd)
-     locale/browser/aboutSyncTabs.dtd               (%chrome/browser/aboutSyncTabs.dtd)
-+#ifdef TOR_BROWSER_UPDATE
-+    locale/browser/aboutTBUpdate.dtd               (%chrome/browser/aboutTBUpdate.dtd)
-+#endif
-     locale/browser/browser.dtd                     (%chrome/browser/browser.dtd)
-     locale/browser/baseMenuOverlay.dtd             (%chrome/browser/baseMenuOverlay.dtd)
-     locale/browser/browser.properties              (%chrome/browser/browser.properties)
--- 
-cgit v0.10.2
diff --git a/projects/instantbird/Updater-Linux-search-path-bug-18900.mozpatch b/projects/instantbird/Updater-Linux-search-path-bug-18900.mozpatch
deleted file mode 100644
index 3c46bd7..0000000
--- a/projects/instantbird/Updater-Linux-search-path-bug-18900.mozpatch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 82cfa7c8786c1ad1421666365bd71f3594861328 Mon Sep 17 00:00:00 2001
-From: Kathy Brade <brade at pearlcrescent.com>
-Date: Tue, 26 Apr 2016 14:25:35 -0400
-Subject: Bug 18900: updater doesn't work on Linux (cannot find libraries)
-
-Revert "Bug 1159090 - Only append library path for updater if it is a unique value. r=rstrong"
-
-This reverts commit 5c4fcaf37f8e479b5d3c46a21b8a48ad1fe567d8.
-
-diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp
-index 0c7b6b0..d256f2a 100644
---- a/toolkit/xre/nsUpdateDriver.cpp
-+++ b/toolkit/xre/nsUpdateDriver.cpp
-@@ -488,20 +488,20 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir,
- static void
- AppendToLibPath(const char *pathToAppend)
- {
-+  char *s = nullptr;
-   char *pathValue = getenv(LD_LIBRARY_PATH_ENVVAR_NAME);
-   if (nullptr == pathValue || '\0' == *pathValue) {
--    char *s = PR_smprintf("%s=%s", LD_LIBRARY_PATH_ENVVAR_NAME, pathToAppend);
--    PR_SetEnv(s);
--  } else if (!strstr(pathValue, pathToAppend)) {
--    char *s = PR_smprintf("%s=%s" PATH_SEPARATOR "%s",
-+    s = PR_smprintf("%s=%s", LD_LIBRARY_PATH_ENVVAR_NAME, pathToAppend);
-+  } else {
-+    s = PR_smprintf("%s=%s" PATH_SEPARATOR "%s",
-                     LD_LIBRARY_PATH_ENVVAR_NAME, pathToAppend, pathValue);
--    PR_SetEnv(s);
-   }
- 
-   // The memory used by PR_SetEnv is not copied to the environment on all
-   // platform, it can be used by reference directly. So we purposely do not
-   // call PR_smprintf_free on s.  Subsequent calls to PR_SetEnv will free
-   // the old memory first.
-+  PR_SetEnv(s);
- }
- #endif
- 
--- 
-cgit v0.10.2
-
diff --git a/projects/instantbird/bug-1167248.mozpatch b/projects/instantbird/bug-1167248.mozpatch
deleted file mode 100644
index 2ef5804..0000000
--- a/projects/instantbird/bug-1167248.mozpatch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 65aeb7ca6d2b5f55acb35bb8eef3152b613faf1f Mon Sep 17 00:00:00 2001
-From: Jacek Caban <jacek at codeweavers.com>
-Date: Thu, 21 Jan 2016 13:40:07 +0100
-Subject: [PATCH] Bug 1167248 - Cross compilation fixup.
-
----
- js/src/jsmath.cpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp
-index 56ba1cf..3f4ddd9 100644
---- a/js/src/jsmath.cpp
-+++ b/js/src/jsmath.cpp
-@@ -44,7 +44,7 @@
- // "Community Additions" comment on MSDN here:
- // https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx
- # define SystemFunction036 NTAPI SystemFunction036
--# include <NTSecAPI.h>
-+# include <ntsecapi.h>
- # undef SystemFunction036
- #endif
- 
diff --git a/projects/instantbird/bug-1240589.mozpatch b/projects/instantbird/bug-1240589.mozpatch
deleted file mode 100644
index 0c52b02..0000000
--- a/projects/instantbird/bug-1240589.mozpatch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 9e4a3887ed69bccc6186ef8765dfab690239f5fa Mon Sep 17 00:00:00 2001
-From: Jacek Caban <jacek at codeweavers.com>
-Date: Sat, 30 Jan 2016 17:31:37 +0100
-Subject: [PATCH] Bug 1240589 - Cross compilation fixup.
-
----
- ipc/chromium/src/base/rand_util_win.cc | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/ipc/chromium/src/base/rand_util_win.cc b/ipc/chromium/src/base/rand_util_win.cc
-index 2a4fb29..d998cb6 100644
---- a/ipc/chromium/src/base/rand_util_win.cc
-+++ b/ipc/chromium/src/base/rand_util_win.cc
-@@ -11,7 +11,7 @@
- // "Community Additions" comment on MSDN here:
- // http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx
- #define SystemFunction036 NTAPI SystemFunction036
--#include <NTSecAPI.h>
-+#include <ntsecapi.h>
- #undef SystemFunction036
- 
- #include <algorithm>
diff --git a/projects/instantbird/config b/projects/instantbird/config
index 19aaba6..f6e5e5a 100644
--- a/projects/instantbird/config
+++ b/projects/instantbird/config
@@ -80,7 +80,6 @@ input_files:
   - filename: trac-17896.patch
   - filename: trac-17494.patch
   - filename: trac-13312.patch
-  - filename: trac-20206.mozpatch
   - filename: search-context-menu.patch
   - filename: search-preferences-xul.patch
   - filename: log-preferences-xul.patch
@@ -124,28 +123,11 @@ input_files:
     enable: '[% c("var/osx") %]'
   - filename: cert_override.txt
     enable: '[% c("var/osx") %]'
-  - filename: trac-18290.mozpatch
-    enable: '[% c("var/windows") %]'
-  - filename: bug-1240589.mozpatch
-    enable: '[% c("var/windows") %]'
-  - filename: bug-1167248.mozpatch
-    enable: '[% c("var/windows") %]'
   - filename: trac-18331.mozpatch
     enable: '[% c("var/osx") %]'
-  - filename: Change-the-default-Firefox-profile-director-bug-9173.mozpatch
-  - filename: Firefox-update-process-bug-4234.mozpatch
-  - filename: Improve-profile-access-bug-14631-first.mozpatch
-  - filename: Improve-profile-access-bug-14631-second.mozpatch
-  - filename: Mac-outside-app-data-bug-13252.mozpatch
-  - filename: Sign-MAR-files-bug-13379.mozpatch
-  - filename: Update-load-local-changes-bug-14392-first.mozpatch
-  - filename: Update-load-local-changes-bug-16940-second.mozpatch
-  - filename: Updater-Linux-search-path-bug-18900.mozpatch
   - filename: aboutTBUpdateLogo.png
-  - filename: 0001-Bug-1070710-Add-mozilla-ViewRegion-which-assembles-a.mozpatch
-  - filename: 0002-Bug-1070710-Use-ViewRegion-for-vibrant-areas-in-Vibr.mozpatch
-  - filename: 0003-Bug-1070710-Use-ViewRegion-for-window-dragging.-r-sp.mozpatch
   - filename: trac-16475.mozpatch
+  - filename: trac-20309.mozpatch
   - filename: updater-remove-links.mozpatch
   - filename: OSX-package-as-tar.bz2.mozpatch
     enable: '[% c("var/osx") %]'
diff --git a/projects/instantbird/trac-16475.mozpatch b/projects/instantbird/trac-16475.mozpatch
index 6e4586a..4fa14ab 100644
--- a/projects/instantbird/trac-16475.mozpatch
+++ b/projects/instantbird/trac-16475.mozpatch
@@ -1,53 +1,32 @@
+From 5baab1b1e4e9c4c4c59f864ffe03265ef17f956a Mon Sep 17 00:00:00 2001
+From: Arlo Breault <arlolra at gmail.com>
+Date: Thu, 6 Oct 2016 20:13:35 -0700
+Subject: [PATCH] Block flash too
+
+---
+ dom/plugins/base/nsPluginHost.cpp | 9 ---------
+ 1 file changed, 9 deletions(-)
+
 diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
+index 5345ce7..1569236 100644
 --- a/dom/plugins/base/nsPluginHost.cpp
 +++ b/dom/plugins/base/nsPluginHost.cpp
-@@ -2085,6 +2085,26 @@
+@@ -2081,15 +2081,6 @@ PRBool nsPluginHost::GhettoBlacklist(nsIFile *pluginFile)
+     return PR_TRUE; // fuck 'em. blacklist.
    }
- }
- 
-+PRBool nsPluginHost::GhettoBlacklist(nsIFile *pluginFile)
-+{
-+    nsCString leaf;
-+    const char *leafStr;
-+    nsresult rv;
-+    
-+    rv = pluginFile->GetNativeLeafName(leaf);
-+    if (NS_FAILED(rv)) {
-+        return PR_TRUE; // blacklist.
-+    }
-+
-+    leafStr = leaf.get();
-+
-+    if (!leafStr) {
-+        return PR_TRUE; // blacklist.
-+    }
-+
-+    return PR_TRUE; // blacklist.
-+}
-+
- typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
  
- nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
-@@ -2194,6 +2214,10 @@
-       continue;
-     }
- 
-+    if (GhettoBlacklist(localfile)) {
-+        continue;
-+    }
-+
-     // if it is not found in cache info list or has been changed, create a new one
-     if (!pluginTag) {
-       nsPluginFile pluginFile(localfile);
-diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h
---- a/dom/plugins/base/nsPluginHost.h
-+++ b/dom/plugins/base/nsPluginHost.h
-@@ -334,6 +334,8 @@
-   // Loads all cached plugins info into mCachedPlugins
-   nsresult ReadPluginInfo();
+-  // libgnashplugin.so, libflashplayer.so, Flash Player-10.4-10.5.plugin,
+-  // NPSWF32.dll, NPSWF64.dll
+-  if (strstr(leafStr, "libgnashplugin") == leafStr ||
+-      strstr(leafStr, "libflashplayer") == leafStr ||
+-      strstr(leafStr, "Flash Player") == leafStr ||
+-      strstr(leafStr, "NPSWF") == leafStr) {
+-    return PR_FALSE;
+-  }
+-
+   return PR_TRUE; // fuck 'em. blacklist.
+ }
  
-+  PRBool GhettoBlacklist(nsIFile *pluginFile);
-+
-   // Given a file path, returns the plugins info from our cache
-   // and removes it from the cache.
-   void RemoveCachedPluginsInfo(const char *filePath,
+-- 
+2.10.1
+
diff --git a/projects/instantbird/trac-18290.mozpatch b/projects/instantbird/trac-18290.mozpatch
deleted file mode 100644
index 1766fb8..0000000
--- a/projects/instantbird/trac-18290.mozpatch
+++ /dev/null
@@ -1,47 +0,0 @@
-From dfb3f02c452b56bd22d7cdf2086b29e118fea688 Mon Sep 17 00:00:00 2001
-From: Georg Koppen <gk at torproject.org>
-Date: Wed, 10 Feb 2016 13:14:03 +0000
-Subject: [PATCH] Disabling view management for mingw-w64 builds
-
-
-diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp
-index 85b2879..89be490 100644
---- a/widget/windows/WindowsUIUtils.cpp
-+++ b/widget/windows/WindowsUIUtils.cpp
-@@ -20,6 +20,8 @@
- #include "nsString.h"
- #include "nsIWidget.h"
- 
-+/* Disable in mingw-w64 Gecko builds. */
-+#if 0
- #include <windows.ui.viewmanagement.h>
- 
- #pragma comment(lib, "runtimeobject.lib")
-@@ -85,6 +87,8 @@ public:
- };
- #endif
- 
-+#endif
-+
- WindowsUIUtils::WindowsUIUtils() :
-   mInTabletMode(eTabletModeUnknown)
- {
-@@ -113,6 +117,7 @@ WindowsUIUtils::GetInTabletMode(bool* aResult)
- NS_IMETHODIMP
- WindowsUIUtils::UpdateTabletModeState()
- {
-+#if 0
-   if (!IsWin10OrLater()) {
-     return NS_OK;
-   }
-@@ -168,6 +173,7 @@ WindowsUIUtils::UpdateTabletModeState()
-       }
-     }
-   }
-+#endif
- 
-   return NS_OK;
- }
--- 
-2.7.0
-
diff --git a/projects/instantbird/trac-20206.mozpatch b/projects/instantbird/trac-20206.mozpatch
deleted file mode 100644
index b47cbc9..0000000
--- a/projects/instantbird/trac-20206.mozpatch
+++ /dev/null
@@ -1,73 +0,0 @@
-
-# HG changeset patch
-# User Jonathan Kew <jkew at mozilla.com>
-# Date 1467313395 -3600
-# Node ID eb6de343924f07e384be029a11c2404b7ac5e3df
-# Parent  444a4a7233f776cea47f2a9eabe6a7f301de4b51
-Bug 1283573 - Don't attempt to look up a single-face-family name if the corresponding main family isn't available. r=mstange
-
-diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm
---- a/gfx/thebes/gfxMacPlatformFontList.mm
-+++ b/gfx/thebes/gfxMacPlatformFontList.mm
-@@ -726,22 +726,31 @@ gfxMacPlatformFontList::InitSingleFaceLi
- {
-     AutoTArray<nsString, 10> singleFaceFonts;
-     gfxFontUtils::GetPrefsFontList("font.single-face-list", singleFaceFonts);
- 
-     uint32_t numFonts = singleFaceFonts.Length();
-     for (uint32_t i = 0; i < numFonts; i++) {
-         LOG_FONTLIST(("(fontlist-singleface) face name: %s\n",
-                       NS_ConvertUTF16toUTF8(singleFaceFonts[i]).get()));
--        gfxFontEntry *fontEntry = LookupLocalFont(singleFaceFonts[i],
-+        nsAutoString familyName(singleFaceFonts[i]);
-+        auto colon = familyName.FindChar(':');
-+        if (colon != kNotFound) {
-+            nsAutoString key(Substring(familyName, colon + 1));
-+            ToLowerCase(key);
-+            if (!mFontFamilies.GetWeak(key)) {
-+                continue;
-+            }
-+            familyName.Truncate(colon);
-+        }
-+        gfxFontEntry *fontEntry = LookupLocalFont(familyName,
-                                                   400, 0,
-                                                   NS_FONT_STYLE_NORMAL);
-         if (fontEntry) {
--            nsAutoString familyName, key;
--            familyName = singleFaceFonts[i];
-+            nsAutoString key;
-             GenerateFontListKey(familyName, key);
-             LOG_FONTLIST(("(fontlist-singleface) family name: %s, key: %s\n",
-                           NS_ConvertUTF16toUTF8(familyName).get(),
-                           NS_ConvertUTF16toUTF8(key).get()));
- 
-             // add only if doesn't exist already
-             if (!mFontFamilies.GetWeak(key)) {
-                 gfxFontFamily *familyEntry =
-diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
---- a/modules/libpref/init/all.js
-+++ b/modules/libpref/init/all.js
-@@ -3759,19 +3759,19 @@ pref("font.size.variable.zh-TW", 15);
- pref("font.name.serif.x-math", "Latin Modern Math");
- // Apple's Symbol is Unicode so use it
- pref("font.name-list.serif.x-math", "Latin Modern Math, XITS Math, Cambria Math, TeX Gyre Bonum Math, TeX Gyre Pagella Math, TeX Gyre Schola, TeX Gyre Termes Math, STIX Math, Asana Math, STIXGeneral, DejaVu Serif, DejaVu Sans, Symbol, Times");
- pref("font.name.sans-serif.x-math", "Helvetica");
- pref("font.name.monospace.x-math", "Courier");
- pref("font.name.cursive.x-math", "Apple Chancery");
- pref("font.name.fantasy.x-math", "Papyrus");
- 
--// individual font faces to be treated as independent families
--// names are Postscript names of each face
--pref("font.single-face-list", "Osaka-Mono");
-+// Individual font faces to be treated as independent families,
-+// listed as <Postscript name of face:Owning family name>
-+pref("font.single-face-list", "Osaka-Mono:Osaka");
- 
- // optimization hint for fonts with localized names to be read in at startup, otherwise read in at lookup miss
- // names are canonical family names (typically English names)
- pref("font.preload-names-list", "Hiragino Kaku Gothic ProN,Hiragino Mincho ProN,STSong");
- 
- // Override font-weight values for some problematic families Apple ships
- // (see bug 931426).
- // The name here is the font's PostScript name, which can be checked in
-
diff --git a/projects/instantbird/trac-20309.mozpatch b/projects/instantbird/trac-20309.mozpatch
new file mode 100644
index 0000000..55fc453
--- /dev/null
+++ b/projects/instantbird/trac-20309.mozpatch
@@ -0,0 +1,25 @@
+From 8cb3d859bc95b7d86152437c0983534f6db1f08c Mon Sep 17 00:00:00 2001
+From: Arlo Breault <arlolra at gmail.com>
+Date: Thu, 6 Oct 2016 20:20:11 -0700
+Subject: [PATCH] s/TorBrowser-Data/TorMessenger-Data/
+
+---
+ xpcom/io/TorFileUtils.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/xpcom/io/TorFileUtils.cpp b/xpcom/io/TorFileUtils.cpp
+index c45961a..23d6fbe 100644
+--- a/xpcom/io/TorFileUtils.cpp
++++ b/xpcom/io/TorFileUtils.cpp
+@@ -16,7 +16,7 @@ TorBrowser_GetUserDataDir(nsIFile *aExeFile, nsIFile** aFile)
+   nsCOMPtr<nsIFile> tbDataDir;
+ 
+ #ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
+-  nsAutoCString tbDataLeafName(NS_LITERAL_CSTRING("TorBrowser-Data"));
++  nsAutoCString tbDataLeafName(NS_LITERAL_CSTRING("TorMessenger-Data"));
+   nsCOMPtr<nsIFile> appRootDir;
+   nsresult rv = GetAppRootDir(aExeFile, getter_AddRefs(appRootDir));
+   NS_ENSURE_SUCCESS(rv, rv);
+-- 
+2.10.1
+
diff --git a/projects/mozilla/config b/projects/mozilla/config
index 4612d02..f8faefb 100644
--- a/projects/mozilla/config
+++ b/projects/mozilla/config
@@ -1,7 +1,7 @@
 # vim: filetype=yaml sw=2
 version: '[% c("abbrev") %]'
 git_url: https://git.torproject.org/tor-browser.git
-git_hash: 90a36a577e8e4934860513c9ec5f1165ac81e53b
+git_hash: 8b1f07f31cd04fb157bf99a9e2e600b4422f277f
 src: |
   #!/bin/sh
   set -e





More information about the tor-commits mailing list