Chromium Code Reviews| Index: chrome/test/data/password/create_form_copy_on_submit.html |
| diff --git a/chrome/test/data/password/create_form_copy_on_submit.html b/chrome/test/data/password/create_form_copy_on_submit.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b3f352e6f9f922c1f0fe71e8a2c44dffc5517239 |
| --- /dev/null |
| +++ b/chrome/test/data/password/create_form_copy_on_submit.html |
| @@ -0,0 +1,55 @@ |
| +<!-- |
| +This page enables to simulate the following scenario: |
| +On password form submit, the page's JavaScript creates another |
|
engedy
2014/07/11 17:05:35
nit: Spell it out here more that there is a static
vabr (Chromium)
2014/07/11 18:15:47
Done.
|
| +form, copies the user's password into it, and submits that. |
| + |
| +The issue demonstrated here is that there is very little time |
| +between creating and submitting the second form. As observed in |
| +http://crbug.com/367768, PasswordManager is not able to process |
|
engedy
2014/07/11 17:05:35
nit: Add one more line here to describe the proble
vabr (Chromium)
2014/07/11 18:15:47
Done.
|
| +the form quickly enough in such cases. This test checks that it |
| +still makes use of the first form and works in this scenario. |
| +--> |
| +<html> |
| + <head> |
| + <script src="form_utils.js"></script> |
| + <script> |
| +function preCreatePasswordForm() { |
| + // Remember the filled in password + destroy the old form. |
| + var old_password = document.getElementById('password').value; |
| + document.getElementById('contains-form').innerText = ''; |
| + // Spin the message loop to let the deletion settle in. |
|
engedy
2014/07/11 17:05:35
Could you please describe more why this is needed?
vabr (Chromium)
2014/07/11 18:15:47
Done. The problem is I'm not sure it is needed. It
engedy
2014/07/11 18:26:11
Acknowledged.
|
| + window.setTimeout(createPasswordForm, 0, old_password); |
| +} |
| +function createPasswordForm(old_password) { |
| + // Create and append the new password form. It is almost the |
| + // same as the deleted one, only with a different action. |
| + addForm(createForm()); |
|
engedy
2014/07/11 17:05:36
This might be a terribly bad idea, but perhaps thi
vabr (Chromium)
2014/07/11 18:15:47
I'm not sure if it is a bad idea, I just don't see
engedy
2014/07/11 18:26:11
Yes, I wanted to reduce the duplication, but I thi
|
| + // Spin the message loop to let the creation settle in. |
| + window.setTimeout(postCreatePasswordForm, 0, old_password); |
| +} |
| +function postCreatePasswordForm(old_password) { |
| + // Copy over the old password + add a dummy username, and submit |
| + // the new form. |
| + document.getElementById('username').value = 'test'; |
| + document.getElementById('password').value = old_password; |
| + document.getElementById('submit-button').click(); |
| +} |
| + </script> |
| + <title>Test dynamically created password form</title> |
| + </head> |
| + <body> |
| + <div id="contains-form"> |
| + <form action="none.html"> |
| + Old Form (to visually distinguish it from the form it is replaced with): |
| + <label for="username">Username</label> |
| + <input type="text" id="username" name="username"> |
| + <label for="password">Password</label> |
| + <input type="password" id="password" name="password"> |
| + <input type="submit" id="submit-button" value="Don't click!"> |
| + </form> |
| + <button id="non-form-button" onclick="preCreatePasswordForm();"> |
| + Click! |
| + </button> |
| + </div> |
| + </body> |
| +</html> |