toolkit/components/passwordmgr/test/test_basic_form_pwonly.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/passwordmgr/test/test_basic_form_pwonly.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,219 @@
     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: forms and logins without a username.
    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 +
    1.21 +var nsLoginInfo = new SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/login-manager/loginInfo;1", SpecialPowers.Ci.nsILoginInfo);
    1.22 +ok(nsLoginInfo != null, "nsLoginInfo constructor");
    1.23 +
    1.24 +// pwlogin1 uses a unique formSubmitURL, to check forms where no other logins
    1.25 +// will apply. pwlogin2 uses the normal formSubmitURL, so that we can test
    1.26 +// forms with a mix of username and non-username logins that might apply.
    1.27 +//
    1.28 +// Note: pwlogin2 is deleted at the end of the test.
    1.29 +
    1.30 +pwlogin1 = new nsLoginInfo();
    1.31 +pwlogin2 = new nsLoginInfo();
    1.32 +
    1.33 +pwlogin1.init("http://mochi.test:8888", "http://mochi.test:1111", null,
    1.34 +    "", "1234", "uname", "pword");
    1.35 +
    1.36 +pwlogin2.init("http://mochi.test:8888", "http://mochi.test:8888", null,
    1.37 +    "", "1234", "uname", "pword");
    1.38 +
    1.39 +try {
    1.40 +    pwmgr.addLogin(pwlogin1);
    1.41 +    pwmgr.addLogin(pwlogin2);
    1.42 +} catch (e) {
    1.43 +    ok(false, "addLogin threw: " + e);
    1.44 +}
    1.45 +
    1.46 +</script>
    1.47 +<p id="display"></p>
    1.48 +
    1.49 +<div id="content" style="display: none">
    1.50 +
    1.51 +
    1.52 +<!-- simple form: no username field, 1 password field -->
    1.53 +<form id='form1' action='http://mochi.test:1111/formtest.js'> 1
    1.54 +    <input type='password' name='pname' value=''>
    1.55 +
    1.56 +    <button type='submit'>Submit</button>
    1.57 +    <button type='reset'> Reset </button>
    1.58 +</form>
    1.59 +
    1.60 +<!-- simple form: no username field, 2 password fields -->
    1.61 +<form id='form2' action='http://mochi.test:1111/formtest.js'> 2
    1.62 +    <input type='password' name='pname1' value=''>
    1.63 +    <input type='password' name='pname2' value=''>
    1.64 +
    1.65 +    <button type='submit'>Submit</button>
    1.66 +    <button type='reset'> Reset </button>
    1.67 +</form>
    1.68 +
    1.69 +<!-- simple form: no username field, 3 password fields -->
    1.70 +<form id='form3' action='http://mochi.test:1111/formtest.js'> 3
    1.71 +    <input type='password' name='pname1' value=''>
    1.72 +    <input type='password' name='pname2' value=''>
    1.73 +    <input type='password' name='pname3' value=''>
    1.74 +
    1.75 +    <button type='submit'>Submit</button>
    1.76 +    <button type='reset'> Reset </button>
    1.77 +</form>
    1.78 +
    1.79 +<!-- 4 password fields, should be ignored. -->
    1.80 +<form id='form4' action='http://mochi.test:1111/formtest.js'> 4
    1.81 +    <input type='password' name='pname1' value=''>
    1.82 +    <input type='password' name='pname2' value=''>
    1.83 +    <input type='password' name='pname3' value=''>
    1.84 +    <input type='password' name='pname4' value=''>
    1.85 +
    1.86 +    <button type='submit'>Submit</button>
    1.87 +    <button type='reset'> Reset </button>
    1.88 +</form>
    1.89 +
    1.90 +
    1.91 +
    1.92 +<!-- 1 username field -->
    1.93 +<form id='form5' action='http://mochi.test:1111/formtest.js'> 5
    1.94 +    <input type='text'     name='uname' value=''>
    1.95 +    <input type='password' name='pname' value=''>
    1.96 +
    1.97 +    <button type='submit'>Submit</button>
    1.98 +    <button type='reset'> Reset </button>
    1.99 +</form>
   1.100 +
   1.101 +
   1.102 +<!-- 1 username field, with a value set -->
   1.103 +<form id='form6' action='http://mochi.test:1111/formtest.js'> 6
   1.104 +    <input type='text'     name='uname' value='someuser'>
   1.105 +    <input type='password' name='pname' value=''>
   1.106 +
   1.107 +    <button type='submit'>Submit</button>
   1.108 +    <button type='reset'> Reset </button>
   1.109 +</form>
   1.110 +
   1.111 +
   1.112 +
   1.113 +<!--
   1.114 +(The following forms have 2 potentially-matching logins, on is
   1.115 +password-only, the other is username+password)
   1.116 +-->
   1.117 +
   1.118 +
   1.119 +
   1.120 +<!-- 1 username field, with value set. Fill in the matching U+P login -->
   1.121 +<form id='form7' action='formtest.js'> 7
   1.122 +    <input type='text'     name='uname' value='testuser'>
   1.123 +    <input type='password' name='pname' value=''>
   1.124 +
   1.125 +    <button type='submit'>Submit</button>
   1.126 +    <button type='reset'> Reset </button>
   1.127 +</form>
   1.128 +
   1.129 +<!-- 1 username field, with value set. Don't fill in U+P login-->
   1.130 +<form id='form8' action='formtest.js'> 8
   1.131 +    <input type='text'     name='uname' value='someuser'>
   1.132 +    <input type='password' name='pname' value=''>
   1.133 +
   1.134 +    <button type='submit'>Submit</button>
   1.135 +    <button type='reset'> Reset </button>
   1.136 +</form>
   1.137 +
   1.138 +
   1.139 +
   1.140 +<!-- 1 username field, too small for U+P login -->
   1.141 +<form id='form9' action='formtest.js'> 9
   1.142 +    <input type='text'     name='uname' value='' maxlength="4">
   1.143 +    <input type='password' name='pname' value=''>
   1.144 +
   1.145 +    <button type='submit'>Submit</button>
   1.146 +    <button type='reset'> Reset </button>
   1.147 +</form>
   1.148 +
   1.149 +<!-- 1 username field, too small for U+P login -->
   1.150 +<form id='form10' action='formtest.js'> 10
   1.151 +    <input type='text'     name='uname' value='' maxlength="0">
   1.152 +    <input type='password' name='pname' value=''>
   1.153 +
   1.154 +    <button type='submit'>Submit</button>
   1.155 +    <button type='reset'> Reset </button>
   1.156 +</form>
   1.157 +
   1.158 +<!-- 1 username field, too small for U+P login -->
   1.159 +<form id='form11' action='formtest.js'> 11
   1.160 +    <input type='text'     name='uname' value=''>
   1.161 +    <input type='password' name='pname' value='' maxlength="4">
   1.162 +
   1.163 +    <button type='submit'>Submit</button>
   1.164 +    <button type='reset'> Reset </button>
   1.165 +</form>
   1.166 +
   1.167 +<!-- 1 username field, too small for either login -->
   1.168 +<form id='form12' action='formtest.js'> 12
   1.169 +    <input type='text'     name='uname' value=''>
   1.170 +    <input type='password' name='pname' value='' maxlength="1">
   1.171 +
   1.172 +    <button type='submit'>Submit</button>
   1.173 +    <button type='reset'> Reset </button>
   1.174 +</form>
   1.175 +
   1.176 +<!-- 1 username field, too small for either login -->
   1.177 +<form id='form13' action='formtest.js'> 13
   1.178 +    <input type='text'     name='uname' value=''>
   1.179 +    <input type='password' name='pname' value='' maxlength="0">
   1.180 +
   1.181 +    <button type='submit'>Submit</button>
   1.182 +    <button type='reset'> Reset </button>
   1.183 +</form>
   1.184 +
   1.185 +
   1.186 +
   1.187 +</div>
   1.188 +
   1.189 +<pre id="test">
   1.190 +<script class="testbody" type="text/javascript">
   1.191 +
   1.192 +/** Test for Login Manager: password-only logins **/
   1.193 +function startTest() {
   1.194 +
   1.195 +    checkForm(1, "1234");
   1.196 +    checkForm(2, "1234", "");
   1.197 +    checkForm(3, "1234", "", "");
   1.198 +    checkUnmodifiedForm(4);
   1.199 +
   1.200 +    checkForm(5, "", "1234");
   1.201 +    checkForm(6, "someuser", "");
   1.202 +
   1.203 +    checkForm(7, "testuser", "testpass");
   1.204 +    checkForm(8, "someuser", "");
   1.205 +
   1.206 +    checkForm(9, "", "1234");
   1.207 +    checkForm(10, "", "1234");
   1.208 +    checkForm(11, "", "1234");
   1.209 +
   1.210 +    checkUnmodifiedForm(12);
   1.211 +    checkUnmodifiedForm(13);
   1.212 +
   1.213 +    pwmgr.removeLogin(pwlogin2);
   1.214 +    SimpleTest.finish();
   1.215 +}
   1.216 +
   1.217 +window.onload = startTest;
   1.218 +</script>
   1.219 +</pre>
   1.220 +</body>
   1.221 +</html>
   1.222 +

mercurial