Bug 1243729 - Part III, Test for change password form, r=MattN draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Wed, 06 Apr 2016 14:28:06 +0800
changeset 348006 2fb28205c290fce3eb460588ad8e99fc5d63a4ae
parent 348005 141533d3efc6f9d3ddf522643680cb7dac3b7ee0
child 517761 d4d79a8e063ad647f62ac5135ee7994006eacb20
push id14726
push userbmo:timdream@gmail.com
push dateWed, 06 Apr 2016 09:29:19 +0000
reviewersMattN
bugs1243729
milestone48.0a1
Bug 1243729 - Part III, Test for change password form, r=MattN MozReview-Commit-ID: 5PoY6OZ74XX
toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
--- a/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
@@ -474,16 +474,44 @@ add_task(function* test_change2pw0unExis
   is(login.password, "notifyp1", "Check the password unchanged");
   is(login.timesUsed, 2, "Check times used incremented");
 
   checkOnlyLoginWasUsedTwice({ justChanged: false });
 
   Services.logins.removeLogin(login2);
 });
 
+add_task(function* test_changeUPLoginOnPUpdateForm() {
+  info("Check for change-password popup, u+p login on password update form.");
+  Services.logins.addLogin(login1);
+
+  yield testSubmittingLoginForm("subtst_notifications_change_p.html", function*(fieldValues) {
+    is(fieldValues.username, "null", "Checking submitted username");
+    is(fieldValues.password, "pass2", "Checking submitted password");
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "got notification popup");
+    clickDoorhangerButton(notif, CHANGE_BUTTON);
+    ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
+  });
+
+  let logins = Services.logins.getAllLogins();
+  is(logins.length, 1, "Should only have 1 login");
+  let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
+  is(login.username, "notifyu1", "Check the username unchanged");
+  is(login.password, "pass2", "Check the password changed");
+  is(login.timesUsed, 2, "Check times used");
+
+  checkOnlyLoginWasUsedTwice({ justChanged: true });
+
+  // cleanup
+  login1.password = "pass2";
+  Services.logins.removeLogin(login1);
+  login1.password = "notifyp1";
+});
+
 add_task(function* test_recipeCaptureFields_NewLogin() {
   info("Check that we capture the proper fields when a field recipe is in use.");
 
   yield testSubmittingLoginForm("subtst_notifications_2pw_1un_1text.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
     let notif = getCaptureDoorhanger("password-save");
     ok(notif, "got notification popup");