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

Unified Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 1184913002: [Password Manager] Suppress UI when password generation is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Second try Created 5 years, 6 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/renderer/autofill/password_autofill_agent_browsertest.cc
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
index 11a4e11d4ef996b5187b038e6aded668e055e21e..12198e733476a18612cf1288875ccf21b9ea4bb9 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -18,6 +18,7 @@
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/password_form_field_prediction_map.h"
#include "content/public/renderer/render_frame.h"
+#include "content/public/renderer/render_view.h"
please use gerrit instead 2015/06/16 00:53:23 Is this include necessary?
Garrett Casto 2015/06/16 06:15:04 Leftover from debugging, removed.
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebVector.h"
@@ -90,6 +91,14 @@ const char kNonVisibleFormHTML[] =
" </form>"
"</body>";
+const char kChangePasswordFormHTML[] =
+ "<FORM name='LoginTestForm' action='http://www.bidule.com'>"
+ " <INPUT type='password' id='old_password'/>"
+ " <INPUT type='password' id='new_password'/>"
+ " <INPUT type='password' id='confirm_password'/>"
+ " <INPUT type='submit' value='Login'/>"
+ "</FORM>";
+
const char kEmptyWebpage[] =
"<html>"
" <head>"
@@ -256,6 +265,10 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
LoadHTML(kFormHTML);
+ // Necessary for SimulateElementClick() to work correctly.
+ GetWebWidget()->resize(blink::WebSize(500, 500));
+ GetWebWidget()->setFocus(true);
+
// Now retrieve the input elements so the test can access them.
UpdateUsernameAndPasswordElements();
}
@@ -1863,4 +1876,42 @@ TEST_F(PasswordAutofillAgentTest,
ExpectFormSubmittedWithUsernameAndPasswords(kAliceUsername, "NewPass22", "");
}
+// If password generation is enabled for a field, password autofill should not
+// show UI.
+TEST_F(PasswordAutofillAgentTest, PasswordGenerationSupersedesAutofill) {
+ LoadHTML(kChangePasswordFormHTML);
+
+ // Update password_element_;
+ WebDocument document = GetMainFrame()->document();
+ WebElement element =
+ document.getElementById(WebString::fromUTF8("old_password"));
+ ASSERT_FALSE(element.isNull());
+ password_element_ = element.to<blink::WebInputElement>();
+
+ // Update fill_data_ for the new form and simulate filling.
+ fill_data_.wait_for_username = true;
+ fill_data_.username_field = FormFieldData();
+ fill_data_.password_field.name = base::ASCIIToUTF16("old_password");
+ UpdateOriginForHTML(kChangePasswordFormHTML);
+ SimulateOnFillPasswordForm(fill_data_);
+
+ // Simulate generation triggering.
+ SetNotBlacklistedMessage(password_generation_,
+ kChangePasswordFormHTML);
+ SetAccountCreationFormsDetectedMessage(password_generation_,
+ GetMainFrame()->document(),
+ 0);
+
+ // Simulate the field being clicked to start typing. This should trigger
+ // generation but not password autofill.
+ SetFocused(password_element_);
+ SimulateElementClick("old_password");
please use gerrit instead 2015/06/16 00:53:23 Shouldn't password generation trigger on "new_pass
Garrett Casto 2015/06/16 06:15:04 In general yes. The test for this is slightly cont
+ const IPC::Message* message =
+ render_thread_->sink().GetFirstMessageMatching(
+ AutofillHostMsg_ShowPasswordSuggestions::ID);
+ EXPECT_FALSE(message);
please use gerrit instead 2015/06/16 00:53:23 EXPECT_EQ(nullptr, render_thread_->sink().GetFirst
Garrett Casto 2015/06/16 06:15:04 Done.
+ ExpectPasswordGenerationAvailable(password_generation_,
+ true);
Ilya Sherman 2015/06/16 02:24:09 nit: No need to wrap here. (Might want to run "gi
Garrett Casto 2015/06/16 06:15:04 Done.
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698