Bug 1499795 - Disabling DoH about:preferences controls when the network.trr.mode pref is locked. r=jaws
authorJonathan Kingston <jkt@mozilla.com>
Wed, 06 Mar 2019 10:23:10 +0000
changeset 520455 0f706ba8fc8dd215149421cd278f400318e2a37b
parent 520454 2993263a193c4b455915e78f45b03c27b839e075
child 520456 b25ed3efc1b313962d3d360db7cedf033dadd27e
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1499795
milestone67.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 1499795 - Disabling DoH about:preferences controls when the network.trr.mode pref is locked. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D22172
browser/components/preferences/connection.js
--- a/browser/components/preferences/connection.js
+++ b/browser/components/preferences/connection.js
@@ -282,28 +282,32 @@ var gConnectionsDialog = {
       hideControllingExtension(PROXY_KEY);
       setInputsDisabledState(false);
     } else {
       handleControllingExtension(PREF_SETTING_TYPE, PROXY_KEY)
         .then(setInputsDisabledState);
     }
   },
 
+  isDnsOverHttpsLocked() {
+    return Services.prefs.prefIsLocked("network.trr.mode");
+  },
+
   isDnsOverHttpsEnabled() {
     // values outside 1:4 are considered falsey/disabled in this context
     let trrPref = Preferences.get("network.trr.mode");
     let enabled = trrPref.value > 0 && trrPref.value < 5;
     return enabled;
   },
 
   readDnsOverHttpsMode() {
     // called to update checked element property to reflect current pref value
     let enabled = this.isDnsOverHttpsEnabled();
     let uriPref = Preferences.get("network.trr.uri");
-    uriPref.disabled = !enabled;
+    uriPref.disabled = !enabled || this.isDnsOverHttpsLocked();
     return enabled;
   },
 
   writeDnsOverHttpsMode() {
     // called to update pref with user change
     let trrModeCheckbox = document.getElementById("networkDnsOverHttps");
     // we treat checked/enabled as mode 2
     return trrModeCheckbox.checked ? 2 : 0;
@@ -314,17 +318,35 @@ var gConnectionsDialog = {
     // Disable the custom radio button if the parent checkbox is not selected.
     let parentCheckbox = document.getElementById("networkDnsOverHttps");
     let customDnsOverHttpsUrlRadio = document.getElementById("customDnsOverHttpsUrlRadio");
     let customDnsOverHttpsInput = document.getElementById("customDnsOverHttpsInput");
     customDnsOverHttpsInput.disabled = !parentCheckbox.checked || !customDnsOverHttpsUrlRadio.selected;
     customDnsOverHttpsUrlRadio.disabled = !parentCheckbox.checked;
   },
 
+  getDnsOverHttpsControls() {
+    return [
+      document.getElementById("networkDnsOverHttps"),
+      document.getElementById("customDnsOverHttpsUrlRadio"),
+      document.getElementById("defaultDnsOverHttpsUrlRadio"),
+      document.getElementById("customDnsOverHttpsInput"),
+    ];
+  },
+
+  disableDnsOverHttpsUI(disabled) {
+    for (let element of this.getDnsOverHttpsControls()) {
+      element.disabled = disabled;
+    }
+  },
+
   initDnsOverHttpsUI() {
+    // If we have a locked pref disable the UI.
+    this.disableDnsOverHttpsUI(this.isDnsOverHttpsLocked());
+
     let defaultDnsOverHttpsUrlRadio = document.getElementById("defaultDnsOverHttpsUrlRadio");
     let defaultPrefUrl = Preferences.get("network.trr.uri").defaultValue;
     document.l10n.setAttributes(defaultDnsOverHttpsUrlRadio, "connection-dns-over-https-url-default", {
       url: defaultPrefUrl,
     });
     defaultDnsOverHttpsUrlRadio.value = defaultPrefUrl;
     let radioGroup = document.getElementById("DnsOverHttpsUrlRadioGroup");
     radioGroup.selectedIndex = Preferences.get("network.trr.uri").hasUserValue ? 1 : 0;