diff --git a/.firefox.metadata b/.firefox.metadata
index f33c77b..1e6295c 100644
--- a/.firefox.metadata
+++ b/.firefox.metadata
@@ -1,5 +1,6 @@
-c822547dbc12e2baebdfdfb38b665e23f0c2513a SOURCES/cbindgen-vendor.tar.xz
-0693b8482089631c9c1c2b3c521aa701013e8a06 SOURCES/firefox-91.13.0esr.processed-source.tar.xz
-3ad70d1bac601289f0355fed936bfd61e2fbbfd5 SOURCES/firefox-langpacks-91.13.0esr-20220817.tar.xz
-b5fd1332d8e0d37339ae170c7bebcb63a40b22e0 SOURCES/nspr-4.32.0-1.el8_1.src.rpm
-8fff814901e03c2518ede2f8992d898f5ba61ed9 SOURCES/nss-3.67.0-7.el8_1.src.rpm
+52f2d51d0e17d137571bf3a766f514d34e28e556 SOURCES/cbindgen-vendor.tar.xz
+8161b83c675a6a598a89e377bc50c675cb0bf43c SOURCES/firefox-102.3.0esr.processed-source.tar.xz
+e7f01e90e3d0ca5dfa84d44e9e8b9a0770585d72 SOURCES/firefox-langpacks-102.3.0esr-20220913.tar.xz
+da39a3ee5e6b4b0d3255bfef95601890afd80709 SOURCES/mochitest-python.tar.gz
+af58b3c87a8b5491dde63b07efaeb3d7f1ec56c1 SOURCES/nspr-4.34.0-3.el8_1.src.rpm
+fc5297c6830f0a1e88f84b94b0b066487664061b SOURCES/nss-3.79.0-6.el8_1.src.rpm
diff --git a/.gitignore b/.gitignore
index aa16c51..e1d19cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 SOURCES/cbindgen-vendor.tar.xz
-SOURCES/firefox-91.13.0esr.processed-source.tar.xz
-SOURCES/firefox-langpacks-91.13.0esr-20220817.tar.xz
-SOURCES/nspr-4.32.0-1.el8_1.src.rpm
-SOURCES/nss-3.67.0-7.el8_1.src.rpm
+SOURCES/firefox-102.3.0esr.processed-source.tar.xz
+SOURCES/firefox-langpacks-102.3.0esr-20220913.tar.xz
+SOURCES/mochitest-python.tar.gz
+SOURCES/nspr-4.34.0-3.el8_1.src.rpm
+SOURCES/nss-3.79.0-6.el8_1.src.rpm
diff --git a/SOURCES/0001-GLIBCXX-fix-for-GCC-12.patch b/SOURCES/0001-GLIBCXX-fix-for-GCC-12.patch
new file mode 100644
index 0000000..37d6f50
--- /dev/null
+++ b/SOURCES/0001-GLIBCXX-fix-for-GCC-12.patch
@@ -0,0 +1,44 @@
+From efd5bc0715e5477318be95a76811cda0a89e8289 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
+Date: Fri, 4 Mar 2022 12:00:26 +0100
+Subject: [PATCH] GLIBCXX fix for GCC 12?
+
+---
+ build/unix/stdc++compat/stdc++compat.cpp | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/build/unix/stdc++compat/stdc++compat.cpp b/build/unix/stdc++compat/stdc++compat.cpp
+index 0180f6bcfa998..8d7a542ff11f0 100644
+--- a/build/unix/stdc++compat/stdc++compat.cpp
++++ b/build/unix/stdc++compat/stdc++compat.cpp
+@@ -24,6 +24,7 @@
+    GLIBCXX_3.4.27 is from gcc 10
+    GLIBCXX_3.4.28 is from gcc 10
+    GLIBCXX_3.4.29 is from gcc 11
++   GLIBCXX_3.4.30 is from gcc 12
+ 
+ This file adds the necessary compatibility tricks to avoid symbols with
+ version GLIBCXX_3.4.20 and bigger, keeping binary compatibility with
+@@ -69,6 +70,19 @@ void __attribute__((weak)) __throw_bad_array_new_length() { MOZ_CRASH(); }
+ }  // namespace std
+ #endif
+ 
++#if _GLIBCXX_RELEASE >= 12
++namespace std {
++
++/* This avoids the GLIBCXX_3.4.30 symbol version. */
++void __attribute__((weak))
++__glibcxx_assert_fail(const char* __file, int __line, const char* __function,
++                      const char* __condition) {
++  MOZ_CRASH();
++}
++
++}  // namespace std
++#endif
++
+ /* While we generally don't build with exceptions, we have some host tools
+  * that do use them. libstdc++ from GCC 5.0 added exception constructors with
+  * char const* argument. Older versions only have a constructor with
+-- 
+2.35.1
+
diff --git a/SOURCES/Bug-1238661---fix-mozillaSignalTrampoline-to-work-.patch b/SOURCES/Bug-1238661---fix-mozillaSignalTrampoline-to-work-.patch
deleted file mode 100644
index 6dfe2ad..0000000
--- a/SOURCES/Bug-1238661---fix-mozillaSignalTrampoline-to-work-.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up firefox-60.0/mfbt/LinuxSignal.h.mozilla-1238661 firefox-60.0/mfbt/LinuxSignal.h
---- firefox-60.0/mfbt/LinuxSignal.h.mozilla-1238661	2018-04-27 08:55:38.848241768 +0200
-+++ firefox-60.0/mfbt/LinuxSignal.h	2018-04-27 09:06:47.946769859 +0200
-@@ -22,7 +22,7 @@ __attribute__((naked)) void SignalTrampo
-                                              void* aContext) {
-   asm volatile("nop; nop; nop; nop" : : : "memory");
- 
--  asm volatile("b %0" : : "X"(H) : "memory");
-+  asm volatile("bx %0" : : "r"(H), "l"(aSignal), "l"(aInfo), "l"(aContext) : "memory");
- }
- 
- #  define MOZ_SIGNAL_TRAMPOLINE(h) (mozilla::SignalTrampoline<h>)
diff --git a/SOURCES/Bug-1526653---fix_user_vfp_armv7.patch b/SOURCES/Bug-1526653---fix_user_vfp_armv7.patch
deleted file mode 100644
index 3f84f95..0000000
--- a/SOURCES/Bug-1526653---fix_user_vfp_armv7.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From fd6847c9416f9eebde636e21d794d25d1be8791d Mon Sep 17 00:00:00 2001
-From: Mike Hommey <mh@glandium.org>
-Date: Sat, 1 Jun 2019 09:06:01 +0900
-Subject: [PATCH] Bug 1526653 - Include struct definitions for user_vfp and
- user_vfp_exc.
-
----
- js/src/wasm/WasmSignalHandlers.cpp | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/js/src/wasm/WasmSignalHandlers.cpp b/js/src/wasm/WasmSignalHandlers.cpp
-index 636537f8478..383c380f04c 100644
---- a/js/src/wasm/WasmSignalHandlers.cpp
-+++ b/js/src/wasm/WasmSignalHandlers.cpp
-@@ -248,7 +248,16 @@ using mozilla::DebugOnly;
- #endif
- 
- #ifdef WASM_EMULATE_ARM_UNALIGNED_FP_ACCESS
--#  include <sys/user.h>
-+struct user_vfp {
-+  unsigned long long fpregs[32];
-+  unsigned long fpscr;
-+};
-+
-+struct user_vfp_exc {
-+  unsigned long fpexc;
-+  unsigned long fpinst;
-+  unsigned long fpinst2;
-+};
- #endif
- 
- #if defined(ANDROID)
--- 
-2.20.1
-
diff --git a/SOURCES/D110204-fscreen.diff b/SOURCES/D110204-fscreen.diff
index ce4c908..c25f992 100644
--- a/SOURCES/D110204-fscreen.diff
+++ b/SOURCES/D110204-fscreen.diff
@@ -1,22 +1,35 @@
---- firefox-91.11.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff	2022-06-20 21:18:51.000000000 +0200
-+++ firefox-91.11.0/widget/gtk/nsWindow.cpp	2022-06-21 12:21:44.892706641 +0200
-@@ -91,6 +91,7 @@
+diff -up firefox-102.2.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff firefox-102.2.0/widget/gtk/nsWindow.cpp
+--- firefox-102.2.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff	2022-08-18 21:54:09.000000000 +0200
++++ firefox-102.2.0/widget/gtk/nsWindow.cpp	2022-09-02 15:55:18.023843940 +0200
+@@ -96,6 +96,7 @@
+ #include "ScreenHelperGTK.h"
  #include "SystemTimeConverter.h"
  #include "WidgetUtilsGtk.h"
- #include "mozilla/X11Util.h"
 +#include "nsIBrowserHandler.h"
  
  #ifdef ACCESSIBILITY
  #  include "mozilla/a11y/LocalAccessible.h"
-@@ -441,6 +442,7 @@ nsWindow::nsWindow()
-       mHasMappedToplevel(false),
-       mRetryPointerGrab(false),
-       mSizeState(nsSizeMode_Normal),
-+      mPendingFullscreen(false),
-       mAspectRatio(0.0f),
-       mAspectRatioSaved(0.0f),
-       mLastScrollEventTime(GDK_CURRENT_TIME),
-@@ -4618,6 +4620,19 @@ void nsWindow::OnWindowStateEvent(GtkWid
+@@ -169,7 +170,8 @@ const gint kEvents = GDK_TOUCHPAD_GESTUR
+                      GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
+                      GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+                      GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK | GDK_SCROLL_MASK |
+-                     GDK_POINTER_MOTION_MASK | GDK_PROPERTY_CHANGE_MASK;
++                     GDK_POINTER_MOTION_MASK | GDK_PROPERTY_CHANGE_MASK |
++                     GDK_FOCUS_CHANGE_MASK;
+ 
+ /* utility functions */
+ static bool is_mouse_in_window(GdkWindow* aWindow, gdouble aMouseX,
+@@ -408,7 +410,8 @@ nsWindow::nsWindow()
+       mMovedAfterMoveToRect(false),
+       mResizedAfterMoveToRect(false),
+       mConfiguredClearColor(false),
+-      mGotNonBlankPaint(false) {
++      mGotNonBlankPaint(false),
++      mPendingFullscreen(false) {
+   mWindowType = eWindowType_child;
+   mSizeConstraints.mMaxSize = GetSafeWindowSize(mSizeConstraints.mMaxSize);
+ 
+@@ -4814,6 +4817,19 @@ void nsWindow::OnWindowStateEvent(GtkWid
        ClearTransparencyBitmap();
      }
    }
@@ -26,17 +39,17 @@
 +  if (mPendingFullscreen &&
 +      !(aEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
 +    LOG(
-+        ("  Window should be fullscreen, but it's not, retrying set to "
-+         "fullscreen.\n"));
++        "  Window should be fullscreen, but it's not, retrying set to "
++         "fullscreen.\n");
 +    MakeFullScreen(true);
 +  } else {
-+    LOG(("  Window successfully switched to fullscreen, happy now\n"));
++    LOG("  Window successfully switched to fullscreen, happy now\n");
 +    mPendingFullscreen = false;
 +  }
  }
  
  void nsWindow::OnDPIChanged() {
-@@ -6860,6 +6875,19 @@ nsresult nsWindow::MakeFullScreen(bool a
+@@ -7042,6 +7058,19 @@ nsresult nsWindow::MakeFullScreen(bool a
        }
      }
  
@@ -47,22 +60,23 @@
 +      bool isKiosk;
 +      browserHandler->GetKiosk(&isKiosk);
 +      if (isKiosk) {
-+        LOG(("  is kiosk, ensure the window switch to fullscreen\n"));
++        LOG("  is kiosk, ensure the window switch to fullscreen\n");
 +        mPendingFullscreen = true;
 +      }
 +    } else {
-+      LOG(("  Cannot find the browserHandler service.\n"));
++      LOG("  Cannot find the browserHandler service.\n");
 +    }
      gtk_window_fullscreen(GTK_WINDOW(mShell));
    } else {
      mSizeMode = mLastSizeMode;
---- firefox-91.11.0/widget/gtk/nsWindow.h.D110204-fscreen.diff	2022-06-21 12:21:44.894706636 +0200
-+++ firefox-91.11.0/widget/gtk/nsWindow.h	2022-06-21 12:25:20.985209461 +0200
-@@ -767,6 +767,7 @@ class nsWindow final : public nsBaseWidg
-    * move-to-rect callback we set mResizedAfterMoveToRect.
+diff -up firefox-102.2.0/widget/gtk/nsWindow.h.D110204-fscreen.diff firefox-102.2.0/widget/gtk/nsWindow.h
+--- firefox-102.2.0/widget/gtk/nsWindow.h.D110204-fscreen.diff	2022-08-18 21:53:52.000000000 +0200
++++ firefox-102.2.0/widget/gtk/nsWindow.h	2022-09-02 08:17:07.606010905 +0200
+@@ -712,6 +712,7 @@ class nsWindow final : public nsBaseWidg
+    * move-to-rect callback we set mMovedAfterMoveToRect/mResizedAfterMoveToRect.
     */
-   bool mWaitingForMoveToRectCallback;
-+  bool mPendingFullscreen;
-   bool mResizedAfterMoveToRect;
+   bool mWaitingForMoveToRectCallback : 1;
++  bool mPendingFullscreen : 1;
+   bool mMovedAfterMoveToRect : 1;
+   bool mResizedAfterMoveToRect : 1;
  
-   /**
diff --git a/SOURCES/build-aarch64-skia.patch b/SOURCES/build-aarch64-skia.patch
new file mode 100644
index 0000000..a63e3e8
--- /dev/null
+++ b/SOURCES/build-aarch64-skia.patch
@@ -0,0 +1,45 @@
+diff -up firefox-72.0/gfx/skia/skia/include/private/SkHalf.h.aarch64-skia firefox-72.0/gfx/skia/skia/include/private/SkHalf.h
+--- firefox-72.0/gfx/skia/skia/include/private/SkHalf.h.aarch64-skia	2020-01-02 22:33:02.000000000 +0100
++++ firefox-72.0/gfx/skia/skia/include/private/SkHalf.h	2020-01-03 09:00:37.537296105 +0100
+@@ -40,7 +40,7 @@ static inline Sk4h SkFloatToHalf_finite_
+ 
+ static inline Sk4f SkHalfToFloat_finite_ftz(uint64_t rgba) {
+     Sk4h hs = Sk4h::Load(&rgba);
+-#if !defined(SKNX_NO_SIMD) && defined(SK_CPU_ARM64)
++#if 0 // !defined(SKNX_NO_SIMD) && defined(SK_CPU_ARM64)
+     float32x4_t fs;
+     asm ("fcvtl %[fs].4s, %[hs].4h   \n"   // vcvt_f32_f16(...)
+         : [fs] "=w" (fs)                   // =w: write-only NEON register
+@@ -62,7 +62,7 @@ static inline Sk4f SkHalfToFloat_finite_
+ }
+ 
+ static inline Sk4h SkFloatToHalf_finite_ftz(const Sk4f& fs) {
+-#if !defined(SKNX_NO_SIMD) && defined(SK_CPU_ARM64)
++#if 0 // !defined(SKNX_NO_SIMD) && defined(SK_CPU_ARM64)
+     float32x4_t vec = fs.fVec;
+     asm ("fcvtn %[vec].4h, %[vec].4s  \n"   // vcvt_f16_f32(vec)
+         : [vec] "+w" (vec));                // +w: read-write NEON register
+diff -up firefox-72.0/gfx/skia/skia/src/opts/SkRasterPipeline_opts.h.aarch64-skia firefox-72.0/gfx/skia/skia/src/opts/SkRasterPipeline_opts.h
+--- firefox-72.0/gfx/skia/skia/src/opts/SkRasterPipeline_opts.h.aarch64-skia	2020-01-03 09:00:37.538296107 +0100
++++ firefox-72.0/gfx/skia/skia/src/opts/SkRasterPipeline_opts.h	2020-01-03 10:11:41.259219508 +0100
+@@ -1087,7 +1087,7 @@ SI F from_half(U16 h) {
+ }
+ 
+ SI U16 to_half(F f) {
+-#if defined(JUMPER_IS_NEON) && defined(SK_CPU_ARM64) \
++#if 0 //defined(JUMPER_IS_NEON) && defined(SK_CPU_ARM64) \
+     && !defined(SK_BUILD_FOR_GOOGLE3)  // Temporary workaround for some Google3 builds.
+     return vcvt_f16_f32(f);
+ 
+diff -up firefox-72.0/gfx/skia/skia/third_party/skcms/src/Transform_inl.h.aarch64-skia firefox-72.0/gfx/skia/skia/third_party/skcms/src/Transform_inl.h
+--- firefox-72.0/gfx/skia/skia/third_party/skcms/src/Transform_inl.h.aarch64-skia	2020-01-03 09:00:37.538296107 +0100
++++ firefox-72.0/gfx/skia/skia/third_party/skcms/src/Transform_inl.h	2020-01-03 10:11:53.513250979 +0100
+@@ -183,8 +183,6 @@ SI F F_from_Half(U16 half) {
+ SI U16 Half_from_F(F f) {
+ #if defined(USING_NEON_FP16)
+     return bit_pun<U16>(f);
+-#elif defined(USING_NEON_F16C)
+-    return (U16)vcvt_f16_f32(f);
+ #elif defined(USING_AVX512F)
+     return (U16)_mm512_cvtps_ph((__m512 )f, _MM_FROUND_CUR_DIRECTION );
+ #elif defined(USING_AVX_F16C)
diff --git a/SOURCES/build-arm-libaom.patch b/SOURCES/build-arm-libaom.patch
new file mode 100644
index 0000000..985f01d
--- /dev/null
+++ b/SOURCES/build-arm-libaom.patch
@@ -0,0 +1,12 @@
+diff -up firefox-73.0/media/libaom/moz.build.old firefox-73.0/media/libaom/moz.build
+--- firefox-73.0/media/libaom/moz.build.old	2020-02-07 23:13:28.000000000 +0200
++++ firefox-73.0/media/libaom/moz.build	2020-02-17 10:30:08.509805092 +0200
+@@ -55,7 +55,7 @@ elif CONFIG['CPU_ARCH'] == 'arm':
+ 
+     for f in SOURCES:
+         if f.endswith('neon.c'):
+-            SOURCES[f].flags += CONFIG['VPX_ASFLAGS']
++            SOURCES[f].flags += CONFIG['NEON_FLAGS']
+ 
+     if CONFIG['OS_TARGET'] == 'Android':
+         # For cpu-features.h
diff --git a/SOURCES/build-arm-libopus.patch b/SOURCES/build-arm-libopus.patch
new file mode 100644
index 0000000..1b3f31b
--- /dev/null
+++ b/SOURCES/build-arm-libopus.patch
@@ -0,0 +1,12 @@
+diff -up firefox-66.0/media/libopus/silk/arm/arm_silk_map.c.old firefox-66.0/media/libopus/silk/arm/arm_silk_map.c
+--- firefox-66.0/media/libopus/silk/arm/arm_silk_map.c.old	2019-03-12 21:07:35.356677522 +0100
++++ firefox-66.0/media/libopus/silk/arm/arm_silk_map.c	2019-03-12 21:07:42.937693394 +0100
+@@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE.
+ # include "config.h"
+ #endif
+ 
+-#include "main_FIX.h"
++#include "fixed/main_FIX.h"
+ #include "NSQ.h"
+ #include "SigProc_FIX.h"
+ 
diff --git a/SOURCES/build-ascii-decode-fail-rhel7.patch b/SOURCES/build-ascii-decode-fail-rhel7.patch
new file mode 100644
index 0000000..1bc1630
--- /dev/null
+++ b/SOURCES/build-ascii-decode-fail-rhel7.patch
@@ -0,0 +1,45 @@
+diff -up firefox-102.0/third_party/python/PyYAML/lib3/yaml/reader.py.build-ascii-decode-fail-rhel7 firefox-102.0/third_party/python/PyYAML/lib3/yaml/reader.py
+--- firefox-102.0/third_party/python/PyYAML/lib3/yaml/reader.py.build-ascii-decode-fail-rhel7	2022-06-23 09:11:39.000000000 +0200
++++ firefox-102.0/third_party/python/PyYAML/lib3/yaml/reader.py	2022-08-16 13:24:31.697757209 +0200
+@@ -73,6 +73,8 @@ class Reader(object):
+             self.name = "<unicode string>"
+             self.check_printable(stream)
+             self.buffer = stream+'\0'
++            #self.encoding = 'utf-8'
++            #self.raw_decode = codecs.utf_8_decode
+         elif isinstance(stream, bytes):
+             self.name = "<byte string>"
+             self.raw_buffer = stream
+@@ -83,6 +85,11 @@ class Reader(object):
+             self.eof = False
+             self.raw_buffer = None
+             self.determine_encoding()
++        print("DEBUG_OUTPUT:")
++        print(self.name)
++        print(self.encoding)
++        print(self.stream)
++        #print(self.stream.read())
+ 
+     def peek(self, index=0):
+         try:
+diff -up firefox-102.0/toolkit/components/nimbus/generate/generate_feature_manifest.py.build-ascii-decode-fail-rhel7 firefox-102.0/toolkit/components/nimbus/generate/generate_feature_manifest.py
+--- firefox-102.0/toolkit/components/nimbus/generate/generate_feature_manifest.py.build-ascii-decode-fail-rhel7	2022-08-16 14:16:33.432529817 +0200
++++ firefox-102.0/toolkit/components/nimbus/generate/generate_feature_manifest.py	2022-08-17 08:01:38.175878171 +0200
+@@ -37,7 +37,7 @@ def generate_feature_manifest(fd, input_
+     write_fm_js_headers(fd)
+     nimbus_dir_path = pathlib.Path(input_file).parent
+     try:
+-        with open(input_file, "r") as yaml_input:
++        with open(input_file, "r", encoding="utf-8") as yaml_input:
+             data = yaml.safe_load(yaml_input)
+             with pathlib.Path(nimbus_dir_path, FEATURE_MANIFEST_SCHEMA).open() as f:
+                 schema = json.load(f)
+@@ -92,7 +92,7 @@ def generate_platform_feature_manifest(f
+         )
+ 
+     try:
+-        with open(input_file, "r") as yaml_input:
++        with open(input_file, "r", encoding="utf-8") as yaml_input:
+             data = yaml.safe_load(yaml_input)
+             fd.write(file_structure(data))
+     except (IOError) as e:
diff --git a/SOURCES/build-big-endian-errors.patch b/SOURCES/build-big-endian-errors.patch
new file mode 100644
index 0000000..b4bcb38
--- /dev/null
+++ b/SOURCES/build-big-endian-errors.patch
@@ -0,0 +1,57 @@
+diff -up firefox-102.0/third_party/libwebrtc/common_audio/wav_file.cc.big-endian-errors firefox-102.0/third_party/libwebrtc/common_audio/wav_file.cc
+--- firefox-102.0/third_party/libwebrtc/common_audio/wav_file.cc.big-endian-errors	2022-08-17 13:19:53.056891028 +0200
++++ firefox-102.0/third_party/libwebrtc/common_audio/wav_file.cc	2022-08-17 13:19:57.251879556 +0200
+@@ -89,9 +89,6 @@ void WavReader::Reset() {
+ 
+ size_t WavReader::ReadSamples(const size_t num_samples,
+                               int16_t* const samples) {
+-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
+-#error "Need to convert samples to big-endian when reading from WAV file"
+-#endif
+ 
+   size_t num_samples_left_to_read = num_samples;
+   size_t next_chunk_start = 0;
+@@ -129,9 +126,6 @@ size_t WavReader::ReadSamples(const size
+ }
+ 
+ size_t WavReader::ReadSamples(const size_t num_samples, float* const samples) {
+-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
+-#error "Need to convert samples to big-endian when reading from WAV file"
+-#endif
+ 
+   size_t num_samples_left_to_read = num_samples;
+   size_t next_chunk_start = 0;
+@@ -213,9 +207,6 @@ WavWriter::WavWriter(FileWrapper file,
+ }
+ 
+ void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) {
+-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
+-#error "Need to convert samples to little-endian when writing to WAV file"
+-#endif
+ 
+   for (size_t i = 0; i < num_samples; i += kMaxChunksize) {
+     const size_t num_remaining_samples = num_samples - i;
+@@ -243,9 +234,6 @@ void WavWriter::WriteSamples(const int16
+ }
+ 
+ void WavWriter::WriteSamples(const float* samples, size_t num_samples) {
+-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
+-#error "Need to convert samples to little-endian when writing to WAV file"
+-#endif
+ 
+   for (size_t i = 0; i < num_samples; i += kMaxChunksize) {
+     const size_t num_remaining_samples = num_samples - i;
+diff -up firefox-102.0/third_party/libwebrtc/common_audio/wav_header.cc.big-endian-errors firefox-102.0/third_party/libwebrtc/common_audio/wav_header.cc
+--- firefox-102.0/third_party/libwebrtc/common_audio/wav_header.cc.big-endian-errors	2022-08-17 13:18:04.688187393 +0200
++++ firefox-102.0/third_party/libwebrtc/common_audio/wav_header.cc	2022-08-17 13:18:22.451138816 +0200
+@@ -26,10 +26,6 @@
+ namespace webrtc {
+ namespace {
+ 
+-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
+-#error "Code not working properly for big endian platforms."
+-#endif
+-
+ #pragma pack(2)
+ struct ChunkHeader {
+   uint32_t ID;
diff --git a/SOURCES/build-debuginfo-fix.patch b/SOURCES/build-debuginfo-fix.patch
deleted file mode 100644
index 03fc300..0000000
--- a/SOURCES/build-debuginfo-fix.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -up firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft.cc.debuginfo-fix firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft.cc
---- firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft.cc.debuginfo-fix	2021-09-01 11:11:46.738285751 +0200
-+++ firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft.cc	2021-09-01 11:11:56.127319530 +0200
-@@ -21,7 +21,7 @@
-  *  be found in the AUTHORS file in the root of the source tree.
-  */
- 
--#include "modules/audio_processing//utility/ooura_fft.h"
-+#include "modules/audio_processing/utility/ooura_fft.h"
- 
- #include <math.h>
- 
-diff -up firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft_sse2.cc.debuginfo-fix firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft_sse2.cc
---- firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft_sse2.cc.debuginfo-fix	2021-09-01 11:12:26.513428847 +0200
-+++ firefox-91.0.1/third_party/libwebrtc/webrtc/modules/audio_processing/utility/ooura_fft_sse2.cc	2021-09-01 11:12:32.117449009 +0200
-@@ -8,7 +8,7 @@
-  *  be found in the AUTHORS file in the root of the source tree.
-  */
- 
--#include "modules/audio_processing//utility/ooura_fft.h"
-+#include "modules/audio_processing/utility/ooura_fft.h"
- 
- #include <emmintrin.h>
- 
diff --git a/SOURCES/build-disable-elfhack.patch b/SOURCES/build-disable-elfhack.patch
new file mode 100644
index 0000000..04d49f2
--- /dev/null
+++ b/SOURCES/build-disable-elfhack.patch
@@ -0,0 +1,12 @@
+diff -up firefox-97.0/toolkit/moz.configure.disable-elfhack firefox-97.0/toolkit/moz.configure
+--- firefox-97.0/toolkit/moz.configure.disable-elfhack	2022-02-08 09:58:47.518047952 +0100
++++ firefox-97.0/toolkit/moz.configure	2022-02-08 10:17:49.552945956 +0100
+@@ -1273,7 +1273,7 @@ with only_when("--enable-compile-environ
+             help="{Enable|Disable} elf hacks",
+         )
+ 
+-        set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: True))
++        set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: False))
+ 
+ 
+ @depends(build_environment)
diff --git a/SOURCES/build-mozconfig-fix.patch b/SOURCES/build-mozconfig-fix.patch
deleted file mode 100644
index 91dffb1..0000000
--- a/SOURCES/build-mozconfig-fix.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up mozilla-release-c61f5f5ead48c78a80c80db5c489bdc7cfaf8175/python/mozbuild/mozbuild/mozconfig.py.mozconfig-fix mozilla-release-c61f5f5ead48c78a80c80db5c489bdc7cfaf8175/python/mozbuild/mozbuild/mozconfig.py
---- mozilla-release-c61f5f5ead48c78a80c80db5c489bdc7cfaf8175/python/mozbuild/mozbuild/mozconfig.py.mozconfig-fix	2018-03-13 17:22:19.018466884 +0100
-+++ mozilla-release-c61f5f5ead48c78a80c80db5c489bdc7cfaf8175/python/mozbuild/mozbuild/mozconfig.py	2018-03-13 17:23:57.379559640 +0100
-@@ -446,7 +446,7 @@ class MozconfigLoader(object):
-                             value = value[1:]
- 
-                         # Lines with a quote not ending in a quote are multi-line.
--                        if has_quote and not value.endswith("'"):
-+                        if has_quote and not value.endswith(("'", ";")):
-                             in_variable = name
-                             current.append(value)
-                             continue
diff --git a/SOURCES/build-nss-version.patch b/SOURCES/build-nss-version.patch
deleted file mode 100644
index 25d34f6..0000000
--- a/SOURCES/build-nss-version.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -up firefox-91.0.1/build/moz.configure/nspr.configure.nss-nspr-downgrade firefox-91.0.1/build/moz.configure/nspr.configure
---- firefox-91.0.1/build/moz.configure/nspr.configure.nss-nspr-downgrade	2021-08-25 13:17:26.265307060 +0200
-+++ firefox-91.0.1/build/moz.configure/nspr.configure	2021-08-25 13:17:28.161313632 +0200
-@@ -50,7 +50,7 @@ set_define("JS_WITHOUT_NSPR", True, when
- def nspr_minver(js_standalone):
-     if js_standalone:
-         return "nspr >= 4.10"
--    return "nspr >= 4.32"
-+    return "nspr >= 4.31"
- 
- 
- nspr_pkg = pkg_check_modules("NSPR", nspr_minver, when="--with-system-nspr")
-diff -up firefox-91.0.1/build/moz.configure/nss.configure.nss-nspr-downgrade firefox-91.0.1/build/moz.configure/nss.configure
---- firefox-91.0.1/build/moz.configure/nss.configure.nss-nspr-downgrade	2021-08-25 13:17:45.049372175 +0200
-+++ firefox-91.0.1/build/moz.configure/nss.configure	2021-08-25 13:17:37.763346918 +0200
-@@ -9,7 +9,7 @@ option("--with-system-nss", help="Use sy
- imply_option("--with-system-nspr", True, when="--with-system-nss")
- 
- nss_pkg = pkg_check_modules(
--    "NSS", "nss >= 3.68", when="--with-system-nss", config=False
-+    "NSS", "nss >= 3.67", when="--with-system-nss", config=False
- )
- 
- set_config("MOZ_SYSTEM_NSS", True, when="--with-system-nss")
diff --git a/SOURCES/build-ppc64le-inline.patch b/SOURCES/build-ppc64le-inline.patch
deleted file mode 100644
index de0f6d9..0000000
--- a/SOURCES/build-ppc64le-inline.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-diff -up firefox-68.1.0/js/xpconnect/src/XPCWrappedNative.cpp.ppc64le-inline firefox-68.1.0/js/xpconnect/src/XPCWrappedNative.cpp
---- firefox-68.1.0/js/xpconnect/src/XPCWrappedNative.cpp.ppc64le-inline	2019-08-26 18:52:28.000000000 +0200
-+++ firefox-68.1.0/js/xpconnect/src/XPCWrappedNative.cpp	2019-08-29 08:49:57.695687874 +0200
-@@ -1092,7 +1092,11 @@ class MOZ_STACK_CLASS CallMethodHelper f
-   MOZ_ALWAYS_INLINE bool GetOutParamSource(uint8_t paramIndex,
-                                            MutableHandleValue srcp) const;
- 
-+#if (__GNUC__ && __linux__ && __PPC64__ && _LITTLE_ENDIAN)
-+  bool GatherAndConvertResults();
-+#else
-   MOZ_ALWAYS_INLINE bool GatherAndConvertResults();
-+#endif
- 
-   MOZ_ALWAYS_INLINE bool QueryInterfaceFastPath();
- 
-@@ -1139,7 +1143,11 @@ class MOZ_STACK_CLASS CallMethodHelper f
- 
-   ~CallMethodHelper();
- 
-+#if (__GNUC__ && __linux__ && __PPC64__ && _LITTLE_ENDIAN)
-+  bool Call();
-+#else
-   MOZ_ALWAYS_INLINE bool Call();
-+#endif
- 
-   // Trace implementation so we can put our CallMethodHelper in a Rooted<T>.
-   void trace(JSTracer* aTrc);
diff --git a/SOURCES/build-remove-dav1d-from-wayland-dep.patch b/SOURCES/build-remove-dav1d-from-wayland-dep.patch
new file mode 100644
index 0000000..d073acd
--- /dev/null
+++ b/SOURCES/build-remove-dav1d-from-wayland-dep.patch
@@ -0,0 +1,49 @@
+diff -up firefox-102.0/media/ffvpx/config_common.h.dav1d-remove firefox-102.0/media/ffvpx/config_common.h
+--- firefox-102.0/media/ffvpx/config_common.h.dav1d-remove	2022-08-08 12:48:33.218128539 +0200
++++ firefox-102.0/media/ffvpx/config_common.h	2022-08-08 12:48:52.986003374 +0200
+@@ -24,15 +24,11 @@
+ #undef CONFIG_VP8_VAAPI_HWACCEL
+ #undef CONFIG_VP9_VAAPI_HWACCEL
+ #undef CONFIG_AV1_VAAPI_HWACCEL
+-#undef CONFIG_LIBDAV1D
+-#undef CONFIG_AV1_DECODER
+ #define CONFIG_VAAPI 1
+ #define CONFIG_VAAPI_1 1
+ #define CONFIG_VP8_VAAPI_HWACCEL 1
+ #define CONFIG_VP9_VAAPI_HWACCEL 1
+ #define CONFIG_AV1_VAAPI_HWACCEL 1
+-#define CONFIG_LIBDAV1D 1
+-#define CONFIG_AV1_DECODER 1
+ #endif
+ 
+ #endif
+diff -up firefox-102.0/media/ffvpx/libavcodec/moz.build.dav1d-remove firefox-102.0/media/ffvpx/libavcodec/moz.build
+--- firefox-102.0/media/ffvpx/libavcodec/moz.build.dav1d-remove	2022-08-08 12:44:24.098710736 +0200
++++ firefox-102.0/media/ffvpx/libavcodec/moz.build	2022-08-08 12:46:42.635828719 +0200
+@@ -104,17 +104,23 @@ if not CONFIG['MOZ_FFVPX_AUDIOONLY']:
+     ]
+     if CONFIG['MOZ_WAYLAND']:
+         LOCAL_INCLUDES += ['/media/mozva']
++        if CONFIG['MOZ_DAV1D_ASM']:
++            SOURCES += [
++                'libdav1d.c',
++            ]
+         SOURCES += [
+             'atsc_a53.c',
+-            'libdav1d.c',
+             'vaapi_av1.c',
+             'vaapi_decode.c',
+             'vaapi_vp8.c',
+             'vaapi_vp9.c',
+         ]
++        if CONFIG['MOZ_DAV1D_ASM']:
++            USE_LIBS += [
++                'dav1d',
++                'media_libdav1d_asm',
++            ]
+         USE_LIBS += [
+-          'dav1d',
+-          'media_libdav1d_asm',
+           'mozva'
+         ]
+ 
diff --git a/SOURCES/disable-openh264-download.patch b/SOURCES/disable-openh264-download.patch
new file mode 100644
index 0000000..028b730
--- /dev/null
+++ b/SOURCES/disable-openh264-download.patch
@@ -0,0 +1,39 @@
+diff -up firefox-81.0/toolkit/modules/GMPInstallManager.jsm.old firefox-81.0/toolkit/modules/GMPInstallManager.jsm
+--- firefox-81.0/toolkit/modules/GMPInstallManager.jsm.old	2020-09-25 10:39:04.769458703 +0200
++++ firefox-81.0/toolkit/modules/GMPInstallManager.jsm	2020-09-25 10:39:22.038504747 +0200
+@@ -54,10 +54,6 @@ function getScopedLogger(prefix) {
+ 
+ const LOCAL_GMP_SOURCES = [
+   {
+-    id: "gmp-gmpopenh264",
+-    src: "chrome://global/content/gmp-sources/openh264.json",
+-  },
+-  {
+     id: "gmp-widevinecdm",
+     src: "chrome://global/content/gmp-sources/widevinecdm.json",
+   },
+diff --git a/toolkit/content/jar.mn b/toolkit/content/jar.mn
+--- a/toolkit/content/jar.mn
++++ b/toolkit/content/jar.mn
+@@ -108,7 +108,6 @@ toolkit.jar:
+ #ifdef XP_MACOSX
+    content/global/macWindowMenu.js
+ #endif
+-   content/global/gmp-sources/openh264.json    (gmp-sources/openh264.json)
+    content/global/gmp-sources/widevinecdm.json (gmp-sources/widevinecdm.json)
+ 
+ # Third party files
+diff --git a/toolkit/modules/GMPInstallManager.jsm b/toolkit/modules/GMPInstallManager.jsm
+--- a/toolkit/modules/GMPInstallManager.jsm
++++ b/toolkit/modules/GMPInstallManager.jsm
+@@ -238,6 +234,9 @@ GMPInstallManager.prototype = {
+    *                 downloaderr, verifyerr or previouserrorencountered
+    */
+   installAddon(gmpAddon) {
++    if (gmpAddon.isOpenH264) {
++      return Promise.reject({ type: "disabled" });
++    }
+     if (this._deferred) {
+       let log = getScopedLogger("GMPInstallManager.installAddon");
+       log.error("previous error encountered");
+
diff --git a/SOURCES/distribution.ini b/SOURCES/distribution.ini
index 8bf461e..11f1f96 100644
--- a/SOURCES/distribution.ini
+++ b/SOURCES/distribution.ini
@@ -1,9 +1,9 @@
 [Global]
-id=redhat
+id=fedora
 version=1.0
-about=Mozilla Firefox for Red Hat Enterprise Linux
+about=Mozilla Firefox for Fedora
 
 [Preferences]
-app.distributor=redhat
-app.distributor.channel=redhat
-app.partner.fedora=redhat
+app.distributor=fedora
+app.distributor.channel=fedora
+app.partner.fedora=fedora
diff --git a/SOURCES/expat-CVE-2022-25235.patch b/SOURCES/expat-CVE-2022-25235.patch
deleted file mode 100644
index 1e5c664..0000000
--- a/SOURCES/expat-CVE-2022-25235.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-diff -up firefox-91.7.0/parser/expat/lib/xmltok.c.expat-CVE-2022-25235 firefox-91.7.0/parser/expat/lib/xmltok.c
---- firefox-91.7.0/parser/expat/lib/xmltok.c.expat-CVE-2022-25235	2022-03-02 17:57:38.364361168 +0100
-+++ firefox-91.7.0/parser/expat/lib/xmltok.c	2022-03-02 17:58:22.235512399 +0100
-@@ -65,13 +65,6 @@
-                       + ((((byte)[2]) >> 5) & 1)] \
-          & (1u << (((byte)[2]) & 0x1F)))
- 
--#define UTF8_GET_NAMING(pages, p, n) \
--  ((n) == 2 \
--  ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
--  : ((n) == 3 \
--     ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
--     : 0))
--
- /* Detection of invalid UTF-8 sequences is based on Table 3.1B
-    of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
-    with the additional restriction of not allowing the Unicode
-diff -up firefox-91.7.0/parser/expat/lib/xmltok_impl.c.expat-CVE-2022-25235 firefox-91.7.0/parser/expat/lib/xmltok_impl.c
---- firefox-91.7.0/parser/expat/lib/xmltok_impl.c.expat-CVE-2022-25235	2022-03-02 17:57:38.365361172 +0100
-+++ firefox-91.7.0/parser/expat/lib/xmltok_impl.c	2022-03-02 18:04:51.240853247 +0100
-@@ -34,7 +34,7 @@
-    case BT_LEAD ## n: \
-      if (end - ptr < n) \
-        return XML_TOK_PARTIAL_CHAR; \
--     if (!IS_NAME_CHAR(enc, ptr, n)) { \
-+     if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NAME_CHAR(enc, ptr, n)) { \
-        *nextTokPtr = ptr; \
-        return XML_TOK_INVALID; \
-      } \
-@@ -62,7 +62,7 @@
-    case BT_LEAD ## n: \
-      if (end - ptr < n) \
-        return XML_TOK_PARTIAL_CHAR; \
--     if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \
-+     if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NMSTRT_CHAR(enc, ptr, n)) { \
-        *nextTokPtr = ptr; \
-        return XML_TOK_INVALID; \
-      } \
-@@ -1090,6 +1090,10 @@ PREFIX(prologTok)(const ENCODING *enc, c
-   case BT_LEAD ## n: \
-     if (end - ptr < n) \
-       return XML_TOK_PARTIAL_CHAR; \
-+    if (IS_INVALID_CHAR(enc, ptr, n)) {                                        \
-+      *nextTokPtr = ptr;                                                       \
-+      return XML_TOK_INVALID;                                                  \
-+    }                                                                          \
-     if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
-       ptr += n; \
-       tok = XML_TOK_NAME; \
diff --git a/SOURCES/expat-CVE-2022-25236.patch b/SOURCES/expat-CVE-2022-25236.patch
deleted file mode 100644
index 2065dc9..0000000
--- a/SOURCES/expat-CVE-2022-25236.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff -up firefox-91.7.0/parser/expat/lib/xmlparse.c.expat-CVE-2022-25236 firefox-91.7.0/parser/expat/lib/xmlparse.c
---- firefox-91.7.0/parser/expat/lib/xmlparse.c.expat-CVE-2022-25236	2022-03-02 18:08:40.085642028 +0100
-+++ firefox-91.7.0/parser/expat/lib/xmlparse.c	2022-03-02 18:13:31.838667958 +0100
-@@ -700,8 +700,7 @@ XML_ParserCreate(const XML_Char *encodin
- XML_Parser XMLCALL
- XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
- {
--  XML_Char tmp[2];
--  *tmp = nsSep;
-+  XML_Char tmp[2] = {nsSep, 0};
-   return XML_ParserCreate_MM(encodingName, NULL, tmp);
- }
- #endif
-@@ -1276,8 +1275,7 @@ XML_ExternalEntityParserCreate(XML_Parse
-      would be otherwise.
-   */
-   if (ns) {
--    XML_Char tmp[2];
--    *tmp = namespaceSeparator;
-+    XML_Char tmp[2] = {parser->m_namespaceSeparator, 0};
-     parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd);
-   }
-   else {
-@@ -3667,6 +3665,16 @@ addBinding(XML_Parser parser, PREFIX *pr
-     if (!mustBeXML && isXMLNS
-         && (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))
-       isXMLNS = XML_FALSE;
-+    // NOTE: While Expat does not validate namespace URIs against RFC 3986,
-+    //       we have to at least make sure that the XML processor on top of
-+    //       Expat (that is splitting tag names by namespace separator into
-+    //       2- or 3-tuples (uri-local or uri-local-prefix)) cannot be confused
-+    //       by an attacker putting additional namespace separator characters
-+    //       into namespace declarations.  That would be ambiguous and not to
-+    //       be expected.
-+    if (parser->m_ns && (uri[len] == parser->m_namespaceSeparator)) {
-+      return XML_ERROR_SYNTAX;
-+    }
-   }
-   isXML = isXML && len == xmlLen;
-   isXMLNS = isXMLNS && len == xmlnsLen;
diff --git a/SOURCES/expat-CVE-2022-25315.patch b/SOURCES/expat-CVE-2022-25315.patch
deleted file mode 100644
index 171980f..0000000
--- a/SOURCES/expat-CVE-2022-25315.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -up firefox-91.7.0/parser/expat/lib/xmlparse.c.expat-CVE-2022-25315 firefox-91.7.0/parser/expat/lib/xmlparse.c
---- firefox-91.7.0/parser/expat/lib/xmlparse.c.expat-CVE-2022-25315	2022-03-02 18:17:50.966583254 +0100
-+++ firefox-91.7.0/parser/expat/lib/xmlparse.c	2022-03-02 18:19:27.636924735 +0100
-@@ -2479,6 +2479,7 @@ storeRawNames(XML_Parser parser)
-   while (tag) {
-     int bufSize;
-     int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
-+    size_t rawNameLen;
-     char *rawNameBuf = tag->buf + nameLen;
-     /* Stop if already stored.  Since tagStack is a stack, we can stop
-        at the first entry that has already been copied; everything
-@@ -2490,7 +2491,11 @@ storeRawNames(XML_Parser parser)
-     /* For re-use purposes we need to ensure that the
-        size of tag->buf is a multiple of sizeof(XML_Char).
-     */
--    bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
-+    rawNameLen = ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
-+    /* Detect and prevent integer overflow. */
-+    if (rawNameLen > (size_t)INT_MAX - nameLen)
-+      return XML_FALSE;
-+    bufSize = nameLen + (int)rawNameLen;
-     if (bufSize > tag->bufEnd - tag->buf) {
-       char *temp = (char *)REALLOC(tag->buf, bufSize);
-       if (temp == NULL)
diff --git a/SOURCES/fedora-shebang-build.patch b/SOURCES/fedora-shebang-build.patch
new file mode 100644
index 0000000..9ade86c
--- /dev/null
+++ b/SOURCES/fedora-shebang-build.patch
@@ -0,0 +1,9 @@
+diff -up firefox-73.0/build/unix/run-mozilla.sh.old firefox-73.0/build/unix/run-mozilla.sh
+--- firefox-73.0/build/unix/run-mozilla.sh.old	2020-02-12 09:58:00.150895904 +0100
++++ firefox-73.0/build/unix/run-mozilla.sh	2020-02-12 09:58:06.505860696 +0100
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/usr/bin/sh
+ #
+ # 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
diff --git a/SOURCES/firefox-centos-default-prefs.js b/SOURCES/firefox-centos-default-prefs.js
deleted file mode 100644
index 039e27f..0000000
--- a/SOURCES/firefox-centos-default-prefs.js
+++ /dev/null
@@ -1,35 +0,0 @@
-pref("app.update.auto",                     false);
-pref("app.update.enabled",                  false);
-pref("app.update.autoInstallEnabled",       false);
-pref("general.smoothScroll",                true);
-pref("intl.locale.matchOS",                 true);
-pref("toolkit.storage.synchronous",         0);
-pref("toolkit.networkmanager.disable",      false);
-pref("offline.autoDetect",                  true);
-pref("browser.backspace_action",            2);
-pref("browser.display.use_system_colors",   true);
-pref("browser.download.folderList",         1);
-pref("browser.link.open_external",          3);
-pref("browser.shell.checkDefaultBrowser",   false);
-pref("network.manage-offline-status",       true);
-pref("extensions.shownSelectionUI",         true);
-pref("ui.SpellCheckerUnderlineStyle",       1);
-pref("startup.homepage_override_url",       "http://www.centos.org");
-pref("startup.homepage_welcome_url",        "http://www.centos.org");
-pref("browser.startup.homepage",            "data:text/plain,browser.startup.homepage=file:///%PREFIX%/share/doc/HTML/index.html");
-pref("geo.wifi.uri", "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%");
-pref("media.gmp-gmpopenh264.provider.enabled",false);
-pref("media.gmp-gmpopenh264.autoupdate",false);
-pref("media.gmp-gmpopenh264.enabled",false);
-pref("media.gmp-gmpopenh264.enabled",false);
-pref("plugins.notifyMissingFlash", false);
-/* See https://bugzilla.redhat.com/show_bug.cgi?id=1226489 */
-pref("browser.display.use_system_colors", false);
-pref("layers.use-image-offscreen-surfaces", false);
-/* Allow sending credetials to all https:// sites */
-pref("network.negotiate-auth.trusted-uris", "https://");
-pref("security.use_sqldb", false);
-/* Use OS settings for UI language */
-pref("intl.locale.requested", "");
-/* See https://bugzilla.redhat.com/show_bug.cgi?id=1672424 */
-pref("storage.nfs_filesystem", true);
diff --git a/SOURCES/firefox-gcc-build.patch b/SOURCES/firefox-gcc-build.patch
new file mode 100644
index 0000000..55017ad
--- /dev/null
+++ b/SOURCES/firefox-gcc-build.patch
@@ -0,0 +1,38 @@
+--- firefox-80.0.1/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h	2020-08-31 10:04:19.000000000 -0400
++++ firefox-80.0.1/toolkit/crashreporter/google-breakpad/src/third_party/lss/linux_syscall_support.h	2020-09-12 07:24:35.298931628 -0400
+@@ -1962,7 +1962,7 @@ struct kernel_statfs {
+                            LSS_ENTRYPOINT                                     \
+                            "pop %%ebx"                                        \
+                            args                                               \
+-                           : "esp", "memory");                                \
++                           : "memory");                                       \
+       LSS_RETURN(type,__res)
+     #undef  _syscall0
+     #define _syscall0(type,name)                                              \
+@@ -2019,7 +2019,7 @@ struct kernel_statfs {
+                              : "i" (__NR_##name), "ri" ((long)(arg1)),        \
+                                "c" ((long)(arg2)), "d" ((long)(arg3)),        \
+                                "S" ((long)(arg4)), "D" ((long)(arg5))         \
+-                             : "esp", "memory");                              \
++                             : "memory");                                     \
+         LSS_RETURN(type,__res);                                               \
+       }
+     #undef  _syscall6
+@@ -2041,7 +2041,7 @@ struct kernel_statfs {
+                              : "i" (__NR_##name),  "0" ((long)(&__s)),        \
+                                "c" ((long)(arg2)), "d" ((long)(arg3)),        \
+                                "S" ((long)(arg4)), "D" ((long)(arg5))         \
+-                             : "esp", "memory");                              \
++                             : "memory");                                     \
+         LSS_RETURN(type,__res);                                               \
+       }
+     LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
+@@ -2127,7 +2127,7 @@ struct kernel_statfs {
+                            : "0"(-EINVAL), "i"(__NR_clone),
+                              "m"(fn), "m"(child_stack), "m"(flags), "m"(arg),
+                              "m"(parent_tidptr), "m"(newtls), "m"(child_tidptr)
+-                           : "esp", "memory", "ecx", "edx", "esi", "edi");
++                           : "memory", "ecx", "edx", "esi", "edi");
+       LSS_RETURN(int, __res);
+     }
+
diff --git a/SOURCES/firefox-mozconfig b/SOURCES/firefox-mozconfig
index 6c7afd7..e91a5e5 100644
--- a/SOURCES/firefox-mozconfig
+++ b/SOURCES/firefox-mozconfig
@@ -1,30 +1,28 @@
 . $topsrcdir/browser/config/mozconfig
 
-ac_add_options --prefix="$PREFIX"
-ac_add_options --libdir="$LIBDIR"
 ac_add_options --with-system-zlib
 ac_add_options --disable-strip
-ac_add_options --disable-tests
 #ac_add_options --enable-libnotify
 ac_add_options --enable-necko-wifi
 ac_add_options --disable-updater
 ac_add_options --enable-chrome-format=omni
 ac_add_options --enable-pulseaudio
+ac_add_options --enable-av1
 ac_add_options --without-system-icu
 ac_add_options --enable-release
 ac_add_options --allow-addon-sideload
 ac_add_options --with-system-jpeg
 ac_add_options --enable-js-shell
 ac_add_options --with-unsigned-addon-scopes=app,system
-
-ac_add_options --with-mozilla-api-keyfile=../mozilla-api-key
-ac_add_options --with-google-location-service-api-keyfile=../google-api-key
-ac_add_options --with-google-safebrowsing-api-keyfile=../google-api-key
+ac_add_options --without-sysroot
+# investigate this one:
+ac_add_options --without-wasm-sandboxed-libraries
 ac_add_options --disable-crashreporter
-
 export BUILD_OFFICIAL=1
 export MOZILLA_OFFICIAL=1
 export MOZ_TELEMETRY_REPORTING=1
+export MOZ_UPDATE_CHANNEL=release
+export MOZ_APP_REMOTINGNAME=firefox
 mk_add_options BUILD_OFFICIAL=1
 mk_add_options MOZILLA_OFFICIAL=1
 mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir
diff --git a/SOURCES/firefox-nss-version.patch b/SOURCES/firefox-nss-version.patch
new file mode 100644
index 0000000..7b7c859
--- /dev/null
+++ b/SOURCES/firefox-nss-version.patch
@@ -0,0 +1,13 @@
+diff -up firefox-102.2.0/build/moz.configure/nss.configure.nss-version firefox-102.2.0/build/moz.configure/nss.configure
+--- firefox-102.2.0/build/moz.configure/nss.configure.nss-version	2022-08-23 18:17:14.699869558 +0200
++++ firefox-102.2.0/build/moz.configure/nss.configure	2022-08-23 18:15:33.790051448 +0200
+@@ -9,7 +9,7 @@ system_lib_option("--with-system-nss", h
+ imply_option("--with-system-nspr", True, when="--with-system-nss")
+ 
+ nss_pkg = pkg_check_modules(
+-    "NSS", "nss >= 3.79.1", when="--with-system-nss", config=False
++    "NSS", "nss >= 3.79", when="--with-system-nss", config=False
+ )
+ 
+ set_config("MOZ_SYSTEM_NSS", True, when="--with-system-nss")
+diff -up firefox-102.2.0/.nss-version firefox-102.2.0/
diff --git a/SOURCES/firefox-redhat-default-prefs.js b/SOURCES/firefox-redhat-default-prefs.js
index 9ead3a2..7bf5098 100644
--- a/SOURCES/firefox-redhat-default-prefs.js
+++ b/SOURCES/firefox-redhat-default-prefs.js
@@ -2,7 +2,7 @@ pref("app.update.auto",                     false);
 pref("app.update.enabled",                  false);
 pref("app.update.autoInstallEnabled",       false);
 pref("general.smoothScroll",                true);
-pref("intl.locale.matchOS",                 true);
+pref("intl.locale.requested",               "");
 pref("toolkit.storage.synchronous",         0);
 pref("toolkit.networkmanager.disable",      false);
 pref("offline.autoDetect",                  true);
@@ -17,19 +17,23 @@ pref("ui.SpellCheckerUnderlineStyle",       1);
 pref("startup.homepage_override_url",       "http://www.redhat.com");
 pref("startup.homepage_welcome_url",        "http://www.redhat.com");
 pref("browser.startup.homepage",            "data:text/plain,browser.startup.homepage=file:///%PREFIX%/share/doc/HTML/index.html");
-pref("geo.wifi.uri", "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%");
 pref("media.gmp-gmpopenh264.provider.enabled",false);
 pref("media.gmp-gmpopenh264.autoupdate",false);
 pref("media.gmp-gmpopenh264.enabled",false);
-pref("media.gmp-gmpopenh264.enabled",false);
+pref("media.gmp.decoder.enabled", true);
 pref("plugins.notifyMissingFlash", false);
 /* See https://bugzilla.redhat.com/show_bug.cgi?id=1226489 */
 pref("browser.display.use_system_colors", false);
-pref("layers.use-image-offscreen-surfaces", false);
 /* Allow sending credetials to all https:// sites */
 pref("network.negotiate-auth.trusted-uris", "https://");
 pref("security.use_sqldb", false);
-/* Use OS settings for UI language */
-pref("intl.locale.requested", "");
+pref("spellchecker.dictionary_path","/usr/share/myspell");
+/* Disable DoH by default */
+pref("network.trr.mode",                    5);
+/* Enable per-user policy dir, see mozbz#1583466 */
+pref("browser.policies.perUserDir",         true);
+pref("browser.gnome-search-provider.enabled",true);
+/* Enable ffvpx playback for WebRTC */
+pref("media.navigator.mediadatadecoder_vpx_enabled", true);
 /* See https://bugzilla.redhat.com/show_bug.cgi?id=1672424 */
 pref("storage.nfs_filesystem", true);
\ No newline at end of file
diff --git a/SOURCES/firefox-search-provider.ini b/SOURCES/firefox-search-provider.ini
new file mode 100644
index 0000000..3868e3d
--- /dev/null
+++ b/SOURCES/firefox-search-provider.ini
@@ -0,0 +1,5 @@
+[Shell Search Provider]
+DesktopId=firefox.desktop
+BusName=org.mozilla.Firefox.SearchProvider
+ObjectPath=/org/mozilla/Firefox/SearchProvider
+Version=2
diff --git a/SOURCES/firefox-symbolic.svg b/SOURCES/firefox-symbolic.svg
index 7a2c73e..8ecd135 100644
--- a/SOURCES/firefox-symbolic.svg
+++ b/SOURCES/firefox-symbolic.svg
@@ -1,30 +1,3 @@
-<?xml version='1.0' encoding='UTF-8' standalone='no'?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg xmlns:cc='http://creativecommons.org/ns#' xmlns:dc='http://purl.org/dc/elements/1.1/' sodipodi:docname='firefox-symbolic.svg' height='16' id='svg7384' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' xmlns:osb='http://www.openswatchbook.org/uri/2009/osb' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:svg='http://www.w3.org/2000/svg' version='1.1' inkscape:version='0.91 r13725' width='16' xmlns='http://www.w3.org/2000/svg'>
-  <metadata id='metadata90'>
-    <rdf:RDF>
-      <cc:Work rdf:about=''>
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage'/>
-        <dc:title>Gnome Symbolic Icon Theme</dc:title>
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <sodipodi:namedview inkscape:bbox-paths='true' bordercolor='#666666' borderopacity='1' inkscape:current-layer='layer9' inkscape:cx='-10.975734' inkscape:cy='233.73843' gridtolerance='10' inkscape:guide-bbox='true' guidetolerance='10' id='namedview88' inkscape:object-nodes='false' inkscape:object-paths='false' objecttolerance='10' pagecolor='#555753' inkscape:pageopacity='1' inkscape:pageshadow='2' showborder='false' showgrid='false' showguides='true' inkscape:snap-bbox='true' inkscape:snap-bbox-midpoints='false' inkscape:snap-global='true' inkscape:snap-grids='true' inkscape:snap-nodes='true' inkscape:snap-others='false' inkscape:snap-to-guides='true' inkscape:window-height='1403' inkscape:window-maximized='1' inkscape:window-width='2560' inkscape:window-x='2560' inkscape:window-y='0' inkscape:zoom='1'>
-    <inkscape:grid empspacing='2' enabled='true' id='grid4866' originx='-222.00001' originy='-381.99852' snapvisiblegridlinesonly='true' spacingx='1px' spacingy='1px' type='xygrid' visible='true'/>
-  </sodipodi:namedview>
-  <title id='title9167'>Gnome Symbolic Icon Theme</title>
-  <defs id='defs7386'>
-    <linearGradient id='linearGradient7212' osb:paint='solid'>
-      <stop id='stop7214' offset='0' style='stop-color:#000000;stop-opacity:1;'/>
-    </linearGradient>
-  </defs>
-  <g inkscape:groupmode='layer' id='layer9' inkscape:label='apps' style='display:inline' transform='translate(-463.00021,164.99852)'>
-    
-    <path inkscape:connector-curvature='0' d='M 469.05437,-154.9679 Z' id='path17747' style='fill:none;stroke:#000000;stroke-width:0.99851286px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1'/>
-    <path inkscape:connector-curvature='0' d='M 469.08553,-154.9054 Z' id='path17749' style='fill:none;stroke:#000000;stroke-width:0.99851286px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1'/>
-    <path inkscape:connector-curvature='0' d='m 473.0627,-162.9375 c -0.41568,-0.0182 -0.62813,0.0274 -0.625,0.0312 0.006,0.008 1.72988,0.32697 2.03125,0.75 0,0 -0.71915,0.007 -1.4375,0.21875 -0.0325,0.01 2.64053,0.33122 3.1875,3.0625 0,0 -0.29354,-0.64386 -0.65625,-0.75 0.23852,0.74134 0.16466,2.17583 -0.0625,2.875 -0.0292,0.0899 -0.0525,-0.38762 -0.5,-0.59375 0.14332,1.04923 -0.006,2.6978 -0.71875,3.15625 -0.0555,0.0357 0.43942,-1.64894 0.0937,-1 -2.06368,3.2325 -4.50486,1.31102 -5.5,0.625 0.79871,0.19996 1.80035,0.0704 2.125,-0.15625 0.49572,-0.34615 0.79916,-0.59107 1.0625,-0.53125 0.26322,0.0601 0.42318,-0.22934 0.21875,-0.46875 -0.20466,-0.23989 -0.70268,-0.55471 -1.375,-0.375 -0.47415,0.12687 -1.04057,0.54268 -1.9375,0 -0.7652,-0.46319 -0.67076,-0.69942 -0.67076,-0.93907 0,-0.23977 0.21387,-0.59107 0.59375,-0.53125 0.0851,0.0134 0.15074,0.009 0.1875,0 0.18483,0.0422 0.35743,0.0964 0.53125,0.1875 0.008,-0.2241 -0.0292,-0.87345 -0.15625,-1.23012 0.0106,0.004 0.0289,0.011 0.0312,0 0.0384,-0.17687 1.05477,-0.18386 1.37388,-0.59643 0.20404,-0.26362 0.14073,-0.79683 0.14073,-0.79683 l -1,0 c -0.52354,0.002 -0.97244,-0.75086 -1.01451,-0.85669 0.11444,-0.62597 0.48612,-0.83952 1.01451,-1.14331 -0.39748,-0.003 -0.18871,0 -1,0 -0.52875,0 -0.84718,0.36158 -1.01451,0.54956 -0.70058,-0.16587 -1.38144,-0.25227 -1.86049,-0.0609 -0.22125,-0.22941 -0.39604,-0.80055 -0.42188,-1.48863 0,0 -1.20486,0.73864 -1.07812,2.55113 -0.002,0.14904 -0.0499,0.21348 -0.0625,0.3125 -0.13061,0.22845 -0.1553,0.40492 -0.125,0.375 -0.0656,0.13627 -0.15391,0.28402 -0.21875,0.46875 -0.0149,0.0362 -0.0495,0.0463 -0.0625,0.0937 -0.009,0.0322 0.002,0.0638 0,0.0937 -0.11512,0.36099 -0.21516,0.98244 -0.3125,1.54262 0,0 0.12424,-0.51425 0.3125,-0.88637 -0.15639,0.54353 -0.26211,1.54974 -0.1875,2.73012 0,0 0.015,-0.20429 0.0625,-0.5 0.0465,0.80102 0.25925,1.72737 0.84375,2.75 1.46152,2.5575 3.89248,3.68885 6.4375,3.46875 0.44516,-0.0296 0.89639,-0.10834 1.34375,-0.21875 5.92923,-1.46449 5.28125,-8.78118 5.28125,-8.78118 l -0.15625,1.09375 c 0,0 -0.24147,-1.99977 -0.53125,-2.75 -0.44412,-1.14957 -0.62372,-1.15791 -0.625,-1.15625 0.29743,0.77226 0.21875,1.1875 0.21875,1.1875 0,0 -0.51279,-1.43939 -1.90625,-1.90625 -0.82515,-0.27632 -1.45932,-0.38807 -1.875,-0.40625 z' id='path159-6' sodipodi:nodetypes='sccccccccccsccccscccccscccccccccccccccccccccccccccs' style='fill:#bebebe;fill-opacity:1;stroke:none'/>
-    <path inkscape:connector-curvature='0' d='m 470.87695,-164.01953 c -0.83043,0.0139 -1.67042,0.17659 -2.48047,0.5 l -0.46289,0.18359 c 0.66083,0.79767 1.84339,0.43951 1.84339,0.43951 2.50802,-0.52344 5.12427,0.6034 6.44177,2.89252 1.49591,2.59908 0.85463,5.89258 -1.50586,7.74219 -2.36049,1.84961 -5.71108,1.68349 -7.87695,-0.39062 -2.16588,-2.07412 -2.47623,-5.41522 -0.73047,-7.85352 l 0.29101,-0.40625 -0.81445,-0.58203 -0.29101,0.40625 c -2.03104,2.83673 -1.66628,6.74516 0.85351,9.1582 2.5198,2.41305 6.43934,2.60693 9.18555,0.45508 2.74621,-2.15185 3.49621,-6.00355 1.75586,-9.02734 -1.30527,-2.26785 -3.7177,-3.55935 -6.20899,-3.51758 z' id='path22109' sodipodi:nodetypes='ccccsssccccsssc' style='color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999994;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate'/>
-  </g>
+<svg id="Assets" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
+  <path d="M190.368 150.591c0.157 0.009 0.079 0.003 0 0zm-57.874-28.933c0.158 0.008 0.079 0.003 0 0zm346.228 44.674c-10.445-25.123-31.6-52.248-48.211-60.82 13.52 26.5 21.345 53.093 24.335 72.935 0 0.04 0.015 0.136 0.047 0.4-27.175-67.732-73.254-95.047-110.886-154.512-1.9-3.008-3.805-6.022-5.661-9.2a73.237 73.237 0 0 1-2.646-4.972 43.757 43.757 0 0 1-3.585-9.5 0.625 0.625 0 0 0-0.546-0.644 0.8 0.8 0 0 0-0.451 0c-0.033 0.011-0.084 0.051-0.119 0.065-0.053 0.02-0.12 0.069-0.176 0.095 0.026-0.036 0.083-0.117 0.1-0.135-53.437 31.3-75.587 86.093-81.282 120.97a128.057 128.057 0 0 0-47.624 12.153 6.144 6.144 0 0 0-3.041 7.63 6.034 6.034 0 0 0 8.192 3.525 116.175 116.175 0 0 1 41.481-10.826c0.468-0.033 0.937-0.062 1.405-0.1a117.624 117.624 0 0 1 5.932-0.211 120.831 120.831 0 0 1 34.491 4.777c0.654 0.192 1.295 0.414 1.946 0.616a120.15 120.15 0 0 1 5.539 1.842 121.852 121.852 0 0 1 3.992 1.564c1.074 0.434 2.148 0.868 3.206 1.331a118.453 118.453 0 0 1 4.9 2.307c0.743 0.368 1.485 0.735 2.217 1.117a120.535 120.535 0 0 1 4.675 2.587 107.785 107.785 0 0 1 2.952 1.776 123.018 123.018 0 0 1 42.028 43.477c-12.833-9.015-35.81-17.918-57.947-14.068 86.441 43.214 63.234 192.027-56.545 186.408a106.7 106.7 0 0 1-31.271-6.031 132.461 132.461 0 0 1-7.059-2.886c-1.356-0.618-2.711-1.243-4.051-1.935-29.349-15.168-53.583-43.833-56.611-78.643 0 0 11.093-41.335 79.433-41.335 7.388 0 28.508-20.614 28.9-26.593-0.09-1.953-41.917-18.59-58.223-34.656-8.714-8.585-12.851-12.723-16.514-15.829a71.7 71.7 0 0 0-6.225-4.7 111.335 111.335 0 0 1-0.675-58.733c-24.687 11.242-43.89 29.011-57.849 44.7h-0.111c-9.528-12.067-8.855-51.873-8.312-60.184-0.114-0.516-7.107 3.63-8.024 4.254a175.21 175.21 0 0 0-23.486 20.12 210.5 210.5 0 0 0-22.443 26.913c0 0.012-0.007 0.025-0.011 0.037 0-0.012 0.007-0.025 0.011-0.038a202.837 202.837 0 0 0-32.244 72.81c-0.058 0.265-2.29 10.054-3.92 22.147a265.794 265.794 0 0 0-0.769 5.651c-0.558 3.636-0.992 7.6-1.42 13.767-0.019 0.239-0.031 0.474-0.048 0.712a591.152 591.152 0 0 0-0.481 7.995c0 0.411-0.025 0.816-0.025 1.227 0 132.709 107.6 240.29 240.324 240.29 118.865 0 217.559-86.288 236.882-199.63 0.407-3.075 0.732-6.168 1.092-9.27 4.777-41.21-0.53-84.525-15.588-120.747zm-164.068 72.1z" fill="#fff"/>
 </svg>
diff --git a/SOURCES/firefox-tests-xpcshell-freeze.patch b/SOURCES/firefox-tests-xpcshell-freeze.patch
new file mode 100644
index 0000000..1115417
--- /dev/null
+++ b/SOURCES/firefox-tests-xpcshell-freeze.patch
@@ -0,0 +1,14 @@
+diff -up firefox-88.0/testing/xpcshell/runxpcshelltests.py.old firefox-88.0/testing/xpcshell/runxpcshelltests.py
+--- firefox-88.0/testing/xpcshell/runxpcshelltests.py.old	2021-04-30 10:45:14.466616224 +0200
++++ firefox-88.0/testing/xpcshell/runxpcshelltests.py	2021-04-30 10:45:21.339525085 +0200
+@@ -1382,8 +1382,8 @@ class XPCShellTests(object):
+                         self.log.info("Process %s" % label)
+                     self.log.info(msg)
+ 
+-            dumpOutput(proc.stdout, "stdout")
+-            dumpOutput(proc.stderr, "stderr")
++            #dumpOutput(proc.stdout, "stdout")
++            #dumpOutput(proc.stderr, "stderr")
+         self.nodeProc = {}
+ 
+     def startHttp3Server(self):
diff --git a/SOURCES/firefox.1 b/SOURCES/firefox.1
index 4311322..556cf07 100644
--- a/SOURCES/firefox.1
+++ b/SOURCES/firefox.1
@@ -60,7 +60,7 @@ Open new instance, not a new window in running instance.
 \fB\-\-UILocale\fR \fIlocale\fR
 Start with \fIlocale\fR resources as UI Locale.
 .TP
-\fB\-\-save\-mode\fR
+\fB\-\-safe\-mode\fR
 Disables extensions and themes for this session.
 .TP
 \fB\-\-headless\fR
diff --git a/SOURCES/firefox.appdata.xml.in b/SOURCES/firefox.appdata.xml.in
new file mode 100644
index 0000000..bfa9afc
--- /dev/null
+++ b/SOURCES/firefox.appdata.xml.in
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2019 Firefox contributors -->
+<component type="desktop">
+  <id>firefox.desktop</id>
+  <metadata_license>CC0-1.0</metadata_license>
+  <name>Firefox</name>
+  <summary>Web Browser</summary>
+  <summary xml:lang="ca">Navegador web</summary>
+  <summary xml:lang="cs">Webový prohlížeč</summary>
+  <summary xml:lang="es">Navegador web</summary>
+  <summary xml:lang="fa">مرورگر اینترنتی</summary>
+  <summary xml:lang="fi">WWW-selain</summary>
+  <summary xml:lang="fr">Navigateur Web</summary>
+  <summary xml:lang="hu">Webböngésző</summary>
+  <summary xml:lang="it">Browser Web</summary>
+  <summary xml:lang="ja">ウェブ・ブラウザ</summary>
+  <summary xml:lang="ko">웹 브라우저</summary>
+  <summary xml:lang="nb">Nettleser</summary>
+  <summary xml:lang="nl">Webbrowser</summary>
+  <summary xml:lang="nn">Nettlesar</summary>
+  <summary xml:lang="no">Nettleser</summary>
+  <summary xml:lang="pl">Przeglądarka WWW</summary>
+  <summary xml:lang="pt">Navegador Web</summary>
+  <summary xml:lang="pt_BR">Navegador Web</summary>
+  <summary xml:lang="sk">Internetový prehliadač</summary>
+  <summary xml:lang="sv">Webbläsare</summary>
+  <description>
+    <p>
+      Bringing together all kinds of awesomeness to make browsing better for you.
+      Get to your favorite sites quickly – even if you don’t remember the URLs.
+      Type your term into the location bar (aka the Awesome Bar) and the autocomplete
+      function will include possible matches from your browsing history, bookmarked
+      sites and open tabs.
+    </p>
+  </description>
+  <url type="homepage">https://www.mozilla.org</url>
+  <update_contact>stransky@redhat.com</update_contact>
+  <kudos>
+    <kudo>ModernToolkit</kudo>
+    <kudo>SearchProvider</kudo>
+  </kudos>
+  <project_group>Mozilla</project_group>
+  <project_license>GPL-3.0+</project_license>
+  <developer_name>Mozilla Corporation</developer_name>
+  <url type="bugtracker">https://bugzilla.mozilla.org/</url>
+  <url type="help">https://support.mozilla.org/</url>
+  <translation type="gettext">firefox</translation>
+  <provides>
+    <id>firefox.desktop</id>
+  </provides>
+  <screenshots>
+    <screenshot type="default">https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/firefox/a.png</screenshot>
+    <screenshot>https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/firefox/b.png</screenshot>
+    <screenshot>https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/firefox/c.png</screenshot>
+  </screenshots>
+  <releases>
+    <release version="__VERSION__" date="__DATE__"/>
+  </releases>
+</component>
diff --git a/SOURCES/firefox.desktop b/SOURCES/firefox.desktop
index f13e600..a152ed4 100644
--- a/SOURCES/firefox.desktop
+++ b/SOURCES/firefox.desktop
@@ -50,7 +50,7 @@ MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xm
 StartupNotify=true
 Categories=Network;WebBrowser;
 Keywords=web;browser;internet;
-Actions=new-window;new-private-window;
+Actions=new-window;new-private-window;profile-manager-window;
 
 [Desktop Action new-window]
 Name=Open a New Window
@@ -63,8 +63,8 @@ Name[ast]=Ventana nueva
 Name[az]=Yeni Pəncərə
 Name[be]=Новае акно
 Name[bg]=Нов прозорец
-Name[bn-BD]=নতুন উইন্ডো (N)
-Name[bn-IN]=নতুন উইন্ডো
+Name[bn_BD]=নতুন উইন্ডো (N)
+Name[bn_IN]=নতুন উইন্ডো
 Name[br]=Prenestr nevez
 Name[brx]=गोदान उइन्ड'(N)
 Name[bs]=Novi prozor
@@ -76,37 +76,37 @@ Name[da]=Nyt vindue
 Name[de]=Neues Fenster
 Name[dsb]=Nowe wokno
 Name[el]=Νέο παράθυρο
-Name[en-GB]=New Window
-Name[en-US]=New Window
-Name[en-ZA]=New Window
+Name[en_GB]=New Window
+Name[en_US]=New Window
+Name[en_ZA]=New Window
 Name[eo]=Nova fenestro
-Name[es-AR]=Nueva ventana
-Name[es-CL]=Nueva ventana
-Name[es-ES]=Nueva ventana
-Name[es-MX]=Nueva ventana
+Name[es_AR]=Nueva ventana
+Name[es_CL]=Nueva ventana
+Name[es_ES]=Nueva ventana
+Name[es_MX]=Nueva ventana
 Name[et]=Uus aken
 Name[eu]=Leiho berria
 Name[fa]=پنجره جدید‌
 Name[ff]=Henorde Hesere
 Name[fi]=Uusi ikkuna
 Name[fr]=Nouvelle fenêtre
-Name[fy-NL]=Nij finster
-Name[ga-IE]=Fuinneog Nua
+Name[fy_NL]=Nij finster
+Name[ga_IE]=Fuinneog Nua
 Name[gd]=Uinneag ùr
 Name[gl]=Nova xanela
 Name[gn]=Ovetã pyahu
-Name[gu-IN]=નવી વિન્ડો
+Name[gu_IN]=નવી વિન્ડો
 Name[he]=חלון חדש
-Name[hi-IN]=नया विंडो
+Name[hi_IN]=नया विंडो
 Name[hr]=Novi prozor
 Name[hsb]=Nowe wokno
 Name[hu]=Új ablak
-Name[hy-AM]=Նոր Պատուհան
+Name[hy_AM]=Նոր Պատուհան
 Name[id]=Jendela Baru
 Name[is]=Nýr gluggi
 Name[it]=Nuova finestra
 Name[ja]=新しいウィンドウ
-Name[ja-JP-mac]=新規ウインドウ
+Name[ja_JP-mac]=新規ウインドウ
 Name[ka]=ახალი ფანჯარა
 Name[kk]=Жаңа терезе
 Name[km]=បង្អួច​​​ថ្មី
@@ -125,15 +125,15 @@ Name[ml]=പുതിയ ജാലകം
 Name[mr]=नवीन पटल
 Name[ms]=Tetingkap Baru
 Name[my]=ဝင်းဒိုးအသစ်
-Name[nb-NO]=Nytt vindu
-Name[ne-NP]=नयाँ सञ्झ्याल
+Name[nb_NO]=Nytt vindu
+Name[ne_NP]=नयाँ सञ्झ्याल
 Name[nl]=Nieuw venster
-Name[nn-NO]=Nytt vindauge
+Name[nn_NO]=Nytt vindauge
 Name[or]=ନୂତନ ୱିଣ୍ଡୋ
-Name[pa-IN]=ਨਵੀਂ ਵਿੰਡੋ
+Name[pa_IN]=ਨਵੀਂ ਵਿੰਡੋ
 Name[pl]=Nowe okno
-Name[pt-BR]=Nova janela
-Name[pt-PT]=Nova janela
+Name[pt_BR]=Nova janela
+Name[pt_PT]=Nova janela
 Name[rm]=Nova fanestra
 Name[ro]=Fereastră nouă
 Name[ru]=Новое окно
@@ -144,7 +144,7 @@ Name[sl]=Novo okno
 Name[son]=Zanfun taaga
 Name[sq]=Dritare e Re
 Name[sr]=Нови прозор
-Name[sv-SE]=Nytt fönster
+Name[sv_SE]=Nytt fönster
 Name[ta]=புதிய சாளரம்
 Name[te]=కొత్త విండో
 Name[th]=หน้าต่างใหม่
@@ -156,11 +156,9 @@ Name[uz]=Yangi oyna
 Name[vi]=Cửa sổ mới
 Name[wo]=Palanteer bu bees
 Name[xh]=Ifestile entsha
-Name[zh-CN]=新建窗口
-Name[zh-TW]=開新視窗
-
-
-Exec=firefox %u
+Name[zh_CN]=新建窗口
+Name[zh_TW]=開新視窗
+Exec=firefox --new-window %u
 
 [Desktop Action new-private-window]
 Name=Open a New Private Window
@@ -173,8 +171,8 @@ Name[ast]=Ventana privada nueva
 Name[az]=Yeni Məxfi Pəncərə
 Name[be]=Новае акно адасаблення
 Name[bg]=Нов прозорец за поверително сърфиране
-Name[bn-BD]=নতুন ব্যক্তিগত উইন্ডো
-Name[bn-IN]=নতুন ব্যক্তিগত উইন্ডো
+Name[bn_BD]=নতুন ব্যক্তিগত উইন্ডো
+Name[bn_IN]=নতুন ব্যক্তিগত উইন্ডো
 Name[br]=Prenestr merdeiñ prevez nevez
 Name[brx]=गोदान प्राइभेट उइन्ड'
 Name[bs]=Novi privatni prozor
@@ -186,37 +184,37 @@ Name[da]=Nyt privat vindue
 Name[de]=Neues privates Fenster
 Name[dsb]=Nowe priwatne wokno
 Name[el]=Νέο παράθυρο ιδιωτικής περιήγησης
-Name[en-GB]=New Private Window
-Name[en-US]=New Private Window
-Name[en-ZA]=New Private Window
+Name[en_GB]=New Private Window
+Name[en_US]=New Private Window
+Name[en_ZA]=New Private Window
 Name[eo]=Nova privata fenestro
-Name[es-AR]=Nueva ventana privada
-Name[es-CL]=Nueva ventana privada
-Name[es-ES]=Nueva ventana privada
-Name[es-MX]=Nueva ventana privada
+Name[es_AR]=Nueva ventana privada
+Name[es_CL]=Nueva ventana privada
+Name[es_ES]=Nueva ventana privada
+Name[es_MX]=Nueva ventana privada
 Name[et]=Uus privaatne aken
 Name[eu]=Leiho pribatu berria
 Name[fa]=پنجره ناشناس جدید
 Name[ff]=Henorde Suturo Hesere
 Name[fi]=Uusi yksityinen ikkuna
 Name[fr]=Nouvelle fenêtre de navigation privée
-Name[fy-NL]=Nij priveefinster
-Name[ga-IE]=Fuinneog Nua Phríobháideach
+Name[fy_NL]=Nij priveefinster
+Name[ga_IE]=Fuinneog Nua Phríobháideach
 Name[gd]=Uinneag phrìobhaideach ùr
 Name[gl]=Nova xanela privada
 Name[gn]=Ovetã ñemi pyahu
-Name[gu-IN]=નવી ખાનગી વિન્ડો
+Name[gu_IN]=નવી ખાનગી વિન્ડો
 Name[he]=חלון פרטי חדש
-Name[hi-IN]=नयी निजी विंडो
+Name[hi_IN]=नयी निजी विंडो
 Name[hr]=Novi privatni prozor
 Name[hsb]=Nowe priwatne wokno
 Name[hu]=Új privát ablak
-Name[hy-AM]=Սկսել Գաղտնի դիտարկում
+Name[hy_AM]=Սկսել Գաղտնի դիտարկում
 Name[id]=Jendela Mode Pribadi Baru
 Name[is]=Nýr huliðsgluggi
 Name[it]=Nuova finestra anonima
 Name[ja]=新しいプライベートウィンドウ
-Name[ja-JP-mac]=新規プライベートウインドウ
+Name[ja_JP-mac]=新規プライベートウインドウ
 Name[ka]=ახალი პირადი ფანჯარა
 Name[kk]=Жаңа жекелік терезе
 Name[km]=បង្អួច​ឯកជន​ថ្មី
@@ -235,15 +233,15 @@ Name[ml]=പുതിയ സ്വകാര്യ ജാലകം
 Name[mr]=नवीन वैयक्तिक पटल
 Name[ms]=Tetingkap Persendirian Baharu
 Name[my]=New Private Window
-Name[nb-NO]=Nytt privat vindu
-Name[ne-NP]=नयाँ निजी सञ्झ्याल
+Name[nb_NO]=Nytt privat vindu
+Name[ne_NP]=नयाँ निजी सञ्झ्याल
 Name[nl]=Nieuw privévenster
-Name[nn-NO]=Nytt privat vindauge
+Name[nn_NO]=Nytt privat vindauge
 Name[or]=ନୂତନ ବ୍ୟକ୍ତିଗତ ୱିଣ୍ଡୋ
-Name[pa-IN]=ਨਵੀਂ ਪ੍ਰਾਈਵੇਟ ਵਿੰਡੋ
+Name[pa_IN]=ਨਵੀਂ ਪ੍ਰਾਈਵੇਟ ਵਿੰਡੋ
 Name[pl]=Nowe okno prywatne
-Name[pt-BR]=Nova janela privativa
-Name[pt-PT]=Nova janela privada
+Name[pt_BR]=Nova janela privativa
+Name[pt_PT]=Nova janela privada
 Name[rm]=Nova fanestra privata
 Name[ro]=Fereastră privată nouă
 Name[ru]=Новое приватное окно
@@ -254,7 +252,7 @@ Name[sl]=Novo zasebno okno
 Name[son]=Sutura zanfun taaga
 Name[sq]=Dritare e Re Private
 Name[sr]=Нови приватан прозор
-Name[sv-SE]=Nytt privat fönster
+Name[sv_SE]=Nytt privat fönster
 Name[ta]=புதிய தனிப்பட்ட சாளரம்
 Name[te]=కొత్త ఆంతరంగిక విండో
 Name[th]=หน้าต่างส่วนตัวใหม่
@@ -266,7 +264,12 @@ Name[uz]=Yangi maxfiy oyna
 Name[vi]=Cửa sổ riêng tư mới
 Name[wo]=Panlanteeru biir bu bees
 Name[xh]=Ifestile yangasese entsha
-Name[zh-CN]=新建隐私浏览窗口
-Name[zh-TW]=新增隱私視窗
+Name[zh_CN]=新建隐私浏览窗口
+Name[zh_TW]=新增隱私視窗
 Exec=firefox --private-window %u
 
+[Desktop Action profile-manager-window]
+Name=Open the Profile Manager
+Name[cs]=Správa profilů
+Name[de]=Profilverwaltung öffnen
+Exec=firefox --ProfileManager
diff --git a/SOURCES/firefox.sh.in b/SOURCES/firefox.sh.in
index 06c10ed..42eb1a7 100644
--- a/SOURCES/firefox.sh.in
+++ b/SOURCES/firefox.sh.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/bash
 #
 # The contents of this file are subject to the Netscape Public
 # License Version 1.1 (the "License"); you may not use this file
@@ -39,12 +39,12 @@ cmdname=`basename $0`
 MOZ_ARCH=$(uname -m)
 case $MOZ_ARCH in
 	x86_64 | s390x | sparc64)
-		MOZ_LIB_DIR="%PREFIX%/lib64"
-		SECONDARY_LIB_DIR="%PREFIX%/lib"
+		MOZ_LIB_DIR="/__PREFIX__/lib64"
+		SECONDARY_LIB_DIR="/__PREFIX__/lib"
 		;;
 	* )
