Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for Login Manager</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="pwmgr_common.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body> |
michael@0 | 10 | Login Manager test: forms and logins without a username. |
michael@0 | 11 | <script> |
michael@0 | 12 | commonInit(); |
michael@0 | 13 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 14 | |
michael@0 | 15 | var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"] |
michael@0 | 16 | .getService(SpecialPowers.Ci.nsILoginManager); |
michael@0 | 17 | |
michael@0 | 18 | var nsLoginInfo = new SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/login-manager/loginInfo;1", SpecialPowers.Ci.nsILoginInfo); |
michael@0 | 19 | ok(nsLoginInfo != null, "nsLoginInfo constructor"); |
michael@0 | 20 | |
michael@0 | 21 | // pwlogin1 uses a unique formSubmitURL, to check forms where no other logins |
michael@0 | 22 | // will apply. pwlogin2 uses the normal formSubmitURL, so that we can test |
michael@0 | 23 | // forms with a mix of username and non-username logins that might apply. |
michael@0 | 24 | // |
michael@0 | 25 | // Note: pwlogin2 is deleted at the end of the test. |
michael@0 | 26 | |
michael@0 | 27 | pwlogin1 = new nsLoginInfo(); |
michael@0 | 28 | pwlogin2 = new nsLoginInfo(); |
michael@0 | 29 | |
michael@0 | 30 | pwlogin1.init("http://mochi.test:8888", "http://mochi.test:1111", null, |
michael@0 | 31 | "", "1234", "uname", "pword"); |
michael@0 | 32 | |
michael@0 | 33 | pwlogin2.init("http://mochi.test:8888", "http://mochi.test:8888", null, |
michael@0 | 34 | "", "1234", "uname", "pword"); |
michael@0 | 35 | |
michael@0 | 36 | try { |
michael@0 | 37 | pwmgr.addLogin(pwlogin1); |
michael@0 | 38 | pwmgr.addLogin(pwlogin2); |
michael@0 | 39 | } catch (e) { |
michael@0 | 40 | ok(false, "addLogin threw: " + e); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | </script> |
michael@0 | 44 | <p id="display"></p> |
michael@0 | 45 | |
michael@0 | 46 | <div id="content" style="display: none"> |
michael@0 | 47 | |
michael@0 | 48 | |
michael@0 | 49 | <!-- simple form: no username field, 1 password field --> |
michael@0 | 50 | <form id='form1' action='http://mochi.test:1111/formtest.js'> 1 |
michael@0 | 51 | <input type='password' name='pname' value=''> |
michael@0 | 52 | |
michael@0 | 53 | <button type='submit'>Submit</button> |
michael@0 | 54 | <button type='reset'> Reset </button> |
michael@0 | 55 | </form> |
michael@0 | 56 | |
michael@0 | 57 | <!-- simple form: no username field, 2 password fields --> |
michael@0 | 58 | <form id='form2' action='http://mochi.test:1111/formtest.js'> 2 |
michael@0 | 59 | <input type='password' name='pname1' value=''> |
michael@0 | 60 | <input type='password' name='pname2' value=''> |
michael@0 | 61 | |
michael@0 | 62 | <button type='submit'>Submit</button> |
michael@0 | 63 | <button type='reset'> Reset </button> |
michael@0 | 64 | </form> |
michael@0 | 65 | |
michael@0 | 66 | <!-- simple form: no username field, 3 password fields --> |
michael@0 | 67 | <form id='form3' action='http://mochi.test:1111/formtest.js'> 3 |
michael@0 | 68 | <input type='password' name='pname1' value=''> |
michael@0 | 69 | <input type='password' name='pname2' value=''> |
michael@0 | 70 | <input type='password' name='pname3' value=''> |
michael@0 | 71 | |
michael@0 | 72 | <button type='submit'>Submit</button> |
michael@0 | 73 | <button type='reset'> Reset </button> |
michael@0 | 74 | </form> |
michael@0 | 75 | |
michael@0 | 76 | <!-- 4 password fields, should be ignored. --> |
michael@0 | 77 | <form id='form4' action='http://mochi.test:1111/formtest.js'> 4 |
michael@0 | 78 | <input type='password' name='pname1' value=''> |
michael@0 | 79 | <input type='password' name='pname2' value=''> |
michael@0 | 80 | <input type='password' name='pname3' value=''> |
michael@0 | 81 | <input type='password' name='pname4' value=''> |
michael@0 | 82 | |
michael@0 | 83 | <button type='submit'>Submit</button> |
michael@0 | 84 | <button type='reset'> Reset </button> |
michael@0 | 85 | </form> |
michael@0 | 86 | |
michael@0 | 87 | |
michael@0 | 88 | |
michael@0 | 89 | <!-- 1 username field --> |
michael@0 | 90 | <form id='form5' action='http://mochi.test:1111/formtest.js'> 5 |
michael@0 | 91 | <input type='text' name='uname' value=''> |
michael@0 | 92 | <input type='password' name='pname' value=''> |
michael@0 | 93 | |
michael@0 | 94 | <button type='submit'>Submit</button> |
michael@0 | 95 | <button type='reset'> Reset </button> |
michael@0 | 96 | </form> |
michael@0 | 97 | |
michael@0 | 98 | |
michael@0 | 99 | <!-- 1 username field, with a value set --> |
michael@0 | 100 | <form id='form6' action='http://mochi.test:1111/formtest.js'> 6 |
michael@0 | 101 | <input type='text' name='uname' value='someuser'> |
michael@0 | 102 | <input type='password' name='pname' value=''> |
michael@0 | 103 | |
michael@0 | 104 | <button type='submit'>Submit</button> |
michael@0 | 105 | <button type='reset'> Reset </button> |
michael@0 | 106 | </form> |
michael@0 | 107 | |
michael@0 | 108 | |
michael@0 | 109 | |
michael@0 | 110 | <!-- |
michael@0 | 111 | (The following forms have 2 potentially-matching logins, on is |
michael@0 | 112 | password-only, the other is username+password) |
michael@0 | 113 | --> |
michael@0 | 114 | |
michael@0 | 115 | |
michael@0 | 116 | |
michael@0 | 117 | <!-- 1 username field, with value set. Fill in the matching U+P login --> |
michael@0 | 118 | <form id='form7' action='formtest.js'> 7 |
michael@0 | 119 | <input type='text' name='uname' value='testuser'> |
michael@0 | 120 | <input type='password' name='pname' value=''> |
michael@0 | 121 | |
michael@0 | 122 | <button type='submit'>Submit</button> |
michael@0 | 123 | <button type='reset'> Reset </button> |
michael@0 | 124 | </form> |
michael@0 | 125 | |
michael@0 | 126 | <!-- 1 username field, with value set. Don't fill in U+P login--> |
michael@0 | 127 | <form id='form8' action='formtest.js'> 8 |
michael@0 | 128 | <input type='text' name='uname' value='someuser'> |
michael@0 | 129 | <input type='password' name='pname' value=''> |
michael@0 | 130 | |
michael@0 | 131 | <button type='submit'>Submit</button> |
michael@0 | 132 | <button type='reset'> Reset </button> |
michael@0 | 133 | </form> |
michael@0 | 134 | |
michael@0 | 135 | |
michael@0 | 136 | |
michael@0 | 137 | <!-- 1 username field, too small for U+P login --> |
michael@0 | 138 | <form id='form9' action='formtest.js'> 9 |
michael@0 | 139 | <input type='text' name='uname' value='' maxlength="4"> |
michael@0 | 140 | <input type='password' name='pname' value=''> |
michael@0 | 141 | |
michael@0 | 142 | <button type='submit'>Submit</button> |
michael@0 | 143 | <button type='reset'> Reset </button> |
michael@0 | 144 | </form> |
michael@0 | 145 | |
michael@0 | 146 | <!-- 1 username field, too small for U+P login --> |
michael@0 | 147 | <form id='form10' action='formtest.js'> 10 |
michael@0 | 148 | <input type='text' name='uname' value='' maxlength="0"> |
michael@0 | 149 | <input type='password' name='pname' value=''> |
michael@0 | 150 | |
michael@0 | 151 | <button type='submit'>Submit</button> |
michael@0 | 152 | <button type='reset'> Reset </button> |
michael@0 | 153 | </form> |
michael@0 | 154 | |
michael@0 | 155 | <!-- 1 username field, too small for U+P login --> |
michael@0 | 156 | <form id='form11' action='formtest.js'> 11 |
michael@0 | 157 | <input type='text' name='uname' value=''> |
michael@0 | 158 | <input type='password' name='pname' value='' maxlength="4"> |
michael@0 | 159 | |
michael@0 | 160 | <button type='submit'>Submit</button> |
michael@0 | 161 | <button type='reset'> Reset </button> |
michael@0 | 162 | </form> |
michael@0 | 163 | |
michael@0 | 164 | <!-- 1 username field, too small for either login --> |
michael@0 | 165 | <form id='form12' action='formtest.js'> 12 |
michael@0 | 166 | <input type='text' name='uname' value=''> |
michael@0 | 167 | <input type='password' name='pname' value='' maxlength="1"> |
michael@0 | 168 | |
michael@0 | 169 | <button type='submit'>Submit</button> |
michael@0 | 170 | <button type='reset'> Reset </button> |
michael@0 | 171 | </form> |
michael@0 | 172 | |
michael@0 | 173 | <!-- 1 username field, too small for either login --> |
michael@0 | 174 | <form id='form13' action='formtest.js'> 13 |
michael@0 | 175 | <input type='text' name='uname' value=''> |
michael@0 | 176 | <input type='password' name='pname' value='' maxlength="0"> |
michael@0 | 177 | |
michael@0 | 178 | <button type='submit'>Submit</button> |
michael@0 | 179 | <button type='reset'> Reset </button> |
michael@0 | 180 | </form> |
michael@0 | 181 | |
michael@0 | 182 | |
michael@0 | 183 | |
michael@0 | 184 | </div> |
michael@0 | 185 | |
michael@0 | 186 | <pre id="test"> |
michael@0 | 187 | <script class="testbody" type="text/javascript"> |
michael@0 | 188 | |
michael@0 | 189 | /** Test for Login Manager: password-only logins **/ |
michael@0 | 190 | function startTest() { |
michael@0 | 191 | |
michael@0 | 192 | checkForm(1, "1234"); |
michael@0 | 193 | checkForm(2, "1234", ""); |
michael@0 | 194 | checkForm(3, "1234", "", ""); |
michael@0 | 195 | checkUnmodifiedForm(4); |
michael@0 | 196 | |
michael@0 | 197 | checkForm(5, "", "1234"); |
michael@0 | 198 | checkForm(6, "someuser", ""); |
michael@0 | 199 | |
michael@0 | 200 | checkForm(7, "testuser", "testpass"); |
michael@0 | 201 | checkForm(8, "someuser", ""); |
michael@0 | 202 | |
michael@0 | 203 | checkForm(9, "", "1234"); |
michael@0 | 204 | checkForm(10, "", "1234"); |
michael@0 | 205 | checkForm(11, "", "1234"); |
michael@0 | 206 | |
michael@0 | 207 | checkUnmodifiedForm(12); |
michael@0 | 208 | checkUnmodifiedForm(13); |
michael@0 | 209 | |
michael@0 | 210 | pwmgr.removeLogin(pwlogin2); |
michael@0 | 211 | SimpleTest.finish(); |
michael@0 | 212 | } |
michael@0 | 213 | |
michael@0 | 214 | window.onload = startTest; |
michael@0 | 215 | </script> |
michael@0 | 216 | </pre> |
michael@0 | 217 | </body> |
michael@0 | 218 | </html> |
michael@0 | 219 |