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

Side by Side Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 2772793002: Skip checking non-emptiness of username on In-Page Navigation. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 // autofill will actually fill. 2571 // autofill will actually fill.
2572 SimulateElementClick(kUsernameName); 2572 SimulateElementClick(kUsernameName);
2573 2573
2574 // Simulate a user clicking on the password element. This should produce a 2574 // Simulate a user clicking on the password element. This should produce a
2575 // dropdown with suggestion of all available usernames. 2575 // dropdown with suggestion of all available usernames.
2576 static_cast<PageClickListener*>(autofill_agent_) 2576 static_cast<PageClickListener*>(autofill_agent_)
2577 ->FormControlElementClicked(password_element_, false); 2577 ->FormControlElementClicked(password_element_, false);
2578 CheckSuggestions("", false); 2578 CheckSuggestions("", false);
2579 } 2579 }
2580 2580
2581 // Checks that an in-page navigation form submission could have an empty
2582 // username.
2583 TEST_F(PasswordAutofillAgentTest, InPageNavigationSubmissionUsernameIsEmpty) {
2584 username_element_.setValue(WebString());
2585 SimulatePasswordChange("random");
2586
2587 // Simulate that JavaScript removes the submitted form from DOM. That means
2588 // that a submission was successful.
2589 std::string remove_form =
2590 "var form = document.getElementById('LoginTestForm');"
2591 "form.parentNode.removeChild(form);";
2592 ExecuteJavaScriptForTests(remove_form.c_str());
2593
2594 static_cast<content::RenderFrameObserver*>(password_autofill_agent_)
2595 ->DidCommitProvisionalLoad(false, true);
2596 base::RunLoop().RunUntilIdle();
2597
2598 // Chect that the form was submitted with in-page navigation.
2599 EXPECT_TRUE(fake_driver_.called_inpage_navigation());
2600 EXPECT_EQ(base::string16(),
2601 fake_driver_.password_form_inpage_navigation()->username_value);
2602 EXPECT_EQ(ASCIIToUTF16("random"),
2603 fake_driver_.password_form_inpage_navigation()->password_value);
2604 }
2605
2581 } // namespace autofill 2606 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698