toolkit/components/passwordmgr/test/test_bug_444968.html

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:88ee3184d035
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for Login Manager</title>
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" src="pwmgr_common.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 </head>
9 <body>
10 Login Manager test: 444968
11 <script>
12 commonInit();
13 SimpleTest.waitForExplicitFinish();
14
15 const Ci = SpecialPowers.Ci;
16 const Cc = SpecialPowers.Cc;
17 pwmgr = Cc["@mozilla.org/login-manager;1"].
18 getService(Ci.nsILoginManager);
19
20 login1A = Cc["@mozilla.org/login-manager/loginInfo;1"].
21 createInstance(Ci.nsILoginInfo);
22 login1B = Cc["@mozilla.org/login-manager/loginInfo;1"].
23 createInstance(Ci.nsILoginInfo);
24 login2A = Cc["@mozilla.org/login-manager/loginInfo;1"].
25 createInstance(Ci.nsILoginInfo);
26 login2B = Cc["@mozilla.org/login-manager/loginInfo;1"].
27 createInstance(Ci.nsILoginInfo);
28 login2C = Cc["@mozilla.org/login-manager/loginInfo;1"].
29 createInstance(Ci.nsILoginInfo);
30
31 login1A.init("http://mochi.test:8888", "http://bug444968-1", null,
32 "testuser1A", "testpass1A", "", "");
33 login1B.init("http://mochi.test:8888", "http://bug444968-1", null,
34 "", "testpass1B", "", "");
35
36 login2A.init("http://mochi.test:8888", "http://bug444968-2", null,
37 "testuser2A", "testpass2A", "", "");
38 login2B.init("http://mochi.test:8888", "http://bug444968-2", null,
39 "", "testpass2B", "", "");
40 login2C.init("http://mochi.test:8888", "http://bug444968-2", null,
41 "testuser2C", "testpass2C", "", "");
42
43 pwmgr.addLogin(login1A);
44 pwmgr.addLogin(login1B);
45 pwmgr.addLogin(login2A);
46 pwmgr.addLogin(login2B);
47 pwmgr.addLogin(login2C);
48 </script>
49
50 <p id="display"></p>
51 <div id="content" style="display: none">
52 <!-- first 3 forms have matching user+pass and pass-only logins -->
53
54 <!-- user+pass form. -->
55 <form id="form1" action="http://bug444968-1">
56 <input type="text" name="uname">
57 <input type="password" name="pword">
58 <button type="submit">Submit</button>
59 </form>
60
61 <!-- password-only form. -->
62 <form id="form2" action="http://bug444968-1">
63 <input type="password" name="pword">
64 <button type="submit">Submit</button>
65 </form>
66
67 <!-- user+pass form, username prefilled -->
68 <form id="form3" action="http://bug444968-1">
69 <input type="text" name="uname" value="testuser1A">
70 <input type="password" name="pword">
71 <button type="submit">Submit</button>
72 </form>
73
74
75 <!-- next 4 forms have matching user+pass (2x) and pass-only (1x) logins -->
76
77 <!-- user+pass form. -->
78 <form id="form4" action="http://bug444968-2">
79 <input type="text" name="uname">
80 <input type="password" name="pword">
81 <button type="submit">Submit</button>
82 </form>
83
84 <!-- password-only form. -->
85 <form id="form5" action="http://bug444968-2">
86 <input type="password" name="pword">
87 <button type="submit">Submit</button>
88 </form>
89
90 <!-- user+pass form, username prefilled -->
91 <form id="form6" action="http://bug444968-2">
92 <input type="text" name="uname" value="testuser2A">
93 <input type="password" name="pword">
94 <button type="submit">Submit</button>
95 </form>
96
97 <!-- user+pass form, username prefilled -->
98 <form id="form7" action="http://bug444968-2">
99 <input type="text" name="uname" value="testuser2C">
100 <input type="password" name="pword">
101 <button type="submit">Submit</button>
102 </form>
103
104 </div>
105 <pre id="test">
106 <script class="testbody" type="text/javascript">
107
108 /* Test for Login Manager: 444968 (password-only forms should prefer a
109 * password-only login when present )
110 */
111 function startTest() {
112 checkForm(1, "testuser1A", "testpass1A");
113 checkForm(2, "testpass1B");
114 checkForm(3, "testuser1A", "testpass1A");
115
116 checkUnmodifiedForm(4); // 2 logins match
117 checkForm(5, "testpass2B");
118 checkForm(6, "testuser2A", "testpass2A");
119 checkForm(7, "testuser2C", "testpass2C");
120
121 pwmgr.removeLogin(login1A);
122 pwmgr.removeLogin(login1B);
123 pwmgr.removeLogin(login2A);
124 pwmgr.removeLogin(login2B);
125 pwmgr.removeLogin(login2C);
126
127 SimpleTest.finish();
128 }
129
130 window.onload = startTest;
131 </script>
132 </pre>
133 </body>
134 </html>

mercurial