1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/passwordmgr/test/test_basic_form_2.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test for Login Manager</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="text/javascript" src="pwmgr_common.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.11 +</head> 1.12 +<body> 1.13 +Login Manager test: simple form fill with autofillForms disabled 1.14 +<script> 1.15 +commonInit(); 1.16 +SimpleTest.waitForExplicitFinish(); 1.17 + 1.18 +var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"] 1.19 + .getService(SpecialPowers.Ci.nsILoginManager); 1.20 +// Assume that the pref starts out true, so set to false 1.21 +SpecialPowers.setBoolPref("signon.autofillForms", false); 1.22 +</script> 1.23 + 1.24 +<p id="display"></p> 1.25 + 1.26 +<div id="content" style="display: block"> 1.27 + 1.28 + <form id="form1" action="formtest.js"> 1.29 + <p>This is form 1.</p> 1.30 + <input type="text" name="uname"> 1.31 + <input type="password" name="pword"> 1.32 + 1.33 + <button type="submit">Submit</button> 1.34 + <button type="reset"> Reset </button> 1.35 + </form> 1.36 + 1.37 +</div> 1.38 + 1.39 +<pre id="test"> 1.40 +<script class="testbody" type="text/javascript"> 1.41 + 1.42 +/** Test for Login Manager: simple form fill with autofillForms disabled **/ 1.43 + 1.44 +function startTest(){ 1.45 + // Ensure the form is empty at start 1.46 + is($_(1, "uname").value, "", "Checking for blank username"); 1.47 + is($_(1, "pword").value, "", "Checking for blank password"); 1.48 + 1.49 + // Call the public method, check return value 1.50 + is(pwmgr.fillForm(document.getElementById("form1")), true, 1.51 + "Checking return value of fillForm"); 1.52 + 1.53 + // Check that the form was filled 1.54 + is($_(1, "uname").value, "testuser", "Checking for filled username"); 1.55 + is($_(1, "pword").value, "testpass", "Checking for filled password"); 1.56 + 1.57 + // Reset pref (since we assumed it was true to start) 1.58 + SpecialPowers.setBoolPref("signon.autofillForms", true); 1.59 + 1.60 + SimpleTest.finish(); 1.61 +} 1.62 +window.onload = startTest; 1.63 + 1.64 +</script> 1.65 +</pre> 1.66 +</body> 1.67 +</html>