Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: chrome/test/data/password/password_xhr_submit.html

Issue 1012853002: [Password Manager] Use successful XHR submission as a signal for password saving (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/password/password_xhr_submit.html
diff --git a/chrome/test/data/password/password_xhr_submit.html b/chrome/test/data/password/password_xhr_submit.html
index 67ec93e2b8b0567b979a6dbda02f2efd3d13afe6..93fec20e0fb3bb778afa782cf8181a3439bcfb6b 100644
--- a/chrome/test/data/password/password_xhr_submit.html
+++ b/chrome/test/data/password/password_xhr_submit.html
@@ -2,9 +2,30 @@
<head>
<script>
+var navigate = true;
+
+// TODO(gcasto): Not sure why this is necessary, but calling
+// window.domAutomationController directly in setTimeout seemt to causes the
+// function to be evaluated inline.
+function delayedUpload() {
+ window.domAutomationController.send("XHR_FINISHED");
+}
+
function state_changed(xhr) {
- if (xhr.readyState == 4)
- window.top.location.href = "done.html";
+ if (xhr.readyState == 4) {
+ if (navigate) {
+ window.top.location.href = "done.html";
+ } else {
+ // Pretend like auth succeeded by hiding the login and signup forms.
+ document.getElementById("testform").style.display = "none";
+ document.getElementById("signup_testform").style.display = "none";
+ window.domAutomationController.setAutomationId(0);
+ // Delay upload so that handler in PasswordAutofillAgent can be run
+ // first. This will happen immediately after JS execution ends, so this
+ // shouldn't introduce any timing dependent flakes.
+ setTimeout(delayedUpload, 0);
+ }
+ }
}
function send_xhr() {
@@ -24,7 +45,8 @@ function send_xhr() {
<input type="submit" id="submit_button" name="submit_button">
</form>
-<form action="password_xhr_submit.html" id="signup_testform">
+<form action="password_xhr_submit.html" onsubmit="send_xhr(); return false;"
+ id="signup_testform">
<input type="text" id="signup_username_field" name="signup_username_field">
<input type="password" id="signup_password_field"
name="signup_password_field" autocomplete="new-password">
« no previous file with comments | « chrome/browser/password_manager/password_manager_browsertest.cc ('k') | components/autofill/content/renderer/autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698