Bug 1507353 - Convert the accesses to security.insecure_connection_*.* prefs into lazy getters r=johannh
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 20 Nov 2018 20:04:14 +0000
changeset 503805 897e034e2b4eb0af24529d1a454f8bf60ba9f755
parent 503804 026d0eca5d0ebc6f25ef0b2f71450bb8793002a4
child 503806 61a3be9a8fadeaa115abddde754576b36ef0f229
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1507353
milestone65.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 1507353 - Convert the accesses to security.insecure_connection_*.* prefs into lazy getters r=johannh Differential Revision: https://phabricator.services.mozilla.com/D11968
browser/base/content/browser-siteIdentity.js
browser/base/content/test/performance/browser_preferences_usage.js
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -202,16 +202,41 @@ var gIdentityHandler = {
     delete this._permissionAnchors;
     let permissionAnchors = {};
     for (let anchor of document.getElementById("blocked-permissions-container").children) {
       permissionAnchors[anchor.getAttribute("data-permission-id")] = anchor;
     }
     return this._permissionAnchors = permissionAnchors;
   },
 
+  get _insecureConnectionIconEnabled() {
+    delete this._insecureConnectionIconEnabled;
+    XPCOMUtils.defineLazyPreferenceGetter(this, "_insecureConnectionIconEnabled",
+                                          "security.insecure_connection_icon.enabled");
+    return this._insecureConnectionIconEnabled;
+  },
+  get _insecureConnectionIconPBModeEnabled() {
+    delete this._insecureConnectionIconPBModeEnabled;
+    XPCOMUtils.defineLazyPreferenceGetter(this, "_insecureConnectionIconPBModeEnabled",
+                                          "security.insecure_connection_icon.pbmode.enabled");
+    return this._insecureConnectionIconPBModeEnabled;
+  },
+  get _insecureConnectionTextEnabled() {
+    delete this._insecureConnectionTextEnabled;
+    XPCOMUtils.defineLazyPreferenceGetter(this, "_insecureConnectionTextEnabled",
+                                          "security.insecure_connection_text.enabled");
+    return this._insecureConnectionTextEnabled;
+  },
+  get _insecureConnectionTextPBModeEnabled() {
+    delete this._insecureConnectionTextPBModeEnabled;
+    XPCOMUtils.defineLazyPreferenceGetter(this, "_insecureConnectionTextPBModeEnabled",
+                                          "security.insecure_connection_text.pbmode.enabled");
+    return this._insecureConnectionTextPBModeEnabled;
+  },
+
   /**
    * Handles clicks on the "Clear Cookies and Site Data" button.
    */
   async clearSiteData(event) {
     if (!this._uriHasHost) {
       return;
     }
 
@@ -520,24 +545,24 @@ var gIdentityHandler = {
         } else if (this._isMixedActiveContentBlocked) {
           this._identityBox.classList.add("mixedDisplayContentLoadedActiveBlocked");
         } else if (this._isMixedPassiveContentLoaded) {
           this._identityBox.classList.add("mixedDisplayContent");
         } else {
           this._identityBox.classList.add("weakCipher");
         }
       } else {
-        let warnOnInsecure = Services.prefs.getBoolPref("security.insecure_connection_icon.enabled") ||
-                             (Services.prefs.getBoolPref("security.insecure_connection_icon.pbmode.enabled") &&
+        let warnOnInsecure = this._insecureConnectionIconEnabled ||
+                             (this._insecureConnectionIconPBModeEnabled &&
                              PrivateBrowsingUtils.isWindowPrivate(window));
         let className = warnOnInsecure ? "notSecure" : "unknownIdentity";
         this._identityBox.className = className;
 
-        let warnTextOnInsecure = Services.prefs.getBoolPref("security.insecure_connection_text.enabled") ||
-                                 (Services.prefs.getBoolPref("security.insecure_connection_text.pbmode.enabled") &&
+        let warnTextOnInsecure = this._insecureConnectionTextEnabled ||
+                                 (this._insecureConnectionTextPBModeEnabled &&
                                  PrivateBrowsingUtils.isWindowPrivate(window));
         if (warnTextOnInsecure) {
           icon_label = gNavigatorBundle.getString("identity.notSecure.label");
           this._identityBox.classList.add("notSecureText");
         }
       }
       if (this._hasInsecureLoginForms) {
         // Insecure login forms can only be present on "unknown identity"
--- a/browser/base/content/test/performance/browser_preferences_usage.js
+++ b/browser/base/content/test/performance/browser_preferences_usage.js
@@ -125,32 +125,16 @@ add_task(async function open_10_tabs() {
   let whitelist = {
     "layout.css.dpi": {
       max: 35,
     },
     "browser.zoom.full": {
       min: 10,
       max: 25,
     },
-    "security.insecure_connection_icon.pbmode.enabled": {
-      min: 10,
-      max: 18,
-    },
-    "security.insecure_connection_icon.enabled": {
-      min: 10,
-      max: 18,
-    },
-    "security.insecure_connection_text.enabled": {
-      min: 10,
-      max: 18,
-    },
-    "security.insecure_connection_text.pbmode.enabled": {
-      min: 10,
-      max: 18,
-    },
     "browser.startup.record": {
       max: 20,
     },
     "browser.tabs.remote.logSwitchTiming": {
       max: 25,
     },
     "network.loadinfo.skip_type_assertion": {
       // This is accessed in debug only.
@@ -182,32 +166,16 @@ add_task(async function navigate_around(
   let whitelist = {
     "browser.zoom.full": {
       min: 100,
       max: 110,
     },
     "network.loadinfo.skip_type_assertion": {
       // This is accessed in debug only.
     },
-    "security.insecure_connection_icon.pbmode.enabled": {
-      min: 20,
-      max: 60,
-    },
-    "security.insecure_connection_icon.enabled": {
-      min: 20,
-      max: 60,
-    },
-    "security.insecure_connection_text.enabled": {
-      min: 20,
-      max: 60,
-    },
-    "security.insecure_connection_text.pbmode.enabled": {
-      min: 20,
-      max: 60,
-    },
     "toolkit.cosmeticAnimations.enabled": {
       min: 45,
       max: 55,
     },
   };
 
   Services.prefs.resetStats();