toolkit/components/passwordmgr/test/test_basic_form_html5.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_html5.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,171 @@
     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: html5 input types (email, tel, url, etc.)
    1.14 +<script>
    1.15 +commonInit();
    1.16 +SimpleTest.waitForExplicitFinish();
    1.17 +
    1.18 +const Ci = SpecialPowers.Ci;
    1.19 +const Cc = SpecialPowers.Cc;
    1.20 +pwmgr = Cc["@mozilla.org/login-manager;1"].
    1.21 +        getService(Ci.nsILoginManager);
    1.22 +
    1.23 +login1  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.24 +           createInstance(Ci.nsILoginInfo);
    1.25 +login2  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.26 +           createInstance(Ci.nsILoginInfo);
    1.27 +login3  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.28 +           createInstance(Ci.nsILoginInfo);
    1.29 +login4  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.30 +           createInstance(Ci.nsILoginInfo);
    1.31 +
    1.32 +login1.init("http://mochi.test:8888", "http://bug600551-1", null,
    1.33 +            "testuser@example.com", "testpass1", "", "");
    1.34 +login2.init("http://mochi.test:8888", "http://bug600551-2", null,
    1.35 +            "555-555-5555", "testpass2", "", "");
    1.36 +login3.init("http://mochi.test:8888", "http://bug600551-3", null,
    1.37 +            "http://mozilla.org", "testpass3", "", "");
    1.38 +login4.init("http://mochi.test:8888", "http://bug600551-4", null,
    1.39 +            "123456789", "testpass4", "", "");
    1.40 +
    1.41 +pwmgr.addLogin(login1);
    1.42 +pwmgr.addLogin(login2);
    1.43 +pwmgr.addLogin(login3);
    1.44 +pwmgr.addLogin(login4);
    1.45 +</script>
    1.46 +
    1.47 +<p id="display"></p>
    1.48 +<div id="content" style="display: none">
    1.49 +
    1.50 +  <form id="form1" action="http://bug600551-1">
    1.51 +    <input  type="email"    name="uname">
    1.52 +    <input  type="password" name="pword">
    1.53 +    <button type="submit">Submit</button>
    1.54 +  </form>
    1.55 +  
    1.56 +  <form id="form2" action="http://bug600551-2">
    1.57 +    <input  type="tel"      name="uname">
    1.58 +    <input  type="password" name="pword">
    1.59 +    <button type="submit">Submit</button>
    1.60 +  </form>
    1.61 +  
    1.62 +  <form id="form3" action="http://bug600551-3">
    1.63 +    <input  type="url"      name="uname">
    1.64 +    <input  type="password" name="pword">
    1.65 +    <button type="submit">Submit</button>
    1.66 +  </form>
    1.67 +  
    1.68 +  
    1.69 +  <form id="form4" action="http://bug600551-4">
    1.70 +    <input  type="number"   name="uname">
    1.71 +    <input  type="password" name="pword">
    1.72 +    <button type="submit">Submit</button>
    1.73 +  </form>
    1.74 +  
    1.75 +  <!-- The following forms should not be filled with usernames -->
    1.76 +  <form id="form5" action="formtest.js">
    1.77 +    <input  type="search"   name="uname">
    1.78 +    <input  type="password" name="pword">
    1.79 +    <button type="submit">Submit</button>
    1.80 +  </form>
    1.81 +  
    1.82 +  <form id="form6" action="formtest.js">
    1.83 +    <input  type="datetime" name="uname">
    1.84 +    <input  type="password" name="pword">
    1.85 +    <button type="submit">Submit</button>
    1.86 +  </form>
    1.87 +  
    1.88 +  <form id="form7" action="formtest.js">
    1.89 +    <input  type="date"     name="uname">
    1.90 +    <input  type="password" name="pword">
    1.91 +    <button type="submit">Submit</button>
    1.92 +  </form>
    1.93 +  
    1.94 +  <form id="form8" action="formtest.js">
    1.95 +    <input  type="month" name="uname">
    1.96 +    <input  type="password" name="pword">
    1.97 +    <button type="submit">Submit</button>
    1.98 +  </form>
    1.99 +  
   1.100 +  <form id="form9" action="formtest.js">
   1.101 +    <input  type="week"     name="uname">
   1.102 +    <input  type="password" name="pword">
   1.103 +    <button type="submit">Submit</button>
   1.104 +  </form>
   1.105 +  
   1.106 +  <form id="form10" action="formtest.js">
   1.107 +    <input  type="time"     name="uname">
   1.108 +    <input  type="password" name="pword">
   1.109 +    <button type="submit">Submit</button>
   1.110 +  </form>
   1.111 +  
   1.112 +  <form id="form11" action="formtest.js">
   1.113 +    <input  type="datetime-local" name="uname">
   1.114 +    <input  type="password"       name="pword">
   1.115 +    <button type="submit">Submit</button>
   1.116 +  </form>
   1.117 +  
   1.118 +  <form id="form12" action="formtest.js">
   1.119 +    <input  type="range"    name="uname">
   1.120 +    <input  type="password" name="pword">
   1.121 +    <button type="submit">Submit</button>
   1.122 +  </form>
   1.123 +  
   1.124 +  <form id="form13" action="formtest.js">
   1.125 +    <input  type="color"    name="uname">
   1.126 +    <input  type="password" name="pword">
   1.127 +    <button type="submit">Submit</button>
   1.128 +  </form>
   1.129 +
   1.130 +
   1.131 +</div>
   1.132 +<pre id="test">
   1.133 +<script class="testbody" type="text/javascript">
   1.134 +
   1.135 +/* Test for Login Manager: 600551
   1.136 +  (Password manager not working with input type=email)
   1.137 + */
   1.138 +function startTest() {
   1.139 +  checkForm(1, "testuser@example.com", "testpass1");
   1.140 +  checkForm(2, "555-555-5555", "testpass2");
   1.141 +  checkForm(3, "http://mozilla.org", "testpass3");
   1.142 +  checkForm(4, "123456789", "testpass4");
   1.143 +  
   1.144 +  is($_(5, "uname").value, "", "type=search should not be considered a username");
   1.145 +  
   1.146 +  is($_(6, "uname").value, "", "type=datetime should not be considered a username");
   1.147 +  
   1.148 +  is($_(7, "uname").value, "", "type=date should not be considered a username");
   1.149 +  
   1.150 +  is($_(8, "uname").value, "", "type=month should not be considered a username");
   1.151 +  
   1.152 +  is($_(9, "uname").value, "", "type=week should not be considered a username");
   1.153 +  
   1.154 +  is($_(10, "uname").value, "", "type=time should not be considered a username");
   1.155 +  
   1.156 +  is($_(11, "uname").value, "", "type=datetime-local should not be considered a username");
   1.157 +  
   1.158 +  is($_(12, "uname").value, "50", "type=range should not be considered a username");
   1.159 +  
   1.160 +  is($_(13, "uname").value, "#000000", "type=color should not be considered a username");
   1.161 +
   1.162 +  pwmgr.removeLogin(login1);
   1.163 +  pwmgr.removeLogin(login2);
   1.164 +  pwmgr.removeLogin(login3);
   1.165 +  pwmgr.removeLogin(login4);
   1.166 + 
   1.167 +  SimpleTest.finish();
   1.168 +}
   1.169 +
   1.170 +window.onload = startTest;
   1.171 +</script>
   1.172 +</pre>
   1.173 +</body>
   1.174 +</html>

mercurial