Bug 1255265 - Rename some helpers and variables in browser_capture_doorhanger.js for clarity. r=dolske draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 09 Mar 2016 20:20:41 -0800
changeset 338909 59a3ce7289858003a5c75983b6116fa153c3dee3
parent 338908 b6e776a67026716ab7e96f5bd9fc6c79dcf8bb4d
child 515879 9cb8a23acf5777a4a24193a15ecce2d9e25ab1d1
push id12603
push usermozilla@noorenberghe.ca
push dateThu, 10 Mar 2016 04:21:22 +0000
reviewersdolske
bugs1255265
milestone48.0a1
Bug 1255265 - Rename some helpers and variables in browser_capture_doorhanger.js for clarity. r=dolske I avoided the renames in the port to b-c to make the interdiff easier. MozReview-Commit-ID: H0yjc2KY8BM
toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
toolkit/components/passwordmgr/test/browser/head.js
--- a/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
@@ -28,62 +28,62 @@ add_task(function* setup() {
     }],
   });
 });
 
 add_task(function* test_remember_opens() {
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
+    notif.remove();
   });
 });
 
 add_task(function* test_clickNever() {
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
     is(true, Services.logins.getLoginSavingEnabled("http://mochi.test:8888"),
        "Checking for login saving enabled");
-    clickPopupButton(popup, NEVER_BUTTON);
+    clickDoorhangerButton(notif, NEVER_BUTTON);
   });
 
   info("Make sure Never took effect");
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(!popup, "checking for no notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(!notif, "checking for no notification popup");
     is(false, Services.logins.getLoginSavingEnabled("http://mochi.test:8888"),
        "Checking for login saving disabled");
     Services.logins.setLoginSavingEnabled("http://mochi.test:8888", true);
   });
 });
 
 add_task(function* test_clickRemember() {
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
 
     is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
-    clickPopupButton(popup, REMEMBER_BUTTON);
+    clickDoorhangerButton(notif, REMEMBER_BUTTON);
   });
 
   info("Make sure Remember took effect and we don't prompt for an existing login");
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(!popup, "checking for no notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(!notif, "checking for no notification popup");
   });
 
   checkOnlyLoginWasUsedTwice({ justChanged: false });
 
   // remove that login
   Services.logins.removeLogin(login1);
 });
 
@@ -91,154 +91,154 @@ add_task(function* test_clickRemember() 
 
 add_task(function* test_rememberSignonsFalse() {
   info("Make sure we don't prompt with rememberSignons=false");
   Services.prefs.setBoolPref("signon.rememberSignons", false);
 
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(!popup, "checking for no notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(!notif, "checking for no notification popup");
   });
 });
 
 add_task(function* test_rememberSignonsTrue() {
   info("Make sure we prompt with rememberSignons=true");
   Services.prefs.setBoolPref("signon.rememberSignons", true);
 
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
+    notif.remove();
   });
 });
 
 /* autocomplete=off tests... */
 
 add_task(function* test_autocompleteOffUsername() {
   info("Check for notification popup when autocomplete=off present on username");
 
   yield testSubmittingLoginForm("subtst_notifications_2.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "checking for notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "checking for notification popup");
+    notif.remove();
   });
 });
 
 add_task(function* test_autocompleteOffPassword() {
   info("Check for notification popup when autocomplete=off present on password");
 
   yield testSubmittingLoginForm("subtst_notifications_3.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "checking for notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "checking for notification popup");
+    notif.remove();
   });
 });
 
 add_task(function* test_autocompleteOffForm() {
   info("Check for notification popup when autocomplete=off present on form");
 
   yield testSubmittingLoginForm("subtst_notifications_4.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "checking for notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "checking for notification popup");
+    notif.remove();
   });
 });
 
 
 add_task(function* test_noPasswordField() {
   info("Check for no notification popup when no password field present");
 
   yield testSubmittingLoginForm("subtst_notifications_5.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "null", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(!popup, "checking for no notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(!notif, "checking for no notification popup");
   });
 });
 
 add_task(function* test_pwOnlyLoginMatchesForm() {
   info("Check for update popup when existing pw-only login matches form.");
   Services.logins.addLogin(login2);
 
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(popup, "checking for notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "checking for notification popup");
+    notif.remove();
   });
 
   Services.logins.removeLogin(login2);
 });
 
 add_task(function* test_pwOnlyFormMatchesLogin() {
   info("Check for no notification popup when pw-only form matches existing login.");
   Services.logins.addLogin(login1);
 
   yield testSubmittingLoginForm("subtst_notifications_6.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(!popup, "checking for no notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(!notif, "checking for no notification popup");
   });
 
   Services.logins.removeLogin(login1);
 });
 
 add_task(function* test_pwOnlyFormDoesntMatchExisting() {
   info("Check for notification popup when pw-only form doesn't match existing login.");
   Services.logins.addLogin(login1B);
 
   yield testSubmittingLoginForm("subtst_notifications_6.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
+    notif.remove();
   });
 
   Services.logins.removeLogin(login1B);
 });
 
 add_task(function* test_changeUPLoginOnUPForm_dont() {
   info("Check for change-password popup, u+p login on u+p form. (not changed)");
   Services.logins.addLogin(login1);
 
   yield testSubmittingLoginForm("subtst_notifications_8.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "pass2", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(popup, "got notification popup");
-    clickPopupButton(popup, DONT_CHANGE_BUTTON);
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "got notification popup");
+    clickDoorhangerButton(notif, DONT_CHANGE_BUTTON);
   });
 
   Services.logins.removeLogin(login1);
 });
 
 add_task(function* test_changeUPLoginOnUPForm_change() {
   info("Check for change-password popup, u+p login on u+p form.");
   Services.logins.addLogin(login1);
 
   yield testSubmittingLoginForm("subtst_notifications_8.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "pass2", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(popup, "got notification popup");
-    clickPopupButton(popup, CHANGE_BUTTON);
-    ok(!getPopup("password-change"), "popup should be gone");
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "got notification popup");
+    clickDoorhangerButton(notif, CHANGE_BUTTON);
+    ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
   });
 
   checkOnlyLoginWasUsedTwice({ justChanged: true });
 
   // cleanup
   login1.password = "pass2";
   Services.logins.removeLogin(login1);
   login1.password = "notifyp1";
