Bug 1548253 - Port pref cache variables of nsContentUtils to StaticPrefs - dom.enable_performance, r=Ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 01 May 2019 21:06:59 +0000
changeset 530984 04c2cdd7311b3eceb88173cda0ffc834bba55efb
parent 530983 32a9dc03ded349c77a7d8bce5b26e5fc882d48f1
child 530985 4826fedb277de974714e473ea71b4ca9167b4d3a
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1548253
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1548253 - Port pref cache variables of nsContentUtils to StaticPrefs - dom.enable_performance, r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D29505
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/performance/PerformanceTiming.cpp
dom/performance/PerformanceTiming.h
modules/libpref/init/StaticPrefList.h
modules/libpref/init/all.js
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -307,17 +307,16 @@ nsString* nsContentUtils::sControlText =
 nsString* nsContentUtils::sMetaText = nullptr;
 nsString* nsContentUtils::sOSText = nullptr;
 nsString* nsContentUtils::sAltText = nullptr;
 nsString* nsContentUtils::sModifierSeparator = nullptr;
 
 bool nsContentUtils::sInitialized = false;
 bool nsContentUtils::sIsUpgradableDisplayContentPrefEnabled = false;
 bool nsContentUtils::sIsFrameTimingPrefEnabled = false;
-bool nsContentUtils::sIsPerformanceTimingEnabled = false;
 bool nsContentUtils::sIsResourceTimingEnabled = false;
 bool nsContentUtils::sIsPerformanceNavigationTimingEnabled = false;
 bool nsContentUtils::sIsFormAutofillAutocompleteEnabled = false;
 bool nsContentUtils::sSendPerformanceTimingNotifications = false;
 bool nsContentUtils::sUseActivityCursor = false;
 bool nsContentUtils::sAnimationsAPICoreEnabled = false;
 bool nsContentUtils::sGetBoxQuadsEnabled = false;
 bool nsContentUtils::sSkipCursorMoveForSameValueSet = false;
@@ -624,19 +623,16 @@ nsresult nsContentUtils::Init() {
     RegisterStrongMemoryReporter(new DOMEventListenerManagersHashReporter());
   }
 
   sBlockedScriptRunners = new AutoTArray<nsCOMPtr<nsIRunnable>, 8>;
 
   Preferences::AddBoolVarCache(&sAllowXULXBL_for_file,
                                "dom.allow_XUL_XBL_for_file");
 
