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 onload="endTest();">
|
2007-05-16 03:02:45 -07:00
|
|
|
Login Manager test: 221634
|
2007-04-22 16:56:06 -07:00
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
2007-06-25 14:20:55 -07:00
|
|
|
<form id="form1" action="formtest.js">
|
|
|
|
<input type="text" name="uname">
|
|
|
|
<input type="password" name="pword">
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
<button type="reset"> Reset</button>
|
|
|
|
</form>
|
|
|
|
|
2007-04-22 19:41:29 -07:00
|
|
|
<img onload="performTest();" src="mlogosm.gif">
|
2007-04-22 16:56:06 -07:00
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2007-05-16 03:02:45 -07:00
|
|
|
/** Test for Login Manager: 221634 (password manager needs to fill in forms before the page finishes loading) **/
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
var dclHappened = false;
|
|
|
|
var testHappened = false;
|
|
|
|
var pageloadHappened = false;
|
|
|
|
|
|
|
|
// We're still loading the page, so make sure nothing has filled in yet.
|
2007-06-25 14:20:55 -07:00
|
|
|
is($_(1, "uname").value, "", "Checking unfilled username 1");
|
|
|
|
is($_(1, "pword").value, "", "Checking unfilled password 1");
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", contentLoaded, false);
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
|
|
|
|
// Step 1 - Fires at DOMContentLoaded
|
|
|
|
function contentLoaded() {
|
|
|
|
ok(!testHappened, "Sanity check to ensure test hasn't happened yet.")
|
|
|
|
ok(!pageloadHappened, "Sanity check to ensure pageload hasn't happened yet.")
|
|
|
|
|
|
|
|
// We're in DOMContentLoaded, so the pwmgr may or may not have filled in yet.
|
|
|
|
|
|
|
|
// Set a 0-second timeout, which should execute before the pageload event.
|
|
|
|
// setTimeout(reallyDoTest, 0);
|
|
|
|
// ha-ha... That doesn't work. The pageload event comes first, although
|
|
|
|
// it can be hacked into working by adding <img src="404_non_existant_file.gif">
|
|
|
|
|
|
|
|
dclHappened = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 2 - Fires when the image loads, which should be immediately after DOMContentLoaded (but before pageload)
|
|
|
|
function performTest() {
|
|
|
|
ok(dclHappened, "Sanity check to make sure DOMContentLoaded already happened");
|
|
|
|
ok(!pageloadHappened, "Sanity check to ensure pageload hasn't happened yet.")
|
|
|
|
|
|
|
|
// Check form1
|
2007-06-25 14:20:55 -07:00
|
|
|
is($_(1, "uname").value, "testuser", "Checking filled username");
|
|
|
|
is($_(1, "pword").value, "testpass", "Checking filled password");
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
testHappened = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 3 - Fired by |body| onload.
|
|
|
|
function endTest() {
|
|
|
|
ok(dclHappened, "Sanity check to make sure DOMContentLoaded already happened");
|
|
|
|
ok(testHappened, "Sanity check to make sure our test ran before pageload");
|
|
|
|
|
|
|
|
// Check form1
|
2007-06-25 14:20:55 -07:00
|
|
|
is($_(1, "uname").value, "testuser", "Rechecking filled username");
|
|
|
|
is($_(1, "pword").value, "testpass", "Rechecking filled password");
|
2007-04-22 16:56:06 -07:00
|
|
|
|
|
|
|
pageloadHappened = true;
|
|
|
|
|
|
|
|
// Make sure the expected number of tests (for this page) have run.
|
|
|
|
// If the event execution gets out of order, only a subset get counted.
|
|
|
|
// (Although there should still be other failures... Belt-n-suspenders!)
|
|
|
|
is(SimpleTest._tests.length, 12, "expected number of executed tests");
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|