| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script> | 3 <script> |
| 4 | 4 |
| 5 var navigate = true; |
| 6 |
| 7 // TODO(gcasto): Not sure why this is necessary, but calling |
| 8 // window.domAutomationController directly in setTimeout seemt to causes the |
| 9 // function to be evaluated inline. |
| 10 function delayedUpload() { |
| 11 window.domAutomationController.send("XHR_FINISHED"); |
| 12 } |
| 13 |
| 5 function state_changed(xhr) { | 14 function state_changed(xhr) { |
| 6 if (xhr.readyState == 4) | 15 if (xhr.readyState == 4) { |
| 7 window.top.location.href = "done.html"; | 16 if (navigate) { |
| 17 window.top.location.href = "done.html"; |
| 18 } else { |
| 19 // Pretend like auth succeeded by hiding the login and signup forms. |
| 20 document.getElementById("testform").style.display = "none"; |
| 21 document.getElementById("signup_testform").style.display = "none"; |
| 22 window.domAutomationController.setAutomationId(0); |
| 23 // Delay upload so that handler in PasswordAutofillAgent can be run |
| 24 // first. This will happen immediately after JS execution ends, so this |
| 25 // shouldn't introduce any timing dependent flakes. |
| 26 setTimeout(delayedUpload, 0); |
| 27 } |
| 28 } |
| 8 } | 29 } |
| 9 | 30 |
| 10 function send_xhr() { | 31 function send_xhr() { |
| 11 var xhr = new XMLHttpRequest(); | 32 var xhr = new XMLHttpRequest(); |
| 12 xhr.onreadystatechange = function() { state_changed(xhr); }; | 33 xhr.onreadystatechange = function() { state_changed(xhr); }; |
| 13 xhr.open("GET", "password_xhr_submit.html", true); | 34 xhr.open("GET", "password_xhr_submit.html", true); |
| 14 xhr.send(null); | 35 xhr.send(null); |
| 15 } | 36 } |
| 16 | 37 |
| 17 </script> | 38 </script> |
| 18 </head> | 39 </head> |
| 19 <body> | 40 <body> |
| 20 <form action="password_xhr_submit.html" onsubmit="send_xhr(); return false;" | 41 <form action="password_xhr_submit.html" onsubmit="send_xhr(); return false;" |
| 21 id="testform"> | 42 id="testform"> |
| 22 <input type="text" id="username_field" name="username_field"> | 43 <input type="text" id="username_field" name="username_field"> |
| 23 <input type="password" id="password_field" name="password_field"> | 44 <input type="password" id="password_field" name="password_field"> |
| 24 <input type="submit" id="submit_button" name="submit_button"> | 45 <input type="submit" id="submit_button" name="submit_button"> |
| 25 </form> | 46 </form> |
| 26 | 47 |
| 27 <form action="password_xhr_submit.html" id="signup_testform"> | 48 <form action="password_xhr_submit.html" onsubmit="send_xhr(); return false;" |
| 49 id="signup_testform"> |
| 28 <input type="text" id="signup_username_field" name="signup_username_field"> | 50 <input type="text" id="signup_username_field" name="signup_username_field"> |
| 29 <input type="password" id="signup_password_field" | 51 <input type="password" id="signup_password_field" |
| 30 name="signup_password_field" autocomplete="new-password"> | 52 name="signup_password_field" autocomplete="new-password"> |
| 31 <input type="password" id="confirmation_password_field" | 53 <input type="password" id="confirmation_password_field" |
| 32 name="confirmation_password_field" autocomplete="new-password"> | 54 name="confirmation_password_field" autocomplete="new-password"> |
| 33 <input type="submit" id="signup_submit_button" name="signup_submit_button"> | 55 <input type="submit" id="signup_submit_button" name="signup_submit_button"> |
| 34 </form> | 56 </form> |
| 35 </body> | 57 </body> |
| 36 </html> | 58 </html> |
| OLD | NEW |