summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_basic_form_3pw_1.html
blob: 59aec20612f3558b03f1c10f132aafaca224057c (plain)
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
256
257
258
259
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test autofill for forms with 3 password fields</title>
  <script 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: forms with 3 password fields (form filling)
<script>
gTestDependsOnDeprecatedLogin = true;
runChecksAfterCommonInit(() => startTest());

let DEFAULT_ORIGIN = window.location.origin;
</script>
<p id="display"></p>

<div id="content" style="display: none">
</div>

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

/** Test for Login Manager: form fill, 3 password fields **/

// Test to make sure 3-password forms are filled properly.

async function startTest() {
  let win = window.open("about:blank");
  SimpleTest.registerCleanupFunction(() => win.close());
  await loadFormIntoWindow(DEFAULT_ORIGIN, `
    <p>The next three forms are <b>user/pass/passB/passC</b>, as all-empty, preuser(only), and preuser/pass</p>
    <form id="form1" action="formtest.js">
      <input  type="text"       name="uname">
      <input  type="password"   name="pword">
      <input  type="password"   name="qword">
      <input  type="password"   name="rword">

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

    <form id="form2" action="formtest.js">
      <input  type="text"       name="uname"  value="testuser">
      <input  type="password"   name="pword">
      <input  type="password"   name="qword">
      <input  type="password"   name="rword">

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

    <form id="form3" action="formtest.js">
      <input  type="text"       name="uname"  value="testuser">
      <input  type="password"   name="pword"  value="testpass">
      <input  type="password"   name="qword">
      <input  type="password"   name="rword">

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


    <p>The next three forms are <b>user/passB/pass/passC</b>, as all-empty, preuser(only), and preuser/pass</p>
    <form id="form4" action="formtest.js">
      <input  type="text"       name="uname">
      <input  type="password"   name="qword">
      <input  type="password"   name="pword">
      <input  type="password"   name="rword">

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

    <form id="form5" action="formtest.js">
      <input  type="text"       name="uname"  value="testuser">
      <input  type="password"   name="qword">
      <input  type="password"   name="pword">
      <input  type="password"   name="rword">

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

    <form id="form6" action="formtest.js">
      <input  type="text"       name="uname"  value="testuser">
      <input  type="password"   name="qword">
      <input  type="password"   name="pword"  value="testpass">
      <input  type="password"   name="rword">

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

    <p>The next three forms are <b>user/passB/passC/pass</b>, as all-empty, preuser(only), and preuser/pass</p>
    <form id="form7" action="formtest.js">
      <input  type="text"       name="uname">
      <input  type="password"   name="qword">
      <input  type="password"   name="rword">
      <input  type="password"   name="pword">

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

    <form id="form8" action="formtest.js">
      <input  type="text"       name="uname"  value="testuser">
      <input  type="password"   name="qword">
      <input  type="password"   name="rword">
      <input  type="password"   name="pword">

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

    <form id="form9" action="formtest.js">
      <input  type="text"       name="uname"  value="testuser">
      <input  type="password"   name="qword">
      <input  type="password"   name="rword">
      <input  type="password"   name="pword"  value="testpass">

      <button type="submit">Submit</button>
      <button type="reset"> Reset </button>
    </form>`, win, 9);

  let TESTCASES = [
    // Check form 1
    {
      formNum: 1,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 1"],
        ["pword", "testpass", "Checking password 1"],
        ["qword", "", "Checking password 1 (q)"],
        ["rword", "", "Checking password 1 (r)"],
      ],
    },
    // Check form 2
    {
      formNum: 2,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 2"],
        ["pword", "testpass", "Checking password 2"],
        ["qword", "", "Checking password 2 (q)"],
        ["rword", "", "Checking password 2 (r)"],
      ],
    },
    // Check form 3
    {
      formNum: 3,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 3"],
        ["pword", "testpass", "Checking password 3"],
        ["qword", "", "Checking password 3 (q)"],
        ["rword", "", "Checking password 3 (r)"],
      ],
    },
    // Check form 4
    {
      formNum: 4,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 4"],
        ["rword", "", "Checking password 4 (r)"],
      ],
      todoIsAssertionTuples: [
        ["qword", "", "Checking password 4 (q)"],
        ["pword", "testpass", "Checking password 4"],
      ],
    },
    // Check form 5
    {
      formNum: 5,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 5"],
        ["rword", "", "Checking password 5 (r)"],
      ],
      todoIsAssertionTuples: [
        ["qword", "", "Checking password 5 (q)"],
        ["pword", "testpass", "Checking password 5"],
      ],
    },
    // Check form 6
    {
      formNum: 6,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 6"],
        ["pword", "testpass", "Checking password 6"],
        ["rword", "", "Checking password 6 (r)"],
      ],
      todoIsAssertionTuples: [
        ["qword", "", "Checking password 6 (q)"],
      ],
    },
    // Check form 7
    {
      formNum: 7,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 7"],
        ["rword", "", "Checking password 7 (r)"],
      ],
      todoIsAssertionTuples: [
        ["qword", "", "Checking password 7 (q)"],
        ["pword", "testpass", "Checking password 7"],
      ],
    },
    // Check form 8
    {
      formNum: 8,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 8"],
        ["rword", "", "Checking password 8 (r)"],
      ],
      todoIsAssertionTuples: [
        ["qword", "", "Checking password 8 (q)"],
        ["pword", "testpass", "Checking password 8"],
      ],
    },
    // Check form 9
    {
      formNum: 9,
      isAssertionTuples: [
        ["uname", "testuser", "Checking username 9"],
        ["rword", "", "Checking password 9 (r)"],
        ["pword", "testpass", "Checking password 9"],
      ],
      todoIsAssertionTuples: [
        ["qword", "", "Checking password 9 (q)"],
      ],
    },
  ];

  await SpecialPowers.spawn(win, [TESTCASES], (testcasesF) => {
    let doc = this.content.document;
    for (let testcase of testcasesF) {
      let { formNum } = testcase;
      for (let tuple of testcase.isAssertionTuples) {
        let [name, value, message] = tuple;
        is(doc.querySelector(`#form${formNum} input[name=${name}]`).value, value, message);
      }
      if (!testcase.todoIsAssertionTuples) {
        continue;
      }
      // TODO: Bug 1669614
      // for (let tuple of testcase.todoIsAssertionTuples) {
      //   let [name, value, message] = tuple;
      //   todo_is(doc.querySelector(`#form${formNum} input[name=${name}]`).value, value, message);
      // }
    }
  });

  // TODO: as with the 2-password cases, add tests to check for creating new
  // logins and changing passwords.
  SimpleTest.finish();
}
</script>
</pre>
</body>
</html>