-  Preferences::AddBoolVarCache(&sIsPerformanceTimingEnabled,
-                               "dom.enable_performance", true);
-
   Preferences::AddBoolVarCache(&sIsResourceTimingEnabled,
                                "dom.enable_resource_timing", true);
 
   Preferences::AddBoolVarCache(&sIsPerformanceNavigationTimingEnabled,
                                "dom.enable_performance_navigation_timing",
                                true);
 
   Preferences::AddBoolVarCache(&sIsUpgradableDisplayContentPrefEnabled,
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2338,23 +2338,16 @@ class nsContentUtils {
    * allowed for the given subject principal. These are only allowed if the user
    * initiated them (like with a mouse-click or key press).
    */
   static bool IsCutCopyAllowed(nsIPrincipal* aSubjectPrincipal);
 
   /*
    * Returns true if the performance timing APIs are enabled.
    */
-  static bool IsPerformanceTimingEnabled() {
-    return sIsPerformanceTimingEnabled;
-  }
-
-  /*
-   * Returns true if the performance timing APIs are enabled.
-   */
   static bool IsResourceTimingEnabled() { return sIsResourceTimingEnabled; }
 
   /*
    * Returns true if the performance timing APIs are enabled.
    */
   static bool IsPerformanceNavigationTimingEnabled() {
     return sIsPerformanceNavigationTimingEnabled;
   }
@@ -3480,17 +3473,16 @@ class nsContentUtils {
   static uint32_t sRunnersCountAtFirstBlocker;
   static uint32_t sScriptBlockerCountWhereRunnersPrevented;
 
   static nsIInterfaceRequestor* sSameOriginChecker;
 
   static bool sIsHandlingKeyBoardEvent;
   static bool sAllowXULXBL_for_file;
   static uint32_t sHandlingInputTimeout;
-  static bool sIsPerformanceTimingEnabled;
   static bool sIsResourceTimingEnabled;
   static bool sIsPerformanceNavigationTimingEnabled;
   static bool sIsUpgradableDisplayContentPrefEnabled;
   static bool sIsFrameTimingPrefEnabled;
   static bool sIsFormAutofillAutocompleteEnabled;
   static bool sSendPerformanceTimingNotifications;
   static bool sUseActivityCursor;
   static bool sAnimationsAPICoreEnabled;
--- a/dom/performance/PerformanceTiming.cpp
+++ b/dom/performance/PerformanceTiming.cpp
@@ -81,17 +81,17 @@ PerformanceTiming::PerformanceTiming(Per
       aChannel, aHttpChannel,
       aPerformance->IsSystemPrincipal()
           ? aZeroTime
           : nsRFPService::ReduceTimePrecisionAsMSecs(
                 aZeroTime, aPerformance->GetRandomTimelineSeed())));
 
   // Non-null aHttpChannel implies that this PerformanceTiming object is being
   // used for subresources, which is irrelevant to this probe.
-  if (!aHttpChannel && nsContentUtils::IsPerformanceTimingEnabled() &&
+  if (!aHttpChannel && StaticPrefs::dom_enable_performance() &&
       IsTopLevelContentDocument()) {
     Telemetry::Accumulate(Telemetry::TIME_TO_RESPONSE_START_MS,
                           mTimingData->ResponseStartHighRes(aPerformance) -
                               mTimingData->ZeroTime());
   }
 }
 
 // Copy the timing info from the channel so we don't need to keep the channel
@@ -108,17 +108,17 @@ PerformanceTimingData::PerformanceTiming
       mAllRedirectsSameOrigin(true),
       mReportCrossOriginRedirect(true),
       mSecureConnection(false),
       mTimingAllowed(true),
       mInitialized(false) {
   mInitialized = !!aChannel;
   mZeroTime = aZeroTime;
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+  if (!StaticPrefs::dom_enable_performance() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     mZeroTime = 0;
   }
 
   nsCOMPtr<nsIURI> uri;
   if (aHttpChannel) {
     aHttpChannel->GetURI(getter_AddRefs(uri));
   } else {
@@ -230,17 +230,17 @@ void PerformanceTimingData::SetPropertie
 
 PerformanceTiming::~PerformanceTiming() {}
 
 DOMHighResTimeStamp PerformanceTimingData::FetchStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
   if (!mFetchStart) {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+    if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return mZeroTime;
     }
     MOZ_ASSERT(!mAsyncOpen.IsNull(),
                "The fetch start time stamp should always be "
                "valid if the performance timing is enabled");
     if (!mAsyncOpen.IsNull()) {
       if (!mWorkerRequestStart.IsNull() && mWorkerRequestStart > mAsyncOpen) {
@@ -280,60 +280,60 @@ bool PerformanceTimingData::CheckAllowed
 
   // Check if the resource is either same origin as the page that started
   // the load, or if the response contains the proper Timing-Allow-Origin
   // header with the domain of the page that started the load.
   return aChannel->TimingAllowCheck(principal);
 }
 
 uint8_t PerformanceTimingData::GetRedirectCount() const {
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return 0;
   }
   if (!mAllRedirectsSameOrigin) {
     return 0;
   }
   return mRedirectCount;
 }
 
 bool PerformanceTimingData::ShouldReportCrossOriginRedirect() const {
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return false;
   }
 
   // If the redirect count is 0, or if one of the cross-origin
   // redirects doesn't have the proper Timing-Allow-Origin header,
   // then RedirectStart and RedirectEnd will be set to zero
   return (mRedirectCount != 0) && mReportCrossOriginRedirect;
 }
 
 DOMHighResTimeStamp PerformanceTimingData::AsyncOpenHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting() || mAsyncOpen.IsNull()) {
     return mZeroTime;
   }
   DOMHighResTimeStamp rawValue =
       TimeStampToDOMHighRes(aPerformance, mAsyncOpen);
   if (aPerformance->IsSystemPrincipal()) {
     return rawValue;
   }
   return nsRFPService::ReduceTimePrecisionAsMSecs(
       rawValue, aPerformance->GetRandomTimelineSeed());
 }
 
 DOMHighResTimeStamp PerformanceTimingData::WorkerStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting() || mWorkerStart.IsNull()) {
     return mZeroTime;
   }
   DOMHighResTimeStamp rawValue =
       TimeStampToDOMHighRes(aPerformance, mWorkerStart);
   if (aPerformance->IsSystemPrincipal()) {
     return rawValue;
   }
