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

Side by Side Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 1515553006: Change password bubble for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, clean-up Created 5 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override { 122 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override {
123 message_loop_runner_->Quit(); 123 message_loop_runner_->Quit();
124 } 124 }
125 125
126 private: 126 private:
127 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 127 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
128 128
129 DISALLOW_COPY_AND_ASSIGN(ObservingAutofillClient); 129 DISALLOW_COPY_AND_ASSIGN(ObservingAutofillClient);
130 }; 130 };
131 131
132 // For simplicity we assume that password store contains only 1 credentials.
132 void CheckThatCredentialsStored( 133 void CheckThatCredentialsStored(
133 password_manager::TestPasswordStore* password_store, 134 password_manager::TestPasswordStore* password_store,
134 const base::string16& username, 135 const base::string16& username,
135 const base::string16& password) { 136 const base::string16& password) {
136 auto& passwords_map = password_store->stored_passwords(); 137 auto& passwords_map = password_store->stored_passwords();
137 ASSERT_EQ(1u, passwords_map.size()); 138 ASSERT_EQ(1u, passwords_map.size());
138 auto& passwords_vector = passwords_map.begin()->second; 139 auto& passwords_vector = passwords_map.begin()->second;
139 ASSERT_EQ(1u, passwords_vector.size()); 140 ASSERT_EQ(1u, passwords_vector.size());
140 const autofill::PasswordForm& form = passwords_vector[0]; 141 const autofill::PasswordForm& form = passwords_vector[0];
141 EXPECT_EQ(username, form.username_value); 142 EXPECT_EQ(username, form.username_value);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 std::string fill_and_submit = 399 std::string fill_and_submit =
399 "document.getElementById('username_failed').value = 'temp';" 400 "document.getElementById('username_failed').value = 'temp';"
400 "document.getElementById('password_failed').value = 'random';" 401 "document.getElementById('password_failed').value = 'random';"
401 "document.getElementById('submit_failed').click();"; 402 "document.getElementById('submit_failed').click();";
402 403
403 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 404 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
404 observer.Wait(); 405 observer.Wait();
405 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); 406 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
406 } 407 }
407 408
408 // Disabled on Mac due to flakiness: crbug.com/493263
409 #if defined(OS_MACOSX)
410 #define MAYBE_NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage \
411 DISABLED_NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage
412 #else
413 #define MAYBE_NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage \
414 NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage
415 #endif
416 IN_PROC_BROWSER_TEST_F( 409 IN_PROC_BROWSER_TEST_F(
417 PasswordManagerBrowserTestBase, 410 PasswordManagerBrowserTestBase,
418 MAYBE_NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage) { 411 NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage) {
419 NavigateToFile("/password/multi_frames.html"); 412 NavigateToFile("/password/multi_frames.html");
420 413
421 // Make sure that we don't prompt to save the password for a failed login 414 // Make sure that we don't prompt to save the password for a failed login
422 // from a sub-frame with multiple frames in the same page. 415 // from a sub-frame with multiple frames in the same page.
423 NavigationObserver observer(WebContents()); 416 NavigationObserver observer(WebContents());
424 scoped_ptr<PromptObserver> prompt_observer( 417 scoped_ptr<PromptObserver> prompt_observer(
425 PromptObserver::Create(WebContents())); 418 PromptObserver::Create(WebContents()));
426 std::string fill_and_submit = 419 std::string fill_and_submit =
427 "var first_frame = document.getElementById('first_frame');" 420 "var first_frame = document.getElementById('first_frame');"
428 "var frame_doc = first_frame.contentDocument;" 421 "var frame_doc = first_frame.contentDocument;"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 PasswordStoreFactory::GetForProfile( 960 PasswordStoreFactory::GetForProfile(
968 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 961 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
969 .get()); 962 .get());
970 963
971 // Spin the message loop to make sure the password store had a chance to save 964 // Spin the message loop to make sure the password store had a chance to save
972 // the password. 965 // the password.
973 base::RunLoop run_loop; 966 base::RunLoop run_loop;
974 run_loop.RunUntilIdle(); 967 run_loop.RunUntilIdle();
975 EXPECT_FALSE(password_store->IsEmpty()); 968 EXPECT_FALSE(password_store->IsEmpty());
976 969
977 #if !defined(OS_MACOSX)
978 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), 970 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
979 base::ASCIIToUTF16("random")); 971 base::ASCIIToUTF16("random"));
980 #endif
981 } 972 }
982 973
983 // Test for checking that no prompt is shown for URLs with file: scheme. 974 // Test for checking that no prompt is shown for URLs with file: scheme.
984 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 975 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
985 NoPromptForFileSchemeURLs) { 976 NoPromptForFileSchemeURLs) {
986 GURL url = GetFileURL("password_form.html"); 977 GURL url = GetFileURL("password_form.html");
987 ui_test_utils::NavigateToURL(browser(), url); 978 ui_test_utils::NavigateToURL(browser(), url);
988 979
989 NavigationObserver observer(WebContents()); 980 NavigationObserver observer(WebContents());
990 scoped_ptr<PromptObserver> prompt_observer( 981 scoped_ptr<PromptObserver> prompt_observer(
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 1629
1639 content::SimulateMouseClickAt( 1630 content::SimulateMouseClickAt(
1640 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(left + 1, 1631 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(left + 1,
1641 top + 1)); 1632 top + 1));
1642 // Make sure the popup would be shown. 1633 // Make sure the popup would be shown.
1643 observing_autofill_client.Wait(); 1634 observing_autofill_client.Wait();
1644 } 1635 }
1645 1636
1646 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 1637 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
1647 ChangePwdFormBubbleShown) { 1638 ChangePwdFormBubbleShown) {
1639 // TODO(dvadym): Remove appending kEnablePasswordChangeSupport switch as soon as
1640 // it is removed on Mac. http://crbug.com/359315
1641 #if defined(OS_MACOSX)
1642 // Add the enable-password-change-support feature.
1643 base::FeatureList::ClearInstanceForTesting();
1644 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
1645 feature_list->InitializeFromCommandLine(
1646 password_manager::features::kEnablePasswordChangeSupport.name, "");
1647 base::FeatureList::SetInstance(std::move(feature_list));
1648 #endif
1648 NavigateToFile("/password/password_form.html"); 1649 NavigateToFile("/password/password_form.html");
1649 1650
1650 NavigationObserver observer(WebContents()); 1651 NavigationObserver observer(WebContents());
1651 scoped_ptr<PromptObserver> prompt_observer( 1652 scoped_ptr<PromptObserver> prompt_observer(
1652 PromptObserver::Create(WebContents())); 1653 PromptObserver::Create(WebContents()));
1653 std::string fill_and_submit = 1654 std::string fill_and_submit =
1654 "document.getElementById('chg_username_field').value = 'temp';" 1655 "document.getElementById('chg_username_field').value = 'temp';"
1655 "document.getElementById('chg_password_field').value = 'random';" 1656 "document.getElementById('chg_password_field').value = 'random';"
1656 "document.getElementById('chg_new_password_1').value = 'random1';" 1657 "document.getElementById('chg_new_password_1').value = 'random1';"
1657 "document.getElementById('chg_new_password_2').value = 'random1';" 1658 "document.getElementById('chg_new_password_2').value = 'random1';"
1658 "document.getElementById('chg_submit_button').click()"; 1659 "document.getElementById('chg_submit_button').click()";
1659 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 1660 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
1660 observer.Wait(); 1661 observer.Wait();
1661 // TODO(dvadym): Turn on this test when Change password UI will be implemented
1662 // for Mac. http://crbug.com/359315
1663 #if defined(OS_MACOSX)
1664 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
1665 #else
1666 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1662 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1667 #endif
1668 } 1663 }
1669 1664
1670 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 1665 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
1671 ChangePwdFormPushStateBubbleShown) { 1666 ChangePwdFormPushStateBubbleShown) {
1667 // TODO(dvadym): Remove appending kEnablePasswordChangeSupport switch as soon as
1668 // it is removed on Mac. http://crbug.com/359315
1669 #if defined(OS_MACOSX)
1670 // Add the enable-password-change-support feature.
1671 base::FeatureList::ClearInstanceForTesting();
1672 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
1673 feature_list->InitializeFromCommandLine(
1674 password_manager::features::kEnablePasswordChangeSupport.name, "");
1675 base::FeatureList::SetInstance(std::move(feature_list));
1676 #endif
1672 NavigateToFile("/password/password_push_state.html"); 1677 NavigateToFile("/password/password_push_state.html");
1673 1678
1674 NavigationObserver observer(WebContents()); 1679 NavigationObserver observer(WebContents());
1675 observer.set_quit_on_entry_committed(true); 1680 observer.set_quit_on_entry_committed(true);
1676 scoped_ptr<PromptObserver> prompt_observer( 1681 scoped_ptr<PromptObserver> prompt_observer(
1677 PromptObserver::Create(WebContents())); 1682 PromptObserver::Create(WebContents()));
1678 std::string fill_and_submit = 1683 std::string fill_and_submit =
1679 "document.getElementById('chg_username_field').value = 'temp';" 1684 "document.getElementById('chg_username_field').value = 'temp';"
1680 "document.getElementById('chg_password_field').value = 'random';" 1685 "document.getElementById('chg_password_field').value = 'random';"
1681 "document.getElementById('chg_new_password_1').value = 'random1';" 1686 "document.getElementById('chg_new_password_1').value = 'random1';"
1682 "document.getElementById('chg_new_password_2').value = 'random1';" 1687 "document.getElementById('chg_new_password_2').value = 'random1';"
1683 "document.getElementById('chg_submit_button').click()"; 1688 "document.getElementById('chg_submit_button').click()";
1684 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 1689 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
1685 observer.Wait(); 1690 observer.Wait();
1686 // TODO(dvadym): Turn on this test when Change password UI will be implemented
1687 // for Mac. http://crbug.com/359315
1688 #if defined(OS_MACOSX)
1689 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
1690 #else
1691 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1691 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1692 #endif
1693 } 1692 }
1694 1693
1695 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) { 1694 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) {
1696 // Go to a successful landing page through submitting first, so that it is 1695 // Go to a successful landing page through submitting first, so that it is
1697 // reachable through going back, and the remembered page transition is form 1696 // reachable through going back, and the remembered page transition is form
1698 // submit. There is no need to submit non-empty strings. 1697 // submit. There is no need to submit non-empty strings.
1699 NavigateToFile("/password/password_form.html"); 1698 NavigateToFile("/password/password_form.html");
1700 1699
1701 NavigationObserver dummy_submit_observer(WebContents()); 1700 NavigationObserver dummy_submit_observer(WebContents());
1702 std::string just_submit = 1701 std::string just_submit =
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 content::RenderProcessHostWatcher iframe_killed( 2029 content::RenderProcessHostWatcher iframe_killed(
2031 iframe->GetProcess(), 2030 iframe->GetProcess(),
2032 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 2031 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
2033 2032
2034 IPC::IpcSecurityTestUtil::PwnMessageReceived( 2033 IPC::IpcSecurityTestUtil::PwnMessageReceived(
2035 iframe->GetProcess()->GetChannel(), illegal_forms_parsed); 2034 iframe->GetProcess()->GetChannel(), illegal_forms_parsed);
2036 2035
2037 iframe_killed.Wait(); 2036 iframe_killed.Wait();
2038 } 2037 }
2039 2038
2040 // TODO(dvadym): Turn on this test when Change password UI will be implemented
2041 // for Mac. http://crbug.com/359315
2042 #if !defined(OS_MACOSX)
2043 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 2039 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
2044 ChangePwdNoAccountStored) { 2040 ChangePwdNoAccountStored) {
2041 #if defined(OS_MACOSX)
2042 // Add the enable-password-change-support feature.
2043 base::FeatureList::ClearInstanceForTesting();
2044 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
2045 feature_list->InitializeFromCommandLine(
2046 password_manager::features::kEnablePasswordChangeSupport.name, "");
2047 base::FeatureList::SetInstance(std::move(feature_list));
2048 #endif
2045 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); 2049 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled());
2046 NavigateToFile("/password/password_form.html"); 2050 NavigateToFile("/password/password_form.html");
2047 2051
2048 // Fill a form and submit through a <input type="submit"> button. 2052 // Fill a form and submit through a <input type="submit"> button.
2049 NavigationObserver observer(WebContents()); 2053 NavigationObserver observer(WebContents());
2050 scoped_ptr<PromptObserver> prompt_observer( 2054 scoped_ptr<PromptObserver> prompt_observer(
2051 PromptObserver::Create(WebContents())); 2055 PromptObserver::Create(WebContents()));
2052 2056
2053 std::string fill_and_submit = 2057 std::string fill_and_submit =
2054 "document.getElementById('chg_password_wo_username_field').value = " 2058 "document.getElementById('chg_password_wo_username_field').value = "
(...skipping 15 matching lines...) Expand all
2070 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 2074 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
2071 .get()); 2075 .get());
2072 // Spin the message loop to make sure the password store had a chance to save 2076 // Spin the message loop to make sure the password store had a chance to save
2073 // the password. 2077 // the password.
2074 base::RunLoop run_loop; 2078 base::RunLoop run_loop;
2075 run_loop.RunUntilIdle(); 2079 run_loop.RunUntilIdle();
2076 EXPECT_FALSE(password_store->IsEmpty()); 2080 EXPECT_FALSE(password_store->IsEmpty());
2077 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16(""), 2081 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16(""),
2078 base::ASCIIToUTF16("new_pw")); 2082 base::ASCIIToUTF16("new_pw"));
2079 } 2083 }
2080 #endif
2081 2084
2082 // TODO(dvadym): Turn on this test when Change password UI will be implemented
2083 // for Mac. http://crbug.com/359315
2084 #if !defined(OS_MACOSX)
2085 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 2085 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
2086 ChangePwd1AccountStored) { 2086 ChangePwd1AccountStored) {
2087 #if defined(OS_MACOSX)
2088 // Add the enable-password-change-support feature.
2089 base::FeatureList::ClearInstanceForTesting();
2090 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
2091 feature_list->InitializeFromCommandLine(
2092 password_manager::features::kEnablePasswordChangeSupport.name, "");
2093 base::FeatureList::SetInstance(std::move(feature_list));
2094 #endif
2087 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); 2095 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled());
2088 // At first let us save credentials to the PasswordManager. 2096 // At first let us save credentials to the PasswordManager.
2089 scoped_refptr<password_manager::TestPasswordStore> password_store = 2097 scoped_refptr<password_manager::TestPasswordStore> password_store =
2090 static_cast<password_manager::TestPasswordStore*>( 2098 static_cast<password_manager::TestPasswordStore*>(
2091 PasswordStoreFactory::GetForProfile( 2099 PasswordStoreFactory::GetForProfile(
2092 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 2100 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
2093 .get()); 2101 .get());
2094 autofill::PasswordForm signin_form; 2102 autofill::PasswordForm signin_form;
2095 signin_form.signon_realm = embedded_test_server()->base_url().spec(); 2103 signin_form.signon_realm = embedded_test_server()->base_url().spec();
2096 signin_form.password_value = base::ASCIIToUTF16("pw"); 2104 signin_form.password_value = base::ASCIIToUTF16("pw");
(...skipping 24 matching lines...) Expand all
2121 ->GetPendingPassword(); 2129 ->GetPendingPassword();
2122 prompt_observer->AcceptUpdatePrompt(pending_credentials); 2130 prompt_observer->AcceptUpdatePrompt(pending_credentials);
2123 2131
2124 // Spin the message loop to make sure the password store had a chance to 2132 // Spin the message loop to make sure the password store had a chance to
2125 // update the password. 2133 // update the password.
2126 base::RunLoop run_loop; 2134 base::RunLoop run_loop;
2127 run_loop.RunUntilIdle(); 2135 run_loop.RunUntilIdle();
2128 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), 2136 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
2129 base::ASCIIToUTF16("new_pw")); 2137 base::ASCIIToUTF16("new_pw"));
2130 } 2138 }
2131 #endif
2132 2139
2133 // TODO(dvadym): Turn on this test when Change password UI will be implemented
2134 // for Mac. http://crbug.com/359315
2135 #if !defined(OS_MACOSX)
2136 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 2140 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
2137 PasswordOverridenUpdateBubbleShown) { 2141 PasswordOverridenUpdateBubbleShown) {
2142 #if defined(OS_MACOSX)
2143 // Add the enable-password-change-support feature.
2144 base::FeatureList::ClearInstanceForTesting();
2145 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
2146 feature_list->InitializeFromCommandLine(
2147 password_manager::features::kEnablePasswordChangeSupport.name, "");
2148 base::FeatureList::SetInstance(std::move(feature_list));
2149 #endif
2138 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); 2150 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled());
2139 // At first let us save credentials to the PasswordManager. 2151 // At first let us save credentials to the PasswordManager.
2140 scoped_refptr<password_manager::TestPasswordStore> password_store = 2152 scoped_refptr<password_manager::TestPasswordStore> password_store =
2141 static_cast<password_manager::TestPasswordStore*>( 2153 static_cast<password_manager::TestPasswordStore*>(
2142 PasswordStoreFactory::GetForProfile( 2154 PasswordStoreFactory::GetForProfile(
2143 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 2155 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
2144 .get()); 2156 .get());
2145 autofill::PasswordForm signin_form; 2157 autofill::PasswordForm signin_form;
2146 signin_form.signon_realm = embedded_test_server()->base_url().spec(); 2158 signin_form.signon_realm = embedded_test_server()->base_url().spec();
2147 signin_form.username_value = base::ASCIIToUTF16("temp"); 2159 signin_form.username_value = base::ASCIIToUTF16("temp");
(...skipping 18 matching lines...) Expand all
2166 const autofill::PasswordForm stored_form = 2178 const autofill::PasswordForm stored_form =
2167 password_store->stored_passwords().begin()->second[0]; 2179 password_store->stored_passwords().begin()->second[0];
2168 prompt_observer->AcceptUpdatePrompt(stored_form); 2180 prompt_observer->AcceptUpdatePrompt(stored_form);
2169 // Spin the message loop to make sure the password store had a chance to 2181 // Spin the message loop to make sure the password store had a chance to
2170 // update the password. 2182 // update the password.
2171 base::RunLoop run_loop; 2183 base::RunLoop run_loop;
2172 run_loop.RunUntilIdle(); 2184 run_loop.RunUntilIdle();
2173 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), 2185 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
2174 base::ASCIIToUTF16("new_pw")); 2186 base::ASCIIToUTF16("new_pw"));
2175 } 2187 }
2176 #endif
2177 2188
2178 // TODO(dvadym): Turn on this test when Change password UI will be implemented
2179 // for Mac. http://crbug.com/359315
2180 #if !defined(OS_MACOSX)
2181 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 2189 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
2182 PasswordNotOverridenUpdateBubbleNotShown) { 2190 PasswordNotOverridenUpdateBubbleNotShown) {
2191 #if defined(OS_MACOSX)
2192 // Add the enable-password-change-support feature.
2193 base::FeatureList::ClearInstanceForTesting();
2194 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
2195 feature_list->InitializeFromCommandLine(
2196 password_manager::features::kEnablePasswordChangeSupport.name, "");
2197 base::FeatureList::SetInstance(std::move(feature_list));
2198 #endif
2183 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); 2199 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled());
2184 // At first let us save credentials to the PasswordManager. 2200 // At first let us save credentials to the PasswordManager.
2185 scoped_refptr<password_manager::TestPasswordStore> password_store = 2201 scoped_refptr<password_manager::TestPasswordStore> password_store =
2186 static_cast<password_manager::TestPasswordStore*>( 2202 static_cast<password_manager::TestPasswordStore*>(
2187 PasswordStoreFactory::GetForProfile( 2203 PasswordStoreFactory::GetForProfile(
2188 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 2204 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
2189 .get()); 2205 .get());
2190 autofill::PasswordForm signin_form; 2206 autofill::PasswordForm signin_form;
2191 signin_form.signon_realm = embedded_test_server()->base_url().spec(); 2207 signin_form.signon_realm = embedded_test_server()->base_url().spec();
2192 signin_form.username_value = base::ASCIIToUTF16("temp"); 2208 signin_form.username_value = base::ASCIIToUTF16("temp");
(...skipping 10 matching lines...) Expand all
2203 "document.getElementById('password_field').value = 'pw';" 2219 "document.getElementById('password_field').value = 'pw';"
2204 "document.getElementById('input_submit_button').click()"; 2220 "document.getElementById('input_submit_button').click()";
2205 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 2221 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
2206 observer.Wait(); 2222 observer.Wait();
2207 // The stored password "pw" was not overriden, so update prompt is not 2223 // The stored password "pw" was not overriden, so update prompt is not
2208 // expected. 2224 // expected.
2209 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); 2225 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt());
2210 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), 2226 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
2211 base::ASCIIToUTF16("pw")); 2227 base::ASCIIToUTF16("pw"));
2212 } 2228 }
2213 #endif
2214 2229
2215 // TODO(dvadym): Turn on this test when Change password UI will be implemented
2216 // for Mac. http://crbug.com/359315
2217 #if !defined(OS_MACOSX)
2218 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 2230 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
2219 ChangePwdWhenTheFormContainNotUsernameTextfield) { 2231 ChangePwdWhenTheFormContainNotUsernameTextfield) {
2232 #if defined(OS_MACOSX)
2233 // Add the enable-password-change-support feature.
2234 base::FeatureList::ClearInstanceForTesting();
2235 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
2236 feature_list->InitializeFromCommandLine(
2237 password_manager::features::kEnablePasswordChangeSupport.name, "");
2238 base::FeatureList::SetInstance(std::move(feature_list));
2239 #endif
vasilii 2015/12/15 15:58:01 Shouldn't it go to the test's setup?
dvadym 2015/12/16 14:16:30 It will be removed with the flag in a couple of we
2220 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); 2240 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled());
2221 // At first let us save credentials to the PasswordManager. 2241 // At first let us save credentials to the PasswordManager.
2222 scoped_refptr<password_manager::TestPasswordStore> password_store = 2242 scoped_refptr<password_manager::TestPasswordStore> password_store =
2223 static_cast<password_manager::TestPasswordStore*>( 2243 static_cast<password_manager::TestPasswordStore*>(
2224 PasswordStoreFactory::GetForProfile( 2244 PasswordStoreFactory::GetForProfile(
2225 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 2245 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
2226 .get()); 2246 .get());
2227 autofill::PasswordForm signin_form; 2247 autofill::PasswordForm signin_form;
2228 signin_form.signon_realm = embedded_test_server()->base_url().spec(); 2248 signin_form.signon_realm = embedded_test_server()->base_url().spec();
2229 signin_form.password_value = base::ASCIIToUTF16("pw"); 2249 signin_form.password_value = base::ASCIIToUTF16("pw");
(...skipping 22 matching lines...) Expand all
2252 const autofill::PasswordForm stored_form = 2272 const autofill::PasswordForm stored_form =
2253 password_store->stored_passwords().begin()->second[0]; 2273 password_store->stored_passwords().begin()->second[0];
2254 prompt_observer->AcceptUpdatePrompt(stored_form); 2274 prompt_observer->AcceptUpdatePrompt(stored_form);
2255 // Spin the message loop to make sure the password store had a chance to 2275 // Spin the message loop to make sure the password store had a chance to
2256 // update the password. 2276 // update the password.
2257 base::RunLoop run_loop; 2277 base::RunLoop run_loop;
2258 run_loop.RunUntilIdle(); 2278 run_loop.RunUntilIdle();
2259 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), 2279 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
2260 base::ASCIIToUTF16("new_pw")); 2280 base::ASCIIToUTF16("new_pw"));
2261 } 2281 }
2262 #endif
2263 2282
2264 // Test whether the password form with the username and password fields having 2283 // Test whether the password form with the username and password fields having
2265 // ambiguity in id attribute gets autofilled correctly. 2284 // ambiguity in id attribute gets autofilled correctly.
2266 IN_PROC_BROWSER_TEST_F( 2285 IN_PROC_BROWSER_TEST_F(
2267 PasswordManagerBrowserTestBase, 2286 PasswordManagerBrowserTestBase,
2268 AutofillSuggestionsForPasswordFormWithAmbiguousIdAttribute) { 2287 AutofillSuggestionsForPasswordFormWithAmbiguousIdAttribute) {
2269 // At first let us save credentials to the PasswordManager. 2288 // At first let us save credentials to the PasswordManager.
2270 scoped_refptr<password_manager::PasswordStore> password_store = 2289 scoped_refptr<password_manager::PasswordStore> password_store =
2271 PasswordStoreFactory::GetForProfile(browser()->profile(), 2290 PasswordStoreFactory::GetForProfile(browser()->profile(),
2272 ServiceAccessType::IMPLICIT_ACCESS); 2291 ServiceAccessType::IMPLICIT_ACCESS);
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 std::string submit = 2919 std::string submit =
2901 "document.getElementById('username').value = 'temp';" 2920 "document.getElementById('username').value = 'temp';"
2902 "document.getElementById('password').value = 'mypassword';" 2921 "document.getElementById('password').value = 'mypassword';"
2903 "document.getElementById('submit').click();"; 2922 "document.getElementById('submit').click();";
2904 VerifyPasswordIsSavedAndFilled( 2923 VerifyPasswordIsSavedAndFilled(
2905 "/password/password_autocomplete_off_test.html", submit, "password", 2924 "/password/password_autocomplete_off_test.html", submit, "password",
2906 "mypassword"); 2925 "mypassword");
2907 } 2926 }
2908 2927
2909 } // namespace password_manager 2928 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698