Bug 1147563 - Deprecate the 'testuser' login that is created during initialization of the password manager tests. r=MattN
authorJared Wein <jwein@mozilla.com>
Tue, 02 Apr 2019 18:24:45 +0000
changeset 467651 49a9bb5d764ca3164dac1b0cb34285c561ecd6f9
parent 467650 b09ce6eebb4942cd2e570bf785c660ca6abb6258
child 467652 4edd84663f956428a125e54cddafd73f633dae64
push id35806
push userrgurzau@mozilla.com
push dateWed, 03 Apr 2019 04:07:39 +0000
treeherdermozilla-central@45808ab18609 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1147563
milestone68.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 1147563 - Deprecate the 'testuser' login that is created during initialization of the password manager tests. r=MattN This login should not show up in tests that don't expect it once we allow non-matching formSubmitURLs. Differential Revision: https://phabricator.services.mozilla.com/D23443
toolkit/components/passwordmgr/test/mochitest/mochitest.ini
toolkit/components/passwordmgr/test/mochitest/pwmgr_common.js
toolkit/components/passwordmgr/test/mochitest/pwmgr_common_parent.js
toolkit/components/passwordmgr/test/mochitest/test_basic_form.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_1pw.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_1pw_2.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_2pw_1.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_3pw_1.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_pwevent.html
toolkit/components/passwordmgr/test/mochitest/test_basic_form_pwonly.html
toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
toolkit/components/passwordmgr/test/mochitest/test_form_action_1.html
toolkit/components/passwordmgr/test/mochitest/test_form_action_2.html
toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html
toolkit/components/passwordmgr/test/mochitest/test_input_events.html
toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
toolkit/components/passwordmgr/test/mochitest/test_master_password.html
toolkit/components/passwordmgr/test/mochitest/test_maxlength.html
toolkit/components/passwordmgr/test/mochitest/test_passwords_in_type_password.html
toolkit/components/passwordmgr/test/mochitest/test_recipe_login_fields.html
--- a/toolkit/components/passwordmgr/test/mochitest/mochitest.ini
+++ b/toolkit/components/passwordmgr/test/mochitest/mochitest.ini
@@ -58,17 +58,18 @@ skip-if = toolkit == 'android' # autocom
 [test_basic_form.html]
 [test_basic_form_0pw.html]
 [test_basic_form_1pw.html]
 [test_basic_form_1pw_2.html]
 [test_basic_form_2pw_1.html]
 [test_basic_form_2pw_2.html]
 [test_basic_form_3pw_1.html]
 [test_basic_form_autocomplete.html]
-skip-if = toolkit == 'android' # android:autocomplete.
+skip-if = toolkit == 'android' || (os == 'linux' && debug) # android:autocomplete, linux: bug 1538955
+scheme = https
 [test_basic_form_autocomplete_formSubmitURL.html]
 skip-if = toolkit == 'android' # android:autocomplete.
 scheme = https
 [test_basic_form_honor_autocomplete_off.html]
 scheme = https
 skip-if = toolkit == 'android' # android:autocomplete.
 [test_insecure_form_field_autocomplete.html]
 skip-if = toolkit == 'android' || os == 'linux' # android:autocomplete., linux: bug 1325778
@@ -79,16 +80,17 @@ skip-if = toolkit == 'android' # android
 [test_basic_form_html5.html]
 [test_basic_form_pwevent.html]
 [test_basic_form_pwonly.html]
 [test_bug_627616.html]
 skip-if = toolkit == 'android' # Tests desktop prompts
 [test_bug_776171.html]
 [test_case_differences.html]
 skip-if = toolkit == 'android' # autocomplete
+scheme = https
 [test_form_action_1.html]
 [test_form_action_2.html]
 [test_form_action_javascript.html]
 [test_formless_autofill.html]
 [test_formless_submit.html]
 skip-if = toolkit == 'android' && debug # bug 1397615
 [test_formless_submit_navigation.html]
 skip-if = toolkit == 'android' && debug # bug 1397615
