diff --git a/toolkit/components/passwordmgr/LoginManagerContent.jsm b/toolkit/components/passwordmgr/LoginManagerContent.jsm index 7a469548897..a3f2878e90a 100644 --- a/toolkit/components/passwordmgr/LoginManagerContent.jsm +++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm @@ -713,18 +713,20 @@ var LoginManagerContent = { // Don't modify the username field if it's disabled or readOnly so we preserve its case. let disabledOrReadOnly = usernameField.disabled || usernameField.readOnly; + let userNameDiffers = selectedLogin.username != usernameField.value; // Don't replace the username if it differs only in case, and the user triggered // this autocomplete. We assume that if it was user-triggered the entered text // is desired. - let userEnteredDifferentCase = userTriggered && - (usernameField.value != selectedLogin.username && - usernameField.value.toLowerCase() == selectedLogin.username.toLowerCase()); + let userEnteredDifferentCase = userTriggered && userNameDiffers && + usernameField.value.toLowerCase() == selectedLogin.username.toLowerCase(); - if (!disabledOrReadOnly && !userEnteredDifferentCase) { + if (!disabledOrReadOnly && !userEnteredDifferentCase && userNameDiffers) { usernameField.setUserInput(selectedLogin.username); } } - passwordField.setUserInput(selectedLogin.password); + if (passwordField.value != selectedLogin.password) { + passwordField.setUserInput(selectedLogin.password); + } didFillForm = true; } else if (selectedLogin && !autofillForm) { // For when autofillForm is false, but we still have the information diff --git a/toolkit/components/passwordmgr/test/mochitest.ini b/toolkit/components/passwordmgr/test/mochitest.ini index 4f8754b0553..5507e958419 100644 --- a/toolkit/components/passwordmgr/test/mochitest.ini +++ b/toolkit/components/passwordmgr/test/mochitest.ini @@ -61,6 +61,7 @@ skip-if = toolkit == 'android' #TIMED_OUT [test_bug_654348.html] [test_bug_776171.html] [test_input_events.html] +[test_input_events_for_identical_values.html] [test_master_password.html] skip-if = toolkit == 'android' #TIMED_OUT [test_master_password_cleanup.html] diff --git a/toolkit/components/passwordmgr/test/test_input_events_for_identical_values.html b/toolkit/components/passwordmgr/test/test_input_events_for_identical_values.html new file mode 100644 index 00000000000..70d5f08fe2c --- /dev/null +++ b/toolkit/components/passwordmgr/test/test_input_events_for_identical_values.html @@ -0,0 +1,56 @@ + + + + Test for input events in Login Manager when username/password are filled in already + + + + + + +Login Manager test: input events should fire. + + + +

+ +
+ +
+

This is form 1.

+ + + + + +
+ +
+

+
+