@@ -350,17 +350,17 @@ DOMHighResTimeStamp PerformanceTimingDat
  * and PerformanceResourceTiming::RedirectStart() to make such verifications.
  *
  * @return a valid timing if the Performance Timing is enabled
  */
 DOMHighResTimeStamp PerformanceTimingData::RedirectStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   return TimeStampToReducedDOMHighResOrFetchStart(aPerformance, mRedirectStart);
 }
 
 DOMTimeMilliSec PerformanceTiming::RedirectStart() {
   if (!mTimingData->IsInitialized()) {
@@ -385,17 +385,17 @@ DOMTimeMilliSec PerformanceTiming::Redir
  * PerformanceResourceTiming::RedirectEnd() to make such verifications.
  *
  * @return a valid timing if the Performance Timing is enabled
  */
 DOMHighResTimeStamp PerformanceTimingData::RedirectEndHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   return TimeStampToReducedDOMHighResOrFetchStart(aPerformance, mRedirectEnd);
 }
 
 DOMTimeMilliSec PerformanceTiming::RedirectEnd() {
   if (!mTimingData->IsInitialized()) {
@@ -409,34 +409,34 @@ DOMTimeMilliSec PerformanceTiming::Redir
   }
   return 0;
 }
 
 DOMHighResTimeStamp PerformanceTimingData::DomainLookupStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   return TimeStampToReducedDOMHighResOrFetchStart(aPerformance,
                                                   mDomainLookupStart);
 }
 
 DOMTimeMilliSec PerformanceTiming::DomainLookupStart() {
   return static_cast<int64_t>(
       mTimingData->DomainLookupStartHighRes(mPerformance));
 }
 
 DOMHighResTimeStamp PerformanceTimingData::DomainLookupEndHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   // Bug 1155008 - nsHttpTransaction is racy. Return DomainLookupStart when null
   if (mDomainLookupEnd.IsNull()) {
     return DomainLookupStartHighRes(aPerformance);
   }
   DOMHighResTimeStamp rawValue =
@@ -452,17 +452,17 @@ DOMTimeMilliSec PerformanceTiming::Domai
   return static_cast<int64_t>(
       mTimingData->DomainLookupEndHighRes(mPerformance));
 }
 
 DOMHighResTimeStamp PerformanceTimingData::ConnectStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   if (mConnectStart.IsNull()) {
     return DomainLookupEndHighRes(aPerformance);
   }
   DOMHighResTimeStamp rawValue =
       TimeStampToDOMHighRes(aPerformance, mConnectStart);