-		MOZ_LIB_DIR="%PREFIX%/lib"
-		SECONDARY_LIB_DIR="%PREFIX%/lib64"
+		MOZ_LIB_DIR="/__PREFIX__/lib"
+		SECONDARY_LIB_DIR="/__PREFIX__/lib64"
 		;;
 esac
 
@@ -61,14 +61,40 @@ if [ ! -r $MOZ_LIB_DIR/firefox/$MOZ_FIREFOX_FILE ]; then
     MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
 fi
 MOZ_DIST_BIN="$MOZ_LIB_DIR/firefox"
+MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks"
+MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
 MOZ_PROGRAM="$MOZ_DIST_BIN/$MOZ_FIREFOX_FILE"
 MOZ_LAUNCHER="$MOZ_DIST_BIN/run-mozilla.sh"
+GETENFORCE_FILE="/usr/sbin/getenforce"
+
+##
+## Enable Wayland backend?
+##
+%DISABLE_WAYLAND_PLACEHOLDER%
+
+if ! [ $MOZ_DISABLE_WAYLAND ] && [ "$WAYLAND_DISPLAY" ]; then
+  if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ]; then
+    export MOZ_ENABLE_WAYLAND=1
+  fi
+##  Enable Wayland on KDE/Sway
+##
+  if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
+    export MOZ_ENABLE_WAYLAND=1
+  fi
+fi
+
+##
+## Use D-Bus remote exclusively when there's Wayland display.
+##
+if [ "$WAYLAND_DISPLAY" ]; then
+  export MOZ_DBUS_REMOTE=1
+fi
 
 ##
 ## Set MOZ_GRE_CONF
 ##
 MOZ_GRE_CONF=/etc/gre.d/gre.conf
