File: test_bug_227640.html

package info (click to toggle)
wine-gecko-2.21 2.21%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 646,272 kB
  • ctags: 630,086
  • sloc: cpp: 2,895,786; ansic: 1,502,970; python: 156,675; asm: 115,373; java: 111,421; sh: 63,309; xml: 62,872; makefile: 58,685; perl: 19,182; objc: 3,461; yacc: 2,051; lex: 979; pascal: 929; exp: 449; php: 244; lisp: 228; awk: 211; sed: 26; csh: 21; ada: 16; ruby: 3
file content (255 lines) | stat: -rw-r--r-- 8,719 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Login Manager</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>  
  <script type="text/javascript" src="pwmgr_common.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
Login Manager test: 227640
<p id="display"></p>
<div id="content" style="display: none">
  
  <!-- no autocomplete for password field -->
  <form id="form1" onsubmit="return checkSubmit(1)" method="get">
    <input  type="text"       name="uname" value="">
    <input  type="password"   name="pword" value="" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for username field -->
  <form id="form2" onsubmit="return checkSubmit(2);" method="get">
    <input  type="text"       name="uname" value="" autocomplete=off>
    <input  type="password"   name="pword" value="">

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for username or password fields -->
  <form id="form3" onsubmit="return checkSubmit(3);" method="get">
    <input  type="text"       name="uname" value="" autocomplete=off>
    <input  type="password"   name="pword" value="" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form -->
  <form id="form4" onsubmit="return checkSubmit(4);" method="get" autocomplete=off>
    <input  type="text"       name="uname" value="">
    <input  type="password"   name="pword" value="">

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form and password field -->
  <form id="form5" onsubmit="return checkSubmit(5);" method="get">
    <input  type="text"       name="uname" value="">
    <input  type="password"   name="pword" value="" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form and username field -->
  <form id="form6" onsubmit="return checkSubmit(6);" method="get">
    <input  type="text"       name="uname" value="" autocomplete=off>
    <input  type="password"   name="pword" value="">

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form, userfield, and password field -->
  <form id="form7" onsubmit="return checkSubmit(7);" method="get" autocomplete=off>
    <input  type="text"       name="uname" value="" autocomplete=off>
    <input  type="password"   name="pword" value="" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>


  <!-- ===== repeat, but with logins not previously stored ===== -->


  <!-- no autocomplete for password field -->
  <form id="form8" onsubmit="return checkSubmit(8);" method="get">
    <input  type="text"       name="xxxuname" value="newuser">
    <input  type="password"   name="xxxpword" value="newpass" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for username field -->
  <form id="form9" onsubmit="return checkSubmit(9);" method="get">
    <input  type="text"       name="xxxuname" value="newuser" autocomplete=off>
    <input  type="password"   name="xxxpword" value="newpass">

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for username or password fields -->
  <form id="form10" onsubmit="return checkSubmit(10);" method="get">
    <input  type="text"       name="xxxuname" value="newuser" autocomplete=off>
    <input  type="password"   name="xxxpword" value="newpass" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form -->
  <form id="form11" onsubmit="return checkSubmit(11);" method="get" autocomplete=off>
    <input  type="text"       name="xxxuname" value="newuser">
    <input  type="password"   name="xxxpword" value="newpass">

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form and password field -->
  <form id="form12" onsubmit="return checkSubmit(12);" method="get">
    <input  type="text"       name="xxxuname" value="newuser">
    <input  type="password"   name="xxxpword" value="newpass" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form and username field -->
  <form id="form13" onsubmit="return checkSubmit(13);" method="get">
    <input  type="text"       name="xxxuname" value="newuser" autocomplete=off>
    <input  type="password"   name="xxxpword" value="newpass">

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

  <!-- no autocomplete for entire form, userfield, and password field -->
  <form id="form14" onsubmit="return checkSubmit(14);" method="get" autocomplete=off>
    <input  type="text"       name="xxxuname" value="newuser" autocomplete=off>
    <input  type="password"   name="xxxpword" value="newpass" autocomplete=off>

    <button type="submit">Submit</button>
    <button type="reset"> Reset </button>
  </form>

</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Login Manager: 227640 (password is saved even when the
    password field has autocomplete="off") **/
commonInit();

// This test ensures that pwmgr does not save a username or password when
// autocomplete=off is present.

var numStartingLogins = 0;
var numSubmittedForms = 0;

function startTest() {
  // Get current number of logins, so we can know if some accidently get
  // added during the test.
  numStartingLogins = countLogins();
  ok(numStartingLogins > 0, "counting logins at start");

  // Check first set of forms, which should not be filled by pwmgr.
  for (var i = 1; i <= 7; i++) {
    is($_(i, "uname").value, "", "Checking for unfilled username " + i);
    is($_(i, "pword").value, "", "Checking for unfilled password " + i);
    // Set the field values to that of an existing login
    $_(i, "uname").value = "testuser";
    $_(i, "pword").value = "testpass";
  }

  // Check second set of forms, which should have preset values (and are unknown to pwmgr).
  for (var i = 8; i <= 14; i++) {
    is($_(i, "xxxuname").value, "newuser", "Checking unmodified username " + i);
    is($_(i, "xxxpword").value, "newpass", "Checking unmodified password " + i);
  }

  var button = getFormSubmitButton(1);

  // submit the first form.
  button.click();
}


// Called by each form's onsubmit handler.
function checkSubmit(formNum) {
  numSubmittedForms++;

  // End the test at the last form.
  if (formNum == 14) {
    is(numSubmittedForms, 14, "Ensuring all forms were submitted.");;

    var numEndingLogins = countLogins();
    ok(numEndingLogins > 0, "counting logins at end");

    is(numStartingLogins, numEndingLogins, "counting logins at end");

    SimpleTest.finish();
    return false; // return false to cancel current form submission
  }

  var button = getFormSubmitButton(formNum + 1);

  // submit the next form.
  button.click();

  return false; // return false to cancel current form submission
}


function getFormSubmitButton(formNum) {
  var form = $("form" + formNum); // by id, not name
  ok(form != null, "getting form " + formNum);

  // we can't just call form.submit(), because that doesn't seem to
  // invoke the form onsubmit handler.
  var button = form.firstChild;
  while (button && button.type != "submit") { button = button.nextSibling; }
  ok(button != null, "getting form submit button");

  return button;
}

// Counts the number of logins currently stored by password manager.
function countLogins() {
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

  var logins = pwmgr.getAllLogins();

  return logins.length;
}

// Get the pwmgr service
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

var Cc_pwmgr = Components.classes["@mozilla.org/login-manager;1"];
ok(Cc_pwmgr != null, "Access Cc[@mozilla.org/login-manager;1]");

var Ci_pwmgr = Components.interfaces.nsILoginManager;
ok(Ci_pwmgr != null, "Access Ci.nsILoginManager");

var pwmgr = Cc_pwmgr.getService(Ci_pwmgr);
ok(pwmgr != null, "pwmgr getService()");


window.onload = startTest;

SimpleTest.waitForExplicitFinish();

</script>
</pre>
</body>
</html>