bug 1498758 - Update placeholder value of DNS over HTTPS input, add default pref value r=jduell
authorErica Wright <ewright@mozilla.com>
Sat, 13 Oct 2018 02:16:31 +0000
changeset 499424 b2dc8c549bc4bd48d05c6146c9b1daad0645f94e
parent 499423 ebaf166c573104897304cf5b0143eba1bd2c8960
child 499425 f17dfd86498ec12d828373d6b7b2d76f29983d22
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs1498758
milestone64.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 1498758 - Update placeholder value of DNS over HTTPS input, add default pref value r=jduell Update placeholder value of DNS over HTTPS input to the cloudflare provider add a default pref value for network.trr.uri Differential Revision: https://phabricator.services.mozilla.com/D8639
browser/components/preferences/connection.js
browser/components/preferences/connection.xul
browser/components/preferences/in-content/tests/browser_connection_dnsoverhttps.js
modules/libpref/init/all.js
--- a/browser/components/preferences/connection.js
+++ b/browser/components/preferences/connection.js
@@ -37,16 +37,17 @@ Preferences.addAll([
   { id: "network.trr.uri", type: "string" },
 ]);
 
 window.addEventListener("DOMContentLoaded", () => {
   Preferences.get("network.proxy.type").on("change",
     gConnectionsDialog.proxyTypeChanged.bind(gConnectionsDialog));
   Preferences.get("network.proxy.socks_version").on("change",
     gConnectionsDialog.updateDNSPref.bind(gConnectionsDialog));
+  gConnectionsDialog.initDnsOverHttpsUI();
 
   document
     .getElementById("disableProxyExtension")
     .addEventListener(
       "command", makeDisableControllingExtension(
         PREF_SETTING_TYPE, PROXY_KEY).bind(gConnectionsDialog));
   gConnectionsDialog.updateProxySettingsUI();
   initializeProxyUI(gConnectionsDialog);
@@ -305,9 +306,14 @@ var gConnectionsDialog = {
 
   writeDnsOverHttpsUri() {
     // called to update pref with user input
     let input = document.getElementById("networkDnsOverHttpsUrl");
     let uriString = input.value.trim();
     // turn an empty string into `undefined` to clear the pref back to the default
     return uriString.length ? uriString : undefined;
   },
+
+  initDnsOverHttpsUI() {
+    let input = document.getElementById("networkDnsOverHttpsUrl");
+    input.placeholder = Preferences.get("network.trr.uri").defaultValue;
+  },
 };
--- a/browser/components/preferences/connection.xul
+++ b/browser/components/preferences/connection.xul
@@ -154,14 +154,13 @@
               data-l10n-id="connection-dns-over-https"
               preference="network.trr.mode"
               onsyncfrompreference="return gConnectionsDialog.readDnsOverHttpsMode();"
               onsynctopreference="return gConnectionsDialog.writeDnsOverHttpsMode()" />
     <hbox class="indent" flex="1" align="center">
       <label control="networkDnsOverHttpsUrl" data-l10n-id="connection-dns-over-https-url"
              data-l10n-attrs="tooltiptext"/>
       <textbox id="networkDnsOverHttpsUrl" flex="1" preference="network.trr.uri"
-               placeholder="https://doh.example.com/dns-query"
                onsynctopreference="return gConnectionsDialog.writeDnsOverHttpsUri()" />
     </hbox>
     <separator/>
   </vbox>
 </dialog>
--- a/browser/components/preferences/in-content/tests/browser_connection_dnsoverhttps.js
+++ b/browser/components/preferences/in-content/tests/browser_connection_dnsoverhttps.js
@@ -3,17 +3,17 @@ ChromeUtils.import("resource://gre/modul
 const SUBDIALOG_URL = "chrome://browser/content/preferences/connection.xul";
 const TRR_MODE_PREF = "network.trr.mode";
 const TRR_URI_PREF = "network.trr.uri";
 
 const modeCheckboxSelector = "#networkDnsOverHttps";
 const uriTextboxSelector = "#networkDnsOverHttpsUrl";
 const defaultPrefValues = Object.freeze({
   [TRR_MODE_PREF]: 0,
-  [TRR_URI_PREF]: "",
+  [TRR_URI_PREF]: "https://mozilla.cloudflare-dns.com/dns-query",
 });
 
 function resetPrefs() {
   Services.prefs.clearUserPref(TRR_MODE_PREF);
   Services.prefs.clearUserPref(TRR_URI_PREF);
 }
 
 let preferencesOpen = new Promise(res => open_preferences(res));
@@ -122,30 +122,30 @@ add_task(async function default_values()
   is(modePref, defaultPrefValues[TRR_MODE_PREF],
      `Actual value of ${TRR_MODE_PREF} matches expected default value`);
   is(uriPref, defaultPrefValues[TRR_URI_PREF],
      `Actual value of ${TRR_MODE_PREF} matches expected default value`);
 });
 
 let testVariations = [
   // verify state with defaults
-  { expectedModePref: 0, expectedUriValue: "" },
+  { expectedModePref: 0, expectedUriValue: "https://mozilla.cloudflare-dns.com/dns-query" },
 
   // verify each of the modes maps to the correct checked state
   { [TRR_MODE_PREF]: 0, expectedModeChecked: false },
   { [TRR_MODE_PREF]: 1, expectedModeChecked: true },
   { [TRR_MODE_PREF]: 2, expectedModeChecked: true },
   { [TRR_MODE_PREF]: 3, expectedModeChecked: true },
   { [TRR_MODE_PREF]: 4, expectedModeChecked: true },
   { [TRR_MODE_PREF]: 5, expectedModeChecked: false },
   // verify an out of bounds mode value maps to the correct checked state
   { [TRR_MODE_PREF]: 77, expectedModeChecked: false },
 
   // verify toggling the checkbox gives the right outcomes
-  { clickMode: true, expectedModeValue: 2, expectedUriValue: "" },
+  { clickMode: true, expectedModeValue: 2, expectedUriValue: "https://mozilla.cloudflare-dns.com/dns-query" },
   {
     [TRR_MODE_PREF]: 4,
     expectedModeChecked: true, clickMode: true, expectedModePref: 0,
   },
   {
     [TRR_MODE_PREF]: 2, [TRR_URI_PREF]: "https://example.com",
     expectedModeValue: true, expectedUriValue: "https://example.com",
   },
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5428,17 +5428,17 @@ pref("network.captive-portal-service.max
 // Every 10 checks, the delay is increased by a factor of 5
 pref("network.captive-portal-service.backoffFactor", "5.0");
 pref("network.captive-portal-service.enabled", false);
 
 // DNS Trusted Recursive Resolver
 // 0 - default off, 1 - race, 2 TRR first, 3 TRR only, 4 shadow, 5 off by choice
 pref("network.trr.mode", 0);
 // DNS-over-HTTP service to use, must be HTTPS://
-pref("network.trr.uri", "");
+pref("network.trr.uri", "https://mozilla.cloudflare-dns.com/dns-query");
 // credentials to pass to DOH end-point
 pref("network.trr.credentials", "");
 // Wait for captive portal confirmation before enabling TRR
 #if defined(ANDROID)
 // On Android, the captive portal is handled by the OS itself
 pref("network.trr.wait-for-portal", false);
 #else
 pref("network.trr.wait-for-portal", true);