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

Unified Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 2915763003: [Password Manager] Show omnibox icon and anchored prompt once user start typing password (Closed)
Patch Set: Rebase Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_manager_browsertest.cc
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc
index fbd82cc30e6a2b88357ae8b34c8c016263134096..2ee854edbfd571507c9e815845a6032c605a5d5c 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -166,20 +166,6 @@ class ObservingAutofillClient
DISALLOW_COPY_AND_ASSIGN(ObservingAutofillClient);
};
-// For simplicity we assume that password store contains only 1 credential.
-void CheckThatCredentialsStored(
- password_manager::TestPasswordStore* password_store,
- const base::string16& username,
- const base::string16& password) {
- auto& passwords_map = password_store->stored_passwords();
- ASSERT_EQ(1u, passwords_map.size());
- auto& passwords_vector = passwords_map.begin()->second;
- ASSERT_EQ(1u, passwords_vector.size());
- const autofill::PasswordForm& form = passwords_vector[0];
- EXPECT_EQ(username, form.username_value);
- EXPECT_EQ(password, form.password_value);
-}
-
void TestPromptNotShown(const char* failure_message,
content::WebContents* web_contents,
content::RenderViewHost* rvh) {
@@ -193,7 +179,7 @@ void TestPromptNotShown(const char* failure_message,
ASSERT_TRUE(content::ExecuteScript(rvh, fill_and_submit));
observer.Wait();
- EXPECT_FALSE(BubbleObserver(web_contents).IsShowingSavePrompt());
+ EXPECT_FALSE(BubbleObserver(web_contents).IsSavePromptShownAutomatically());
}
} // namespace
@@ -218,16 +204,11 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) {
// Save the password and check the store.
BubbleObserver bubble_observer(WebContents());
- EXPECT_TRUE(bubble_observer.IsShowingSavePrompt());
+ EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically());
bubble_observer.AcceptSavePrompt();
WaitForPasswordStore();
- scoped_refptr<password_manager::TestPasswordStore> password_store =
- static_cast<password_manager::TestPasswordStore*>(
- PasswordStoreFactory::GetForProfile(
- browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
- .get());
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
+ CheckThatCredentialsStored(base::ASCIIToUTF16("temp"),
base::ASCIIToUTF16("random"));
}
@@ -269,7 +250,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
observer.Wait();
std::unique_ptr<BubbleObserver> prompt_observer(
new BubbleObserver(WebContents()));
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -287,7 +268,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('input_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -306,7 +287,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('submit_unrelated').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, LoginFailed) {
@@ -324,7 +305,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, LoginFailed) {
"document.getElementById('submit_failed').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, Redirects) {
@@ -340,7 +321,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, Redirects) {
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer1.Wait();
BubbleObserver bubble_observer(WebContents());
- EXPECT_TRUE(bubble_observer.IsShowingSavePrompt());
+ EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically());
// The redirection page now redirects via Javascript. We check that the
// bubble stays.
@@ -348,7 +329,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, Redirects) {
ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(
RenderFrameHost(), "window.location.href = 'done.html';"));
observer2.Wait();
- EXPECT_TRUE(bubble_observer.IsShowingSavePrompt());
+ EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -367,7 +348,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForDynamicForm) {
@@ -408,7 +389,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForDynamicForm) {
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(BubbleObserver(WebContents()).IsShowingSavePrompt());
+ EXPECT_TRUE(BubbleObserver(WebContents()).IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptForNavigation) {
@@ -421,7 +402,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptForNavigation) {
ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(
RenderFrameHost(), "window.location.href = 'done.html';"));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -446,7 +427,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill));
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -472,7 +453,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame));
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(
@@ -492,7 +473,7 @@ IN_PROC_BROWSER_TEST_F(
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(
@@ -515,7 +496,7 @@ IN_PROC_BROWSER_TEST_F(
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.SetPathToWaitFor("/password/failed.html");
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForXHRSubmit) {
@@ -534,7 +515,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForXHRSubmit) {
"document.getElementById('submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -552,7 +533,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"send_xhr()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -573,7 +554,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"send_xhr()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -603,7 +584,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
break;
}
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -634,7 +615,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
break;
}
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -660,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
break;
}
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(
@@ -687,7 +668,7 @@ IN_PROC_BROWSER_TEST_F(
break;
}
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForFetchSubmit) {
@@ -706,7 +687,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForFetchSubmit) {
"document.getElementById('submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -724,7 +705,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"send_fetch()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -745,7 +726,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"send_fetch()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -775,7 +756,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
break;
}
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -806,7 +787,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
break;
}
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(
@@ -833,7 +814,7 @@ IN_PROC_BROWSER_TEST_F(
break;
}
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(
@@ -860,7 +841,7 @@ IN_PROC_BROWSER_TEST_F(
break;
}
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptIfLinkClicked) {
@@ -877,7 +858,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptIfLinkClicked) {
"document.getElementById('link').click();";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -903,7 +884,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
first_observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
prompt_observer->AcceptSavePrompt();
// Now navigate to a login form that has similar HTML markup.
@@ -927,7 +908,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('input_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form));
second_observer.Wait();
- EXPECT_FALSE(second_prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(second_prompt_observer->IsSavePromptShownAutomatically());
// Verify that we sent two pings to Autofill. One vote for of PASSWORD for
// the current form, and one vote for ACCOUNT_CREATION_PASSWORD on the
@@ -964,7 +945,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -982,7 +963,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('input_submit_button_no_name').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1000,7 +981,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementsByName('input_submit_button_no_id')[0].click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1021,20 +1002,12 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"form.children[2].click()"; // form.children[2] is the submit button.
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
prompt_observer->AcceptSavePrompt();
// Check that credentials are stored.
- scoped_refptr<password_manager::TestPasswordStore> password_store =
- static_cast<password_manager::TestPasswordStore*>(
- PasswordStoreFactory::GetForProfile(
- browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
- .get());
-
WaitForPasswordStore();
- EXPECT_FALSE(password_store->IsEmpty());
-
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
+ CheckThatCredentialsStored(base::ASCIIToUTF16("temp"),
base::ASCIIToUTF16("random"));
}
@@ -1053,7 +1026,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('input_submit_button').click();";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1071,7 +1044,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('input_submit_button_http_error').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1202,7 +1175,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
new BubbleObserver(WebContents()));
NavigateToFile("/password/done.html");
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1220,7 +1193,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('input_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1237,7 +1210,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('input_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Test fix for crbug.com/368690.
@@ -1256,7 +1229,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptWhenReloading) {
chrome::NavigateParams params(browser(), url, ::ui::PAGE_TRANSITION_RELOAD);
ui_test_utils::NavigateToURL(&params);
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
// Test that if a form gets dynamically added between the form parsing and
@@ -1274,7 +1247,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
observer.Wait();
- EXPECT_TRUE(BubbleObserver(WebContents()).IsShowingSavePrompt());
+ EXPECT_TRUE(BubbleObserver(WebContents()).IsSavePromptShownAutomatically());
}
// Test that if a hidden form gets dynamically added between the form parsing
@@ -1377,13 +1350,11 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoLastLoadGoodLastLoad) {
// authentication.
ui_test_utils::NavigateToURLWithDisposition(
browser(), http_test_server.GetURL("/basic_auth"),
- WindowOpenDisposition::NEW_FOREGROUND_TAB,
- ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
+ WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
- content::WebContents* tab =
- browser()->tab_strip_model()->GetActiveWebContents();
- content::NavigationController* nav_controller = &tab->GetController();
- NavigationObserver nav_observer(tab);
+ content::NavigationController* nav_controller =
+ &WebContents()->GetController();
+ NavigationObserver nav_observer(WebContents());
WindowedAuthNeededObserver auth_needed_observer(nav_controller);
auth_needed_observer.Wait();
@@ -1399,8 +1370,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoLastLoadGoodLastLoad) {
// The password manager should be working correctly.
nav_observer.Wait();
WaitForPasswordStore();
- BubbleObserver bubble_observer(tab);
- EXPECT_TRUE(bubble_observer.IsShowingSavePrompt());
+ BubbleObserver bubble_observer(WebContents());
+ EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically());
bubble_observer.AcceptSavePrompt();
// Spin the message loop to make sure the password store had a chance to save
@@ -1429,7 +1400,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
observer.Wait();
WaitForPasswordStore();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Test that if login fails and content server pushes a different login form
@@ -1451,7 +1422,7 @@ IN_PROC_BROWSER_TEST_F(
observer.SetPathToWaitFor("/password/done_and_separate_login_form.html");
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(
@@ -1473,7 +1444,7 @@ IN_PROC_BROWSER_TEST_F(
observer.SetPathToWaitFor("/password/done_and_separate_login_form.html");
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
// Tests whether a attempted submission of a malicious credentials gets blocked.
@@ -1502,7 +1473,7 @@ IN_PROC_BROWSER_TEST_F(
WaitForPasswordStore();
BubbleObserver prompt_observer(WebContents());
- EXPECT_TRUE(prompt_observer.IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer.IsSavePromptShownAutomatically());
// Normally the redirect happens to done.html. Here an attack is simulated
// that hijacks the redirect to a attacker controlled page.
@@ -1517,7 +1488,7 @@ IN_PROC_BROWSER_TEST_F(
attacker_observer.SetPathToWaitFor("/password/simple_password.html");
attacker_observer.Wait();
- EXPECT_TRUE(prompt_observer.IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer.IsSavePromptShownAutomatically());
std::string fill_and_submit_attacker_form =
"document.getElementById('username_field').value = 'attacker_username';"
@@ -1530,18 +1501,12 @@ IN_PROC_BROWSER_TEST_F(
done_observer.SetPathToWaitFor("/password/done.html");
done_observer.Wait();
- EXPECT_TRUE(prompt_observer.IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer.IsSavePromptShownAutomatically());
prompt_observer.AcceptSavePrompt();
// Wait for password store and check that credentials are stored.
WaitForPasswordStore();
- scoped_refptr<password_manager::TestPasswordStore> password_store =
- static_cast<password_manager::TestPasswordStore*>(
- PasswordStoreFactory::GetForProfile(
- browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
- .get());
- EXPECT_FALSE(password_store->IsEmpty());
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("user"),
+ CheckThatCredentialsStored(base::ASCIIToUTF16("user"),
base::ASCIIToUTF16("password"));
}
@@ -1660,7 +1625,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
prompt_observer->AcceptSavePrompt();
WaitForPasswordStore();
@@ -1732,7 +1697,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Similar to the case above, but this time the form persists after
@@ -1755,7 +1720,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
// The password manager should distinguish forms with empty actions. After
@@ -1775,7 +1740,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('ea_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Similar to the case above, but this time the form persists after
@@ -1796,7 +1761,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('ea_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
// Current and target URLs contain different parameters and references. This
@@ -1818,7 +1783,7 @@ IN_PROC_BROWSER_TEST_F(
"document.getElementById('pa_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Similar to the case above, but this time the form persists after
@@ -1842,7 +1807,7 @@ IN_PROC_BROWSER_TEST_F(
"document.getElementById('pa_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1917,7 +1882,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('chg_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -1936,7 +1901,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('chg_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) {
@@ -1968,7 +1933,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) {
"window.history.back();";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_back));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
// Regression test for http://crbug.com/452306
@@ -1989,7 +1954,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('testform').submit();";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), change_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Regression test for http://crbug.com/451631
@@ -2013,7 +1978,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('testform').submit();";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
@@ -2040,7 +2005,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
break;
}
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Tests that if a site embeds the login and signup forms into one <form>, the
@@ -2093,7 +2058,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
std::string init_form = "sendMessage('fill_and_submit');";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), init_form));
init_observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
prompt_observer->AcceptSavePrompt();
// Visit the form again
@@ -2166,7 +2131,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"ifrmDoc.getElementById('input_submit_button').click();";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
prompt_observer->AcceptSavePrompt();
// Visit the form again
@@ -2294,17 +2259,12 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
// No credentials stored before, so save bubble is shown.
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
prompt_observer->AcceptSavePrompt();
+
// Check that credentials are stored.
- scoped_refptr<password_manager::TestPasswordStore> password_store =
- static_cast<password_manager::TestPasswordStore*>(
- PasswordStoreFactory::GetForProfile(
- browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
- .get());
WaitForPasswordStore();
- EXPECT_FALSE(password_store->IsEmpty());
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16(""),
+ CheckThatCredentialsStored(base::ASCIIToUTF16(""),
base::ASCIIToUTF16("new_pw"));
}
@@ -2338,7 +2298,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(),
fill_and_submit_change_password));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt());
+ EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically());
// We emulate that the user clicks "Update" button.
const autofill::PasswordForm& pending_credentials =
@@ -2347,7 +2307,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
prompt_observer->AcceptUpdatePrompt(pending_credentials);
WaitForPasswordStore();
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
+ CheckThatCredentialsStored(base::ASCIIToUTF16("temp"),
base::ASCIIToUTF16("new_pw"));
}
@@ -2384,13 +2344,13 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
observer.Wait();
// The stored password "pw" was overriden with "new_pw", so update prompt is
// expected.
- EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt());
+ EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically());
const autofill::PasswordForm stored_form =
password_store->stored_passwords().begin()->second[0];
prompt_observer->AcceptUpdatePrompt(stored_form);
WaitForPasswordStore();
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
+ CheckThatCredentialsStored(base::ASCIIToUTF16("temp"),
base::ASCIIToUTF16("new_pw"));
}
@@ -2421,8 +2381,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
observer.Wait();
// The stored password "pw" was not overriden, so update prompt is not
// expected.
- EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt());
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
+ EXPECT_FALSE(prompt_observer->IsUpdatePromptShownAutomatically());
+ CheckThatCredentialsStored(base::ASCIIToUTF16("temp"),
base::ASCIIToUTF16("pw"));
}
@@ -2457,13 +2417,13 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(),
fill_and_submit_change_password));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt());
+ EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically());
const autofill::PasswordForm stored_form =
password_store->stored_passwords().begin()->second[0];
prompt_observer->AcceptUpdatePrompt(stored_form);
WaitForPasswordStore();
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
+ CheckThatCredentialsStored(base::ASCIIToUTF16("temp"),
base::ASCIIToUTF16("new_pw"));
}
@@ -2933,11 +2893,6 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, InternalsPage_Browser) {
// username element when there are no stored credentials.
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
PasswordRetryFormSaveNoUsernameCredentials) {
- scoped_refptr<password_manager::TestPasswordStore> password_store =
- static_cast<password_manager::TestPasswordStore*>(
- PasswordStoreFactory::GetForProfile(
- browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
- .get());
// Check that password save bubble is shown.
NavigateToFile("/password/password_form.html");
NavigationObserver observer(WebContents());
@@ -2948,12 +2903,11 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('retry_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
prompt_observer->AcceptSavePrompt();
WaitForPasswordStore();
- CheckThatCredentialsStored(password_store.get(), base::string16(),
- base::ASCIIToUTF16("pw"));
+ CheckThatCredentialsStored(base::string16(), base::ASCIIToUTF16("pw"));
}
// Tests that no bubble shown when a password form without username submitted
@@ -2986,8 +2940,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('retry_submit_button').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
- EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
+ EXPECT_FALSE(prompt_observer->IsUpdatePromptShownAutomatically());
}
// Tests that the update bubble shown when a password form without username is
@@ -3017,14 +2971,14 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
// The new password "new_pw" is used, so update prompt is expected.
- EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt());
+ EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically());
const autofill::PasswordForm stored_form =
password_store->stored_passwords().begin()->second[0];
prompt_observer->AcceptUpdatePrompt(stored_form);
WaitForPasswordStore();
- CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
+ CheckThatCredentialsStored(base::ASCIIToUTF16("temp"),
base::ASCIIToUTF16("new_pw"));
}
@@ -3073,7 +3027,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
"document.getElementById('submit').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
- EXPECT_TRUE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically());
}
// Tests that password suggestions still work if the fields have the
@@ -3123,7 +3077,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(),
fill_and_submit_change_password));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
// Verify that the form's 'skip_zero_click' is not updated.
auto& passwords_map = password_store->stored_passwords();
@@ -3166,7 +3120,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(),
fill_and_submit_change_password));
observer.Wait();
- EXPECT_FALSE(prompt_observer->IsShowingSavePrompt());
+ EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
// Verify that the form's 'skip_zero_click' is not updated.
auto& passwords_map = password_store->stored_passwords();

Powered by Google App Engine
This is Rietveld 408576698