-if [ "$MOZ_LIB_DIR" == "/usr/lib64" ]; then
+if [ "$MOZ_LIB_DIR" == "/__PREFIX__/lib64" ]; then
   MOZ_GRE_CONF=/etc/gre.d/gre64.conf
 fi
 export MOZ_GRE_CONF
@@ -96,7 +122,18 @@ export MOZ_PLUGIN_PATH
 ##
 ## Set MOZ_APP_LAUNCHER for gnome-session
 ##
-export MOZ_APP_LAUNCHER="%PREFIX%/bin/firefox"
+export MOZ_APP_LAUNCHER="/__PREFIX__/bin/firefox"
+
+##
+## Set FONTCONFIG_PATH for Xft/fontconfig
+##
+FONTCONFIG_PATH="/etc/fonts:${MOZILLA_FIVE_HOME}/res/Xft"
+export FONTCONFIG_PATH
+
+##
+## We want Firefox to use Openh264 provided by Fedora
+##
+export MOZ_GMP_PATH=$MOZ_LIB_DIR/mozilla/plugins/gmp-gmpopenh264/system-installed
 
 ##
 ## In order to better support certain scripts (such as Indic and some CJK 
@@ -127,6 +164,85 @@ export G_SLICE=always-malloc
 ##
 export MOZ_USE_XINPUT2=1
 