@@ -476,17 +476,17 @@ DOMHighResTimeStamp PerformanceTimingDat
 DOMTimeMilliSec PerformanceTiming::ConnectStart() {
   return static_cast<int64_t>(mTimingData->ConnectStartHighRes(mPerformance));
 }
 
 DOMHighResTimeStamp PerformanceTimingData::SecureConnectionStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   if (!mSecureConnection) {
     return 0;  // We use 0 here, because mZeroTime is sometimes set to the
                // navigation start time.
   }
   if (mSecureConnectionStart.IsNull()) {
@@ -505,17 +505,17 @@ DOMTimeMilliSec PerformanceTiming::Secur
   return static_cast<int64_t>(
       mTimingData->SecureConnectionStartHighRes(mPerformance));
 }
 
 DOMHighResTimeStamp PerformanceTimingData::ConnectEndHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   // Bug 1155008 - nsHttpTransaction is racy. Return ConnectStart when null
   if (mConnectEnd.IsNull()) {
     return ConnectStartHighRes(aPerformance);
   }
   DOMHighResTimeStamp rawValue =
@@ -530,17 +530,17 @@ DOMHighResTimeStamp PerformanceTimingDat
 DOMTimeMilliSec PerformanceTiming::ConnectEnd() {
   return static_cast<int64_t>(mTimingData->ConnectEndHighRes(mPerformance));
 }
 
 DOMHighResTimeStamp PerformanceTimingData::RequestStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
 
   if (mRequestStart.IsNull()) {
     mRequestStart = mWorkerRequestStart;
   }
 
@@ -550,17 +550,17 @@ DOMHighResTimeStamp PerformanceTimingDat
 DOMTimeMilliSec PerformanceTiming::RequestStart() {
   return static_cast<int64_t>(mTimingData->RequestStartHighRes(mPerformance));
 }
 
 DOMHighResTimeStamp PerformanceTimingData::ResponseStartHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   if (mResponseStart.IsNull() ||
       (!mCacheReadStart.IsNull() && mCacheReadStart < mResponseStart)) {
     mResponseStart = mCacheReadStart;
   }
 
@@ -574,17 +574,17 @@ DOMHighResTimeStamp PerformanceTimingDat
 DOMTimeMilliSec PerformanceTiming::ResponseStart() {
   return static_cast<int64_t>(mTimingData->ResponseStartHighRes(mPerformance));
 }
 
 DOMHighResTimeStamp PerformanceTimingData::ResponseEndHighRes(
     Performance* aPerformance) {
   MOZ_ASSERT(aPerformance);
 
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       nsContentUtils::ShouldResistFingerprinting()) {
     return mZeroTime;
   }
   if (mResponseEnd.IsNull() ||
       (!mCacheReadEnd.IsNull() && mCacheReadEnd < mResponseEnd)) {
     mResponseEnd = mCacheReadEnd;
   }
   if (mResponseEnd.IsNull()) {
@@ -625,17 +625,17 @@ bool PerformanceTiming::IsTopLevelConten
   Unused << docShell->GetSameTypeRootTreeItem(getter_AddRefs(rootItem));
   if (rootItem.get() != static_cast<nsIDocShellTreeItem*>(docShell.get())) {
     return false;
   }
   return rootItem->ItemType() == nsIDocShellTreeItem::typeContent;
 }
 
 nsTArray<nsCOMPtr<nsIServerTiming>> PerformanceTimingData::GetServerTiming() {
-  if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+  if (!StaticPrefs::dom_enable_performance() || !IsInitialized() ||
       !TimingAllowed() || nsContentUtils::ShouldResistFingerprinting()) {
     return nsTArray<nsCOMPtr<nsIServerTiming>>();
   }
 
   return nsTArray<nsCOMPtr<nsIServerTiming>>(mServerTiming);
 }
 
 }  // namespace dom
--- a/dom/performance/PerformanceTiming.h
+++ b/dom/performance/PerformanceTiming.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_PerformanceTiming_h
 #define mozilla_dom_PerformanceTiming_h
 
 #include "mozilla/Attributes.h"
+#include "mozilla/StaticPrefs.h"
 #include "nsContentUtils.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsRFPService.h"
 #include "nsWrapperCache.h"
 #include "Performance.h"
 #include "nsITimedChannel.h"
 
 class nsIHttpChannel;
