Bug 1530029 - Fix tests that use checkArrayValues to also check for the autocomplete footer in password manager tests. r=MattN
authorprathiksha <prathikshaprasadsuman@gmail.com>
Tue, 12 Mar 2019 00:21:11 +0000
changeset 521487 89679dcecb8a59dcc4272d1258faaf55be47ef8e
parent 521486 bd7db47ad0786b0f1545207d237293b78db8adf6
child 521488 f53c8cedef752e0aca5c0f4a848275267d94df7f
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1530029
milestone67.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 1530029 - Fix tests that use checkArrayValues to also check for the autocomplete footer in password manager tests. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D22807
toolkit/components/passwordmgr/test/mochitest/mochitest.ini
toolkit/components/passwordmgr/test/mochitest/pwmgr_common.js
toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
toolkit/components/passwordmgr/test/mochitest/test_autocomplete_sandboxed.html
toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
--- a/toolkit/components/passwordmgr/test/mochitest/mochitest.ini
+++ b/toolkit/components/passwordmgr/test/mochitest/mochitest.ini
@@ -1,12 +1,13 @@
 [DEFAULT]
 prefs =
   signon.rememberSignons=true
   signon.autofillForms.http=true
+  signon.showAutoCompleteFooter=true
   security.insecure_field_warning.contextual.enabled=false
   network.auth.non-web-content-triggered-resources-http-auth-allow=true
 
 support-files =
   ../../../prompts/test/chromeScript.js
   !/toolkit/components/prompts/test/prompt_common.js
   ../../../satchel/test/parent_utils.js
   !/toolkit/components/satchel/test/satchel_common.js
--- a/toolkit/components/passwordmgr/test/mochitest/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/mochitest/pwmgr_common.js
@@ -1,12 +1,14 @@
 /**
  * Helpers for password manager mochitest-plain tests.
  */
 
