| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/password_manager/password_manager_test_base.h" | 6 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 7 #include "chrome/browser/password_manager/password_store_factory.h" | 7 #include "chrome/browser/password_manager/password_store_factory.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.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 // focus. | 74 // focus. |
| 75 chrome::FocusLocationBar(browser()); | 75 chrome::FocusLocationBar(browser()); |
| 76 WaitForElementValue("username_field", "tempORARY"); | 76 WaitForElementValue("username_field", "tempORARY"); |
| 77 | 77 |
| 78 NavigationObserver navigation_observer(WebContents()); | 78 NavigationObserver navigation_observer(WebContents()); |
| 79 BubbleObserver prompt_observer(WebContents()); | 79 BubbleObserver prompt_observer(WebContents()); |
| 80 std::string submit = | 80 std::string submit = |
| 81 "document.getElementById('input_submit_button').click();"; | 81 "document.getElementById('input_submit_button').click();"; |
| 82 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 82 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
| 83 navigation_observer.Wait(); | 83 navigation_observer.Wait(); |
| 84 EXPECT_TRUE(prompt_observer.IsShowingSavePrompt()); | 84 EXPECT_TRUE(prompt_observer.IsSavePromptShownAutomatically()); |
| 85 prompt_observer.AcceptSavePrompt(); | 85 prompt_observer.AcceptSavePrompt(); |
| 86 | 86 |
| 87 // Spin the message loop to make sure the password store had a chance to save | 87 // Spin the message loop to make sure the password store had a chance to save |
| 88 // the password. | 88 // the password. |
| 89 WaitForPasswordStore(); | 89 WaitForPasswordStore(); |
| 90 EXPECT_FALSE(password_store->IsEmpty()); | 90 EXPECT_FALSE(password_store->IsEmpty()); |
| 91 | 91 |
| 92 // Verify that there are two saved password, the old password and the new | 92 // Verify that there are two saved password, the old password and the new |
| 93 // password. | 93 // password. |
| 94 password_manager::TestPasswordStore::PasswordMap stored_passwords = | 94 password_manager::TestPasswordStore::PasswordMap stored_passwords = |
| 95 password_store->stored_passwords(); | 95 password_store->stored_passwords(); |
| 96 EXPECT_EQ(1u, stored_passwords.size()); | 96 EXPECT_EQ(1u, stored_passwords.size()); |
| 97 EXPECT_EQ(2u, stored_passwords.begin()->second.size()); | 97 EXPECT_EQ(2u, stored_passwords.begin()->second.size()); |
| 98 EXPECT_EQ(base::UTF8ToUTF16("temp"), | 98 EXPECT_EQ(base::UTF8ToUTF16("temp"), |
| 99 (stored_passwords.begin()->second)[0].username_value); | 99 (stored_passwords.begin()->second)[0].username_value); |
| 100 EXPECT_EQ(base::UTF8ToUTF16("tempORARY"), | 100 EXPECT_EQ(base::UTF8ToUTF16("tempORARY"), |
| 101 (stored_passwords.begin()->second)[1].username_value); | 101 (stored_passwords.begin()->second)[1].username_value); |
| 102 } | 102 } |
| 103 | 103 |
| 104 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 105 ManualFallbackForSaving) { |
| 106 NavigateToFile("/password/password_form.html"); |
| 107 |
| 108 std::string focus("document.getElementById('password_field').focus();"); |
| 109 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), focus)); |
| 110 SimulateUserTypingInField(RenderViewHost(), WebContents(), "password_field"); |
| 111 BubbleObserver prompt_observer(WebContents()); |
| 112 prompt_observer.WaitForFallbackForSaving(); |
| 113 |
| 114 // The save prompt should be available but shouldn't pop up automatically. |
| 115 EXPECT_TRUE(prompt_observer.IsSavePromptAvailable()); |
| 116 EXPECT_FALSE(prompt_observer.IsSavePromptShownAutomatically()); |
| 117 |
| 118 prompt_observer.AcceptSavePrompt(); |
| 119 |
| 120 WaitForPasswordStore(); |
| 121 CheckThatCredentialsStored(base::string16(), base::ASCIIToUTF16("ORARY")); |
| 122 } |
| 123 |
| 104 } // namespace password_manager | 124 } // namespace password_manager |
| OLD | NEW |