+# OK, here's where all the real work gets done
+
+
+##
+## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1
+## in your environment before launching Firefox.
+##
+#
+# MOZ_DISABLE_LANGPACKS=1
+# export MOZ_DISABLE_LANGPACKS
+#
+
+##
+## Automatically installed langpacks are tracked by .fedora-langpack-install
+## config file.
+##
+FEDORA_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.fedora-langpack-install"
+
+# MOZ_DISABLE_LANGPACKS disables language packs completely
+MOZILLA_DOWN=0
+if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then
+    if [ -x $MOZ_DIST_BIN/$MOZ_FIREFOX_FILE ]; then
+        # Is firefox running?
+        /__PREFIX__/bin/pidof $MOZ_PROGRAM > /dev/null 2>&1
+        MOZILLA_DOWN=$?
+    fi
+fi
+
+# When Firefox is not running, restore SELinux labels for profile files
+# (rhbz#1731371)
+if [ $MOZILLA_DOWN -ne 0 ]; then
+  if [ -x $GETENFORCE_FILE ] && [ `getenforce` != "Disabled" ]; then
+    (restorecon -vr ~/.mozilla/firefox/* &)
+  fi
+fi
+
+# Modify language pack configuration only when firefox is not running 
+# and language packs are not disabled
+if [ $MOZILLA_DOWN -ne 0 ]; then
+
+    # Clear already installed langpacks
+    mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
+    if [ -f $FEDORA_LANGPACK_CONFIG ]; then
+        rm `cat $FEDORA_LANGPACK_CONFIG` > /dev/null 2>&1
+        rm $FEDORA_LANGPACK_CONFIG > /dev/null 2>&1
+        # remove all empty langpacks dirs while they block installation of langpacks
+        rmdir $MOZ_EXTENSIONS_PROFILE_DIR/langpack* > /dev/null 2>&1
+    fi
+
+    # Get locale from system
+    CURRENT_LOCALE=$LC_ALL
+    CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
+    CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
+
+    # Try with a local variant first, then without a local variant
+    SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g" | sed "s|\..*||g"`
+    MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g" | sed "s|\..*||g"`
+
+    function create_langpack_link() {
+        local language=$*
+        local langpack=langpack-${language}@firefox.mozilla.org.xpi
+        if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
+            rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
+            # If the target file is a symlink (the fallback langpack), 
+            # install the original file instead of the fallback one
+            if [ -h $MOZ_LANGPACKS_DIR/$langpack ]; then
+                langpack=`readlink $MOZ_LANGPACKS_DIR/$langpack`
+            fi
+            ln -s $MOZ_LANGPACKS_DIR/$langpack \
+                  $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
+            echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $FEDORA_LANGPACK_CONFIG
+            return 0
+        fi
+        return 1
+    }
+
+    create_langpack_link $MOZLOCALE || create_langpack_link $SHORTMOZLOCALE || true
+fi
+
 # BEAST fix (rhbz#1005611)
 NSS_SSL_CBC_RANDOM_IV=${NSS_SSL_CBC_RANDOM_IV-1}
 export NSS_SSL_CBC_RANDOM_IV
@@ -160,11 +276,17 @@ do
   esac
 done
 
-# Linux version specific environment variables
-%RHEL_ENV_VARS%
+# Flatpak specific environment variables
+%FLATPAK_ENV_VARS%
 
 # Don't throw "old profile" dialog box.
 export MOZ_ALLOW_DOWNGRADE=1
 
 # Run the browser
+debugging=0
+if [ $debugging = 1 ]
+then
+  echo $MOZ_LAUNCHER $script_args $MOZ_PROGRAM "$@"
+fi
+
 exec $MOZ_LAUNCHER $script_args $MOZ_PROGRAM "$@"
diff --git a/SOURCES/google-loc-api-key b/SOURCES/google-loc-api-key
new file mode 100644
index 0000000..f40090d
--- /dev/null
+++ b/SOURCES/google-loc-api-key
@@ -0,0 +1 @@
+AIzaSyB2h2OuRcUgy5N-5hsZqiPW6sH3n_rptiQ
diff --git a/SOURCES/mozilla-1170092.patch b/SOURCES/mozilla-1170092.patch
index 50d6785..d4cd582 100644
--- a/SOURCES/mozilla-1170092.patch
+++ b/SOURCES/mozilla-1170092.patch
@@ -1,6 +1,6 @@
-diff -up firefox-91.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-91.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
---- firefox-91.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2021-07-27 23:29:57.000000000 +0200
-+++ firefox-91.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2021-07-29 16:20:44.164513998 +0200
+diff -up firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
+--- firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2021-03-18 14:48:36.000000000 +0100
++++ firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2021-03-22 19:20:02.429310184 +0100
 @@ -249,8 +249,20 @@ nsresult nsReadConfig::openAndEvaluateJS
      if (NS_FAILED(rv)) return rv;
  
@@ -23,22 +23,23 @@ diff -up firefox-91.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 fi
    } else {
      nsAutoCString location("resource://gre/defaults/autoconfig/");
      location += aFileName;
-diff -up firefox-91.0/modules/libpref/Preferences.cpp.1170092 firefox-91.0/modules/libpref/Preferences.cpp
---- firefox-91.0/modules/libpref/Preferences.cpp.1170092	2021-07-27 23:30:34.000000000 +0200
-+++ firefox-91.0/modules/libpref/Preferences.cpp	2021-07-29 16:20:44.166514005 +0200
-@@ -4553,6 +4553,8 @@ nsresult Preferences::InitInitialObjects
+diff -up firefox-87.0/modules/libpref/Preferences.cpp.1170092 firefox-87.0/modules/libpref/Preferences.cpp
+--- firefox-87.0/modules/libpref/Preferences.cpp.1170092	2021-03-18 14:48:54.000000000 +0100
++++ firefox-87.0/modules/libpref/Preferences.cpp	2021-03-22 19:20:02.429310184 +0100
+@@ -4499,6 +4499,9 @@ nsresult Preferences::InitInitialObjects
    //
    // Thus, in the omni.jar case, we always load app-specific default
    // preferences from omni.jar, whether or not `$app == $gre`.
++  //
 +  // At very end load configuration from system config location:
 +  // - /etc/firefox/pref/*.js
  
    nsresult rv = NS_ERROR_FAILURE;
    UniquePtr<nsZipFind> find;
-diff -up firefox-91.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-91.0/toolkit/xre/nsXREDirProvider.cpp
---- firefox-91.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2021-07-27 23:30:56.000000000 +0200
-+++ firefox-91.0/toolkit/xre/nsXREDirProvider.cpp	2021-07-29 16:26:20.071628932 +0200
-@@ -71,6 +71,7 @@
+diff -up firefox-87.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-87.0/toolkit/xre/nsXREDirProvider.cpp
+--- firefox-87.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2021-03-18 14:52:00.000000000 +0100
++++ firefox-87.0/toolkit/xre/nsXREDirProvider.cpp	2021-03-22 19:37:56.574480347 +0100
+@@ -65,6 +65,7 @@
  #endif
  #ifdef XP_UNIX
  #  include <ctype.h>
@@ -46,7 +47,7 @@ diff -up firefox-91.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-91.0/tool
  #endif
  #ifdef XP_IOS
  #  include "UIKitDirProvider.h"
-@@ -550,6 +551,21 @@ nsXREDirProvider::GetFile(const char* aP
+@@ -552,6 +553,21 @@ nsXREDirProvider::GetFile(const char* aP
        }
      }
    }
@@ -68,26 +69,26 @@ diff -up firefox-91.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-91.0/tool
    if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE;
  
    if (ensureFilePermissions) {
-@@ -827,6 +843,16 @@ nsresult nsXREDirProvider::GetFilesInter
-       LoadDirIntoArray(mXULAppDir, kAppendBackgroundTasksPrefDir, directories);
+@@ -874,6 +890,16 @@ nsresult nsXREDirProvider::GetFilesInter
      }
  #endif
+ 
 +    // Add /etc/<application>/pref/ directory if it exists
 +    nsCOMPtr<nsIFile> systemPrefDir;
 +    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
 +                                getter_AddRefs(systemPrefDir));
 +    if (NS_SUCCEEDED(rv)) {
 +      rv = systemPrefDir->AppendNative(nsLiteralCString("pref"));
-+      if (NS_SUCCEEDED(rv)) {
++      if (NS_SUCCEEDED(rv))
 +        directories.AppendObject(systemPrefDir);
 +      }
-+    }
- 
++
      rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
    } else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
-diff -up firefox-91.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-91.0/xpcom/io/nsAppDirectoryServiceDefs.h
---- firefox-91.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2021-07-27 23:31:38.000000000 +0200
-+++ firefox-91.0/xpcom/io/nsAppDirectoryServiceDefs.h	2021-07-29 16:20:44.168514012 +0200
+     // NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
+diff -up firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h
+--- firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2021-03-18 14:51:58.000000000 +0100
++++ firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h	2021-03-22 19:20:02.430310213 +0100
 @@ -59,6 +59,7 @@
  #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
  #define NS_APP_PREFS_OVERRIDE_DIR \
diff --git a/SOURCES/mozilla-1516803.patch b/SOURCES/mozilla-1516803.patch
new file mode 100644
index 0000000..5053e51
--- /dev/null
+++ b/SOURCES/mozilla-1516803.patch
@@ -0,0 +1,15 @@
+diff -up firefox-84.0/security/sandbox/linux/moz.build.1516803 firefox-84.0/security/sandbox/linux/moz.build
+--- firefox-84.0/security/sandbox/linux/moz.build.1516803	2020-12-10 16:17:55.425139545 +0100
++++ firefox-84.0/security/sandbox/linux/moz.build	2020-12-10 16:29:21.945860841 +0100
+@@ -114,9 +114,8 @@ if CONFIG["CC_TYPE"] in ("clang", "gcc")
+ # gcc lto likes to put the top level asm in syscall.cc in a different partition
+ # from the function using it which breaks the build.  Work around that by
+ # forcing there to be only one partition.
+-for f in CONFIG["OS_CXXFLAGS"]:
+-    if f.startswith("-flto") and CONFIG["CC_TYPE"] != "clang":
+-        LDFLAGS += ["--param lto-partitions=1"]
++if CONFIG['CC_TYPE'] != 'clang':
++    LDFLAGS += ['--param', 'lto-partitions=1']
+ 
+ DEFINES["NS_NO_XPCOM"] = True
+ DisableStlWrapping()
diff --git a/SOURCES/mozilla-1669639.patch b/SOURCES/mozilla-1669639.patch
new file mode 100644
index 0000000..cd04aab
--- /dev/null
+++ b/SOURCES/mozilla-1669639.patch
@@ -0,0 +1,14 @@
+--- firefox-81.0.1/build/mach_initialize.py.old	2020-10-06 14:16:06.212974910 +0200
++++ firefox-81.0.1/build/mach_initialize.py	2020-10-06 14:19:03.313179557 +0200
+@@ -507,7 +507,10 @@ class ImportHook(object):
+         # doesn't happen or because it doesn't matter).
+         if not os.path.exists(module.__file__[:-1]):
+             if os.path.exists(module.__file__):
+-                os.remove(module.__file__)
++                try:
++                    os.remove(module.__file__)
++                except:
++                    pass
+             del sys.modules[module.__name__]
+             module = self(name, globals, locals, fromlist, level)
+ 
diff --git a/SOURCES/mozilla-1670333.patch b/SOURCES/mozilla-1670333.patch
new file mode 100644
index 0000000..1c5c476
--- /dev/null
+++ b/SOURCES/mozilla-1670333.patch
@@ -0,0 +1,68 @@
+diff -up firefox-99.0/dom/media/mp4/MP4Demuxer.cpp.1670333 firefox-99.0/dom/media/mp4/MP4Demuxer.cpp
+--- firefox-99.0/dom/media/mp4/MP4Demuxer.cpp.1670333	2022-03-31 01:24:44.000000000 +0200
++++ firefox-99.0/dom/media/mp4/MP4Demuxer.cpp	2022-04-04 09:58:35.606351546 +0200
+@@ -31,6 +31,8 @@ mozilla::LogModule* GetDemuxerLog() { re
+   DDMOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, "::%s: " arg, \
+             __func__, ##__VA_ARGS__)
+ 
++extern bool gUseKeyframeFromContainer;
++
+ namespace mozilla {
+ 
+ DDLoggedTypeDeclNameAndBase(MP4TrackDemuxer, MediaTrackDemuxer);
+@@ -394,6 +396,12 @@ already_AddRefed<MediaRawData> MP4TrackD
+           [[fallthrough]];
+         case H264::FrameType::OTHER: {
+           bool keyframe = type == H264::FrameType::I_FRAME;
++          if (gUseKeyframeFromContainer) {
++            if (sample->mKeyframe && sample->mKeyframe != keyframe) {
++              sample->mKeyframe = keyframe;
++            }
++            break;
++          }
+           if (sample->mKeyframe != keyframe) {
+             NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
+                                        "@ pts:%" PRId64 " dur:%" PRId64
+diff -up firefox-99.0/dom/media/platforms/PDMFactory.cpp.1670333 firefox-99.0/dom/media/platforms/PDMFactory.cpp
+--- firefox-99.0/dom/media/platforms/PDMFactory.cpp.1670333	2022-03-31 01:24:44.000000000 +0200
++++ firefox-99.0/dom/media/platforms/PDMFactory.cpp	2022-04-04 10:09:57.383419125 +0200
+@@ -58,6 +58,8 @@
+ 
+ #include <functional>
+ 
++bool gUseKeyframeFromContainer = false;
++
+ namespace mozilla {
+ 
+ #define PDM_INIT_LOG(msg, ...) \
+@@ -495,7 +497,7 @@ void PDMFactory::CreateRddPDMs() {
+ #ifdef MOZ_FFMPEG
+   if (StaticPrefs::media_ffmpeg_enabled() &&
+       StaticPrefs::media_rdd_ffmpeg_enabled() &&
+-      !CreateAndStartupPDM<FFmpegRuntimeLinker>()) {
++      !(mFFmpegUsed = CreateAndStartupPDM<FFmpegRuntimeLinker>())) {
+     mFailureFlags += GetFailureFlagBasedOnFFmpegStatus(
+         FFmpegRuntimeLinker::LinkStatusCode());
+   }
+@@ -602,8 +604,9 @@ void PDMFactory::CreateDefaultPDMs() {
+ 
+   CreateAndStartupPDM<AgnosticDecoderModule>();
+ 
+-  if (StaticPrefs::media_gmp_decoder_enabled() &&
++  if (StaticPrefs::media_gmp_decoder_enabled() && !mFFmpegUsed &&
+       !CreateAndStartupPDM<GMPDecoderModule>()) {
++    gUseKeyframeFromContainer = true;
+     mFailureFlags += DecoderDoctorDiagnostics::Flags::GMPPDMFailedToStartup;
+   }
+ }
+diff -up firefox-99.0/dom/media/platforms/PDMFactory.h.1670333 firefox-99.0/dom/media/platforms/PDMFactory.h
+--- firefox-99.0/dom/media/platforms/PDMFactory.h.1670333	2022-03-31 01:24:44.000000000 +0200
++++ firefox-99.0/dom/media/platforms/PDMFactory.h	2022-04-04 09:58:35.606351546 +0200
+@@ -121,6 +121,7 @@ class PDMFactory final {
+   RefPtr<PlatformDecoderModule> mNullPDM;
+ 
+   DecoderDoctorDiagnostics::FlagsSet mFailureFlags;
++  bool mFFmpegUsed = false;
+ 
+   friend class RemoteVideoDecoderParent;
+   static void EnsureInit();
diff --git a/SOURCES/mozilla-1775202.patch b/SOURCES/mozilla-1775202.patch
new file mode 100644
index 0000000..b1748de
--- /dev/null
+++ b/SOURCES/mozilla-1775202.patch
@@ -0,0 +1,17 @@
+diff --git a/third_party/libwebrtc/moz.build b/third_party/libwebrtc/moz.build
+index 8579f8bb3622..d9ca79d4fcb8 100644
+--- a/third_party/libwebrtc/moz.build
++++ b/third_party/libwebrtc/moz.build
+@@ -520,7 +520,10 @@ if CONFIG["CPU_ARCH"] == "ppc64" and CONFIG["OS_TARGET"] == "Linux":
+         "/third_party/libwebrtc/api/audio_codecs/isac/audio_decoder_isac_float_gn",
+         "/third_party/libwebrtc/api/audio_codecs/isac/audio_encoder_isac_float_gn",
+         "/third_party/libwebrtc/modules/audio_coding/isac_c_gn",
+-        "/third_party/libwebrtc/modules/audio_coding/isac_gn"
++        "/third_party/libwebrtc/modules/audio_coding/isac_gn",
++        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_generic_gn",
++        "/third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
++        "/third_party/libwebrtc/modules/desktop_capture/primitives_gn"
+     ]
+ 
+ if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
diff --git a/SOURCES/mozilla-bmo1005535.patch b/SOURCES/mozilla-bmo1005535.patch
index cab0134..d20d812 100644
--- a/SOURCES/mozilla-bmo1005535.patch
+++ b/SOURCES/mozilla-bmo1005535.patch
@@ -1,7 +1,20 @@
-diff -up firefox-78.0/gfx/skia/skia/src/gpu/GrColor.h.mozilla.bmo1005535 firefox-78.0/gfx/skia/skia/src/gpu/GrColor.h
---- firefox-78.0/gfx/skia/skia/src/gpu/GrColor.h.mozilla.bmo1005535	2020-06-25 16:16:34.459083304 +0200
-+++ firefox-78.0/gfx/skia/skia/src/gpu/GrColor.h	2020-06-25 16:17:00.968174743 +0200
-@@ -64,7 +64,7 @@ static inline GrColor GrColorPackRGBA(un
+# HG changeset patch
+# User Steve Singer <steve@ssinger.info>
+# Date 1558451540 -7200
+#      Tue May 21 17:12:20 2019 +0200
+# Node ID 433beec63e6b5f409683af20a0c1ab137cc7bfad
+# Parent  c0fdccc716e80a6d289c94f5d507ae141c62a3bf
+Bug 1005535 - Get skia GPU building on big endian.
+
+diff --git a/gfx/skia/skia/src/gpu/GrColor.h b/gfx/skia/skia/src/gpu/GrColor.h
+--- a/gfx/skia/skia/src/gpu/GrColor.h
++++ b/gfx/skia/skia/src/gpu/GrColor.h
+@@ -59,17 +59,17 @@ static inline GrColor GrColorPackRGBA(un
+ #define GrColorUnpackG(color)   (((color) >> GrColor_SHIFT_G) & 0xFF)
+ #define GrColorUnpackB(color)   (((color) >> GrColor_SHIFT_B) & 0xFF)
+ #define GrColorUnpackA(color)   (((color) >> GrColor_SHIFT_A) & 0xFF)
+ 
+ /**
   *  Since premultiplied means that alpha >= color, we construct a color with
   *  each component==255 and alpha == 0 to be "illegal"
   */
@@ -10,3 +23,8 @@ diff -up firefox-78.0/gfx/skia/skia/src/gpu/GrColor.h.mozilla.bmo1005535 firefox
  
  /** Normalizes and coverts an uint8_t to a float. [0, 255] -> [0.0, 1.0] */
  static inline float GrNormalizeByteToFloat(uint8_t value) {
+     static const float ONE_OVER_255 = 1.f / 255.f;
+     return value * ONE_OVER_255;
+ }
+ 
+ /** Used to pick vertex attribute types. */
diff --git a/SOURCES/mozilla-bmo1504834-part1.patch b/SOURCES/mozilla-bmo1504834-part1.patch
index 01da145..1afe3aa 100644
--- a/SOURCES/mozilla-bmo1504834-part1.patch
+++ b/SOURCES/mozilla-bmo1504834-part1.patch
@@ -1,7 +1,16 @@
-diff -up firefox-78.0/gfx/2d/DrawTargetSkia.cpp.mozilla-bmo1504834-part1 firefox-78.0/gfx/2d/DrawTargetSkia.cpp
---- firefox-78.0/gfx/2d/DrawTargetSkia.cpp.mozilla-bmo1504834-part1	2020-06-17 04:18:58.000000000 +0200
-+++ firefox-78.0/gfx/2d/DrawTargetSkia.cpp	2020-06-25 16:52:29.824532769 +0200
-@@ -135,8 +135,7 @@ static IntRect CalculateSurfaceBounds(co
+# HG changeset patch
+# Parent  b5471d23321d16a0bacc25b7afd27d2e16adba1a
+Taken from https://bugzilla.mozilla.org/show_bug.cgi?id=1504834
+
+diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp
+--- a/gfx/2d/DrawTargetSkia.cpp
++++ b/gfx/2d/DrawTargetSkia.cpp
+@@ -130,18 +130,17 @@ static IntRect CalculateSurfaceBounds(co
+   Rect sampledBounds = inverse.TransformBounds(*aBounds);
+   if (!sampledBounds.ToIntRect(&bounds)) {
+     return surfaceBounds;
+   }
+ 
    return surfaceBounds.Intersect(bounds);
  }
  
@@ -11,10 +20,20 @@ diff -up firefox-78.0/gfx/2d/DrawTargetSkia.cpp.mozilla-bmo1504834-part1 firefox
  
  static bool VerifyRGBXFormat(uint8_t* aData, const IntSize& aSize,
                               const int32_t aStride, SurfaceFormat aFormat) {
-diff -up firefox-78.0/gfx/2d/Types.h.mozilla-bmo1504834-part1 firefox-78.0/gfx/2d/Types.h
---- firefox-78.0/gfx/2d/Types.h.mozilla-bmo1504834-part1	2020-06-25 16:52:29.826532776 +0200
-+++ firefox-78.0/gfx/2d/Types.h	2020-06-25 16:55:02.942063616 +0200
-@@ -90,15 +90,8 @@ enum class SurfaceFormat : int8_t {
+   if (aFormat != SurfaceFormat::B8G8R8X8 || aSize.IsEmpty()) {
+     return true;
+   }
+   // We should've initialized the data to be opaque already
+   // On debug builds, verify that this is actually true.
+diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h
+--- a/gfx/2d/Types.h
++++ b/gfx/2d/Types.h
+@@ -84,25 +84,18 @@ enum class SurfaceFormat : int8_t {
+   Depth,
+ 
+   // This represents the unknown format.
+   UNKNOWN,
+ 
  // The following values are endian-independent synonyms. The _UINT32 suffix
  // indicates that the name reflects the layout when viewed as a uint32_t
  // value.
@@ -30,10 +49,20 @@ diff -up firefox-78.0/gfx/2d/Types.h.mozilla-bmo1504834-part1 firefox-78.0/gfx/2
  
    // The following values are OS and endian-independent synonyms.
    //
-diff -up firefox-78.0/gfx/skia/skia/third_party/skcms/skcms.cc.mozilla-bmo1504834-part1 firefox-78.0/gfx/skia/skia/third_party/skcms/skcms.cc
---- firefox-78.0/gfx/skia/skia/third_party/skcms/skcms.cc.mozilla-bmo1504834-part1	2020-06-17 04:18:58.000000000 +0200
-+++ firefox-78.0/gfx/skia/skia/third_party/skcms/skcms.cc	2020-06-25 16:54:02.993855444 +0200
-@@ -30,6 +30,8 @@
+   // TODO(aosmond): When everything blocking bug 1581828 has been resolved, we
+   // can make this use R8B8G8A8 and R8B8G8X8 for non-Windows platforms.
+   OS_RGBA = A8R8G8B8_UINT32,
+   OS_RGBX = X8R8G8B8_UINT32
+ };
+diff --git a/gfx/skia/skia/third_party/skcms/skcms.cc b/gfx/skia/skia/third_party/skcms/skcms.cc
+--- a/gfx/skia/skia/third_party/skcms/skcms.cc
++++ b/gfx/skia/skia/third_party/skcms/skcms.cc
+@@ -25,16 +25,18 @@
+         // it'd be a lot slower.  But we want all those headers included so we
+         // can use their features after runtime checks later.
+         #include <smmintrin.h>
+         #include <avxintrin.h>
+         #include <avx2intrin.h>
          #include <avx512fintrin.h>
          #include <avx512dqintrin.h>
      #endif
@@ -42,17 +71,27 @@ diff -up firefox-78.0/gfx/skia/skia/third_party/skcms/skcms.cc.mozilla-bmo150483
  #endif
  
  // sizeof(x) will return size_t, which is 32-bit on some machines and 64-bit on others.
-@@ -280,20 +282,28 @@ enum {
+ // We have better testing on 64-bit machines, so force 32-bit machines to behave like 64-bit.
+ //
+ // Please do not use sizeof() directly, and size_t only when required.
+ // (We have no way of enforcing these requests...)
+ #define SAFE_SIZEOF(x) ((uint64_t)sizeof(x))
+@@ -275,30 +277,38 @@ enum {
+     skcms_Signature_sf32 = 0x73663332,
+     // XYZ is also a PCS signature, so it's defined in skcms.h
+     // skcms_Signature_XYZ = 0x58595A20,
+ };
+ 
  static uint16_t read_big_u16(const uint8_t* ptr) {
      uint16_t be;
      memcpy(&be, ptr, sizeof(be));
 -#if defined(_MSC_VER)
--    return _byteswap_ushort(be);
 +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 +    return be;
- #else
++#else
 +    #if defined(_MSC_VER)
-+    return _byteswap_ushort(be);
+     return _byteswap_ushort(be);
+-#else
 +    #else
      return __builtin_bswap16(be);
 +    #endif
@@ -63,15 +102,20 @@ diff -up firefox-78.0/gfx/skia/skia/third_party/skcms/skcms.cc.mozilla-bmo150483
      uint32_t be;
      memcpy(&be, ptr, sizeof(be));
 -#if defined(_MSC_VER)
--    return _byteswap_ulong(be);
 +#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__
 +    return be;
- #else
++#else
 +    #if defined(_MSC_VER)
-+    return _byteswap_ulong(be);
+     return _byteswap_ulong(be);
+-#else
 +    #else
      return __builtin_bswap32(be);
 +    #endif
  #endif
  }
  
+ static int32_t read_big_i32(const uint8_t* ptr) {
+     return (int32_t)read_big_u32(ptr);
+ }
+ 
+ static float read_big_fixed(const uint8_t* ptr) {
diff --git a/SOURCES/mozilla-bmo1504834-part2.patch b/SOURCES/mozilla-bmo1504834-part2.patch
deleted file mode 100644
index e6e6aa5..0000000
--- a/SOURCES/mozilla-bmo1504834-part2.patch
+++ /dev/null
@@ -1,88 +0,0 @@
-# HG changeset patch
-# Parent  36563351309ddbc6c29559ba50a41d005f925abb
-Skia does not support big endian. The places to fix are too numerous and upstream (skia, not Mozilla)
-has no interest in maintaining big endian.
-So here we try to swizzle the input for skia, so that skia always works on LE, and when it comes
-out again, we transform back to BE.
-
-diff -r 36563351309d gfx/2d/ConvolutionFilter.cpp
---- a/gfx/2d/ConvolutionFilter.cpp	Mon Sep 09 17:59:28 2019 +0200
-+++ b/gfx/2d/ConvolutionFilter.cpp	Tue Sep 10 08:25:13 2019 +0200
-@@ -35,9 +35,38 @@
-   return true;
- }
- 
-+static void ByteSwapArray(uint8_t *u8Array, int32_t size) {
-+    uint32_t *array = reinterpret_cast<uint32_t*>(u8Array);
-+    for (int pxl = 0; pxl < size; ++pxl) {
-+        // Use an endian swap to move the bytes, i.e. BGRA -> ARGB.
-+        uint32_t rgba = array[pxl];
-+        array[pxl] = NativeEndian::swapToLittleEndian(rgba);
-+    }
-+}
-+
- void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
-                                              bool aHasAlpha) {
-+#if MOZ_BIG_ENDIAN
-+    int outputSize = mFilter->numValues();
-+
-+    // Input size isn't handed in, so we have to calculate it quickly
-+    int inputSize = 0;
-+    for (int xx = 0; xx < outputSize; ++xx) {
-+        // Get the filter that determines the current output pixel.
-+        int filterOffset, filterLength;
-+        mFilter->FilterForValue(xx, &filterOffset, &filterLength);
-+        inputSize = std::max(inputSize, filterOffset + filterLength);
-+    }
-+
-+    ByteSwapArray((uint8_t*)aSrc, inputSize);
-+#endif
-+
-   SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
-+
-+#if MOZ_BIG_ENDIAN
-+    ByteSwapArray((uint8_t*)aSrc, inputSize);
-+    ByteSwapArray(aDst, outputSize);
-+#endif
- }
- 
- void ConvolutionFilter::ConvolveVertically(uint8_t* const* aSrc, uint8_t* aDst,
-@@ -49,8 +78,26 @@
-   int32_t filterLength;
-   auto filterValues =
-       mFilter->FilterForValue(aRowIndex, &filterOffset, &filterLength);
-+
-+#if MOZ_BIG_ENDIAN
-+  for (int filterY = 0; filterY < filterLength; filterY++) {
-+      // Skia only knows LE, so we have to swizzle the input
-+    ByteSwapArray(aSrc[filterY], aRowSize);
-+  }
-+#endif
-+
-   SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
-                               aHasAlpha);
-+
-+#if MOZ_BIG_ENDIAN
-+  // After skia is finished, we swizzle back to BE, in case
-+  // the input is used again somewhere else
-+  for (int filterY = 0; filterY < filterLength; filterY++) {
-+    ByteSwapArray(aSrc[filterY], aRowSize);
-+  }
-+  // The destination array as well
-+  ByteSwapArray(aDst, aRowSize);
-+#endif
- }
- 
- /* ConvolutionFilter::ComputeResizeFactor is derived from Skia's
-diff -r 36563351309d gfx/skia/skia/include/core/SkPreConfig.h
---- a/gfx/skia/skia/include/core/SkPreConfig.h	Mon Sep 09 17:59:28 2019 +0200
-+++ b/gfx/skia/skia/include/core/SkPreConfig.h	Tue Sep 10 08:25:13 2019 +0200
-@@ -73,7 +73,7 @@
-       defined(__ppc__) || defined(__hppa) || \
-       defined(__PPC__) || defined(__PPC64__) || \
-       defined(_MIPSEB) || defined(__ARMEB__) || \
--      defined(__s390__) || \
-+      defined(__s390__) || defined(__s390x__) || \
-       (defined(__sh__) && defined(__BIG_ENDIAN__)) || \
-       (defined(__ia64) && defined(__BIG_ENDIAN__))
-          #define SK_CPU_BENDIAN
diff --git a/SOURCES/mozilla-bmo1504834-part3.patch b/SOURCES/mozilla-bmo1504834-part3.patch
index 1a498f8..d07702e 100644
--- a/SOURCES/mozilla-bmo1504834-part3.patch
+++ b/SOURCES/mozilla-bmo1504834-part3.patch
@@ -1,12 +1,17 @@
 # HG changeset patch
-# Parent  aecb4600e5da17443b224c79eee178c1d8e155e3
+# Parent  d1d66f7e4d0e7fd45e91e4fcee07555e72046d48
 For FF68, AntiAliasing of XULTexts seem to be broken on big endian (s390x). Text and icons of the sandwich-menu to the
 right of the address bar, as well as plugin-windows appears transparant, which usually means unreadable (white on white).
 
-diff -r aecb4600e5da gfx/skia/skia/include/private/SkNx.h
---- a/gfx/skia/skia/include/private/SkNx.h	Tue Aug 20 09:46:55 2019 +0200
-+++ b/gfx/skia/skia/include/private/SkNx.h	Mon Sep 09 10:04:06 2019 +0200
-@@ -238,7 +238,18 @@
+diff --git a/gfx/skia/skia/include/private/SkNx.h b/gfx/skia/skia/include/private/SkNx.h
+--- a/gfx/skia/skia/include/private/SkNx.h
++++ b/gfx/skia/skia/include/private/SkNx.h
+@@ -233,17 +233,28 @@ struct SkNx<1,T> {
+     AI SkNx operator<<(int bits) const { return fVal << bits; }
+     AI SkNx operator>>(int bits) const { return fVal >> bits; }
+ 
+     AI SkNx operator+(const SkNx& y) const { return fVal + y.fVal; }
+     AI SkNx operator-(const SkNx& y) const { return fVal - y.fVal; }
      AI SkNx operator*(const SkNx& y) const { return fVal * y.fVal; }
      AI SkNx operator/(const SkNx& y) const { return fVal / y.fVal; }
  
@@ -25,10 +30,20 @@ diff -r aecb4600e5da gfx/skia/skia/include/private/SkNx.h
      AI SkNx operator|(const SkNx& y) const { return FromBits(ToBits(fVal) | ToBits(y.fVal)); }
      AI SkNx operator^(const SkNx& y) const { return FromBits(ToBits(fVal) ^ ToBits(y.fVal)); }
  
-diff -r aecb4600e5da gfx/skia/skia/src/opts/SkBlitMask_opts.h
---- a/gfx/skia/skia/src/opts/SkBlitMask_opts.h	Tue Aug 20 09:46:55 2019 +0200
-+++ b/gfx/skia/skia/src/opts/SkBlitMask_opts.h	Mon Sep 09 10:04:06 2019 +0200
-@@ -203,7 +203,13 @@
+     AI SkNx operator==(const SkNx& y) const { return FromBits(fVal == y.fVal ? ~0 : 0); }
+     AI SkNx operator!=(const SkNx& y) const { return FromBits(fVal != y.fVal ? ~0 : 0); }
+     AI SkNx operator<=(const SkNx& y) const { return FromBits(fVal <= y.fVal ? ~0 : 0); }
+     AI SkNx operator>=(const SkNx& y) const { return FromBits(fVal >= y.fVal ? ~0 : 0); }
+     AI SkNx operator< (const SkNx& y) const { return FromBits(fVal <  y.fVal ? ~0 : 0); }
+diff --git a/gfx/skia/skia/src/opts/SkBlitMask_opts.h b/gfx/skia/skia/src/opts/SkBlitMask_opts.h
+--- a/gfx/skia/skia/src/opts/SkBlitMask_opts.h
++++ b/gfx/skia/skia/src/opts/SkBlitMask_opts.h
+@@ -198,17 +198,23 @@ namespace SK_OPTS_NS {
+                                        const SkAlpha* mask, size_t maskRB,
+                                        int w, int h) {
+         auto fn = [](const Sk4px& d, const Sk4px& aa) {
+             //   = (s + d(1-sa))aa + d(1-aa)
+             //   = s*aa + d(1-sa*aa)
              //   ~~~>
              // a = 1*aa + d(1-1*aa) = aa + d(1-aa)
              // c = 0*aa + d(1-1*aa) =      d(1-aa)
@@ -42,3 +57,8 @@ diff -r aecb4600e5da gfx/skia/skia/src/opts/SkBlitMask_opts.h
                   + d.approxMulDiv255(aa.inv());
          };
          while (h --> 0) {
+             Sk4px::MapDstAlpha(w, dst, mask, fn);
+             dst  +=  dstRB / sizeof(*dst);
+             mask += maskRB / sizeof(*mask);
+         }
+     }
diff --git a/SOURCES/mozilla-bmo1504834-part4.patch b/SOURCES/mozilla-bmo1504834-part4.patch
deleted file mode 100644
index 9d2ffc4..0000000
--- a/SOURCES/mozilla-bmo1504834-part4.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-# HG changeset patch
-# Parent  46ea866ca3acb8bb5e1709ceb799b9c94f591dec
-Problem description: Tab-titles that are too long to fit into a tab get faded out.
-                     On big endian this is broken and instead of fading out, the 
-                     tab gets white and the font transparent, leading to an unreadable
-                     tab-title
-Solution: This is not a real solution, but a hack. The real solution would have been
-          to byte-swap the correct buffer, but I could not find it.
-          So the next best thing is to deactivate the fading-effect. Now all tab-titles
-          are readable, albeit not as pretty to look at as they could be. 
-Side-effects: I have not yet found an unwanted side-effect.
-
-diff -r 46ea866ca3ac -r 6ef20eee3f8f gfx/2d/DrawTargetSkia.cpp
---- a/gfx/2d/DrawTargetSkia.cpp	Tue Oct 22 12:27:22 2019 +0200
-+++ b/gfx/2d/DrawTargetSkia.cpp	Thu Oct 31 09:11:56 2019 +0100
-@@ -1861,6 +1861,14 @@
-       SkCanvas::kPreserveLCDText_SaveLayerFlag |
-           (aCopyBackground ? SkCanvas::kInitWithPrevious_SaveLayerFlag : 0));
- 
-+#if MOZ_BIG_ENDIAN
-+  // Pushing a layer where an aMask is defined produces wrong output.
-+  // We _should_ endian swap the data, but I couldn't find a workable way to do so
-+  // Therefore I deactivate those layers in the meantime.
-+  // The result is: Tab-titles that are longer than the available space should be faded out.
-+  //                The fading doesn't work, so we deactivate the fading-effect here.
-+  if (!aMask)
-+#endif
-   mCanvas->saveLayer(saveRec);
- 
-   SetPermitSubpixelAA(aOpaque);
diff --git a/SOURCES/mozilla-bmo1554971.patch b/SOURCES/mozilla-bmo1554971.patch
deleted file mode 100644
index 9958150..0000000
--- a/SOURCES/mozilla-bmo1554971.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up firefox-91.0/toolkit/components/extensions/schemas/runtime.json.mozilla-bmo1554971 firefox-91.0/toolkit/components/extensions/schemas/runtime.json
---- firefox-91.0/toolkit/components/extensions/schemas/runtime.json.mozilla-bmo1554971	2021-07-29 17:20:08.523253193 +0200
-+++ firefox-91.0/toolkit/components/extensions/schemas/runtime.json	2021-07-29 17:21:23.517498581 +0200
-@@ -64,7 +64,7 @@
-       {
-         "id": "PlatformArch",
-         "type": "string",
--        "enum": ["aarch64", "arm", "ppc64", "s390x", "sparc64", "x86-32", "x86-64"],
-+        "enum": ["aarch64", "arm", "ppc64", "ppc64le", "s390x", "sparc64", "x86-32", "x86-64"],
-         "allowedContexts": ["content", "devtools"],
-         "description": "The machine's processor architecture."
-       },
diff --git a/SOURCES/mozilla-bmo1602730.patch b/SOURCES/mozilla-bmo1602730.patch
deleted file mode 100644
index c11f958..0000000
--- a/SOURCES/mozilla-bmo1602730.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff -r 6ef20eee3f8f gfx/layers/basic/BasicCompositor.cpp
---- a/gfx/layers/basic/BasicCompositor.cpp	Thu Oct 31 09:11:56 2019 +0100
-+++ b/gfx/layers/basic/BasicCompositor.cpp	Wed Dec 11 16:16:09 2019 +0100
-@@ -693,9 +693,13 @@
- 
-   RefPtr<SourceSurface> sourceMask;
-   Matrix maskTransform;
-+  // Setting an alpha-mask here breaks the URL-bar on big endian (s390x)
-+  // if the typed URL is too long for the textbox (automatic scrolling needed)
-+#if MOZ_LITTLE_ENDIAN
-   if (aTransform.Is2D()) {
-     SetupMask(aEffectChain, dest, offset, sourceMask, maskTransform);
-   }
-+#endif
- 
-   CompositionOp blendMode = CompositionOp::OP_OVER;
-   if (Effect* effect =
-diff -r 6ef20eee3f8f gfx/layers/composite/CompositableHost.cpp
---- a/gfx/layers/composite/CompositableHost.cpp	Thu Oct 31 09:11:56 2019 +0100
-+++ b/gfx/layers/composite/CompositableHost.cpp	Wed Dec 11 16:16:09 2019 +0100
-@@ -91,6 +91,7 @@
-   }
-   MOZ_ASSERT(source);
- 
-+  // Alternatively: Comment out these lines where the alpha-mask is set
-   RefPtr<EffectMask> effect =
-       new EffectMask(source, source->GetSize(), aTransform);
-   aEffects.mSecondaryEffects[EffectTypes::MASK] = effect;
diff --git a/SOURCES/mozilla-bmo1626236.patch b/SOURCES/mozilla-bmo1626236.patch
deleted file mode 100644
index 32e3742..0000000
--- a/SOURCES/mozilla-bmo1626236.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-# HG changeset patch
-# User msirringhaus@suse.de
-# Date 1582805876 -3600
-#      Thu Feb 27 13:17:56 2020 +0100
-# Node ID cc3d09abea31068e57f1ab918782f9f86fc6a158
-# Parent  9cd90914846f667f18babc491a74c164ae5d6e9f
-imported patch decoder_workaround.patch
-
-diff -r 9cd90914846f image/decoders/nsGIFDecoder2.cpp
---- a/image/decoders/nsGIFDecoder2.cpp	Thu Feb 27 12:57:14 2020 +0100
-+++ b/image/decoders/nsGIFDecoder2.cpp	Fri Mar 27 13:06:18 2020 +0100
-@@ -422,6 +422,9 @@
-   MOZ_ASSERT(mSwizzleFn);
-   uint8_t* data = reinterpret_cast<uint8_t*>(aColormap);
-   mSwizzleFn(data, data, aColors);
-+#if MOZ_BIG_ENDIAN()
-+  SwizzleRow(SurfaceFormat::A8R8G8B8, SurfaceFormat::B8G8R8A8)(data, data, aColors);
-+#endif
- }
- 
- LexerResult nsGIFDecoder2::DoDecode(SourceBufferIterator& aIterator,
-diff -r 9cd90914846f image/decoders/nsJPEGDecoder.cpp
---- a/image/decoders/nsJPEGDecoder.cpp	Thu Feb 27 12:57:14 2020 +0100
-+++ b/image/decoders/nsJPEGDecoder.cpp	Fri Mar 27 13:06:18 2020 +0100
-@@ -263,6 +263,9 @@
-         case JCS_YCbCr:
-           // By default, we will output directly to BGRA. If we need to apply
-           // special color transforms, this may change.
-+#if MOZ_BIG_ENDIAN()
-+          mInfo.out_color_space = MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB;
-+#else
-           switch (SurfaceFormat::OS_RGBX) {
-             case SurfaceFormat::B8G8R8X8:
-               mInfo.out_color_space = JCS_EXT_BGRX;
-@@ -277,6 +280,7 @@
-               mState = JPEG_ERROR;
-               return Transition::TerminateFailure();
-           }
-+#endif
-           break;
-         case JCS_CMYK:
-         case JCS_YCCK:
-diff -r 9cd90914846f image/decoders/nsPNGDecoder.cpp
---- a/image/decoders/nsPNGDecoder.cpp	Thu Feb 27 12:57:14 2020 +0100
-+++ b/image/decoders/nsPNGDecoder.cpp	Fri Mar 27 13:06:18 2020 +0100
-@@ -361,7 +361,7 @@
-                                    IResumable* aOnResume) {
-   MOZ_ASSERT(!HasError(), "Shouldn't call DoDecode after error!");
- 
--  return mLexer.Lex(aIterator, aOnResume,
-+  LexerResult res = mLexer.Lex(aIterator, aOnResume,
-                     [=](State aState, const char* aData, size_t aLength) {
-                       switch (aState) {
-                         case State::PNG_DATA:
-@@ -371,6 +371,14 @@
-                       }
-                       MOZ_CRASH("Unknown State");
-                     });
-+
-+#if MOZ_BIG_ENDIAN()
-+  if(res.is<TerminalState>() && res.as<TerminalState>() == TerminalState::SUCCESS) {
-+      NativeEndian::swapToLittleEndianInPlace<uint32_t>((uint32_t*)(mImageData), mImageDataLength / 4);
-+  }
-+#endif
-+
-+  return res;
- }
- 
- LexerTransition<nsPNGDecoder::State> nsPNGDecoder::ReadPNGData(
-diff -r 9cd90914846f image/decoders/nsWebPDecoder.cpp
---- a/image/decoders/nsWebPDecoder.cpp	Thu Feb 27 12:57:14 2020 +0100
-+++ b/image/decoders/nsWebPDecoder.cpp	Fri Mar 27 13:06:18 2020 +0100
-@@ -237,7 +237,12 @@
-   // WebP doesn't guarantee that the alpha generated matches the hint in the
-   // header, so we always need to claim the input is BGRA. If the output is
-   // BGRX, swizzling will mask off the alpha channel.
-+#if MOZ_BIG_ENDIAN()
-+  mBuffer.colorspace = MODE_ARGB;
-+  SurfaceFormat inFormat = mFormat;
-+#else
-   SurfaceFormat inFormat = SurfaceFormat::OS_RGBA;
-+#endif
- 
-   SurfacePipeFlags pipeFlags = SurfacePipeFlags();
-   if (mFormat == SurfaceFormat::OS_RGBA &&
-
diff --git a/SOURCES/mozilla-bmo849632.patch b/SOURCES/mozilla-bmo849632.patch
index 177fdc3..9de64b9 100644
--- a/SOURCES/mozilla-bmo849632.patch
+++ b/SOURCES/mozilla-bmo849632.patch
@@ -1,16 +1,24 @@
+# HG changeset patch
+# Parent  3de59fe1b8708c01e134ce698c4232b8a854f617
 Problem:  webGL sites are displayed in the wrong color (usually blue-ish)
 Solution: Problem is with skia once again. Output of webgl seems endian-correct, but skia only
           knows how to deal with little endian.
           So we swizzle the output of webgl after reading it from readpixels()
 Note:     This does not fix all webGL sites, but is a step in the right direction
-diff -r 6b017d3e9733 gfx/gl/GLContext.h
---- a/gfx/gl/GLContext.h    Mon Sep 09 10:04:05 2019 +0200
-+++ b/gfx/gl/GLContext.h    Wed Nov 13 17:13:04 2019 +0100
-@@ -1551,6 +1551,13 @@
+
+diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h
+--- a/gfx/gl/GLContext.h
++++ b/gfx/gl/GLContext.h
+@@ -1548,16 +1548,23 @@ class GLContext : public GenericAtomicRe
+     AFTER_GL_CALL;
+   }
+ 
+   void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+                        GLenum format, GLenum type, GLvoid* pixels) {
      BEFORE_GL_CALL;
      mSymbols.fReadPixels(x, y, width, height, format, type, pixels);
      OnSyncCall();
-+#if MOZ_BIG_ENDIAN
++#if MOZ_BIG_ENDIAN()
 +    uint8_t* itr = (uint8_t*)pixels;
 +    for (GLsizei i = 0; i < width * height; i++) {
 +      NativeEndian::swapToLittleEndianInPlace((uint32_t*)itr, 1);
@@ -20,4 +28,8 @@ diff -r 6b017d3e9733 gfx/gl/GLContext.h
      AFTER_GL_CALL;
      mHeavyGLCallsSinceLastFlush = true;
    }
-
+ 
+   void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+                    GLenum format, GLenum type, GLvoid* pixels);
+ 
+  public:
diff --git a/SOURCES/mozilla-bmo998749.patch b/SOURCES/mozilla-bmo998749.patch
index 4ddde4c..50e22b5 100644
--- a/SOURCES/mozilla-bmo998749.patch
+++ b/SOURCES/mozilla-bmo998749.patch
@@ -27,4 +27,3 @@ diff -r 506857dace0a -r 34676feac1a5 gfx/2d/FilterProcessing.h
  
  class FilterProcessing {
   public:
-
diff --git a/SOURCES/mozilla-build-arm.patch b/SOURCES/mozilla-build-arm.patch
new file mode 100644
index 0000000..e390a28
--- /dev/null
+++ b/SOURCES/mozilla-build-arm.patch
@@ -0,0 +1,14 @@
+diff -up firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h.arm firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h
+--- firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h.arm	2017-03-03 13:53:52.480754536 +0100
++++ firefox-52.0/gfx/skia/skia/include/core/SkPreConfig.h	2017-03-03 13:56:01.476018102 +0100
+@@ -203,6 +203,10 @@
+     #define SK_ARM_HAS_CRC32
+ #endif
+ 
++#if defined(__aarch64__)
++    #undef SK_ARM_HAS_NEON
++#endif
++
+ //////////////////////////////////////////////////////////////////////
+ 
+ #if !defined(SKIA_IMPLEMENTATION)
diff --git a/SOURCES/mozilla-s390-context.patch b/SOURCES/mozilla-s390-context.patch
deleted file mode 100644
index 55bd7a8..0000000
--- a/SOURCES/mozilla-s390-context.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-# HG changeset patch
-# User msirringhaus@suse.de
-# Date 1558452408 -7200
-#      Tue May 21 17:26:48 2019 +0200
-# Node ID 602e92722e765a3c238d3b96b26c0c8063b5eeb4
-# Parent  a3cc550d25e3a04d906f516928cbcbe50efd585e
-[mq]: mozilla-s390-context.patch
-
-diff -r a3cc550d25e3 -r 602e92722e76 js/src/wasm/WasmSignalHandlers.cpp
---- a/js/src/wasm/WasmSignalHandlers.cpp	Tue May 21 17:22:06 2019 +0200
-+++ b/js/src/wasm/WasmSignalHandlers.cpp	Tue May 21 17:26:48 2019 +0200
-@@ -154,6 +154,10 @@
- #    define R01_sig(p) ((p)->uc_mcontext.gp_regs[1])
- #    define R32_sig(p) ((p)->uc_mcontext.gp_regs[32])
- #  endif
-+#  if defined(__linux__) && defined(__s390x__)
-+#    define GR_sig(p,x) ((p)->uc_mcontext.gregs[x])
-+#    define PSWa_sig(p) ((p)->uc_mcontext.psw.addr)
-+#  endif
- #elif defined(__NetBSD__)
- #  define EIP_sig(p) ((p)->uc_mcontext.__gregs[_REG_EIP])
- #  define EBP_sig(p) ((p)->uc_mcontext.__gregs[_REG_EBP])
-@@ -385,8 +389,13 @@
- #  define PC_sig(p) R32_sig(p)
- #  define SP_sig(p) R01_sig(p)
- #  define FP_sig(p) R01_sig(p)
-+#elif defined(__s390x__)
-+# define PC_sig(p) PSWa_sig(p)
-+# define SP_sig(p) GR_sig(p, 15)
-+# define FP_sig(p) GR_sig(p, 11)
- #endif
- 
-+
- static void SetContextPC(CONTEXT* context, uint8_t* pc) {
- #ifdef PC_sig
-   *reinterpret_cast<uint8_t**>(&PC_sig(context)) = pc;
diff --git a/SOURCES/mozilla-s390x-skia-gradient.patch b/SOURCES/mozilla-s390x-skia-gradient.patch
new file mode 100644
index 0000000..a5e5d95
--- /dev/null
+++ b/SOURCES/mozilla-s390x-skia-gradient.patch
@@ -0,0 +1,51 @@
+# HG changeset patch
+# Parent  acf59ea86dd1d878b43920832093f082dcfc61c0
+
+diff -r acf59ea86dd1 gfx/skia/skia/src/shaders/gradients/Sk4fLinearGradient.cpp
+--- a/gfx/skia/skia/src/shaders/gradients/Sk4fLinearGradient.cpp	Mon Mar 09 08:26:10 2020 +0100
++++ b/gfx/skia/skia/src/shaders/gradients/Sk4fLinearGradient.cpp	Fri Mar 27 13:30:28 2020 +0100
+@@ -7,7 +7,7 @@
+ 
+ #include "include/core/SkPaint.h"
+ #include "src/shaders/gradients/Sk4fLinearGradient.h"
+-
++#include "src/core/SkEndian.h"
+ #include <cmath>
+ #include <utility>
+ 
+@@ -28,6 +28,9 @@
+ 
+     while (n >= 4) {
+         DstTraits<premul>::store4x(c0, c1, c2, c3, dst, bias0, bias1);
++#ifdef SK_CPU_BENDIAN
++        SkEndianSwap32s(dst, 4);
++#endif
+         dst += 4;
+ 
+         c0 = c0 + dc4;
+@@ -37,12 +40,23 @@
+         n -= 4;
+     }
+     if (n & 2) {
+-        DstTraits<premul>::store(c0, dst++, bias0);
+-        DstTraits<premul>::store(c1, dst++, bias1);
++        DstTraits<premul>::store(c0, dst, bias0);
++#ifdef SK_CPU_BENDIAN
++        *dst = SkEndianSwap32(*dst);
++#endif
++        ++dst;
++        DstTraits<premul>::store(c1, dst, bias1);
++#ifdef SK_CPU_BENDIAN
++        *dst = SkEndianSwap32(*dst);
++#endif
++        ++dst;
+         c0 = c0 + dc2;
+     }
+     if (n & 1) {
+         DstTraits<premul>::store(c0, dst, bias0);
++#ifdef SK_CPU_BENDIAN
++        *dst = SkEndianSwap32(*dst);
++#endif
+     }
+ }
+ 
diff --git a/SOURCES/node-stdout-nonblocking-wrapper b/SOURCES/node-stdout-nonblocking-wrapper
index e36d134..7dfb513 100755
--- a/SOURCES/node-stdout-nonblocking-wrapper
+++ b/SOURCES/node-stdout-nonblocking-wrapper
@@ -1,3 +1,2 @@
 #!/bin/sh
-#exec /usr/bin/node "$@" 2>&1 | cat -
-exec $MOZ_NODEJS "$@" 2>&1 | cat -
+exec node "$@" 2>&1 | cat -
diff --git a/SOURCES/one_swizzle_to_rule_them_all.patch b/SOURCES/one_swizzle_to_rule_them_all.patch
new file mode 100644
index 0000000..bb37560
--- /dev/null
+++ b/SOURCES/one_swizzle_to_rule_them_all.patch
@@ -0,0 +1,34 @@
+# HG changeset patch
+# User M. Sirringhaus <msirringhaus@suse.de>
+# Date 1645518286 -3600
+#      Tue Feb 22 09:24:46 2022 +0100
+# Node ID 494640792b4677f6462e95b90a54a4e22aeb738b
+# Parent  81832d035e101471dcf52dd91de287268add7a91
+imported patch one_swizzle_to_rule_them_all.patch
+
+Index: firefox-102.0/gfx/webrender_bindings/RenderCompositorSWGL.cpp
+===================================================================
+--- firefox-102.0.orig/gfx/webrender_bindings/RenderCompositorSWGL.cpp
++++ firefox-102.0/gfx/webrender_bindings/RenderCompositorSWGL.cpp
+@@ -7,6 +7,7 @@
+ #include "RenderCompositorSWGL.h"
+ 
+ #include "mozilla/gfx/Logging.h"
++#include "mozilla/gfx/Swizzle.h"
+ #include "mozilla/widget/CompositorWidget.h"
+ 
+ #ifdef MOZ_WIDGET_GTK
+@@ -235,6 +237,13 @@ void RenderCompositorSWGL::CommitMappedB
+   }
+   mDT->Flush();
+ 
++#if MOZ_BIG_ENDIAN()
++  // One swizzle to rule them all.
++  gfx::SwizzleData(mMappedData, mMappedStride, gfx::SurfaceFormat::B8G8R8A8,
++                   mMappedData, mMappedStride, gfx::SurfaceFormat::A8R8G8B8,
++                   mDT->GetSize());
++#endif
++
+   // Done with the DT. Hand it back to the widget and clear out any trace of it.
+   mWidget->EndRemoteDrawingInRegion(mDT, mDirtyRegion);
+   mDirtyRegion.SetEmpty();
diff --git a/SOURCES/pgo.patch b/SOURCES/pgo.patch
new file mode 100644
index 0000000..eec103c
--- /dev/null
+++ b/SOURCES/pgo.patch
@@ -0,0 +1,115 @@
+diff -up firefox-99.0/build/moz.configure/lto-pgo.configure.pgo firefox-99.0/build/moz.configure/lto-pgo.configure
+--- firefox-99.0/build/moz.configure/lto-pgo.configure.pgo	2022-03-31 01:24:38.000000000 +0200
++++ firefox-99.0/build/moz.configure/lto-pgo.configure	2022-04-04 10:15:45.387694143 +0200
+@@ -247,8 +247,8 @@ def lto(
+             cflags.append("-flto")
+             ldflags.append("-flto")
+         else:
+-            cflags.append("-flto=thin")
+-            ldflags.append("-flto=thin")
++            cflags.append("-flto")
++            ldflags.append("-flto")
+ 
+         if target.os == "Android" and value == "cross":
+             # Work around https://github.com/rust-lang/rust/issues/90088
+@@ -264,7 +264,7 @@ def lto(
+         if value == "full":
+             cflags.append("-flto")
+         else:
+-            cflags.append("-flto=thin")
++            cflags.append("-flto")
+         # With clang-cl, -flto can only be used with -c or -fuse-ld=lld.
+         # AC_TRY_LINKs during configure don't have -c, so pass -fuse-ld=lld.
+         cflags.append("-fuse-ld=lld")
+diff -up firefox-99.0/build/pgo/profileserver.py.pgo firefox-99.0/build/pgo/profileserver.py
+--- firefox-99.0/build/pgo/profileserver.py.pgo	2022-03-31 01:24:38.000000000 +0200
++++ firefox-99.0/build/pgo/profileserver.py	2022-04-04 10:15:45.387694143 +0200
+@@ -11,7 +11,7 @@ import glob
+ import subprocess
+ 
+ import mozcrash
+-from mozbuild.base import MozbuildObject, BinaryNotFoundException
++from mozbuild.base import MozbuildObject, BinaryNotFoundException, BuildEnvironmentNotFoundException
+ from mozfile import TemporaryDirectory
+ from mozhttpd import MozHttpd
+ from mozprofile import FirefoxProfile, Preferences
+@@ -87,9 +87,22 @@ if __name__ == "__main__":
+     locations = ServerLocations()
+     locations.add_host(host="127.0.0.1", port=PORT, options="primary,privileged")
+ 
+-    old_profraw_files = glob.glob("*.profraw")
+-    for f in old_profraw_files:
+-        os.remove(f)
++    using_gcc = False
++    try:
++        if build.config_environment.substs.get('CC_TYPE') == 'gcc':
++            using_gcc = True
++    except BuildEnvironmentNotFoundException:
++        pass
++
++    if using_gcc:
++        for dirpath, _, filenames in os.walk('.'):
++            for f in filenames:
++                if f.endswith('.gcda'):
++                    os.remove(os.path.join(dirpath, f))
++    else:
++        old_profraw_files = glob.glob('*.profraw')
++        for f in old_profraw_files:
++            os.remove(f)
+ 
+     with TemporaryDirectory() as profilePath:
+         # TODO: refactor this into mozprofile
+@@ -212,6 +225,10 @@ if __name__ == "__main__":
+             print("Firefox exited successfully, but produced a crashreport")
+             sys.exit(1)
+ 
++        print('Copying profile data....')
++        os.system('pwd');
++        os.system('tar cf profdata.tar.gz `find . -name "*.gcda"`; cd ..; tar xf instrumented/profdata.tar.gz;');
++
+         llvm_profdata = env.get("LLVM_PROFDATA")
+         if llvm_profdata:
+             profraw_files = glob.glob("*.profraw")
+diff -up firefox-99.0/build/unix/mozconfig.unix.pgo firefox-99.0/build/unix/mozconfig.unix
+--- firefox-99.0/build/unix/mozconfig.unix.pgo	2022-03-31 01:24:38.000000000 +0200
++++ firefox-99.0/build/unix/mozconfig.unix	2022-04-04 10:15:45.387694143 +0200
+@@ -4,6 +4,15 @@ if [ -n "$FORCE_GCC" ]; then
+     CC="$MOZ_FETCHES_DIR/gcc/bin/gcc"
+     CXX="$MOZ_FETCHES_DIR/gcc/bin/g++"
+ 
++    if [ -n "$MOZ_PGO" ]; then
++        if [ -z "$USE_ARTIFACT" ]; then
++            ac_add_options --enable-lto
++        fi
++        export AR="$topsrcdir/gcc/bin/gcc-ar"
++        export NM="$topsrcdir/gcc/bin/gcc-nm"
++        export RANLIB="$topsrcdir/gcc/bin/gcc-ranlib"
++    fi
++
+     # We want to make sure we use binutils and other binaries in the tooltool
+     # package.
+     mk_add_options "export PATH=$MOZ_FETCHES_DIR/gcc/bin:$PATH"
+diff -up firefox-99.0/extensions/spellcheck/src/moz.build.pgo firefox-99.0/extensions/spellcheck/src/moz.build
+--- firefox-99.0/extensions/spellcheck/src/moz.build.pgo	2022-03-31 01:24:50.000000000 +0200
++++ firefox-99.0/extensions/spellcheck/src/moz.build	2022-04-04 10:15:45.387694143 +0200
+@@ -28,3 +28,5 @@ EXPORTS.mozilla += [
+     "mozInlineSpellChecker.h",
+     "mozSpellChecker.h",
+ ]
++
++CXXFLAGS += ['-fno-devirtualize']
+diff -up firefox-99.0/toolkit/components/terminator/nsTerminator.cpp.pgo firefox-99.0/toolkit/components/terminator/nsTerminator.cpp
+--- firefox-99.0/toolkit/components/terminator/nsTerminator.cpp.pgo	2022-04-04 10:15:45.387694143 +0200
++++ firefox-99.0/toolkit/components/terminator/nsTerminator.cpp	2022-04-04 10:19:07.022239556 +0200
+@@ -466,6 +466,11 @@ void nsTerminator::StartWatchdog() {
+   }
+ #endif
+ 
++  // Disable watchdog for PGO train builds - writting profile information at
++  // exit may take time and it is better to make build hang rather than
++  // silently produce poorly performing binary.
++  crashAfterMS = INT32_MAX;
++
+   UniquePtr<Options> options(new Options());
+   // crashAfterTicks is guaranteed to be > 0 as
+   // crashAfterMS >= ADDITIONAL_WAIT_BEFORE_CRASH_MS >> HEARTBEAT_INTERVAL_MS
diff --git a/SOURCES/print-error-reftest b/SOURCES/print-error-reftest
new file mode 100755
index 0000000..7a58c1c
--- /dev/null
+++ b/SOURCES/print-error-reftest
@@ -0,0 +1,13 @@
+#!/usr/bin/bash
+# Print reftest failures and compose them to html
+
+TEST_DIR="$1"
+TEST_FLAVOUR="$2"
+OUTPUT_FILE="failures-reftest$TEST_FLAVOUR.html"
+
+grep --text -e "REFTEST TEST-UNEXPECTED-PASS" -e "REFTEST TEST-UNEXPECTED-FAIL" -e "IMAGE 1 (TEST):" -e "IMAGE 2 (REFERENCE):" $TEST_DIR/reftest$TEST_FLAVOUR 2>&1 > $OUTPUT_FILE
+sed -i '/REFTEST   IMAGE 1/a ">' $OUTPUT_FILE
+sed -i '/REFTEST   IMAGE 2/a "><BR><BR>' $OUTPUT_FILE
+sed -i '/REFTEST TEST/a <BR>' $OUTPUT_FILE
+sed -i -e 's/^REFTEST   IMAGE 1 (TEST): /<img border=2 src="/' $OUTPUT_FILE
+sed -i -e 's/^REFTEST   IMAGE 2 (REFERENCE): /<img border=2 src="/' $OUTPUT_FILE
diff --git a/SOURCES/print-errors b/SOURCES/print-errors
new file mode 100755
index 0000000..0d66169
--- /dev/null
+++ b/SOURCES/print-errors
@@ -0,0 +1,9 @@
+#!/usr/bin/bash
+# Print failed tests
+
+TEST_DIR=$1
+TEST_FLAVOUR=$2
+
+grep "TEST-UNEXPECTED-FAIL" $TEST_DIR/mochitest$TEST_FLAVOUR 2>&1 > failures-mochitest$TEST_FLAVOUR.txt
+grep --text -e "  FAIL " -e "  TIMEOUT " $TEST_DIR/xpcshell$TEST_FLAVOUR 2>&1 > failures-xpcshell$TEST_FLAVOUR.txt
+grep --text -e "REFTEST TEST-UNEXPECTED-PASS" -e "REFTEST TEST-UNEXPECTED-FAIL" $TEST_DIR/reftest$TEST_FLAVOUR 2>&1 > failures-reftest$TEST_FLAVOUR.txt
diff --git a/SOURCES/print_failures b/SOURCES/print_failures
new file mode 100755
index 0000000..bc92b0c
--- /dev/null
+++ b/SOURCES/print_failures
@@ -0,0 +1,9 @@
+#!/usr/bin/bash
+# Analyze and print test failures
+
+export TEST_DIR="test_results"
+
+#./print-errors $TEST_DIR ""
+./print-errors $TEST_DIR "-wr"
+#./print-error-reftest $TEST_DIR ""
+./print-error-reftest $TEST_DIR "-wr"
diff --git a/SOURCES/print_results b/SOURCES/print_results
new file mode 100755
index 0000000..d0b1307
--- /dev/null
+++ b/SOURCES/print_results
@@ -0,0 +1,10 @@
+#!/usr/bin/bash
+# Analyze and print general test results
+
+export TEST_DIR="test_results"
+
+echo "Test results"
+#echo "Basic compositor"
+#./psummary $TEST_DIR ""
+echo "WebRender"
+./psummary $TEST_DIR "-wr"
diff --git a/SOURCES/psummary b/SOURCES/psummary
new file mode 100755
index 0000000..f64fc8f
--- /dev/null
+++ b/SOURCES/psummary
@@ -0,0 +1,23 @@
+#!/usr/bin/bash
+# Analyze and print specialized (basic/webrender) test results
+
+TEST_DIR=$1
+TEST_FLAVOUR=$2
+
+MPASS=`grep "TEST_END: Test OK" $TEST_DIR/mochitest$TEST_FLAVOUR | wc -l`
+MERR=`grep "TEST_END: Test ERROR" $TEST_DIR/mochitest$TEST_FLAVOUR | wc -l`
+MUNEX=`grep "TEST-UNEXPECTED-FAIL" $TEST_DIR/mochitest$TEST_FLAVOUR | wc  -l`
+echo "Mochitest   PASSED: $MPASS FAILED: $MERR UNEXPECTED-FAILURES: $MUNEX"
+
+XPCPASS=`grep --text "Expected results:" $TEST_DIR/xpcshell$TEST_FLAVOUR | cut -d ' ' -f 3`
+XPCFAIL=`grep --text "Unexpected results:" $TEST_DIR/xpcshell$TEST_FLAVOUR | cut -d ' ' -f 3`
+echo "XPCShell:   PASSED: $XPCPASS FAILED: $XPCFAIL"
+
+CRPASS=`grep "REFTEST INFO | Successful:" $TEST_DIR/crashtest$TEST_FLAVOUR | cut -d ' ' -f 5`
+CRFAIL=`grep "^REFTEST INFO | Unexpected:" $TEST_DIR/crashtest$TEST_FLAVOUR | cut -d ' ' -f 5`
+echo "Crashtest:  PASSED: $CRPASS FAILED: $CRFAIL"
+
+RFPASS=`grep --text "REFTEST INFO | Successful:" $TEST_DIR/reftest$TEST_FLAVOUR | cut -d ' ' -f 5`
+RFUN=`grep --text "^REFTEST INFO | Unexpected:" $TEST_DIR/reftest$TEST_FLAVOUR | cut -d ' ' -f 5`
+RFKNOWN=`grep --text "REFTEST INFO | Known problems:" $TEST_DIR/reftest$TEST_FLAVOUR | cut -d ' ' -f 6`
+echo "Reftest:    PASSED: $RFPASS FAILED: $RFUN Known issues: $RFKNOWN"
diff --git a/SOURCES/rhbz-1219542-s390-build.patch b/SOURCES/rhbz-1219542-s390-build.patch
new file mode 100644
index 0000000..f94e43a
--- /dev/null
+++ b/SOURCES/rhbz-1219542-s390-build.patch
@@ -0,0 +1,23 @@
+diff -up firefox-55.0/js/src/old-configure.in.rhbz-1219542-s390 firefox-55.0/js/src/old-configure.in
+--- firefox-55.0/js/src/old-configure.in.rhbz-1219542-s390	2017-07-31 18:20:48.000000000 +0200
++++ firefox-55.0/js/src/old-configure.in	2017-08-02 14:31:32.190243669 +0200
+@@ -541,7 +541,7 @@ case "$host" in
+ 
+ *-linux*|*-kfreebsd*-gnu|*-gnu*)
+     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
+-    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
++    HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O1}"
+     ;;
+ 
+ *)
+@@ -617,8 +617,8 @@ case "$target" in
+ 
+ *-*linux*)
+     if test "$GNU_CC" -o "$GNU_CXX"; then
+-        MOZ_PGO_OPTIMIZE_FLAGS="-O3"
+-        MOZ_OPTIMIZE_FLAGS="-O3"
++        MOZ_PGO_OPTIMIZE_FLAGS="-O1"
++        MOZ_OPTIMIZE_FLAGS="-O1"
+         if test -z "$CLANG_CC"; then
+            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
+         fi
diff --git a/SOURCES/rhbz-1354671.patch b/SOURCES/rhbz-1354671.patch
new file mode 100644
index 0000000..b6e8bbd
--- /dev/null
+++ b/SOURCES/rhbz-1354671.patch
@@ -0,0 +1,12 @@
+diff -up firefox-70.0/layout/base/PresShell.h.1354671 firefox-70.0/layout/base/PresShell.h
+--- firefox-70.0/layout/base/PresShell.h.1354671	2019-10-22 12:33:12.987775587 +0200
++++ firefox-70.0/layout/base/PresShell.h	2019-10-22 12:36:39.999366086 +0200
+@@ -257,7 +257,7 @@ class PresShell final : public nsStubDoc
+    * to the same aSize value.  AllocateFrame is infallible and will abort
+    * on out-of-memory.
+    */
+-  void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) {
++  void* __attribute__((optimize("no-lifetime-dse"))) AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) {
+ #define FRAME_ID(classname, ...)                                  \
+   static_assert(size_t(nsQueryFrame::FrameIID::classname##_id) == \
+                     size_t(eArenaObjectID_##classname),           \
diff --git a/SOURCES/run-tests-wayland b/SOURCES/run-tests-wayland
new file mode 100755
index 0000000..95ee6f6
--- /dev/null
+++ b/SOURCES/run-tests-wayland
@@ -0,0 +1,80 @@
+#!/usr/bin/bash
+# usage: run-tests-wayland [test flavour]
+
+set -x
+
+RUN_XPCSHELL_TEST=1
+RUN_REFTEST=1
+RUN_MOCHITEST=1
+RUN_CRASHTEST=1
+
+while (( "$#" )); do
+  SELECTED_TEST=$1
+  if [ "$SELECTED_TEST" = "xpcshell" ] ; then
+    RUN_XPCSHELL_TEST=1
+  elif [ "$SELECTED_TEST" = "reftest" ] ; then
+    RUN_REFTEST=1
+  elif [ "$SELECTED_TEST" = "mochitest" ] ; then
+    RUN_MOCHITEST=1
+  elif [ "$SELECTED_TEST" = "crashtest" ] ; then
+    RUN_CRASHTEST=1
+  fi
+  shift
+done
+
+export MACH_USE_SYSTEM_PYTHON=1
+export MOZ_NODE_PATH=/usr/bin/node
+
+MOCHITEST_PARAMS="--timeout 1 --chunk-by-dir 4"
+TEST_DIR="test_results"
+mkdir $TEST_DIR
+
+env | grep "DISPLAY"
+
+# Fix for system nss
+ln -s /usr/bin/certutil objdir/dist/bin/certutil
+ln -s /usr/bin/pk12util objdir/dist/bin/pk12util
+
+NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
+
+export MOZ_ENABLE_WAYLAND=1
+
+if [ $RUN_XPCSHELL_TEST -ne 0 ] ; then
+#  ./mach xpcshell-test 2>&1 | cat - | tee $TEST_DIR/xpcshell
+  ./mach xpcshell-test --enable-webrender 2>&1 | cat - | tee $TEST_DIR/xpcshell-wr
+  sleep 60
+fi
+
+# Basic render testing
+export TEST_PARAMS="--setpref reftest.ignoreWindowSize=true --setpref widget.wayland.test-workarounds.enabled=true"
+#export TEST_FLAVOUR=""
+#if [ $RUN_REFTEST -ne 0 ] ; then
+#  ./mach reftest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
+#fi
+#if [ $RUN_CRASHTEST -ne 0 ] ; then
+#  ./mach crashtest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
+#fi
+#if [ $RUN_MOCHITEST -ne 0 ] ; then
+#  ./mach mochitest --marionette localhost:$(($(($RANDOM))+2000)) $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
+#fi
+
+# WebRender testing
+export TEST_PARAMS="--enable-webrender $TEST_PARAMS"
+export TEST_FLAVOUR="-wr"
+# Use dom/base/test or dom/base/test/chrome for short version
+export MOCHITEST_DIR='dom'
+if [ $RUN_REFTEST -ne 0 ] ; then
+  ./mach reftest $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
+  sleep 60
+fi
+if [ $RUN_CRASHTEST -ne 0 ] ; then
+  ./mach crashtest $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
+  sleep 60
+fi
+if [ $RUN_MOCHITEST -ne 0 ] ; then
+  ./mach mochitest $MOCHITEST_DIR $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
+  sleep 60
+fi
+
+rm -f  objdir/dist/bin/certutil
+rm -f  objdir/dist/bin/pk12util
diff --git a/SOURCES/run-tests-x11 b/SOURCES/run-tests-x11
new file mode 100755
index 0000000..1d4a1c0
--- /dev/null
+++ b/SOURCES/run-tests-x11
@@ -0,0 +1,39 @@
+#!/usr/bin/bash
+set -x
+
+export MACH_USE_SYSTEM_PYTHON=1
+export MOZ_NODE_PATH=/usr/bin/node
+export X_PARAMS="-screen 0 1600x1200x24"
+export MOCHITEST_PARAMS="--timeout 1 --chunk-by-dir 4"
+export TEST_DIR="test_results"
+
+# Fix for system nss
+ln -s /usr/bin/certutil objdir/dist/bin/certutil
+ln -s /usr/bin/pk12util objdir/dist/bin/pk12util
+
+NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
+
+# Basic render testing
+export TEST_PARAMS=""
+export TEST_FLAVOUR=""
+#xvfb-run -s "$X_PARAMS" -n 91 ./mach xpcshell-test --sequential $TEST_PARAMS 2>&1 | cat - | tee $TEST_DIR/xpcshell
+#xvfb-run -s "$X_PARAMS" -n 92 ./mach reftest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
+#xvfb-run -s "$X_PARAMS" -n 93 ./mach crashtest --marionette localhost:$(($(($RANDOM))+2000)) $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
+#xvfb-run -s "$X_PARAMS" -n 94 ./mach mochitest --marionette localhost:$(($(($RANDOM))+2000)) $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
+
+# WebRender testing
+export TEST_PARAMS="--enable-webrender $TEST_PARAMS"
+export TEST_FLAVOUR="-wr"
+#xvfb-run -s "$X_PARAMS" -n 95 ./mach xpcshell-test --sequential $TEST_PARAMS 2>&1 | cat - | tee $TEST_DIR/xpcshell-wr
+#sleep 60
+#xvfb-run -s "$X_PARAMS" -n 96 ./mach reftest $TEST_PARAMS 2>&1 | tee $TEST_DIR/reftest$TEST_FLAVOUR
+#sleep 60
+#xvfb-run -s "$X_PARAMS" -n 97 ./mach crashtest $TEST_PARAMS 2>&1 | tee $TEST_DIR/crashtest$TEST_FLAVOUR
+#sleep 60
+#export DISPLAY=:0
+#./mach mochitest dom/base/test/ $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
+export DISPLAY=:98
+xvfb-run -s "$X_PARAMS" -n 98 ./mach mochitest dom/base/test/ $MOCHITEST_PARAMS $TEST_PARAMS 2>&1 | tee $TEST_DIR/mochitest$TEST_FLAVOUR
+
+rm -f  objdir/dist/bin/certutil
+rm -f  objdir/dist/bin/pk12util
diff --git a/SOURCES/run-wayland-compositor b/SOURCES/run-wayland-compositor
new file mode 100755
index 0000000..0480ed2
--- /dev/null
+++ b/SOURCES/run-wayland-compositor
@@ -0,0 +1,50 @@
+#!/usr/bin/bash
+# Run wayland compositor and set WAYLAND_DISPLAY env variable
+
+set -x
+
+echo export DESKTOP_SESSION=gnome > $HOME/.xsessionrc
+echo export XDG_CURRENT_DESKTOP=GNOME > $HOME/.xsessionrc
+echo export XDG_SESSION_TYPE=wayland >> $HOME/.xsessionrc
+
+# Turn off the screen saver and screen locking
+gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
+gsettings set org.gnome.desktop.screensaver lock-enabled false
+gsettings set org.gnome.desktop.screensaver lock-delay 3600
+
+# Disable the screen saver
+# This starts the gnome-keyring-daemon with an unlocked login keyring. libsecret uses this to
+# store secrets. Firefox uses libsecret to store a key that protects sensitive information like
+# credit card numbers.
+if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
+    # if not found, launch a new one
+    eval `dbus-launch --sh-syntax`
+fi
+eval `echo '' | /usr/bin/gnome-keyring-daemon -r -d --unlock --components=secrets`
+
+if [ -z "$XDG_RUNTIME_DIR" ]; then
+  export XDG_RUNTIME_DIR=$HOME
+fi
+
+. xvfb-run -s "-screen 0 1600x1200x24" -n 80 mutter --display=:80 --wayland --nested &
+export DISPLAY=:80
+
+if [ -z "$WAYLAND_DISPLAY" ] ; then
+  export WAYLAND_DISPLAY=wayland-0
+else
+  export WAYLAND_DISPLAY=wayland-1
+fi
+sleep 10
+retry_count=0
+max_retries=5
+until [ $retry_count -gt $max_retries ]; do
+  if [ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; then
+    retry_count=$(($max_retries + 1))
+  else
+    retry_count=$(($retry_count + 1))
+    echo "Waiting for Mutter, retry: $retry_count"
+    sleep 2
+  fi
+done
+
+env | grep "DISPLAY"
diff --git a/SOURCES/svg-rendering.patch b/SOURCES/svg-rendering.patch
new file mode 100644
index 0000000..9c0559c
--- /dev/null
+++ b/SOURCES/svg-rendering.patch
@@ -0,0 +1,29 @@
+# HG changeset patch
+# User M. Sirringhaus <msirringhaus@suse.de>
+# Date 1645518286 -3600
+#      Tue Feb 22 09:24:46 2022 +0100
+# Node ID 81832d035e101471dcf52dd91de287268add7a91
+# Parent  66f7ce16eb4965108687280e5443edd610631efb
+imported patch svg-rendering.patch
+
+diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp
+--- a/image/imgFrame.cpp
++++ b/image/imgFrame.cpp
+@@ -372,6 +372,17 @@ nsresult imgFrame::InitWithDrawable(gfxD
+     return NS_ERROR_OUT_OF_MEMORY;
+   }
+ 
++#if MOZ_BIG_ENDIAN()
++  if (aBackend == gfx::BackendType::SKIA && canUseDataSurface) {
++      // SKIA is lying about what format it returns on big endian
++      for (int ii=0; ii < mRawSurface->GetSize().Height()*mRawSurface->Stride() / 4; ++ii) {
++        uint32_t *vals = (uint32_t*)(mRawSurface->GetData());
++        uint32_t val = ((vals[ii] << 8) & 0xFF00FF00 ) | ((vals[ii] >> 8) & 0xFF00FF );
++        vals[ii] = (val << 16) | (val >> 16);
++      }
++  }
++#endif
++
+   if (!canUseDataSurface) {
+     // We used an offscreen surface, which is an "optimized" surface from
+     // imgFrame's perspective.
diff --git a/SPECS/firefox.spec b/SPECS/firefox.spec
index b3ddda8..2fa485e 100644
--- a/SPECS/firefox.spec
+++ b/SPECS/firefox.spec
@@ -1,11 +1,19 @@
 %global disable_toolsets  0
+# Produce a build suitable for release, i.e. use PGO/LTO. You can turn it off
+# when building locally to reduce build time.
+%global release_build     1
 
-%ifarch %{ix86}
-  # no debug package for the i686 because oom on i686 with debuginfos
-  #FIXME revise if still necessary
-  %global debug_package %{nil}
+# Run Mozilla test suite as a part of compile rpm section. Turn off when
+# building locally and don't want to spend 24 hours waiting for results.
+%global run_firefox_tests 0
+%ifarch x86_64 %{ix86}
+%global run_firefox_tests 0
 %endif
 
+# Don't create debuginfo rpm packages. It reduces build time as
+# exctracting debuginfo takes long time.
+%global create_debuginfo  1
+
 %{lua:
 function dist_to_rhel_minor(str, start)
   match = string.match(str, ".module%+el8.%d+")
@@ -24,19 +32,22 @@ function dist_to_rhel_minor(str, start)
 end}
 
 %global rhel_minor_version %{lua:print(dist_to_rhel_minor(rpm.expand("%dist")))}
-%global build_with_clang  0
+
+# Produce debug (non-optimized) package build. Suitable for debugging only
+# as the build is *very* slow.
+%global debug_build       0
 
 %global system_nss        1
 %global bundle_nss        0
 
 %if 0%{?rhel} == 8
-  %if %{rhel_minor_version} < 3
+  %if %{rhel_minor_version} <= 4
     %global bundle_nss        1
     %global system_nss        1
   %endif
 %endif
 
-%define use_bundled_ffi   0
+%global build_with_asan   0
 
 %global use_llvmts        0
 %global use_nodejsts      0
@@ -44,101 +55,156 @@ end}
 %global use_llvmts        1
 %global use_nodejsts      1
 %endif
+%if %{run_firefox_tests} 
+%global test_on_wayland   1
+%endif
+
 
 %global nodejs_rb         nodejs
 %global llvm_version      7.0
-
-%if 0%{?rhel} == 8
-%global llvm_version      6.0
+%if "%{toolchain}" == "clang"
+%global build_with_clang 1
+%else
+%global build_with_clang 0
 %endif
 
+%ifarch armv7hl
+%global create_debuginfo  0
+%endif
 %if 0%{?rhel} == 7
   %global use_dts         1
   %global nodejs_rb       rh-nodejs10-nodejs
   %global llvm_version    11.0
 %endif
 
+# Temporary disabled due to
+# https://bugzilla.redhat.com/show_bug.cgi?id=1951606
+%global enable_mozilla_crashreporter 0
+
+%global system_ffi        1
+%ifarch armv7hl
+%global system_libvpx     1
+%else
+%global system_libvpx     0
+%endif
+%global hardened_build    1
+%global system_jpeg       1
+%global disable_elfhack   1
+%global use_bundled_cbindgen  1
+%if %{debug_build}
+%global release_build     0
+%endif
+# Build PGO+LTO on x86_64 only due to build issues
+# on other arches.
+%global build_with_pgo    0
+%ifarch x86_64
+%if %{release_build}
+%global build_with_pgo    0
+%endif
+%endif
 %global use_rustts        1
-%if 0%{?rhel} >= 9
+%global dts_version       10
+%global rust_version      1.62
+%if 0%{?rhel} >= 8
   %global use_rustts      0
 %endif
-
-%global dts_version       10
-%global rust_version      1.52
+%if 0%{?flatpak}
+%global build_with_pgo    0
+%endif
 
 %if 0%{?disable_toolsets}
 %global use_rustts        0
 %global use_dts           0
 %global use_llvmts        0
+%global use_nodejsts      0
+%global nodejs_rb         nodejs
 %endif
 
 # Big endian platforms
 %ifarch ppc64 s390x
-# Javascript Intl API is not supported on big endian platforms right now:
-# https://bugzilla.mozilla.org/show_bug.cgi?id=1322212
 %global big_endian        1
 %endif
 
-# Hardened build?
-%global hardened_build    1
+%if 0%{?build_with_pgo}
+%global use_xvfb          1
+%global build_tests       1
+%endif
 
-%ifarch %{ix86} x86_64
-%global run_tests         0
-%else
-%global run_tests         0
+%if 0%{?run_firefox_tests}
+%global use_xvfb          1
+%global build_tests       1
 %endif
 
-# Build as a debug package?
-%global debug_build       0
+%global launch_wayland_compositor 0
+%if %{build_with_pgo} && 0%{?test_on_wayland}
+%global launch_wayland_compositor 1
+%endif
+%if %{run_firefox_tests} && 0%{?test_on_wayland}
+%global launch_wayland_compositor 1
+%endif
 
 # We need to use full path because of flatpak where datadir is /app/share
 %global default_bookmarks_file  /usr/share/bookmarks/default-bookmarks.html
 %global firefox_app_id  \{ec8030f7-c20a-464f-9b0e-13a3a9e97384\}
 # Minimal required versions
+%global cairo_version 1.13.1
+%global freetype_version 2.1.9
+%global libnotify_version 0.7.0
+%if %{?system_libvpx}
+%global libvpx_version 1.8.2
+%endif
 
-%if 0%{?system_nss}
-%global nspr_version 4.32
-# NSS/NSPR quite often ends in build override, so as requirement the version
-# we're building against could bring us some broken dependencies from time to time.
-#%global nspr_build_version %(pkg-config --silence-errors --modversion nspr 2>/dev/null || echo 65536)
+%if %{?system_nss}
+%global nspr_version 4.34
 %global nspr_build_version %{nspr_version}
-%global nss_version 3.67
-#%global nss_build_version %(pkg-config --silence-errors --modversion nss 2>/dev/null || echo 65536)
+%global nss_version 3.79
 %global nss_build_version %{nss_version}
 %endif
 
-# GTK3 bundling
-%define avoid_bundled_rebuild   0
+%global mozappdir     %{_libdir}/firefox
+%global mozappdirdev  %{_libdir}/firefox-devel-%{version}
+%global langpackdir   %{mozappdir}/browser/extensions
+%global tarballdir    firefox-%{version}
 
 %define bundled_install_path %{mozappdir}/bundled
+%global official_branding       1
 
 # We could use %%include, but in %%files, %%post and other sections, but in these
 # sections it could lead to syntax errors about unclosed %%if. Work around it by
 # using the following macro
 %define include_file() %{expand:%(cat '%1')}
 
-%global mozappdir     %{_libdir}/%{name}
-%global mozappdirdev  %{_libdir}/%{name}-devel-%{version}
-%global langpackdir   %{mozappdir}/browser/extensions
-%global tarballdir    %{name}-%{version}
-%global pre_version   esr
+%bcond_without langpacks
 
-%global official_branding       1
-%global build_langpacks         1
+%global pre_version   esr
+%if !%{release_build}
+%global pre_tag .npgo
+%endif
+%if %{build_with_clang}
+%global pre_tag .clang
+%endif
+%if %{build_with_asan}
+%global pre_tag .asan
+%global build_with_pgo    0
+%endif
+%if !%{system_nss}
+%global nss_tag .nss
+%endif
+%if %{debug_build}
+%global pre_tag .debug
+%endif
 
-# Workaround the dreaded "upstream source file changed content" rpmdiff failure that only secalert can waive.
-# If set to .b2 or .b3 ... the processed source file needs to be renamed before upload, e.g.
-# firefox-91.9.0esr.b2.processed-source.tar.xz
-# With does_not_exist it's empty and source file name as is.
-#global buildnum %{?does_not_exist}
-%global buildnum %{?does_not_exist}
+# Exclude private libraries from autogenerated provides and requires
+%global __provides_exclude_from ^%{mozappdir}
+%global __requires_exclude ^(%%(find %{buildroot}%{mozappdir} -name '*.so' | xargs -n1 basename | sort -u | paste -s -d '|' -))
 
 Summary:        Mozilla Firefox Web browser
 Name:           firefox
-Version:        91.13.0
-Release:        1%{?dist}
+Version:        102.3.0
+Release:        6%{?dist}
 URL:            https://www.mozilla.org/firefox/
 License:        MPLv1.1 or GPLv2+ or LGPLv2+
+
 %if 0%{?rhel} == 9
 ExcludeArch:    %{ix86}
 %endif
@@ -152,25 +218,19 @@ ExcludeArch:    %{ix86}
 %if 0%{?rhel} == 7
 ExcludeArch:    aarch64 s390 ppc
 %endif
-
 # We can't use the official tarball as it contains some test files that use
 # licenses that are rejected by Red Hat Legal.
 # The official tarball has to be always processed by the process-official-tarball
-# script.
-# Link to official tarball: https://hg.mozilla.org/releases/mozilla-release/archive/firefox-%%{version}%%{?pre_version}.source.tar.xz
-Source0:        firefox-%{version}%{?pre_version}%{?buildnum}.processed-source.tar.xz
-%if %{build_langpacks}
-Source1:        firefox-langpacks-%{version}%{?pre_version}-20220817.tar.xz
-
+# script
+# Link to original tarball: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz
+Source0:        firefox-%{version}%{?pre_version}.processed-source.tar.xz
+%if %{with langpacks}
+Source1:        firefox-langpacks-%{version}%{?pre_version}-20220913.tar.xz
 %endif
 Source2:        cbindgen-vendor.tar.xz
 Source3:        process-official-tarball
 Source10:       firefox-mozconfig
-%if 0%{?centos}
-Source12:       firefox-centos-default-prefs.js
-%else
 Source12:       firefox-redhat-default-prefs.js
-%endif
 Source20:       firefox.desktop
 Source21:       firefox.sh.in
 Source23:       firefox.1
@@ -178,52 +238,75 @@ Source24:       mozilla-api-key
 Source25:       firefox-symbolic.svg
 Source26:       distribution.ini
 Source27:       google-api-key
-Source28:       node-stdout-nonblocking-wrapper
-
-Source403:      nss-3.67.0-7.el8_1.src.rpm
+Source32:       node-stdout-nonblocking-wrapper
+Source33:       firefox.appdata.xml.in
+Source34:       firefox-search-provider.ini
+Source35:       google-loc-api-key
+Source37:       mochitest-python.tar.gz
+Source38:       print_results
+Source39:       print-errors
+Source40:       run-tests-x11
+Source41:       run-tests-wayland
+Source42:       psummary
+Source43:       print_failures
+Source44:       print-error-reftest
+Source45:       run-wayland-compositor
+Source403:      nss-3.79.0-6.el8_1.src.rpm
 Source401:      nss-setup-flags-env.inc
-Source402:      nspr-4.32.0-1.el8_1.src.rpm
+Source402:      nspr-4.34.0-3.el8_1.src.rpm
 
 # Build patches
-Patch1001:      build-ppc64le-inline.patch
-Patch1008:        build-rhel7-nasm-dwarf.patch
-Patch1009:        build-debuginfo-fix.patch
-# workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1699374
-Patch4:         build-mozconfig-fix.patch
-Patch6:         build-nss-version.patch
-
-# Fedora/RHEL specific patches
+Patch3:         mozilla-build-arm.patch
+Patch25:        rhbz-1219542-s390-build.patch
+# Fixing missing cacheFlush when JS_CODEGEN_NONE is used (s390x)
+Patch40:        build-aarch64-skia.patch
+Patch41:        build-disable-elfhack.patch
+Patch44:        build-arm-libopus.patch
+Patch47:        fedora-shebang-build.patch
+Patch49:        build-arm-libaom.patch
+Patch53:        firefox-gcc-build.patch
+Patch54:        mozilla-1669639.patch
+Patch71:        0001-GLIBCXX-fix-for-GCC-12.patch
+Patch72:        build-remove-dav1d-from-wayland-dep.patch
+Patch73:        build-ascii-decode-fail-rhel7.patch
+Patch75:        build-big-endian-errors.patch
+Patch76:        firefox-nss-version.patch
+Patch77:        mozilla-1775202.patch
+
+
+# Test patches
+# Generate without context by
+# GENDIFF_DIFF_ARGS=-U0 gendiff firefox-xxxx .firefox-tests-xpcshell
+# GENDIFF_DIFF_ARGS=-U0 gendiff firefox-xxxx .firefox-tests-reftest
+Patch102:       firefox-tests-xpcshell-freeze.patch
+
+# Fedora specific patches
 Patch215:        firefox-enable-addons.patch
 Patch219:        rhbz-1173156.patch
 Patch224:        mozilla-1170092.patch
-Patch225:        firefox-nss-addon-hack.patch
+#ARM run-time patch
+Patch226:        rhbz-1354671.patch
+Patch228:        disable-openh264-download.patch
+Patch229:        firefox-nss-addon-hack.patch
+Patch230:        D110204-fscreen.diff
 
 # Upstream patches
-
-Patch503:        mozilla-s390-context.patch
-Patch505:        mozilla-bmo1005535.patch
-Patch506:        mozilla-bmo1504834-part1.patch
-Patch507:        mozilla-bmo1504834-part2.patch
-Patch508:        mozilla-bmo1504834-part3.patch
-Patch509:        mozilla-bmo1504834-part4.patch
-Patch510:        mozilla-bmo1554971.patch
-Patch511:        mozilla-bmo1602730.patch
-Patch512:        mozilla-bmo849632.patch
-Patch513:        mozilla-bmo998749.patch
-#Patch514:        mozilla-s390x-skia-gradient.patch
-Patch515:        mozilla-bmo1626236.patch
-Patch518:        D110204-fscreen.diff
-Patch519:        expat-CVE-2022-25235.patch
-Patch520:        expat-CVE-2022-25236.patch
-Patch521:        expat-CVE-2022-25315.patch
-
-# Flatpak patches
-
-# CentOS patches
-%if 0%{?centos}
-Patch10000:      Bug-1238661---fix-mozillaSignalTrampoline-to-work-.patch
-Patch10001:      Bug-1526653---fix_user_vfp_armv7.patch
-%endif
+Patch415:        mozilla-1670333.patch
+Patch416:        mozilla-bmo1005535.patch
+Patch417:        mozilla-bmo1504834-part1.patch
+Patch418:        mozilla-bmo1504834-part3.patch
+Patch419:        mozilla-bmo849632.patch
+Patch420:        mozilla-bmo998749.patch
+Patch421:        mozilla-s390x-skia-gradient.patch
+Patch422:        one_swizzle_to_rule_them_all.patch
+Patch423:        svg-rendering.patch
+
+# PGO/LTO patches
+Patch600:        pgo.patch
+Patch602:        mozilla-1516803.patch
+
+# Backported WebRTC changes for PipeWire/Wayland screen sharing support
+Patch1008:      build-rhel7-nasm-dwarf.patch
 
 %if %{?system_nss}
 %if !0%{?bundle_nss}
@@ -233,29 +316,32 @@ BuildRequires:  nss-static >= %{nss_version}
 %endif
 %endif
 BuildRequires:  pkgconfig(libpng)
-BuildRequires:  xz
-BuildRequires:  libXt-devel
-BuildRequires:  mesa-libGL-devel
-Requires:       liberation-fonts-common
-Requires:       liberation-sans-fonts
+%if %{?system_jpeg}
 BuildRequires:  libjpeg-devel
+%endif
 BuildRequires:  zip
 BuildRequires:  bzip2-devel
 BuildRequires:  pkgconfig(zlib)
-#BuildRequires:  pkgconfig(libIDL-2.0)
+BuildRequires:  pkgconfig(gtk+-3.0)
 BuildRequires:  pkgconfig(gtk+-2.0)
-BuildRequires:  krb5-devel
+BuildRequires:  pkgconfig(krb5)
 BuildRequires:  pkgconfig(pango)
-BuildRequires:  pkgconfig(freetype2) >= 2.1.9
+BuildRequires:  pkgconfig(freetype2) >= %{freetype_version}
 BuildRequires:  pkgconfig(xt)
+BuildRequires:  pkgconfig(xtst)
 BuildRequires:  pkgconfig(xrender)
 BuildRequires:  pkgconfig(libstartup-notification-1.0)
-BuildRequires:  pkgconfig(libnotify)
+BuildRequires:  pkgconfig(libnotify) >= %{libnotify_version}
 BuildRequires:  pkgconfig(dri)
 BuildRequires:  pkgconfig(libcurl)
+BuildRequires:  pkgconfig(alsa)
+BuildRequires:  libstdc++-devel
+BuildRequires:  libstdc++-static
 BuildRequires:  dbus-glib-devel
+%if %{?system_libvpx}
+BuildRequires:  libvpx-devel >= %{libvpx_version}
+%endif
 BuildRequires:  m4
-
 BuildRequires:  pkgconfig(libpulse)
 
 %if 0%{?use_dts}
@@ -270,13 +356,11 @@ BuildRequires:  cargo
 BuildRequires:  rust
 BuildRequires:  clang clang-libs llvm
 %endif
-
+BuildRequires:  %{nodejs_rb} >= 10.21
+%if 0%{?rhel} == 7
 BuildRequires:  scl-utils
 BuildRequires:  findutils
-
-BuildRequires:  %{nodejs_rb} >= 10.21
-BuildRequires:  python3
-
+%endif
 %if 0%{?rhel} == 8
 BuildRequires:  cargo
 BuildRequires:  rust >= %{rust_version}
@@ -285,35 +369,33 @@ BuildRequires:  llvm-devel >= %{llvm_version}
 BuildRequires:  clang >= %{llvm_version}
 BuildRequires:  clang-devel >= %{llvm_version}
 BuildRequires:  rustfmt >= %{rust_version}
-%else
+%endif
+
 %if 0%{?use_rustts}
 BuildRequires:  rust-toolset-%{rust_version}
 %endif
+
 %if 0%{?use_llvmts}
 BuildRequires:  llvm-toolset-%{llvm_version}
 BuildRequires:  llvm-toolset-%{llvm_version}-llvm-devel
 BuildRequires:  llvm-toolset-%{llvm_version}-clang
 BuildRequires:  llvm-toolset-%{llvm_version}-clang-devel
 %endif
-%endif
 
-BuildRequires:  nasm
-%if %{build_with_clang}
-BuildRequires:  lld
-%endif
 
-%if 0%{?rhel} == 8
-  %if %{rhel_minor_version} >= 3
-BuildRequires:  pkgconfig(libpipewire-0.3)
-  %else
+%if 0%{?rhel} > 7
 BuildRequires:  pipewire-devel
-  %endif
 %endif
 
-BuildRequires:        gtk3-devel
-BuildRequires:        glib2-devel
-BuildRequires:        perl-interpreter
+%if !0%{?use_bundled_cbindgen}
+BuildRequires:  cbindgen
+%endif
+BuildRequires:  nasm >= 1.13
+BuildRequires:  libappstream-glib
 
+%if 0%{?big_endian}
+BuildRequires:  icu
+%endif
 # Bundled nss/nspr requirement
 %if 0%{?bundle_nss}
 BuildRequires:    nss-softokn
@@ -327,35 +409,107 @@ BuildRequires:    gcc-c++
 BuildRequires:    xmlto
 %endif
 
-BuildRequires:    libstdc++-static
-
 Requires:       mozilla-filesystem
+#not known or rhel7
+#Recommends:     mozilla-openh264 >= 2.1.1
+#Recommends:     libva
 Requires:       p11-kit-trust
+Requires:       pciutils-libs
 %if %{?system_nss}
 %if !0%{?bundle_nss}
 Requires:       nspr >= %{nspr_build_version}
 Requires:       nss >= %{nss_build_version}
 %endif
 %endif
+BuildRequires:  python3-devel
+BuildRequires:  python3-setuptools
 
 BuildRequires:  desktop-file-utils
-BuildRequires:  system-bookmarks
 Requires:       redhat-indexhtml
 
-%if %{?run_tests}
-BuildRequires:  xorg-x11-server-Xvfb
+%if !0%{?flatpak}
+#TODO
+BuildRequires:  system-bookmarks
 %endif
-
+%if %{?system_ffi}
 BuildRequires:  pkgconfig(libffi)
+%endif
 
-%if 0%{?big_endian}
-  %if 0%{?flatpak}
-BuildRequires:  icu
-  %endif
+%if 0%{?use_xvfb}
+BuildRequires:  xorg-x11-server-Xvfb
 %endif
+%if %{build_with_asan}
+BuildRequires:  libasan
+BuildRequires:  libasan-static
+%endif
+BuildRequires:  perl-interpreter
+#BuildRequires:  fdk-aac-free-devel not on rhel8
+%if 0%{?test_on_wayland}
+BuildRequires:  mutter
+BuildRequires:  gsettings-desktop-schemas
+BuildRequires:  gnome-settings-daemon
+BuildRequires:  mesa-dri-drivers
+BuildRequires:  xorg-x11-server-Xwayland
+BuildRequires:  dbus-x11
+BuildRequires:  gnome-keyring
+%endif
+%if 0%{?run_firefox_tests}
+BuildRequires:  procps-ng
+BuildRequires:  nss-tools
+BuildRequires:  dejavu-sans-mono-fonts
+BuildRequires:  dejavu-sans-fonts
+BuildRequires:  dejavu-serif-fonts
+BuildRequires:  dbus-x11
+BuildRequires:  gnome-keyring
+BuildRequires:  mesa-dri-drivers
+# ----------------------------------------
+BuildRequires:  liberation-fonts-common
+BuildRequires:  liberation-mono-fonts
+BuildRequires:  liberation-sans-fonts
+BuildRequires:  liberation-serif-fonts
+# ----------------------------------
+# Missing on f32
+%if 0%{?fedora} > 33
+BuildRequires:  google-carlito-fonts
+%endif
+BuildRequires:  google-droid-sans-fonts
+BuildRequires:  google-noto-fonts-common
+BuildRequires:  google-noto-cjk-fonts-common
+BuildRequires:  google-noto-sans-cjk-ttc-fonts
+BuildRequires:  google-noto-sans-gurmukhi-fonts
+BuildRequires:  google-noto-sans-fonts
+BuildRequires:  google-noto-emoji-color-fonts
+BuildRequires:  google-noto-sans-sinhala-vf-fonts
+# -----------------------------------
+BuildRequires:  thai-scalable-fonts-common
+BuildRequires:  thai-scalable-waree-fonts
+BuildRequires:  khmeros-base-fonts
+BuildRequires:  jomolhari-fonts
+# ----------------------------------
+BuildRequires:  lohit-tamil-fonts
+BuildRequires:  lohit-telugu-fonts
+# ----------------------------------
+BuildRequires:  paktype-naskh-basic-fonts
+# faild to build in Koji / f32
+%if 0%{?fedora} > 33
+BuildRequires:  pt-sans-fonts
+%endif
+BuildRequires:  smc-meera-fonts
+BuildRequires:  stix-fonts
+BuildRequires:  abattis-cantarell-fonts
+BuildRequires:  xorg-x11-fonts-ISO8859-1-100dpi
+BuildRequires:  xorg-x11-fonts-misc
+%endif
+BuildRequires:  make
+BuildRequires:  pciutils-libs
 
 Obsoletes:      mozilla <= 37:1.7.13
 Provides:       webclient
+%if 0%{?rhel} == 8 && %{rhel_minor_version} < 6
+%ifarch aarch64
+BuildRequires: gcc-toolset-12-annobin-plugin-gcc
+%endif
+%endif
 
 # Bundled libraries
 Provides: bundled(angle)
@@ -405,99 +559,120 @@ Provides: bundled(rlbox_sandboxing_api)
 Provides: bundled(sqlite3)
 
 %if 0%{?bundle_nss}
-Provides: bundled(nss) = 3.67.0
-Provides: bundled(nspr) = 4.32.0
+Provides: bundled(nss) = 3.79.0
+Provides: bundled(nspr) = 4.34.0
 %endif
 
 %description
 Mozilla Firefox is an open-source web browser, designed for standards
 compliance, performance and portability.
 
-%if %{run_tests}
-%global testsuite_pkg_name mozilla-%{name}-testresults
+%if 0%{?run_firefox_tests}
+%global testsuite_pkg_name %{name}-testresults
 %package -n %{testsuite_pkg_name}
 Summary: Results of testsuite
 %description -n %{testsuite_pkg_name}
 This package contains results of tests executed during build.
 %files -n %{testsuite_pkg_name}
-/test_results
+/%{version}-%{release}/test_results
+/%{version}-%{release}/test_summary.txt
+/%{version}-%{release}/failures-*
 %endif
 
 #---------------------------------------------------------------------
+
 %prep
 echo "Build environment"
 echo "dist                  %{?dist}"
-echo "RHEL 8 minor version: %{rhel_minor_version}"
+echo "RHEL 8 minor version: %{?rhel_minor_version}"
 echo "use_bundled_ffi       %{?use_bundled_ffi}"
 echo "bundle_nss            %{?bundle_nss}"
 echo "system_nss            %{?system_nss}"
 echo "use_rustts            %{?use_rustts}"
 
-
 %setup -q -n %{tarballdir}
+
 # Build patches, can't change backup suffix from default because during build
 # there is a compare of config and js/config directories and .orig suffix is
 # ignored during this compare.
 
-%patch4  -p1 -b .build-mozconfig-fix
-%patch6  -p1 -b .nss-version
+%ifarch s390
+%patch25 -p1 -b .rhbz-1219542-s390
+%endif
+%patch40 -p1 -b .aarch64-skia
+%if 0%{?disable_elfhack}
+%patch41 -p1 -b .disable-elfhack
+%endif
+%patch3  -p1 -b .arm
+%patch44 -p1 -b .build-arm-libopus
+%patch47 -p1 -b .fedora-shebang
+%patch49 -p1 -b .build-arm-libaom
+%patch53 -p1 -b .firefox-gcc-build
+%patch54 -p1 -b .1669639
+%patch71 -p1 -b .0001-GLIBCXX-fix-for-GCC-12
+%patch72 -p1 -b .build-remove-dav1d-from-wayland-dep
+
+%patch75 -p1 -b .build-big-endian-errors
+%patch76 -p1 -b .firefox-nss-version
+#ppc64le build failure because of webrtc
+%patch77 -p1 -b .mozilla-1775202
+
+%patch73 -p1 -b .build-ascii-decode-fail-rhel7
+
+# Test patches
+%patch102 -p1 -b .firefox-tests-xpcshell-freeze
 
 # Fedora patches
 %patch215 -p1 -b .addons
 %patch219 -p1 -b .rhbz-1173156
 %patch224 -p1 -b .1170092
-
-# Enable workaround for RHEL >= 8: rhbz#2043303
-%if 0%{?rhel} == 8 || 0%{?rhel} >= 9
-%patch225 -p1 -b .firefox-nss-addon-hack
+#ARM run-time patch
+%ifarch aarch64
+%patch226 -p1 -b .1354671
+%endif
+%patch228 -p1 -b .disable-openh264-download
+%patch229 -p1 -b .firefox-nss-addon-hack
+%patch230 -p1 -b .D110204-fscreen.diff
+
+%patch415 -p1 -b .1670333
+%patch416 -p1 -b .mozilla-bmo1005535
+%patch417 -p1 -b .mozilla-bmo1504834-part1
+%patch418 -p1 -b .mozilla-bmo1504834-part3
+%patch419 -p1 -b .mozilla-bmo849632
+%patch420 -p1 -b .mozilla-bmo998749
+%patch421 -p1 -b .mozilla-s390x-skia-gradient
+%patch422 -p1 -b .one_swizzle_to_rule_them_all
+%patch423 -p1 -b .svg-rendering
+
+# PGO patches
+%if %{build_with_pgo}
+%if !%{build_with_clang}
+%patch600 -p1 -b .pgo
+%patch602 -p1 -b .1516803
 %endif
-
-# Patch for big endian platforms only
-%if 0%{?big_endian}
 %endif
 
-%patch503 -p1 -b .mozilla-s390-context
-%patch505 -p1 -b .mozilla-bmo1005535
-%patch506 -p1 -b .mozilla-bmo1504834-part1
-%patch507 -p1 -b .mozilla-bmo1504834-part2
-%patch508 -p1 -b .mozilla-bmo1504834-part3
-%patch509 -p1 -b .mozilla-bmo1504834-part4
-%patch510 -p1 -b .mozilla-bmo1554971
-%patch511 -p1 -b .mozilla-bmo1602730
-%patch512 -p1 -b .mozilla-bmo849632
-%patch513 -p1 -b .mozilla-bmo998749
-#%patch514 -p1 -b .mozilla-s390x-skia-gradient
-%patch515 -p1 -b .mozilla-bmo1626236
-%patch518 -p1 -b .D110204-fscreen.diff
-%patch519 -p1 -b .expat-CVE-2022-25235
-%patch520 -p1 -b .expat-CVE-2022-25236
-%patch521 -p1 -b .expat-CVE-2022-25315
-
-
-%patch1001 -p1 -b .ppc64le-inline
 %if 0%{?rhel} == 7
-# fix the /usr/lib/rpm/debugedit: canonicalization unexpectedly shrank by one character
-%patch1009 -p1 -b .build-debuginfo-fix
   %ifarch %{ix86}
 # -F dwarf not available in RHEL7's nasm
 %patch1008 -p1 -b .build-rhel7-nasm-dwarf
   %endif
 %endif
 
-%if 0%{?centos}
-%ifarch %{arm}
-%patch 10000 -p1 -b .centos.armhfp
-%patch 10001 -p1 -b .centos.armhfp2
-%endif
-%endif
+
 
 %{__rm} -f .mozconfig
 %{__cp} %{SOURCE10} .mozconfig
+echo "ac_add_options --enable-default-toolkit=cairo-gtk3-wayland" >> .mozconfig
 %if %{official_branding}
 echo "ac_add_options --enable-official-branding" >> .mozconfig
 %endif
 %{__cp} %{SOURCE24} mozilla-api-key
 %{__cp} %{SOURCE27} google-api-key
+%{__cp} %{SOURCE35} google-loc-api-key
+
+echo "ac_add_options --prefix=\"%{_prefix}\"" >> .mozconfig
+echo "ac_add_options --libdir=\"%{_libdir}\"" >> .mozconfig
 
 %if %{?system_nss}
 echo "ac_add_options --with-system-nspr" >> .mozconfig
@@ -507,7 +682,11 @@ echo "ac_add_options --without-system-nspr" >> .mozconfig
 echo "ac_add_options --without-system-nss" >> .mozconfig
 %endif
 
-%ifarch %{ix86} x86_64
+%if %{?system_ffi}
+echo "ac_add_options --enable-system-ffi" >> .mozconfig
+%endif
+
+%ifarch %{arm}
 echo "ac_add_options --disable-elf-hack" >> .mozconfig
 %endif
 
@@ -515,7 +694,7 @@ echo "ac_add_options --disable-elf-hack" >> .mozconfig
 echo "ac_add_options --enable-debug" >> .mozconfig
 echo "ac_add_options --disable-optimize" >> .mozconfig
 %else
-%global optimize_flags "-g -O2"
+%global optimize_flags "none"
 %ifarch s390x
 %global optimize_flags "-g -O1"
 %endif
@@ -535,22 +714,35 @@ echo "ac_add_options --disable-debug" >> .mozconfig
 echo "ac_add_options --disable-jemalloc" >> .mozconfig
 %endif
 
-%ifnarch %{ix86} x86_64
-echo "ac_add_options --disable-webrtc" >> .mozconfig
+%if 0%{?build_tests}
+echo "ac_add_options --enable-tests" >> .mozconfig
+%else
+echo "ac_add_options --disable-tests" >> .mozconfig
 %endif
 
-%if %{?run_tests}
-echo "ac_add_options --enable-tests" >> .mozconfig
+%if !%{?system_jpeg}
+echo "ac_add_options --without-system-jpeg" >> .mozconfig
+%else
+echo "ac_add_options --with-system-jpeg" >> .mozconfig
 %endif
 
-%ifarch s390x
+%if %{?system_libvpx}
+echo "ac_add_options --with-system-libvpx" >> .mozconfig
+%else
+echo "ac_add_options --without-system-libvpx" >> .mozconfig
+%endif
+
+%ifarch s390 s390x
 echo "ac_add_options --disable-jit" >> .mozconfig
 %endif
 
-%ifnarch %{ix86}
-%if !0%{?debug_build}
-echo "ac_add_options --disable-debug-symbols" >> .mozconfig
+%if %{build_with_asan}
+echo "ac_add_options --enable-address-sanitizer" >> .mozconfig
+echo "ac_add_options --disable-jemalloc" >> .mozconfig
 %endif
+
+%if !%{enable_mozilla_crashreporter}
+echo "ac_add_options --disable-crashreporter" >> .mozconfig
 %endif
 
 # AV1 requires newer nasm that was rebased in 8.4
@@ -558,15 +750,18 @@ echo "ac_add_options --disable-debug-symbols" >> .mozconfig
 echo "ac_add_options --disable-av1" >> .mozconfig
 %endif
 
+# api keys full path
+echo "ac_add_options --with-mozilla-api-keyfile=`pwd`/mozilla-api-key" >> .mozconfig
+# It seems that the api key we have is for the safe browsing only
+echo "ac_add_options --with-google-location-service-api-keyfile=`pwd`/google-loc-api-key" >> .mozconfig
+echo "ac_add_options --with-google-safebrowsing-api-keyfile=`pwd`/google-api-key" >> .mozconfig
+
 echo 'export NODEJS="%{_buildrootdir}/bin/node-stdout-nonblocking-wrapper"' >> .mozconfig
 
 # Remove executable bit to make brp-mangle-shebangs happy.
 chmod -x third_party/rust/itertools/src/lib.rs
-chmod a-x third_party/rust/gfx-backend-vulkan/src/*.rs
-chmod a-x third_party/rust/gfx-hal/src/*.rs
 chmod a-x third_party/rust/ash/src/extensions/ext/*.rs
 chmod a-x third_party/rust/ash/src/extensions/khr/*.rs
-chmod a-x third_party/rust/ash/src/extensions/mvk/*.rs
 chmod a-x third_party/rust/ash/src/extensions/nv/*.rs
 
 #---------------------------------------------------------------------
@@ -574,15 +769,9 @@ chmod a-x third_party/rust/ash/src/extensions/nv/*.rs
 %build
 # Disable LTO to work around rhbz#1883904
 %define _lto_cflags %{nil}
-ulimit -a
-free
-#set -e
-# Hack for missing shell when building in brew on RHEL6
-
-%if ! 0%{?avoid_bundled_rebuild}
-    rm -rf %{_buildrootdir}/*
-%endif
 export PATH="%{_buildrootdir}/bin:$PATH"
+# Cleanup buildroot for existing rpms from bundled nss/nspr and other packages
+rm -rf %{_buildrootdir}/*
 
 function install_rpms_to_current_dir() {
     PACKAGE_RPM=$(eval echo $1)
@@ -603,61 +792,6 @@ function install_rpms_to_current_dir() {
          rpm2cpio "$package" | cpio -idu
      done
 }
-
-function build_bundled_package() {
-  PACKAGE_RPM=$1
-  PACKAGE_FILES=$2
-  PACKAGE_SOURCE=$3
-  PACKAGE_BUILD_OPTIONS=$4
-  export PACKAGE_DIR="%{_topdir}/RPMS"
-
-  PACKAGE_ALREADY_BUILD=0
-  %if %{?avoid_bundled_rebuild}
-    if ls $PACKAGE_DIR/$PACKAGE_RPM; then
-      PACKAGE_ALREADY_BUILD=1
-    fi
-    if ls $PACKAGE_DIR/%{_arch}/$PACKAGE_RPM; then
-      PACKAGE_ALREADY_BUILD=1
-    fi
-  %endif
-  if [ $PACKAGE_ALREADY_BUILD == 0 ]; then
-    echo "Rebuilding $PACKAGE_RPM from $PACKAGE_SOURCE"; echo "==============================="
-    rpmbuild --nodeps $PACKAGE_BUILD_OPTIONS --rebuild $PACKAGE_SOURCE
-    cat /var/tmp/rpm-tmp*
-  fi
-
-  find $PACKAGE_DIR
-  if [ ! -f $PACKAGE_DIR/$PACKAGE_RPM ]; then
-    # Hack for tps tests
-    ARCH_STR=%{_arch}
-    %ifarch %{ix86}
-    ARCH_STR="i?86"
-    %endif
-    export PACKAGE_DIR="$PACKAGE_DIR/$ARCH_STR"
-  fi
-  pushd $PACKAGE_DIR
-
-  echo "Installing $PACKAGE_DIR/$PACKAGE_RPM"; echo "==============================="
-  pwd
-  PACKAGE_LIST=$(echo $PACKAGE_DIR/$PACKAGE_RPM | tr " " "\n")
-  for PACKAGE in $PACKAGE_LIST
-  do
-      rpm2cpio $PACKAGE | cpio -iduv
-  done
-
-  PATH=$PACKAGE_DIR/usr/bin:$PATH
-  export PATH
-  LD_LIBRARY_PATH=$PACKAGE_DIR/usr/%{_lib}:$LD_LIBRARY_PATH
-  export LD_LIBRARY_PATH
-
-  # Clean rpms to avoid including them to package
-  %if ! 0%{?avoid_bundled_rebuild}
-    rm -f $PACKAGE_FILES
-  %endif
-
-  popd
-}
-
 %if 0%{?bundle_nss}
   rpm -ivh %{SOURCE402}
   #rpmbuild --nodeps --define '_prefix %{bundled_install_path}' --without=tests -ba %{_specdir}/nspr.spec
@@ -669,12 +803,15 @@ function build_bundled_package() {
   echo "Setting nspr flags"
   # nss-setup-flags-env.inc
   sed -i 's@%{bundled_install_path}@%{_buildrootdir}%{bundled_install_path}@g' %{_buildrootdir}%{bundled_install_path}/%{_lib}/pkgconfig/nspr*.pc
+  cat %{_buildrootdir}%{bundled_install_path}/%{_lib}/pkgconfig/nspr*.pc
 
   export LDFLAGS="-L%{_buildrootdir}%{bundled_install_path}/%{_lib} $LDFLAGS"
   export LDFLAGS="-Wl,-rpath,%{bundled_install_path}/%{_lib} $LDFLAGS"
   export LDFLAGS="-Wl,-rpath-link,%{_buildrootdir}%{bundled_install_path}/%{_lib} $LDFLAGS"
   export PKG_CONFIG_PATH=%{_buildrootdir}%{bundled_install_path}/%{_lib}/pkgconfig
-  export PATH="{_buildrootdir}%{bundled_install_path}/bin:$PATH"
+  pkg-config --libs-only-L nspr
+  pkg-config --libs nspr
+  export PATH="%{_buildrootdir}%{bundled_install_path}/bin:$PATH"
 
   export PATH=%{_buildrootdir}/%{bundled_install_path}/bin:$PATH
   echo $PKG_CONFIG_PATH
@@ -683,8 +820,6 @@ function build_bundled_package() {
   rpmbuild --nodeps --define '_prefix %{bundled_install_path}' --without=tests -ba %{_specdir}/nss.spec
   pushd %{_buildrootdir}
   #cleanup
-  #rm -rf {_buildrootdir}/usr/lib/debug/*
-  #rm -rf {_buildrootdir}/usr/lib/.build-id
   install_rpms_to_current_dir nss-3*.rpm
   install_rpms_to_current_dir nss-devel*.rpm
   install_rpms_to_current_dir nss-pkcs11-devel*.rpm
@@ -705,29 +840,12 @@ function build_bundled_package() {
   find %{_buildrootdir}
 %endif
 
-%if 0%{use_bundled_ffi}
-  # Install libraries to the predefined location to later add them to the Firefox libraries
-  rpm -ivh %{SOURCE303}
-  rpmbuild --nodeps --define '_prefix %{bundled_install_path}' -ba %{_specdir}/libffi.spec
-  pushd %{_buildrootdir}
-  install_rpms_to_current_dir 'libffi*.rpm'
-  popd
-  %filter_from_requires /libffi.so.6/d
-%endif
-%filter_setup
-
-function replace_prefix() {
-  FILE_NAME=$1
-  PKG_CONFIG_PREFIX=$2
-
-  cat $FILE_NAME | tail -n +2 > tmp.txt
-  echo "$PKG_CONFIG_PREFIX" > $FILE_NAME
-  cat tmp.txt >> $FILE_NAME
-  rm -rf tmp.txt
-}
-
-# We need to disable exit on error temporarily for the following scripts:
 set +e
+%if 0%{?rhel} == 8 && %{rhel_minor_version} < 6
+%ifarch aarch64
+source scl_source enable gcc-toolset-12
+%endif
+%endif
 %if 0%{?use_dts}
 source scl_source enable devtoolset-%{dts_version}
 %endif
@@ -737,79 +855,104 @@ source scl_source enable rust-toolset-%{rust_version}
 %if 0%{?use_nodejsts}
 source scl_source enable rh-nodejs10
 %endif
+%if 0%{?use_llvmts}
+source scl_source enable llvm-toolset-%{llvm_version}
+%endif
 
+set -e
 env
 which gcc
 which c++
 which g++
 which ld
 which nasm
-# Build and install local node if needed
-# ======================================
-export MOZ_NODEJS=`which node`
-
+which node
+%if 0%{?use_bundled_cbindgen}
 mkdir -p my_rust_vendor
 cd my_rust_vendor
 %{__tar} xf %{SOURCE2}
-cd -
 mkdir -p .cargo
 cat > .cargo/config <<EOL
 [source.crates-io]
 replace-with = "vendored-sources"
 
 [source.vendored-sources]
-directory = "`pwd`/my_rust_vendor"
+directory = "`pwd`"
 EOL
 
-export CARGO_HOME=.cargo
-cargo install cbindgen
-export PATH=`pwd`/.cargo/bin:$PATH
-export CBINDGEN=`pwd`/.cargo/bin/cbindgen
+%ifarch aarch64
+#export RUSTFLAGS="-Cdebuginfo=0 -Clinker=/opt/rh/gcc-toolset-12/root/usr/bin/gcc"
+%endif
 
-# debug missing sqlite3 python module
-export MACH_USE_SYSTEM_PYTHON=1
-./mach python -c "import sys;print(sys.path)"
+env CARGO_HOME=.cargo cargo install cbindgen
+export PATH=`pwd`/.cargo/bin:$PATH
+cd -
+%endif
 
 mkdir %{_buildrootdir}/bin || :
-cp %{SOURCE28} %{_buildrootdir}/bin || :
-chmod +x %{_buildrootdir}/bin/node-stdout-nonblocking-wrapper
+cp %{SOURCE32} %{_buildrootdir}/bin || :
 
 # Update the various config.guess to upstream release for aarch64 support
-find ./ -name config.guess -exec cp /usr/lib/rpm/config.guess {} ';'
-
-# -fpermissive is needed to build with gcc 4.6+ which has become stricter
-#
-# Mozilla builds with -Wall with exception of a few warnings which show up
-# everywhere in the code; so, don't override that.
-#
-# Disable C++ exceptions since Mozilla code is not exception-safe
-#
+# Do not update config.guess in the ./third_party/rust because that would break checksums
+find ./ -path ./third_party/rust -prune -o -name config.guess -exec cp /usr/lib/rpm/config.guess {} ';'
+
 MOZ_OPT_FLAGS=$(echo "%{optflags}" | %{__sed} -e 's/-Wall//')
 #rhbz#1037063
 # -Werror=format-security causes build failures when -Wno-format is explicitly given
 # for some sources
 # Explicitly force the hardening flags for Firefox so it passes the checksec test;
 # See also https://fedoraproject.org/wiki/Changes/Harden_All_Packages
+%if 0%{?fedora} < 30
 MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -Wformat-security -Wformat -Werror=format-security"
-
+%else
+# Workaround for mozbz#1531309
+MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-Werror=format-security//')
+%endif
+%if 0%{?fedora} > 30
+MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fpermissive"
+%endif
 %if %{?hardened_build}
-  MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now"
-  %endif
+MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now"
+%endif
 %if %{?debug_build}
-  MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-O2//')
+MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-O2//')
+%endif
+%ifarch s390
+MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-g/-g1/')
+# If MOZ_DEBUG_FLAGS is empty, firefox's build will default it to "-g" which
+# overrides the -g1 from line above and breaks building on s390/arm
+# (OOM when linking, rhbz#1238225)
+export MOZ_DEBUG_FLAGS=" "
+%endif
+%ifarch %{arm} %{ix86}
+MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-g/-g0/')
+export MOZ_DEBUG_FLAGS=" "
 %endif
-
-# We don't wantfirefox to use CK_GCM_PARAMS_V3 in nss
-MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -DNSS_PKCS11_3_0_STRICT"
-
 %if !%{build_with_clang}
-  %ifarch aarch64 %{ix86} x86_64 s390x
-    MOZ_LINK_FLAGS="-Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
-  %endif
-  %ifarch %{ix86}
-    MOZ_LINK_FLAGS="-Wl,--no-keep-memory -Wl,--strip-debug"
-    echo "ac_add_options --enable-linker=gold" >> .mozconfig
-  %endif
+%ifarch s390x ppc aarch64 %{ix86}
+MOZ_LINK_FLAGS="-Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
+%endif
+%ifarch %{arm}
+MOZ_LINK_FLAGS="-Wl,--no-keep-memory -Wl,--strip-debug"
+echo "ac_add_options --enable-linker=gold" >> .mozconfig
+%endif
+%endif
+%if 0%{?flatpak}
+# Make sure the linker can find libraries in /app/lib64 as we don't use
+# __global_ldflags that normally sets this.
+MOZ_LINK_FLAGS="$MOZ_LINK_FLAGS -L%{_libdir}"
+%endif
+%ifarch %{arm} %{ix86} %{s390x}
+export RUSTFLAGS="-Cdebuginfo=0"
+echo 'export RUSTFLAGS="-Cdebuginfo=0"' >> .mozconfig
+%endif
+#%ifarch aarch64
+#export RUSTFLAGS="-Cdebuginfo=0 -Clinker=/opt/rh/gcc-toolset-12/root/usr/bin/gcc"
+#echo 'export RUSTFLAGS="-Cdebuginfo=0 -Clinker=/opt/rh/gcc-toolset-12/root/usr/bin/gcc"' >> .mozconfig
+#%endif
+%if %{build_with_asan}
+MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fsanitize=address -Dxmalloc=myxmalloc"
+MOZ_LINK_FLAGS="$MOZ_LINK_FLAGS -fsanitize=address -ldl"
 %endif
 
 %if 0%{?bundle_nss}
@@ -819,77 +962,57 @@ MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -DNSS_PKCS11_3_0_STRICT"
   MOZ_LINK_FLAGS="-Wl,-rpath-link,%{_buildrootdir}%{bundled_install_path}/%{_lib} $MOZ_LINK_FLAGS"
 %endif
 
-%ifarch %{ix86}
-  export RUSTFLAGS="-Cdebuginfo=0"
-  echo 'export RUSTFLAGS="-Cdebuginfo=0"' >> .mozconfig
-%endif
+# We don't wantfirefox to use CK_GCM_PARAMS_V3 in nss
+MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -DNSS_PKCS11_3_0_STRICT"
 
-export PREFIX='%{_prefix}'
-export LIBDIR='%{_libdir}'
-export CC=gcc
-export CXX=g++
 echo "export CFLAGS=\"$MOZ_OPT_FLAGS\"" >> .mozconfig
 echo "export CXXFLAGS=\"$MOZ_OPT_FLAGS\"" >> .mozconfig
 echo "export LDFLAGS=\"$MOZ_LINK_FLAGS\"" >> .mozconfig
 
 %if %{build_with_clang}
-  echo "export LLVM_PROFDATA=\"llvm-profdata\"" >> .mozconfig
-  echo "export AR=\"llvm-ar\"" >> .mozconfig
-  echo "export NM=\"llvm-nm\"" >> .mozconfig
-  echo "export RANLIB=\"llvm-ranlib\"" >> .mozconfig
-  echo "ac_add_options --enable-linker=lld" >> .mozconfig
+echo "export LLVM_PROFDATA=\"llvm-profdata\"" >> .mozconfig
+echo "export AR=\"llvm-ar\"" >> .mozconfig
+echo "export NM=\"llvm-nm\"" >> .mozconfig
+echo "export RANLIB=\"llvm-ranlib\"" >> .mozconfig
+echo "ac_add_options --enable-linker=lld" >> .mozconfig
 %else
-  echo "export CC=gcc" >> .mozconfig
-  echo "export CXX=g++" >> .mozconfig
-  echo "export AR=\"gcc-ar\"" >> .mozconfig
-  echo "export NM=\"gcc-nm\"" >> .mozconfig
-  echo "export RANLIB=\"gcc-ranlib\"" >> .mozconfig
+echo "export CC=gcc" >> .mozconfig
+echo "export CXX=g++" >> .mozconfig
+echo "export AR=\"gcc-ar\"" >> .mozconfig
+echo "export NM=\"gcc-nm\"" >> .mozconfig
+echo "export RANLIB=\"gcc-ranlib\"" >> .mozconfig
+%endif
+%if 0%{?build_with_pgo}
+echo "ac_add_options MOZ_PGO=1" >> .mozconfig
+# PGO build doesn't work with ccache
+export CCACHE_DISABLE=1
 %endif
 
 MOZ_SMP_FLAGS=-j1
-# More than two build tasks can lead to OOM gcc crash.
-%if 0%{?rhel} < 8
-  [ -z "$RPM_BUILD_NCPUS" ] && \
+# On x86_64 architectures, Mozilla can build up to 4 jobs at once in parallel,
+# however builds tend to fail on other arches when building in parallel.
+#%ifarch %{ix86} s390x %{arm} aarch64 ppc64le
+#[ -z "$RPM_BUILD_NCPUS" ] && \
+#     RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
+#[ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
+#%endif
+#%ifarch x86_64 ppc ppc64 ppc64le
+[ -z "$RPM_BUILD_NCPUS" ] && \
        RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
-  [ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
-%else
-  %ifarch %{ix86} x86_64 ppc64 ppc64le aarch64
-  [ -z "$RPM_BUILD_NCPUS" ] && \
-       RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
-    [ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
-    [ "$RPM_BUILD_NCPUS" -ge 4 ] && MOZ_SMP_FLAGS=-j3
-    [ "$RPM_BUILD_NCPUS" -ge 8 ] && MOZ_SMP_FLAGS=-j3
-  %endif
-%endif
-
-cat /proc/meminfo
+[ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
+[ "$RPM_BUILD_NCPUS" -ge 4 ] && MOZ_SMP_FLAGS=-j4
+[ "$RPM_BUILD_NCPUS" -ge 8 ] && MOZ_SMP_FLAGS=-j8
+[ "$RPM_BUILD_NCPUS" -ge 16 ] && MOZ_SMP_FLAGS=-j16
+#%endif
 
-# Free memory in kB
-if grep -q MemAvailable /proc/meminfo; then
-    MEM_AVAILABLE=$(grep MemAvailable /proc/meminfo | awk '{ print $2 }')
-else
-    MEM_AVAILABLE=$(grep MemFree /proc/meminfo | awk '{ print $2 }')
-fi
-
-# Usually the compiler processes can take 2 GB of memory at peaks
-TASK_SIZE=4000000
-MEM_CONSTRAINED_JOBS=$(( MEM_AVAILABLE / TASK_SIZE ))
-
-if [ $MEM_CONSTRAINED_JOBS -le 0 ]; then
-  MEM_CONSTRAINED_JOBS=1
-fi
+echo "mk_add_options MOZ_MAKE_FLAGS=\"$MOZ_SMP_FLAGS\"" >> .mozconfig
+echo "mk_add_options MOZ_SERVICES_SYNC=1" >> .mozconfig
+echo "export STRIP=/bin/true" >> .mozconfig
+#export MACH_USE_SYSTEM_PYTHON=1
 
-CPU_AVAILABLE=$(/usr/bin/getconf _NPROCESSORS_ONLN)
-# Pick the minimum from available CPUs or memory constrained number of jobs
-MOZ_SMP_FLAGS=-j$([ "$CPU_AVAILABLE" -le "$MEM_CONSTRAINED_JOBS" ] && echo "$CPU_AVAILABLE" || echo "$MEM_CONSTRAINED_JOBS")
-
-# override smp flags to the rpmbuild defaults ATM
-%ifnarch ppc64le
-MOZ_SMP_FLAGS=%{_smp_mflags}
-%endif
-
-%ifarch s390x
-MOZ_SMP_FLAGS=-j2
+%if %{launch_wayland_compositor}
+cp %{SOURCE45} .
+. ./run-wayland-compositor
 %endif
 
 %if 0%{?bundle_nss}
@@ -900,57 +1023,18 @@ MOZ_SMP_FLAGS=-j2
   echo $PKG_CONFIG_PATH
 %endif
 
-export MOZ_MAKE_FLAGS="$MOZ_SMP_FLAGS"
-export MOZ_SERVICES_SYNC="1"
-# we need to strip the sources on i686 because to we don't use rpm to generate debugsymbols because of oom
-%ifnarch %{ix86}
-  export STRIP=/bin/true
+%if %{build_with_pgo}
+%if 0%{?test_on_wayland}
+env | grep "WAYLAND"
+MOZ_ENABLE_WAYLAND=1 ./mach build -v 2>&1 || exit 1
+%else
+xvfb-run ./mach build -v 2>&1 || exit 1
 %endif
-which node
-echo 'export NODEJS="%{_buildrootdir}/bin/node-stdout-nonblocking-wrapper"'
-env
-ls %{_buildrootdir}
-
-export MACH_USE_SYSTEM_PYTHON=1
-%if 0%{?use_llvmts}
-  #scl enable llvm-toolset-%{llvm_version} './mach build -v'
-  ./mach build -v || exit 1
 %else
-  ./mach build -v || exit 1
+./mach build -v 2>&1 || exit 1
 %endif
-# Look for the reason we get: /usr/lib/rpm/debugedit: canonicalization unexpectedly shrank by one character
-readelf -wl objdir/dist/bin/libxul.so | grep "/"
 
-%if %{?run_tests}
-  %if %{?system_nss}
-    ln -s /usr/bin/certutil objdir/dist/bin/certutil
-    ln -s /usr/bin/pk12util objdir/dist/bin/pk12util
-  %endif
-  mkdir test_results
-  ./mach --log-no-times check-spidermonkey &> test_results/check-spidermonkey || true
-  ./mach --log-no-times check-spidermonkey &> test_results/check-spidermonkey-2nd-run || true
-  ./mach --log-no-times cppunittest &> test_results/cppunittest || true
-  xvfb-run ./mach --log-no-times crashtest &> test_results/crashtest || true
-  ./mach --log-no-times gtest &> test_results/gtest || true
-  xvfb-run ./mach --log-no-times jetpack-test &> test_results/jetpack-test || true
-  # not working right now ./mach marionette-test &> test_results/marionette-test || true
-  xvfb-run ./mach --log-no-times mochitest-a11y &> test_results/mochitest-a11y || true
-  xvfb-run ./mach --log-no-times mochitest-browser &> test_results/mochitest-browser || true
-  xvfb-run ./mach --log-no-times mochitest-chrome &> test_results/mochitest-chrome || true
-  xvfb-run ./mach --log-no-times mochitest-devtools &> test_results/mochitest-devtools || true
-  xvfb-run ./mach --log-no-times mochitest-plain &> test_results/mochitest-plain || true
-  xvfb-run ./mach --log-no-times reftest &> test_results/reftest || true
-  xvfb-run ./mach --log-no-times webapprt-test-chrome &> test_results/webapprt-test-chrome || true
-  xvfb-run ./mach --log-no-times webapprt-test-content &> test_results/webapprt-test-content || true
-  ./mach --log-no-times webidl-parser-test &> test_results/webidl-parser-test || true
-  xvfb-run ./mach --log-no-times xpcshell-test &> test_results/xpcshell-test || true
-  %if %{?system_nss}
-    rm -f  objdir/dist/bin/certutil
-    rm -f  objdir/dist/bin/pk12util
-  %endif
-%endif
 #---------------------------------------------------------------------
-
 %install
 export MACH_USE_SYSTEM_PYTHON=1
 function install_rpms_to_current_dir() {
@@ -996,15 +1080,35 @@ function install_rpms_to_current_dir() {
   popd
 %endif
 
-# Install bundled libffi
-%if %{use_bundled_ffi}
-  pushd %{buildroot}
-  install_rpms_to_current_dir libffi-3*.rpm
-  popd
+# run Firefox test suite
+%if %{launch_wayland_compositor}
+cp %{SOURCE45} .
+. ./run-wayland-compositor
+%endif
+
+%if 0%{?run_firefox_tests}
+mkdir -p objdir/_virtualenvs/init_py3
+%{__cat} > objdir/_virtualenvs/init_py3/pip.conf << EOF
+[global]
+find-links=`pwd`/mochitest-python
+no-index=true
+EOF
+tar xf %{SOURCE37}
+cp %{SOURCE40} %{SOURCE41} %{SOURCE42} %{SOURCE38} %{SOURCE39} %{SOURCE43} %{SOURCE44} .
+mkdir -p test_results
+%if %{?test_on_wayland}
+./run-tests-wayland || true
+%else
+./run-tests-x11 || true
+%endif
+./print_results > test_summary.txt 2>&1 || true
+./print_failures || true
 %endif
 
 # set up our default bookmarks
-%{__cp} -p %{default_bookmarks_file} objdir/dist/bin/browser/chrome/en-US/locale/browser/bookmarks.html
+%if !0%{?flatpak}
+%{__cp} -p %{default_bookmarks_file} objdir/dist/bin/browser/chrome/browser/content/browser/default-bookmarks.html
+%endif
 
 # Make sure locale works for langpacks
 %{__cat} > objdir/dist/bin/browser/defaults/preferences/firefox-l10n.js << EOF
@@ -1019,12 +1123,22 @@ desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE20}
 
 # set up the firefox start script
 %{__rm} -rf %{buildroot}%{_bindir}/firefox
-%{__cat} %{SOURCE21} > %{buildroot}%{_bindir}/firefox
-sed -i -e 's|%PREFIX%|%{_prefix}|' %{buildroot}%{_bindir}/firefox
-sed -i -e 's|%RHEL_ENV_VARS%||' %{buildroot}%{_bindir}/firefox
-
+%{__sed} -e 's,/__PREFIX__,%{_prefix},g' %{SOURCE21} > %{buildroot}%{_bindir}/firefox
 %{__chmod} 755 %{buildroot}%{_bindir}/firefox
 
+%if 0%{?flatpak}
+sed -i -e 's|%FLATPAK_ENV_VARS%|export TMPDIR="$XDG_CACHE_HOME/tmp"|' %{buildroot}%{_bindir}/firefox
+%else
+sed -i -e 's|%FLATPAK_ENV_VARS%||' %{buildroot}%{_bindir}/firefox
+%endif
+
+# Run firefox under wayland only on RHEL9 and newer
+%if 0%{?rhel} < 9
+sed -i -e 's|%DISABLE_WAYLAND_PLACEHOLDER%|export MOZ_DISABLE_WAYLAND=1|' %{buildroot}%{_bindir}/firefox
+%else
+sed -i -e 's|%DISABLE_WAYLAND_PLACEHOLDER%||' %{buildroot}%{_bindir}/firefox
+%endif
+
 %{__install} -p -D -m 644 %{SOURCE23} %{buildroot}%{_mandir}/man1/firefox.1
 
 %{__rm} -f %{buildroot}/%{mozappdir}/firefox-config
@@ -1041,49 +1155,8 @@ done
 %{__cp} -p %{SOURCE25} \
            %{buildroot}%{_datadir}/icons/hicolor/symbolic/apps
 
-# Register as an application to be visible in the software center
-#
-# NOTE: It would be *awesome* if this file was maintained by the upstream
-# project, translated and installed into the right place during `make install`.
-#
-# See http://www.freedesktop.org/software/appstream/docs/ for more details.
-#
-%{__mkdir_p} %{buildroot}%{_datadir}/appdata
-cat > %{buildroot}%{_datadir}/appdata/%{name}.appdata.xml <<EOF
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright 2014 Richard Hughes <richard@hughsie.com> -->
-<!--
-BugReportURL: https://bugzilla.mozilla.org/show_bug.cgi?id=1071061
-SentUpstream: 2014-09-22
--->
-<application>
-  <id type="desktop">firefox.desktop</id>
-  <metadata_license>CC0-1.0</metadata_license>
-  <project_license>MPLv1.1 or GPLv2+ or LGPLv2+</project_license>
-  <description>
-    <p>
-      Bringing together all kinds of awesomeness to make browsing better for you.
-      Get to your favorite sites quickly – even if you don’t remember the URLs.
-      Type your term into the location bar (aka the Awesome Bar) and the autocomplete
-      function will include possible matches from your browsing history, bookmarked
-      sites and open tabs.
-    </p>
-    <!-- FIXME: Needs another couple of paragraphs -->
-  </description>
-  <url type="homepage">http://www.mozilla.org/</url>
-  <screenshots>
-    <screenshot type="default">https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/firefox/a.png</screenshot>
-    <screenshot>https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/firefox/b.png</screenshot>
-    <screenshot>https://raw.githubusercontent.com/hughsie/fedora-appstream/master/screenshots-extra/firefox/c.png</screenshot>
-  </screenshots>
-  <!-- FIXME: change this to an upstream email address for spec updates
-  <updatecontact>someone_who_cares@upstream_project.org</updatecontact>
-   -->
-</application>
-EOF
-
 echo > %{name}.lang
-%if %{build_langpacks}
+%if %{with langpacks}
 # Extract langpacks, make any mods needed, repack the langpack, and install it.
 %{__mkdir_p} %{buildroot}%{langpackdir}
 %{__tar} xf %{SOURCE1}
@@ -1100,7 +1173,11 @@ for langpack in `ls firefox-langpacks/*.xpi`; do
 
   %{__install} -m 644 ${extensionID}.xpi %{buildroot}%{langpackdir}
   language=`echo $language | sed -e 's/-/_/g'`
+%if 0%{?flatpak}
+  echo "%{langpackdir}/${extensionID}.xpi" >> %{name}.lang
+%else
   echo "%%lang($language) %{langpackdir}/${extensionID}.xpi" >> %{name}.lang
+%endif
 done
 %{__rm} -rf firefox-langpacks
 
@@ -1116,6 +1193,7 @@ echo "%%lang($language_short) %{langpackdir}/langpack-$language_short@firefox.mo
 
 # Table of fallbacks for each language
 # please file a bug at bugzilla.redhat.com if the assignment is incorrect
+#create_default_langpack "bn-IN" "bn"
 create_default_langpack "es-AR" "es"
 create_default_langpack "fy-NL" "fy"
 create_default_langpack "ga-IE" "ga"
@@ -1142,10 +1220,13 @@ sed -i -e 's|%PREFIX%|%{_prefix}|' %{buildroot}%{mozappdir}/defaults/preferences
   echo 'pref("security.pki.use_modern_crypto_with_pkcs12", true);' >> %{buildroot}%{mozappdir}/defaults/preferences/all-redhat.js
 %endif
 
-%ifarch s390x ppc64
+%ifarch s390x
   echo 'pref("gfx.webrender.force-disabled", true);' >> %{buildroot}%{mozappdir}/defaults/preferences/all-redhat.js
 %endif
 
+%ifarch s390x ppc64
+  echo 'pref("gfx.webrender.force-disabled", true);' >> %{buildroot}%{mozappdir}/defaults/preferences/all-redhat.js
+%endif
 
 # System config dir
 %{__mkdir_p} %{buildroot}/%{_sysconfdir}/%{name}/pref
@@ -1161,13 +1242,13 @@ sed -i -e 's|%PREFIX%|%{_prefix}|' %{buildroot}%{mozappdir}/defaults/preferences
 %{__rm} -rf %{buildroot}%{mozappdir}/dictionaries
 ln -s %{_datadir}/myspell %{buildroot}%{mozappdir}/dictionaries
 
-%if %{run_tests}
-# Add debuginfo for crash-stats.mozilla.com
-%{__mkdir_p} %{buildroot}/test_results
-%{__cp} test_results/* %{buildroot}/test_results
+%if 0%{?run_firefox_tests}
+%{__mkdir_p} %{buildroot}/%{version}-%{release}/test_results
+%{__cp} test_results/* %{buildroot}/%{version}-%{release}/test_results
+%{__cp} test_summary.txt %{buildroot}/%{version}-%{release}/
+%{__cp} failures-* %{buildroot}/%{version}-%{release}/ || true
 %endif
 
-
 # Copy over run-mozilla.sh
 %{__cp} build/unix/run-mozilla.sh %{buildroot}%{mozappdir}
 
@@ -1175,16 +1256,39 @@ ln -s %{_datadir}/myspell %{buildroot}%{mozappdir}/dictionaries
 %{__mkdir_p} %{buildroot}%{mozappdir}/distribution
 %{__cp} %{SOURCE26} %{buildroot}%{mozappdir}/distribution
 
-%if 0%{?centos}
-sed -i -e 's|Red Hat Enterprise|CentOS|' %{buildroot}%{mozappdir}/distribution/distribution.ini
-%endif
+# Install appdata file
+mkdir -p %{buildroot}%{_datadir}/metainfo
+%{__sed} -e "s/__VERSION__/%{version}/" \
+         -e "s/__DATE__/$(date '+%Y-%m-%d')/" \
+         %{SOURCE33} > %{buildroot}%{_datadir}/metainfo/firefox.appdata.xml
+
+# Install Gnome search provider files
+mkdir -p %{buildroot}%{_datadir}/gnome-shell/search-providers
+%{__cp} %{SOURCE34} %{buildroot}%{_datadir}/gnome-shell/search-providers
+
+# Remove gtk2 support as flash plugin is no longer supported
+rm -rf %{buildroot}%{mozappdir}/gtk2/
 
 # Remove copied libraries to speed up build
 rm -f %{buildroot}%{mozappdirdev}/sdk/lib/libmozjs.so
 rm -f %{buildroot}%{mozappdirdev}/sdk/lib/libmozalloc.so
 rm -f %{buildroot}%{mozappdirdev}/sdk/lib/libxul.so
+
+# Create a symlink to replace libnssckbi.so with p11-kit-client.so
+# instead of p11-kit-trust.so, so that Firefox can see the system
+# trust store on the host through the p11-kit RPC protocol.  A symlink
+# to libnss3.so is also needed, because Firefox tries to load
+# libnssckbi.so from the same directory where libnss3.so is loaded (as
+# of Firefox 89).
+%if 0%{?flatpak}
+ln -sf /usr/lib64/libnss3.so %{buildroot}%{_libdir}/libnss3.so
+ln -sf /usr/lib64/pkcs11/p11-kit-client.so %{buildroot}%{_libdir}/libnssckbi.so
+%endif
 #---------------------------------------------------------------------
 
+%check
+appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/*.appdata.xml
+
 %preun
 # is it a final removal?
 if [ $1 -eq 0 ]; then
@@ -1212,6 +1316,7 @@ update-desktop-database &> /dev/null || :
 if [ $1 -eq 0 ] ; then
     touch --no-create %{_datadir}/icons/hicolor &>/dev/null
     gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+    %{__rm} -rf %{langpackdir}
 fi
 
 %posttrans
@@ -1226,16 +1331,19 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %dir %{_sysconfdir}/%{name}/*
 %dir %{_datadir}/mozilla/extensions/*
 %dir %{_libdir}/mozilla/extensions/*
-%{_datadir}/appdata/*.appdata.xml
-%{_datadir}/applications/*.desktop
+%{_datadir}/applications/%{name}.desktop
+%{_datadir}/metainfo/*.appdata.xml
+%{_datadir}/gnome-shell/search-providers/*.ini
 %dir %{mozappdir}
-%doc %{mozappdir}/LICENSE
+%license %{mozappdir}/LICENSE
 %{mozappdir}/browser/chrome
 %{mozappdir}/defaults/preferences/*
 %{mozappdir}/browser/defaults/preferences
 %{mozappdir}/browser/features/*.xpi
 %{mozappdir}/distribution/distribution.ini
-%if %{build_langpacks}
+# That's Windows only
+%ghost %{mozappdir}/browser/features/aushelper@mozilla.org.xpi
+%if %{with langpacks}
 %dir %{langpackdir}
 %endif
 %{mozappdir}/browser/omni.ja
@@ -1243,6 +1351,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{mozappdir}/application.ini
 %{mozappdir}/pingsender
 %exclude %{mozappdir}/removed-files
+%if 0%{?flatpak}
+%{_libdir}/libnss3.so
+%{_libdir}/libnssckbi.so
+%endif
 %{_datadir}/icons/hicolor/16x16/apps/firefox.png
 %{_datadir}/icons/hicolor/22x22/apps/firefox.png
 %{_datadir}/icons/hicolor/24x24/apps/firefox.png
@@ -1250,6 +1362,13 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{_datadir}/icons/hicolor/32x32/apps/firefox.png
 %{_datadir}/icons/hicolor/48x48/apps/firefox.png
 %{_datadir}/icons/hicolor/symbolic/apps/firefox-symbolic.svg
+%if %{enable_mozilla_crashreporter}
+%{mozappdir}/crashreporter
+%{mozappdir}/crashreporter.ini
+%{mozappdir}/minidump-analyzer
+%{mozappdir}/Throbber-small.gif
+%{mozappdir}/browser/crashreporter-override.ini
+%endif
 %{mozappdir}/*.so
 %{mozappdir}/defaults/pref/channel-prefs.js
 %{mozappdir}/dependentlibs.list
@@ -1258,13 +1377,12 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{mozappdir}/platform.ini
 %{mozappdir}/plugin-container
 %{mozappdir}/gmp-clearkey
-%{mozappdir}/fonts/*.ttf
+%{mozappdir}/fonts/TwemojiMozilla.ttf
 %if !%{?system_nss}
 %exclude %{mozappdir}/libnssckbi.so
 %endif
-%if 0%{use_bundled_ffi}
-%{mozappdir}/bundled/%{_lib}/libffi.so*
-%exclude %{_datadir}/doc/libffi*
+%if %{build_with_asan}
+%{mozappdir}/llvm-symbolizer
 %endif
 
 %if 0%{?bundle_nss}
@@ -1280,15 +1398,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{mozappdir}/bundled/%{_lib}/libplds4.so
 %endif
 
-
 #---------------------------------------------------------------------
 
 %changelog
-* Wed Aug 24 2022 CentOS Sources <bugs@centos.org> - 91.13.0-1.el8.centos
-- Apply debranding changes
-
-* Wed Aug 17 2022 Eike Rathke <erack@redhat.com> - 91.13.0-1
-- Update to 91.13.0 build1
+* Tue Sep 13 2022 Jan Horak <jhorak@redhat.com> - 102.3.0-6
+- Update to 102.3.0 build1
 
 * Thu Jul 21 2022 Eike Rathke <erack@redhat.com> - 91.12.0-1
 - Update to 91.12.0 build1
@@ -1690,3 +1804,4 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 
 * Thu Dec  8 2016 Jan Horak <jhorak@redhat.com> - 52.0-0.5
 - Firefox Aurora 52 testing build
+