mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
252 lines
8.6 KiB
HTML
252 lines
8.6 KiB
HTML
|
<!DOCTYPE HTML>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Test for Password Manager</title>
|
||
|
<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>
|
||
|
Password Manager test: 227640
|
||
|
<p id="display"></p>
|
||
|
<div id="content" style="display: none">
|
||
|
|
||
|
<!-- no autocomplete for password field -->
|
||
|
<form id="form1" onsubmit="return checkSubmit(1)" method="get">
|
||
|
<input type="text" name="uname1" value="">
|
||
|
<input type="password" name="pword1" value="" autocomplete=off>
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="uname2" value="" autocomplete=off>
|
||
|
<input type="password" name="pword2" value="">
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="uname3" value="" autocomplete=off>
|
||
|
<input type="password" name="pword3" value="" autocomplete=off>
|
||
|
|
||
|
<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>
|
||
|
<input type="text" name="uname4" value="">
|
||
|
<input type="password" name="pword4" value="">
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="uname5" value="">
|
||
|
<input type="password" name="pword5" value="" autocomplete=off>
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="uname6" value="" autocomplete=off>
|
||
|
<input type="password" name="pword6" value="">
|
||
|
|
||
|
<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>
|
||
|
<input type="text" name="uname7" value="" autocomplete=off>
|
||
|
<input type="password" name="pword7" value="" autocomplete=off>
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="xxxuname1" value="newuser1">
|
||
|
<input type="password" name="xxxpword1" value="newpass1" autocomplete=off>
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="xxxuname2" value="newuser2" autocomplete=off>
|
||
|
<input type="password" name="xxxpword2" value="newpass2">
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="xxxuname3" value="newuser3" autocomplete=off>
|
||
|
<input type="password" name="xxxpword3" value="newpass3" autocomplete=off>
|
||
|
|
||
|
<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>
|
||
|
<input type="text" name="xxxuname4" value="newuser4">
|
||
|
<input type="password" name="xxxpword4" value="newpass4">
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="xxxuname5" value="newuser5">
|
||
|
<input type="password" name="xxxpword5" value="newpass5" autocomplete=off>
|
||
|
|
||
|
<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">
|
||
|
<input type="text" name="xxxuname6" value="newuser6" autocomplete=off>
|
||
|
<input type="password" name="xxxpword6" value="newpass6">
|
||
|
|
||
|
<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>
|
||
|
<input type="text" name="xxxuname7" value="newuser7" autocomplete=off>
|
||
|
<input type="password" name="xxxpword7" value="newpass7" autocomplete=off>
|
||
|
|
||
|
<button type="submit">Submit</button>
|
||
|
<button type="reset"> Reset </button>
|
||
|
</form>
|
||
|
|
||
|
</div>
|
||
|
<pre id="test">
|
||
|
<script class="testbody" type="text/javascript">
|
||
|
|
||
|
/** Test for Password Manger: 227640 (password is saved even when the password field has autocomplete="off") **/
|
||
|
|
||
|
// 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() {
|
||
|
// Get current number of logins, to make sure we don't end up storing new logins.
|
||
|
numStartingLogins = countLogins();
|
||
|
ok(numStartingLogins > 0, "counting logins at start");
|
||
|
|
||
|
// Check first set of forms, which should be filled by pwmgr.
|
||
|
for (var i = 1; i <= 7; i++) {
|
||
|
is($_("uname" + i).value, "testuser" + i, "Checking for filled username " + i);
|
||
|
is($_("pword" + i).value, "testpass" + i, "Checking for filled password " + i);
|
||
|
}
|
||
|
|
||
|
// Check second set of forms, which should have preset values (and are unknown to pwmgr).
|
||
|
for (var i = 1; i <= 7; i++) {
|
||
|
is($_("xxxuname" + i).value, "newuser" + i, "Checking for unmodified username " + i);
|
||
|
is($_("xxxpword" + i).value, "newpass" + i, "Checking for unmodified password " + i);
|
||
|
}
|
||
|
|
||
|
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) {
|
||
|
is(numSubmittedForms, 14, "Ensuring all forms were submitted for testing.");;
|
||
|
|
||
|
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);
|
||
|
|
||
|
// we can't just call form.submit(), because that doesn't seem to invoke the form onsubmit handler.
|
||
|
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');
|
||
|
|
||
|
var count = 0;
|
||
|
var enum = pwmgr.enumerator;
|
||
|
while (enum.hasMoreElements()) { count++; enum.getNext(); }
|
||
|
|
||
|
return count;
|
||
|
}
|
||
|
|
||
|
// Get the pwmgr service
|
||
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||
|
|
||
|
var Cc_pwmgr = Components.classes["@mozilla.org/passwordmanager;1"];
|
||
|
ok(Cc_pwmgr != null, "Access Cc[@mozilla.org/passwordmanager;1]");
|
||
|
|
||
|
var Ci_pwmgr = Components.interfaces.nsIPasswordManager;
|
||
|
ok(Ci_pwmgr != null, "Access Ci.nsIPasswordManager");
|
||
|
|
||
|
var pwmgr = Cc_pwmgr.getService(Ci_pwmgr);
|
||
|
ok(pwmgr != null, "pwmgr getService()");
|
||
|
|
||
|
|
||
|
window.onload = startTest;
|
||
|
|
||
|
SimpleTest.waitForExplicitFinish();
|
||
|
|
||
|
</script>
|
||
|
</pre>
|
||
|
</body>
|
||
|
</html>
|
||
|
|