Bug 1570212 - Convert dom.testing.sync-content-blocking-notifications to a static pref. r=mccr8
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 02 Aug 2019 11:59:04 +0000
changeset 486126 0502c02439ebfc5dcc73fac0625699dfa51325b0
parent 486125 a035512b4f4417cecab6ad1359efc93d87a9b7f4
child 486127 09628a9faf5919510757d1765090e3d1c811dc1e
push id36390
push usercbrindusan@mozilla.com
push dateMon, 05 Aug 2019 09:54:13 +0000
treeherdermozilla-central@d681969e4480 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1570212
milestone70.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 1570212 - Convert dom.testing.sync-content-blocking-notifications to a static pref. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D40155
dom/base/nsGlobalWindowOuter.cpp
modules/libpref/init/StaticPrefList.yaml
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -306,18 +306,16 @@ using mozilla::TimeStamp;
   return GetCurrentInnerWindowInternal()->method args;  \
   PR_END_MACRO
 
 static LazyLogModule gDOMLeakPRLogOuter("DOMLeakOuter");
 extern LazyLogModule gPageCacheLog;
 
 static int32_t gOpenPopupSpamCount = 0;
 
-static bool gSyncContentBlockingNotifications = false;
-
 nsGlobalWindowOuter::OuterWindowByIdTable*
     nsGlobalWindowOuter::sOuterWindowsById = nullptr;
 
 /* static */
 nsPIDOMWindowOuter* nsPIDOMWindowOuter::GetFromCurrentInner(
     nsPIDOMWindowInner* aInner) {
   if (!aInner) {
     return nullptr;
@@ -5423,24 +5421,16 @@ void nsGlobalWindowOuter::NotifyContentB
   nsCOMPtr<Document> doc = docShell->GetDocument();
   NS_ENSURE_TRUE_VOID(doc);
 
   nsCOMPtr<nsIURI> uri(aURIHint);
   nsCOMPtr<nsIChannel> channel(aChannel);
   nsCOMPtr<nsIClassifiedChannel> trackingChannel =
       do_QueryInterface(aTrackingChannel);
 
-  static bool prefInitialized = false;
-  if (!prefInitialized) {
-    Preferences::AddBoolVarCache(
-        &gSyncContentBlockingNotifications,
-        "dom.testing.sync-content-blocking-notifications", false);
-    prefInitialized = true;
-  }
-
   nsCOMPtr<nsIRunnable> func = NS_NewRunnableFunction(
       "NotifyContentBlockingEventDelayed",
       [doc, docShell, uri, channel, aEvent, aBlocked, aReason,
        trackingChannel]() {
         // This event might come after the user has navigated to another
         // page. To prevent showing the TrackingProtection UI on the wrong
         // page, we need to check that the loading URI for the channel is
         // the same as the URI currently loaded in the document.
@@ -5577,17 +5567,17 @@ void nsGlobalWindowOuter::NotifyContentB
           // changed
           return;
         }
 
         nsDocShell::Cast(docShell)->nsDocLoader::OnContentBlockingEvent(channel,
                                                                         event);
       });
   nsresult rv;
-  if (gSyncContentBlockingNotifications) {
+  if (StaticPrefs::dom_testing_sync_content_blocking_notifications()) {
     rv = func->Run();
   } else {
     rv = NS_DispatchToCurrentThreadQueue(func.forget(), 100,
                                          EventQueuePriority::Idle);
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1973,16 +1973,21 @@
   value: false
   mirror: always
 
 - name: dom.testing.structuredclonetester.enabled
   type: RelaxedAtomicBool
   value: false
   mirror: always
 
+- name: dom.testing.sync-content-blocking-notifications
+  type: bool
+  value: false
+  mirror: always
+
 # Time (in ms) that it takes to regenerate 1ms.
 - name: dom.timeout.background_budget_regeneration_rate
   type: int32_t
   value: 100
   mirror: always
 
 # Time (in ms) that it takes to regenerate 1ms.
 - name: dom.timeout.foreground_budget_regeneration_rate