Skip to content
Snippets Groups Projects
Commit 0fad6e4b authored by Sean McArthur's avatar Sean McArthur
Browse files

Merge pull request #2217 from mozilla/issue_406_authenticate_keypress

Fix the user going back to the "enter email" state if they select an email using auto-complete and then type CTRL-C on the email address.
parents ce47dd5b 4dc6dbc1
No related branches found
No related tags found
No related merge requests found
...@@ -126,8 +126,10 @@ BrowserID.Modules.Authenticate = (function() { ...@@ -126,8 +126,10 @@ BrowserID.Modules.Authenticate = (function() {
function enterEmailState() { function enterEmailState() {
/*jshint validthis: true*/ /*jshint validthis: true*/
var self=this;
if (!dom.is("#email", ":disabled")) { if (!dom.is("#email", ":disabled")) {
this.submit = checkEmail; self.publish("enter_email");
self.submit = checkEmail;
showHint("start"); showHint("start");
} }
} }
...@@ -157,7 +159,7 @@ BrowserID.Modules.Authenticate = (function() { ...@@ -157,7 +159,7 @@ BrowserID.Modules.Authenticate = (function() {
} }
} }
function emailKeyUp() { function emailChange() {
/*jshint validthis: true*/ /*jshint validthis: true*/
var newEmail = dom.getInner("#email"); var newEmail = dom.getInner("#email");
if (newEmail !== lastEmail) { if (newEmail !== lastEmail) {
...@@ -191,7 +193,10 @@ BrowserID.Modules.Authenticate = (function() { ...@@ -191,7 +193,10 @@ BrowserID.Modules.Authenticate = (function() {
dialogHelpers.showRPTosPP.call(self); dialogHelpers.showRPTosPP.call(self);
} }
self.bind("#email", "keyup", emailKeyUp); self.bind("#email", "keyup", emailChange);
// Adding the change event causes the email to be checked whenever an
// element blurs but it has been updated via autofill. See issue #406
self.bind("#email", "change", emailChange);
self.click("#forgotPassword", forgotPassword); self.click("#forgotPassword", forgotPassword);
Module.sc.start.call(self, options); Module.sc.start.call(self, options);
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
// The first time the password is shown, change the email address. The // The first time the password is shown, change the email address. The
// second time the password is shown, make sure the password was cleared. // second time the password is shown, make sure the password was cleared.
if(enterPasswordCount == 0) { if(enterPasswordCount === 0) {
// simulate the user changing the email address. This should clear the // simulate the user changing the email address. This should clear the
// password. // password.
$("#password").val("password"); $("#password").val("password");
...@@ -145,6 +145,40 @@ ...@@ -145,6 +145,40 @@
controller.checkEmail(); controller.checkEmail();
}); });
asyncTest("do not clear password if user selects an email address using autofill, then presses a key that does not change the address (CTRL-C for instance)", function() {
xhr.useResult("known_secondary");
// This test is for issue #406
// First, see the staps after this handler.
mediator.subscribe("enter_password", function() {
// The user is now looking at the password field and they decide to copy
// from the email field by hitting CTRL-C.
//
// Simulates the user hitting a key that does not change the
// input. The user should NOT go back to the "enter_email" state at this
// point.
var enterEmailCount = 0;
mediator.subscribe("enter_email", function() {
enterEmailCount++;
});
$("#email").keyup();
equal(enterEmailCount, 0, "enter_email not called after submit if keyup did not change email field");
start();
});
// Simulates the user selecting testuser@testuser.com from the
// autocomplete menu.
$("#email").val("registered@testuser.com");
$("#email").change();
// Simulate the user hitting the "next" button. Once the address is
// verified, the enter_password message will be triggered.
controller.submit();
});
asyncTest("checkEmail with email that has IdP support - 'primary_user' message", function() { asyncTest("checkEmail with email that has IdP support - 'primary_user' message", function() {
$("#email").val("unregistered@testuser.com"); $("#email").val("unregistered@testuser.com");
xhr.useResult("primary"); xhr.useResult("primary");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment