| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/password_manager/password_manager_test_base.h" | 7 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 8 #include "chrome/browser/password_manager/password_store_factory.h" | 8 #include "chrome/browser/password_manager/password_store_factory.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "components/password_manager/core/browser/test_password_store.h" | 10 #include "components/password_manager/core/browser/test_password_store.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 EXPECT_FALSE(password_store->IsEmpty()); | 74 EXPECT_FALSE(password_store->IsEmpty()); |
| 75 | 75 |
| 76 // Reload the original page to have the saved credentials autofilled. | 76 // Reload the original page to have the saved credentials autofilled. |
| 77 NavigationObserver reload_observer(WebContents()); | 77 NavigationObserver reload_observer(WebContents()); |
| 78 NavigateToFile("/password/signup_form.html"); | 78 NavigateToFile("/password/signup_form.html"); |
| 79 reload_observer.Wait(); | 79 reload_observer.Wait(); |
| 80 | 80 |
| 81 // Let the user interact with the page, so that DOM gets modification events, | 81 // Let the user interact with the page, so that DOM gets modification events, |
| 82 // needed for autofilling fields. | 82 // needed for autofilling fields. |
| 83 content::SimulateMouseClickAt( | 83 content::SimulateMouseClickAt( |
| 84 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); | 84 WebContents(), 0, blink::WebMouseEvent::Button::Left, gfx::Point(1, 1)); |
| 85 | 85 |
| 86 WaitForElementValue("username_field", "temp"); | 86 WaitForElementValue("username_field", "temp"); |
| 87 WaitForElementValue("password_field", "random"); | 87 WaitForElementValue("password_field", "random"); |
| 88 | 88 |
| 89 // Change username and submit. This should add the characters "ORARY" to the | 89 // Change username and submit. This should add the characters "ORARY" to the |
| 90 // already autofilled username. | 90 // already autofilled username. |
| 91 SimulateUserTypingInField(RenderViewHost(), WebContents(), "username_field"); | 91 SimulateUserTypingInField(RenderViewHost(), WebContents(), "username_field"); |
| 92 // TODO(gcasto): Not sure why this click is required. | 92 // TODO(gcasto): Not sure why this click is required. |
| 93 content::SimulateMouseClickAt( | 93 content::SimulateMouseClickAt( |
| 94 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); | 94 WebContents(), 0, blink::WebMouseEvent::Button::Left, gfx::Point(1, 1)); |
| 95 WaitForElementValue("username_field", "tempORARY"); | 95 WaitForElementValue("username_field", "tempORARY"); |
| 96 | 96 |
| 97 NavigationObserver second_observer(WebContents()); | 97 NavigationObserver second_observer(WebContents()); |
| 98 std::unique_ptr<BubbleObserver> second_prompt_observer( | 98 std::unique_ptr<BubbleObserver> second_prompt_observer( |
| 99 new BubbleObserver(WebContents())); | 99 new BubbleObserver(WebContents())); |
| 100 std::string submit = | 100 std::string submit = |
| 101 "document.getElementById('input_submit_button').click();"; | 101 "document.getElementById('input_submit_button').click();"; |
| 102 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 102 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
| 103 second_observer.Wait(); | 103 second_observer.Wait(); |
| 104 EXPECT_TRUE(second_prompt_observer->IsShowingSavePrompt()); | 104 EXPECT_TRUE(second_prompt_observer->IsShowingSavePrompt()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 116 password_store->stored_passwords(); | 116 password_store->stored_passwords(); |
| 117 EXPECT_EQ(1u, stored_passwords.size()); | 117 EXPECT_EQ(1u, stored_passwords.size()); |
| 118 EXPECT_EQ(2u, stored_passwords.begin()->second.size()); | 118 EXPECT_EQ(2u, stored_passwords.begin()->second.size()); |
| 119 EXPECT_EQ(base::UTF8ToUTF16("temp"), | 119 EXPECT_EQ(base::UTF8ToUTF16("temp"), |
| 120 (stored_passwords.begin()->second)[0].username_value); | 120 (stored_passwords.begin()->second)[0].username_value); |
| 121 EXPECT_EQ(base::UTF8ToUTF16("tempORARY"), | 121 EXPECT_EQ(base::UTF8ToUTF16("tempORARY"), |
| 122 (stored_passwords.begin()->second)[1].username_value); | 122 (stored_passwords.begin()->second)[1].username_value); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace password_manager | 125 } // namespace password_manager |
| OLD | NEW |