@@ -246,160 +246,160 @@ add_task(function* test_changeUPLoginOnU
 
 add_task(function* test_changePLoginOnUPForm() {
   info("Check for change-password popup, p-only login on u+p form.");
   Services.logins.addLogin(login2);
 
   yield testSubmittingLoginForm("subtst_notifications_9.html", function*(fieldValues) {
     is(fieldValues.username, "", "Checking submitted username");
     is(fieldValues.password, "pass2", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(popup, "got notification popup");
-    clickPopupButton(popup, CHANGE_BUTTON);
-    ok(!getPopup("password-change"), "popup should be gone");
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "got notification popup");
+    clickDoorhangerButton(notif, CHANGE_BUTTON);
+    ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
   });
 });
 
 add_task(function* test_changePLoginOnPForm() {
   info("Check for change-password popup, p-only login on p-only form.");
 
   yield testSubmittingLoginForm("subtst_notifications_10.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(popup, "got notification popup");
-    clickPopupButton(popup, CHANGE_BUTTON);
-    ok(!getPopup("password-change"), "popup should be gone");
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "got notification popup");
+    clickDoorhangerButton(notif, CHANGE_BUTTON);
+    ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
   });
   Services.logins.removeLogin(login2);
 });
 
 add_task(function* test_checkUPSaveText() {
   info("Check text on a user+pass notification popup");
 
   yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
     // Check the text, which comes from the localized saveLoginText string.
-    let notificationText = popup.message;
+    let notificationText = notif.message;
     let expectedText = "Would you like " + BRAND_SHORT_NAME + " to remember this login?";
     is(expectedText, notificationText, "Checking text: " + notificationText);
-    popup.remove();
+    notif.remove();
   });
 });
 
 add_task(function* test_checkPSaveText() {
   info("Check text on a pass-only notification popup");
 
   yield testSubmittingLoginForm("subtst_notifications_6.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
     // Check the text, which comes from the localized saveLoginTextNoUser string.
-    let notificationText = popup.message;
+    let notificationText = notif.message;
     let expectedText = "Would you like " + BRAND_SHORT_NAME + " to remember this password?";
     is(expectedText, notificationText, "Checking text: " + notificationText);
-    popup.remove();
+    notif.remove();
   });
 });
 
 add_task(function* test_capture2pw0un() {
   info("Check for notification popup when a form with 2 password fields (no username) " +
        "is submitted and there are no saved logins.");
 
   yield testSubmittingLoginForm("subtst_notifications_2pw_0un.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-save");
-    ok(popup, "got notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
+    notif.remove();
   });
 });
 
 add_task(function* test_change2pw0unExistingDifferentUP() {
   info("Check for notification popup when a form with 2 password fields (no username) " +
        "is submitted and there is a saved login with a username and different password.");
 
   Services.logins.addLogin(login1B);
 
   yield testSubmittingLoginForm("subtst_notifications_2pw_0un.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(popup, "got notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "got notification popup");
+    notif.remove();
   });
 
   Services.logins.removeLogin(login1B);
 });
 
 add_task(function* test_change2pw0unExistingDifferentP() {
   info("Check for notification popup when a form with 2 password fields (no username) " +
        "is submitted and there is a saved login with no username and different password.");
 
   Services.logins.addLogin(login2B);
 
   yield testSubmittingLoginForm("subtst_notifications_2pw_0un.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(popup, "got notification popup");
-    popup.remove();
+    let notif = getCaptureDoorhanger("password-change");
+    ok(notif, "got notification popup");
+    notif.remove();
   });
 
   Services.logins.removeLogin(login2B);
 });
 
 add_task(function* test_change2pw0unExistingWithSameP() {
   info("Check for no notification popup when a form with 2 password fields (no username) " +
        "is submitted and there is a saved login with a username and the same password.");
 
   Services.logins.addLogin(login2);
 
   yield testSubmittingLoginForm("subtst_notifications_2pw_0un.html", function*(fieldValues) {
     is(fieldValues.username, "null", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
-    let popup = getPopup("password-change");
-    ok(!popup, "checking for no notification popup");
+    let notif = getCaptureDoorhanger("password-change");
+    ok(!notif, "checking for no notification popup");
   });
 
   checkOnlyLoginWasUsedTwice({ justChanged: false });
 
   Services.logins.removeLogin(login2);
 });
 
 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 popup = getPopup("password-save");
-    ok(popup, "got notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(notif, "got notification popup");
 
     // Sanity check, no logins should exist yet.
     let logins = Services.logins.getAllLogins();
     is(logins.length, 0, "Should not have any logins yet");
 
-    clickPopupButton(popup, REMEMBER_BUTTON);
+    clickDoorhangerButton(notif, REMEMBER_BUTTON);
   }, "http://example.org"); // The recipe is for example.org
 });
 
 add_task(function* test_recipeCaptureFields_ExistingLogin() {
   info("Check that we capture the proper fields when a field recipe is in use " +
        "and there is a matching login");
 
   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 popup = getPopup("password-save");
-    ok(!popup, "checking for no notification popup");
+    let notif = getCaptureDoorhanger("password-save");
+    ok(!notif, "checking for no notification popup");
   }, "http://example.org");
 
   checkOnlyLoginWasUsedTwice({ justChanged: false });
   let logins = Services.logins.getAllLogins();
   is(logins[0].username, "notifyu1", "check .username for existing login submission");
   is(logins[0].password, "notifyp1", "check .password for existing login submission");
 
   Services.logins.removeAllLogins();
