Bug 1534903 - Don't show only the View Saved Logins footer upon focusing a non-empty password field. r=jaws
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 15 Mar 2019 20:36:01 +0000
changeset 525335 a645622faf21365beb94094ed3f4274f0b00e88b
parent 525334 54ae8fe6502b06eb1523b6d249299367e3834deb
child 525336 341fa541129c3c57de510671e29a5db5acf4956e
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1534903
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 1534903 - Don't show only the View Saved Logins footer upon focusing a non-empty password field. r=jaws If the field is insecure then we do want to show the footer below the insecure warning. Differential Revision: https://phabricator.services.mozilla.com/D23629
toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
--- a/toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
+++ b/toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
@@ -46,17 +46,24 @@ function LoginAutoCompleteResult(aSearch
         duplicates.add(login.username);
       }
       seen.add(login.username);
     }
     return duplicates;
   }
 
   this._showInsecureFieldWarning = (!isSecure && LoginHelper.showInsecureFieldWarning) ? 1 : 0;
-  this._showAutoCompleteFooter = (LoginHelper.showAutoCompleteFooter && LoginHelper.enabled) ? 1 : 0;
+  this._showAutoCompleteFooter = 0;
+  // We need to check LoginHelper.enabled here since the insecure warning should
+  // appear even if pwmgr is disabled but the footer should never appear in that case.
+  if (LoginHelper.showAutoCompleteFooter && LoginHelper.enabled) {
+    // Don't show the footer on non-empty password fields as it's not providing
+    // value and only adding noise since a password was already filled.
+    this._showAutoCompleteFooter = (!isPasswordField || !aSearchString) ? 1 : 0;
+  }
   this.searchString = aSearchString;
   this.logins = matchingLogins.sort(loginSort);
   this.matchCount = matchingLogins.length + this._showInsecureFieldWarning + this._showAutoCompleteFooter;
   this._messageManager = messageManager;
   this._stringBundle = Services.strings.createBundle("chrome://passwordmgr/locale/passwordmgr.properties");
   this._dateAndTimeFormatter = new Services.intl.DateTimeFormat(undefined, { dateStyle: "medium" });
 
   this._isPasswordField = isPasswordField;
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
@@ -878,23 +878,21 @@ add_task(async function test_form13_stay
   synthesizeKey("KEY_Delete");
 
   await spinEventLoop();
   let popupState = await getPopupState();
   is(popupState.open, true, "Check popup is still open");
   checkACForm("", "prefilled");
 
   info("testing password field");
+  synthesizeMouseAtCenter(pword, {});
+  pword.select();
+  popupState = await getPopupState();
+  is(popupState.open, false, "Check popup closed since password field isn't empty");
   shownPromise = promiseACShown();
-  synthesizeMouseAtCenter(pword, {});
-  await shownPromise;
-  pword.select();
   synthesizeKey("KEY_Delete");
-
-  await spinEventLoop();
-  popupState = await getPopupState();
-  is(popupState.open, true, "Check popup is still open");
+  await shownPromise;
   checkACForm("", "");
 });
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
@@ -889,23 +889,21 @@ add_task(async function test_form13_stay
   synthesizeKey("KEY_Delete");
 
   await spinEventLoop();
   let popupState = await getPopupState();
   is(popupState.open, true, "Check popup is still open");
   checkACForm("", "prefilled");
 
   info("testing password field");
+  synthesizeMouseAtCenter(pword, {});
+  pword.select();
+  popupState = await getPopupState();
+  is(popupState.open, false, "Check popup closed since password field isn't empty");
   shownPromise = promiseACShown();
-  synthesizeMouseAtCenter(pword, {});
-  await shownPromise;
-  pword.select();
   synthesizeKey("KEY_Delete");
-
-  await spinEventLoop();
-  popupState = await getPopupState();
-  is(popupState.open, true, "Check popup is still open");
+  await shownPromise;
   checkACForm("", "");
 });
 </script>
 </pre>
 </body>
 </html>