--- a/toolkit/components/passwordmgr/test/mochitest/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/mochitest/pwmgr_common.js
@@ -136,21 +136,17 @@ function checkUnmodifiedForm(formNum) {
 
     is(ele.value, ele.defaultValue, "Test to default value of field " +
        ele.name + " in form " + formNum);
   }
 }
 
 function registerRunTests() {
   return new Promise(resolve => {
-    // We provide a general mechanism for our tests to know when they can
-    // safely run: we add a final form that we know will be filled in, wait
-    // for the login manager to tell us that it's filled in and then continue
-    // with the rest of the tests.
-    window.addEventListener("DOMContentLoaded", (event) => {
+    function onDOMContentLoaded() {
       var form = document.createElement("form");
       form.id = "observerforcer";
       var username = document.createElement("input");
       username.name = "testuser";
       form.appendChild(username);
       var password = document.createElement("input");
       password.name = "testpass";
       password.type = "password";
@@ -167,17 +163,28 @@ function registerRunTests() {
           var runTestEvent = new Event("runTests");
           window.dispatchEvent(runTestEvent);
           resolve();
         });
       });
       SpecialPowers.addObserver(observer, "passwordmgr-processed-form");
 
       document.body.appendChild(form);
-    });
+    }
+    // We provide a general mechanism for our tests to know when they can
+    // safely run: we add a final form that we know will be filled in, wait
+    // for the login manager to tell us that it's filled in and then continue
+    // with the rest of the tests.
+    if (document.readyState == "complete" ||
+        document.readyState == "loaded" ||
+        document.readyState == "interactive") {
+      onDOMContentLoaded();
+    } else {
+      window.addEventListener("DOMContentLoaded", onDOMContentLoaded);
+    }
   });
 }
 
 function enableMasterPassword() {
   setMasterPassword(true);
 }
 
 function disableMasterPassword() {
@@ -273,28 +280,53 @@ function promisePromptShown(expectedTopi
 function runInParent(aFunctionOrURL) {
   let chromeScript = SpecialPowers.loadChromeScript(aFunctionOrURL);
   SimpleTest.registerCleanupFunction(() => {
     chromeScript.destroy();
   });
   return chromeScript;
 }
 
+/*
+ * gTestDependsOnDeprecatedLogin Set this global to true if your test relies
+ * on the testuser/testpass login that is created in pwmgr_common.js. New tests
+ * should not rely on this login.
+ */
+var gTestDependsOnDeprecatedLogin = false;
+
+/**
+ * Replace the content innerHTML with the provided form and wait for autofill to fill in the form.
+ *
+ * @param {string} form The form to be appended to the #content element.
+ * @param {string} fieldSelector The CSS selector for the field to-be-filled
+ * @param {string} fieldValue The value expected to be filled
+ * @param {string} formId The ID (excluding the # character) of the form
+ */
+function setFormAndWaitForFieldFilled(form, {fieldSelector, fieldValue, formId}) {
+  // eslint-disable-next-line no-unsanitized/property
+  document.querySelector("#content").innerHTML = form;
+  return SimpleTest.promiseWaitForCondition(() => {
+    let ancestor = formId ? document.querySelector("#" + formId) :
+                            document.documentElement;
+    return ancestor.querySelector(fieldSelector).value == fieldValue;
+  }, "Wait for password manager to fill form");
+}
+
 /**
  * Run commonInit synchronously in the parent then run the test function after the runTests event.
  *
  * @param {Function} aFunction The test function to run
  */
 function runChecksAfterCommonInit(aFunction = null) {
   SimpleTest.waitForExplicitFinish();
   if (aFunction) {
     window.addEventListener("runTests", aFunction);
     PWMGR_COMMON_PARENT.addMessageListener("registerRunTests", () => registerRunTests());
   }
-  PWMGR_COMMON_PARENT.sendSyncMessage("setupParent");
+  PWMGR_COMMON_PARENT.sendSyncMessage("setupParent", {testDependsOnDeprecatedLogin: gTestDependsOnDeprecatedLogin});
   return PWMGR_COMMON_PARENT;
 }
 
 // Begin code that runs immediately for all tests that include this file.
 
 const PWMGR_COMMON_PARENT = runInParent(SimpleTest.getTestFileURL("pwmgr_common_parent.js"));
 
 SimpleTest.registerCleanupFunction(() => {
--- a/toolkit/components/passwordmgr/test/mochitest/pwmgr_common_parent.js
+++ b/toolkit/components/passwordmgr/test/mochitest/pwmgr_common_parent.js
@@ -16,41 +16,43 @@ const {LoginTestUtils} = ChromeUtils.imp
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Init with a common login
  * If selfFilling is true or non-undefined, fires an event at the page so that
  * the test can start checking filled-in values. Tests that check observer
  * notifications might be confused by this.
  */
-function commonInit(selfFilling) {
+function commonInit(selfFilling, testDependsOnDeprecatedLogin) {
   var pwmgr = Services.logins;
   assert.ok(pwmgr != null, "Access LoginManager");
 
   // Check that initial state has no logins
   var logins = pwmgr.getAllLogins();
   assert.equal(logins.length, 0, "Not expecting logins to be present");
   var disabledHosts = pwmgr.getAllDisabledHosts();
   if (disabledHosts.length) {
     assert.ok(false, "Warning: wasn't expecting disabled hosts to be present.");
     for (var host of disabledHosts) {
       pwmgr.setLoginSavingEnabled(host, true);
     }
   }
 
-  // Add a login that's used in multiple tests
-  var login = Cc["@mozilla.org/login-manager/loginInfo;1"].
-              createInstance(Ci.nsILoginInfo);
-  login.init("http://mochi.test:8888", "http://mochi.test:8888", null,
-             "testuser", "testpass", "uname", "pword");
-  pwmgr.addLogin(login);
+  if (testDependsOnDeprecatedLogin) {
+    // Add a login that's used in multiple tests
+    var login = Cc["@mozilla.org/login-manager/loginInfo;1"].
+                createInstance(Ci.nsILoginInfo);
+    login.init("http://mochi.test:8888", "http://mochi.test:8888", null,
+               "testuser", "testpass", "uname", "pword");
+    pwmgr.addLogin(login);
+  }
 
   // Last sanity check
   logins = pwmgr.getAllLogins();
-  assert.equal(logins.length, 1, "Checking for successful init login");
+  assert.equal(logins.length, testDependsOnDeprecatedLogin ? 1 : 0, "Checking for successful init login");
   disabledHosts = pwmgr.getAllDisabledHosts();
   assert.equal(disabledHosts.length, 0, "Checking for no disabled hosts");
 
   if (selfFilling) {
     return;
   }
 
   // Notify the content side that initialization is done and tests can start.
@@ -99,18 +101,18 @@ function onPrompt(subject, topic, data) 
   });
 }
 Services.obs.addObserver(onPrompt, "passwordmgr-prompt-change");
 Services.obs.addObserver(onPrompt, "passwordmgr-prompt-save");
 
 
 // Begin message listeners
 
-addMessageListener("setupParent", ({selfFilling = false} = {selfFilling: false}) => {
-  commonInit(selfFilling);
+addMessageListener("setupParent", ({selfFilling = false, testDependsOnDeprecatedLogin = false} = {}) => {
+  commonInit(selfFilling, testDependsOnDeprecatedLogin);
   sendAsyncMessage("doneSetup");
 });
 
 addMessageListener("loadRecipes", async function(recipes) {
   var recipeParent = await LoginManagerParent.recipeParentPromise;
   await recipeParent.load(recipes);
   sendAsyncMessage("loadedRecipes", recipes);
 });
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form.html
@@ -6,39 +6,42 @@
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: simple form fill
 
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(startTest);
 
 /** Test for Login Manager: form fill, multiple forms. **/
 
-function startTest() {
+async function startTest() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form1" action="formtest.js">
+      <p>This is form 1.</p>
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+
+      <button type="submit">Submit</button>
+      <button type="reset"> Reset </button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "testuser"});
+
   is($_(1, "uname").value, "testuser", "Checking for filled username");
   is($_(1, "pword").value, "testpass", "Checking for filled password");
 
   SimpleTest.finish();
 }
 </script>
 
 <p id="display"></p>
 
 <div id="content" style="display: none">
 
-  <form id="form1" action="formtest.js">
-    <p>This is form 1.</p>
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-
-    <button type="submit">Submit</button>
-    <button type="reset"> Reset </button>
-  </form>
 
 </div>
 
 <pre id="test"></pre>
 </body>
 </html>
 
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_1pw.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_1pw.html
@@ -5,16 +5,17 @@
   <title>Test autofill for forms with 1 password field</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: forms with 1 password field
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 
 <div id="content" style="display: none">
 
 <!-- no username fields -->
 
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_1pw_2.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_1pw_2.html
@@ -5,16 +5,17 @@
   <title>Test forms with 1 password field, part 2</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: forms with 1 password field, part 2
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 
 <div id="content" style="display: none">
 
 <form id='form1' action='formtest.js'> 1
     <input type='password' name='pname' value=''>
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_2pw_1.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_2pw_1.html
@@ -5,16 +5,17 @@
   <title>Test autofill for forms with 2 password fields</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: forms with 2 password fields
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 
 <div id="content" style="display: none">
 
 
 <!-- no username fields -->
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_3pw_1.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_3pw_1.html
@@ -5,16 +5,17 @@
   <title>Test autofill for forms with 3 password fields</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: forms with 3 password fields (form filling)
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 
 <div id="content" style="display: none">
   <p>The next three forms are <b>user/pass/passB/passC</b>, as all-empty, preuser(only), and preuser/pass</p>
   <form id="form1" action="formtest.js">
     <input  type="text"       name="uname">
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html
@@ -20,71 +20,66 @@ var setupScript = runInParent(function s
   const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
   // Create some logins just for this form, since we'll be deleting them.
   var nsLoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
                                            Ci.nsILoginInfo, "init");
   assert.ok(nsLoginInfo != null, "nsLoginInfo constructor");
 
   // login0 has no username, so should be filtered out from the autocomplete list.
-  var login0 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login0 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "", "user0pass", "", "pword");
 
-  var login1 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login1 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "tempuser1", "temppass1", "uname", "pword");
 
-  var login2 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login2 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "testuser2", "testpass2", "uname", "pword");
 
