forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_bug_221634.html
95 lines (71 loc) · 3.14 KB
/
test_bug_221634.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Login 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 onload="endTest();">
Login Manager test: 221634
<p id="display"></p>
<div id="content" style="display: none">
<form id="form1" action="formtest.js">
<input type="text" name="uname">
<input type="password" name="pword">
<button type="submit">Submit</button>
<button type="reset"> Reset</button>
</form>
<img onload="performTest();" src="mlogosm.gif">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: 221634 (password manager needs to fill in forms before the page finishes loading) **/
commonInit();
var dclHappened = false;
var testHappened = false;
var pageloadHappened = false;
// We're still loading the page, so make sure nothing has filled in yet.
is($_(1, "uname").value, "", "Checking unfilled username 1");
is($_(1, "pword").value, "", "Checking unfilled password 1");
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_existent_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
is($_(1, "uname").value, "testuser", "Checking filled username");
is($_(1, "pword").value, "testpass", "Checking filled password");
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
is($_(1, "uname").value, "testuser", "Rechecking filled username");
is($_(1, "pword").value, "testpass", "Rechecking filled password");
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>