|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test for Login Manager</title> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="pwmgr_common.js"></script> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
8 </head> |
|
9 <body> |
|
10 Login Manager test: simple form fill with autofillForms disabled |
|
11 <script> |
|
12 commonInit(); |
|
13 SimpleTest.waitForExplicitFinish(); |
|
14 |
|
15 var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"] |
|
16 .getService(SpecialPowers.Ci.nsILoginManager); |
|
17 // Assume that the pref starts out true, so set to false |
|
18 SpecialPowers.setBoolPref("signon.autofillForms", false); |
|
19 </script> |
|
20 |
|
21 <p id="display"></p> |
|
22 |
|
23 <div id="content" style="display: block"> |
|
24 |
|
25 <form id="form1" action="formtest.js"> |
|
26 <p>This is form 1.</p> |
|
27 <input type="text" name="uname"> |
|
28 <input type="password" name="pword"> |
|
29 |
|
30 <button type="submit">Submit</button> |
|
31 <button type="reset"> Reset </button> |
|
32 </form> |
|
33 |
|
34 </div> |
|
35 |
|
36 <pre id="test"> |
|
37 <script class="testbody" type="text/javascript"> |
|
38 |
|
39 /** Test for Login Manager: simple form fill with autofillForms disabled **/ |
|
40 |
|
41 function startTest(){ |
|
42 // Ensure the form is empty at start |
|
43 is($_(1, "uname").value, "", "Checking for blank username"); |
|
44 is($_(1, "pword").value, "", "Checking for blank password"); |
|
45 |
|
46 // Call the public method, check return value |
|
47 is(pwmgr.fillForm(document.getElementById("form1")), true, |
|
48 "Checking return value of fillForm"); |
|
49 |
|
50 // Check that the form was filled |
|
51 is($_(1, "uname").value, "testuser", "Checking for filled username"); |
|
52 is($_(1, "pword").value, "testpass", "Checking for filled password"); |
|
53 |
|
54 // Reset pref (since we assumed it was true to start) |
|
55 SpecialPowers.setBoolPref("signon.autofillForms", true); |
|
56 |
|
57 SimpleTest.finish(); |
|
58 } |
|
59 window.onload = startTest; |
|
60 |
|
61 </script> |
|
62 </pre> |
|
63 </body> |
|
64 </html> |