2007-04-22 16:56:06 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
2007-05-16 03:02:45 -07:00
|
|
|
<title>Test for Login Manager</title>
|
2007-04-22 16:56:06 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
|
|
<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>
|
2007-05-16 03:02:45 -07:00
|
|
|
Login Manager test: 227640
|
2007-04-22 16:56:06 -07:00
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
<!-- no autocomplete for password field -->
|
|
|
|
<form id="form1" onsubmit="return checkSubmit(1)" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="uname" value="">
|
|
|
|
<input type="password" name="pword" value="" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for username field -->
|
|
|
|
<form id="form2" onsubmit="return checkSubmit(2);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="uname" value="" autocomplete=off>
|
|
|
|
<input type="password" name="pword" value="">
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for username or password fields -->
|
|
|
|
<form id="form3" onsubmit="return checkSubmit(3);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="uname" value="" autocomplete=off>
|
|
|
|
<input type="password" name="pword" value="" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form -->
|
|
|
|
<form id="form4" onsubmit="return checkSubmit(4);" method="get" autocomplete=off>
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="uname" value="">
|
|
|
|
<input type="password" name="pword" value="">
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form and password field -->
|
|
|
|
<form id="form5" onsubmit="return checkSubmit(5);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="uname" value="">
|
|
|
|
<input type="password" name="pword" value="" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form and username field -->
|
|
|
|
<form id="form6" onsubmit="return checkSubmit(6);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="uname" value="" autocomplete=off>
|
|
|
|
<input type="password" name="pword" value="">
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form, userfield, and password field -->
|
|
|
|
<form id="form7" onsubmit="return checkSubmit(7);" method="get" autocomplete=off>
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="uname" value="" autocomplete=off>
|
|
|
|
<input type="password" name="pword" value="" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ===== repeat, but with logins not previously stored ===== -->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- no autocomplete for password field -->
|
|
|
|
<form id="form8" onsubmit="return checkSubmit(8);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="xxxuname" value="newuser">
|
|
|
|
<input type="password" name="xxxpword" value="newpass" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for username field -->
|
|
|
|
<form id="form9" onsubmit="return checkSubmit(9);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="xxxuname" value="newuser" autocomplete=off>
|
|
|
|
<input type="password" name="xxxpword" value="newpass">
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for username or password fields -->
|
|
|
|
<form id="form10" onsubmit="return checkSubmit(10);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="xxxuname" value="newuser" autocomplete=off>
|
|
|
|
<input type="password" name="xxxpword" value="newpass" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form -->
|
|
|
|
<form id="form11" onsubmit="return checkSubmit(11);" method="get" autocomplete=off>
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="xxxuname" value="newuser">
|
|
|
|
<input type="password" name="xxxpword" value="newpass">
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form and password field -->
|
|
|
|
<form id="form12" onsubmit="return checkSubmit(12);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="xxxuname" value="newuser">
|
|
|
|
<input type="password" name="xxxpword" value="newpass" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form and username field -->
|
|
|
|
<form id="form13" onsubmit="return checkSubmit(13);" method="get">
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="xxxuname" value="newuser" autocomplete=off>
|
|
|
|
<input type="password" name="xxxpword" value="newpass">
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<!-- no autocomplete for entire form, userfield, and password field -->
|
|
|
|
<form id="form14" onsubmit="return checkSubmit(14);" method="get" autocomplete=off>
|
2007-06-25 14:20:55 -07:00
|
|
|
<input type="text" name="xxxuname" value="newuser" autocomplete=off>
|
|
|
|
<input type="password" name="xxxpword" value="newpass" autocomplete=off>
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset </button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2007-06-25 14:20:55 -07:00
|
|
|
/** Test for Login Manager: 227640 (password is saved even when the
|
|
|
|
password field has autocomplete="off") **/
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
// This test ensures that pwmgr does not save a username or password when
|
|
|
|
// autocomplete=off is present.
|
|
|
|
|
|
|
|
var numStartingLogins = 0;
|
|
|
|
var numSubmittedForms = 0;
|
|
|
|
|
|
|
|
function startTest() {
|
2007-06-25 14:20:55 -07:00
|
|
|
// Get current number of logins, so we can know if some accidently get
|
|
|
|
// added during the test.
|
2007-04-22 16:56:06 -07:00
|
|
|
numStartingLogins = countLogins();
|
|
|
|
ok(numStartingLogins > 0, "counting logins at start");
|
|
|
|
|
2008-05-08 20:34:46 -07:00
|
|
|
// Check first set of forms, which should not be filled by pwmgr.
|
2007-04-22 16:56:06 -07:00
|
|
|
for (var i = 1; i <= 7; i++) {
|
2008-05-08 20:34:46 -07:00
|
|
|
is($_(i, "uname").value, "", "Checking for unfilled username " + i);
|
|
|
|
is($_(i, "pword").value, "", "Checking for unfilled password " + i);
|
|
|
|
// Set the field values to that of an existing login
|
|
|
|
$_(i, "uname").value = "testuser";
|
|
|
|
$_(i, "pword").value = "testpass";
|
2007-04-22 16:56:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check second set of forms, which should have preset values (and are unknown to pwmgr).
|
2007-06-25 14:20:55 -07:00
|
|
|
for (var i = 8; i <= 14; i++) {
|
|
|
|
is($_(i, "xxxuname").value, "newuser", "Checking unmodified username " + i);
|
|
|
|
is($_(i, "xxxpword").value, "newpass", "Checking unmodified password " + i);
|
2007-04-22 16:56:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var button = getFormSubmitButton(1);
|
|
|
|
|
|
|
|
// submit the first form.
|
|
|
|
button.click();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Called by each form's onsubmit handler.
|
|
|
|
function checkSubmit(formNum) {
|
|
|
|
numSubmittedForms++;
|
|
|
|
|
|
|
|
// End the test at the last form.
|
|
|
|
if (formNum == 14) {
|
2007-06-25 14:20:55 -07:00
|
|
|
is(numSubmittedForms, 14, "Ensuring all forms were submitted.");;
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
var numEndingLogins = countLogins();
|
|
|
|
ok(numEndingLogins > 0, "counting logins at end");
|
|
|
|
|
|
|
|
is(numStartingLogins, numEndingLogins, "counting logins at end");
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
return false; // return false to cancel current form submission
|
|
|
|
}
|
|
|
|
|
|
|
|
var button = getFormSubmitButton(formNum + 1);
|
|
|
|
|
|
|
|
// submit the next form.
|
|
|
|
button.click();
|
|
|
|
|
|
|
|
return false; // return false to cancel current form submission
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getFormSubmitButton(formNum) {
|
|
|
|
var form = $("form" + formNum); // by id, not name
|
|
|
|
ok(form != null, "getting form " + formNum);
|
|
|
|
|
2007-06-25 14:20:55 -07:00
|
|
|
// we can't just call form.submit(), because that doesn't seem to
|
|
|
|
// invoke the form onsubmit handler.
|
2007-04-22 16:56:06 -07:00
|
|
|
var button = form.firstChild;
|
|
|
|
while (button && button.type != "submit") { button = button.nextSibling; }
|
|
|
|
ok(button != null, "getting form submit button");
|
|
|
|
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Counts the number of logins currently stored by password manager.
|
|
|
|
function countLogins() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
|
2007-05-16 03:02:45 -07:00
|
|
|
var logins = pwmgr.getAllLogins({});
|
2007-04-22 16:56:06 -07:00
|
|
|
|
2007-05-16 03:02:45 -07:00
|
|
|
return logins.length;
|
2007-04-22 16:56:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the pwmgr service
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
|
2007-05-16 03:02:45 -07:00
|
|
|
var Cc_pwmgr = Components.classes["@mozilla.org/login-manager;1"];
|
|
|
|
ok(Cc_pwmgr != null, "Access Cc[@mozilla.org/login-manager;1]");
|
2007-04-22 16:56:06 -07:00
|
|
|
|
2007-05-16 03:02:45 -07:00
|
|
|
var Ci_pwmgr = Components.interfaces.nsILoginManager;
|
|
|
|
ok(Ci_pwmgr != null, "Access Ci.nsILoginManager");
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
var pwmgr = Cc_pwmgr.getService(Ci_pwmgr);
|
|
|
|
ok(pwmgr != null, "pwmgr getService()");
|
|
|
|
|
|
|
|
|
|
|
|
window.onload = startTest;
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|