Bug 1305050 - Removing chrome error in deleting password autocomplete and improving testing to catch issues.
MozReview-Commit-ID: JEX5gly6bTA
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
@@ -429,26 +429,27 @@ add_task(function* test_form1_delete() {
// driver, so I'm not sure what's up.
// Delete the first entry (of 4), "tempuser1"
doKey("down");
var numLogins;
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 5, "Correct number of logins before deleting one");
+ let countChangedPromise = notifyMenuChanged(3);
var deletionPromise = promiseStorageChanged(["removeLogin"]);
// On OS X, shift-backspace and shift-delete work, just delete does not.
// On Win/Linux, shift-backspace does not work, delete and shift-delete do.
doKey("delete", shiftModifier);
yield deletionPromise;
checkACForm("", "");
numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
is(numLogins, 4, "Correct number of logins after deleting one");
- notifyMenuChanged(4);
+ yield countChangedPromise;
doKey("return");
yield promiseFormsProcessed();
checkACForm("testuser2", "testpass2");
});
add_task(function* test_form1_first_after_deletion() {
restoreForm();
let shownPromise = promiseACShown();
--- a/toolkit/components/satchel/AutoCompletePopup.jsm
+++ b/toolkit/components/satchel/AutoCompletePopup.jsm
@@ -173,26 +173,16 @@ this.AutoCompletePopup = {
if (this.openedPopup) {
this.openedPopup.closePopup();
}
AutoCompleteTreeView.clearResults();
},
removeLogin(login) {
Services.logins.removeLogin(login);
-
- // It's possible to race and have the deleted login no longer be in our
- // resultCache's logins, so we remove it from the database above and only
- // deal with our resultCache below.
- let idx = this._resultCache.logins.findIndex(cur => {
- return login.guid === cur.QueryInterface(Ci.nsILoginMetaInfo).guid
- });
- if (idx !== -1) {
- this.removeEntry(idx, false);
- }
},
receiveMessage: function(message) {
if (!message.target.autoCompletePopup) {
// Returning false to pacify ESLint, but this return value is
// ignored by the messaging infrastructure.
return false;
}
--- a/toolkit/components/satchel/test/parent_utils.js
+++ b/toolkit/components/satchel/test/parent_utils.js
@@ -69,27 +69,27 @@ var ParentUtils = {
checkRowCount(expectedCount, expectedFirstValue = null) {
ContentTaskUtils.waitForCondition(() => {
return gAutocompletePopup.tree.view.rowCount === expectedCount &&
(!expectedFirstValue ||
expectedCount <= 1 ||
gAutocompletePopup.tree.view.getCellText(0, gAutocompletePopup.tree.columns[0]) ===
expectedFirstValue);
- }).then(() => {
+ }, "Waiting for row count change: " + expectedCount + " First value: " + expectedFirstValue).then(() => {
let results = this.getMenuEntries();
sendAsyncMessage("gotMenuChange", { results });
});
},
checkSelectedIndex(expectedIndex) {
ContentTaskUtils.waitForCondition(() => {
return gAutocompletePopup.popupOpen &&
gAutocompletePopup.selectedIndex === expectedIndex;
- }).then(() => {
+ }, "Checking selected index").then(() => {
sendAsyncMessage("gotSelectedIndex");
});
},
getPopupState() {
sendAsyncMessage("gotPopupState", {
open: gAutocompletePopup.popupOpen,
selectedIndex: gAutocompletePopup.selectedIndex,