Bug 1322673 - Test that password changes are saved when both http: and https: for the same username exist. r=johannh
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 08 Jan 2019 20:51:43 +0000
changeset 510063 8268418fa2528e228a503e74a1a2f71272f257a3
parent 510062 1898dd0aeab9facb23b0ec8fd4f7a4aa5b994fa3
child 510064 e64d57b541e483c6464435158bf5ff6fdc35ff8e
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1322673
milestone66.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 1322673 - Test that password changes are saved when both http: and https: for the same username exist. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D15885
toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger_httpsUpgrade.js
--- a/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger_httpsUpgrade.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger_httpsUpgrade.js
@@ -61,16 +61,55 @@ add_task(async function test_httpsUpgrad
   is(login.formSubmitURL, "https://example.com", "Check the formSubmitURL is upgraded");
   is(login.username, "notifyu1", "Check the username is unchanged");
   is(login.password, "pass2", "Check the password changed");
   is(login.timesUsed, 2, "Check times used increased");
 
   Services.logins.removeAllLogins();
 });
 
+add_task(async function test_httpsUpgradeCaptureFields_changePWWithBothSchemesSaved() {
+  info("Check that we prompt to change and properly save when capturing an upgraded login with a new PW when an http login also exists for that username");
+  Services.logins.addLogin(login1);
+  Services.logins.addLogin(login1HTTPS);
+
+  let logins = Services.logins.getAllLogins();
+  is(logins.length, 2, "Should have both HTTP and HTTPS logins");
+
+  await testSubmittingLoginForm("subtst_notifications_8.html", async function(fieldValues) {
+    is(fieldValues.username, "notifyu1", "Checking submitted username");
+    is(fieldValues.password, "pass2", "Checking submitted password");
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "checking for a change popup");
+
+    await checkDoorhangerUsernamePassword("notifyu1", "pass2");
+    clickDoorhangerButton(notif, CHANGE_BUTTON);
+
+    ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
+  }, "https://example.com");
+
+  logins = Services.logins.getAllLogins();
+  is(logins.length, 2, "Should have 2 logins still");
+  let loginHTTP = logins[0].QueryInterface(Ci.nsILoginMetaInfo);
+  let loginHTTPS = logins[1].QueryInterface(Ci.nsILoginMetaInfo);
+  ok(LoginHelper.doLoginsMatch(login1, loginHTTP, {ignorePassword: true}), "Check HTTP login is equal");
+  is(loginHTTP.timesUsed, 1, "Check times used stayed the same");
+  is(loginHTTP.timeCreated, loginHTTP.timePasswordChanged, "login.timeCreated == login.timePasswordChanged");
+  is(loginHTTP.timeLastUsed, loginHTTP.timePasswordChanged, "timeLastUsed == timePasswordChanged");
+
+  ok(LoginHelper.doLoginsMatch(login1HTTPS, loginHTTPS, {ignorePassword: true}), "Check HTTPS login is equal");
+  is(loginHTTPS.username, "notifyu1", "Check the username is unchanged");
+  is(loginHTTPS.password, "pass2", "Check the password changed");
+  is(loginHTTPS.timesUsed, 2, "Check times used increased");
+  ok(loginHTTPS.timeCreated < loginHTTPS.timePasswordChanged, "login.timeCreated < login.timePasswordChanged");
+  is(loginHTTPS.timeLastUsed, loginHTTPS.timePasswordChanged, "timeLastUsed == timePasswordChanged");
+
+  Services.logins.removeAllLogins();
+});
+
 add_task(async function test_httpsUpgradeCaptureFields_captureMatchingHTTP() {
   info("Capture a new HTTP login which matches a stored HTTPS one.");
   Services.logins.addLogin(login1HTTPS);
 
   await testSubmittingLoginForm("subtst_notifications_1.html", async function(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
     let notif = getCaptureDoorhanger("password-save");