gecko/toolkit/components/passwordmgr/test/test_bug_427033.html

75 lines
1.9 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for Login Manager</title>
<script type="text/javascript" src="/MochiKit/packed.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>
Login Manager test: form with JS submit action
<p id="display"></p>
<div id="content" style="display: none">
<form id='form1' action='javascript:alert("never shows")'> 1
<input name="uname">
<input name="pword" type="password">
<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: JS action URL **/
function startTest() {
checkForm(1, "jsuser", "jspass123");
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
pwmgr.removeLogin(jslogin);
SimpleTest.finish();
}
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// Get the pwmgr service
var Cc_pwmgr = Components.classes["@mozilla.org/login-manager;1"];
ok(Cc_pwmgr != null, "Access Cc[@mozilla.org/login-manager;1]");
var Ci_pwmgr = Components.interfaces.nsILoginManager;
ok(Ci_pwmgr != null, "Access Ci.nsILoginManager");
var pwmgr = Cc_pwmgr.getService(Ci_pwmgr);
ok(pwmgr != null, "pwmgr getService()");
var jslogin = Components.classes["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Components.interfaces.nsILoginInfo);
ok(jslogin != null, "create a login");
jslogin.init("http://localhost:8888", "javascript:", null,
"jsuser", "jspass123", "uname", "pword");
try {
pwmgr.addLogin(jslogin);
} catch (e) {
ok(false, "addLogin threw: " + e);
}
window.onload = startTest;
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>