Bug 1519137 - Add lazy pref getter for content blocking before initializing blockers. r=ewright, a=RyanVM
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 10 Jan 2019 17:51:31 +0000
changeset 506660 d566c5f82f8b4d53ed05bc8836ea0b9d7dee051c
parent 506659 138a3eb773c865898c1f43e53aa9b3b39e2f38d4
child 506661 5b52f9f8300439f6f58beead39f28ee22faf4863
push id10501
push userryanvm@gmail.com
push dateSat, 12 Jan 2019 21:41:05 +0000
treeherdermozilla-beta@5b52f9f83004 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersewright, RyanVM
bugs1519137
milestone65.0
Bug 1519137 - Add lazy pref getter for content blocking before initializing blockers. r=ewright, a=RyanVM This was causing some prefs that blockers were accessing not to be set yet. Differential Revision: https://phabricator.services.mozilla.com/D16208
browser/base/content/browser-contentblocking.js
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -596,41 +596,41 @@ var ContentBlocking = {
     let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
     this.reportBreakageLearnMore.href = baseURL + "blocking-breakage";
 
     this.updateAnimationsEnabled = () => {
       this.iconBox.toggleAttribute("animationsenabled",
         Services.prefs.getBoolPref(this.PREF_ANIMATIONS_ENABLED, false));
     };
 
-    for (let blocker of this.blockers) {
-      if (blocker.init) {
-        blocker.init();
-      }
-    }
-
-    this.updateAnimationsEnabled();
-
-    Services.prefs.addObserver(this.PREF_ANIMATIONS_ENABLED, this.updateAnimationsEnabled);
-
     XPCOMUtils.defineLazyPreferenceGetter(this, "showBlockedLabels",
       this.PREF_SHOW_BLOCKED_LABELS, false, () => {
         for (let blocker of this.blockers) {
           blocker.updateCategoryLabel();
         }
     });
     XPCOMUtils.defineLazyPreferenceGetter(this, "showAllowedLabels",
       this.PREF_SHOW_ALLOWED_LABELS, false, () => {
         for (let blocker of this.blockers) {
           blocker.updateCategoryLabel();
         }
     });
     XPCOMUtils.defineLazyPreferenceGetter(this, "reportBreakageEnabled",
       this.PREF_REPORT_BREAKAGE_ENABLED, false);
 
+    for (let blocker of this.blockers) {
+      if (blocker.init) {
+        blocker.init();
+      }
+    }
+
+    this.updateAnimationsEnabled();
+
+    Services.prefs.addObserver(this.PREF_ANIMATIONS_ENABLED, this.updateAnimationsEnabled);
+
     this.appMenuLabel.setAttribute("value", this.strings.appMenuTitle);
     this.appMenuLabel.setAttribute("tooltiptext", this.strings.appMenuTooltip);
 
     this.activeTooltipText =
       gNavigatorBundle.getString("trackingProtection.icon.activeTooltip");
     this.disabledTooltipText =
       gNavigatorBundle.getString("trackingProtection.icon.disabledTooltip");
     this.updateCBCategoryLabel = this.updateCBCategoryLabel.bind(this);