-  var login3 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login3 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "testuser3", "testpass3", "uname", "pword");
 
-  var login4 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login4 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "zzzuser4", "zzzpass4", "uname", "pword");
 
+  // The following unused variables are referenced by `eval` in the message listeners below.
   // login 5 only used in the single-user forms
-  var login5 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete2", null,
+  /* eslint-disable no-unused-vars */
+  var login5 = new nsLoginInfo("https://example.com", "https://autocomplete2", null,
                                "singleuser5", "singlepass5", "uname", "pword");
 
-  var login6A = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete3", null,
+  var login6A = new nsLoginInfo("https://example.com", "https://autocomplete3", null,
                                 "form7user1", "form7pass1", "uname", "pword");
-  var login6B = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete3", null,
+  var login6B = new nsLoginInfo("https://example.com", "https://autocomplete3", null,
                                 "form7user2", "form7pass2", "uname", "pword");
 
-  var login7  = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete4", null,
+  var login7  = new nsLoginInfo("https://example.com", "https://autocomplete4", null,
                                 "form8user", "form8pass", "uname", "pword");
 
-  var login8A = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete5", null,
+  var login8A = new nsLoginInfo("https://example.com", "https://autocomplete5", null,
                                 "form9userAB", "form9pass", "uname", "pword");
-  var login8B = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete5", null,
+  var login8B = new nsLoginInfo("https://example.com", "https://autocomplete5", null,
                                 "form9userAAB", "form9pass", "uname", "pword");
-  // Reference by `eval` in the message listeners below.
-  // eslint-disable-next-line no-unused-vars
-  var login8C = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete5", null,
+  var login8C = new nsLoginInfo("https://example.com", "https://autocomplete5", null,
                                 "form9userAABzz", "form9pass", "uname", "pword");
 
-  var login10 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete7", null,
+  var login10 = new nsLoginInfo("https://example.com", "https://autocomplete7", null,
                                 "testuser10", "testpass10", "uname", "pword");
 