+/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
+
 // Copied from LoginTestUtils.masterPassword.masterPassword to use from the content process.
 const MASTER_PASSWORD = "omgsecret!";
 const TESTS_DIR = "/tests/toolkit/components/passwordmgr/test/";
 
 /**
  * Returns the element with the specified |name| attribute.
  */
 function $_(formNum, name) {
@@ -32,16 +34,35 @@ function $_(formNum, name) {
     ok(false, "$_ got confused.");
     return null;
   }
 
   return element;
 }
 
 /**
+ * Check autocomplete popup results to ensure that expected
+ * values are being shown correctly as items in the popup.
+ */
+function checkAutoCompleteResults(actualValues, expectedValues, hostname, msg) {
+  // Check the footer first.
+  let footerResult = actualValues[actualValues.length - 1];
+  ok(footerResult.includes("View Saved Logins"), "the footer text is shown correctly");
+  ok(footerResult.includes(hostname), "the footer has the correct hostname attribute");
+
+  if (actualValues.length == 0) {
+    info("Only the footer is present in the popup");
+    return;
+  }
+
+  // Check the rest of the autocomplete item values.
+  checkArrayValues(actualValues.slice(0, -1), expectedValues, msg);
+}
+
+/**
  * Check a form for expected values. If an argument is null, a field's
  * expected value will be the default value.
  *
  * <form id="form#">
  * checkForm(#, "foo");
  */
 function checkForm(formNum, val1, val2, val3) {
   var e, form = document.getElementById("form" + formNum);
--- a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
@@ -51,17 +51,17 @@ runInParent(function addLogins() {
 <!-- we presumably can't hide the content for this test. -->
 <div id="content">
   <iframe></iframe>
 </div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 let iframe = SpecialPowers.wrap(document.getElementsByTagName("iframe")[0]);
-let iframeDoc;
+let iframeDoc, hostname;
 let uname;
 let pword;
 
 // Restore the form to the default state.
 function restoreForm() {
   pword.focus();
   uname.value = "";
   pword.value = "";
@@ -81,33 +81,34 @@ add_task(async function setup() {
   iframe.src = "https://example.org/tests/toolkit/components/passwordmgr/test/mochitest/form_basic.html";
   await new Promise(resolve => {
     iframe.addEventListener("load", function() {
       resolve();
     }, {once: true});
   });
 
   iframeDoc = iframe.contentDocument;
+  hostname = iframeDoc.documentURIObject.host;
   uname = iframeDoc.getElementById("form-basic-username");
   pword = iframeDoc.getElementById("form-basic-password");
 });
 
 add_task(async function test_empty_first_entry() {
   // Make sure initial form is empty.
   checkACForm("", "");
   // Trigger autocomplete popup
   restoreForm();
   let popupState = await getPopupState();
   is(popupState.open, false, "Check popup is initially closed");
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown");
   let results = await shownPromise;
   popupState = await getPopupState();
   is(popupState.selectedIndex, -1, "Check no entries are selected");
-  checkArrayValues(results, ["name", "name1", "name2"], "initial");
+  checkAutoCompleteResults(results, ["name", "name1", "name2"], hostname, "initial");
 
   // Check first entry
   let index0Promise = notifySelectedIndex(0);
   synthesizeKey("KEY_ArrowDown");
   await index0Promise;
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
@@ -131,17 +132,17 @@ add_task(async function test_search() {
   let shownPromise = promiseACShown();
   // We need to blur for the autocomplete controller to notice the forced value below.
   uname.blur();
   uname.value = "name";
   uname.focus();
   sendChar("1");
   synthesizeKey("KEY_ArrowDown"); // open
   let results = await shownPromise;
-  checkArrayValues(results, ["name1"], "check result deduping for 'name1'");
+  checkAutoCompleteResults(results, ["name1"], hostname, "check result deduping for 'name1'");
   synthesizeKey("KEY_ArrowDown"); // first
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("name1", "pass1");
 
   let popupState = await getPopupState();
   is(popupState.open, false, "Check popup is now closed");
 });
@@ -159,19 +160,19 @@ add_task(async function test_delete_firs
 
   let 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.
   synthesizeKey("KEY_Delete", {shiftKey: true});
   await deletionPromise;
   checkACForm("", "");
 
-  let results = await notifyMenuChanged(2, "name1");
+  let results = await notifyMenuChanged(3, "name1");
 
-  checkArrayValues(results, ["name1", "name2"], "two should remain after deleting the first");
+  checkAutoCompleteResults(results, ["name1", "name2"], hostname, "two logins should remain after deleting the first");
   let popupState = await getPopupState();
   is(popupState.open, true, "Check popup stays open after deleting");
   synthesizeKey("KEY_Escape");
   popupState = await getPopupState();
   is(popupState.open, false, "Check popup closed upon ESC");
 });
 
 add_task(async function test_delete_duplicate_entry() {
@@ -194,19 +195,19 @@ add_task(async function test_delete_dupl
 
   is(LoginManager.countLogins("http://example.org", "http://example.org", null), 1,
      "Check that the HTTP login remains");
   is(LoginManager.countLogins("https://example.org", "https://example.org", null), 0,
      "Check that the HTTPS login was deleted");
 
   // Two menu items should remain as the HTTPS login should have been deleted but
   // the HTTP would remain.
-  let results = await notifyMenuChanged(1, "name2");
+  let results = await notifyMenuChanged(2, "name2");
 
-  checkArrayValues(results, ["name2"], "one should remain after deleting the HTTPS name1");
+  checkAutoCompleteResults(results, ["name2"], hostname, "one login should remain after deleting the HTTPS name1");
   let popupState = await getPopupState();
   is(popupState.open, true, "Check popup stays open after deleting");
   synthesizeKey("KEY_Escape");
   popupState = await getPopupState();
   is(popupState.open, false, "Check popup closed upon ESC");
 });
 
 </script>
--- a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_sandboxed.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_sandboxed.html
@@ -48,16 +48,17 @@ var setupScript = runInParent(function s
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Login Manager: form field autocomplete in sandboxed documents (null principal) **/
 
 let sandboxed = document.getElementById("sandboxed");
 let uname;
 let pword;
+let hostname;
 
 // Check for expected username/password in form.
 function checkACForm(expectedUsername, expectedPassword) {
   var formID = uname.parentNode.id;
   is(uname.value, expectedUsername, "Checking " + formID + " username is: " + expectedUsername);
   is(pword.value, expectedPassword, "Checking " + formID + " password is: " + expectedPassword);
 }
 
@@ -69,16 +70,17 @@ add_task(async function setup() {
   let frameWindow = SpecialPowers.wrap(sandboxed).contentWindow;
   // Can't use SimpleTest.promiseFocus as it doesn't work with the sandbox.
   await SimpleTest.promiseWaitForCondition(() => {
     return frameWindow.document.readyState == "complete" && frameWindow.location.href != "about:blank";
   }, "Check frame is loaded");
   let frameDoc = SpecialPowers.wrap(sandboxed).contentDocument;
   uname = frameDoc.getElementById("form-basic-username");
   pword = frameDoc.getElementById("form-basic-password");
+  hostname = frameDoc.documentURIObject.host;
 });
 
 add_task(async function test_no_autofill() {
   // Make sure initial form is empty as autofill shouldn't happen in the sandboxed frame.
   checkACForm("", "");
   let popupState = await getPopupState();
   is(popupState.open, false, "Check popup is initially closed");
 });
@@ -90,16 +92,16 @@ add_task(async function test_autocomplet
   let results = await shownPromise;
 
   let popupState = await getPopupState();
   is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
 
   let expectedMenuItems = [
     "This connection is not secure. Logins entered here could be compromised. Learn More",
   ];
-  checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
+  checkAutoCompleteResults(results, expectedMenuItems, hostname, "Check all menuitems are displayed correctly.");
 
   checkACForm("", "");
 });
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html
@@ -44,34 +44,35 @@ runInParent(function addLogins() {
 <div id="content">
   <iframe></iframe>
 </div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 let iframe = SpecialPowers.wrap(document.getElementsByTagName("iframe")[0]);
-let iframeDoc;
+let iframeDoc, hostname;
 
 add_task(async function setup() {
   iframe.src = "https://example.org/tests/toolkit/components/passwordmgr/test/mochitest/form_autofocus_js.html";
   await new Promise(resolve => {
     iframe.addEventListener("load", function() {
       resolve();
     }, {once: true});
   });
 
   iframeDoc = iframe.contentDocument;
+  hostname = iframeDoc.documentURIObject.host;
 
   SimpleTest.requestFlakyTimeout("Giving a chance for the unexpected popupshown to occur");
 });
 
 add_task(async function test_initial_focus() {
-  let results = await notifyMenuChanged(2, "name");
-  checkArrayValues(results, ["name", "name1"], "Two results");
+  let results = await notifyMenuChanged(3, "name");
+  checkAutoCompleteResults(results, ["name", "name1"], hostname, "Two login results");
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   is(iframeDoc.getElementById("form-basic-password").value, "pass", "Check first password filled");
   let popupState = await getPopupState();
   is(popupState.open, false, "Check popup is now closed");
 });
 
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
@@ -233,17 +233,17 @@ add_task(async function test_form1_menui
 
   let popupState = await getPopupState();
   is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
 
   let expectedMenuItems = ["tempuser1",
                            "testuser2",
                            "testuser3",
                            "zzzuser4"];
-  checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
+  checkAutoCompleteResults(results, expectedMenuItems, "mochi.test", "Check all menuitems are displayed correctly.");
 
   checkACForm("", ""); // value shouldn't update just by selecting
   synthesizeKey("KEY_Enter");
   await spinEventLoop(); // let focus happen
   checkACForm("", "");
 });
 
 add_task(async function test_form1_first_entry() {
@@ -316,45 +316,48 @@ add_task(async function test_form1_wrapa
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown"); // first
   synthesizeKey("KEY_ArrowDown"); // second
   synthesizeKey("KEY_ArrowDown"); // third
   synthesizeKey("KEY_ArrowDown"); // fourth
+  synthesizeKey("KEY_ArrowDown"); // footer
   synthesizeKey("KEY_ArrowDown"); // deselects
   synthesizeKey("KEY_ArrowDown"); // first
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("tempuser1", "temppass1");
 });
 
 add_task(async function test_form1_wraparound_up_last_entry() {
   // Trigger autocomplete popup
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
+  synthesizeKey("KEY_ArrowUp"); // footer
   synthesizeKey("KEY_ArrowUp"); // last (fourth)
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_wraparound_down_up_up() {
   // Trigger autocomplete popup
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown"); // select first entry
   synthesizeKey("KEY_ArrowUp"); // selects nothing!
+  synthesizeKey("KEY_ArrowUp"); // footer
   synthesizeKey("KEY_ArrowUp"); // select last entry
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_wraparound_up_last() {
   restoreForm();
@@ -362,18 +365,20 @@ add_task(async function test_form1_wrapa
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_ArrowUp"); // deselects
   synthesizeKey("KEY_ArrowUp"); // last entry
   synthesizeKey("KEY_ArrowUp");
   synthesizeKey("KEY_ArrowUp");
+  synthesizeKey("KEY_ArrowUp");
   synthesizeKey("KEY_ArrowUp"); // first entry
   synthesizeKey("KEY_ArrowUp"); // deselects
+  synthesizeKey("KEY_ArrowUp"); // footer
   synthesizeKey("KEY_ArrowUp"); // last entry
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_fill_username_without_autofill_right() {
   restoreForm();
@@ -419,17 +424,18 @@ add_task(async function test_form1_paged
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   /* test 13 */
   // Check last entry (page down)
   synthesizeKey("KEY_ArrowDown"); // first
-  synthesizeKey("KEY_PageDown"); // last
+  synthesizeKey("KEY_PageDown"); // footer
+  synthesizeKey("KEY_ArrowUp"); // last
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_untrusted_event() {
   restoreForm();
   await spinEventLoop();
@@ -453,17 +459,17 @@ add_task(async function test_form1_delet
   // Setting uname.value didn't seem to work either. This works with a human
   // driver, so I'm not sure what's up.
 
   // Delete the first entry (of 4), "tempuser1"
   synthesizeKey("KEY_ArrowDown");
   let 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);
+  let countChangedPromise = notifyMenuChanged(4);
   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.
   synthesizeKey("KEY_Delete", {shiftKey: true});
   await deletionPromise;
 
   checkACForm("", "");
   numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
@@ -527,16 +533,17 @@ add_task(async function test_form1_delet
   /* test 54 */
   // Delete the last entry (of 2), "zzzuser4"
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Delete", {shiftKey: true});
   checkACForm("", "");
   let numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
   is(numLogins, 2, "Correct number of logins after deleting one");
+  synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("testuser2", "testpass2");
 });
 
 add_task(async function test_form1_first_after_3_deletions() {
   restoreForm();
   let shownPromise = promiseACShown();
@@ -736,41 +743,39 @@ add_task(async function test_form9_filte
   checkACForm("form9userAB", "");
   uname.focus();
   synthesizeKey("KEY_ArrowLeft");
   shownPromise = promiseACShown();
   synthesizeKey("A", {shiftKey: true});
   let results = await shownPromise;
 
   checkACForm("form9userAAB", "");
-  checkArrayValues(results, ["form9userAAB"], "Check dropdown is updated after inserting 'A'");
+  checkAutoCompleteResults(results, ["form9userAAB"], "mochi.test", "Check dropdown is updated after inserting 'A'");
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("form9userAAB", "form9pass");
 });
 
 add_task(async function test_form9_autocomplete_cache() {
   // Note that this addLogin call will only be seen by the autocomplete
   // attempt for the synthesizeKey if we do not successfully cache the
   // autocomplete results.
   setupScript.sendSyncMessage("addLogin", "login8C");
   uname.focus();
-  let promise0 = notifyMenuChanged(0);
+  let promise1 = notifyMenuChanged(1);
   sendString("z");
-  await promise0;
-  let popupState = await getPopupState();
-  is(popupState.open, false, "Check popup shouldn't open");
+  let results = await promise1;
+  checkAutoCompleteResults(results, [], "mochi.test", "Check popup does not have any login items");
 
   // check that empty results are cached - bug 496466
-  promise0 = notifyMenuChanged(0);
+  promise1 = notifyMenuChanged(1);
   sendString("z");
-  await promise0;
-  popupState = await getPopupState();
-  is(popupState.open, false, "Check popup stays closed due to cached empty result");
+  results = await promise1;
+  checkAutoCompleteResults(results, [], "mochi.test", "Check popup only has the footer when it opens");
 });
 
 add_task(async function test_form11_formless() {
   // Test form-less autocomplete
   uname = $_(11, "uname");
   pword = $_(11, "pword");
   restoreForm();
   checkACForm("", "");
--- a/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
@@ -85,17 +85,17 @@ add_task(async function test_empty_first
   restoreForm();
   let popupState = await getPopupState();
   is(popupState.open, false, "Check popup is initially closed");
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown");
   let results = await shownPromise;
   popupState = await getPopupState();
   is(popupState.selectedIndex, -1, "Check no entries are selected");
-  checkArrayValues(results, ["name", "Name", "USER"], "initial");
+  checkAutoCompleteResults(results, ["name", "Name", "USER"], "mochi.test", "initial");
 
   // Check first entry
   let index0Promise = notifySelectedIndex(0);
   synthesizeKey("KEY_ArrowDown");
   await index0Promise;
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
--- a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
@@ -233,17 +233,17 @@ add_task(async function test_form1_warni
   let popupState = await getPopupState();
   is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
 
   let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
                            "tempuser1",
                            "testuser2",
                            "testuser3",
                            "zzzuser4"];
-  checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
+  checkAutoCompleteResults(results, expectedMenuItems, "mochi.test", "Check all menuitems are displayed correctly.");
 
   synthesizeKey("KEY_ArrowDown"); // select insecure warning
   checkACForm("", ""); // value shouldn't update just by selecting
   synthesizeKey("KEY_Enter");
   await spinEventLoop(); // let focus happen
   checkACForm("", "");
 });
 
@@ -322,66 +322,71 @@ add_task(async function test_form1_wrapa
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   synthesizeKey("KEY_ArrowDown"); // first
   synthesizeKey("KEY_ArrowDown"); // second
   synthesizeKey("KEY_ArrowDown"); // third
   synthesizeKey("KEY_ArrowDown"); // fourth
+  synthesizeKey("KEY_ArrowDown"); // footer
   synthesizeKey("KEY_ArrowDown"); // deselects
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   synthesizeKey("KEY_ArrowDown"); // first
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("tempuser1", "temppass1");
 });
 
 add_task(async function test_form1_wraparound_up_last_entry() {
   // Trigger autocomplete popup
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
+  synthesizeKey("KEY_ArrowUp"); // footer
   synthesizeKey("KEY_ArrowUp"); // last (fourth)
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_wraparound_down_up_up() {
   // Trigger autocomplete popup
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown"); // select first entry
   synthesizeKey("KEY_ArrowUp"); // selects nothing!
+  synthesizeKey("KEY_ArrowUp"); // selects footer
   synthesizeKey("KEY_ArrowUp"); // select last entry
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_wraparound_up_last() {
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_ArrowUp"); // deselects
+  synthesizeKey("KEY_ArrowUp"); // footer
   synthesizeKey("KEY_ArrowUp"); // last entry
   synthesizeKey("KEY_ArrowUp");
   synthesizeKey("KEY_ArrowUp");
   synthesizeKey("KEY_ArrowUp"); // skip insecure warning
   synthesizeKey("KEY_ArrowUp"); // first entry
   synthesizeKey("KEY_ArrowUp"); // deselects
+  synthesizeKey("KEY_ArrowUp"); // footer
   synthesizeKey("KEY_ArrowUp"); // last entry
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_fill_username_without_autofill_right() {
   restoreForm();
@@ -431,16 +436,17 @@ add_task(async function test_form1_paged
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   // test 13
   // Check last entry (page down)
   synthesizeKey("KEY_ArrowDown"); // first
   synthesizeKey("KEY_PageDown"); // last
+  synthesizeKey("KEY_ArrowUp"); // skip footer
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_untrusted_event() {
   restoreForm();
   await spinEventLoop();
@@ -466,17 +472,17 @@ add_task(async function test_form1_delet
 
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   // Delete the first entry (of 4), "tempuser1"
   synthesizeKey("KEY_ArrowDown");
   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(4);
+  let countChangedPromise = notifyMenuChanged(5);
   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.
   synthesizeKey("KEY_Delete", {shiftKey: true});
   await deletionPromise;
 
   checkACForm("", "");
   numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
@@ -544,16 +550,18 @@ add_task(async function test_form1_delet
   // test 54
   // Delete the last entry (of 2), "zzzuser4"
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Delete", {shiftKey: true});
   checkACForm("", "");
   let numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
   is(numLogins, 2, "Correct number of logins after deleting one");
+  synthesizeKey("KEY_ArrowDown"); // skip insecure warning
+  synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("testuser2", "testpass2");
 });
 
 add_task(async function test_form1_first_after_3_deletions() {
   restoreForm();
   let shownPromise = promiseACShown();
@@ -760,45 +768,50 @@ add_task(async function test_form9_filte
   checkACForm("form9userAB", "");
   uname.focus();
   synthesizeKey("KEY_ArrowLeft");
   shownPromise = promiseACShown();
   synthesizeKey("A", {shiftKey: true});
   let results = await shownPromise;
 
   checkACForm("form9userAAB", "");
-  checkArrayValues(results, ["This connection is not secure. Logins entered here could be compromised. Learn More", "form9userAAB"],
-                   "Check dropdown is updated after inserting 'A'");
+  checkAutoCompleteResults(results,
+                           ["This connection is not secure. Logins entered here could be compromised. Learn More", "form9userAAB"],
+                           "mochi.test",
+                           "Check dropdown is updated after inserting 'A'");
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("form9userAAB", "form9pass");
 });
 
 add_task(async function test_form9_autocomplete_cache() {
   // Note that this addLogin call will only be seen by the autocomplete
   // attempt for the synthesizeKey if we do not successfully cache the
   // autocomplete results.
   setupScript.sendSyncMessage("addLogin", "login8C");
   uname.focus();
-  let promise0 = notifyMenuChanged(1);
+  let promise2 = notifyMenuChanged(2);
   let shownPromise = promiseACShown();
   sendString("z");
-  await promise0;
+  let results = await promise2;
   await shownPromise;
-  let popupState = await getPopupState();
-  is(popupState.open, true, "Check popup should open");
-
+  checkAutoCompleteResults(results,
+                           ["This connection is not secure. Logins entered here could be compromised. Learn More"],
+                           "mochi.test",
+                           "Check popup only has the footer and insecure warning");
   // check that empty results are cached - bug 496466
-  promise0 = notifyMenuChanged(1);
+  promise2 = notifyMenuChanged(2);
   sendString("z");
-  await promise0;
-  popupState = await getPopupState();
-  is(popupState.open, true, "Check popup stays opened due to cached empty result");
+  results = await promise2;
+  checkAutoCompleteResults(results,
+                           ["This connection is not secure. Logins entered here could be compromised. Learn More"],
+                           "mochi.test",
+                           "Check popup only has the footer and insecure warning");
 });
 
 add_task(async function test_form11_recipes() {
   await loadRecipes({
     siteRecipes: [{
       "hosts": ["mochi.test:8888"],
       "usernameSelector": "input[name='1']",
       "passwordSelector": "input[name='2']",
--- a/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
@@ -203,17 +203,17 @@ add_task(async function test_form1_enabl
   is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
 
   let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
                            "No username (" + DATE_NOW_STRING + ")",
                            "tempuser1",
                            "testuser2",
                            "testuser3",
                            "zzzuser4"];
-  checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
+  checkAutoCompleteResults(results, expectedMenuItems, "mochi.test", "Check all menuitems are displayed correctly.");
 
   synthesizeKey("KEY_ArrowDown"); // select insecure warning
   checkACFormPasswordField(""); // value shouldn't update just by selecting
   synthesizeKey("KEY_Enter");
   await spinEventLoop(); // let focus happen
   checkACFormPasswordField("");
 });
 
@@ -232,17 +232,17 @@ add_task(async function test_form1_disab
   let popupState = await getPopupState();
   is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
 
   let expectedMenuItems = ["No username (" + DATE_NOW_STRING + ")",
                            "tempuser1",
                            "testuser2",
                            "testuser3",
                            "zzzuser4"];
-  checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
+  checkAutoCompleteResults(results, expectedMenuItems, "mochi.test", "Check all menuitems are displayed correctly.");
 
   synthesizeKey("KEY_ArrowDown"); // select first item
   checkACFormPasswordField(""); // value shouldn't update just by selecting
   synthesizeKey("KEY_Enter");
   await spinEventLoop(); // let focus happen
   checkACFormPasswordField("user0pass");
 });
 
@@ -262,17 +262,17 @@ add_task(async function test_form1_enabl
   is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
 
   let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
                            "No username (" + DATE_NOW_STRING + ")",
                            "tempuser1",
                            "testuser2",
                            "testuser3",
                            "zzzuser4"];
-  checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
+  checkAutoCompleteResults(results, expectedMenuItems, "mochi.test", "Check all menuitems are displayed correctly.");
 
   synthesizeKey("KEY_ArrowDown"); // select insecure warning
   checkACFormPasswordField(""); // value shouldn't update just by selecting
   synthesizeKey("KEY_Enter");
   await spinEventLoop(); // let focus happen
   checkACFormPasswordField("");
 });