| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/macros.h" | 5 #include "base/macros.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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 NavigationObserver observer(WebContents()); | 115 NavigationObserver observer(WebContents()); |
| 116 observer.SetPathToWaitFor("/password/done.html"); | 116 observer.SetPathToWaitFor("/password/done.html"); |
| 117 observer.Wait(); | 117 observer.Wait(); |
| 118 | 118 |
| 119 std::unique_ptr<PromptObserver> prompt_observer( | 119 std::unique_ptr<PromptObserver> prompt_observer( |
| 120 PromptObserver::Create(WebContents())); | 120 PromptObserver::Create(WebContents())); |
| 121 // The autofill password manager shouldn't react to the successful login. | 121 // The autofill password manager shouldn't react to the successful login. |
| 122 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 122 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest, SaveViaAPIAndAutofill) { |
| 126 NavigateToFile("/password/password_form.html"); |
| 127 std::string fill_password = |
| 128 "document.getElementById('username_field').value = 'user';" |
| 129 "document.getElementById('password_field').value = '12345';"; |
| 130 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_password)); |
| 131 |
| 132 // Call the API to save the form. |
| 133 ASSERT_TRUE(content::ExecuteScript( |
| 134 RenderViewHost(), |
| 135 "var c = new PasswordCredential({ id: 'user', password: '12345' });" |
| 136 "navigator.credentials.store(c);")); |
| 137 std::unique_ptr<PromptObserver> prompt_observer( |
| 138 PromptObserver::Create(WebContents())); |
| 139 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 140 prompt_observer->Dismiss(); |
| 141 |
| 142 NavigationObserver form_submit_observer(WebContents()); |
| 143 ASSERT_TRUE(content::ExecuteScript( |
| 144 RenderViewHost(), |
| 145 "document.getElementById('input_submit_button').click();")); |
| 146 form_submit_observer.Wait(); |
| 147 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 148 } |
| 149 |
| 125 } // namespace | 150 } // namespace |
| OLD | NEW |