--- a/toolkit/components/passwordmgr/test/browser/head.js
+++ b/toolkit/components/passwordmgr/test/browser/head.js
@@ -72,17 +72,17 @@ const DONT_CHANGE_BUTTON = 1;
 
 /**
  * Checks if we have a password capture popup notification
  * of the right type and with the right label.
  *
  * @param {String} aKind The desired `passwordNotificationType`
  * @return the found password popup notification.
  */
-function getPopup(aKind) {
+function getCaptureDoorhanger(aKind) {
   ok(true, "Looking for " + aKind + " popup notification");
   let notification = PopupNotifications.getNotification("password");
   if (notification) {
     is(notification.options.passwordNotificationType, aKind, "Notification type matches.");
     if (aKind == "password-change") {
       is(notification.mainAction.label, "Update", "Main action label matches update doorhanger.");
     } else if (aKind == "password-save") {
       is(notification.mainAction.label, "Remember", "Main action label matches save doorhanger.");
@@ -93,17 +93,17 @@ function getPopup(aKind) {
 
 /**
  * Clicks the specified popup notification button.
  *
  * @param {Element} aPopup Popup Notification element
  * @param {Number} aButtonIndex Number indicating which button to click.
  *                              See the constants in this file.
  */
-function clickPopupButton(aPopup, aButtonIndex) {
+function clickDoorhangerButton(aPopup, aButtonIndex) {
   ok(true, "Looking for action at index " + aButtonIndex);
 
   let notifications = aPopup.owner.panel.childNodes;
   ok(notifications.length > 0, "at least one notification displayed");
   ok(true, notifications.length + " notification(s)");
   let notification = notifications[0];
 
   if (aButtonIndex == 0) {