toolkit/components/passwordmgr/test/test_bug_444968.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/passwordmgr/test/test_bug_444968.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,134 @@
     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: 444968
    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 +login1A  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.24 +           createInstance(Ci.nsILoginInfo);
    1.25 +login1B  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.26 +           createInstance(Ci.nsILoginInfo);
    1.27 +login2A  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.28 +           createInstance(Ci.nsILoginInfo);
    1.29 +login2B  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.30 +           createInstance(Ci.nsILoginInfo);
    1.31 +login2C  = Cc["@mozilla.org/login-manager/loginInfo;1"].
    1.32 +           createInstance(Ci.nsILoginInfo);
    1.33 +
    1.34 +login1A.init("http://mochi.test:8888", "http://bug444968-1", null,
    1.35 +            "testuser1A", "testpass1A", "", "");
    1.36 +login1B.init("http://mochi.test:8888", "http://bug444968-1", null,
    1.37 +            "", "testpass1B", "", "");
    1.38 +
    1.39 +login2A.init("http://mochi.test:8888", "http://bug444968-2", null,
    1.40 +            "testuser2A", "testpass2A", "", "");
    1.41 +login2B.init("http://mochi.test:8888", "http://bug444968-2", null,
    1.42 +            "", "testpass2B", "", "");
    1.43 +login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
    1.44 +            "testuser2C", "testpass2C", "", "");
    1.45 +
    1.46 +pwmgr.addLogin(login1A);
    1.47 +pwmgr.addLogin(login1B);
    1.48 +pwmgr.addLogin(login2A);
    1.49 +pwmgr.addLogin(login2B);
    1.50 +pwmgr.addLogin(login2C);
    1.51 +</script>
    1.52 +
    1.53 +<p id="display"></p>
    1.54 +<div id="content" style="display: none">
    1.55 +  <!-- first 3 forms have matching user+pass and pass-only logins -->
    1.56 +
    1.57 +  <!-- user+pass form. -->
    1.58 +  <form id="form1" action="http://bug444968-1">
    1.59 +    <input  type="text"     name="uname">
    1.60 +    <input  type="password" name="pword">
    1.61 +    <button type="submit">Submit</button>
    1.62 +  </form>
    1.63 +
    1.64 +  <!-- password-only form. -->
    1.65 +  <form id="form2" action="http://bug444968-1">
    1.66 +    <input  type="password" name="pword">
    1.67 +    <button type="submit">Submit</button>
    1.68 +  </form>
    1.69 +
    1.70 +  <!-- user+pass form, username prefilled -->
    1.71 +  <form id="form3" action="http://bug444968-1">
    1.72 +    <input  type="text"     name="uname" value="testuser1A">
    1.73 +    <input  type="password" name="pword">
    1.74 +    <button type="submit">Submit</button>
    1.75 +  </form>
    1.76 +
    1.77 +
    1.78 +  <!-- next 4 forms have matching user+pass (2x) and pass-only (1x) logins -->
    1.79 +
    1.80 +  <!-- user+pass form. -->
    1.81 +  <form id="form4" action="http://bug444968-2">
    1.82 +    <input  type="text"     name="uname">
    1.83 +    <input  type="password" name="pword">
    1.84 +    <button type="submit">Submit</button>
    1.85 +  </form>
    1.86 +
    1.87 +  <!-- password-only form. -->
    1.88 +  <form id="form5" action="http://bug444968-2">
    1.89 +    <input  type="password" name="pword">
    1.90 +    <button type="submit">Submit</button>
    1.91 +  </form>
    1.92 +
    1.93 +  <!-- user+pass form, username prefilled -->
    1.94 +  <form id="form6" action="http://bug444968-2">
    1.95 +    <input  type="text"     name="uname" value="testuser2A">
    1.96 +    <input  type="password" name="pword">
    1.97 +    <button type="submit">Submit</button>
    1.98 +  </form>
    1.99 +
   1.100 +  <!-- user+pass form, username prefilled -->
   1.101 +  <form id="form7" action="http://bug444968-2">
   1.102 +    <input  type="text"     name="uname" value="testuser2C">
   1.103 +    <input  type="password" name="pword">
   1.104 +    <button type="submit">Submit</button>
   1.105 +  </form>
   1.106 +
   1.107 +</div>
   1.108 +<pre id="test">
   1.109 +<script class="testbody" type="text/javascript">
   1.110 +
   1.111 +/* Test for Login Manager: 444968 (password-only forms should prefer a
   1.112 + * password-only login when present )
   1.113 + */
   1.114 +function startTest() {
   1.115 +  checkForm(1, "testuser1A", "testpass1A");
   1.116 +  checkForm(2, "testpass1B");
   1.117 +  checkForm(3, "testuser1A", "testpass1A");
   1.118 +
   1.119 +  checkUnmodifiedForm(4); // 2 logins match
   1.120 +  checkForm(5, "testpass2B");
   1.121 +  checkForm(6, "testuser2A", "testpass2A");
   1.122 +  checkForm(7, "testuser2C", "testpass2C");
   1.123 +
   1.124 +  pwmgr.removeLogin(login1A);
   1.125 +  pwmgr.removeLogin(login1B);
   1.126 +  pwmgr.removeLogin(login2A);
   1.127 +  pwmgr.removeLogin(login2B);
   1.128 +  pwmgr.removeLogin(login2C);
   1.129 +
   1.130 +  SimpleTest.finish();
   1.131 +}
   1.132 +
   1.133 +window.onload = startTest;
   1.134 +</script>
   1.135 +</pre>
   1.136 +</body>
   1.137 +</html>

mercurial