gecko-dev/toolkit/components/passwordmgr/test/test_basic_form_2.html

65 строки
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for Login Manager</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: simple form fill with autofillForms disabled
<script>
commonInit();
SimpleTest.waitForExplicitFinish();
var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
.getService(SpecialPowers.Ci.nsILoginManager);
// Assume that the pref starts out true, so set to false
SpecialPowers.setBoolPref("signon.autofillForms", false);
</script>
<p id="display"></p>
<div id="content" style="display: block">
<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">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: simple form fill with autofillForms disabled **/
function startTest(){
// Ensure the form is empty at start
is($_(1, "uname").value, "", "Checking for blank username");
is($_(1, "pword").value, "", "Checking for blank password");
// Call the public method, check return value
is(pwmgr.fillForm(document.getElementById("form1")), true,
"Checking return value of fillForm");
// Check that the form was filled
is($_(1, "uname").value, "testuser", "Checking for filled username");
is($_(1, "pword").value, "testpass", "Checking for filled password");
// Reset pref (since we assumed it was true to start)
SpecialPowers.setBoolPref("signon.autofillForms", true);
SimpleTest.finish();
}
window.onload = startTest;
</script>
</pre>
</body>
</html>