2 This page enables to simulate the following scenario:
3 On password form submit, the page's JavaScript deletes that form, creates
4 another one, almost an exact copy of the deleted form, just with a different
5 action, and submits the new one.
7 The issue demonstrated here is that there is very little time between
8 creating and submitting the second form. As observed in
9 http://crbug.com/367768, PasswordManager is not able to process the form
10 quickly enough in such cases: the PasswordFormManager associated with the
11 created form has not enough time to asynchronously get matching results from
12 the password store, and is hence not ready to provisionally save the new
13 credential. This test checks that PasswordManager still makes use of the
14 PasswordFormManager associated with the first form (which is a reasonable
15 match for the credential, though worse than the newer PasswordFormManager)
16 and works in this scenario.
20 <script src=
"form_utils.js"></script>
22 function preCreatePasswordForm() {
23 // Remember the filled in password + destroy the old form.
24 var old_password
= document
.getElementById('password').value
;
25 document
.getElementById('contains-form').innerText
= '';
26 // Spin the message loop: it's not clear spinning it is needed, but
27 // let's make sure the deletion side effects, if any, have time to
28 // propagate and don't cause flakes.
29 window
.setTimeout(createPasswordForm
, 0, old_password
);
31 function createPasswordForm(old_password
) {
32 // Create and append the new password form. It is almost the
33 // same as the deleted one, only with a different action.
34 document
.body
.appendChild(createSimplePasswordForm());
35 // Spin the message loop again, to let the creation settle in.
36 window
.setTimeout(postCreatePasswordForm
, 0, old_password
);
38 function postCreatePasswordForm(old_password
) {
39 // Copy over the old password + add a dummy username, and submit
41 document
.getElementById('username').value
= 'test';
42 document
.getElementById('password').value
= old_password
;
43 document
.getElementById('submit-button').click();
46 <title>Test dynamically created password form
</title>
49 <div id=
"contains-form">
50 <form action=
"none.html">
51 Old Form (to visually distinguish it from the form it is replaced with):
52 <label for=
"username">Username
</label>
53 <input type=
"text" id=
"username" name=
"username">
54 <label for=
"password">Password
</label>
55 <input type=
"password" id=
"password" name=
"password">
56 <input type=
"submit" id=
"submit-button" value=
"Don't click!">
58 <button id=
"non-form-button" onclick=
"preCreatePasswordForm();">