+  var login11 = new nsLoginInfo("https://example.com", "https://example.com", null,
+                                "testuser11", "testpass11", "uname", "pword");
+  /* eslint-enable no-unused-vars */
 
   // try/catch in case someone runs the tests manually, twice.
   try {
     Services.logins.addLogin(login0);
     Services.logins.addLogin(login1);
     Services.logins.addLogin(login2);
     Services.logins.addLogin(login3);
     Services.logins.addLogin(login4);
-    Services.logins.addLogin(login5);
-    Services.logins.addLogin(login6A);
-    Services.logins.addLogin(login6B);
-    Services.logins.addLogin(login7);
-    Services.logins.addLogin(login8A);
-    Services.logins.addLogin(login8B);
-    // login8C is added later
-    Services.logins.addLogin(login10);
   } catch (e) {
     assert.ok(false, "addLogin threw: " + e);
   }
 
   addMessageListener("addLogin", loginVariableName => {
     // eslint-disable-next-line no-eval
     let login = eval(loginVariableName);
     assert.ok(!!login, "Login to add is defined: " + loginVariableName);
@@ -99,95 +94,23 @@ var setupScript = runInParent(function s
 });
 </script>
 <p id="display"></p>
 
 <!-- we presumably can't hide the content for this test. -->
 <div id="content">
 
   <!-- form1 tests multiple matching logins -->
-  <form id="form1" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
   <!-- other forms test single logins, with autocomplete=off set -->
-  <form id="form2" action="http://autocomplete2" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword" autocomplete="off">
-    <button type="submit">Submit</button>
-  </form>
-
-  <form id="form3" action="http://autocomplete2" onsubmit="return false;">
-    <input  type="text"       name="uname" autocomplete="off">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <form id="form4" action="http://autocomplete2" onsubmit="return false;" autocomplete="off">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <form id="form5" action="http://autocomplete2" onsubmit="return false;">
-    <input  type="text"       name="uname" autocomplete="off">
-    <input  type="password"   name="pword" autocomplete="off">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- control -->
-  <form id="form6" action="http://autocomplete2" onsubmit="return false;">
+  <form id="form1" action="https://autocomplete:8888/formtest.js" onsubmit="return false;">
     <input  type="text"       name="uname">
     <input  type="password"   name="pword">
     <button type="submit">Submit</button>
   </form>
 
-  <!-- This form will be manipulated to insert a different username field. -->
-  <form id="form7" action="http://autocomplete3" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- test for no autofill after onblur with blank username -->
-  <form id="form8" action="http://autocomplete4" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- test autocomplete dropdown -->
-  <form id="form9" action="http://autocomplete5" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- tests <form>-less autocomplete -->
-  <div id="form11">
-     <input  type="text"       name="uname" id="uname">
-     <input  type="password"   name="pword" id="pword">
-     <button type="submit">Submit</button>
-  </div>
-
-  <!-- test for onUsernameInput recipe testing -->
-  <form id="form12" action="http://autocomplete7" onsubmit="return false;">
-    <input  type="text"   name="1">
-    <input  type="text"   name="2">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- test not closing when the search string (.value) becomes empty -->
-  <form id="form13" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
-    <input  type="text"       name="uname" value="prefilled">
-    <input  type="password"   name="pword" value="prefilled">
-    <button type="submit">Submit</button>
-  </form>
 </div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Login Manager: multiple login autocomplete. **/
 
 var uname = $_(1, "uname");
@@ -240,17 +163,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"];
-  checkAutoCompleteResults(results, expectedMenuItems, "mochi.test", "Check all menuitems are displayed correctly.");
+  checkAutoCompleteResults(results, expectedMenuItems, "example.com", "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() {
@@ -463,28 +386,28 @@ add_task(async function test_form1_delet
 
   // XXX tried sending character "t" before/during dropdown to test
   // filtering, but had no luck. Seemed like the character was getting lost.
   // 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);
+  let numLogins = LoginManager.countLogins("https://example.com", "https://autocomplete:8888", null);
   is(numLogins, 5, "Correct number of logins before deleting one");
 
   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);
+  numLogins = LoginManager.countLogins("https://example.com", "https://autocomplete:8888", null);
   is(numLogins, 4, "Correct number of logins after deleting one");
   await countChangedPromise;
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("testuser2", "testpass2");
 });
 
 add_task(async function test_form1_first_after_deletion() {
@@ -506,17 +429,17 @@ add_task(async function test_form1_delet
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   // Delete the second entry (of 3), "testuser3"
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Delete", {shiftKey: true});
   checkACForm("", "");
-  let numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
+  let numLogins = LoginManager.countLogins("https://example.com", "https://autocomplete:8888", null);
   is(numLogins, 3, "Correct number of logins after deleting one");
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_first_after_deletion2() {
   restoreForm();
@@ -538,17 +461,17 @@ add_task(async function test_form1_delet
   await shownPromise;
 
   /* 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);
+  let numLogins = LoginManager.countLogins("https://example.com", "https://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() {
@@ -570,25 +493,37 @@ add_task(async function test_form1_check
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   /* test 56 */
   // Delete the only remaining entry, "testuser2"
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Delete", {shiftKey: true});
   checkACForm("", "");
-  let numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
+  let numLogins = LoginManager.countLogins("https://example.com", "https://autocomplete:8888", null);
   is(numLogins, 1, "Correct number of logins after deleting one");
 
-  // remove the login that's not shown in the list.
+  // remove the logins for the previous tests
   setupScript.sendSyncMessage("removeLogin", "login0");
+  setupScript.sendSyncMessage("removeLogin", "login1");
+  setupScript.sendSyncMessage("removeLogin", "login2");
+  setupScript.sendSyncMessage("removeLogin", "login3");
+  setupScript.sendSyncMessage("removeLogin", "login4");
+  setupScript.sendSyncMessage("addLogin", "login5");
 });
 
 /* Tests for single-user forms for ignoring autocomplete=off */
 add_task(async function test_form2() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form2" action="https://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword" autocomplete="off">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   // Turn our attention to form2
   uname = $_(2, "uname");
   pword = $_(2, "pword");
   checkACForm("singleuser5", "singlepass5");
 
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
@@ -598,16 +533,23 @@ add_task(async function test_form2() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form3() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form3" action="https://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname" autocomplete="off">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   uname = $_(3, "uname");
   pword = $_(3, "pword");
   checkACForm("singleuser5", "singlepass5");
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
@@ -615,16 +557,23 @@ add_task(async function test_form3() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form4() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form4" action="https://autocomplete2" onsubmit="return false;" autocomplete="off">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   uname = $_(4, "uname");
   pword = $_(4, "pword");
   checkACForm("singleuser5", "singlepass5");
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
@@ -632,16 +581,23 @@ add_task(async function test_form4() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form5() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form5" action="https://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname" autocomplete="off">
+      <input  type="password"   name="pword" autocomplete="off">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   uname = $_(5, "uname");
   pword = $_(5, "pword");
   checkACForm("singleuser5", "singlepass5");
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
@@ -649,16 +605,24 @@ add_task(async function test_form5() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form6() {
+  await setFormAndWaitForFieldFilled(`
+    <!-- control -->
+    <form id="form6" action="https://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   // (this is a control, w/o autocomplete=off, to ensure the login
   // that was being suppressed would have been filled in otherwise)
   uname = $_(6, "uname");
   pword = $_(6, "pword");
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form6_changeUsername() {
@@ -666,21 +630,32 @@ add_task(async function test_form6_chang
   // the username.
   uname.focus();
   synthesizeKey("KEY_ArrowRight");
   synthesizeKey("X", {shiftKey: true});
   // Trigger the 'blur' event on uname
   pword.focus();
   await spinEventLoop();
   checkACForm("singleuser5X", "singlepass5");
+  uname.focus();
 
   setupScript.sendSyncMessage("removeLogin", "login5");
 });
 
 add_task(async function test_form7() {
+  setupScript.sendSyncMessage("addLogin", "login6A");
+  setupScript.sendSyncMessage("addLogin", "login6B");
+  await setFormAndWaitForFieldFilled(`
+    <!-- This form will be manipulated to insert a different username field. -->
+    <form id="form7" action="https://autocomplete3" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: ""});
+
   uname = $_(7, "uname");
   pword = $_(7, "pword");
   checkACForm("", "");
 
   // Insert a new username field into the form. We'll then make sure
   // that invoking the autocomplete doesn't try to fill the form.
   var newField = document.createElement("input");
   newField.setAttribute("type", "text");
@@ -711,16 +686,31 @@ add_task(async function test_form7_2() {
   checkACForm("form7user1", "");
   is($_(7, "uname2").value, "", "Verifying empty uname2");
   restoreForm(); // clear field, so reloading test doesn't fail
 
   setupScript.sendSyncMessage("removeLogin", "login6A");
 });
 
 add_task(async function test_form8() {
+  setupScript.sendSyncMessage("addLogin", "login7");
+  await setFormAndWaitForFieldFilled(`
+    <!-- This form will be manipulated to insert a different username field. -->
+    <form id="form7" action="https://autocomplete3" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>
+    <!-- test for no autofill after onblur with blank username -->
+    <form id="form8" action="https://autocomplete4" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "form8user", formId: "form8"});
+
   uname = $_(8, "uname");
   pword = $_(8, "pword");
   checkACForm("form8user", "form8pass");
   restoreForm();
 });
 
 add_task(async function test_form8_blur() {
   checkACForm("", "");
@@ -731,77 +721,99 @@ add_task(async function test_form8_blur(
 add_task(async function test_form8_2() {
   checkACForm("", "");
   restoreForm();
 });
 
 add_task(async function test_form8_3() {
   checkACForm("", "");
   setupScript.sendSyncMessage("removeLogin", "login7");
+  setupScript.sendSyncMessage("addLogin", "login8A");
+  setupScript.sendSyncMessage("addLogin", "login8B");
 });
 
 add_task(async function test_form9_filtering() {
+  await setFormAndWaitForFieldFilled(`
+    <!-- test autocomplete dropdown -->
+    <form id="form9" action="https://autocomplete5" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: ""});
+
   // Turn our attention to form9 to test the dropdown - bug 497541
   uname = $_(9, "uname");
   pword = $_(9, "pword");
   uname.focus();
   let shownPromise = promiseACShown();
   sendString("form9userAB");
   await shownPromise;
 
   checkACForm("form9userAB", "");
   uname.focus();
   synthesizeKey("KEY_ArrowLeft");
   shownPromise = promiseACShown();
   synthesizeKey("A", {shiftKey: true});
   let results = await shownPromise;
 
   checkACForm("form9userAAB", "");
-  checkAutoCompleteResults(results, ["form9userAAB"], "mochi.test", "Check dropdown is updated after inserting 'A'");
+  checkAutoCompleteResults(results, ["form9userAAB"], "example.com", "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 promise1 = notifyMenuChanged(1);
   sendString("z");
   let results = await promise1;
-  checkAutoCompleteResults(results, [], "mochi.test", "Check popup does not have any login items");
+  checkAutoCompleteResults(results, [], "example.com", "Check popup does not have any login items");
 
   // check that empty results are cached - bug 496466
   promise1 = notifyMenuChanged(1);
   sendString("z");
   results = await promise1;
-  checkAutoCompleteResults(results, [], "mochi.test", "Check popup only has the footer when it opens");
+  checkAutoCompleteResults(results, [], "example.com", "Check popup only has the footer when it opens");
 });
 
 add_task(async function test_form11_formless() {
+  setupScript.sendSyncMessage("removeLogin", "login8A");
+  setupScript.sendSyncMessage("removeLogin", "login8B");
+  setupScript.sendSyncMessage("removeLogin", "login8C");
+  setupScript.sendSyncMessage("addLogin", "login11");
+  await setFormAndWaitForFieldFilled(`
+    <!-- tests <form>-less autocomplete -->
+    <div id="form11">
+      <input  type="text"       name="uname" id="uname">
+      <input  type="password"   name="pword" id="pword">
+      <button type="submit">Submit</button>
+    </div>`, {fieldSelector: `input[name="uname"]`, fieldValue: "testuser11"});
+
   // Test form-less autocomplete
   uname = $_(11, "uname");
   pword = $_(11, "pword");
   restoreForm();
   checkACForm("", "");
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   // Trigger autocomplete
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   let processedPromise = promiseFormsProcessed();
   synthesizeKey("KEY_Enter");
   await processedPromise;
-  checkACForm("testuser", "testpass");
+  checkACForm("testuser11", "testpass11");
 });
 
 add_task(async function test_form11_open_on_trusted_focus() {
   uname = $_(11, "uname");
   pword = $_(11, "pword");
   uname.value = "";
   pword.value = "";
 
@@ -818,23 +830,33 @@ add_task(async function test_form11_open
   const shownPromise = promiseACShown();
   synthesizeMouseAtCenter(uname, {});
   await firePrivEventPromise;
   await shownPromise;
   synthesizeKey("KEY_ArrowDown");
   const processedPromise = promiseFormsProcessed();
   synthesizeKey("KEY_Enter");
   await processedPromise;
-  checkACForm("testuser", "testpass");
+  checkACForm("testuser11", "testpass11");
+  setupScript.sendSyncMessage("removeLogin", "login11");
 });
 
 add_task(async function test_form12_recipes() {
+  setupScript.sendSyncMessage("addLogin", "login10");
+  await setFormAndWaitForFieldFilled(`
+    <!-- test for onUsernameInput recipe testing -->
+    <form id="form12" action="https://autocomplete7" onsubmit="return false;">
+      <input  type="text"   name="1">
+      <input  type="text"   name="2">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="1"]`, fieldValue: ""});
+
   await loadRecipes({
     siteRecipes: [{
-      "hosts": ["mochi.test:8888"],
+      "hosts": ["example.com"],
       "usernameSelector": "input[name='1']",
       "passwordSelector": "input[name='2']",
     }],
   });
   uname = $_(12, "1");
   pword = $_(12, "2");
 
   // First test DOMAutocomplete
@@ -861,16 +883,24 @@ add_task(async function test_form12_reci
   checkACForm("testuser10", "");
   synthesizeKey("KEY_Tab");
   await promiseFormsProcessed();
   checkACForm("testuser10", "testpass10");
   await resetRecipes();
 });
 
 add_task(async function test_form13_stays_open_upon_empty_search() {
+  await setFormAndWaitForFieldFilled(`
+    <!-- test not closing when the search string (.value) becomes empty -->
+    <form id="form13" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
+      <input  type="text"       name="uname" value="prefilled">
+      <input  type="password"   name="pword" value="prefilled">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "prefilled"});
+
   uname = $_(13, "uname");
   pword = $_(13, "pword");
   checkACForm("prefilled", "prefilled");
 
   uname.scrollIntoView();
   let shownPromise = promiseACShown();
   synthesizeMouseAtCenter(uname, {});
   await shownPromise;
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_pwevent.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_pwevent.html
@@ -6,37 +6,32 @@ https://bugzilla.mozilla.org/show_bug.cg
 <head>
   <meta charset="utf-8"/>
   <title>Test for Bug 355063</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <script type="application/javascript">
   /** Test for Bug 355063 **/
-
-  runChecksAfterCommonInit(function startTest() {
+  gTestDependsOnDeprecatedLogin = true;
+  runChecksAfterCommonInit(async function startTest() {
     info("startTest");
     // Password Manager's own listener should always have been added first, so
     // the test's listener should be called after the pwmgr's listener fills in
     // a login.
     //
     SpecialPowers.addChromeEventListener("DOMFormHasPassword", function eventFired() {
       SpecialPowers.removeChromeEventListener("DOMFormHasPassword", eventFired);
       var passField = $("p1");
       passField.addEventListener("input", checkForm);
     });
-    addForm();
+    await setFormAndWaitForFieldFilled("<form id=form1>form1: <input id=u1><input type=password id=p1></form><br>",
+                                       {fieldSelector: "#u1", fieldValue: "testuser"});
   });
 
-  function addForm() {
-    info("addForm");
-    var c = document.getElementById("content");
-    c.innerHTML = "<form id=form1>form1: <input id=u1><input type=password id=p1></form><br>";
-  }
-
   function checkForm() {
     info("checkForm");
     var userField = document.getElementById("u1");
     var passField = document.getElementById("p1");
     is(userField.value, "testuser", "checking filled username");
     is(passField.value, "testpass", "checking filled password");
 
     SimpleTest.finish();
--- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_pwonly.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_pwonly.html
@@ -5,16 +5,17 @@
   <title>Test forms and logins without a username</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: forms and logins without a username.
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 runInParent(() => {
   const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
   var nsLoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo);
 
   // pwlogin1 uses a unique formSubmitURL, to check forms where no other logins
   // will apply. pwlogin2 uses the normal formSubmitURL, so that we can test
   // forms with a mix of username and non-username logins that might apply.
--- a/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html
@@ -18,23 +18,23 @@ runChecksAfterCommonInit(false);
 
 SpecialPowers.loadChromeScript(function addLogins() {
   const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
   // Create some logins just for this form, since we'll be deleting them.
   var nsLoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
                                            Ci.nsILoginInfo, "init");
 
-  var login0 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login0 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "name", "pass", "uname", "pword");
 
-  var login1 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login1 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "Name", "Pass", "uname", "pword");
 
-  var login2 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
+  var login2 = new nsLoginInfo("https://example.com", "https://autocomplete:8888", null,
                                "USER", "PASS", "uname", "pword");
 
   try {
     Services.logins.addLogin(login0);
     Services.logins.addLogin(login1);
     Services.logins.addLogin(login2);
   } catch (e) {
     assert.ok(false, "addLogin threw: " + e);
@@ -42,17 +42,17 @@ SpecialPowers.loadChromeScript(function 
 });
 </script>
 <p id="display"></p>
 
 <!-- we presumably can't hide the content for this test. -->
 <div id="content">
 
   <!-- form1 tests multiple matching logins -->
-  <form id="form1" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
+  <form id="form1" action="https://autocomplete:8888/formtest.js" onsubmit="return false;">
     <input  type="text"       name="uname">
     <input  type="password"   name="pword">
     <button type="submit">Submit</button>
   </form>
 
 </div>
 
 <pre id="test">
@@ -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");
-  checkAutoCompleteResults(results, ["name", "Name", "USER"], "mochi.test", "initial");
+  checkAutoCompleteResults(results, ["name", "Name", "USER"], "example.com", "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_form_action_1.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_form_action_1.html
@@ -5,16 +5,17 @@
   <title>Test for considering form action</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: Bug 360493
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 <div id="content" style="display: none">
 
   <!-- normal form with normal relative action. -->
   <form id="form1" action="formtest.js">
     <input  type="text"       name="uname">
--- a/toolkit/components/passwordmgr/test/mochitest/test_form_action_2.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_form_action_2.html
@@ -5,16 +5,17 @@
   <title>Test for considering form action</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: Bug 360493
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 <div id="content" style="display: none">
 
   <!-- The tests in this page exercise things that shouldn't work. -->
 
   <!-- Change port # of action URL from 8888 to 7777 -->
--- a/toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html
@@ -8,17 +8,17 @@
   <script src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <script type="application/javascript">
 document.addEventListener("DOMContentLoaded", () => {
   document.getElementById("loginFrame").addEventListener("load", (evt) => {
     // Tell the parent to setup test logins.
-    PWMGR_COMMON_PARENT.sendAsyncMessage("setupParent", { selfFilling: true });
+    PWMGR_COMMON_PARENT.sendAsyncMessage("setupParent", { selfFilling: true, testDependsOnDeprecatedLogin: true });
   });
 });
 
 let doneSetupPromise = new Promise(resolve => {
   // When the setup is done, load a recipe for this test.
   PWMGR_COMMON_PARENT.addMessageListener("doneSetup", function doneSetup() {
     resolve();
   });
--- a/toolkit/components/passwordmgr/test/mochitest/test_input_events.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_input_events.html
@@ -6,16 +6,17 @@
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="onNewEvent(event)">
 Login Manager test: input events should fire.
 
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit();
 
 SimpleTest.requestFlakyTimeout("untriaged");
 
 /** Test for Login Manager: form fill, should get input events. **/
 
 var usernameInputFired = false;
 var passwordInputFired = false;
--- a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html
@@ -35,16 +35,17 @@ var setupScript = runInParent(function s
                                   "testuser2", "testpass2", "uname", "pword");
 
   logins.login3 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
                                   "testuser3", "testpass3", "uname", "pword");
 
   logins.login4 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
                                   "zzzuser4", "zzzpass4", "uname", "pword");
 
+  // The following logins are added later
   // login 5 only used in the single-user forms
   logins.login5 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete2", null,
                                   "singleuser5", "singlepass5", "uname", "pword");
 
   logins.login6A = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete3", null,
                                    "form7user1", "form7pass1", "uname", "pword");
   logins.login6B = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete3", null,
                                    "form7user2", "form7pass2", "uname", "pword");
@@ -65,24 +66,16 @@ var setupScript = runInParent(function s
 
   // try/catch in case someone runs the tests manually, twice.
   try {
     Services.logins.addLogin(logins.login0);
     Services.logins.addLogin(logins.login1);
     Services.logins.addLogin(logins.login2);
     Services.logins.addLogin(logins.login3);
     Services.logins.addLogin(logins.login4);
-    Services.logins.addLogin(logins.login5);
-    Services.logins.addLogin(logins.login6A);
-    Services.logins.addLogin(logins.login6B);
-    Services.logins.addLogin(logins.login7);
-    Services.logins.addLogin(logins.login8A);
-    Services.logins.addLogin(logins.login8B);
-    // login8C is added later
-    Services.logins.addLogin(logins.login10);
   } catch (e) {
     assert.ok(false, "addLogin threw: " + e);
   }
 
   addMessageListener("addLogin", loginVariableName => {
     let login = logins[loginVariableName];
     assert.ok(!!login, "Login to add is defined: " + loginVariableName);
     Services.logins.addLogin(login);
@@ -101,89 +94,16 @@ var setupScript = runInParent(function s
 
   <!-- form1 tests multiple matching logins -->
   <form id="form1" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
     <input  type="text"       name="uname">
     <input  type="password"   name="pword">
     <button type="submit">Submit</button>
   </form>
 
-  <!-- other forms test single logins, with autocomplete=off set -->
-  <form id="form2" action="http://autocomplete2" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword" autocomplete="off">
-    <button type="submit">Submit</button>
-  </form>
-
-  <form id="form3" action="http://autocomplete2" onsubmit="return false;">
-    <input  type="text"       name="uname" autocomplete="off">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <form id="form4" action="http://autocomplete2" onsubmit="return false;" autocomplete="off">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <form id="form5" action="http://autocomplete2" onsubmit="return false;">
-    <input  type="text"       name="uname" autocomplete="off">
-    <input  type="password"   name="pword" autocomplete="off">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- control -->
-  <form id="form6" action="http://autocomplete2" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- This form will be manipulated to insert a different username field. -->
-  <form id="form7" action="http://autocomplete3" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- test for no autofill after onblur with blank username -->
-  <form id="form8" action="http://autocomplete4" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- test autocomplete dropdown -->
-  <form id="form9" action="http://autocomplete5" onsubmit="return false;">
-    <input  type="text"       name="uname">
-    <input  type="password"   name="pword">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- test for onUsernameInput recipe testing -->
-  <form id="form11" action="http://autocomplete7" onsubmit="return false;">
-    <input  type="text"   name="1">
-    <input  type="text"   name="2">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- tests <form>-less autocomplete -->
-  <div id="form12">
-     <input  type="text"       name="uname" id="uname">
-     <input  type="password"   name="pword" id="pword">
-     <button type="submit">Submit</button>
-  </div>
-
-  <!-- test not closing when the search string (.value) becomes empty -->
-  <form id="form13" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
-    <input  type="text"       name="uname" value="prefilled">
-    <input  type="password"   name="pword" value="prefilled">
-    <button type="submit">Submit</button>
-  </form>
 </div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Login Manager: multiple login autocomplete. **/
 
 SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal", true]]});
@@ -476,28 +396,28 @@ add_task(async function test_form1_delet
   // filtering, but had no luck. Seemed like the character was getting lost.
   // Setting uname.value didn't seem to work either. This works with a human
   // driver, so I'm not sure what's up.
 
   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);
+  numLogins = LoginManager.countLogins("http://mochi.test:8888", "", null);
   is(numLogins, 5, "Correct number of logins before deleting one");
 
   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);
+  numLogins = LoginManager.countLogins("http://mochi.test:8888", "", null);
   is(numLogins, 4, "Correct number of logins after deleting one");
   await countChangedPromise;
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("testuser2", "testpass2");
 });
 
 add_task(async function test_form1_first_after_deletion() {
@@ -521,17 +441,17 @@ add_task(async function test_form1_delet
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   // Delete the second entry (of 3), "testuser3"
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Delete", {shiftKey: true});
   checkACForm("", "");
-  let numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
+  let numLogins = LoginManager.countLogins("http://mochi.test:8888", "", null);
   is(numLogins, 3, "Correct number of logins after deleting one");
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("zzzuser4", "zzzpass4");
 });
 
 add_task(async function test_form1_first_after_deletion2() {
   restoreForm();
@@ -555,17 +475,17 @@ add_task(async function test_form1_delet
 
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   // 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);
+  let numLogins = LoginManager.countLogins("http://mochi.test: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");
 });
 
@@ -590,25 +510,34 @@ add_task(async function test_form1_check
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   // test 56
   // Delete the only remaining entry, "testuser2"
   synthesizeKey("KEY_ArrowDown");
   synthesizeKey("KEY_Delete", {shiftKey: true});
   checkACForm("", "");
-  let numLogins = LoginManager.countLogins("http://mochi.test:8888", "http://autocomplete:8888", null);
+  let numLogins = LoginManager.countLogins("http://mochi.test:8888", "", null);
   is(numLogins, 1, "Correct number of logins after deleting one");
 
   // remove the login that's not shown in the list.
   setupScript.sendSyncMessage("removeLogin", "login0");
 });
 
 // Tests for single-user forms for ignoring autocomplete=off
 add_task(async function test_form2() {
+  setupScript.sendSyncMessage("addLogin", "login5");
+  await setFormAndWaitForFieldFilled(`
+    <!-- other forms test single logins, with autocomplete=off set -->
+    <form id="form2" action="http://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword" autocomplete="off">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   // Turn our attention to form2
   uname = $_(2, "uname");
   pword = $_(2, "pword");
   checkACForm("singleuser5", "singlepass5");
 
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
@@ -619,16 +548,23 @@ add_task(async function test_form2() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form3() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form3" action="http://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname" autocomplete="off">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   uname = $_(3, "uname");
   pword = $_(3, "pword");
   checkACForm("singleuser5", "singlepass5");
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
@@ -637,16 +573,23 @@ add_task(async function test_form3() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form4() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form4" action="http://autocomplete2" onsubmit="return false;" autocomplete="off">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   uname = $_(4, "uname");
   pword = $_(4, "pword");
   checkACForm("singleuser5", "singlepass5");
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
@@ -655,16 +598,23 @@ add_task(async function test_form4() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form5() {
+  await setFormAndWaitForFieldFilled(`
+    <form id="form5" action="http://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname" autocomplete="off">
+      <input  type="password"   name="pword" autocomplete="off">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   uname = $_(5, "uname");
   pword = $_(5, "pword");
   checkACForm("singleuser5", "singlepass5");
   restoreForm();
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
@@ -673,16 +623,24 @@ add_task(async function test_form5() {
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   synthesizeKey("KEY_Enter");
   await promiseFormsProcessed();
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form6() {
+  await setFormAndWaitForFieldFilled(`
+    <!-- control -->
+    <form id="form6" action="http://autocomplete2" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "singleuser5"});
+
   // (this is a control, w/o autocomplete=off, to ensure the login
   // that was being suppressed would have been filled in otherwise)
   uname = $_(6, "uname");
   pword = $_(6, "pword");
   checkACForm("singleuser5", "singlepass5");
 });
 
 add_task(async function test_form6_changeUsername() {
@@ -690,21 +648,32 @@ add_task(async function test_form6_chang
   // the username.
   uname.focus();
   synthesizeKey("KEY_ArrowRight");
   synthesizeKey("X", {shiftKey: true});
   // Trigger the 'blur' event on uname
   pword.focus();
   await spinEventLoop();
   checkACForm("singleuser5X", "singlepass5");
+  uname.focus();
 
   setupScript.sendSyncMessage("removeLogin", "login5");
 });
 
 add_task(async function test_form7() {
+  setupScript.sendSyncMessage("addLogin", "login6A");
+  setupScript.sendSyncMessage("addLogin", "login6B");
+  await setFormAndWaitForFieldFilled(`
+    <!-- This form will be manipulated to insert a different username field. -->
+    <form id="form7" action="http://autocomplete3" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: ""});
+
   uname = $_(7, "uname");
   pword = $_(7, "pword");
   checkACForm("", "");
 
   // Insert a new username field into the form. We'll then make sure
   // that invoking the autocomplete doesn't try to fill the form.
   var newField = document.createElement("input");
   newField.setAttribute("type", "text");
@@ -736,16 +705,32 @@ add_task(async function test_form7_2() {
   checkACForm("form7user1", "");
   is($_(7, "uname2").value, "", "Verifying empty uname2");
   restoreForm(); // clear field, so reloading test doesn't fail
 
   setupScript.sendSyncMessage("removeLogin", "login6A");
 });
 
 add_task(async function test_form8() {
+  setupScript.sendSyncMessage("addLogin", "login7");
+  await setFormAndWaitForFieldFilled(`
+    <!-- This form will be manipulated to insert a different username field. -->
+    <form id="form7" action="http://autocomplete3" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>
+    <!-- test for no autofill after onblur with blank username -->
+    <form id="form8" action="http://autocomplete4" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>
+    `, {fieldSelector: `#form8 input[name="uname"]`, fieldValue: "form8user"});
+
   uname = $_(8, "uname");
   pword = $_(8, "pword");
   checkACForm("form8user", "form8pass");
   restoreForm();
 });
 
 add_task(async function test_form8_blur() {
   checkACForm("", "");
@@ -759,16 +744,26 @@ add_task(async function test_form8_2() {
 });
 
 add_task(async function test_form8_3() {
   checkACForm("", "");
   setupScript.sendSyncMessage("removeLogin", "login7");
 });
 
 add_task(async function test_form9_filtering() {
+  setupScript.sendSyncMessage("addLogin", "login8A");
+  setupScript.sendSyncMessage("addLogin", "login8B");
+  await setFormAndWaitForFieldFilled(`
+    <!-- test autocomplete dropdown -->
+    <form id="form9" action="http://autocomplete5" onsubmit="return false;">
+      <input  type="text"       name="uname">
+      <input  type="password"   name="pword">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: ""});
+
   // Turn our attention to form9 to test the dropdown - bug 497541
   uname = $_(9, "uname");
   pword = $_(9, "pword");
   uname.focus();
   let shownPromise = promiseACShown();
   sendString("form9userAB");
   await shownPromise;
 
@@ -809,26 +804,38 @@ add_task(async function test_form9_autoc
   // check that empty results are cached - bug 496466
   promise2 = notifyMenuChanged(2);
   sendString("z");
   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");
+  setupScript.sendSyncMessage("removeLogin", "login8A");
+  setupScript.sendSyncMessage("removeLogin", "login8B");
+  setupScript.sendSyncMessage("removeLogin", "login8C");
 });
 
 add_task(async function test_form11_recipes() {
+  setupScript.sendSyncMessage("addLogin", "login10");
   await loadRecipes({
     siteRecipes: [{
       "hosts": ["mochi.test:8888"],
       "usernameSelector": "input[name='1']",
       "passwordSelector": "input[name='2']",
     }],
   });
+  await setFormAndWaitForFieldFilled(`
+    <!-- test for onUsernameInput recipe testing -->
+    <form id="form11" action="http://autocomplete7" onsubmit="return false;">
+      <input  type="text"   name="1">
+      <input  type="text"   name="2">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="1"]`, fieldValue: ""});
+
   uname = $_(11, "1");
   pword = $_(11, "2");
 
   // First test DOMAutocomplete
   // Switch the password field to type=password so _fillForm marks the username
   // field for autocomplete.
   pword.type = "password";
   await promiseFormsProcessed();
@@ -853,35 +860,51 @@ add_task(async function test_form11_reci
   synthesizeKey("KEY_Tab");
   await promiseFormsProcessed();
   checkACForm("testuser10", "testpass10");
   await resetRecipes();
 });
 
 add_task(async function test_form12_formless() {
   // Test form-less autocomplete
+  await setFormAndWaitForFieldFilled(`
+    <!-- tests <form>-less autocomplete -->
+    <div id="form12">
+      <input  type="text"       name="uname" id="uname">
+      <input  type="password"   name="pword" id="pword">
+      <button type="submit">Submit</button>
+    </div>`, {fieldSelector: `input[name="uname"]`, fieldValue: ""});
+
   uname = $_(12, "uname");
   pword = $_(12, "pword");
   restoreForm();
   checkACForm("", "");
   let shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open
   await shownPromise;
 
   synthesizeKey("KEY_ArrowDown"); // skip insecure warning
   // Trigger autocomplete
   synthesizeKey("KEY_ArrowDown");
   checkACForm("", ""); // value shouldn't update
   let processedPromise = promiseFormsProcessed();
   synthesizeKey("KEY_Enter");
   await processedPromise;
-  checkACForm("testuser", "testpass");
+  checkACForm("testuser10", "testpass10");
 });
 
 add_task(async function test_form13_stays_open_upon_empty_search() {
+  await setFormAndWaitForFieldFilled(`
+    <!-- test not closing when the search string (.value) becomes empty -->
+    <form id="form13" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
+      <input  type="text"       name="uname" value="prefilled">
+      <input  type="password"   name="pword" value="prefilled">
+      <button type="submit">Submit</button>
+    </form>`, {fieldSelector: `input[name="uname"]`, fieldValue: "prefilled"});
+
   uname = $_(13, "uname");
   pword = $_(13, "pword");
   checkACForm("prefilled", "prefilled");
 
   uname.scrollIntoView();
   let shownPromise = promiseACShown();
   synthesizeMouseAtCenter(uname, {});
   await shownPromise;
--- a/toolkit/components/passwordmgr/test/mochitest/test_master_password.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_master_password.html
@@ -24,16 +24,17 @@ Login Manager test: master password.
 "use strict";
 
 // Force parent to not look for tab-modal prompts, as they're not used for auth prompts.
 isTabModal = false;
 
 var exampleCom = "https://example.com/tests/toolkit/components/passwordmgr/test/mochitest/";
 var exampleOrg = "https://example.org/tests/toolkit/components/passwordmgr/test/mochitest/";
 
+gTestDependsOnDeprecatedLogin = true;
 var chromeScript = runChecksAfterCommonInit();
 
 runInParent(() => {
   const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
   var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo);
 
   var login1 = new nsLoginInfo();
--- a/toolkit/components/passwordmgr/test/mochitest/test_maxlength.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_maxlength.html
@@ -5,16 +5,17 @@
   <title>Test for maxlength attributes</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: Bug 391514
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 <div id="content" style="display: none">
   <!-- normal form. -->
   <form id="form1" action="formtest.js">
     <input  type="text"     name="uname">
     <input  type="password" name="pword">
--- a/toolkit/components/passwordmgr/test/mochitest/test_passwords_in_type_password.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_passwords_in_type_password.html
@@ -5,16 +5,17 @@
   <title>Test that passwords only get filled in type=password</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="pwmgr_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Login Manager test: Bug 242956
 <script>
+gTestDependsOnDeprecatedLogin = true;
 runChecksAfterCommonInit(() => startTest());
 </script>
 <p id="display"></p>
 <div id="content" style="display: none">
   <!-- pword is not a type=password input -->
   <form id="form1" action="formtest.js">
     <input  type="text" name="uname">
     <input  type="text" name="pword">
--- a/toolkit/components/passwordmgr/test/mochitest/test_recipe_login_fields.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_recipe_login_fields.html
@@ -5,16 +5,17 @@
   <title>Test for recipes overriding login fields</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <script src="/tests/SimpleTest/AddTask.js"></script>
   <script src="pwmgr_common.js"></script>
   <link rel="stylesheet" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <script>
+gTestDependsOnDeprecatedLogin = true;
 var chromeScript = runChecksAfterCommonInit();
 
 let fillPromiseResolvers = [];
 
 function waitForFills(fillCount) {
   let promises = [];
   while (fillCount--) {
     let promise = new Promise(resolve => fillPromiseResolvers.push(resolve));