<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=355063
-->
<head>
  <meta charset="utf-8"/>
  <title>Test for Bug 355063</title>
  <script 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 **/
  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);
    });
    await setFormAndWaitForFieldFilled("<form id=form1>form1: <input id=u1><input type=password id=p1></form><br>",
                                       {fieldSelector: "#u1", fieldValue: "testuser"});
  });

  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();
  }
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=355063">Mozilla Bug 355063</a>
<p id="display"></p>
<div id="content">
forms go here!
</div>
<pre id="test">
</pre>
</body>
</html>