@@ -239,43 +240,43 @@ class PerformanceTiming final : public n
 
   Performance* GetParentObject() const { return mPerformance; }
 
   virtual JSObject* WrapObject(JSContext* cx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
   // PerformanceNavigation WebIDL methods
   DOMTimeMilliSec NavigationStart() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetNavigationStart();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetNavigationStart(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec UnloadEventStart() {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetUnloadEventStart();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetUnloadEventStart(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec UnloadEventEnd() {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetUnloadEventEnd();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetUnloadEventEnd(),
@@ -291,146 +292,146 @@ class PerformanceTiming final : public n
   DOMTimeMilliSec ConnectStart();
   DOMTimeMilliSec SecureConnectionStart();
   DOMTimeMilliSec ConnectEnd();
   DOMTimeMilliSec RequestStart();
   DOMTimeMilliSec ResponseStart();
   DOMTimeMilliSec ResponseEnd();
 
   DOMTimeMilliSec DomLoading() {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetDomLoading();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetDomLoading(), mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec DomInteractive() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetDomInteractive();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetDomInteractive(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec DomContentLoadedEventStart() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetDomContentLoadedEventStart();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetDomContentLoadedEventStart(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec DomContentLoadedEventEnd() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetDomContentLoadedEventEnd();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetDomContentLoadedEventEnd(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec DomComplete() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetDomComplete();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetDomComplete(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec LoadEventStart() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetLoadEventStart();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetLoadEventStart(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec LoadEventEnd() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetLoadEventEnd();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetLoadEventEnd(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec TimeToNonBlankPaint() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetTimeToNonBlankPaint();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetTimeToNonBlankPaint(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec TimeToContentfulPaint() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetTimeToContentfulPaint();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetTimeToContentfulPaint(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec TimeToDOMContentFlushed() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetTimeToDOMContentFlushed();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetTimeToDOMContentFlushed(),
         mPerformance->GetRandomTimelineSeed());
   }
 
   DOMTimeMilliSec TimeToFirstInteractive() const {
-    if (!nsContentUtils::IsPerformanceTimingEnabled() ||
+    if (!StaticPrefs::dom_enable_performance() ||
         nsContentUtils::ShouldResistFingerprinting()) {
       return 0;
     }
     if (mPerformance->IsSystemPrincipal()) {
       return GetDOMTiming()->GetTimeToTTFI();
     }
     return nsRFPService::ReduceTimePrecisionAsMSecs(
         GetDOMTiming()->GetTimeToTTFI(), mPerformance->GetRandomTimelineSeed());
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -454,16 +454,24 @@ VARCACHE_PREF(
 #undef PREF_VALUE
 
 VARCACHE_PREF(
   "dom.fetchObserver.enabled",
    dom_fetchObserver_enabled,
   RelaxedAtomicBool, false
 )
 
+// Enable Performance API
+// Whether nonzero values can be returned from performance.timing.*
+VARCACHE_PREF(
+  "dom.enable_performance",
+   dom_enable_performance,
+  bool, true
+)
+
 // Enable Performance Observer API
 VARCACHE_PREF(
   "dom.enable_performance_observer",
    dom_enable_performance_observer,
   RelaxedAtomicBool, true
 )
 
 // Render animations and videos as a solid color
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -149,19 +149,16 @@ pref("dom.serviceWorkers.idle_extended_t
 
 // The amount of time (milliseconds) an update request is delayed when triggered
 // by a service worker that doesn't control any clients.
 pref("dom.serviceWorkers.update_delay", 1000);
 
 // Enable test for 24 hours update, service workers will always treat last update check time is over 24 hours
 pref("dom.serviceWorkers.testUpdateOverOneDay", false);
 
-// Whether nonzero values can be returned from performance.timing.*
-pref("dom.enable_performance", true);
-
 // Whether resource timing will be gathered and returned by performance.GetEntries*
 pref("dom.enable_resource_timing", true);
 
 // Whether performance.GetEntries* will contain an entry for the active document
 pref("dom.enable_performance_navigation_timing", true);
 
 // Enable notification of performance timing
 pref("dom.performance.enable_notify_performance_timing", false);