Bug 1305050 - Removing chrome error in deleting password autocomplete and improving testing to catch issues. draft
authorJonathan Kingston <jkt@mozilla.com>
Wed, 05 Oct 2016 00:27:19 +0100
changeset 423536 fdcf2baff0ef2689f97acd119e7fa55dc05e01ed
parent 423090 d72cf6ecebaf707c159f6697d9f5f6f6a6feb7e1
child 533477 81726ffce699216281c671b16d13a5e2a68937c8
push id31933
push userjkingston@mozilla.com
push dateTue, 11 Oct 2016 10:12:47 +0000
bugs1305050
milestone52.0a1
Bug 1305050 - Removing chrome error in deleting password autocomplete and improving testing to catch issues. MozReview-Commit-ID: JEX5gly6bTA
toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
toolkit/components/satchel/AutoCompletePopup.jsm
toolkit/components/satchel/test/parent_utils.js
--- 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,