Bug 1631437 - fix display of smtp authentication method. r=khushil
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Tue, 28 Apr 2020 13:51:31 +0300
changeset 38060 ed17a22ae3d993d170302dadc067168391d3bb30
parent 38059 fd16d22d04fa421ab6552ba8e6b7bde56235e9d4
child 38061 9f5657fd0e4e1928cfde34a8949018c7c24a63b1
push id2595
push userclokep@gmail.com
push dateMon, 04 May 2020 19:02:04 +0000
treeherdercomm-beta@f53913797371 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhushil
bugs1631437
Bug 1631437 - fix display of smtp authentication method. r=khushil
mailnews/base/prefs/content/SmtpServerEdit.js
mailnews/base/prefs/content/am-smtp.js
--- a/mailnews/base/prefs/content/SmtpServerEdit.js
+++ b/mailnews/base/prefs/content/SmtpServerEdit.js
@@ -5,16 +5,19 @@
 
 var { cleanUpHostName, isLegalHostNameOrIP } = ChromeUtils.import(
   "resource:///modules/hostnameUtils.jsm"
 );
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { MailServices } = ChromeUtils.import(
   "resource:///modules/MailServices.jsm"
 );
+var { OAuth2Providers } = ChromeUtils.import(
+  "resource:///modules/OAuth2Providers.jsm"
+);
 
 var gSmtpServer;
 var gSmtpUsername;
 var gSmtpDescription;
 var gSmtpUsernameLabel;
 var gSmtpHostname;
 var gSmtpPort;
 var gSmtpAuthMethod;
@@ -107,16 +110,20 @@ function initSmtpSettings(server) {
 
   sslChanged(false);
   authMethodChanged(false);
 
   if (MailServices.smtp.defaultServer) {
     onLockPreference();
   }
 
+  // Hide OAuth2 option if we can't use it.
+  let details = OAuth2Providers.getHostnameDetails(server.hostname);
+  document.getElementById("authMethod-oauth2").hidden = !details;
+
   // Hide deprecated/hidden auth options, unless selected
   hideUnlessSelected(document.getElementById("authMethod-anysecure"));
   hideUnlessSelected(document.getElementById("authMethod-any"));
 
   // "STARTTLS, if available" is vulnerable to MITM attacks so we shouldn't
   // allow users to choose it anymore. Hide the option unless the user already
   // has it set.
   hideUnlessSelected(document.getElementById("connectionSecurityType-1"));
--- a/mailnews/base/prefs/content/am-smtp.js
+++ b/mailnews/base/prefs/content/am-smtp.js
@@ -5,20 +5,16 @@
 
 /* import-globals-from amUtils.js */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { MailServices } = ChromeUtils.import(
   "resource:///modules/MailServices.jsm"
 );
 
-var { OAuth2Providers } = ChromeUtils.import(
-  "resource:///modules/OAuth2Providers.jsm"
-);
-
 var gSmtpServerListWindow = {
   mBundle: null,
   mServerList: null,
   mAddButton: null,
   mEditButton: null,
   mDeleteButton: null,
   mSetDefaultServerButton: null,
 
@@ -173,26 +169,16 @@ var gSmtpServerListWindow = {
       default:
         // leave empty
         Cu.reportError(
           "Warning: unknown value for smtpserver... authMethod: " +
             aServer.authMethod
         );
     }
     if (authStr) {
-      // This is causing a mochitest failure. Mochitest will not move
-      // ahead and it will get stuck. We don't have any element with id
-      // "authMethod-oauth2" so this needs inspection.
-      //
-      // let details = OAuth2Providers.getHostnameDetails(aServer.hostname);
-      // if (!details) {
-      //   document
-      //     .getElementById("authMethod-oauth2")
-      //     .toggleAttribute("disabled", true);
-      // }
       document.getElementById("authMethodValue").value = this.mBundle.getString(
         authStr
       );
     }
   },
 
   refreshServerList(aServerKeyToSelect, aFocusList) {
     // remove all children